Blame |
Last modification |
View Log
| RSS feed
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Paolo Gai <pj@gandalf.sssup.it>
* Massimiliano Giorgi <massy@gandalf.sssup.it>
* Luca Abeni <luca@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
/*
* Copyright (C) 2000 Massimiliano Giorgi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* CVS : $Id: bd_edf.c,v 1.1.1.1 2002-03-29 14:12:52 pj Exp $
*
* File: $File$
* Revision: $Revision: 1.1.1.1 $
* Last update: $Date: 2002-03-29 14:12:52 $
*/
#include <modules/bd_edf.h>
#include <ll/ll.h>
#include <ll/string.h>
#include <ll/stdio.h>
#include <kernel/const.h>
#include <modules/codes.h>
#include <sys/types.h>
#include <kernel/var.h>
#include <kernel/func.h>
#include <kernel/assert.h>
static int mylevel
=-1;
typedef struct TAGbd_edf_resource_des
{
resource_des rd
;
TIME dl
[MAX_PROC
];
} bd_edf_resource_des
;
static int res_level_accept_resource_model
(RLEVEL l
, RES_MODEL
*r
)
{
assertk
(mylevel
==l
);
if (r
->rclass
==BDEDF_RCLASS
||r
->rclass
==(BDEDF_RCLASS
|l
))
return 0;
else
return -1;
}
static void res_register
(RLEVEL l
, PID p
, RES_MODEL
*r
)
{
bd_edf_resource_des
*m
=(bd_edf_resource_des
*)(resource_table
[l
]);
BDEDF_RES_MODEL
*rm
=(BDEDF_RES_MODEL
*)r
;
assertk
(mylevel
==l
);
m
->dl
[p
]=rm
->dl
;
}
static void res_detach
(RLEVEL l
, PID p
)
{
bd_edf_resource_des
*m
=(bd_edf_resource_des
*)(resource_table
[l
]);
assertk
(mylevel
==l
);
m
->dl
[p
]=0;
}
static void res_resource_status
(void)
{}
void BD_EDF_register_module
(void)
{
RLEVEL l
;
bd_edf_resource_des
*m
;
int i
;
/* request an entry in the level_table */
l
=resource_alloc_descriptor
();
/* alloc the space needed for the EDF_level_des */
m
=(bd_edf_resource_des
*)kern_alloc
(sizeof(bd_edf_resource_des
));
/* update the level_table with the new entry */
resource_table
[l
]=(resource_des
*)m
;
/* fill the resource_des descriptor */
strcpy(m
->rd.
res_name,BDEDF_MODULENAME
);
m
->rd.
res_code=BDEDF_MODULE_CODE
;
m
->rd.
res_version=BDEDF_MODULE_VERSION
;
m
->rd.
rtype=DEFAULT_RTYPE
;
m
->rd.
resource_status=res_resource_status
;
m
->rd.
level_accept_resource_model=res_level_accept_resource_model
;
m
->rd.
res_register=res_register
;
m
->rd.
res_detach=res_detach
;
for (i
=0;i
<MAX_PROC
;i
++) m
->dl
[i
]=MAX_TIME
;
assertk
(mylevel
==-1);
mylevel
=l
;
}
TIME bd_edf_getdl
(void)
{
bd_edf_resource_des
*m
;
if (mylevel
==-1) return MAX_TIME
;
m
=(bd_edf_resource_des
*)(resource_table
[mylevel
]);
if (m
->dl
[exec_shadow
]==MAX_TIME
) return MAX_TIME
;
return m
->dl
[exec_shadow
]+sys_gettime
(NULL
);
}