rs changes (also use driver configurations in the image ramdisk)

This commit is contained in:
Philip Homburg 2006-10-31 13:35:04 +00:00
parent 9ac537eb7c
commit 0c1d433f60
11 changed files with 197 additions and 30 deletions

View file

@ -2,13 +2,14 @@
PROGRAMS=at_wini bios_wini cdprobe dev2name floppy loadramdisk newroot \
pci sh service sysenv mfs
EXTRA=drivers.conf passwd
MAKEDEV=/usr/bin/MAKEDEV
all: image.c image.s
clean:
rm -rf $(PROGRAMS) bintoc image image.c image.s t proto.gen
rm -rf $(PROGRAMS) $(EXTRA) bintoc image image.c image.s t proto.gen
image.c: bintoc image
./bintoc -o $@ image
@ -21,7 +22,7 @@ image.s: image.c
bintoc: bintoc.c
$(CC) -o $@ bintoc.c
image: proto.gen mtab rc $(PROGRAMS)
image: proto.gen mtab rc $(PROGRAMS) $(EXTRA)
mkfs -B 2048 image proto.gen || { rm -f image; false; }
at_wini: ../../at_wini/at_wini
@ -96,6 +97,12 @@ mfs: ../../../servers/mfs/mfs
../../../servers/mfs/mfs:
cd ../../../servers/mfs && make
drivers.conf: ../../../etc/drivers.conf
install -s ../../../etc/$@ $@
passwd: ../../../etc/passwd
install -s ../../../etc/$@ $@
depend:
/usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend

View file

@ -19,7 +19,9 @@ d--755 0 0
@DEV@
$
etc d--755 0 0
drivers.conf ---644 0 0 drivers.conf
mtab ---644 0 0 mtab
passwd ---644 0 0 passwd
rc ---755 0 0 rc
$
$

View file

@ -1,13 +1,13 @@
#!/bin/sh
set -e
/bin/service up /bin/pci
/bin/service -c up /bin/floppy -dev /dev/fd0
/bin/service up /bin/pci -config /etc/drivers.conf
/bin/service -c up /bin/floppy -config /etc/drivers.conf -dev /dev/fd0
if [ X`/bin/sysenv bios_wini` = Xyes ]
then
echo Using bios_wini.
/bin/service -c up /bin/bios_wini -dev /dev/c0d0
else
/bin/service -c up /bin/at_wini -dev /dev/c0d0
/bin/service -c up /bin/at_wini -dev /dev/c0d0 -script /etc/rs.single -config /etc/drivers.conf
fi
rootdev=`sysenv rootdev` || echo 'No rootdev?'

View file

@ -1,7 +1,7 @@
ETC=/etc/
USRETC=/usr/etc/
FILES1=fstab group hostname.file inet.conf motd.install mtab passwd profile protocols rc services termcap ttytab utmp rc.cd binary_sizes binary_sizes.big binary_sizes.xxl rc.rescue syslog.conf rc.daemons.dist
FILES1=fstab group hostname.file inet.conf motd.install mtab passwd profile protocols rc services termcap ttytab utmp rc.cd binary_sizes binary_sizes.big binary_sizes.xxl rc.rescue syslog.conf rc.daemons.dist rs.single
FILES2=shadow
FILES3=daily dhcptags.conf rc

135
etc/drivers.conf Normal file
View file

@ -0,0 +1,135 @@
driver floppy
{
irq 6;
io 3f0:8
0:10 # XXX DMA controller
81 # Also DMA
;
system
UMAP # 14
VIRCOPY # 15
IRQCTL # 19
DEVIO # 21
VDEVIO # 23
SETALARM # 24
TIMES # 25
SAFECOPYFROM # 31
SAFECOPYTO # 32
;
};
driver dp8390
{
system
KILL # 6
VIRCOPY # 15
IRQCTL # 19
DEVIO # 21
SDEVIO # 22
SETALARM # 24
GETINFO # 26
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
;
pci device 10ec/8029;
uid 0;
};
driver dumpcore
{
system
TRACE # 5
VIRCOPY # 15
GETINFO # 26
SETGRANT # 34
;
};
driver inet
{
system
KILL # 6
SETALARM # 24
TIMES # 25
SAFECOPYFROM # 31
SAFECOPYTO # 32
VSAFECOPY # 33
SETGRANT # 34
;
uid 0;
};
driver random
{
system
KILL # 6
UMAP # 14
SETALARM # 24
GETINFO # 26
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
;
};
driver cmos
{
io 70:2;
system
DEVIO # 21
TIMES # 25
SAFECOPYTO # 32
SETGRANT # 34
READBIOS # 35
;
};
driver is
{
system
GETINFO # 26
SETGRANT # 34
;
};
driver pci
{
io cf8:8 # PCI bus controller
4d0:2 # PIIX
;
system
PRIVCTL # 4
KILL # 6
DEVIO # 21
GETINFO # 26
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
;
};
driver at_wini
{
io 1f0:8 # Controller 0
3f6 # Also controller 0
;
irq
14 # Controller 0
;
system
KILL # 6
UMAP # 14
IRQCTL # 19
DEVIO # 21
SDEVIO # 22
VDEVIO # 23
SETALARM # 24
TIMES # 25
GETINFO # 26
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
READBIOS # 35
;
};

6
etc/rs.single Normal file
View file

@ -0,0 +1,6 @@
#!/bin/sh
# 'Recovery' script that doesn't. This script is to be used for drivers that
# should not be restarted. Instead, the scripts configures the driver 'down'.
echo "Arguments: $@" >/dev/console
service down "$1"

View file

@ -560,8 +560,7 @@
#define RS_UP_COPY (RS_RQ_BASE + 6) /* start system service and
* keep the binary in memory
*/
#define RS_RUN (RS_RQ_BASE + 7) /* run without restart */
#define RS_START (RS_RQ_BASE + 8) /* start a driver/service
#define RS_START (RS_RQ_BASE + 7) /* start a driver/service
* arguments are passed in
* a struct rs_start
*/

View file

@ -83,7 +83,6 @@ PUBLIC int main(void)
switch(call_nr) {
case RS_UP: result = do_up(&m, FALSE, 0); break;
case RS_UP_COPY: result = do_up(&m, TRUE, 0); break;
case RS_RUN: result = do_up(&m, FALSE, RS_EXITING); break;
case RS_START: result = do_start(&m); break;
case RS_DOWN: result = do_down(&m); break;
case RS_REFRESH: result = do_refresh(&m); break;
@ -139,7 +138,6 @@ PRIVATE void init_server(void)
for (s=0; s< NR_BOOT_PROCS; s++) {
ip = &image[s];
if (ip->proc_nr >= 0) {
nr_in_use ++;
rproc[s].r_flags = RS_IN_USE;
rproc[s].r_proc_nr_e = ip->endpoint;
rproc[s].r_pid = getnpid(ip->proc_nr);

View file

@ -20,8 +20,6 @@
/* Allocate variables. */
struct rproc rproc[NR_SYS_PROCS]; /* system process table */
struct rproc *rproc_ptr[NR_PROCS]; /* mapping for fast access */
int nr_in_use; /* number of services */
extern int errno; /* error status */
/* Prototypes for internal functions that do the hard work. */
FORWARD _PROTOTYPE( int start_service, (struct rproc *rp, int flags,
@ -61,13 +59,11 @@ int flags; /* extra flags, if any */
endpoint_t ep; /* new endpoint no. */
/* See if there is a free entry in the table with system processes. */
if (nr_in_use >= NR_SYS_PROCS) return(EAGAIN);
for (slot_nr = 0; slot_nr < NR_SYS_PROCS; slot_nr++) {
rp = &rproc[slot_nr]; /* get pointer to slot */
if (! rp->r_flags & RS_IN_USE) /* check if available */
break;
}
nr_in_use ++; /* update administration */
/* Obtain command name and parameters. This is a space-separated string
* that looks like "/sbin/service arg1 arg2 ...". Arguments are optional.
@ -166,13 +162,11 @@ message *m_ptr; /* request message pointer */
if (s != OK) return(s);
/* See if there is a free entry in the table with system processes. */
if (nr_in_use >= NR_SYS_PROCS) return(EAGAIN);
for (slot_nr = 0; slot_nr < NR_SYS_PROCS; slot_nr++) {
rp = &rproc[slot_nr]; /* get pointer to slot */
if (! rp->r_flags & RS_IN_USE) /* check if available */
break;
}
nr_in_use ++; /* update administration */
/* Obtain command name and parameters. This is a space-separated string
* that looks like "/sbin/service arg1 arg2 ...". Arguments are optional.
@ -977,8 +971,8 @@ struct priv *privp;
src_bit, call_nr;
unsigned long mask;
/* Clear the privilege structure */
memset(privp, '\0', sizeof(*privp));
/* Clear s_k_call_mask */
memset(privp->s_k_call_mask, '\0', sizeof(privp->s_k_call_mask));
src_bits_per_word= 8*sizeof(rp->r_call_mask[0]);
dst_bits_per_word= 8*sizeof(privp->s_k_call_mask[0]);
@ -1017,6 +1011,12 @@ int endpoint;
int i, r;
struct rs_pci rs_pci;
if (strcmp(rp->r_label, "pci") == 0)
{
printf("init_pci: not when starting 'pci'\n");
return;
}
len= strlen(rp->r_label);
if (len+1 > sizeof(rs_pci.rsp_label))
{

View file

@ -60,7 +60,6 @@ extern struct rproc {
/* Mapping for fast access to the system process table. */
extern struct rproc *rproc_ptr[NR_PROCS];
extern int nr_in_use;
/* Flag values. */
#define RS_IN_USE 0x001 /* set when process slot is in use */

View file

@ -33,14 +33,15 @@ PRIVATE char *known_requests[] = {
"rescue",
"shutdown",
"upcopy", /* fill for RS_UP_COPY */
"run",
"catch for illegal requests"
};
#define ILLEGAL_REQUEST sizeof(known_requests)/sizeof(char *)
/* Global error number set for failed system calls. */
#define OK 0
extern int errno;
#define RUN_CMD "run"
#define RUN_SCRIPT "/etc/rs.single" /* Default script for 'run' */
/* Define names for arguments provided to this utility. The first few
* arguments are required and have a known index. Thereafter, some optional
@ -75,6 +76,7 @@ extern int errno;
* are stored globally in the following variables:
*/
PRIVATE int req_type;
PRIVATE int do_run= 0; /* 'run' command instead of 'up' */
PRIVATE char *req_label;
PRIVATE char *req_path;
PRIVATE char *req_args;
@ -150,22 +152,38 @@ PRIVATE int parse_arguments(int argc, char **argv)
exit(EINVAL);
}
/* Verify request type. */
for (req_type=0; req_type< ILLEGAL_REQUEST; req_type++) {
if (strcmp(known_requests[req_type],argv[optind+ARG_REQUEST])==0) break;
if (strcmp(argv[optind+ARG_REQUEST], RUN_CMD) == 0)
{
req_nr= RS_UP;
do_run= TRUE;
}
if (req_type == ILLEGAL_REQUEST) {
print_usage(argv[ARG_NAME], "illegal request type");
exit(ENOSYS);
else
{
/* Verify request type. */
for (req_type=0; req_type< ILLEGAL_REQUEST; req_type++) {
if (strcmp(known_requests[req_type],argv[optind+ARG_REQUEST])==0)
break;
}
if (req_type == ILLEGAL_REQUEST) {
print_usage(argv[ARG_NAME], "illegal request type");
exit(ENOSYS);
}
req_nr = RS_RQ_BASE + req_type;
}
req_nr = RS_RQ_BASE + req_type;
if (req_nr == RS_UP || req_nr == RS_RUN) {
if (req_nr == RS_UP) {
rs_start.rss_flags= 0;
if (c_flag)
rs_start.rss_flags |= RF_COPY;
if (do_run)
{
/* Set default recovery script for RUN */
req_script = RUN_SCRIPT;
req_nr = RS_START;
}
if (req_nr == RS_UP && c_flag)
req_nr= RS_UP_COPY;
@ -640,6 +658,8 @@ struct
int call_nr;
} system_tab[]=
{
{ "PRIVCTL", SYS_PRIVCTL },
{ "TRACE", SYS_TRACE },
{ "KILL", SYS_KILL },
{ "UMAP", SYS_UMAP },
{ "VIRCOPY", SYS_VIRCOPY },
@ -652,7 +672,9 @@ struct
{ "GETINFO", SYS_GETINFO },
{ "SAFECOPYFROM", SYS_SAFECOPYFROM },
{ "SAFECOPYTO", SYS_SAFECOPYTO },
{ "VSAFECOPY", SYS_VSAFECOPY },
{ "SETGRANT", SYS_SETGRANT },
{ "READBIOS", SYS_READBIOS },
{ NULL, 0 }
};
@ -865,7 +887,6 @@ PUBLIC int main(int argc, char **argv)
switch(request) {
case RS_UP:
case RS_UP_COPY:
case RS_RUN:
/* Build space-separated command string to be passed to RS server. */
strcpy(command, req_path);
command[strlen(req_path)] = ' ';