only check local benchmark dir if it exists
[minix.git] / kernel / start.c
blobb91d5f57533be19492df1462864237a8a62610c8
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 "proto.h"
10 #ifdef CONFIG_WATCHDOG
11 #include "watchdog.h"
12 #endif
14 FORWARD _PROTOTYPE( char *get_value, (_CONST char *params, _CONST char *key));
15 /*===========================================================================*
16 * cstart *
17 *===========================================================================*/
18 PUBLIC void cstart(cs, ds, mds, parmoff, parmsize)
19 U16_t cs, ds; /* kernel code and data segment */
20 U16_t mds; /* monitor data segment */
21 U16_t parmoff, parmsize; /* boot parameters offset and length */
23 /* Perform system initializations prior to calling main(). Most settings are
24 * determined with help of the environment strings passed by MINIX' loader.
26 register char *value; /* value in key=value pair */
27 extern int etext, end;
28 int h;
30 /* Record where the kernel and the monitor are. */
31 kinfo.code_base = seg2phys(cs);
32 kinfo.code_size = (phys_bytes) &etext; /* size of code segment */
33 kinfo.data_base = seg2phys(ds);
34 kinfo.data_size = (phys_bytes) &end; /* size of data segment */
36 /* protection initialization */
37 prot_init();
39 /* Copy the boot parameters to the local buffer. */
40 arch_get_params(params_buffer, sizeof(params_buffer));
42 /* Record miscellaneous information for user-space servers. */
43 kinfo.nr_procs = NR_PROCS;
44 kinfo.nr_tasks = NR_TASKS;
45 strncpy(kinfo.release, OS_RELEASE, sizeof(kinfo.release));
46 kinfo.release[sizeof(kinfo.release)-1] = '\0';
47 strncpy(kinfo.version, OS_VERSION, sizeof(kinfo.version));
48 kinfo.version[sizeof(kinfo.version)-1] = '\0';
49 kinfo.proc_addr = (vir_bytes) proc;
51 /* Load average data initialization. */
52 kloadinfo.proc_last_slot = 0;
53 for(h = 0; h < _LOAD_HISTORY; h++)
54 kloadinfo.proc_load_history[h] = 0;
56 /* Processor? Decide if mode is protected for older machines. */
57 machine.processor=atoi(get_value(params_buffer, "processor"));
59 /* XT, AT or MCA bus? */
60 value = get_value(params_buffer, "bus");
61 if (value == NIL_PTR || strcmp(value, "at") == 0) {
62 machine.pc_at = TRUE; /* PC-AT compatible hardware */
63 } else if (strcmp(value, "mca") == 0) {
64 machine.pc_at = machine.ps_mca = TRUE; /* PS/2 with micro channel */
67 /* Type of VDU: */
68 value = get_value(params_buffer, "video"); /* EGA or VGA video unit */
69 if (strcmp(value, "ega") == 0) machine.vdu_ega = TRUE;
70 if (strcmp(value, "vga") == 0) machine.vdu_vga = machine.vdu_ega = TRUE;
72 /* Get clock tick frequency. */
73 value = get_value(params_buffer, "hz");
74 if(value)
75 system_hz = atoi(value);
76 if(!value || system_hz < 2 || system_hz > 50000) /* sanity check */
77 system_hz = DEFAULT_HZ;
78 value = get_value(params_buffer, SERVARNAME);
79 if(value && atoi(value) == 0)
80 do_serial_debug=1;
82 #ifdef CONFIG_APIC
83 value = get_value(params_buffer, "no_apic");
84 if(value)
85 config_no_apic = atoi(value);
86 else
87 config_no_apic = 1;
88 #endif
90 #ifdef CONFIG_WATCHDOG
91 value = get_value(params_buffer, "watchdog");
92 if (value)
93 watchdog_enabled = atoi(value);
94 #endif
96 /* Return to assembler code to switch to protected mode (if 286),
97 * reload selectors and call main().
100 intr_init(INTS_MINIX, 0);
103 /*===========================================================================*
104 * get_value *
105 *===========================================================================*/
107 PRIVATE char *get_value(params, name)
108 _CONST char *params; /* boot monitor parameters */
109 _CONST char *name; /* key to look up */
111 /* Get environment value - kernel version of getenv to avoid setting up the
112 * usual environment array.
114 register _CONST char *namep;
115 register char *envp;
117 for (envp = (char *) params; *envp != 0;) {
118 for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++)
120 if (*namep == '\0' && *envp == '=') return(envp + 1);
121 while (*envp++ != 0)
124 return(NIL_PTR);