diff --git a/minix/drivers/system/log/diag.c b/minix/drivers/system/log/diag.c index 28eb1e7e4..565a51c41 100644 --- a/minix/drivers/system/log/diag.c +++ b/minix/drivers/system/log/diag.c @@ -11,8 +11,6 @@ #include -extern struct minix_kerninfo *_minix_kerninfo; - /*==========================================================================* * do_new_kmess * *==========================================================================*/ @@ -24,8 +22,7 @@ void do_new_kmess(void) int i, r, next, bytes; static int prev_next = 0; - assert(_minix_kerninfo); - kmess = _minix_kerninfo->kmessages; + kmess = get_minix_kerninfo()->kmessages; /* Print only the new part. Determine how many new bytes there are with * help of the current and previous 'next' index. Note that the kernel diff --git a/minix/drivers/tty/tty/tty.c b/minix/drivers/tty/tty/tty.c index c964d1709..d017af6eb 100644 --- a/minix/drivers/tty/tty/tty.c +++ b/minix/drivers/tty/tty/tty.c @@ -140,8 +140,6 @@ static void sef_local_startup(void); static int sef_cb_init_fresh(int type, sef_init_info_t *info); static void sef_cb_signal_handler(int signo); -extern struct minix_kerninfo *_minix_kerninfo; - /*===========================================================================* * tty_task * *===========================================================================*/ @@ -397,8 +395,7 @@ do_new_kmess(void) int next, bytes, copy, restore = 0; tty_t *tp, rtp; - assert(_minix_kerninfo); - kmess_ptr = _minix_kerninfo->kmessages; + kmess_ptr = get_minix_kerninfo()->kmessages; /* The kernel buffer is circular; print only the new part. Determine * how many new bytes there are with the help of current and diff --git a/minix/fs/procfs/root.c b/minix/fs/procfs/root.c index e3fc217e8..83aec45d6 100644 --- a/minix/fs/procfs/root.c +++ b/minix/fs/procfs/root.c @@ -183,7 +183,6 @@ root_dmap(void) static void root_ipcvecs(void) { - extern struct minix_kerninfo *_minix_kerninfo; extern struct minix_ipcvecs _minix_ipcvecs; /* @@ -191,8 +190,7 @@ root_ipcvecs(void) * will be using their own in-libc vectors that are normal symbols in * the binary. */ - if (!_minix_kerninfo || - !(_minix_kerninfo->ki_flags & MINIX_KIF_IPCVECS)) + if (!(get_minix_kerninfo()->ki_flags & MINIX_KIF_IPCVECS)) return; /* diff --git a/minix/include/lib.h b/minix/include/lib.h index e5e1d2582..5caa03ecb 100644 --- a/minix/include/lib.h +++ b/minix/include/lib.h @@ -21,10 +21,13 @@ #include #include +struct minix_kerninfo *get_minix_kerninfo(void); + struct ps_strings; /* forward declaration for minix_stack_fill. */ -void minix_stack_params(const char *path, char * const *argv, char * const *envp, - size_t *stack_size, char *overflow, int *argc, int *envc); +void minix_stack_params(const char *path, char * const *argv, + char * const *envp, size_t *stack_size, char *overflow, int *argc, + int *envc); void minix_stack_fill(const char *path, int argc, char * const *argv, int envc, char * const *envp, size_t stack_size, char *frame, int *vsp, struct ps_strings **psp); diff --git a/minix/include/minix/ipc.h b/minix/include/minix/ipc.h index e9ca59467..9e2eeff42 100644 --- a/minix/include/minix/ipc.h +++ b/minix/include/minix/ipc.h @@ -2357,7 +2357,7 @@ int _ipc_senda_intr(asynmsg_t *table, size_t count); int _do_kernel_call_intr(message *m_ptr); -int get_minix_kerninfo(struct minix_kerninfo **); +int ipc_minix_kerninfo(struct minix_kerninfo **); /* Hide names to avoid name space pollution. */ #define ipc_notify _ipc_notify diff --git a/minix/lib/libc/arch/arm/sys/Makefile.inc b/minix/lib/libc/arch/arm/sys/Makefile.inc index a915fcc76..125033e41 100644 --- a/minix/lib/libc/arch/arm/sys/Makefile.inc +++ b/minix/lib/libc/arch/arm/sys/Makefile.inc @@ -14,7 +14,7 @@ SRCS+= \ _do_kernel_call_intr.S \ _ipc.S \ brksize.S \ - get_minix_kerninfo.S \ + ipc_minix_kerninfo.S \ ucontext.S ucontextoffsets.h: ${CF} diff --git a/minix/lib/libc/arch/arm/sys/get_minix_kerninfo.S b/minix/lib/libc/arch/arm/sys/ipc_minix_kerninfo.S similarity index 79% rename from minix/lib/libc/arch/arm/sys/get_minix_kerninfo.S rename to minix/lib/libc/arch/arm/sys/ipc_minix_kerninfo.S index b5179d19d..98e03b976 100644 --- a/minix/lib/libc/arch/arm/sys/get_minix_kerninfo.S +++ b/minix/lib/libc/arch/arm/sys/ipc_minix_kerninfo.S @@ -1,13 +1,13 @@ #include #include -ENTRY(get_minix_kerninfo) +ENTRY(ipc_minix_kerninfo) push {fp} mov fp, sp push {r0} mov r1, #0 mov r2, #0 - mov r0, #MINIX_KERNINFO /* _get_minix_kerninfo() */ + mov r0, #MINIX_KERNINFO /* _ipc_minix_kerninfo() */ mov r3, #IPCVEC_INTR /* r3 determines the SVC type */ svc #0 /* trap to kernel */ pop {r2} /* r2 = return struct ptr (was r0) */ diff --git a/minix/lib/libc/arch/i386/sys/Makefile.inc b/minix/lib/libc/arch/i386/sys/Makefile.inc index a915fcc76..125033e41 100644 --- a/minix/lib/libc/arch/i386/sys/Makefile.inc +++ b/minix/lib/libc/arch/i386/sys/Makefile.inc @@ -14,7 +14,7 @@ SRCS+= \ _do_kernel_call_intr.S \ _ipc.S \ brksize.S \ - get_minix_kerninfo.S \ + ipc_minix_kerninfo.S \ ucontext.S ucontextoffsets.h: ${CF} diff --git a/minix/lib/libc/arch/i386/sys/get_minix_kerninfo.S b/minix/lib/libc/arch/i386/sys/ipc_minix_kerninfo.S similarity index 91% rename from minix/lib/libc/arch/i386/sys/get_minix_kerninfo.S rename to minix/lib/libc/arch/i386/sys/ipc_minix_kerninfo.S index 7f62ee1d0..1114e2788 100644 --- a/minix/lib/libc/arch/i386/sys/get_minix_kerninfo.S +++ b/minix/lib/libc/arch/i386/sys/ipc_minix_kerninfo.S @@ -1,7 +1,7 @@ #include #include -ENTRY(get_minix_kerninfo) +ENTRY(ipc_minix_kerninfo) push %ebp movl %esp, %ebp push %ebx diff --git a/minix/lib/libc/sys/Makefile.inc b/minix/lib/libc/sys/Makefile.inc index fe07b4841..fb693d64a 100644 --- a/minix/lib/libc/sys/Makefile.inc +++ b/minix/lib/libc/sys/Makefile.inc @@ -25,7 +25,7 @@ SRCS+= accept.c access.c adjtime.c bind.c brk.c sbrk.c m_closefrom.c getsid.c \ getrusage.c setrlimit.c setpgid.c # Minix specific syscalls / utils. -SRCS+= sprofile.c stack_utils.c _mcontext.c +SRCS+= kernel_utils.c sprofile.c stack_utils.c _mcontext.c # Emulation for missing lchown/lchmod OBJS+= lchown.o lchmod.o diff --git a/minix/lib/libc/sys/init.c b/minix/lib/libc/sys/init.c index 2047479e8..a7a091b91 100644 --- a/minix/lib/libc/sys/init.c +++ b/minix/lib/libc/sys/init.c @@ -19,7 +19,7 @@ struct minix_ipcvecs _minix_ipcvecs = { void __minix_init(void) { - if((get_minix_kerninfo(&_minix_kerninfo) != 0) || + if((ipc_minix_kerninfo(&_minix_kerninfo) != 0) || (_minix_kerninfo->kerninfo_magic != KERNINFO_MAGIC)) { _minix_kerninfo = NULL; @@ -30,4 +30,3 @@ void __minix_init(void) _minix_ipcvecs = *_minix_kerninfo->minix_ipcvecs; } } - diff --git a/minix/lib/libc/sys/kernel_utils.c b/minix/lib/libc/sys/kernel_utils.c new file mode 100644 index 000000000..38b3f58ae --- /dev/null +++ b/minix/lib/libc/sys/kernel_utils.c @@ -0,0 +1,25 @@ +/* + * This file contains the main routine for retrieval of the kernel information + * page. + */ + +#define _MINIX_SYSTEM + +#include +#include "namespace.h" +#include +#include + +extern struct minix_kerninfo *_minix_kerninfo; + +/* + * Get a pointer to the kernel information page. + */ +struct minix_kerninfo * +get_minix_kerninfo(void) +{ + + assert(_minix_kerninfo != NULL); + + return _minix_kerninfo; +} diff --git a/minix/lib/libc/sys/stack_utils.c b/minix/lib/libc/sys/stack_utils.c index 95bf5d228..133881acd 100644 --- a/minix/lib/libc/sys/stack_utils.c +++ b/minix/lib/libc/sys/stack_utils.c @@ -16,8 +16,6 @@ #include #include -extern struct minix_kerninfo *_minix_kerninfo; - /* Create a stack image that only needs to be patched up slightly by * the kernel to be used for the process to be executed. * @@ -133,7 +131,7 @@ void minix_stack_fill(const char *path, int argc, char * const *argv, size_t const min_size = STACK_MIN_SZ; /* Virtual address of the stack pointer, in new memory space. */ - *vsp = _minix_kerninfo->kinfo->user_sp - stack_size; + *vsp = get_minix_kerninfo()->kinfo->user_sp - stack_size; /* Fill in the frame now. */ fpw = (char **) frame; diff --git a/minix/lib/libminc/Makefile b/minix/lib/libminc/Makefile index ece7b4758..28445f2c1 100644 --- a/minix/lib/libminc/Makefile +++ b/minix/lib/libminc/Makefile @@ -286,7 +286,7 @@ CPPFLAGS.strcspn.c+= -D_LIBC .for f in \ access.o brk.o close.o environ.o execve.o fork.o fsync.o \ getgid.o getpid.o geteuid.o getuid.o gettimeofday.o getvfsstat.o \ - init.o link.o loadname.o lseek.o _mcontext.o mknod.o \ + init.o kernel_utils.o link.o loadname.o lseek.o _mcontext.o mknod.o \ mmap.o nanosleep.o open.o pread.o pwrite.o read.o sbrk.o \ select.o setuid.o sigprocmask.o stack_utils.o stat.o stime.o \ syscall.o _ucontext.o umask.o unlink.o write.o \ @@ -302,7 +302,7 @@ CLEANFILES+= ${f:C/\.o/.bc/} .endfor .for f in \ - brksize.o _do_kernel_call_intr.o get_minix_kerninfo.o _ipc.o ucontext.o + brksize.o _do_kernel_call_intr.o ipc_minix_kerninfo.o _ipc.o ucontext.o ${f} ${f:C/\.o/.bc/}: ${LIBMINIXCARCHDIR}/sys/${f:C/\.o/.S/} OBJS+= ${f} CLEANFILES+= ${f} diff --git a/minix/lib/libsys/arch/earm/frclock_util.c b/minix/lib/libsys/arch/earm/frclock_util.c index 086be43bc..d93198121 100644 --- a/minix/lib/libsys/arch/earm/frclock_util.c +++ b/minix/lib/libsys/arch/earm/frclock_util.c @@ -5,9 +5,9 @@ #include #include -#include #include #include +#include #include #define MICROHZ 1000000ULL /* number of micros per second */ @@ -15,19 +15,19 @@ static u64_t Hz; -extern struct minix_kerninfo *_minix_kerninfo; - int micro_delay(u32_t micros) { + struct minix_kerninfo *minix_kerninfo; u64_t start, delta, delta_end; Hz = sys_hz(); + minix_kerninfo = get_minix_kerninfo(); /* Start of delay. */ read_frclock_64(&start); - assert(_minix_kerninfo->minix_arm_frclock_hz); - delta_end = (_minix_kerninfo->minix_arm_frclock_hz * micros) / MICROHZ; + assert(minix_kerninfo->minix_arm_frclock_hz); + delta_end = (minix_kerninfo->minix_arm_frclock_hz * micros) / MICROHZ; /* If we have to wait for at least one HZ tick, use the regular * tickdelay first. Round downwards on purpose, so the average @@ -49,16 +49,20 @@ micro_delay(u32_t micros) u32_t frclock_64_to_micros(u64_t tsc) { - return (u32_t) (tsc / (_minix_kerninfo->minix_arm_frclock_hz / MICROHZ)); + return (u32_t) + (tsc / (get_minix_kerninfo()->minix_arm_frclock_hz / MICROHZ)); } void read_frclock(u32_t *frclk) { + struct minix_kerninfo *minix_kerninfo = get_minix_kerninfo(); + assert(frclk); - assert(_minix_kerninfo->minix_frclock_tcrr); - assert(_minix_kerninfo->minix_arm_frclock_hz); - *frclk = *(volatile u32_t *)((u8_t *) _minix_kerninfo->minix_frclock_tcrr); + assert(minix_kerninfo->minix_frclock_tcrr); + assert(minix_kerninfo->minix_arm_frclock_hz); + *frclk = *(volatile u32_t *)((u8_t *) + minix_kerninfo->minix_frclock_tcrr); } u32_t diff --git a/minix/servers/is/dmp_kernel.c b/minix/servers/is/dmp_kernel.c index 159927821..334440194 100644 --- a/minix/servers/is/dmp_kernel.c +++ b/minix/servers/is/dmp_kernel.c @@ -1,6 +1,7 @@ /* Debugging dump procedures for the kernel. */ #include "inc.h" +#include #include #include #include @@ -55,8 +56,6 @@ struct proc proc[NR_TASKS + NR_PROCS]; struct priv priv[NR_SYS_PROCS]; struct boot_image image[NR_BOOT_PROCS]; -extern struct minix_kerninfo *_minix_kerninfo; - /*===========================================================================* * kmessages_dmp * *===========================================================================*/ @@ -68,8 +67,7 @@ void kmessages_dmp() int r; int size; - assert(_minix_kerninfo); - kmess = _minix_kerninfo->kmessages; + kmess = get_minix_kerninfo()->kmessages; /* 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 diff --git a/minix/servers/rs/exec.c b/minix/servers/rs/exec.c index feb3df4dc..ea332948e 100644 --- a/minix/servers/rs/exec.c +++ b/minix/servers/rs/exec.c @@ -19,8 +19,6 @@ static struct exec_loaders { { NULL } }; -extern struct minix_kerninfo *_minix_kerninfo; - int srv_execve(int proc_e, char *exec, size_t exec_len, char **argv, char **envp) { @@ -75,7 +73,7 @@ static int do_exec(int proc_e, char *exec, size_t exec_len, char *progname, memset(&execi, 0, sizeof(execi)); - execi.stack_high = _minix_kerninfo->kinfo->user_sp; + execi.stack_high = get_minix_kerninfo()->kinfo->user_sp; execi.stack_size = DEFAULT_STACK_LIMIT; execi.proc_e = proc_e; execi.hdr = exec; diff --git a/minix/servers/vfs/exec.c b/minix/servers/vfs/exec.c index 6d105e2de..af65b2bc5 100644 --- a/minix/servers/vfs/exec.c +++ b/minix/servers/vfs/exec.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -82,8 +83,6 @@ static const struct exec_loaders exec_loaders[] = { #define lock_exec() lock_proc(fproc_addr(VM_PROC_NR)) #define unlock_exec() unlock_proc(fproc_addr(VM_PROC_NR)) -extern struct minix_kerninfo *_minix_kerninfo; - /*===========================================================================* * get_read_vp * *===========================================================================*/ @@ -215,7 +214,7 @@ int pm_exec(vir_bytes path, size_t path_len, vir_bytes frame, size_t frame_len, /* passed from exec() libc code */ execi.userflags = 0; - execi.args.stack_high = _minix_kerninfo->kinfo->user_sp; + execi.args.stack_high = get_minix_kerninfo()->kinfo->user_sp; execi.args.stack_size = DEFAULT_STACK_LIMIT; fp->text_size = 0; diff --git a/minix/usr.bin/trace/kernel.c b/minix/usr.bin/trace/kernel.c index 195123049..4931d7ba9 100644 --- a/minix/usr.bin/trace/kernel.c +++ b/minix/usr.bin/trace/kernel.c @@ -23,11 +23,9 @@ #if defined(__i386__) #include "kernel/arch/i386/include/archconst.h" /* for the KTS_ constants */ #endif - +#include #include -extern struct minix_kerninfo *_minix_kerninfo; - /* * Working area. By obtaining values from the kernel into these local process * structures, and then returning them, we gain a little robustness against @@ -156,7 +154,7 @@ vir_bytes kernel_get_stacktop(void) { - return _minix_kerninfo->kinfo->user_sp; + return get_minix_kerninfo()->kinfo->user_sp; } /*