Rev 1552 | Rev 1569 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1162 | tavani | 1 | /* |
1349 | giacomo | 2 | * Project: S.Ha.R.K |
1162 | tavani | 3 | * |
4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
5 | * |
||
6 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
7 | * |
||
8 | * http://www.sssup.it |
||
9 | * http://retis.sssup.it |
||
10 | * http://hartik.sssup.it |
||
11 | */ |
||
12 | |||
13 | #include "kernel/kern.h" |
||
1552 | pj | 14 | #include "edf/edf/edf.h" |
15 | #include "hardcbs/hardcbs/hardcbs.h" |
||
16 | #include "rr/rr/rr.h" |
||
17 | #include "dummy/dummy/dummy.h" |
||
18 | #include "intdrive/intdrive/intdrive.h" |
||
1162 | tavani | 19 | |
1552 | pj | 20 | #include "sem/sem/sem.h" |
21 | #include "hartport/hartport/hartport.h" |
||
1349 | giacomo | 22 | |
1392 | giacomo | 23 | #include <drivers/shark_linuxc26.h> |
24 | #include <drivers/shark_pci26.h> |
||
25 | #include <drivers/shark_input26.h> |
||
26 | #include <drivers/shark_keyb26.h> |
||
27 | #include <drivers/shark_fb26.h> |
||
28 | |||
29 | #define FRAME_BUFFER_DEVICE 0 |
||
30 | |||
1162 | tavani | 31 | /*+ sysyem tick in us +*/ |
1349 | giacomo | 32 | #define TICK 0 |
1162 | tavani | 33 | |
34 | /*+ RR tick in us +*/ |
||
1349 | giacomo | 35 | #define RRTICK 10000 |
1162 | tavani | 36 | |
1349 | giacomo | 37 | /*+ Interrup Server */ |
38 | #define INTDRIVE_Q 1000 |
||
1567 | mauro | 39 | #define INTDRIVE_U 1000 |
1349 | giacomo | 40 | #define INTDRIVE_FLAG 0 |
41 | |||
1392 | giacomo | 42 | void call_shutdown_task(void *arg); |
43 | int device_drivers_init(); |
||
44 | int device_drivers_close(); |
||
45 | void set_shutdown_task(); |
||
46 | TASK shutdown_task_body(void *arg); |
||
47 | |||
48 | PID shutdown_task_PID = -1; |
||
49 | |||
1162 | tavani | 50 | TIME __kernel_register_levels__(void *arg) |
51 | { |
||
52 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
||
53 | |||
1567 | mauro | 54 | INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG); |
1162 | tavani | 55 | EDF_register_level(EDF_ENABLE_ALL); |
1349 | giacomo | 56 | HCBS_register_level(HCBS_ENABLE_ALL, 1); |
1162 | tavani | 57 | RR_register_level(RRTICK, RR_MAIN_YES, mb); |
58 | dummy_register_level(); |
||
59 | |||
60 | SEM_register_module(); |
||
61 | |||
62 | return TICK; |
||
63 | } |
||
64 | |||
65 | TASK __init__(void *arg) |
||
66 | { |
||
1392 | giacomo | 67 | struct multiboot_info *mb = (struct multiboot_info *)arg; |
1162 | tavani | 68 | |
1392 | giacomo | 69 | HARTPORT_init(); |
1162 | tavani | 70 | |
1392 | giacomo | 71 | set_shutdown_task(); |
1162 | tavani | 72 | |
1392 | giacomo | 73 | device_drivers_init(); |
74 | |||
75 | sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN); |
||
76 | |||
77 | __call_main__(mb); |
||
78 | |||
79 | return (void *)0; |
||
1162 | tavani | 80 | } |
1392 | giacomo | 81 | |
82 | void set_shutdown_task() { |
||
83 | |||
84 | NRT_TASK_MODEL nrt; |
||
85 | |||
86 | nrt_task_default_model(nrt); |
||
87 | nrt_task_def_system(nrt); |
||
88 | |||
89 | shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL); |
||
90 | if (shutdown_task_PID == NIL) { |
||
91 | sys_shutdown_message("Error: Cannot create shutdown task\n"); |
||
1550 | pj | 92 | exit(1); |
1392 | giacomo | 93 | } |
94 | |||
95 | } |
||
96 | |||
97 | int device_drivers_init() { |
||
98 | |||
99 | int res; |
||
100 | KEYB_PARMS kparms = BASE_KEYB; |
||
101 | |||
1567 | mauro | 102 | LINUXC26_register_module(TRUE); |
1392 | giacomo | 103 | |
104 | PCI26_init(); |
||
105 | |||
106 | INPUT26_init(); |
||
107 | |||
108 | keyb_def_ctrlC(kparms, NULL); |
||
109 | |||
110 | KEYB26_init(&kparms); |
||
111 | |||
112 | FB26_init(); |
||
113 | |||
114 | res = FB26_open(FRAME_BUFFER_DEVICE); |
||
115 | if (res) { |
||
116 | cprintf("Error: Cannot open graphical mode\n"); |
||
117 | KEYB26_close(); |
||
118 | INPUT26_close(); |
||
1550 | pj | 119 | exit(1); |
1392 | giacomo | 120 | } |
121 | |||
122 | FB26_use_grx(FRAME_BUFFER_DEVICE); |
||
123 | |||
124 | FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
||
125 | |||
126 | return 0; |
||
127 | |||
128 | } |
||
129 | |||
130 | int device_drivers_close() { |
||
131 | |||
132 | FB26_close(FRAME_BUFFER_DEVICE); |
||
133 | |||
134 | KEYB26_close(); |
||
135 | |||
136 | INPUT26_close(); |
||
137 | |||
138 | return 0; |
||
139 | |||
140 | } |
||
141 | |||
142 | #define SHUTDOWN_TIMEOUT_SEC 3 |
||
143 | |||
144 | void call_shutdown_task(void *arg) |
||
145 | { |
||
146 | struct timespec t; |
||
147 | |||
148 | sys_gettime(&t); |
||
149 | t.tv_sec += SHUTDOWN_TIMEOUT_SEC; |
||
150 | |||
151 | /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */ |
||
152 | kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0); |
||
153 | |||
154 | task_activate(shutdown_task_PID); |
||
155 | } |
||
156 | |||
157 | TASK shutdown_task_body(void *arg) { |
||
158 | |||
159 | device_drivers_close(); |
||
160 | |||
161 | sys_shutdown_message("-- S.Ha.R.K. Closed --\n"); |
||
162 | |||
163 | return NULL; |
||
164 | |||
165 | } |