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
|
|
|
|
|
|
|
/* First C file used by the kernel. */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
#include "kernel.h"
|
2005-04-29 17:36:43 +02:00
|
|
|
#include "proc.h"
|
2005-07-19 17:01:47 +02:00
|
|
|
#include <stdlib.h>
|
2005-07-20 17:25:38 +02:00
|
|
|
#include <string.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 <archconst.h>
|
|
|
|
|
2005-06-07 14:34:25 +02:00
|
|
|
FORWARD _PROTOTYPE( char *get_value, (_CONST char *params, _CONST char *key));
|
2005-09-11 18:44:06 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* cstart *
|
|
|
|
*===========================================================================*/
|
2005-04-21 16:53:53 +02:00
|
|
|
PUBLIC void cstart(cs, ds, mds, parmoff, parmsize)
|
|
|
|
U16_t cs, ds; /* kernel code and data segment */
|
|
|
|
U16_t mds; /* monitor data segment */
|
|
|
|
U16_t parmoff, parmsize; /* boot parameters offset and length */
|
|
|
|
{
|
|
|
|
/* Perform system initializations prior to calling main(). Most settings are
|
|
|
|
* determined with help of the environment strings passed by MINIX' loader.
|
|
|
|
*/
|
2005-06-07 14:34:25 +02:00
|
|
|
register char *value; /* value in key=value pair */
|
2005-04-29 17:36:43 +02:00
|
|
|
extern int etext, end;
|
2005-11-14 16:50:46 +01:00
|
|
|
int h;
|
2005-04-29 17:36:43 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Record where the kernel and the monitor are. */
|
2005-04-29 17:36:43 +02:00
|
|
|
kinfo.code_base = seg2phys(cs);
|
|
|
|
kinfo.code_size = (phys_bytes) &etext; /* size of code segment */
|
|
|
|
kinfo.data_base = seg2phys(ds);
|
|
|
|
kinfo.data_size = (phys_bytes) &end; /* size of data segment */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2009-08-30 16:55:30 +02:00
|
|
|
/* protection initialization */
|
|
|
|
prot_init();
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-06-24 18:24:40 +02:00
|
|
|
/* Copy the boot parameters to the local buffer. */
|
2008-11-19 13:26:10 +01:00
|
|
|
arch_get_params(params_buffer, sizeof(params_buffer));
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-04-29 17:36:43 +02:00
|
|
|
/* Record miscellaneous information for user-space servers. */
|
2005-05-18 12:36:23 +02:00
|
|
|
kinfo.nr_procs = NR_PROCS;
|
|
|
|
kinfo.nr_tasks = NR_TASKS;
|
2005-07-20 17:25:38 +02:00
|
|
|
strncpy(kinfo.release, OS_RELEASE, sizeof(kinfo.release));
|
2005-07-13 16:46:11 +02:00
|
|
|
kinfo.release[sizeof(kinfo.release)-1] = '\0';
|
2005-07-20 17:25:38 +02:00
|
|
|
strncpy(kinfo.version, OS_VERSION, sizeof(kinfo.version));
|
2005-07-13 16:46:11 +02:00
|
|
|
kinfo.version[sizeof(kinfo.version)-1] = '\0';
|
2005-04-29 17:36:43 +02:00
|
|
|
kinfo.proc_addr = (vir_bytes) proc;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-11-14 16:50:46 +01:00
|
|
|
/* Load average data initialization. */
|
|
|
|
kloadinfo.proc_last_slot = 0;
|
|
|
|
for(h = 0; h < _LOAD_HISTORY; h++)
|
|
|
|
kloadinfo.proc_load_history[h] = 0;
|
|
|
|
|
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
|
|
|
/* Processor? Decide if mode is protected for older machines. */
|
2008-11-19 13:26:10 +01:00
|
|
|
machine.processor=atoi(get_value(params_buffer, "processor"));
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* XT, AT or MCA bus? */
|
2008-11-19 13:26:10 +01:00
|
|
|
value = get_value(params_buffer, "bus");
|
2005-07-20 17:25:38 +02:00
|
|
|
if (value == NIL_PTR || strcmp(value, "at") == 0) {
|
2005-04-29 17:36:43 +02:00
|
|
|
machine.pc_at = TRUE; /* PC-AT compatible hardware */
|
2005-07-20 17:25:38 +02:00
|
|
|
} else if (strcmp(value, "mca") == 0) {
|
2005-04-29 17:36:43 +02:00
|
|
|
machine.pc_at = machine.ps_mca = TRUE; /* PS/2 with micro channel */
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2005-04-29 17:36:43 +02:00
|
|
|
/* Type of VDU: */
|
2008-11-19 13:26:10 +01:00
|
|
|
value = get_value(params_buffer, "video"); /* EGA or VGA video unit */
|
2005-07-20 17:25:38 +02:00
|
|
|
if (strcmp(value, "ega") == 0) machine.vdu_ega = TRUE;
|
|
|
|
if (strcmp(value, "vga") == 0) machine.vdu_vga = machine.vdu_ega = TRUE;
|
2005-04-29 17:36:43 +02:00
|
|
|
|
2008-12-11 15:15:23 +01:00
|
|
|
/* Get clock tick frequency. */
|
|
|
|
value = get_value(params_buffer, "hz");
|
|
|
|
if(value)
|
|
|
|
system_hz = atoi(value);
|
|
|
|
if(!value || system_hz < 2 || system_hz > 50000) /* sanity check */
|
|
|
|
system_hz = DEFAULT_HZ;
|
2009-01-12 00:45:29 +01:00
|
|
|
value = get_value(params_buffer, SERVARNAME);
|
2008-12-19 14:21:42 +01:00
|
|
|
if(value && atoi(value) == 0)
|
|
|
|
do_serial_debug=1;
|
2008-12-11 15:15:23 +01:00
|
|
|
|
2005-04-29 17:36:43 +02:00
|
|
|
/* Return to assembler code to switch to protected mode (if 286),
|
|
|
|
* reload selectors and call main().
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
intr_init(INTS_MINIX);
|
2005-04-29 17:36:43 +02:00
|
|
|
}
|
|
|
|
|
2005-09-11 18:44:06 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* get_value *
|
|
|
|
*===========================================================================*/
|
|
|
|
|
2005-06-07 14:34:25 +02:00
|
|
|
PRIVATE char *get_value(params, name)
|
|
|
|
_CONST char *params; /* boot monitor parameters */
|
|
|
|
_CONST char *name; /* key to look up */
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* Get environment value - kernel version of getenv to avoid setting up the
|
|
|
|
* usual environment array.
|
|
|
|
*/
|
|
|
|
register _CONST char *namep;
|
|
|
|
register char *envp;
|
|
|
|
|
2005-06-07 14:34:25 +02:00
|
|
|
for (envp = (char *) params; *envp != 0;) {
|
2005-04-21 16:53:53 +02:00
|
|
|
for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++)
|
|
|
|
;
|
|
|
|
if (*namep == '\0' && *envp == '=') return(envp + 1);
|
|
|
|
while (*envp++ != 0)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
return(NIL_PTR);
|
|
|
|
}
|