Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1085 pj 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
 *   Paolo Gai           <pj@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
/*
39
 * CVS :        $Id: initfile.c,v 1.1.1.1 2002-09-02 09:37:45 pj Exp $
40
 *
41
 * File:        $File$
42
 * Revision:    $Revision: 1.1.1.1 $
43
 * Last update: $Date: 2002-09-02 09:37:45 $
44
 */
45
 
46
#include "kernel/kern.h"
47
#include "modules/edf.h"
48
#include "modules/rr.h"
49
#include "modules/cbs.h"
50
#include "modules/dummy.h"
51
 
52
#include "modules/sem.h"
53
#include "modules/hartport.h"
54
#include "modules/cabs.h"
55
#include "modules/pi.h"
56
#include "modules/pc.h"
57
#include "modules/srp.h"
58
#include "modules/npp.h"
59
#include "modules/nop.h"
60
#include "modules/nopm.h"
61
 
62
#include "drivers/keyb.h"
63
 
64
#include <trace/trace.h>
65
#include <trace/queues.h>
66
 
67
#include <fs/bdevinit.h>
68
#include <fs/fsinit.h>
69
#include <fs/bdev.h>
70
 
71
 
72
/*+ sysyem tick in us +*/
73
#define TICK 1000
74
 
75
/*+ RR tick in us +*/
76
#define RRTICK 10000
77
 
78
TIME __kernel_register_levels__(void *arg)
79
{
80
  struct multiboot_info *mb = (struct multiboot_info *)arg;
81
  extern int __register_sub_init_prologue(void);
82
  extern int __register_sub_init(void);
83
 
84
  __register_sub_init_prologue();
85
 
86
  EDF_register_level(EDF_ENABLE_ALL);
87
  RR_register_level(RRTICK, RR_MAIN_YES, mb);
88
  CBS_register_level(CBS_ENABLE_ALL, 0);
89
  dummy_register_level();
90
 
91
  SEM_register_module();
92
 
93
  CABS_register_module();
94
 
95
  PI_register_module();
96
  PC_register_module();
97
  NPP_register_module();
98
  SRP_register_module();
99
  NOP_register_module();
100
  NOPM_register_module();
101
 
102
  __register_sub_init();
103
 
104
  return TICK;
105
}
106
 
107
TASK __init__(void *arg)
108
{
109
  struct multiboot_info *mb = (struct multiboot_info *)arg;
110
  KEYB_PARMS    keyb = BASE_KEYB;
111
  extern int __bdev_sub_init(void);
112
  extern int __fs_sub_init(void);
113
  extern void ctrlc_exit(KEY_EVT *k);
114
 
115
  HARTPORT_init();
116
 
117
  keyb_def_ctrlC(keyb, ctrlc_exit);
118
  KEYB_init(&keyb);
119
 
120
  __bdev_sub_init();
121
  __fs_sub_init();
122
 
123
  __call_main__(mb);
124
 
125
  return (void *)0;
126
}
127
 
128
#define PSCANSCHED 1
129
#define NOTRACE
130
 
131
int __register_sub_init_prologue(void)
132
{
133
#ifndef NOTRACE
134
  int id;
135
 
136
  TRC_init_phase1(NULL);
137
  trc_register_fixed_queue();
138
  id=trc_create_queue(TRC_FIXED_QUEUE,NULL);
139
  trc_trace_class(TRC_CLASS_USER);
140
  trc_assign_class_to_queue(TRC_CLASS_USER,id);
141
#endif 
142
  return 0;
143
}
144
 
145
int __register_sub_init(void)
146
{
147
#if defined(EDFSCHED)
148
  extern void BD_EDF_register_module(void);
149
  BD_EDF_register_module();
150
#elif defined(PSCANSCHED)
151
  extern void BD_PSCAN_register_module(void);
152
  BD_PSCAN_register_module();  
153
#endif
154
  return 0;
155
}
156
 
157
dev_t root_device=-1;
158
dev_t temp_device=-1;
159
 
160
int choose_root_callback(dev_t dev,u_int8_t fs)
161
{
162
  if (fs==FS_MSDOS) return dev;
163
  return -1;
164
}
165
 
166
int choose_temp_callback(__dev_t dev,__uint8_t fs)
167
{
168
  static int flag=0;
169
  if (fs==FS_MSDOS) {
170
    if (flag) return dev;
171
    flag=1;
172
  }
173
  return -1;
174
}
175
 
176
int __bdev_sub_init(void)
177
{
178
  BDEV_PARMS bdev=BASE_BDEV;
179
 
180
  bdev_def_showinfo(bdev,FALSE);
181
  bdev_init(&bdev);
182
 
183
  root_device=bdev_scan_devices(choose_root_callback);
184
  if (root_device<0) {
185
    cprintf("can't find root device to mount on /!!!\n");
186
    sys_end();
187
    return -1;
188
  }
189
 
190
  /*
191
  temp_device=bdev_scan_devices(choose_temp_callback);
192
  if (temp_device<0) {
193
    cprintf("can't find a filesystem to mount on /TEMP!!!\n");
194
  }
195
  */
196
 
197
  return 0;
198
}
199
 
200
 
201
int __fs_sub_init(void)
202
{
203
  extern int libc_initialize(void);
204
  FILESYSTEM_PARMS fs=BASE_FILESYSTEM;
205
  struct mount_opts opts;
206
  //  int res;
207
 
208
  filesystem_def_rootdevice(fs,root_device);
209
  filesystem_def_fs(fs,FS_MSDOS);
210
  filesystem_def_showinfo(fs,FALSE);
211
  filesystem_def_options(fs,opts);
212
 
213
  memset(&opts,0,sizeof(struct mount_opts));
214
  opts.flags=MOUNT_FLAG_RW;
215
 
216
 
217
  filesystem_init(&fs);
218
 
219
  /*
220
  if (temp_device>=0) {
221
    memset(&opts,0,sizeof(struct mount_opts));
222
    opts.flags=MOUNT_FLAG_RW;
223
    res=mount(temp_device,FS_MSDOS,"/TEMP",&opts);
224
    if (res!=0) {
225
      cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno);
226
    } else
227
      cprintf("mounted /TEMP rw\n");    
228
  }
229
  */
230
 
231
  libc_initialize();
232
 
233
#ifndef NOTRACE
234
  TRC_init_phase2();
235
#endif
236
 
237
  return 0;
238
}
239
 
240
void ctrlc_exit(KEY_EVT *k)
241
{
242
  extern void dump_sem_table(void);
243
  extern void dump_nop_table(void);
244
#ifndef NOGRX
245
  grx_close();
246
#endif
247
  cprintf("CTRL-C pressed!\n");
248
  sys_end();
249
}
250
 
251
 
252
 
253
 
254
 
255
 
256