#include <assert.h>
-extern struct minix_kerninfo *_minix_kerninfo;
-
/*==========================================================================*
* do_new_kmess *
*==========================================================================*/
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
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 *
*===========================================================================*/
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
static void
root_ipcvecs(void)
{
- extern struct minix_kerninfo *_minix_kerninfo;
extern struct minix_ipcvecs _minix_ipcvecs;
/*
* 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;
/*
#include <minix/endpoint.h>
#include <minix/ipc.h>
+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);
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
_do_kernel_call_intr.S \
_ipc.S \
brksize.S \
- get_minix_kerninfo.S \
+ ipc_minix_kerninfo.S \
ucontext.S
ucontextoffsets.h: ${CF}
#include <minix/ipcconst.h>
#include <machine/asm.h>
-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) */
_do_kernel_call_intr.S \
_ipc.S \
brksize.S \
- get_minix_kerninfo.S \
+ ipc_minix_kerninfo.S \
ucontext.S
ucontextoffsets.h: ${CF}
#include <minix/ipcconst.h>
#include <machine/asm.h>
-ENTRY(get_minix_kerninfo)
+ENTRY(ipc_minix_kerninfo)
push %ebp
movl %esp, %ebp
push %ebx
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
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;
_minix_ipcvecs = *_minix_kerninfo->minix_ipcvecs;
}
}
-
--- /dev/null
+/*
+ * This file contains the main routine for retrieval of the kernel information
+ * page.
+ */
+
+#define _MINIX_SYSTEM
+
+#include <sys/cdefs.h>
+#include "namespace.h"
+#include <lib.h>
+#include <assert.h>
+
+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;
+}
#include <sys/exec_elf.h>
#include <sys/exec.h>
-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.
*
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;
.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 \
.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}
#include <minix/minlib.h>
#include <minix/sysutil.h>
-#include <minix/type.h>
#include <sys/errno.h>
#include <sys/types.h>
+#include <lib.h>
#include <assert.h>
#define MICROHZ 1000000ULL /* number of micros per second */
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
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
/* Debugging dump procedures for the kernel. */
#include "inc.h"
+#include <lib.h>
#include <minix/timers.h>
#include <assert.h>
#include <machine/interrupt.h>
struct priv priv[NR_SYS_PROCS];
struct boot_image image[NR_BOOT_PROCS];
-extern struct minix_kerninfo *_minix_kerninfo;
-
/*===========================================================================*
* 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
{ NULL }
};
-extern struct minix_kerninfo *_minix_kerninfo;
-
int srv_execve(int proc_e, char *exec, size_t exec_len, char **argv,
char **envp)
{
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;
#include <minix/endpoint.h>
#include <minix/com.h>
#include <minix/u64.h>
+#include <lib.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#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 *
*===========================================================================*/
/* 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;
#if defined(__i386__)
#include "kernel/arch/i386/include/archconst.h" /* for the KTS_ constants */
#endif
-
+#include <lib.h>
#include <minix/param.h>
-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
kernel_get_stacktop(void)
{
- return _minix_kerninfo->kinfo->user_sp;
+ return get_minix_kerninfo()->kinfo->user_sp;
}
/*