Rev 3 | Details | Compare with Previous | 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 | /* |
||
38 | pj | 41 | * CVS : $Id: bd_pscan.c,v 1.2 2003-01-07 17:07:50 pj Exp $ |
2 | pj | 42 | * |
43 | * File: $File$ |
||
38 | pj | 44 | * Revision: $Revision: 1.2 $ |
45 | * Last update: $Date: 2003-01-07 17:07:50 $ |
||
2 | pj | 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 <sys/types.h> |
||
55 | #include <kernel/var.h> |
||
56 | #include <kernel/func.h> |
||
57 | #include <kernel/assert.h> |
||
58 | |||
59 | #define LOWESTPRIORITY 255 |
||
60 | #define HIGHERPRIORITY 0 |
||
61 | |||
62 | static int mylevel=-1; |
||
63 | |||
64 | typedef struct TAGbd_pscan_resource_des |
||
65 | { |
||
66 | resource_des rd; |
||
67 | int priority[MAX_PROC]; |
||
68 | } bd_pscan_resource_des; |
||
69 | |||
38 | pj | 70 | static int res_register(RLEVEL l, PID p, RES_MODEL *r) |
2 | pj | 71 | { |
38 | pj | 72 | bd_pscan_resource_des *m=(bd_pscan_resource_des*)(resource_table[l]); |
73 | BDPSCAN_RES_MODEL *rm; |
||
74 | |||
75 | if (r->rclass!=BDEDF_RCLASS) |
||
2 | pj | 76 | return -1; |
38 | pj | 77 | if (r->level && r->level !=l) |
78 | return -1; |
||
79 | |||
80 | rm=(BDPSCAN_RES_MODEL*)r; |
||
2 | pj | 81 | assertk(mylevel==l); |
82 | m->priority[p]=rm->priority; |
||
38 | pj | 83 | |
84 | return 0; |
||
2 | pj | 85 | } |
86 | |||
87 | static void res_detach(RLEVEL l, PID p) |
||
88 | { |
||
89 | bd_pscan_resource_des *m=(bd_pscan_resource_des*)(resource_table[l]); |
||
90 | assertk(mylevel==l); |
||
91 | m->priority[p]=LOWESTPRIORITY; |
||
92 | } |
||
93 | |||
38 | pj | 94 | RLEVEL BD_PSCAN_register_module(void) |
2 | pj | 95 | { |
96 | RLEVEL l; |
||
97 | bd_pscan_resource_des *m; |
||
98 | int i; |
||
99 | |||
100 | /* request an entry in the level_table */ |
||
101 | l=resource_alloc_descriptor(); |
||
102 | |||
103 | /* alloc the space needed for the EDF_level_des */ |
||
104 | m=(bd_pscan_resource_des*)kern_alloc(sizeof(bd_pscan_resource_des)); |
||
105 | |||
106 | /* update the level_table with the new entry */ |
||
107 | resource_table[l]=(resource_des*)m; |
||
108 | |||
109 | /* fill the resource_des descriptor */ |
||
110 | m->rd.rtype=DEFAULT_RTYPE; |
||
111 | m->rd.res_register=res_register; |
||
112 | m->rd.res_detach=res_detach; |
||
113 | |||
114 | for (i=0;i<MAX_PROC;i++) m->priority[i]=LOWESTPRIORITY; |
||
115 | |||
116 | assertk(mylevel==-1); |
||
117 | mylevel=l; |
||
38 | pj | 118 | |
119 | return l; |
||
2 | pj | 120 | } |
121 | |||
122 | int bd_pscan_getpriority(void) |
||
123 | { |
||
124 | bd_pscan_resource_des *m; |
||
125 | if (mylevel==-1) return LOWESTPRIORITY; |
||
126 | m=(bd_pscan_resource_des*)(resource_table[mylevel]); |
||
127 | return m->priority[exec_shadow]; |
||
128 | } |