Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1673 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 "fsf.h"
48
 
49
#include "pi/pi/pi.h"
50
#include "pc/pc/pc.h"
51
#include "intdrive/intdrive/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_U 0.1*MAX_BANDWIDTH
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(TRUE);
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
        return NULL;
106
}
107
#define SHUTDOWN_TIMEOUT_SEC 3
108
 
109
void set_shutdown_task() {
110
 
111
        NRT_TASK_MODEL nrt;
112
 
113
        nrt_task_default_model(nrt);
114
        nrt_task_def_system(nrt);
115
 
116
        shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL);
117
        if (shutdown_task_PID == NIL) {
118
                sys_shutdown_message("Error: Cannot create shutdown task\n");
119
                exit(1);
120
        }
121
 
122
}
123
 
124
void call_shutdown_task(void *arg) {
125
 
126
        struct timespec t;
127
 
128
        sys_gettime(&t);
129
        t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
130
 
131
        /* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
132
        kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
133
 
134
        task_activate(shutdown_task_PID);
135
}
136
 
137
TIME __kernel_register_levels__(void *arg)
138
{
139
  struct multiboot_info *mb = (struct multiboot_info *)arg;
140
  int edf_level;
141
  int grubstar_level;
142
  int posix_level;
143
  int pi_level;
144
  int pc_level;
145
 
146
  INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG);
147
  edf_level=EDF_register_level(EDF_ENABLE_ALL);
148
  posix_level=POSIX_register_level(RRTICK, edf_level, mb, 32);
149
  grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, edf_level);
150
 
151
  FSF_register_module(posix_level,grubstar_level, (int)(MAX_BANDWIDTH*0.8));
152
  dummy_register_level();
153
 
154
  CBS_register_level(CBS_ENABLE_ALL,edf_level);
155
 
156
  SEM_register_module();
157
 
158
  pi_level=PI_register_module();
159
  pc_level=PC_register_module();
160
 
161
  PTHREAD_register_module(posix_level, pi_level, pc_level);
162
 
163
  load_file();
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
int dos_video_preload(void *filename, long max_size, void **start, void **end);
187
 
188
void *start_file;
189
void *end_file;
190
 
191
void load_file()
192
{
193
  start_file = NULL;
194
  end_file = NULL;
195
 
196
  dos_video_preload("test.m2v",5000000,&start_file,&end_file);
197
 
198
  cprintf("Start file ptr = %08lx\n",(long)(start_file));
199
  cprintf("End   file ptr = %08lx\n",(long)(end_file));
200
  cprintf("Size           = %8ld\n",(long)(end_file - start_file));
201
 
202
}
203
 
204