Fixed bug relating to FS and MEMORY during startup;

Relocated some syslib functions to utils library;
Changed location of 'Multiuser startup ..." echo in /etc/rc
This commit is contained in:
Jorrit Herder 2005-06-06 09:30:44 +00:00
parent f2a85e58d9
commit c281867f46
22 changed files with 121 additions and 148 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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();
}
}

View file

@ -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 <minix/keymap.h>, 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", "<none>");
}
printf(" %sShift-F%d: ", i+1<10? " ":"", i+1);
if (i==0) {
printf("%-14.14s", "<reserved by TTY>");
} 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", "<none>");
}
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", "<none>");
}
printf(" %sShift-F%d: ", i+1<10? " ":"", i+1);
if (i==0) {
printf("%-14.14s", "<reserved by TTY>");
} 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", "<none>");
}
printf("\n");
}
printf("\n");
printf("Press one of the registered function keys to trigger a debug dump.\n");
printf("\n");
}
/*==========================================================================*
* scan_keyboard *
*==========================================================================*/

View file

@ -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, ...) );

View file

@ -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 */

View file

@ -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) {

View file

@ -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

View file

@ -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

View file

@ -1,35 +0,0 @@
#include "utils.h"
#include <minix/config.h>
#include <timers.h>
#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);
}

View file

@ -10,9 +10,7 @@
* to pollute the kernel message buffer with its debug dumps.
*/
#include "syslib.h"
#include <minix/callnr.h>
#include <minix/minlib.h>
#include "utils.h"
/*===========================================================================*
* kputc *

View file

@ -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

View file

@ -16,6 +16,7 @@
#include <errno.h>
#include <minix/syslib.h>
#include <minix/utils.h>
#include "const.h"
#include "type.h"

View file

@ -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

View file

@ -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"));

View file

@ -28,6 +28,7 @@ Copyright 1995 Philip Homburg
#include <minix/const.h>
#include <minix/com.h>
#include <minix/syslib.h>
#include <minix/utils.h>
#include <net/hton.h>
#include <net/gen/ether.h>
#include <net/gen/eth_hdr.h>

View file

@ -20,6 +20,7 @@ Copyright 1995 Philip Homburg
#include <minix/config.h>
#include <minix/type.h>
#include <minix/syslib.h>
#include <minix/utils.h>
#include <unistd.h>
#include "inet_config.h"

View file

@ -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);

View file

@ -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

View file

@ -15,6 +15,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <minix/syslib.h>
#include <minix/utils.h>
#include <limits.h>
#include <errno.h>