Mercurial > hg > Members > yutaka > manager
annotate ppe/Sys.cc @ 2:1e1b0d280427
commit
author | yutaka@localhost.localdomain |
---|---|
date | Wed, 07 Apr 2010 05:18:52 +0900 |
parents | dcd83cefb980 |
children | 8b4d6bf8c43d |
rev | line source |
---|---|
0 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include "Sys.h" | |
4 | |
2 | 5 task_t* |
6 add_list(task_t *tail, task_t *task) | |
7 { | |
8 | |
9 tail->head->next_task = (unsigned long long) (unsigned long) task->head; | |
10 tail->head->next_task_size = task->task_size; | |
11 | |
12 task->head->next_task = 0; | |
13 task->head->next_task_size = 0; | |
14 | |
15 return task; | |
16 | |
17 } | |
18 | |
19 void | |
20 set_pin(task_t *task, int pin_in, int pin_out) | |
21 { | |
22 | |
23 task->head->pin_in = pin_in; | |
24 task->head->pin_out = pin_out; | |
25 | |
26 } | |
27 | |
0 | 28 int |
29 size_fix(int size, int fix) | |
30 { | |
31 | |
32 //16の倍数にする | |
33 size = ((size + fix -1) / fix)*fix; | |
34 | |
35 return size; | |
36 | |
37 } | |
38 | |
39 void* | |
40 allocate(int size) | |
41 { | |
42 | |
43 int alignment = 16; | |
44 size = size_fix(size, alignment); | |
45 | |
46 void *buff; | |
47 posix_memalign(&buff, alignment, size); | |
48 return buff; | |
49 | |
50 } | |
51 | |
1
dcd83cefb980
check , ppe_only, show time , function add.
yutaka@localhost.localdomain
parents:
0
diff
changeset
|
52 void |
2 | 53 fix_type(task_t *task, void *buff) |
1
dcd83cefb980
check , ppe_only, show time , function add.
yutaka@localhost.localdomain
parents:
0
diff
changeset
|
54 { |
dcd83cefb980
check , ppe_only, show time , function add.
yutaka@localhost.localdomain
parents:
0
diff
changeset
|
55 |
dcd83cefb980
check , ppe_only, show time , function add.
yutaka@localhost.localdomain
parents:
0
diff
changeset
|
56 char *p; |
dcd83cefb980
check , ppe_only, show time , function add.
yutaka@localhost.localdomain
parents:
0
diff
changeset
|
57 p = (char*)buff; |
2 | 58 p = p + sizeof(task_head_t); |
1
dcd83cefb980
check , ppe_only, show time , function add.
yutaka@localhost.localdomain
parents:
0
diff
changeset
|
59 |
2 | 60 task->head = (task_head_t*)buff; |
61 task->input = p; | |
1
dcd83cefb980
check , ppe_only, show time , function add.
yutaka@localhost.localdomain
parents:
0
diff
changeset
|
62 |
dcd83cefb980
check , ppe_only, show time , function add.
yutaka@localhost.localdomain
parents:
0
diff
changeset
|
63 } |
dcd83cefb980
check , ppe_only, show time , function add.
yutaka@localhost.localdomain
parents:
0
diff
changeset
|
64 |
2 | 65 task_t* |
66 task_allocate(int in_size, int out_size) | |
0 | 67 { |
68 | |
2 | 69 if (in_size % 16) { |
70 printf("allocate in_size is not multiple of 16\n"); | |
71 } | |
72 | |
73 if (out_size % 16) { | |
74 printf("allocate out_size is not multiple of 16\n"); | |
0 | 75 } |
76 | |
77 int alignment = 16; | |
2 | 78 task_t *task = (task_t*)allocate(sizeof(task_t)); |
0 | 79 |
1
dcd83cefb980
check , ppe_only, show time , function add.
yutaka@localhost.localdomain
parents:
0
diff
changeset
|
80 void *buff; |
2 | 81 void *out; |
82 | |
83 int task_size = in_size + sizeof(task_head_t); | |
84 | |
85 posix_memalign(&buff, alignment, task_size); | |
86 fix_type(task, buff); | |
0 | 87 |
2 | 88 posix_memalign(&out, alignment, out_size); |
89 task->head->ea_out = (unsigned long long) (unsigned long) out; | |
90 task->head->size_out = out_size; | |
91 | |
92 task->task_size = task_size; | |
93 | |
94 | |
95 return task; | |
0 | 96 |
97 } |