diff --git a/drivers/libdriver/driver.c b/drivers/libdriver/driver.c index b05548825..5490b09df 100644 --- a/drivers/libdriver/driver.c +++ b/drivers/libdriver/driver.c @@ -99,7 +99,7 @@ struct driver *dp; /* Device dependent entry points. */ case DEV_IOCTL: r = (*dp->dr_ioctl)(dp, &mess); break; case DEV_READ: - case DEV_WRITE: r = do_rdwt(dp, &mess); break; + case DEV_WRITE: r = do_rdwt(dp, &mess); break; case DEV_GATHER: case DEV_SCATTER: r = do_vrdwt(dp, &mess); break; diff --git a/drivers/memory/memory.c b/drivers/memory/memory.c index 469ed8225..c63e898d8 100644 --- a/drivers/memory/memory.c +++ b/drivers/memory/memory.c @@ -331,11 +331,17 @@ message *m_ptr; /* pointer to control message */ message m; int s; - if (m_ptr->PROC_NR != FS_PROC_NR) return(EPERM); + if (m_ptr->PROC_NR != FS_PROC_NR) { + report("MEM", "warning, MIOCRAMSIZE called by", m_ptr->PROC_NR); + return(EPERM); + } /* Try to allocate a piece of memory for the RAM disk. */ ramdev_size = m_ptr->POSITION; - if (allocmem(ramdev_size, &ramdev_base) < 0) return(ENOMEM); + if (allocmem(ramdev_size, &ramdev_base) < 0) { + report("MEM", "warning, allocmem failed", errno); + return(ENOMEM); + } dv->dv_base = cvul64(ramdev_base); dv->dv_size = cvul64(ramdev_size); diff --git a/drivers/rtl8139/rtl8139.c b/drivers/rtl8139/rtl8139.c index 8b6c9364c..5b47b736b 100755 --- a/drivers/rtl8139/rtl8139.c +++ b/drivers/rtl8139/rtl8139.c @@ -272,6 +272,8 @@ _PROTOTYPE( static void rl_watchdog_f, (timer_t *tp) ); PRIVATE message m; PRIVATE int int_event_check; /* set to TRUE if events arrived */ +extern int errno; + /*===========================================================================* * rtl8139_task * *===========================================================================*/ @@ -281,8 +283,8 @@ void main(void) re_t *rep; long v; - if ((v=get_proc_nr(&rl_tasknr, NULL)) != OK) - panic("RTL8139", "Couldn't get own proc nr", v); + if (getprocnr(&rl_tasknr) != OK) + panic("RTL8139", "getprocnr failed", errno); v= 0; (void) env_parse("ETH_IGN_PROTO", "x", 0, &v, 0x0000L, 0xFFFFL); @@ -522,11 +524,7 @@ static void rl_pci_conf() rep->re_name[8] += i; rep->re_seen= FALSE; envvar[sizeof(RL_ENVVAR)-1]= '0'+i; -#if DEAD_CODE - if (0 == sys_getkenv(envvar, strlen(envvar), val, sizeof(val)) && -#else if (0 == get_mon_param(envvar, val, sizeof(val)) && -#endif ! env_prefix(envvar, "pci")) { env_panic(envvar); } @@ -706,11 +704,7 @@ re_t *rep; #define BUF_ALIGNMENT (64*1024) -#if DEAD_CODE - if (OK != (i=sys_kmalloc(tot_bufsize, &buf))) { -#else if(!(mallocbuf = malloc(BUF_ALIGNMENT + tot_bufsize))) { -#endif panic("RTL8139","Couldn't allocate kernel buffer",i); } @@ -2379,16 +2373,8 @@ timer_t *tp; rep->re_tx[2].ret_busy, rep->re_tx[3].ret_busy); rep->re_need_reset= TRUE; rep->re_got_int= TRUE; - /* Under MINIX, we got here via a synchronous alarm call. - * Change the message type to HARD_INT to fake an interrupt. - * The switch in the main loop 'falls through' if it sees - * the HARD_INT message type. - */ -#if DEAD_CODE - m.m_type = HARD_INT; -#else - check_int_events(); -#endif + + check_int_events(); } } diff --git a/drivers/tty/keyboard.c b/drivers/tty/keyboard.c index 17bfe545f..3ec03b2d3 100644 --- a/drivers/tty/keyboard.c +++ b/drivers/tty/keyboard.c @@ -83,6 +83,7 @@ FORWARD _PROTOTYPE( int func_key, (int scode) ); FORWARD _PROTOTYPE( int scan_keyboard, (void) ); FORWARD _PROTOTYPE( unsigned make_break, (int scode) ); FORWARD _PROTOTYPE( void set_leds, (void) ); +FORWARD _PROTOTYPE( void show_key_mappings, (void) ); FORWARD _PROTOTYPE( void kb_read, (struct tty *tp) ); FORWARD _PROTOTYPE( unsigned map_key, (int scode) ); @@ -204,6 +205,7 @@ tty_t *tp; } else if (CF1 <= ch && ch <= CF12) { switch(ch) { + case CF1: show_key_mappings(); break; case CF3: toggle_scroll(); break; /* hardware <-> software */ case CF7: sigchar(&tty_table[CONSOLE], SIGQUIT); break; case CF8: sigchar(&tty_table[CONSOLE], SIGINT); break; @@ -421,11 +423,10 @@ message *m_ptr; /* pointer to the request message */ int result; /* See if this key can be observed; get the observers array and index. */ - if (SF1 == fkey) result = EINVAL; /* Shift-F1 is TTY reserved */ if (F1 <= fkey && fkey <= F12) { /* F1-F12 */ observers = fkey_obs; index = fkey - F1; - } else if (SF2 <= fkey && fkey <= SF12) { /* Shift F1-F12 */ + } else if (SF1 <= fkey && fkey <= SF12) { /* Shift F1-F12 */ observers = sfkey_obs; index = fkey - SF1; } @@ -473,7 +474,6 @@ int scode; /* scan code for a function key */ unsigned fkey; int index = -1; int i,s; - struct proc proc; /* Ignore key releases. If this is a key press, get full key code. */ if (scode & KEY_RELEASE) return(FALSE); /* key release */ @@ -487,38 +487,7 @@ int scode; /* scan code for a function key */ * Other combinations are not in use. Note that Alt+Shift+F1-F12 is yet * defined in , but other modifier combinations are not. */ - if (SF1 == fkey) { - printf("\n"); - printf("System information. Known function key mappings to request debug dumps:\n"); - printf("-------------------------------------------------------------------------\n"); - for (i=0; i<12; i++) { - - printf(" %sF%d: ", i+1<10? " ":"", i+1); - if (fkey_obs[i] != NONE) { - if ((s=sys_getproc(&proc, fkey_obs[i]))!=OK) - printf("sys_getproc: %d\n", s); - printf("%-14.14s", proc.p_name); - } else { - printf("%-14.14s", ""); - } - - printf(" %sShift-F%d: ", i+1<10? " ":"", i+1); - if (i==0) { - printf("%-14.14s", ""); - } else if (sfkey_obs[i] != NONE) { - if ((s=sys_getproc(&proc, sfkey_obs[i]))!=OK) - printf("sys_getproc: %d\n", s); - printf("%-14.14s", proc.p_name); - } else { - printf("%-14.14s", ""); - } - printf("\n"); - } - printf("\n"); - printf("Press one of the registered function keys to trigger a debug dump.\n"); - printf("\n"); - } - else if (F1 <= fkey && fkey <= F12) { /* F1-F12 */ + if (F1 <= fkey && fkey <= F12) { /* F1-F12 */ observers = &fkey_obs[0]; index = fkey - F1; } else if (SF2 <= fkey && fkey <= SF12) { /* Shift F2-F12 */ @@ -551,6 +520,46 @@ int scode; /* scan code for a function key */ } +/*==========================================================================* + * show_key_mappings * + *==========================================================================*/ +PRIVATE void show_key_mappings() +{ + int i,s; + struct proc proc; + + printf("\n"); + printf("System information. Known function key mappings to request debug dumps:\n"); + printf("-------------------------------------------------------------------------\n"); + for (i=0; i<12; i++) { + + printf(" %sF%d: ", i+1<10? " ":"", i+1); + if (fkey_obs[i] != NONE) { + if ((s=sys_getproc(&proc, fkey_obs[i]))!=OK) + printf("sys_getproc: %d\n", s); + printf("%-14.14s", proc.p_name); + } else { + printf("%-14.14s", ""); + } + + printf(" %sShift-F%d: ", i+1<10? " ":"", i+1); + if (i==0) { + printf("%-14.14s", ""); + } else if (sfkey_obs[i] != NONE) { + if ((s=sys_getproc(&proc, sfkey_obs[i]))!=OK) + printf("sys_getproc: %d\n", s); + printf("%-14.14s", proc.p_name); + } else { + printf("%-14.14s", ""); + } + printf("\n"); + } + printf("\n"); + printf("Press one of the registered function keys to trigger a debug dump.\n"); + printf("\n"); +} + + /*==========================================================================* * scan_keyboard * *==========================================================================*/ diff --git a/include/minix/syslib.h b/include/minix/syslib.h index 6340cfb6f..972104b71 100755 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -34,8 +34,6 @@ /*==========================================================================* * Minix system library. * *==========================================================================*/ -_PROTOTYPE( int printf, (const char *fmt, ...) ); -_PROTOTYPE( void kputc, (int c) ); _PROTOTYPE( int _taskcall, (int who, int syscallnr, message *msgptr) ); _PROTOTYPE( int sys_abort, (int how, ...) ); diff --git a/include/minix/utils.h b/include/minix/utils.h index e5cb1ceb3..0e5e215db 100644 --- a/include/minix/utils.h +++ b/include/minix/utils.h @@ -7,9 +7,9 @@ * Mar 15, 2004 by Jorrit N. Herder * * Changes: + * May 31, 2005: added printf, kputc (relocated from syslib) * May 31, 2005: added getuptime * Mar 18, 2005: added tickdelay - * Mar 15, 2005: added get_proc_nr * Oct 01, 2004: added env_parse, env_prefix, env_panic * Jul 13, 2004: added fkey_ctl * Apr 28, 2004: added report, panic @@ -29,24 +29,23 @@ #define EP_SET 3 /* var = 1:2:3 (nonblank field) */ #define EP_EGETKENV 4 /* sys_getkenv() failed ... */ -_PROTOTYPE(int get_mon_param, (char *key, char *value, int max_size) ); -_PROTOTYPE(int env_prefix, (char *env, char *prefix) ); -_PROTOTYPE(void env_panic, (char *key) ); -_PROTOTYPE(int env_parse, (char *env, char *fmt, int field, long *param, +_PROTOTYPE( int get_mon_param, (char *key, char *value, int max_size) ); +_PROTOTYPE( int env_prefix, (char *env, char *prefix) ); +_PROTOTYPE( void env_panic, (char *key) ); +_PROTOTYPE( int env_parse, (char *env, char *fmt, int field, long *param, long min, long max) ); #define fkey_enable(fkey) fkey_ctl(fkey, 1) #define fkey_disable(fkey) fkey_ctl(fkey, 0) -_PROTOTYPE(int fkey_ctl, (int fkey_code, int enable_disable) ); +_PROTOTYPE( int fkey_ctl, (int fkey_code, int enable_disable) ); -_PROTOTYPE(int get_proc_nr, (int *proc_nr, char *proc_name) ); - -_PROTOTYPE(void report, (char *who, char *mess, int num)); -_PROTOTYPE(void panic, (char *who, char *mess, int num)); - -_PROTOTYPE(int getuptime, (clock_t *ticks)); -_PROTOTYPE(int tickdelay, (clock_t ticks)); +_PROTOTYPE( int printf, (const char *fmt, ...)); +_PROTOTYPE( void kputc, (int c)); +_PROTOTYPE( void report, (char *who, char *mess, int num)); +_PROTOTYPE( void panic, (char *who, char *mess, int num)); +_PROTOTYPE( int getuptime, (clock_t *ticks)); +_PROTOTYPE( int tickdelay, (clock_t ticks)); #endif /* _EXTRALIB_H */ diff --git a/kernel/proc.c b/kernel/proc.c index fa4d91efc..c4512c606 100755 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -85,12 +85,6 @@ FORWARD _PROTOTYPE( void pick_proc, (void) ); #endif /* (CHIP == M68000) */ -#if DEAD_CODE /* now in glo.h */ -/* Declare buffer space and a bit map for notification messages. */ -PRIVATE struct notification notify_buffer[NR_NOTIFY_BUFS]; -PRIVATE bitchunk_t notify_bitmap[BITMAP_CHUNKS(NR_NOTIFY_BUFS)]; -#endif - /*===========================================================================* * sys_call * @@ -152,6 +146,20 @@ message *m_ptr; /* pointer to message in the caller's space */ */ switch(function) { case SENDREC: /* has FRESH_ANSWER flags */ +#if DEAD_CODE + { message m; + if (caller_ptr->p_nr == MEMORY && src_dst == FS_PROC_NR) { + CopyMess(caller_ptr->p_nr, caller_ptr, m_ptr, proc_addr(HARDWARE), &m); + kprintf("MEMORY sendrec FS, m.m_type %d", m.m_type); + kprintf("TTY_LINE %d", m.TTY_LINE); + kprintf("TTY_REQ %d\n", m.TTY_REQUEST); + } + if (caller_ptr->p_nr == FS_PROC_NR && src_dst == MEMORY) { + CopyMess(caller_ptr->p_nr, caller_ptr, m_ptr, proc_addr(HARDWARE), &m); + kprintf("FS sendrec MEMORY, m.m_type %d\n", m.m_type); + } + } +#endif /* fall through */ case SEND: if (! isalive(src_dst)) { @@ -214,9 +222,7 @@ unsigned flags; /* system call flags */ dst_ptr = proc_addr(dst); /* pointer to destination's proc entry */ - /* Check for deadlock by 'caller_ptr' and 'dst' sending to each other. - * This check is rare, so overhead is acceptable. - */ + /* Check for deadlock by 'caller_ptr' and 'dst' sending to each other. */ if (dst_ptr->p_flags & SENDING) { next_ptr = proc_addr(dst_ptr->p_sendto); while (TRUE) { diff --git a/lib/syslib/Makefile b/lib/syslib/Makefile index cc89de616..4fb9a3753 100755 --- a/lib/syslib/Makefile +++ b/lib/syslib/Makefile @@ -7,9 +7,6 @@ LIBSYS = ../libsys.a all: $(LIBSYS) OBJECTS = \ - $(LIBSYS)(kmalloc.o) \ - $(LIBSYS)(kprintf.o) \ - $(LIBSYS)(kputc.o) \ $(LIBSYS)(sys_times.o) \ $(LIBSYS)(sys_getuptm.o) \ $(LIBSYS)(sys_abort.o) \ @@ -50,15 +47,6 @@ $(LIBSYS): $(OBJECTS) aal cr $@ *.o rm *.o -$(LIBSYS)(kmalloc.o): kmalloc.c - $(CC1) kmalloc.c - -$(LIBSYS)(kprintf.o): kprintf.c - $(CC1) kprintf.c - -$(LIBSYS)(kputc.o): kputc.c - $(CC1) kputc.c - $(LIBSYS)(sys_times.o): sys_times.c $(CC1) sys_times.c diff --git a/lib/utils/Makefile b/lib/utils/Makefile index 8c597cfef..4582c1b25 100644 --- a/lib/utils/Makefile +++ b/lib/utils/Makefile @@ -7,6 +7,9 @@ LIBUTILS = ../libutils.a all: $(LIBUTILS) OBJECTS = \ + $(LIBSYS)(kmalloc.o) \ + $(LIBSYS)(kprintf.o) \ + $(LIBSYS)(kputc.o) \ $(LIBUTILS)(tickdelay.o) \ $(LIBUTILS)(getuptime.o) \ $(LIBUTILS)(get_mon_prm.o) \ @@ -14,7 +17,6 @@ OBJECTS = \ $(LIBUTILS)(env_panic.o) \ $(LIBUTILS)(env_prefix.o) \ $(LIBUTILS)(fkey_ctl.o) \ - $(LIBUTILS)(get_proc_nr.o) \ $(LIBUTILS)(panic.o) \ $(LIBUTILS)(report.o) \ $(LIBUTILS)(taskcall.o) \ @@ -24,6 +26,15 @@ $(LIBUTILS): $(OBJECTS) aal cr $@ *.o rm *.o +$(LIBSYS)(kmalloc.o): kmalloc.c + $(CC1) kmalloc.c + +$(LIBSYS)(kprintf.o): kprintf.c + $(CC1) kprintf.c + +$(LIBSYS)(kputc.o): kputc.c + $(CC1) kputc.c + $(LIBUTILS)(getuptime.o): getuptime.c $(CC1) getuptime.c @@ -45,9 +56,6 @@ $(LIBUTILS)(env_panic.o): env_panic.c $(LIBUTILS)(fkey_ctl.o): fkey_ctl.c $(CC1) fkey_ctl.c -$(LIBUTILS)(get_proc_nr.o): get_proc_nr.c - $(CC1) get_proc_nr.c - $(LIBUTILS)(panic.o): panic.c $(CC1) panic.c diff --git a/lib/utils/get_proc_nr.c b/lib/utils/get_proc_nr.c deleted file mode 100644 index 483c00b7d..000000000 --- a/lib/utils/get_proc_nr.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "utils.h" -#include -#include -#include "../../kernel/const.h" -#include "../../kernel/type.h" -#include "../../kernel/proc.h" - -/*===========================================================================* - * get_proc_nr * - *===========================================================================*/ -PUBLIC int get_proc_nr(proc_nr, proc_name) -int *proc_nr; /* store process number here */ -char *proc_name; /* lookup process by name */ -{ - static struct proc proc; - message m; - int s; - if (proc_name != NULL) { /* lookup by name */ - - } else { /* get own process number */ - m.m_type = SYS_GETINFO; - m.I_REQUEST = GET_PROC; - m.I_PROC_NR = SELF; - m.I_KEY_LEN = SELF; - m.I_VAL_LEN = 0; - m.I_VAL_PTR = (char *) &proc; - m.I_VAL_LEN = 0; - if ((s=_taskcall(SYSTASK, SYS_GETINFO, &m)) != OK) - return(s); - *proc_nr = proc.p_nr; - } - return(OK); -} - - diff --git a/lib/syslib/kmalloc.c b/lib/utils/kmalloc.c similarity index 100% rename from lib/syslib/kmalloc.c rename to lib/utils/kmalloc.c diff --git a/lib/syslib/kprintf.c b/lib/utils/kprintf.c similarity index 100% rename from lib/syslib/kprintf.c rename to lib/utils/kprintf.c diff --git a/lib/syslib/kputc.c b/lib/utils/kputc.c similarity index 95% rename from lib/syslib/kputc.c rename to lib/utils/kputc.c index 27fbca062..1c4f4ed7d 100644 --- a/lib/syslib/kputc.c +++ b/lib/utils/kputc.c @@ -10,9 +10,7 @@ * to pollute the kernel message buffer with its debug dumps. */ -#include "syslib.h" -#include -#include +#include "utils.h" /*===========================================================================* * kputc * diff --git a/servers/fs/Makefile b/servers/fs/Makefile index b012e41ee..e6251a3b0 100644 --- a/servers/fs/Makefile +++ b/servers/fs/Makefile @@ -35,7 +35,7 @@ clean: # dependencies a= fs.h $h/config.h $s/types.h $h/const.h $h/type.h \ - $i/limits.h $i/errno.h $i/ansi.h $h/syslib.h \ + $i/limits.h $i/errno.h $i/ansi.h $h/syslib.h $h/utils.h \ const.h type.h proto.h glo.h $s/dir.h cache.o: $a diff --git a/servers/fs/fs.h b/servers/fs/fs.h index 3912d32c7..3ebc92ed7 100644 --- a/servers/fs/fs.h +++ b/servers/fs/fs.h @@ -16,6 +16,7 @@ #include #include +#include #include "const.h" #include "type.h" diff --git a/servers/fs/main.c b/servers/fs/main.c index aae35d5c2..2832bdf73 100644 --- a/servers/fs/main.c +++ b/servers/fs/main.c @@ -260,7 +260,7 @@ PRIVATE void load_ram(void) struct super_block *sp, *dsp; block_t b; Dev_t image_dev; - int r; + int s,r; static char sbbuf[MIN_BLOCK_SIZE]; int block_size_image, block_size_ram, ramfs_block_size; @@ -303,10 +303,19 @@ PRIVATE void load_ram(void) m_out.m_type = DEV_IOCTL; m_out.PROC_NR = FS_PROC_NR; m_out.DEVICE = RAM_DEV; - m_out.REQUEST = MIOCRAMSIZE; - m_out.POSITION = ram_size_kb*1024; - if (sendrec(MEMORY, &m_out) != OK || m_out.REP_STATUS != OK) - panic(__FILE__,"can't set RAM disk size", NO_NUM); + m_out.REQUEST = MIOCRAMSIZE; /* I/O control to use */ + m_out.POSITION = (ram_size_kb * 1024); /* request in bytes */ + if ((s=sendrec(MEMORY, &m_out)) != OK) + panic("FS","sendrec from MEM failed", s); + else if (m_out.REP_STATUS != OK) { + /* Report and continue, unless RAM disk is required as root FS. */ + if (root_dev != DEV_RAM) { + report("FS","can't set RAM disk size", m_out.REP_STATUS); + return; + } else { + panic(__FILE__,"can't set RAM disk size", m_out.REP_STATUS); + } + } #if ENABLE_CACHE2 diff --git a/servers/inet/inet.c b/servers/inet/inet.c index c656e58ea..7cc6114d7 100644 --- a/servers/inet/inet.c +++ b/servers/inet/inet.c @@ -175,9 +175,6 @@ PRIVATE void nw_init() if (svrctl(SYSSIGNON, (void *) NULL) == -1) pause(); /* Our new identity as a server. */ -#if DEAD_CODE - if (get_proc_nr(&this_proc, NULL) != OK) -#endif if (getprocnr(&this_proc) != OK) ip_panic(( "unable to get own process nr\n")); diff --git a/servers/inet/inet.h b/servers/inet/inet.h index 970550176..3e5840fea 100644 --- a/servers/inet/inet.h +++ b/servers/inet/inet.h @@ -28,6 +28,7 @@ Copyright 1995 Philip Homburg #include #include #include +#include #include #include #include diff --git a/servers/inet/inet_config.c b/servers/inet/inet_config.c index 147148b9a..c2554f341 100644 --- a/servers/inet/inet_config.c +++ b/servers/inet/inet_config.c @@ -20,6 +20,7 @@ Copyright 1995 Philip Homburg #include #include #include +#include #include #include "inet_config.h" diff --git a/servers/is/main.c b/servers/is/main.c index 9b26114e6..d5b6e8db1 100644 --- a/servers/is/main.c +++ b/servers/is/main.c @@ -93,14 +93,14 @@ PRIVATE void init_server() /* Set own process number. */ is_proc_nr = IS_PROC_NR; - /* Set key mappings. IS takes all of F2-F12. F1 is TTY reserved. */ + /* Set key mappings. IS takes all of F1-F12 and Shift+F1-F6 . */ for (key=F1; key<=F12; key++) { if ((r=fkey_enable(key)) != OK) { printf("IS: WARNING: couldn't register F%d key: %d\n", (key-F1+1), r); } } - for (key=SF1; key<=SF12; key++) { + for (key=SF1; key<=SF6; key++) { if ((r=fkey_enable(key)) != OK) { printf("IS: WARNING: couldn't register SF%d key: %d\n", (key-SF1+1), r); diff --git a/servers/pm/Makefile b/servers/pm/Makefile index 1c3874913..e19f3855e 100644 --- a/servers/pm/Makefile +++ b/servers/pm/Makefile @@ -33,7 +33,7 @@ clean: # dependencies a = pm.h $h/config.h $s/types.h $h/const.h $h/type.h \ - $i/ansi.h $i/fcntl.h $i/unistd.h $h/syslib.h \ + $i/ansi.h $i/fcntl.h $i/unistd.h $h/syslib.h $h/utils.h \ $i/limits.h $i/errno.h const.h type.h proto.h glo.h alloc.o: $a diff --git a/servers/pm/pm.h b/servers/pm/pm.h index d22df8a26..b582c5a16 100644 --- a/servers/pm/pm.h +++ b/servers/pm/pm.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include