Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

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