2 /* First C file used by the kernel. */
10 #ifdef CONFIG_WATCHDOG
14 /*===========================================================================*
16 *===========================================================================*/
18 u16_t cs
, /* kernel code segment */
19 u16_t ds
, /* kernel data segment */
20 u16_t mds
, /* monitor data segment */
21 u16_t parmoff
, /* boot parameters offset */
22 u16_t parmsize
/* boot parameters length */
25 /* Perform system initializations prior to calling main(). Most settings are
26 * determined with help of the environment strings passed by MINIX' loader.
28 register char *value
; /* value in key=value pair */
29 extern int etext
, end
;
32 /* Record where the kernel and the monitor are. */
33 kinfo
.code_base
= seg2phys(cs
);
34 kinfo
.code_size
= (phys_bytes
) &etext
; /* size of code segment */
35 kinfo
.data_base
= seg2phys(ds
);
36 kinfo
.data_size
= (phys_bytes
) &end
; /* size of data segment */
38 /* protection initialization */
41 /* Copy the boot parameters to the local buffer. */
42 arch_get_params(params_buffer
, sizeof(params_buffer
));
44 /* determine verbosity */
45 if ((value
= env_get(VERBOSEBOOTVARNAME
)))
46 verboseboot
= atoi(value
);
48 DEBUGEXTRA(("cstart\n"));
50 /* Record miscellaneous information for user-space servers. */
51 kinfo
.nr_procs
= NR_PROCS
;
52 kinfo
.nr_tasks
= NR_TASKS
;
53 strncpy(kinfo
.release
, OS_RELEASE
, sizeof(kinfo
.release
));
54 kinfo
.release
[sizeof(kinfo
.release
)-1] = '\0';
55 strncpy(kinfo
.version
, OS_VERSION
, sizeof(kinfo
.version
));
56 kinfo
.version
[sizeof(kinfo
.version
)-1] = '\0';
57 kinfo
.proc_addr
= (vir_bytes
) proc
;
59 /* Load average data initialization. */
60 kloadinfo
.proc_last_slot
= 0;
61 for(h
= 0; h
< _LOAD_HISTORY
; h
++)
62 kloadinfo
.proc_load_history
[h
] = 0;
64 /* Processor? Decide if mode is protected for older machines. */
65 machine
.processor
=atoi(env_get("processor"));
67 /* XT, AT or MCA bus? */
68 value
= env_get("bus");
69 if (value
== NULL
|| strcmp(value
, "at") == 0) {
70 machine
.pc_at
= TRUE
; /* PC-AT compatible hardware */
71 } else if (strcmp(value
, "mca") == 0) {
72 machine
.pc_at
= machine
.ps_mca
= TRUE
; /* PS/2 with micro channel */
76 value
= env_get("video"); /* EGA or VGA video unit */
77 if (strcmp(value
, "ega") == 0) machine
.vdu_ega
= TRUE
;
78 if (strcmp(value
, "vga") == 0) machine
.vdu_vga
= machine
.vdu_ega
= TRUE
;
80 /* Get clock tick frequency. */
81 value
= env_get("hz");
83 system_hz
= atoi(value
);
84 if(!value
|| system_hz
< 2 || system_hz
> 50000) /* sanity check */
85 system_hz
= DEFAULT_HZ
;
86 value
= env_get(SERVARNAME
);
87 if(value
&& atoi(value
) == 0)
91 value
= env_get("no_apic");
93 config_no_apic
= atoi(value
);
98 #ifdef CONFIG_WATCHDOG
99 value
= env_get("watchdog");
101 watchdog_enabled
= atoi(value
);
104 /* Return to assembler code to switch to protected mode (if 286),
105 * reload selectors and call main().
108 DEBUGEXTRA(("intr_init(%d, 0)\n", INTS_MINIX
));
109 intr_init(INTS_MINIX
, 0);
112 /*===========================================================================*
114 *===========================================================================*/
116 PRIVATE
char *get_value(
117 const char *params
, /* boot monitor parameters */
118 const char *name
/* key to look up */
121 /* Get environment value - kernel version of getenv to avoid setting up the
122 * usual environment array.
124 register const char *namep
;
127 for (envp
= (char *) params
; *envp
!= 0;) {
128 for (namep
= name
; *namep
!= 0 && *namep
== *envp
; namep
++, envp
++)
130 if (*namep
== '\0' && *envp
== '=') return(envp
+ 1);
137 /*===========================================================================*
139 *===========================================================================*/
140 PUBLIC
char *env_get(const char *name
)
142 return get_value(params_buffer
, name
);