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>
|
2009-11-16 22:41:44 +01:00
|
|
|
#include "proto.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
|
|
|
|
2011-07-29 20:36:42 +02:00
|
|
|
#ifdef USE_WATCHDOG
|
2010-01-16 21:53:55 +01:00
|
|
|
#include "watchdog.h"
|
|
|
|
#endif
|
|
|
|
|
2005-09-11 18:44:06 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* cstart *
|
|
|
|
*===========================================================================*/
|
2010-04-21 13:05:22 +02:00
|
|
|
PUBLIC void cstart(
|
|
|
|
u16_t cs, /* kernel code segment */
|
|
|
|
u16_t ds, /* kernel data segment */
|
|
|
|
u16_t mds, /* monitor data segment */
|
|
|
|
u16_t parmoff, /* boot parameters offset */
|
|
|
|
u16_t parmsize /* boot parameters length */
|
|
|
|
)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* 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
|
|
|
|
2010-02-13 23:11:16 +01:00
|
|
|
/* determine verbosity */
|
2010-05-19 12:00:02 +02:00
|
|
|
if ((value = env_get(VERBOSEBOOTVARNAME)))
|
2010-02-13 23:11:16 +01:00
|
|
|
verboseboot = atoi(value);
|
|
|
|
|
2010-05-10 20:07:59 +02:00
|
|
|
DEBUGEXTRA(("cstart\n"));
|
2010-02-13 23:11:16 +01: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. */
|
2010-05-19 12:00:02 +02:00
|
|
|
machine.processor=atoi(env_get("processor"));
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* XT, AT or MCA bus? */
|
2010-05-19 12:00:02 +02:00
|
|
|
value = env_get("bus");
|
2010-05-10 15:26:00 +02:00
|
|
|
if (value == NULL || 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: */
|
2010-05-19 12:00:02 +02:00
|
|
|
value = env_get("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. */
|
2010-05-19 12:00:02 +02:00
|
|
|
value = env_get("hz");
|
2008-12-11 15:15:23 +01:00
|
|
|
if(value)
|
|
|
|
system_hz = atoi(value);
|
|
|
|
if(!value || system_hz < 2 || system_hz > 50000) /* sanity check */
|
|
|
|
system_hz = DEFAULT_HZ;
|
2011-03-16 13:25:10 +01:00
|
|
|
|
|
|
|
/* Intitialize serial debugging */
|
2010-05-19 12:00:02 +02:00
|
|
|
value = env_get(SERVARNAME);
|
2011-03-16 13:25:10 +01:00
|
|
|
if(value && atoi(value) == 0) {
|
2008-12-19 14:21:42 +01:00
|
|
|
do_serial_debug=1;
|
2008-12-11 15:15:23 +01:00
|
|
|
|
2011-03-16 13:25:10 +01:00
|
|
|
value = env_get(SERBAUDVARNAME);
|
|
|
|
if (value) serial_debug_baud = atoi(value);
|
|
|
|
}
|
|
|
|
|
2011-07-31 16:20:34 +02:00
|
|
|
#ifdef USE_APIC
|
2010-05-19 12:00:02 +02:00
|
|
|
value = env_get("no_apic");
|
2009-11-16 22:41:44 +01:00
|
|
|
if(value)
|
|
|
|
config_no_apic = atoi(value);
|
|
|
|
else
|
2010-01-11 18:21:19 +01:00
|
|
|
config_no_apic = 1;
|
2010-09-16 09:18:47 +02:00
|
|
|
value = env_get("apic_timer_x");
|
|
|
|
if(value)
|
|
|
|
config_apic_timer_x = atoi(value);
|
|
|
|
else
|
|
|
|
config_apic_timer_x = 1;
|
2009-11-16 22:41:44 +01:00
|
|
|
#endif
|
|
|
|
|
2011-07-29 20:36:42 +02:00
|
|
|
#ifdef USE_WATCHDOG
|
2010-05-19 12:00:02 +02:00
|
|
|
value = env_get("watchdog");
|
2010-01-16 21:53:55 +01:00
|
|
|
if (value)
|
|
|
|
watchdog_enabled = atoi(value);
|
|
|
|
#endif
|
|
|
|
|
2010-09-15 16:09:52 +02:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
if (config_no_apic)
|
|
|
|
config_no_smp = 1;
|
|
|
|
value = env_get("no_smp");
|
|
|
|
if(value)
|
|
|
|
config_no_smp = atoi(value);
|
|
|
|
else
|
|
|
|
config_no_smp = 0;
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
2010-05-10 20:07:59 +02:00
|
|
|
DEBUGEXTRA(("intr_init(%d, 0)\n", INTS_MINIX));
|
2009-11-16 22:41:44 +01:00
|
|
|
intr_init(INTS_MINIX, 0);
|
2005-04-29 17:36:43 +02:00
|
|
|
}
|
|
|
|
|
2005-09-11 18:44:06 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* get_value *
|
|
|
|
*===========================================================================*/
|
|
|
|
|
2010-09-15 16:10:00 +02:00
|
|
|
PUBLIC char *get_value(
|
2010-04-21 13:05:22 +02:00
|
|
|
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.
|
|
|
|
*/
|
2010-03-27 15:31:00 +01:00
|
|
|
register const char *namep;
|
2005-04-21 16:53:53 +02:00
|
|
|
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)
|
|
|
|
;
|
|
|
|
}
|
2010-05-10 15:26:00 +02:00
|
|
|
return(NULL);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2010-05-19 12:00:02 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* env_get *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC char *env_get(const char *name)
|
|
|
|
{
|
|
|
|
return get_value(params_buffer, name);
|
|
|
|
}
|
|
|
|
|