Subversion Repositories shark

Rev

Rev 1562 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1562 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 "edf/edf//edf.h"
40
#include "cbs/cbs/cbs.h"
41
#include "posix/posix/posix.h"
42
#include "pthread.h"
43
#include "sem/sem/sem.h"
44
#include "dummy/dummy/dummy.h"
45
#include "hartport/hartport/hartport.h"
46
#include "grubstar.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_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() {
1563 trimarchi 87
        //KEYB_PARMS  kparms = BASE_KEYB;
1562 trimarchi 88
 
89
        LINUXC26_register_module();
90
        PCI26_init();
1563 trimarchi 91
        //INPUT26_init();
1562 trimarchi 92
 
93
        /*keyb_def_map(kparms, KEYMAP_IT);*/
1563 trimarchi 94
        //keyb_def_ctrlC(kparms, NULL);
95
        //KEYB26_init(&kparms);
1562 trimarchi 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, edf_level, 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
  load_file();
166
 
167
  return TICK;
168
 
169
}
170
 
171
TASK __init__(void *arg)
172
{
173
  struct multiboot_info *mb = (struct multiboot_info *)arg;
174
 
175
  HARTPORT_init();
176
 
177
  set_shutdown_task();
178
 
179
  device_drivers_init();
180
 
181
  sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
182
 
183
  __call_main__(mb);
184
 
185
  return (void *)0;
186
}
187
 
188
int dos_video_preload(void *filename, long max_size, void **start, void **end, void **actual);
189
 
190
void *start_file;
191
void *end_file;
192
void *actual_file;
193
 
194
void load_file()
195
{
196
  start_file = NULL;
197
  end_file = NULL;
198
 
199
  dos_video_preload("test.m2v",5000000,&start_file,&end_file, &actual_file);
200
 
201
  cprintf("Start file ptr = %08lx\n",(long)(start_file));
202
  cprintf("End   file ptr = %08lx\n",(long)(end_file));
203
  cprintf("Size           = %8ld\n",(long)(end_file - start_file));
204
 
205
}
206
 
207