Mercurial > hg > Members > kono > Cerium
view TaskManager/kernel/ppe/BufferManager.cc @ 44:b51daa049bc3
*** empty log message ***
author | gongo |
---|---|
date | Thu, 14 Feb 2008 19:49:43 +0900 |
parents | db136fb5c21d |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include "BufferManager.h" #include "error.h" BufferManager::BufferManager(int siz) { buffer_db_size = siz*4; } void BufferManager::init(void) { buffer_db = new void*[buffer_db_size]; buffer_db_index = 0; } /** * Fix me * アライメントできる create も必要 (spe 用に) * あと、オブジェクトだったら new しないとだめか。 * コンストラクタ呼ぶ必要があるのかー。 * 汎用の allocate ってことは templete ?いやだー */ void* BufferManager::create_buffer(int size) { void *buf1, *buf2; buf1 = malloc(size); buf2 = malloc(size); register_double_buffer(buf1, buf2); return buf1; } void* BufferManager::switch_buffer(void* cur) { int next_index; int max = buffer_db_size; for (int i = 0; i < buffer_db_size; i = i + 2) { if (cur == buffer_db[i]) { next_index = (int)(buffer_db[i+1]); return buffer_db[i + next_index]; } } __debug_ppe("buffer 0x%x is not registered\n", (unsigned int)cur); return NULL; } int BufferManager::register_double_buffer(void *buf1, void *buf2) { /** * Fix me * buffer_db_size 超えた時の処理 * 今は単純に -1 < 0 を返す */ if (buffer_db_index == buffer_db_size) { return -1; } buffer_db[buffer_db_index++] = buf1; buffer_db[buffer_db_index++] = (void*)2; buffer_db[buffer_db_index++] = buf2; buffer_db[buffer_db_index++] = (void*)-2; return 0; }