Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
948 trimarchi 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Giacomo Guidi       <giacomo@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/*
20
 * Copyright (C) 2000 Paolo Gai
21
 *
22
 * This program is free software; you can redistribute it and/or modify
23
 * it under the terms of the GNU General Public License as published by
24
 * the Free Software Foundation; either version 2 of the License, or
25
 * (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
35
 *
36
 */
37
 
38
#include "kernel/kern.h"
39
#include "modules/edf.h"
40
#include "modules/cbs.h"
41
#include "modules/posix.h"
42
#include "pthread.h"
43
#include "modules/sem.h"
44
#include "modules/dummy.h"
45
#include "modules/hartport.h"
46
#include "grubstar.h"
47
#include "fsf.h"
48
 
49
#include "modules/pi.h"
50
#include "modules/pc.h"
51
#include "modules/intdrive.h"
52
 
53
#include <drivers/shark_linuxc26.h>
54
#include <drivers/shark_input26.h>
55
#include <drivers/shark_keyb26.h>
56
#include <drivers/shark_pci26.h>
57
 
58
#define TICK 0
59
 
60
#define RRTICK 10000
61
 
62
/*+ Interrupt Server +*/
63
#define INTDRIVE_Q 1000
64
#define INTDRIVE_T 10000
65
#define INTDRIVE_FLAG 0
66
 
67
void call_shutdown_task(void *arg);
68
int device_drivers_init();
69
int device_drivers_close();
70
void set_shutdown_task();
71
TASK shutdown_task_body(void *arg);
72
 
73
PID shutdown_task_PID = 1;
74
 
75
// void load_file();
76
 
77
int device_drivers_close() {
78
 
79
  KEYB26_close();
80
  INPUT26_close();
81
 
82
  return 0;
83
 
84
}
85
 
86
int device_drivers_init() {
87
  KEYB_PARMS  kparms = BASE_KEYB;
88
 
89
  LINUXC26_register_module();
90
  PCI26_init();
91
  INPUT26_init();
92
 
93
        /*keyb_def_map(kparms, KEYMAP_IT);*/
94
  keyb_def_ctrlC(kparms, NULL);
95
  KEYB26_init(&kparms);
96
 
97
 
98
  return 0;
99
}
100
 
101
TASK shutdown_task_body(void *arg) {
102
 
103
        device_drivers_close();
104
        sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
105
        sys_abort_shutdown(0);
106
 
107
        return NULL;
108
}
109
#define SHUTDOWN_TIMEOUT_SEC 3
110
 
111
void set_shutdown_task() {
112
 
113
        NRT_TASK_MODEL nrt;
114
 
115
        nrt_task_default_model(nrt);
116
        nrt_task_def_system(nrt);
117
 
118
        shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL);
119
        if (shutdown_task_PID == NIL) {
120
                sys_shutdown_message("Error: Cannot create shutdown task\n");
121
                exit(-1);
122
        }
123
 
124
}
125
 
126
void call_shutdown_task(void *arg) {
127
 
128
        struct timespec t;
129
 
130
        sys_gettime(&t);
131
        t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
132
 
133
        /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
134
        kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
135
 
136
        task_activate(shutdown_task_PID);
137
}
138
 
139
TIME __kernel_register_levels__(void *arg)
140
{
141
  struct multiboot_info *mb = (struct multiboot_info *)arg;
142
  int edf_level;
143
  int grubstar_level;
144
  int posix_level;
145
  int pi_level;
146
  int pc_level;
147
 
148
  INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_T, INTDRIVE_FLAG);
149
  edf_level=EDF_register_level(EDF_ENABLE_ALL);
150
  posix_level=POSIX_register_level(RRTICK, POSIX_MAIN_YES, mb, 32);
151
  grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, edf_level);
152
 
153
  FSF_register_module(posix_level,grubstar_level, (int)(MAX_BANDWIDTH*0.8));
154
  dummy_register_level();
155
 
156
  CBS_register_level(CBS_ENABLE_ALL,1);
157
 
158
  SEM_register_module();
159
 
160
  pi_level=PI_register_module();
161
  pc_level=PC_register_module();
162
 
163
  PTHREAD_register_module(posix_level, pi_level, pc_level);
164
 
165
  return TICK;
166
 
167
}
168
 
169
TASK __init__(void *arg)
170
{
171
  struct multiboot_info *mb = (struct multiboot_info *)arg;
172
 
173
  HARTPORT_init();
174
 
175
  set_shutdown_task();
176
 
177
  device_drivers_init();
178
 
179
  sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
180
 
181
  __call_main__(mb);
182
 
183
  return (void *)0;
184
}
185
 
186