#include <cpus.h>
#include <platforms.h>
#include <mach_kdb.h>
#include <himem.h>
#include <fast_idle.h>
#include <mach/i386/vm_param.h>
#include <string.h>
#include <mach/vm_param.h>
#include <mach/vm_prot.h>
#include <mach/machine.h>
#include <mach/time_value.h>
#include <kern/spl.h>
#include <kern/assert.h>
#include <kern/debug.h>
#include <kern/misc_protos.h>
#include <kern/startup.h>
#include <kern/clock.h>
#include <kern/time_out.h>
#include <kern/cpu_data.h>
#include <i386/fpu.h>
#include <i386/ipl.h>
#include <i386/pio.h>
#include <i386/misc_protos.h>
#include <i386/rtclock_entries.h>
#include <i386/mp.h>
#include <pexpert/i386/boot.h>
#if MACH_KDB
#include <ddb/db_aout.h>
#endif
#if NCPUS > 1
#include <i386/mp_desc.h>
#endif
#if NCPUS > 1
#include <i386/mp.h>
#endif
#include <IOKit/IOPlatformExpert.h>
static void machine_conf(void);
#include <i386/cpuid.h>
void
machine_startup()
{
int boot_arg;
#if 0
if( PE_get_hotkey( kPEControlKey ))
halt_in_debugger = halt_in_debugger ? 0 : 1;
#endif
if (PE_parse_boot_arg("debug", &boot_arg)) {
if (boot_arg & DB_HALT) halt_in_debugger=1;
if (boot_arg & DB_PRT) disableDebugOuput=FALSE;
if (boot_arg & DB_SLOG) systemLogDiags=TRUE;
if (boot_arg & DB_NMI) panicDebugging=TRUE;
if (boot_arg & DB_LOG_PI_SCRN) logPanicDataToScreen=TRUE;
}
#if NOTYET
hw_lock_init(&debugger_lock);
hw_lock_init(&pbtlock);
#endif
#if MACH_KDB
#if DB_MACHINE_COMMANDS
db_machine_commands_install(ppc_db_commands);
#endif
ddb_init();
if (boot_arg & DB_KDB)
current_debugger = KDB_CUR_DB;
if (halt_in_debugger && (current_debugger == KDB_CUR_DB)) {
Debugger("inline call to debugger(machine_startup)");
halt_in_debugger = 0;
active_debugger =1;
}
#endif
if (PE_parse_boot_arg("preempt", &boot_arg)) {
extern int default_preemption_rate;
default_preemption_rate = boot_arg;
}
if (PE_parse_boot_arg("unsafe", &boot_arg)) {
extern int max_unsafe_quanta;
max_unsafe_quanta = boot_arg;
}
if (PE_parse_boot_arg("poll", &boot_arg)) {
extern int max_poll_quanta;
max_poll_quanta = boot_arg;
}
if (PE_parse_boot_arg("yield", &boot_arg)) {
extern int sched_poll_yield_shift;
sched_poll_yield_shift = boot_arg;
}
machine_conf();
#if NOTYET
ml_thrm_init();
#endif
setup_main();
}
static void
machine_conf(void)
{
machine_info.max_cpus = NCPUS;
machine_info.avail_cpus = 1;
machine_info.memory_size = mem_size;
}
void
machine_init(void)
{
int unit;
const char *p;
int n;
cpuid_cpu_display("CPU identification", 0);
cpuid_feature_display("CPU features", 0);
#if NCPUS > 1
smp_init();
#endif
init_fpu();
clock_config();
}
void
halt_cpu(void)
{
halt_all_cpus(FALSE);
}
int reset_mem_on_reboot = 1;
void
halt_all_cpus(boolean_t reboot)
{
if (reboot) {
if (!reset_mem_on_reboot)
*(unsigned short *)phystokv(0x472) = 0x1234;
printf("MACH Reboot\n");
PEHaltRestart( kPERestartCPU );
} else {
printf("CPU halted\n");
PEHaltRestart( kPEHaltCPU );
}
while(1);
}
void fc_get(mach_timespec_t *ts);
#include <kern/clock.h>
#include <i386/rtclock_entries.h>
extern kern_return_t sysclk_gettime(
mach_timespec_t *cur_time);
void fc_get(mach_timespec_t *ts) {
(void )sysclk_gettime(ts);
}
void
Debugger(
const char *message)
{
printf("Debugger called: <%s>\n", message);
draw_panic_dialog();
__asm__("int3");
}
void
display_syscall(int syscall)
{
printf("System call happened %d\n", syscall);
}
#if XPR_DEBUG && (NCPUS == 1)
extern kern_return_t sysclk_gettime_interrupts_disabled(
mach_timespec_t *cur_time);
int xpr_time(void)
{
mach_timespec_t time;
sysclk_gettime_interrupts_disabled(&time);
return(time.tv_sec*1000000 + time.tv_nsec/1000);
}
#endif
enable_bluebox()
{
}
disable_bluebox()
{
}
char *
machine_boot_info(char *buf, vm_size_t size)
{
*buf ='\0';
return buf;
}