2 /* First C file used by the kernel. */
10 PRIVATE
char params
[K_PARAM_SIZE
];
12 FORWARD
_PROTOTYPE( char *get_value
, (_CONST
char *params
, _CONST
char *key
));
13 /*===========================================================================*
15 *===========================================================================*/
16 PUBLIC
void cstart(cs
, ds
, mds
, parmoff
, parmsize
)
17 U16_t cs
, ds
; /* kernel code and data segment */
18 U16_t mds
; /* monitor data segment */
19 U16_t parmoff
, parmsize
; /* boot parameters offset and length */
21 /* Perform system initializations prior to calling main(). Most settings are
22 * determined with help of the environment strings passed by MINIX' loader.
24 char params
[128*sizeof(char *)]; /* boot monitor parameters */
25 register char *value
; /* value in key=value pair */
26 extern int etext
, end
;
29 /* Record where the kernel and the monitor are. */
30 kinfo
.code_base
= seg2phys(cs
);
31 kinfo
.code_size
= (phys_bytes
) &etext
; /* size of code segment */
32 kinfo
.data_base
= seg2phys(ds
);
33 kinfo
.data_size
= (phys_bytes
) &end
; /* size of data segment */
35 /* Architecture-dependent initialization. */
38 /* Copy the boot parameters to the local buffer. */
39 kinfo
.params_base
= seg2phys(mds
) + parmoff
;
40 kinfo
.params_size
= MIN(parmsize
,sizeof(params
)-2);
41 phys_copy(kinfo
.params_base
,
42 vir2phys(params
), kinfo
.params_size
);
44 /* Record miscellaneous information for user-space servers. */
45 kinfo
.nr_procs
= NR_PROCS
;
46 kinfo
.nr_tasks
= NR_TASKS
;
47 strncpy(kinfo
.release
, OS_RELEASE
, sizeof(kinfo
.release
));
48 kinfo
.release
[sizeof(kinfo
.release
)-1] = '\0';
49 strncpy(kinfo
.version
, OS_VERSION
, sizeof(kinfo
.version
));
50 kinfo
.version
[sizeof(kinfo
.version
)-1] = '\0';
51 kinfo
.proc_addr
= (vir_bytes
) proc
;
52 kinfo
.kmem_base
= vir2phys(0);
53 kinfo
.kmem_size
= (phys_bytes
) &end
;
55 /* Load average data initialization. */
56 kloadinfo
.proc_last_slot
= 0;
57 for(h
= 0; h
< _LOAD_HISTORY
; h
++)
58 kloadinfo
.proc_load_history
[h
] = 0;
60 /* Processor? Decide if mode is protected for older machines. */
61 machine
.processor
=atoi(get_value(params
, "processor"));
63 /* XT, AT or MCA bus? */
64 value
= get_value(params
, "bus");
65 if (value
== NIL_PTR
|| strcmp(value
, "at") == 0) {
66 machine
.pc_at
= TRUE
; /* PC-AT compatible hardware */
67 } else if (strcmp(value
, "mca") == 0) {
68 machine
.pc_at
= machine
.ps_mca
= TRUE
; /* PS/2 with micro channel */
72 value
= get_value(params
, "video"); /* EGA or VGA video unit */
73 if (strcmp(value
, "ega") == 0) machine
.vdu_ega
= TRUE
;
74 if (strcmp(value
, "vga") == 0) machine
.vdu_vga
= machine
.vdu_ega
= TRUE
;
76 /* Return to assembler code to switch to protected mode (if 286),
77 * reload selectors and call main().
80 intr_init(INTS_MINIX
);
83 /*===========================================================================*
85 *===========================================================================*/
87 PRIVATE
char *get_value(params
, name
)
88 _CONST
char *params
; /* boot monitor parameters */
89 _CONST
char *name
; /* key to look up */
91 /* Get environment value - kernel version of getenv to avoid setting up the
92 * usual environment array.
94 register _CONST
char *namep
;
97 for (envp
= (char *) params
; *envp
!= 0;) {
98 for (namep
= name
; *namep
!= 0 && *namep
== *envp
; namep
++, envp
++)
100 if (*namep
== '\0' && *envp
== '=') return(envp
+ 1);