Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1541 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"
1555 trimarchi 39
#include "edf/edf/edf.h"
40
#include "cbs/cbs/cbs.h"
41
#include "posix/posix/posix.h"
1541 trimarchi 42
#include "pthread.h"
1555 trimarchi 43
#include "sem/sem/sem.h"
44
#include "dummy/dummy/dummy.h"
45
#include "hartport/hartport/hartport.h"
1541 trimarchi 46
#include "fsf.h"
47
 
1555 trimarchi 48
#include "pi/pi/pi.h"
49
#include "pc/pc/pc.h"
50
#include "intdrive/intdrive/intdrive.h"
1541 trimarchi 51
 
52
#include <drivers/shark_linuxc26.h>
53
#include <drivers/shark_input26.h>
54
#include <drivers/shark_keyb26.h>
55
#include <drivers/shark_pci26.h>
56
 
57
#define TICK 0
58
 
59
#define RRTICK 10000
60
 
61
/*+ Interrupt Server +*/
62
#define INTDRIVE_Q 1000
1567 mauro 63
#define INTDRIVE_U 1000
1541 trimarchi 64
#define INTDRIVE_FLAG 0
65
 
66
void call_shutdown_task(void *arg);
67
int device_drivers_init();
68
int device_drivers_close();
69
void set_shutdown_task();
70
TASK shutdown_task_body(void *arg);
71
 
72
PID shutdown_task_PID = 1;
73
 
74
void load_file();
75
 
76
int device_drivers_close() {
77
 
78
  KEYB26_close();
79
  INPUT26_close();
80
 
81
  return 0;
82
 
83
}
84
 
85
int device_drivers_init() {
86
        KEYB_PARMS  kparms = BASE_KEYB;
87
 
1567 mauro 88
        LINUXC26_register_module(TRUE);
1541 trimarchi 89
        PCI26_init();
90
        INPUT26_init();
91
 
92
        /*keyb_def_map(kparms, KEYMAP_IT);*/
93
        keyb_def_ctrlC(kparms, NULL);
94
        KEYB26_init(&kparms);
95
 
96
 
97
        return 0;
98
}
99
 
100
TASK shutdown_task_body(void *arg) {
101
 
102
        device_drivers_close();
103
        sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
104
        return NULL;
105
}
106
#define SHUTDOWN_TIMEOUT_SEC 3
107
 
108
void set_shutdown_task() {
109
 
110
        NRT_TASK_MODEL nrt;
111
 
112
        nrt_task_default_model(nrt);
113
        nrt_task_def_system(nrt);
114
 
115
        shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL);
116
        if (shutdown_task_PID == NIL) {
117
                sys_shutdown_message("Error: Cannot create shutdown task\n");
1550 pj 118
                exit(1);
1541 trimarchi 119
        }
120
 
121
}
122
 
123
void call_shutdown_task(void *arg) {
124
 
125
        struct timespec t;
126
 
127
        sys_gettime(&t);
128
        t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
129
 
130
        /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
131
        kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
132
 
133
        task_activate(shutdown_task_PID);
134
}
135
 
136
TIME __kernel_register_levels__(void *arg)
137
{
138
  struct multiboot_info *mb = (struct multiboot_info *)arg;
139
  int edf_level;
140
  int grubstar_level;
141
  int posix_level;
142
  int pi_level;
143
  int pc_level;
144
 
1567 mauro 145
  INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG);
1541 trimarchi 146
  edf_level=EDF_register_level(EDF_ENABLE_ALL);
147
  posix_level=POSIX_register_level(RRTICK, edf_level, mb, 32);
148
  grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, edf_level);
149
 
150
  FSF_register_module(posix_level,grubstar_level, (int)(MAX_BANDWIDTH*0.8));
151
  dummy_register_level();
152
 
153
  CBS_register_level(CBS_ENABLE_ALL,1);
154
 
155
  SEM_register_module();
156
 
157
  pi_level=PI_register_module();
158
  pc_level=PC_register_module();
159
 
160
  PTHREAD_register_module(posix_level, pi_level, pc_level);
161
 
162
  load_file();
163
 
164
  return TICK;
165
 
166
}
167
 
168
TASK __init__(void *arg)
169
{
170
  struct multiboot_info *mb = (struct multiboot_info *)arg;
171
 
172
  HARTPORT_init();
173
 
174
  set_shutdown_task();
175
 
176
  device_drivers_init();
177
 
178
  sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
179
 
180
  __call_main__(mb);
181
 
182
  return (void *)0;
183
}
184
 
185
int dos_video_preload(void *filename, long max_size, void **start, void **end);
186
 
187
void *start_file;
188
void *end_file;
189
 
190
void load_file()
191
{
192
  start_file = NULL;
193
  end_file = NULL;
194
 
195
  dos_video_preload("test.m2v",5000000,&start_file,&end_file);
196
 
197
  cprintf("Start file ptr = %08lx\n",(long)(start_file));
198
  cprintf("End   file ptr = %08lx\n",(long)(end_file));
199
  cprintf("Size           = %8ld\n",(long)(end_file - start_file));
200
 
201
}
202
 
203