8000 minix/minix/kernel/main.c at master · desnesn/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
522 lines (444 loc) · 14.9 KB

main.c

File metadata and controls

522 lines (444 loc) · 14.9 KB
if (ncpus > 1)
smp_shutdown_aps();
#endif
hw_intr_disable_all();
stop_local_timer();
/* Show shutdown message */
direct_cls();
if((how & RB_POWERDOWN) == RB_POWERDOWN)
direct_print("MINIX has halted and will now power off.\n");
else if(how & RB_HALT)
direct_print("MINIX has halted. "
"It is safe to turn off your computer.\n");
else
direct_print("MINIX will now reset.\n");
arch_shutdown(how);
}
/*===========================================================================*
* cstart *
*===========================================================================*/
void cstart(void)
{
/* Perform system initializations prior to calling main(). Most settings are
* determined with help of the environment strings passed by MINIX' loader.
*/
register char *value; /* value in key=value pair */
/* low-level initialization */
prot_init();
/* determine verbosity */
if ((value = env_get(VERBOSEBOOTVARNAME)))
verboseboot = atoi(value);
/* Initialize clock variables. */
init_clock();
/* Get memory parameters. */
value = env_get("ac_layout");
if(value && atoi(value)) {
kinfo.user_sp = (vir_bytes) USR_STACKTOP_COMPACT;
kinfo.user_end = (vir_bytes) USR_DATATOP_COMPACT;
}
DEBUGEXTRA(("cstart\n"));
/* Record miscellaneous information for user-space servers. */
kinfo.nr_procs = NR_PROCS;
kinfo.nr_tasks = NR_TASKS;
strlcpy(kinfo.release, OS_RELEASE, sizeof(kinfo.release));
strlcpy(kinfo.version, OS_VERSION, sizeof(kinfo.version));
/* Initialize various user-mapped structures. */
memset(&arm_frclock, 0, sizeof(arm_frclock));
memset(&kuserinfo, 0, sizeof(kuserinfo));
kuserinfo.kui_size = sizeof(kuserinfo);
kuserinfo.kui_user_sp = kinfo.user_sp;
#ifdef USE_APIC
value = env_get("no_apic");
if(value)
config_no_apic = atoi(value);
else
config_no_apic = 1;
value = env_get("apic_timer_x");
if(value)
config_apic_timer_x = atoi(value);
else
config_apic_timer_x = 1;
#endif
#ifdef USE_WATCHDOG
value = env_get("watchdog");
if (value)
watchdog_enabled = atoi(value);
#endif
#ifdef CONFIG_SMP
if (config_no_apic)
config_no_smp = 1;
value = env_get("no_smp");
if(value)
config_no_smp = atoi(value);
else
config_no_smp = 0;
#endif
DEBUGEXTRA(("intr_init(0)\n"));
intr_init(0);
arch_init();
}
/*===========================================================================*
* get_value *
*===========================================================================*/
char *get_value(
const char *params, /* boot monitor parameters */
const char *name /* key to look up */
)
{
/* Get environment value - kernel version of getenv to avoid setting up the
* usual environment array.
*/
register const char *namep;
register char *envp;
for (envp = (char *) params; *envp != 0;) {
for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++)
;
if (*namep == '\0' && *envp == '=') return(envp + 1);
while (*envp++ != 0)
;
}
return(NULL);
}
/*===========================================================================*
* env_get *
*===========================================================================*/
char *env_get(const char *name)
{
return get_value(kinfo.param_buf, name);
}
void cpu_print_freq(unsigned cpu)
{
u64_t freq;
freq = cpu_get_freq(cpu);
DEBUGBASIC(("CPU %d freq %lu MHz\n", cpu, (unsigned long)(freq / 1000000)));
}
int is_fpu(void)
{
return get_cpulocal_var(fpu_presence);
}
0