File tree Expand file tree Collapse file tree 4 files changed +67
-1
lines changed Expand file tree Collapse file tree 4 files changed +67
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ CFLAGS += -Iinclude
7
7
.c.o :
8
8
gcc $(CFLAGS ) -o $@ $<
9
9
10
- kernel.bin : sys.o cpu.o intr.o excp.o memory.o sched.o timer.o console_io.o debug.o main.o kern_task_init.o
10
+ kernel.bin : sys.o cpu.o intr.o excp.o memory.o sched.o timer.o console_io.o queue.o debug.o main.o kern_task_init.o
11
11
ld -o $@ $+ -Map System.map -s -T sys.ld -x
12
12
13
13
sys.o : sys.S
@@ -26,6 +26,8 @@ timer.o: timer.c
26
26
27
27
console_io.o : console_io.c
28
28
29
+ queue.o : queue.c
30
+
29
31
debug.o : debug.c
30
32
31
33
main.o : main.c
Original file line number Diff line number Diff line change
1
+ #ifndef _LIST_H_
2
+ #define _LIST_H_
3
+
4
+ struct list {
5
+ struct list * next ;
6
+ struct list * prev ;
7
+ };
8
+
9
+ #endif /* _LIST_H_ */
Original file line number Diff line number Diff line change
1
+ #ifndef _QUEUE_H_
2
+ #define _QUEUE_H_
3
+
4
+ #include <list.h>
5
+
6
+ void queue_init (struct list * head );
7
+ void queue_enq (struct list * entry , struct list * head );
8
+ void queue_del (struct list * entry );
9
+ void queue_dump (struct list * head );
10
+
11
+ #endif /* _QUEUE_H_ */
Original file line number Diff line number Diff line change
1
+ #include <queue.h>
2
+ #include <list.h>
3
+ #include <console_io.h>
4
+
5
+ void queue_init (struct list * head )
6
+ {
7
+ head -> next = head ;
8
+ head -> prev = head ;
9
+ }
10
+
11
+ void queue_enq (struct list * entry , struct list * head )
12
+ {
13
+ entry -> prev = head -> prev ;
14
+ entry -> next = head ;
15
+ head -> prev -> next = entry ;
16
+ head -> prev = entry ;
17
+ }
18
+
19
+ void queue_del (struct list * entry )
20
+ {
21
+ entry -> prev -> next = entry -> next ;
22
+ entry -> next -> prev = entry -> prev ;
23
+ }
24
+
25
+ void queue_dump (struct list * head )
26
+ {
27
+ unsigned int n ;
28
+ struct list * entry ;
29
+
30
+ put_str ("h : p=" );
31
+ dump_hex ((unsigned int )head -> prev , 8 );
32
+ put_str (", n=" );
33
+ dump_hex ((unsigned int )head -> next , 8 );
34
+ put_str ("\r\n" );
35
+
36
+ for (entry = head -> next , n = 0 ; entry != head ; entry = entry -> next , n ++ ) {
37
+ dump_hex (n , 2 );
38
+ put_str (": p=" );
39
+ dump_hex ((unsigned int )entry -> prev , 8 );
40
+ put_str (", n=" );
41
+ dump_hex ((unsigned int )entry -> next , 8 );
42
+ put_str ("\r\n" );
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments