Subversion Repositories shark

Rev

Rev 1383 | Rev 1552 | 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
 
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");
87
                sys_end();
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
 
1383 giacomo 114
        sys_abort_shutdown(0);
1382 giacomo 115
 
116
        return NULL;
117
 
118
}
119
 
1383 giacomo 120
#define SHUTDOWN_TIMEOUT_SEC 3
121
 
1382 giacomo 122
void call_shutdown_task(void *arg) {
123
 
1383 giacomo 124
        struct timespec t;
125
 
126
        sys_gettime(&t);
127
        t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
128
 
129
        kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
130
 
1382 giacomo 131
        task_activate(shutdown_task_PID);
132
 
133
}