From: Ben Gras Date: Wed, 28 Mar 2012 16:23:12 +0000 (+0200) Subject: various kernel printing fixes X-Git-Tag: v3.2.1~633 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.dnssec-keyfromlabel.html?a=commitdiff_plain;h=1e399dd8bd252f34626f5b988d3737d91ad4c5bc;p=minix.git various kernel printing fixes . remove some call cycles by low-level functions invoking printf(); e.g. send_sig() gets a return value that the caller should check . reason: very-early-phase printf() would trigger a printf() causing infinite recursion -> GPF . move serial initialization a little earlier so DEBUG_EXTRA works for serial earlier (e.g. its first instance, for "cstart") . closes tracker item 583: System Fails to Complete Startup with Verbose 2 and 3 Boot Parameters, reported by Stephen Hatton / pikpik. --- diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 3e92d7e65..3fdcb9e0a 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -551,7 +551,8 @@ static void vm_suspend(struct proc *caller, const struct proc *target, /* Connect caller on vmrequest wait queue. */ if(!(caller->p_vmrequest.nextrequestor = vmrequest)) - send_sig(VM_PROC_NR, SIGKMEM); + if(OK != send_sig(VM_PROC_NR, SIGKMEM)) + panic("send_sig failed"); vmrequest = caller; } diff --git a/kernel/proc.c b/kernel/proc.c index 352c94ab6..09f4dfbdb 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -1779,25 +1779,11 @@ const int fatalflag; * succeed. */ *p = _ENDPOINT_P(e); - if(!isokprocn(*p)) { -#if DEBUG_ENABLE_IPC_WARNINGS - printf("kernel:%s:%d: bad endpoint %d: proc %d out of range\n", - file, line, e, *p); -#endif - } else if(isemptyn(*p)) { -#if 0 - printf("kernel:%s:%d: bad endpoint %d: proc %d empty\n", file, line, e, *p); -#endif - } else if(proc_addr(*p)->p_endpoint != e) { -#if DEBUG_ENABLE_IPC_WARNINGS - printf("kernel:%s:%d: bad endpoint %d: proc %d has ept %d (generation %d vs. %d)\n", file, line, - e, *p, proc_addr(*p)->p_endpoint, - _ENDPOINT_G(e), _ENDPOINT_G(proc_addr(*p)->p_endpoint)); -#endif - } else ok = 1; - if(!ok && fatalflag) { + ok = 0; + if(isokprocn(*p) && !isemptyn(*p) && proc_addr(*p)->p_endpoint == e) + ok = 1; + if(!ok && fatalflag) panic("invalid endpoint: %d", e); - } return ok; } diff --git a/kernel/proto.h b/kernel/proto.h index 601eed814..8c66598b4 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -81,7 +81,7 @@ int get_priv(register struct proc *rc, int proc_type); void set_sendto_bit(const struct proc *rc, int id); void unset_sendto_bit(const struct proc *rc, int id); void fill_sendto_mask(const struct proc *rc, sys_map_t *map); -void send_sig(endpoint_t proc_nr, int sig_nr); +int send_sig(endpoint_t proc_nr, int sig_nr); void cause_sig(proc_nr_t proc_nr, int sig_nr); void sig_delay_done(struct proc *rp); void kernel_call(message *m_user, struct proc * caller); diff --git a/kernel/start.c b/kernel/start.c index 3a301d0d9..4e98b70e6 100644 --- a/kernel/start.c +++ b/kernel/start.c @@ -56,6 +56,17 @@ void cstart( system_hz = DEFAULT_HZ; #endif +#ifdef DEBUG_SERIAL + /* Intitialize serial debugging */ + value = env_get(SERVARNAME); + if(value && atoi(value) == 0) { + do_serial_debug=1; + + value = env_get(SERBAUDVARNAME); + if (value) serial_debug_baud = atoi(value); + } +#endif + DEBUGEXTRA(("cstart\n")); /* Record miscellaneous information for user-space servers. */ @@ -72,17 +83,6 @@ void cstart( for(h = 0; h < _LOAD_HISTORY; h++) kloadinfo.proc_load_history[h] = 0; -#ifdef DEBUG_SERIAL - /* Intitialize serial debugging */ - value = env_get(SERVARNAME); - if(value && atoi(value) == 0) { - do_serial_debug=1; - - value = env_get(SERBAUDVARNAME); - if (value) serial_debug_baud = atoi(value); - } -#endif - #ifdef USE_APIC value = env_get("no_apic"); if(value) diff --git a/kernel/system.c b/kernel/system.c index 995d9b66f..85b3b44d9 100644 --- a/kernel/system.c +++ b/kernel/system.c @@ -360,7 +360,7 @@ void fill_sendto_mask(const struct proc *rp, sys_map_t *map) /*===========================================================================* * send_sig * *===========================================================================*/ -void send_sig(endpoint_t ep, int sig_nr) +int send_sig(endpoint_t ep, int sig_nr) { /* Notify a system process about a signal. This is straightforward. Simply * set the signal that is to be delivered in the pending signals map and @@ -370,11 +370,13 @@ void send_sig(endpoint_t ep, int sig_nr) int proc_nr; if(!isokendpt(ep, &proc_nr) || isemptyn(proc_nr)) - panic("send_sig to empty process: %d", ep); + return EINVAL; rp = proc_addr(proc_nr); sigaddset(&priv(rp)->s_sig_pending, sig_nr); mini_notify(proc_addr(SYSTEM), rp->p_endpoint); + + return OK; } /*===========================================================================* @@ -425,7 +427,8 @@ int sig_nr; /* signal to be sent */ rp->p_endpoint, sig_nr); } sigaddset(&priv(rp)->s_sig_pending, sig_nr); - send_sig(rp->p_endpoint, SIGKSIGSM); + if(OK != send_sig(rp->p_endpoint, SIGKSIGSM)) + panic("send_sig failed"); return; } @@ -434,7 +437,8 @@ int sig_nr; /* signal to be sent */ sigaddset(&rp->p_pending, sig_nr); if (! (RTS_ISSET(rp, RTS_SIGNALED))) { /* other pending */ RTS_SET(rp, RTS_SIGNALED | RTS_SIG_PENDING); - send_sig(sig_mgr, SIGKSIG); + if(OK != send_sig(sig_mgr, SIGKSIG)) + panic("send_sig failed"); } } } diff --git a/kernel/system/do_safemap.c b/kernel/system/do_safemap.c index 66ac8fc92..20307e1d1 100644 --- a/kernel/system/do_safemap.c +++ b/kernel/system/do_safemap.c @@ -163,7 +163,8 @@ int map_invoke_vm(struct proc * caller, /* Connect caller on vmrequest wait queue. */ if(!(caller->p_vmrequest.nextrequestor = vmrequest)) - send_sig(VM_PROC_NR, SIGKMEM); + if(OK != send_sig(VM_PROC_NR, SIGKMEM)) + panic("send_sig failed"); vmrequest = caller; return OK;