Subversion Repositories shark

Rev

Rev 1547 | Rev 1567 | 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"
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"
1346 giacomo 19
 
1552 pj 20
#include "sem/sem/sem.h"
21
#include "hartport/hartport/hartport.h"
1346 giacomo 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
 
1383 giacomo 37
void call_shutdown_task(void *arg);
38
int device_drivers_init();
39
int device_drivers_close();
40
void set_shutdown_task();
41
TASK shutdown_task_body(void *arg);
42
 
1463 giacomo 43
PID shutdown_task_PID = -1;
1382 giacomo 44
 
1356 giacomo 45
TIME __kernel_register_levels__(void *arg)
46
{
47
        struct multiboot_info *mb = (struct multiboot_info *)arg;
1346 giacomo 48
 
1356 giacomo 49
        INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
50
        EDF_register_level(EDF_ENABLE_ALL);
51
        HCBS_register_level(HCBS_ENABLE_ALL, 1);
52
        RR_register_level(RRTICK, RR_MAIN_YES, mb);
53
        dummy_register_level();
1346 giacomo 54
 
1356 giacomo 55
        SEM_register_module();
56
 
57
        return TICK;
1346 giacomo 58
}
59
 
1383 giacomo 60
TASK __init__(void *arg)
61
{
62
        struct multiboot_info *mb = (struct multiboot_info *)arg;
63
 
64
        HARTPORT_init();
65
 
66
        set_shutdown_task();
67
 
68
        device_drivers_init();
69
 
70
        sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
71
 
72
        __call_main__(mb);
73
 
74
        return (void *)0;
75
}
76
 
77
void set_shutdown_task() {
78
 
79
        NRT_TASK_MODEL nrt;
80
 
81
        nrt_task_default_model(nrt);
82
        nrt_task_def_system(nrt);
83
 
84
        shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
85
        if (shutdown_task_PID == NIL) {
86
                sys_shutdown_message("Error: Cannot create shutdown task\n");
1547 pj 87
                exit(1);
1383 giacomo 88
        }
89
 
90
}
91
 
1382 giacomo 92
int device_drivers_init() {
93
 
94
        LINUXC26_register_module();
95
 
96
        PCI26_init();
97
 
98
        return 0;
99
 
100
}
101
 
102
int device_drivers_close() {
103
 
104
        return 0;
105
 
106
}
107
 
108
TASK shutdown_task_body(void *arg) {
109
 
110
        device_drivers_close();
111
 
112
        sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
113
 
114
        return NULL;
115
 
116
}
117
 
1383 giacomo 118
#define SHUTDOWN_TIMEOUT_SEC 3
119
 
1382 giacomo 120
void call_shutdown_task(void *arg) {
121
 
1383 giacomo 122
        struct timespec t;
123
 
124
        sys_gettime(&t);
125
        t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
126
 
127
        kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
128
 
1382 giacomo 129
        task_activate(shutdown_task_PID);
130
 
131
}