2 /* First C file used by the kernel. */
11 FORWARD
_PROTOTYPE( char *get_value
, (_CONST
char *params
, _CONST
char *key
));
12 /*===========================================================================*
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
;
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 */
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 */
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");
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)
80 value
= get_value(params_buffer
, "no_apic");
82 config_no_apic
= atoi(value
);
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 /*===========================================================================*
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
;
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);