2 /* First C file used by the kernel. */
10 #ifdef CONFIG_WATCHDOG
14 FORWARD
_PROTOTYPE( char *get_value
, (_CONST
char *params
, _CONST
char *key
));
15 /*===========================================================================*
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
;
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 */
39 /* Copy the boot parameters to the local buffer. */
40 arch_get_params(params_buffer
, sizeof(params_buffer
));
42 /* determine verbosity */
43 if ((value
= get_value(params_buffer
, VERBOSEBOOTVARNAME
)))
44 verboseboot
= atoi(value
);
46 DEBUGMAX(("cstart\n"));
48 /* Record miscellaneous information for user-space servers. */
49 kinfo
.nr_procs
= NR_PROCS
;
50 kinfo
.nr_tasks
= NR_TASKS
;
51 strncpy(kinfo
.release
, OS_RELEASE
, sizeof(kinfo
.release
));
52 kinfo
.release
[sizeof(kinfo
.release
)-1] = '\0';
53 strncpy(kinfo
.version
, OS_VERSION
, sizeof(kinfo
.version
));
54 kinfo
.version
[sizeof(kinfo
.version
)-1] = '\0';
55 kinfo
.proc_addr
= (vir_bytes
) proc
;
57 /* Load average data initialization. */
58 kloadinfo
.proc_last_slot
= 0;
59 for(h
= 0; h
< _LOAD_HISTORY
; h
++)
60 kloadinfo
.proc_load_history
[h
] = 0;
62 /* Processor? Decide if mode is protected for older machines. */
63 machine
.processor
=atoi(get_value(params_buffer
, "processor"));
65 /* XT, AT or MCA bus? */
66 value
= get_value(params_buffer
, "bus");
67 if (value
== NIL_PTR
|| strcmp(value
, "at") == 0) {
68 machine
.pc_at
= TRUE
; /* PC-AT compatible hardware */
69 } else if (strcmp(value
, "mca") == 0) {
70 machine
.pc_at
= machine
.ps_mca
= TRUE
; /* PS/2 with micro channel */
74 value
= get_value(params_buffer
, "video"); /* EGA or VGA video unit */
75 if (strcmp(value
, "ega") == 0) machine
.vdu_ega
= TRUE
;
76 if (strcmp(value
, "vga") == 0) machine
.vdu_vga
= machine
.vdu_ega
= TRUE
;
78 /* Get clock tick frequency. */
79 value
= get_value(params_buffer
, "hz");
81 system_hz
= atoi(value
);
82 if(!value
|| system_hz
< 2 || system_hz
> 50000) /* sanity check */
83 system_hz
= DEFAULT_HZ
;
84 value
= get_value(params_buffer
, SERVARNAME
);
85 if(value
&& atoi(value
) == 0)
89 value
= get_value(params_buffer
, "no_apic");
91 config_no_apic
= atoi(value
);
96 #ifdef CONFIG_WATCHDOG
97 value
= get_value(params_buffer
, "watchdog");
99 watchdog_enabled
= atoi(value
);
102 /* Return to assembler code to switch to protected mode (if 286),
103 * reload selectors and call main().
106 DEBUGMAX(("intr_init(%d, 0)\n", INTS_MINIX
));
107 intr_init(INTS_MINIX
, 0);
110 /*===========================================================================*
112 *===========================================================================*/
114 PRIVATE
char *get_value(params
, name
)
115 _CONST
char *params
; /* boot monitor parameters */
116 _CONST
char *name
; /* key to look up */
118 /* Get environment value - kernel version of getenv to avoid setting up the
119 * usual environment array.
121 register _CONST
char *namep
;
124 for (envp
= (char *) params
; *envp
!= 0;) {
125 for (namep
= name
; *namep
!= 0 && *namep
== *envp
; namep
++, envp
++)
127 if (*namep
== '\0' && *envp
== '=') return(envp
+ 1);