Part of the FPU changes; forgot to add these files in FPU commit.
[minix.git] / kernel / start.c
blobf022ec32b6c7f230e427fe34517b1fc2b3522e3b
2 /* First C file used by the kernel. */
4 #include "kernel.h"
5 #include "proc.h"
6 #include <stdlib.h>
7 #include <string.h>
8 #include <archconst.h>
9 #include "proto.h"
11 FORWARD _PROTOTYPE( char *get_value, (_CONST char *params, _CONST char *key));
12 /*===========================================================================*
13 * cstart *
14 *===========================================================================*/
15 PUBLIC void cstart(cs, ds, mds, parmoff, parmsize)
16 U16_t cs, ds; /* kernel code and data segment */
17 U16_t mds; /* monitor data segment */
18 U16_t parmoff, parmsize; /* boot parameters offset and length */
20 /* Perform system initializations prior to calling main(). Most settings are
21 * determined with help of the environment strings passed by MINIX' loader.
23 register char *value; /* value in key=value pair */
24 extern int etext, end;
25 int h;
27 /* Record where the kernel and the monitor are. */
28 kinfo.code_base = seg2phys(cs);
29 kinfo.code_size = (phys_bytes) &etext; /* size of code segment */
30 kinfo.data_base = seg2phys(ds);
31 kinfo.data_size = (phys_bytes) &end; /* size of data segment */
33 /* protection initialization */
34 prot_init();
36 /* Copy the boot parameters to the local buffer. */
37 arch_get_params(params_buffer, sizeof(params_buffer));
39 /* Record miscellaneous information for user-space servers. */
40 kinfo.nr_procs = NR_PROCS;
41 kinfo.nr_tasks = NR_TASKS;
42 strncpy(kinfo.release, OS_RELEASE, sizeof(kinfo.release));
43 kinfo.release[sizeof(kinfo.release)-1] = '\0';
44 strncpy(kinfo.version, OS_VERSION, sizeof(kinfo.version));
45 kinfo.version[sizeof(kinfo.version)-1] = '\0';
46 kinfo.proc_addr = (vir_bytes) proc;
48 /* Load average data initialization. */
49 kloadinfo.proc_last_slot = 0;
50 for(h = 0; h < _LOAD_HISTORY; h++)
51 kloadinfo.proc_load_history[h] = 0;
53 /* Processor? Decide if mode is protected for older machines. */
54 machine.processor=atoi(get_value(params_buffer, "processor"));
56 /* XT, AT or MCA bus? */
57 value = get_value(params_buffer, "bus");
58 if (value == NIL_PTR || strcmp(value, "at") == 0) {
59 machine.pc_at = TRUE; /* PC-AT compatible hardware */
60 } else if (strcmp(value, "mca") == 0) {
61 machine.pc_at = machine.ps_mca = TRUE; /* PS/2 with micro channel */
64 /* Type of VDU: */
65 value = get_value(params_buffer, "video"); /* EGA or VGA video unit */
66 if (strcmp(value, "ega") == 0) machine.vdu_ega = TRUE;
67 if (strcmp(value, "vga") == 0) machine.vdu_vga = machine.vdu_ega = TRUE;
69 /* Get clock tick frequency. */
70 value = get_value(params_buffer, "hz");
71 if(value)
72 system_hz = atoi(value);
73 if(!value || system_hz < 2 || system_hz > 50000) /* sanity check */
74 system_hz = DEFAULT_HZ;
75 value = get_value(params_buffer, SERVARNAME);
76 if(value && atoi(value) == 0)
77 do_serial_debug=1;
79 #ifdef CONFIG_APIC
80 value = get_value(params_buffer, "no_apic");
81 if(value)
82 config_no_apic = atoi(value);
83 else
84 config_no_apic = 0;
85 #endif
87 /* Return to assembler code to switch to protected mode (if 286),
88 * reload selectors and call main().
91 intr_init(INTS_MINIX, 0);
94 /*===========================================================================*
95 * get_value *
96 *===========================================================================*/
98 PRIVATE char *get_value(params, name)
99 _CONST char *params; /* boot monitor parameters */
100 _CONST char *name; /* key to look up */
102 /* Get environment value - kernel version of getenv to avoid setting up the
103 * usual environment array.
105 register _CONST char *namep;
106 register char *envp;
108 for (envp = (char *) params; *envp != 0;) {
109 for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++)
111 if (*namep == '\0' && *envp == '=') return(envp + 1);
112 while (*envp++ != 0)
115 return(NIL_PTR);