Mercurial > hg > Members > yutaka > manager
comparison ppe/Sys.cc @ 2:1e1b0d280427
commit
author | yutaka@localhost.localdomain |
---|---|
date | Wed, 07 Apr 2010 05:18:52 +0900 |
parents | dcd83cefb980 |
children | 8b4d6bf8c43d |
comparison
equal
deleted
inserted
replaced
1:dcd83cefb980 | 2:1e1b0d280427 |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include "Sys.h" | 3 #include "Sys.h" |
4 | |
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 } | |
4 | 27 |
5 int | 28 int |
6 size_fix(int size, int fix) | 29 size_fix(int size, int fix) |
7 { | 30 { |
8 | 31 |
25 return buff; | 48 return buff; |
26 | 49 |
27 } | 50 } |
28 | 51 |
29 void | 52 void |
30 fix_type(send_params_t *send_params, void *buff) | 53 fix_type(task_t *task, void *buff) |
31 { | 54 { |
32 | 55 |
33 char *p; | 56 char *p; |
34 p = (char*)buff; | 57 p = (char*)buff; |
35 p = p + sizeof(send_params_head_t); | 58 p = p + sizeof(task_head_t); |
36 | 59 |
37 send_params->head = (send_params_head_t*)buff; | 60 task->head = (task_head_t*)buff; |
38 send_params->buff = p; | 61 task->input = p; |
39 | 62 |
40 } | 63 } |
41 | 64 |
42 send_params_t | 65 task_t* |
43 task_allocate(int size) | 66 task_allocate(int in_size, int out_size) |
44 { | 67 { |
45 | 68 |
46 if (size % 16) { | 69 if (in_size % 16) { |
47 printf("allocate size is not multiple of 16\n"); | 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"); | |
48 } | 75 } |
49 | 76 |
50 int alignment = 16; | 77 int alignment = 16; |
51 send_params_t send_params; | 78 task_t *task = (task_t*)allocate(sizeof(task_t)); |
52 | 79 |
53 void *buff; | 80 void *buff; |
54 posix_memalign(&buff, alignment, size); | 81 void *out; |
55 fix_type(&send_params, buff); | |
56 | 82 |
57 return send_params; | 83 int task_size = in_size + sizeof(task_head_t); |
84 | |
85 posix_memalign(&buff, alignment, task_size); | |
86 fix_type(task, buff); | |
87 | |
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; | |
58 | 96 |
59 } | 97 } |