2005-06-07 16:43:35 +02:00
|
|
|
/* Debugging dump procedures for the kernel. */
|
|
|
|
|
2005-10-20 22:28:54 +02:00
|
|
|
#include "inc.h"
|
2005-06-07 16:43:35 +02:00
|
|
|
#include <timers.h>
|
|
|
|
#include <ibm/interrupt.h>
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
#include <minix/endpoint.h>
|
2009-01-12 23:14:43 +01:00
|
|
|
#include <minix/sysutil.h>
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
#include <minix/sys_config.h>
|
2005-06-07 16:43:35 +02:00
|
|
|
#include "../../kernel/const.h"
|
2005-07-14 17:16:12 +02:00
|
|
|
#include "../../kernel/config.h"
|
|
|
|
#include "../../kernel/debug.h"
|
2005-06-07 16:43:35 +02:00
|
|
|
#include "../../kernel/type.h"
|
|
|
|
#include "../../kernel/proc.h"
|
2005-07-29 17:00:49 +02:00
|
|
|
#include "../../kernel/ipc.h"
|
2005-06-07 16:43:35 +02:00
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
#define LINES 22
|
|
|
|
|
2009-01-27 13:54:33 +01:00
|
|
|
#define PRINTRTS(rp) { \
|
|
|
|
char *procname = ""; \
|
|
|
|
printf(" %s", p_rts_flags_str(rp->p_rts_flags)); \
|
|
|
|
if (rp->p_rts_flags & (SENDING|RECEIVING)) { \
|
|
|
|
procname = proc_name(_ENDPOINT_P(rp->p_getfrom_e)); \
|
|
|
|
} \
|
|
|
|
printf(" %-7.7s", procname); \
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pagelines;
|
|
|
|
|
|
|
|
#define PROCLOOP(rp, oldrp) \
|
|
|
|
pagelines = 0; \
|
|
|
|
for (rp = oldrp; rp < END_PROC_ADDR; rp++) { \
|
|
|
|
oldrp = BEG_PROC_ADDR; \
|
|
|
|
if (isemptyp(rp)) continue; \
|
|
|
|
if (++pagelines > LINES) { oldrp = rp; printf("--more--\n"); break; }\
|
|
|
|
if (proc_nr(rp) == IDLE) printf("(%2d) ", proc_nr(rp)); \
|
|
|
|
else if (proc_nr(rp) < 0) printf("[%2d] ", proc_nr(rp)); \
|
|
|
|
else printf(" %2d ", proc_nr(rp));
|
|
|
|
|
2005-06-07 16:43:35 +02:00
|
|
|
#define click_to_round_k(n) \
|
|
|
|
((unsigned) ((((unsigned long) (n) << CLICK_SHIFT) + 512) / 1024))
|
|
|
|
|
|
|
|
/* Declare some local dump procedures. */
|
|
|
|
FORWARD _PROTOTYPE( char *proc_name, (int proc_nr) );
|
2005-07-29 17:00:49 +02:00
|
|
|
FORWARD _PROTOTYPE( char *s_traps_str, (int flags) );
|
|
|
|
FORWARD _PROTOTYPE( char *s_flags_str, (int flags) );
|
|
|
|
FORWARD _PROTOTYPE( char *p_rts_flags_str, (int flags) );
|
2005-06-07 16:43:35 +02:00
|
|
|
|
|
|
|
/* Some global data that is shared among several dumping procedures.
|
|
|
|
* Note that the process table copy has the same name as in the kernel
|
|
|
|
* so that most macros and definitions from proc.h also apply here.
|
|
|
|
*/
|
|
|
|
PUBLIC struct proc proc[NR_TASKS + NR_PROCS];
|
2005-07-14 17:16:12 +02:00
|
|
|
PUBLIC struct priv priv[NR_SYS_PROCS];
|
2005-07-29 17:00:49 +02:00
|
|
|
PUBLIC struct boot_image image[NR_BOOT_PROCS];
|
2005-06-07 16:43:35 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* timing_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void timing_dmp()
|
|
|
|
{
|
2009-01-12 23:14:43 +01:00
|
|
|
static struct util_timingdata timingdata[TIMING_CATEGORIES];
|
2005-06-07 16:43:35 +02:00
|
|
|
int r, c, f, skipped = 0, printed = 0, maxlines = 23, x = 0;
|
|
|
|
static int offsetlines = 0;
|
|
|
|
|
2005-07-14 17:16:12 +02:00
|
|
|
if ((r = sys_getlocktimings(&timingdata[0])) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of lock timings", r);
|
2005-06-07 16:43:35 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(c = 0; c < TIMING_CATEGORIES; c++) {
|
|
|
|
int b;
|
2005-09-11 18:45:46 +02:00
|
|
|
if (!timingdata[c].lock_timings_range[0] || !timingdata[c].binsize)
|
2005-06-07 16:43:35 +02:00
|
|
|
continue;
|
|
|
|
x = printf("%-*s: misses %lu, resets %lu, measurements %lu: ",
|
|
|
|
TIMING_NAME, timingdata[c].names,
|
|
|
|
timingdata[c].misses,
|
|
|
|
timingdata[c].resets,
|
|
|
|
timingdata[c].measurements);
|
|
|
|
for(b = 0; b < TIMING_POINTS; b++) {
|
|
|
|
int w;
|
2005-09-11 18:45:46 +02:00
|
|
|
if (!timingdata[c].lock_timings[b])
|
2005-06-07 16:43:35 +02:00
|
|
|
continue;
|
|
|
|
x += (w = printf(" %5d: %5d", timingdata[c].lock_timings_range[0] +
|
|
|
|
b*timingdata[c].binsize,
|
|
|
|
timingdata[c].lock_timings[b]));
|
2005-09-11 18:45:46 +02:00
|
|
|
if (x + w >= 80) { printf("\n"); x = 0; }
|
2005-06-07 16:43:35 +02:00
|
|
|
}
|
2005-09-11 18:45:46 +02:00
|
|
|
if (x > 0) printf("\n");
|
2005-06-07 16:43:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* kmessages_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void kmessages_dmp()
|
|
|
|
{
|
|
|
|
struct kmessages kmess; /* get copy of kernel messages */
|
2008-11-19 13:26:10 +01:00
|
|
|
char print_buf[_KMESS_BUF_SIZE+1]; /* this one is used to print */
|
2005-06-07 16:43:35 +02:00
|
|
|
int start; /* calculate start of messages */
|
|
|
|
int r;
|
|
|
|
|
|
|
|
/* Try to get a copy of the kernel messages. */
|
|
|
|
if ((r = sys_getkmessages(&kmess)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of kmessages", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to print the kernel messages. First determine start and copy the
|
|
|
|
* buffer into a print-buffer. This is done because the messages in the
|
|
|
|
* copy may wrap (the kernel buffer is circular).
|
|
|
|
*/
|
2008-11-19 13:26:10 +01:00
|
|
|
start = ((kmess.km_next + _KMESS_BUF_SIZE) - kmess.km_size) % _KMESS_BUF_SIZE;
|
2005-06-07 16:43:35 +02:00
|
|
|
r = 0;
|
|
|
|
while (kmess.km_size > 0) {
|
2008-11-19 13:26:10 +01:00
|
|
|
print_buf[r] = kmess.km_buf[(start+r) % _KMESS_BUF_SIZE];
|
2005-06-07 16:43:35 +02:00
|
|
|
r ++;
|
|
|
|
kmess.km_size --;
|
|
|
|
}
|
|
|
|
print_buf[r] = 0; /* make sure it terminates */
|
|
|
|
printf("Dump of all messages generated by the kernel.\n\n");
|
|
|
|
printf("%s", print_buf); /* print the messages */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* monparams_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void monparams_dmp()
|
|
|
|
{
|
|
|
|
char val[1024];
|
|
|
|
char *e;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
/* Try to get a copy of the boot monitor parameters. */
|
|
|
|
if ((r = sys_getmonparams(val, sizeof(val))) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of monitor params", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append new lines to the result. */
|
|
|
|
e = val;
|
|
|
|
do {
|
|
|
|
e += strlen(e);
|
|
|
|
*e++ = '\n';
|
|
|
|
} while (*e != 0);
|
|
|
|
|
|
|
|
/* Finally, print the result. */
|
|
|
|
printf("Dump of kernel environment strings set by boot monitor.\n");
|
|
|
|
printf("\n%s\n", val);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* irqtab_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void irqtab_dmp()
|
|
|
|
{
|
2005-08-25 14:04:36 +02:00
|
|
|
int i,r;
|
2005-06-07 16:43:35 +02:00
|
|
|
struct irq_hook irq_hooks[NR_IRQ_HOOKS];
|
2006-01-12 15:41:40 +01:00
|
|
|
int irq_actids[NR_IRQ_VECTORS];
|
2005-06-07 16:43:35 +02:00
|
|
|
struct irq_hook *e; /* irq tab entry */
|
|
|
|
|
|
|
|
if ((r = sys_getirqhooks(irq_hooks)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of irq hooks", r);
|
|
|
|
return;
|
|
|
|
}
|
2006-01-12 15:41:40 +01:00
|
|
|
if ((r = sys_getirqactids(irq_actids)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of irq mask", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2006-02-24 13:55:00 +01:00
|
|
|
printf("irq_actids:");
|
2006-01-12 15:41:40 +01:00
|
|
|
for (i= 0; i<NR_IRQ_VECTORS; i++)
|
2006-02-24 13:55:00 +01:00
|
|
|
printf(" [%d] = 0x%08x", i, irq_actids[i]);
|
|
|
|
printf("\n");
|
2006-01-12 15:41:40 +01:00
|
|
|
#endif
|
2005-06-07 16:43:35 +02:00
|
|
|
|
|
|
|
printf("IRQ policies dump shows use of kernel's IRQ hooks.\n");
|
Mostly bugfixes of bugs triggered by the test set.
bugfixes:
SYSTEM:
. removed
rc->p_priv->s_flags = 0;
for the priv struct shared by all user processes in get_priv(). this
should only be done once. doing a SYS_PRIV_USER in sys_privctl()
caused the flags of all user processes to be reset, so they were no
longer PREEMPTIBLE. this happened when RS executed a policy script.
(this broke test1 in the test set)
VFS/MFS:
. chown can change the mode of a file, and chmod arguments are only
part of the full file mode so the full filemode is slightly magic.
changed these calls so that the final modes are returned to VFS, so
that the vnode can be kept up-to-date.
(this broke test11 in the test set)
MFS:
. lookup() checked for sizeof(string) instead of sizeof(user_path),
truncating long path names
(caught by test 23)
. truncate functions neglected to update ctime
(this broke test16)
VFS:
. corner case of an empty filename lookup caused fields of a request
not to be filled in in the lookup functions, not making it clear
that the lookup had failed, causing messages to garbage processes,
causing strange failures.
(caught by test 30)
. trust v_size in vnode when doing reads or writes on non-special
files, truncating i/o where necessary; this is necessary for pipes,
as MFS can't tell when a pipe has been truncated without it being
told explicitly each time.
when the last reader/writer on a pipe closes, tell FS about
the new size using truncate_vn().
(this broke test 25, among others)
. permission check for chdir() had disappeared; added a
forbidden() call
(caught by test 23)
new code, shouldn't change anything:
. introduced RTS_SET, RTS_UNSET, and RTS_ISSET macro's, and their
LOCK variants. These macros set and clear the p_rts_flags field,
causing a lot of duplicated logic like
old_flags = rp->p_rts_flags; /* save value of the flags */
rp->p_rts_flags &= ~NO_PRIV;
if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
to change into the simpler
RTS_LOCK_UNSET(rp, NO_PRIV);
so the macros take care of calling dequeue() and enqueue() (or lock_*()),
as the case may be). This makes the code a bit more readable and a
bit less fragile.
. removed return code from do_clocktick in CLOCK as it currently
never replies
. removed some debug code from VFS
. fixed grant debug message in device.c
preemptive checks, tests, changes:
. added return code checks of receive() to SYSTEM and CLOCK
. O_TRUNC should never arrive at MFS (added sanity check and removed
O_TRUNC code)
. user_path declared with PATH_MAX+1 to let it be null-terminated
. checks in MFS to see if strings passed by VFS are null-terminated
IS:
. static irq name table thrown out
2007-02-01 18:50:02 +01:00
|
|
|
printf("-h.id- -proc.nr- -irq nr- -policy- -notify id-\n");
|
2005-06-07 16:43:35 +02:00
|
|
|
for (i=0; i<NR_IRQ_HOOKS; i++) {
|
|
|
|
e = &irq_hooks[i];
|
|
|
|
printf("%3d", i);
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
if (e->proc_nr_e==NONE) {
|
2005-06-07 16:43:35 +02:00
|
|
|
printf(" <unused>\n");
|
|
|
|
continue;
|
|
|
|
}
|
endpoint-aware conversion of servers.
'who', indicating caller number in pm and fs and some other servers, has
been removed in favour of 'who_e' (endpoint) and 'who_p' (proc nr.).
In both PM and FS, isokendpt() convert endpoints to process slot
numbers, returning OK if it was a valid and consistent endpoint number.
okendpt() does the same but panic()s if it doesn't succeed. (In PM,
this is pm_isok..)
pm and fs keep their own records of process endpoints in their proc tables,
which are needed to make kernel calls about those processes.
message field names have changed.
fs drivers are endpoints.
fs now doesn't try to get out of driver deadlock, as the protocol isn't
supposed to let that happen any more. (A warning is printed if ELOCKED
is detected though.)
fproc[].fp_task (indicating which driver the process is suspended on)
became an int.
PM and FS now get endpoint numbers of initial boot processes from the
kernel. These happen to be the same as the old proc numbers, to let
user processes reach them with the old numbers, but FS and PM don't know
that. All new processes after INIT, even after the generation number
wraps around, get endpoint numbers with generation 1 and higher, so
the first instances of the boot processes are the only processes ever
to have endpoint numbers in the old proc number range.
More return code checks of sys_* functions have been added.
IS has become endpoint-aware. Ditched the 'text' and 'data' fields
in the kernel dump (which show locations, not sizes, so aren't terribly
useful) in favour of the endpoint number. Proc number is still visible.
Some other dumps (e.g. dmap, rs) show endpoint numbers now too which got
the formatting changed.
PM reading segments using rw_seg() has changed - it uses other fields
in the message now instead of encoding the segment and process number and
fd in the fd field. For that it uses _read_pm() and _write_pm() which to
_taskcall()s directly in pm/misc.c.
PM now sys_exit()s itself on panic(), instead of sys_abort().
RS also talks in endpoints instead of process numbers.
2006-03-03 11:20:58 +01:00
|
|
|
printf("%10d ", e->proc_nr_e);
|
Mostly bugfixes of bugs triggered by the test set.
bugfixes:
SYSTEM:
. removed
rc->p_priv->s_flags = 0;
for the priv struct shared by all user processes in get_priv(). this
should only be done once. doing a SYS_PRIV_USER in sys_privctl()
caused the flags of all user processes to be reset, so they were no
longer PREEMPTIBLE. this happened when RS executed a policy script.
(this broke test1 in the test set)
VFS/MFS:
. chown can change the mode of a file, and chmod arguments are only
part of the full file mode so the full filemode is slightly magic.
changed these calls so that the final modes are returned to VFS, so
that the vnode can be kept up-to-date.
(this broke test11 in the test set)
MFS:
. lookup() checked for sizeof(string) instead of sizeof(user_path),
truncating long path names
(caught by test 23)
. truncate functions neglected to update ctime
(this broke test16)
VFS:
. corner case of an empty filename lookup caused fields of a request
not to be filled in in the lookup functions, not making it clear
that the lookup had failed, causing messages to garbage processes,
causing strange failures.
(caught by test 30)
. trust v_size in vnode when doing reads or writes on non-special
files, truncating i/o where necessary; this is necessary for pipes,
as MFS can't tell when a pipe has been truncated without it being
told explicitly each time.
when the last reader/writer on a pipe closes, tell FS about
the new size using truncate_vn().
(this broke test 25, among others)
. permission check for chdir() had disappeared; added a
forbidden() call
(caught by test 23)
new code, shouldn't change anything:
. introduced RTS_SET, RTS_UNSET, and RTS_ISSET macro's, and their
LOCK variants. These macros set and clear the p_rts_flags field,
causing a lot of duplicated logic like
old_flags = rp->p_rts_flags; /* save value of the flags */
rp->p_rts_flags &= ~NO_PRIV;
if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
to change into the simpler
RTS_LOCK_UNSET(rp, NO_PRIV);
so the macros take care of calling dequeue() and enqueue() (or lock_*()),
as the case may be). This makes the code a bit more readable and a
bit less fragile.
. removed return code from do_clocktick in CLOCK as it currently
never replies
. removed some debug code from VFS
. fixed grant debug message in device.c
preemptive checks, tests, changes:
. added return code checks of receive() to SYSTEM and CLOCK
. O_TRUNC should never arrive at MFS (added sanity check and removed
O_TRUNC code)
. user_path declared with PATH_MAX+1 to let it be null-terminated
. checks in MFS to see if strings passed by VFS are null-terminated
IS:
. static irq name table thrown out
2007-02-01 18:50:02 +01:00
|
|
|
printf(" (%02d) ", e->irq);
|
2005-07-29 14:44:42 +02:00
|
|
|
printf(" %s", (e->policy & IRQ_REENABLE) ? "reenable" : " - ");
|
2006-01-12 15:41:40 +01:00
|
|
|
printf(" %d", e->notify_id);
|
|
|
|
if (irq_actids[e->irq] & (1 << i))
|
|
|
|
printf("masked");
|
|
|
|
printf("\n");
|
2005-06-07 16:43:35 +02:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* image_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void image_dmp()
|
|
|
|
{
|
2005-07-26 15:51:21 +02:00
|
|
|
int m, i,j,r;
|
2005-07-29 17:00:49 +02:00
|
|
|
struct boot_image *ip;
|
2005-08-04 21:23:03 +02:00
|
|
|
static char ipc_to[BITCHUNK_BITS*2];
|
2005-06-07 16:43:35 +02:00
|
|
|
|
|
|
|
if ((r = sys_getimage(image)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of image table", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
printf("Image table dump showing all processes included in system image.\n");
|
2005-08-04 21:23:03 +02:00
|
|
|
printf("---name-- -nr- -flags- -traps- -sq- ----pc- -stack- -ipc_to[0]--------\n");
|
2005-07-26 15:51:21 +02:00
|
|
|
for (m=0; m<NR_BOOT_PROCS; m++) {
|
|
|
|
ip = &image[m];
|
|
|
|
for (i=j=0; i < BITCHUNK_BITS; i++, j++) {
|
2005-08-04 21:23:03 +02:00
|
|
|
ipc_to[j] = (ip->ipc_to & (1<<i)) ? '1' : '0';
|
|
|
|
if (i % 8 == 7) ipc_to[++j] = ' ';
|
2005-07-26 15:51:21 +02:00
|
|
|
}
|
2005-08-04 21:23:03 +02:00
|
|
|
ipc_to[j] = '\0';
|
2005-07-29 17:00:49 +02:00
|
|
|
printf("%8s %4d %s %s %3d %7lu %7lu %s\n",
|
|
|
|
ip->proc_name, ip->proc_nr,
|
2005-08-04 21:23:03 +02:00
|
|
|
s_flags_str(ip->flags), s_traps_str(ip->trap_mask),
|
|
|
|
ip->priority, (long)ip->initial_pc, ip->stksize, ipc_to);
|
2005-06-07 16:43:35 +02:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* sched_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void sched_dmp()
|
|
|
|
{
|
|
|
|
struct proc *rdy_head[NR_SCHED_QUEUES];
|
|
|
|
struct kinfo kinfo;
|
|
|
|
register struct proc *rp;
|
|
|
|
vir_bytes ptr_diff;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
/* First obtain a scheduling information. */
|
|
|
|
if ((r = sys_getschedinfo(proc, rdy_head)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of process table", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Then obtain kernel addresses to correct pointer information. */
|
|
|
|
if ((r = sys_getkinfo(&kinfo)) != OK) {
|
|
|
|
report("IS","warning: couldn't get kernel addresses", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update all pointers. Nasty pointer algorithmic ... */
|
|
|
|
ptr_diff = (vir_bytes) proc - (vir_bytes) kinfo.proc_addr;
|
|
|
|
for (r=0;r<NR_SCHED_QUEUES; r++)
|
|
|
|
if (rdy_head[r] != NIL_PROC)
|
|
|
|
rdy_head[r] =
|
|
|
|
(struct proc *)((vir_bytes) rdy_head[r] + ptr_diff);
|
|
|
|
for (rp=BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++)
|
|
|
|
if (rp->p_nextready != NIL_PROC)
|
|
|
|
rp->p_nextready =
|
|
|
|
(struct proc *)((vir_bytes) rp->p_nextready + ptr_diff);
|
|
|
|
|
|
|
|
/* Now show scheduling queues. */
|
|
|
|
printf("Dumping scheduling queues.\n");
|
|
|
|
|
|
|
|
for (r=0;r<NR_SCHED_QUEUES; r++) {
|
|
|
|
rp = rdy_head[r];
|
2005-09-11 18:45:46 +02:00
|
|
|
if (!rp) continue;
|
2005-07-27 16:30:17 +02:00
|
|
|
printf("%2d: ", r);
|
2005-06-07 16:43:35 +02:00
|
|
|
while (rp != NIL_PROC) {
|
2005-07-27 16:30:17 +02:00
|
|
|
printf("%3d ", rp->p_nr);
|
2005-06-07 16:43:35 +02:00
|
|
|
rp = rp->p_nextready;
|
|
|
|
}
|
2005-07-27 16:30:17 +02:00
|
|
|
printf("\n");
|
2005-06-07 16:43:35 +02:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* kenv_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void kenv_dmp()
|
|
|
|
{
|
|
|
|
struct kinfo kinfo;
|
|
|
|
struct machine machine;
|
|
|
|
int r;
|
|
|
|
if ((r = sys_getkinfo(&kinfo)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of kernel info struct", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((r = sys_getmachine(&machine)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of kernel machine struct", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Dump of kinfo and machine structures.\n\n");
|
|
|
|
printf("Machine structure:\n");
|
|
|
|
printf("- pc_at: %3d\n", machine.pc_at);
|
|
|
|
printf("- ps_mca: %3d\n", machine.ps_mca);
|
|
|
|
printf("- processor: %3d\n", machine.processor);
|
|
|
|
printf("- vdu_ega: %3d\n", machine.vdu_ega);
|
|
|
|
printf("- vdu_vga: %3d\n\n", machine.vdu_vga);
|
|
|
|
printf("Kernel info structure:\n");
|
|
|
|
printf("- code_base: %5u\n", kinfo.code_base);
|
|
|
|
printf("- code_size: %5u\n", kinfo.code_size);
|
|
|
|
printf("- data_base: %5u\n", kinfo.data_base);
|
|
|
|
printf("- data_size: %5u\n", kinfo.data_size);
|
|
|
|
printf("- proc_addr: %5u\n", kinfo.proc_addr);
|
|
|
|
printf("- bootdev_base: %5u\n", kinfo.bootdev_base);
|
|
|
|
printf("- bootdev_size: %5u\n", kinfo.bootdev_size);
|
2005-10-20 22:28:54 +02:00
|
|
|
printf("- ramdev_base: %5u\n", kinfo.ramdev_base);
|
|
|
|
printf("- ramdev_size: %5u\n", kinfo.ramdev_size);
|
2005-06-07 16:43:35 +02:00
|
|
|
printf("- nr_procs: %3u\n", kinfo.nr_procs);
|
|
|
|
printf("- nr_tasks: %3u\n", kinfo.nr_tasks);
|
2005-06-17 11:13:32 +02:00
|
|
|
printf("- release: %.6s\n", kinfo.release);
|
2005-06-07 16:43:35 +02:00
|
|
|
printf("- version: %.6s\n", kinfo.version);
|
2005-07-14 17:16:12 +02:00
|
|
|
#if DEBUG_LOCK_CHECK
|
2005-06-20 16:52:00 +02:00
|
|
|
printf("- relocking: %d\n", kinfo.relocking);
|
|
|
|
#endif
|
2005-06-07 16:43:35 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-07-27 09:00:20 +02:00
|
|
|
PRIVATE char *s_flags_str(int flags)
|
|
|
|
{
|
|
|
|
static char str[10];
|
|
|
|
str[0] = (flags & PREEMPTIBLE) ? 'P' : '-';
|
2005-08-19 18:43:28 +02:00
|
|
|
str[1] = '-';
|
2005-07-27 09:00:20 +02:00
|
|
|
str[2] = (flags & BILLABLE) ? 'B' : '-';
|
|
|
|
str[3] = (flags & SYS_PROC) ? 'S' : '-';
|
2005-07-29 17:00:49 +02:00
|
|
|
str[4] = '-';
|
|
|
|
str[5] = '\0';
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIVATE char *s_traps_str(int flags)
|
|
|
|
{
|
|
|
|
static char str[10];
|
2007-04-23 16:40:13 +02:00
|
|
|
str[0] = (flags & (1 << SEND)) ? 'S' : '-';
|
|
|
|
str[1] = (flags & (1 << SENDA)) ? 'A' : '-';
|
2005-07-29 17:00:49 +02:00
|
|
|
str[2] = (flags & (1 << RECEIVE)) ? 'R' : '-';
|
|
|
|
str[3] = (flags & (1 << SENDREC)) ? 'B' : '-';
|
|
|
|
str[4] = (flags & (1 << NOTIFY)) ? 'N' : '-';
|
|
|
|
str[5] = '\0';
|
2005-07-27 09:00:20 +02:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2005-07-14 17:16:12 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* privileges_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void privileges_dmp()
|
|
|
|
{
|
|
|
|
register struct proc *rp;
|
|
|
|
static struct proc *oldrp = BEG_PROC_ADDR;
|
|
|
|
register struct priv *sp;
|
2006-06-23 15:27:03 +02:00
|
|
|
int r, i, n = 0;
|
2005-07-14 17:16:12 +02:00
|
|
|
|
|
|
|
/* First obtain a fresh copy of the current process and system table. */
|
|
|
|
if ((r = sys_getprivtab(priv)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of system privileges table", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((r = sys_getproctab(proc)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of process table", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-23 16:40:13 +02:00
|
|
|
printf("\n--nr-id-name---- -flags- -traps- grants -ipc_to-- -ipc_sr-- -system calls--\n");
|
2005-07-14 17:16:12 +02:00
|
|
|
|
2009-01-27 13:54:33 +01:00
|
|
|
PROCLOOP(rp, oldrp)
|
2005-07-14 17:16:12 +02:00
|
|
|
r = -1;
|
|
|
|
for (sp = &priv[0]; sp < &priv[NR_SYS_PROCS]; sp++)
|
|
|
|
if (sp->s_proc_nr == rp->p_nr) { r ++; break; }
|
2005-07-20 17:27:42 +02:00
|
|
|
if (r == -1 && ! (rp->p_rts_flags & SLOT_FREE)) {
|
2005-07-21 20:31:27 +02:00
|
|
|
sp = &priv[USER_PRIV_ID];
|
2005-07-14 17:16:12 +02:00
|
|
|
}
|
2006-06-23 15:27:03 +02:00
|
|
|
printf("(%02u) %-7.7s %s %s %7d",
|
2005-07-21 20:31:27 +02:00
|
|
|
sp->s_id, rp->p_name,
|
2006-06-20 12:03:48 +02:00
|
|
|
s_flags_str(sp->s_flags), s_traps_str(sp->s_trap_mask),
|
|
|
|
sp->s_grant_entries);
|
2006-06-23 15:27:03 +02:00
|
|
|
for (i=0; i < NR_SYS_PROCS; i += BITCHUNK_BITS) {
|
|
|
|
printf(" %04x", get_sys_bits(sp->s_ipc_to, i));
|
2005-07-26 14:49:35 +02:00
|
|
|
}
|
2007-04-23 16:40:13 +02:00
|
|
|
for (i=0; i < NR_SYS_PROCS; i += BITCHUNK_BITS) {
|
|
|
|
printf(" %04x", get_sys_bits(sp->s_ipc_sendrec, i));
|
|
|
|
}
|
2005-07-26 14:49:35 +02:00
|
|
|
|
2006-06-23 15:27:03 +02:00
|
|
|
printf(" ");
|
|
|
|
for (i=0; i < NR_SYS_CALLS; i += BITCHUNK_BITS) {
|
|
|
|
printf(" %04x", sp->s_k_call_mask[i/BITCHUNK_BITS]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
2005-07-14 17:16:12 +02:00
|
|
|
}
|
2005-06-07 16:43:35 +02:00
|
|
|
}
|
|
|
|
|
2005-07-29 17:00:49 +02:00
|
|
|
PRIVATE char *p_rts_flags_str(int flags)
|
|
|
|
{
|
|
|
|
static char str[10];
|
2006-05-11 17:00:46 +02:00
|
|
|
str[0] = (flags & NO_PRIORITY) ? 's' : '-';
|
2005-07-29 17:00:49 +02:00
|
|
|
str[1] = (flags & SENDING) ? 'S' : '-';
|
|
|
|
str[2] = (flags & RECEIVING) ? 'R' : '-';
|
2005-10-12 17:07:38 +02:00
|
|
|
str[3] = (flags & SIGNALED) ? 'I' : '-';
|
2005-07-29 17:00:49 +02:00
|
|
|
str[4] = (flags & SIG_PENDING) ? 'P' : '-';
|
|
|
|
str[5] = (flags & P_STOP) ? 'T' : '-';
|
2006-05-11 17:00:46 +02:00
|
|
|
str[6] = (flags & NO_PRIV) ? 'p' : '-';
|
|
|
|
str[7] = '\0';
|
2005-07-29 17:00:49 +02:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2005-06-07 16:43:35 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* proctab_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
#if (CHIP == INTEL)
|
|
|
|
PUBLIC void proctab_dmp()
|
|
|
|
{
|
|
|
|
/* Proc table dump */
|
|
|
|
|
|
|
|
register struct proc *rp;
|
|
|
|
static struct proc *oldrp = BEG_PROC_ADDR;
|
|
|
|
int r, n = 0;
|
|
|
|
phys_clicks text, data, size;
|
|
|
|
|
|
|
|
/* First obtain a fresh copy of the current process table. */
|
|
|
|
if ((r = sys_getproctab(proc)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of process table", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
printf("\n-nr-----gen---endpoint-name--- -prior-quant- -user----sys--rts flags\n");
|
2005-06-07 16:43:35 +02:00
|
|
|
|
2009-01-27 13:54:33 +01:00
|
|
|
PROCLOOP(rp, oldrp)
|
2005-06-07 16:43:35 +02:00
|
|
|
text = rp->p_memmap[T].mem_phys;
|
|
|
|
data = rp->p_memmap[D].mem_phys;
|
|
|
|
size = rp->p_memmap[T].mem_len
|
|
|
|
+ ((rp->p_memmap[S].mem_phys + rp->p_memmap[S].mem_len) - data);
|
2006-03-03 17:34:37 +01:00
|
|
|
printf(" %5d %10d ", _ENDPOINT_G(rp->p_endpoint), rp->p_endpoint);
|
2009-01-27 13:54:33 +01:00
|
|
|
printf("%-8.8s %02u/%02u %02d/%02u %6lu %6lu",
|
2005-06-07 16:43:35 +02:00
|
|
|
rp->p_name,
|
2005-06-30 17:55:43 +02:00
|
|
|
rp->p_priority, rp->p_max_priority,
|
2005-08-22 17:14:11 +02:00
|
|
|
rp->p_ticks_left, rp->p_quantum_size,
|
2009-01-27 13:54:33 +01:00
|
|
|
rp->p_user_time, rp->p_sys_time);
|
|
|
|
PRINTRTS(rp);
|
2005-06-07 16:43:35 +02:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* (CHIP == INTEL) */
|
|
|
|
|
2009-01-27 13:54:33 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* procstack_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void procstack_dmp()
|
|
|
|
{
|
|
|
|
/* Proc table dump, with stack */
|
|
|
|
|
|
|
|
register struct proc *rp;
|
|
|
|
static struct proc *oldrp = BEG_PROC_ADDR;
|
|
|
|
int r, n = 0;
|
|
|
|
|
|
|
|
/* First obtain a fresh copy of the current process table. */
|
|
|
|
if ((r = sys_getproctab(proc)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of process table", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n-nr-rts flags-- --stack--\n");
|
|
|
|
|
|
|
|
PROCLOOP(rp, oldrp)
|
|
|
|
PRINTRTS(rp);
|
|
|
|
sys_sysctl_stacktrace(rp->p_endpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-07 16:43:35 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* memmap_dmp *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void memmap_dmp()
|
|
|
|
{
|
|
|
|
register struct proc *rp;
|
|
|
|
static struct proc *oldrp = proc;
|
|
|
|
int r, n = 0;
|
|
|
|
phys_clicks size;
|
|
|
|
|
|
|
|
/* First obtain a fresh copy of the current process table. */
|
|
|
|
if ((r = sys_getproctab(proc)) != OK) {
|
|
|
|
report("IS","warning: couldn't get copy of process table", r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
printf("\n-nr/name--- --pc-- --sp-- -text---- -data---- -stack--- -cr3-\n");
|
2009-01-27 13:54:33 +01:00
|
|
|
PROCLOOP(rp, oldrp)
|
2005-06-07 16:43:35 +02:00
|
|
|
size = rp->p_memmap[T].mem_len
|
|
|
|
+ ((rp->p_memmap[S].mem_phys + rp->p_memmap[S].mem_len)
|
|
|
|
- rp->p_memmap[D].mem_phys);
|
2009-01-27 13:54:33 +01:00
|
|
|
printf("%-7.7s%7lx %8lx %4x %4x %4x %4x %5x %5x %8lx\n",
|
2005-06-07 16:43:35 +02:00
|
|
|
rp->p_name,
|
|
|
|
(unsigned long) rp->p_reg.pc,
|
|
|
|
(unsigned long) rp->p_reg.sp,
|
2008-11-19 13:26:10 +01:00
|
|
|
rp->p_memmap[T].mem_phys, rp->p_memmap[T].mem_len,
|
|
|
|
rp->p_memmap[D].mem_phys, rp->p_memmap[D].mem_len,
|
|
|
|
rp->p_memmap[S].mem_phys, rp->p_memmap[S].mem_len,
|
|
|
|
rp->p_seg.p_cr3);
|
2005-06-07 16:43:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* proc_name *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE char *proc_name(proc_nr)
|
|
|
|
int proc_nr;
|
|
|
|
{
|
2009-01-27 13:54:33 +01:00
|
|
|
struct proc *p;
|
2005-06-07 16:43:35 +02:00
|
|
|
if (proc_nr == ANY) return "ANY";
|
2009-01-27 13:54:33 +01:00
|
|
|
if (proc_nr == NONE) return "NONE"; /* bogus */
|
|
|
|
if (proc_nr < -NR_TASKS || proc_nr >= NR_PROCS) return "BOGUS";
|
|
|
|
p = cproc_addr(proc_nr);
|
|
|
|
if (isemptyp(p)) return "EMPTY"; /* bogus */
|
|
|
|
return p->p_name;
|
2005-06-07 16:43:35 +02:00
|
|
|
}
|
|
|
|
|