Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1085 pj 1
/*
2
 * Project: HARTIK (HA-rd R-eal TI-me K-ernel)
3
 *
4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
5
 *               Gerardo Lamastra <gerardo@sssup.it>
6
 *
7
 * Authors     : Paolo Gai <pj@hartik.sssup.it>
8
 * (see authors.txt for full list of hartik's authors)
9
 *
10
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
11
 *
12
 * http://www.sssup.it
13
 * http://retis.sssup.it
14
 * http://hartik.sssup.it
15
 */
16
 
17
/*
18
 * Copyright (C) 2000 Paolo Gai
19
 *
20
 * This program is free software; you can redistribute it and/or modify
21
 * it under the terms of the GNU General Public License as published by
22
 * the Free Software Foundation; either version 2 of the License, or
23
 * (at your option) any later version.
24
 *
25
 * This program is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with this program; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
33
 *
34
 */
35
 
36
 
37
#include "mymod.h"
38
#include <ll/string.h>
39
#include <kernel/model.h>
40
#include <kernel/descr.h>
41
#include <kernel/var.h>
42
#include <kernel/func.h>
43
 
44
// other include files if needed
45
 
46
// NOTE: NO GLOBAL OR STATIC VARIABLES!!! 
47
// (put them inside the level descriptor!)
48
 
49
/* Statuses used in the level */
50
#define MYMOD_READY         MODULE_STATUS_BASE    
51
#define MYMOD_WAIT          MODULE_STATUS_BASE+3  
52
#define MYMOD_IDLE          MODULE_STATUS_BASE+4  
53
 
54
/* the level redefinition for the Module */
55
typedef struct {
56
  level_des l;     /* the standard level descriptor          */
57
 
58
  int myvar[100];  /* other local (private) variables of the module */
59
 
60
} MYMOD_level_des;
61
 
62
// example of OSLib event
63
static void MYMOD_timer_deadline(void *par)
64
{
65
  // usually the void *par is a pointer to a structure or a PID
66
  // if it is a PID, you can do that to retrieve it and the correspondent
67
  // level descriptor
68
  PID p = (PID) par;
69
  MYMOD_level_des *lev;
70
 
71
  lev = (MYMOD_level_des *)level_table[proc_table[p].task_level];
72
 
73
  // now you know the PID of the task and the level descriptor
74
  // ... so, you know all the things you need
75
}
76
 
77
static int MYMOD_level_accept_task_model(LEVEL l, TASK_MODEL *m)
78
{
79
  // your code here
80
  return 0; // dummy number
81
}
82
 
83
static int MYMOD_level_accept_guest_model(LEVEL l, TASK_MODEL *m)
84
{
85
  // your code here
86
  return 0; // dummy number
87
}
88
 
89
static void MYMOD_level_status(LEVEL l)
90
{
91
}
92
 
93
/* The scheduler only gets the first task in the queue */
94
static PID MYMOD_level_scheduler(LEVEL l)
95
{
96
  return 0; // dummy number
97
}
98
 
99
/* The on-line guarantee is enabled only if the appropriate flag is set... */
100
static int MYMOD_level_guarantee(LEVEL l, bandwidth_t *freebandwidth)
101
{
102
  return 0; // dummy number
103
}
104
 
105
static int MYMOD_task_create(LEVEL l, PID p, TASK_MODEL *m)
106
{
107
  return 0; // dummy number
108
}
109
 
110
static void MYMOD_task_detach(LEVEL l, PID p)
111
{
112
}
113
 
114
static int MYMOD_task_eligible(LEVEL l, PID p)
115
{
116
  return 0; // dummy number
117
}
118
 
119
static void MYMOD_task_dispatch(LEVEL l, PID p, int nostop)
120
{
121
}
122
 
123
static void MYMOD_task_epilogue(LEVEL l, PID p)
124
{
125
}
126
 
127
static void MYMOD_task_activate(LEVEL l, PID p)
128
{
129
}
130
 
131
static void MYMOD_task_insert(LEVEL l, PID p)
132
{
133
}
134
 
135
static void MYMOD_task_extract(LEVEL l, PID p)
136
{
137
}
138
 
139
static void MYMOD_task_endcycle(LEVEL l, PID p)
140
{
141
}
142
 
143
static void MYMOD_task_end(LEVEL l, PID p)
144
{
145
}
146
 
147
static void MYMOD_task_sleep(LEVEL l, PID p)
148
{
149
}
150
 
151
static void MYMOD_task_delay(LEVEL l, PID p, TIME usdelay)
152
{
153
}
154
 
155
static int MYMOD_guest_create(LEVEL l, PID p, TASK_MODEL *m)
156
{
157
  return 0; // dummy number
158
}
159
 
160
static void MYMOD_guest_detach(LEVEL l, PID p)
161
{
162
}
163
 
164
static void MYMOD_guest_dispatch(LEVEL l, PID p, int nostop)
165
{
166
}
167
 
168
static void MYMOD_guest_epilogue(LEVEL l, PID p)
169
{
170
}
171
 
172
static void MYMOD_guest_activate(LEVEL l, PID p)
173
{
174
}
175
 
176
static void MYMOD_guest_insert(LEVEL l, PID p)
177
{
178
}
179
 
180
static void MYMOD_guest_extract(LEVEL l, PID p)
181
{
182
}
183
 
184
static void MYMOD_guest_endcycle(LEVEL l, PID p)
185
{
186
}
187
 
188
static void MYMOD_guest_end(LEVEL l, PID p)
189
{
190
}
191
 
192
static void MYMOD_guest_sleep(LEVEL l, PID p)
193
{
194
}
195
 
196
static void MYMOD_guest_delay(LEVEL l, PID p, TIME usdelay)
197
{
198
}
199
 
200
 
201
 
202
 
203
/* Registration functions */
204
 
205
/*+ Registration function:
206
    int flags                 the init flags ... see MYMOD.h +*/
207
void MYMOD_register_level(int flags)
208
{
209
  LEVEL l;            /* the level that we register */
210
  MYMOD_level_des *lev;  /* for readableness only */
211
  PID i;              /* a counter */
212
 
213
  /* request an entry in the level_table */
214
  l = level_alloc_descriptor();
215
 
216
  /* alloc the space needed for the MYMOD_level_des */
217
  lev = (MYMOD_level_des *)kern_alloc(sizeof(MYMOD_level_des));
218
 
219
  /* update the level_table with the new entry */
220
  level_table[l] = (level_des *)lev;
221
 
222
  /* fill the standard descriptor */
223
  strncpy(lev->l.level_name,  MYMOD_LEVELNAME, MAX_LEVELNAME);
224
  lev->l.level_code               = MYMOD_LEVEL_CODE;
225
  lev->l.level_version            = MYMOD_LEVEL_VERSION;
226
 
227
  lev->l.level_accept_task_model  = MYMOD_level_accept_task_model;
228
  lev->l.level_accept_guest_model = MYMOD_level_accept_guest_model;
229
  lev->l.level_status             = MYMOD_level_status;
230
  lev->l.level_scheduler          = MYMOD_level_scheduler;
231
  lev->l.level_guarantee          = MYMOD_level_guarantee;
232
 
233
  lev->l.task_create              = MYMOD_task_create;
234
  lev->l.task_detach              = MYMOD_task_detach;
235
  lev->l.task_eligible            = MYMOD_task_eligible;
236
  lev->l.task_dispatch            = MYMOD_task_dispatch;
237
  lev->l.task_epilogue            = MYMOD_task_epilogue;
238
  lev->l.task_activate            = MYMOD_task_activate;
239
  lev->l.task_insert              = MYMOD_task_insert;
240
  lev->l.task_extract             = MYMOD_task_extract;
241
  lev->l.task_endcycle            = MYMOD_task_endcycle;
242
  lev->l.task_end                 = MYMOD_task_end;
243
  lev->l.task_sleep               = MYMOD_task_sleep;
244
  lev->l.task_delay               = MYMOD_task_delay;
245
 
246
  lev->l.guest_create             = MYMOD_guest_create;
247
  lev->l.guest_detach             = MYMOD_guest_detach;
248
  lev->l.guest_dispatch           = MYMOD_guest_dispatch;
249
  lev->l.guest_epilogue           = MYMOD_guest_epilogue;
250
  lev->l.guest_activate           = MYMOD_guest_activate;
251
  lev->l.guest_insert             = MYMOD_guest_insert;
252
  lev->l.guest_extract            = MYMOD_guest_extract;
253
  lev->l.guest_endcycle           = MYMOD_guest_endcycle;
254
  lev->l.guest_end                = MYMOD_guest_end;
255
  lev->l.guest_sleep              = MYMOD_guest_sleep;
256
  lev->l.guest_delay              = MYMOD_guest_delay;
257
 
258
  /* fill the MYMOD descriptor part */
259
  for (i=0; i<100; i++)
260
    lev->myvar[i] = 0;
261
}
262
 
263
// put here the other interface functions added
264
 
265
 
266
 
267
 
268
 
269
 
270