Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1158 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
 ------------
1381 giacomo 21
 CVS :        $Id: rrn.c,v 1.4 2004-04-18 18:48:22 giacomo Exp $
1158 pj 22
 
23
 File:        $File$
1381 giacomo 24
 Revision:    $Revision: 1.4 $
25
 Last update: $Date: 2004-04-18 18:48:22 $
1158 pj 26
 ------------
27
**/
28
 
29
/*
30
 * Copyright (C) 2003 Paolo Gai
31
 *
32
 * This program is free software; you can redistribute it and/or modify
33
 * it under the terms of the GNU General Public License as published by
34
 * the Free Software Foundation; either version 2 of the License, or
35
 * (at your option) any later version.
36
 *
37
 * This program is distributed in the hope that it will be useful,
38
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
39
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40
 * GNU General Public License for more details.
41
 *
42
 * You should have received a copy of the GNU General Public License
43
 * along with this program; if not, write to the Free Software
44
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
45
 *
46
 */
47
 
48
#include "kernel/kern.h"
1380 giacomo 49
#include "modules/intdrive.h"
1158 pj 50
#include "modules/edf.h"
51
#include "modules/rr.h"
52
#include "modules/rrsoft.h"
53
#include "modules/dummy.h"
54
 
55
#include "modules/sem.h"
56
#include "modules/hartport.h"
57
#include "modules/cabs.h"
58
 
1380 giacomo 59
#include "modules/nop.h"
60
 
1381 giacomo 61
#include <drivers/shark_linuxc26.h>
62
#include <drivers/shark_pci26.h>
63
#include <drivers/shark_input26.h>
64
#include <drivers/shark_keyb26.h>
65
#include <drivers/shark_fb26.h>
66
 
67
#define FRAME_BUFFER_DEVICE 0
68
 
1158 pj 69
/*+ sysyem tick in us +*/
70
#define TICK 0
71
 
72
/*+ RR tick in us +*/
73
#define RRTICK 2000
74
 
1379 giacomo 75
/*+ Interrupt Server +*/
76
#define INTDRIVE_Q 1000
77
#define INTDRIVE_T 10000
78
#define INTDRIVE_FLAG 0
79
 
1381 giacomo 80
PID shutdown_task_PID = -1;
81
 
1158 pj 82
TIME __kernel_register_levels__(void *arg)
83
{
84
  struct multiboot_info *mb = (struct multiboot_info *)arg;
85
 
1379 giacomo 86
  INTDRIVE_register_level(INTDRIVE_Q,INTDRIVE_T,INTDRIVE_FLAG);
1158 pj 87
  RR_register_level(RRTICK, RR_MAIN_NO, mb); // this module remains empty!!!
88
  RRSOFT_register_level(RRTICK, RR_MAIN_NO, mb, RRSOFT_ONLY_HARD|RRSOFT_ONLY_SOFT);
89
  RR_register_level(RRTICK, RR_MAIN_YES, mb);
90
  dummy_register_level();
91
 
92
  SEM_register_module();
93
 
94
  CABS_register_module();
95
 
1380 giacomo 96
  NOP_register_module();
97
 
1158 pj 98
  return TICK;
99
}
100
 
1381 giacomo 101
int device_drivers_close() {
102
 
103
  FB26_close(FRAME_BUFFER_DEVICE);
104
 
105
  KEYB26_close();
106
 
107
  INPUT26_close();
108
 
109
  return 0;
110
 
111
}
112
 
113
int device_drivers_init() {
114
 
115
  int res;
116
  KEYB_PARMS kparms = BASE_KEYB;
117
 
118
  LINUXC26_register_module();
119
 
120
  PCI26_init();
121
 
122
  INPUT26_init();
123
 
124
  keyb_def_ctrlC(kparms, NULL);
125
 
126
  KEYB26_init(&kparms);
127
 
128
  FB26_init();
129
 
130
  res = FB26_open(FRAME_BUFFER_DEVICE);
131
  if (res) {
132
    cprintf("Error: Cannot open graphical mode\n");
133
    KEYB26_close();
134
    INPUT26_close();
135
    sys_end();
136
  }                                                                                          
137
 
138
  FB26_use_grx(FRAME_BUFFER_DEVICE);
139
 
140
  FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
141
 
142
  return 0;
143
 
144
}
145
 
146
TASK shutdown_task_body(void *arg) {
147
 
148
  device_drivers_close();
149
 
150
  sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
151
 
152
  sys_end();
153
 
154
  return NULL;
155
 
156
}
157
 
158
void set_shutdown_task() {
159
 
160
  NRT_TASK_MODEL nrt;
161
 
162
  nrt_task_default_model(nrt);
163
  nrt_task_def_system(nrt);
164
  nrt_task_def_nokill(nrt);
165
 
166
  shutdown_task_PID = task_create("Shutdown Task",shutdown_task_body,&nrt,NULL);
167
  if (shutdown_task_PID == NIL) {
168
    sys_shutdown_message("Error: Cannot create shutdown task\n");
169
    sys_end();
170
  }
171
 
172
}
173
 
174
void call_shutdown_task(void *arg) {
175
 
176
  task_activate(shutdown_task_PID);
177
 
178
}
179
 
1158 pj 180
TASK __init__(void *arg)
181
{
182
  struct multiboot_info *mb = (struct multiboot_info *)arg;
183
 
184
  HARTPORT_init();
185
 
1381 giacomo 186
  set_shutdown_task();
187
 
188
  device_drivers_init();
189
 
190
  sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
191
 
1158 pj 192
  __call_main__(mb);
193
 
194
  return (void *)0;
195
}
1380 giacomo 196
 
197
void app_mutex_init(mutex_t *m)
198
{
199
  NOP_mutexattr_t attr;
200
 
201
  NOP_mutexattr_default(attr);
202
 
203
  mutex_init(m, &attr);
204
}
205