Subversion Repositories shark

Rev

Rev 1377 | Rev 1383 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1346 giacomo 1
/*
1356 giacomo 2
 * Project: S.Ha.R.K
1346 giacomo 3
 *
1356 giacomo 4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
1346 giacomo 5
 *
6
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
7
 *
8
 * http://www.sssup.it
9
 * http://retis.sssup.it
1356 giacomo 10
 * http://hartik.sssup.it
1346 giacomo 11
 */
12
 
13
#include "kernel/kern.h"
14
#include "modules/edf.h"
15
#include "modules/hardcbs.h"
16
#include "modules/rr.h"
17
#include "modules/dummy.h"
18
#include "modules/intdrive.h"
19
 
20
#include "modules/sem.h"
21
#include "modules/hartport.h"
22
 
1382 giacomo 23
#include "drivers/shark_linuxc26.h"
24
#include "drivers/shark_pci26.h"
25
 
1346 giacomo 26
/*+ sysyem tick in us +*/
27
#define TICK 0
28
 
29
/*+ RR tick in us +*/
30
#define RRTICK 10000
31
 
1377 giacomo 32
/*+ Interrupt Server +*/
1356 giacomo 33
#define INTDRIVE_Q 1000
34
#define INTDRIVE_T 10000
35
#define INTDRIVE_FLAG 0
36
 
1382 giacomo 37
PID shutdown_task_PID;
38
 
1356 giacomo 39
TIME __kernel_register_levels__(void *arg)
40
{
41
        struct multiboot_info *mb = (struct multiboot_info *)arg;
1346 giacomo 42
 
1356 giacomo 43
        INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
44
        EDF_register_level(EDF_ENABLE_ALL);
45
        HCBS_register_level(HCBS_ENABLE_ALL, 1);
46
        RR_register_level(RRTICK, RR_MAIN_YES, mb);
47
        dummy_register_level();
1346 giacomo 48
 
1356 giacomo 49
        SEM_register_module();
50
 
51
        return TICK;
1346 giacomo 52
}
53
 
1382 giacomo 54
int device_drivers_init() {
55
 
56
        LINUXC26_register_module();
57
 
58
        PCI26_init();
59
 
60
        return 0;
61
 
62
}
63
 
64
int device_drivers_close() {
65
 
66
        return 0;
67
 
68
}
69
 
70
TASK shutdown_task_body(void *arg) {
71
 
72
        device_drivers_close();
73
 
74
        sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
75
 
76
        sys_end();
77
 
78
        return NULL;
79
 
80
}
81
 
82
void call_shutdown_task(void *arg) {
83
 
84
        task_activate(shutdown_task_PID);
85
 
86
}
87
 
88
void set_shutdown_task() {
89
 
90
        NRT_TASK_MODEL nrt;
91
 
92
        nrt_task_default_model(nrt);
93
        nrt_task_def_system(nrt);
94
        nrt_task_def_nokill(nrt);
95
 
96
        shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
97
        if (shutdown_task_PID == NIL) {
98
                sys_shutdown_message("Error: Cannot create shutdown task\n");
99
                sys_end();
100
        }
101
 
102
}
103
 
1346 giacomo 104
TASK __init__(void *arg)
105
{
1356 giacomo 106
        struct multiboot_info *mb = (struct multiboot_info *)arg;
1346 giacomo 107
 
1356 giacomo 108
        HARTPORT_init();
109
 
1382 giacomo 110
        set_shutdown_task();
111
 
112
        device_drivers_init();
113
 
114
        sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
115
 
1356 giacomo 116
        __call_main__(mb);
117
 
118
        return (void *)0;
1346 giacomo 119
}