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