Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 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
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/*
22
 * Copyright (C) 2000 Massimiliano Giorgi
23
 *
24
 * This program is free software; you can redistribute it and/or modify
25
 * it under the terms of the GNU General Public License as published by
26
 * the Free Software Foundation; either version 2 of the License, or
27
 * (at your option) any later version.
28
 *
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 * GNU General Public License for more details.
33
 *
34
 * You should have received a copy of the GNU General Public License
35
 * along with this program; if not, write to the Free Software
36
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
37
 *
38
 */
39
 
40
/*
41
 * CVS :        $Id: bd_pscan.c,v 1.1.1.1 2002-03-29 14:12:52 pj Exp $
42
 *
43
 * File:        $File$
44
 * Revision:    $Revision: 1.1.1.1 $
45
 * Last update: $Date: 2002-03-29 14:12:52 $
46
 */
47
 
48
#include <modules/bd_pscan.h>
49
 
50
#include <ll/ll.h>
51
#include <ll/string.h>
52
#include <ll/stdio.h>
53
#include <kernel/const.h>
54
#include <modules/codes.h>
55
#include <sys/types.h>
56
#include <kernel/var.h>
57
#include <kernel/func.h>
58
#include <kernel/assert.h>
59
 
60
#define LOWESTPRIORITY 255
61
#define HIGHERPRIORITY   0
62
 
63
static int mylevel=-1;
64
 
65
typedef struct TAGbd_pscan_resource_des
66
{
67
  resource_des rd;
68
  int priority[MAX_PROC];
69
} bd_pscan_resource_des;
70
 
71
static int res_level_accept_resource_model(RLEVEL l, RES_MODEL *r)
72
{
73
  assertk(mylevel==l);
74
  if (r->rclass==BDPSCAN_RCLASS||r->rclass==(BDPSCAN_RCLASS|l))
75
    return 0;
76
  else
77
    return -1;
78
}
79
 
80
static void res_register(RLEVEL l, PID p, RES_MODEL *r)
81
{
82
  bd_pscan_resource_des *m=(bd_pscan_resource_des*)(resource_table[l]);
83
  BDPSCAN_RES_MODEL *rm=(BDPSCAN_RES_MODEL*)r;
84
  assertk(mylevel==l);
85
  m->priority[p]=rm->priority;
86
}
87
 
88
static void res_detach(RLEVEL l, PID p)
89
{
90
  bd_pscan_resource_des *m=(bd_pscan_resource_des*)(resource_table[l]);
91
  assertk(mylevel==l);
92
  m->priority[p]=LOWESTPRIORITY;
93
}
94
 
95
static void res_resource_status(void)
96
{}
97
 
98
void BD_PSCAN_register_module(void)
99
{
100
  RLEVEL l;
101
  bd_pscan_resource_des *m;
102
  int i;
103
 
104
  /* request an entry in the level_table */
105
  l=resource_alloc_descriptor();
106
 
107
  /* alloc the space needed for the EDF_level_des */
108
  m=(bd_pscan_resource_des*)kern_alloc(sizeof(bd_pscan_resource_des));
109
 
110
  /* update the level_table with the new entry */
111
  resource_table[l]=(resource_des*)m;
112
 
113
  /* fill the resource_des descriptor */
114
  strcpy(m->rd.res_name,BDPSCAN_MODULENAME);
115
  m->rd.res_code=BDPSCAN_MODULE_CODE;
116
  m->rd.res_version=BDPSCAN_MODULE_VERSION;
117
  m->rd.rtype=DEFAULT_RTYPE;
118
  m->rd.resource_status=res_resource_status;
119
  m->rd.level_accept_resource_model=res_level_accept_resource_model;
120
  m->rd.res_register=res_register;
121
  m->rd.res_detach=res_detach;
122
 
123
  for (i=0;i<MAX_PROC;i++) m->priority[i]=LOWESTPRIORITY;
124
 
125
  assertk(mylevel==-1);
126
  mylevel=l;
127
}
128
 
129
int bd_pscan_getpriority(void)
130
{
131
  bd_pscan_resource_des *m;
132
  if (mylevel==-1) return LOWESTPRIORITY;
133
  m=(bd_pscan_resource_des*)(resource_table[mylevel]);
134
  return m->priority[exec_shadow];
135
}