require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_I386_CPU_H_)) {
    eval 'sub _I386_CPU_H_ () {1;}' unless defined(&_I386_CPU_H_);
    require 'machine/frame.ph';
    require 'machine/psl.ph';
    require 'machine/segments.ph';
    require 'machine/intrdefs.ph';
    if(defined(&MULTIPROCESSOR)) {
	require 'machine/i82489reg.ph';
	require 'machine/i82489var.ph';
	eval 'sub NLAPIC () {1;}' unless defined(&NLAPIC);
    }
    eval 'sub cpu_swapin {
        local($p) = @_;
	    eval q();
    }' unless defined(&cpu_swapin);
    eval 'sub clockframe () { &intrframe;}' unless defined(&clockframe);
    require 'sys/device.ph';
    require 'sys/lock.ph';
    require 'sys/sched.ph';
    if(defined( &DIAGNOSTIC) || defined( &LOCKDEBUG)) {
    }
    eval 'sub CI_DDB_RUNNING () {0;}' unless defined(&CI_DDB_RUNNING);
    eval 'sub CI_DDB_SHOULDSTOP () {1;}' unless defined(&CI_DDB_SHOULDSTOP);
    eval 'sub CI_DDB_STOPPED () {2;}' unless defined(&CI_DDB_STOPPED);
    eval 'sub CI_DDB_ENTERDDB () {3;}' unless defined(&CI_DDB_ENTERDDB);
    eval 'sub CI_DDB_INDDB () {4;}' unless defined(&CI_DDB_INDDB);
    eval 'sub CPUF_BSP () {0x1;}' unless defined(&CPUF_BSP);
    eval 'sub CPUF_AP () {0x2;}' unless defined(&CPUF_AP);
    eval 'sub CPUF_SP () {0x4;}' unless defined(&CPUF_SP);
    eval 'sub CPUF_PRIMARY () {0x8;}' unless defined(&CPUF_PRIMARY);
    eval 'sub CPUF_APIC_CD () {0x10;}' unless defined(&CPUF_APIC_CD);
    eval 'sub CPUF_PRESENT () {0x1000;}' unless defined(&CPUF_PRESENT);
    eval 'sub CPUF_RUNNING () {0x2000;}' unless defined(&CPUF_RUNNING);
    eval 'sub CPU_INFO_ITERATOR () {\'int\';}' unless defined(&CPU_INFO_ITERATOR);
    eval 'sub CPU_INFO_FOREACH {
        local($cii, $ci) = @_;
	    eval q( &for ($cii = 0, $ci =  &cpu_info_list; $ci !=  &NULL; $ci =  ($ci->{ci_next})));
    }' unless defined(&CPU_INFO_FOREACH);
    eval 'sub CPU_INFO_UNIT {
        local($ci) = @_;
	    eval q((($ci)-> ($ci_dev->{dv_unit})));
    }' unless defined(&CPU_INFO_UNIT);
    if(defined(&MULTIPROCESSOR)) {
	eval 'sub I386_MAXPROCS () {32;}' unless defined(&I386_MAXPROCS);
	eval 'sub CPU_STARTUP {
	    local($_ci) = @_;
    	    eval q((($_ci)-> ($ci_func->{start})($_ci)));
	}' unless defined(&CPU_STARTUP);
	eval 'sub CPU_STOP {
	    local($_ci) = @_;
    	    eval q((($_ci)-> ($ci_func->{stop})($_ci)));
	}' unless defined(&CPU_STOP);
	eval 'sub CPU_START_CLEANUP {
	    local($_ci) = @_;
    	    eval q((($_ci)-> ($ci_func->{cleanup})($_ci)));
	}' unless defined(&CPU_START_CLEANUP);
	eval 'sub cpu_number () {
	    eval q(( &i82489_readreg( &LAPIC_ID)>> &LAPIC_ID_SHIFT));
	}' unless defined(&cpu_number);
	eval 'sub curcpu () {
	    eval q(( $cpu_info[ &cpu_number()]));
	}' unless defined(&curcpu);
	eval 'sub CPU_IS_PRIMARY {
	    local($ci) = @_;
    	    eval q((($ci)-> &ci_flags &  &CPUF_PRIMARY));
	}' unless defined(&CPU_IS_PRIMARY);
    } else {
	eval 'sub I386_MAXPROCS () {1;}' unless defined(&I386_MAXPROCS);
	eval 'sub cpu_number () {
	    eval q(0);
	}' unless defined(&cpu_number);
	eval 'sub curcpu () {
	    eval q(( &cpu_info_primary));
	}' unless defined(&curcpu);
	eval 'sub CPU_IS_PRIMARY {
	    local($ci) = @_;
    	    eval q(1);
	}' unless defined(&CPU_IS_PRIMARY);
	eval 'sub cpu_swapin {
	    local($p) = @_;
    	    eval q();
	}' unless defined(&cpu_swapin);
    }
    eval 'sub curpcb () { &curcpu()-> &ci_curpcb;}' unless defined(&curpcb);
    eval 'sub want_resched () {( &curcpu()-> &ci_want_resched);}' unless defined(&want_resched);
    eval 'sub astpending () {( &curcpu()-> &ci_astpending);}' unless defined(&astpending);
    eval 'sub CLKF_USERMODE {
        local($frame) = @_;
	    eval q( &USERMODE(($frame)-> &if_cs, ($frame)-> &if_eflags));
    }' unless defined(&CLKF_USERMODE);
    eval 'sub CLKF_PC {
        local($frame) = @_;
	    eval q((($frame)-> &if_eip));
    }' unless defined(&CLKF_PC);
    eval 'sub CLKF_INTR {
        local($frame) = @_;
	    eval q(( &IDXSEL(($frame)-> &if_cs) ==  &GICODE_SEL));
    }' unless defined(&CLKF_INTR);
    eval 'sub need_proftick {
        local($p) = @_;
	    eval q((($p)-> &p_flag |=  &P_OWEUPC,  &setsoftast()));
    }' unless defined(&need_proftick);
    eval 'sub signotify {
        local($p) = @_;
	    eval q( &setsoftast());
    }' unless defined(&signotify);
    eval 'sub DELAY {
        local($x) = @_;
	    eval q((* &delay_func)($x));
    }' unless defined(&DELAY);
    eval 'sub delay {
        local($x) = @_;
	    eval q((* &delay_func)($x));
    }' unless defined(&delay);
    eval 'sub microtime {
        local($tv) = @_;
	    eval q((* &microtime_func)($tv));
    }' unless defined(&microtime);
    if(defined( &I586_CPU) || defined( &I686_CPU)) {
	unless(defined(&HZ)) {
	    eval 'sub CPU_CLOCKUPDATE () {
	        eval q( &do {  &if ( &pentium_mhz) {  &__asm  &__volatile(\\"cli\\\\n\\" \\"rdtsc\\\\n\\" \\"sti\\\\n\\" : \\"=A\\" ( &pentium_base_tsc) : ); } }  &while (0));
	    }' unless defined(&CPU_CLOCKUPDATE);
	}
    }
    require 'machine/cputypes.ph';
    if(defined(&_KERNEL)) {
	if(defined( &I586_CPU) || defined( &I686_CPU)) {
	}
	if(defined(&I586_CPU)) {
	}
	if(!defined( &SMALL_KERNEL)  && defined( &I686_CPU)) {
	}
	if(!defined( &SMALL_KERNEL)  && defined( &I586_CPU)) {
	}
	if(!defined( &SMALL_KERNEL)  && defined( &I686_CPU)) {
	}
	if(!defined( &SMALL_KERNEL)  && defined( &I586_CPU)) {
	}
	if(!defined( &SMALL_KERNEL)  && defined( &I686_CPU)) {
	}
	if(defined( &GPL_MATH_EMULATE)) {
	}
	if(defined(&USER_LDT)) {
	}
	if(defined(&VM86)) {
	}
	if(defined(&GENERIC)) {
	}
    }
    eval 'sub CPU_CONSDEV () {1;}' unless defined(&CPU_CONSDEV);
    eval 'sub CPU_BIOS () {2;}' unless defined(&CPU_BIOS);
    eval 'sub CPU_BLK2CHR () {3;}' unless defined(&CPU_BLK2CHR);
    eval 'sub CPU_CHR2BLK () {4;}' unless defined(&CPU_CHR2BLK);
    eval 'sub CPU_ALLOWAPERTURE () {5;}' unless defined(&CPU_ALLOWAPERTURE);
    eval 'sub CPU_CPUVENDOR () {6;}' unless defined(&CPU_CPUVENDOR);
    eval 'sub CPU_CPUID () {7;}' unless defined(&CPU_CPUID);
    eval 'sub CPU_CPUFEATURE () {8;}' unless defined(&CPU_CPUFEATURE);
    eval 'sub CPU_APMWARN () {9;}' unless defined(&CPU_APMWARN);
    eval 'sub CPU_KBDRESET () {10;}' unless defined(&CPU_KBDRESET);
    eval 'sub CPU_APMHALT () {11;}' unless defined(&CPU_APMHALT);
    eval 'sub CPU_USERLDT () {12;}' unless defined(&CPU_USERLDT);
    eval 'sub CPU_OSFXSR () {13;}' unless defined(&CPU_OSFXSR);
    eval 'sub CPU_SSE () {14;}' unless defined(&CPU_SSE);
    eval 'sub CPU_SSE2 () {15;}' unless defined(&CPU_SSE2);
    eval 'sub CPU_XCRYPT () {16;}' unless defined(&CPU_XCRYPT);
    eval 'sub CPU_MAXID () {17;}' unless defined(&CPU_MAXID);
    eval 'sub CTL_MACHDEP_NAMES () {{ { 0, 0}, { "console_device",  &CTLTYPE_STRUCT }, { "bios",  &CTLTYPE_INT }, { "blk2chr",  &CTLTYPE_STRUCT }, { "chr2blk",  &CTLTYPE_STRUCT }, { "allowaperture",  &CTLTYPE_INT }, { "cpuvendor",  &CTLTYPE_STRING }, { "cpuid",  &CTLTYPE_INT }, { "cpufeature",  &CTLTYPE_INT }, { "apmwarn",  &CTLTYPE_INT }, { "kbdreset",  &CTLTYPE_INT }, { "apmhalt",  &CTLTYPE_INT }, { "userldt",  &CTLTYPE_INT }, { "osfxsr",  &CTLTYPE_INT }, { "sse",  &CTLTYPE_INT }, { "sse2",  &CTLTYPE_INT }, { "xcrypt",  &CTLTYPE_INT }, };}' unless defined(&CTL_MACHDEP_NAMES);
    if(defined( &MULTIPROCESSOR)  && defined( &_KERNEL)) {
	require 'sys/mplock.ph';
    }
}
1;
