bump up min IOS version
[libogc.git] / libogc / lwp_queue.c
blobcb359c9ed5a7024298cfc00d4c4bcb6493a899bb
1 #include <stdlib.h>
2 #include "asm.h"
3 #include "processor.h"
4 #include "lwp_queue.h"
6 void __lwp_queue_initialize(lwp_queue *queue,void *start_addr,u32 num_nodes,u32 node_size)
8 u32 count;
9 lwp_node *curr;
10 lwp_node *next;
12 #ifdef _LWPQ_DEBUG
13 printf("__lwp_queue_initialize(%p,%p,%d,%d)\n",queue,start_addr,num_nodes,node_size);
14 #endif
15 count = num_nodes;
16 curr = __lwp_queue_head(queue);
17 queue->perm_null = NULL;
18 next = (lwp_node*)start_addr;
20 while(count--) {
21 curr->next = next;
22 next->prev = curr;
23 curr = next;
24 next = (lwp_node*)(((void*)next)+node_size);
26 curr->next = __lwp_queue_tail(queue);
27 queue->last = curr;
30 lwp_node* __lwp_queue_get(lwp_queue *queue)
32 u32 level;
33 lwp_node *ret = NULL;
35 _CPU_ISR_Disable(level);
36 if(!__lwp_queue_isempty(queue)) {
37 ret = __lwp_queue_firstnodeI(queue);
39 _CPU_ISR_Restore(level);
40 return ret;
43 void __lwp_queue_append(lwp_queue *queue,lwp_node *node)
45 u32 level;
47 _CPU_ISR_Disable(level);
48 __lwp_queue_appendI(queue,node);
49 _CPU_ISR_Restore(level);
52 void __lwp_queue_extract(lwp_node *node)
54 u32 level;
56 _CPU_ISR_Disable(level);
57 __lwp_queue_extractI(node);
58 _CPU_ISR_Restore(level);
61 void __lwp_queue_insert(lwp_node *after,lwp_node *node)
63 u32 level;
65 _CPU_ISR_Disable(level);
66 __lwp_queue_insertI(after,node);
67 _CPU_ISR_Restore(level);