require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_I386_PMAP_H_)) {
    eval 'sub _I386_PMAP_H_ () {1;}' unless defined(&_I386_PMAP_H_);
    require 'machine/cpufunc.ph';
    require 'machine/pte.ph';
    require 'machine/segments.ph';
    require 'uvm/uvm_pglist.ph';
    require 'uvm/uvm_object.ph';
    eval 'sub PDSLOT_PTE () {(( &KERNBASE/ &NBPD)-1);}' unless defined(&PDSLOT_PTE);
    eval 'sub PDSLOT_KERN () {( &KERNBASE/ &NBPD);}' unless defined(&PDSLOT_KERN);
    eval 'sub PDSLOT_APTE () {(1023);}' unless defined(&PDSLOT_APTE);
    eval 'sub PTE_BASE () {(( &pt_entry_t *) ( &PDSLOT_PTE *  &NBPD) );}' unless defined(&PTE_BASE);
    eval 'sub APTE_BASE () {(( &pt_entry_t *) ( &PDSLOT_APTE *  &NBPD) );}' unless defined(&APTE_BASE);
    eval 'sub PDP_BASE () {(( &pd_entry_t *)(( &PTE_BASE) + ( &PDSLOT_PTE *  &NBPG)));}' unless defined(&PDP_BASE);
    eval 'sub APDP_BASE () {(( &pd_entry_t *)(( &APTE_BASE) + ( &PDSLOT_APTE *  &NBPG)));}' unless defined(&APDP_BASE);
    eval 'sub PDP_PDE () {( &PDP_BASE +  &PDSLOT_PTE);}' unless defined(&PDP_PDE);
    eval 'sub APDP_PDE () {( &PDP_BASE +  &PDSLOT_APTE);}' unless defined(&APDP_PDE);
    unless(defined(&NKPTP)) {
	eval 'sub NKPTP () {4;}' unless defined(&NKPTP);
    }
    eval 'sub NKPTP_MIN () {4;}' unless defined(&NKPTP_MIN);
    eval 'sub NKPTP_MAX () {(1024- ( &KERNBASE/ &NBPD) - 1);}' unless defined(&NKPTP_MAX);
    eval 'sub vtopte {
        local($VA) = @_;
	    eval q(( &PTE_BASE +  &atop($VA)));
    }' unless defined(&vtopte);
    eval 'sub kvtopte {
        local($VA) = @_;
	    eval q( &vtopte($VA));
    }' unless defined(&kvtopte);
    eval 'sub ptetov {
        local($PT) = @_;
	    eval q(( &ptoa($PT -  &PTE_BASE)));
    }' unless defined(&ptetov);
    eval 'sub vtophys {
        local($VA) = @_;
	    eval q(((* &vtopte &  &PG_FRAME) | (($VA) & ~ &PG_FRAME)));
    }' unless defined(&vtophys);
    eval 'sub avtopte {
        local($VA) = @_;
	    eval q(( &APTE_BASE +  &atop($VA)));
    }' unless defined(&avtopte);
    eval 'sub ptetoav {
        local($PT) = @_;
	    eval q(( &ptoa($PT -  &APTE_BASE)));
    }' unless defined(&ptetoav);
    eval 'sub avtophys {
        local($VA) = @_;
	    eval q(((* &avtopte &  &PG_FRAME) | (($VA) & ~ &PG_FRAME)));
    }' unless defined(&avtophys);
    eval 'sub pdei {
        local($VA) = @_;
	    eval q(((($VA) &  &PD_MASK) >>  &PDSHIFT));
    }' unless defined(&pdei);
    eval 'sub ptei {
        local($VA) = @_;
	    eval q(((($VA) &  &PT_MASK) >>  &PGSHIFT));
    }' unless defined(&ptei);
    eval 'sub ptp_i2o {
        local($I) = @_;
	    eval q((($I) *  &NBPG));
    }' unless defined(&ptp_i2o);
    eval 'sub ptp_o2i {
        local($O) = @_;
	    eval q((($O) /  &NBPG));
    }' unless defined(&ptp_o2i);
    eval 'sub ptp_i2v {
        local($I) = @_;
	    eval q((($I) *  &NBPD));
    }' unless defined(&ptp_i2v);
    eval 'sub ptp_v2i {
        local($V) = @_;
	    eval q((($V) /  &NBPD));
    }' unless defined(&ptp_v2i);
    eval 'sub PG_W () { &PG_AVAIL1;}' unless defined(&PG_W);
    eval 'sub PG_PVLIST () { &PG_AVAIL2;}' unless defined(&PG_PVLIST);
    eval 'sub PG_X () { &PG_AVAIL3;}' unless defined(&PG_X);
    eval 'sub NPTECL () {8;}' unless defined(&NPTECL);
    if(defined(&_KERNEL)) {
	eval 'sub pm_lock () { ($pm_obj->{vmobjlock});}' unless defined(&pm_lock);
	eval 'sub PMF_USER_LDT () {0x1;}' unless defined(&PMF_USER_LDT);
	eval 'sub PVE_PER_PVPAGE () {(( &NBPG - $sizeof{\'struct pv_page_info\'}) / $sizeof{\'struct pv_entry\'});}' unless defined(&PVE_PER_PVPAGE);
	eval 'sub pmap_kernel () {
	    eval q(( &kernel_pmap_store));
	}' unless defined(&pmap_kernel);
	eval 'sub pmap_resident_count {
	    local($pmap) = @_;
    	    eval q((($pmap)-> ($pm_stats->{resident_count})));
	}' unless defined(&pmap_resident_count);
	eval 'sub pmap_update {
	    local($pm) = @_;
    	    eval q();
	}' unless defined(&pmap_update);
	eval 'sub pmap_clear_modify {
	    local($pg) = @_;
    	    eval q( &pmap_change_attrs($pg, 0,  &PG_M));
	}' unless defined(&pmap_clear_modify);
	eval 'sub pmap_clear_reference {
	    local($pg) = @_;
    	    eval q( &pmap_change_attrs($pg, 0,  &PG_U));
	}' unless defined(&pmap_clear_reference);
	eval 'sub pmap_copy {
	    local($DP,$SP,$D,$L,$S) = @_;
    	    eval q();
	}' unless defined(&pmap_copy);
	eval 'sub pmap_is_modified {
	    local($pg) = @_;
    	    eval q( &pmap_test_attrs($pg,  &PG_M));
	}' unless defined(&pmap_is_modified);
	eval 'sub pmap_is_referenced {
	    local($pg) = @_;
    	    eval q( &pmap_test_attrs($pg,  &PG_U));
	}' unless defined(&pmap_is_referenced);
	eval 'sub pmap_phys_address {
	    local($ppn) = @_;
    	    eval q( &ptoa($ppn));
	}' unless defined(&pmap_phys_address);
	eval 'sub pmap_valid_entry {
	    local($E) = @_;
    	    eval q((($E) &  &PG_V));
	}' unless defined(&pmap_valid_entry);
	eval 'sub pmap_proc_iflush {
	    local($p,$va,$len) = @_;
    	    eval q();
	}' unless defined(&pmap_proc_iflush);
	eval 'sub pmap_unuse_final {
	    local($p) = @_;
    	    eval q();
	}' unless defined(&pmap_unuse_final);
	eval 'sub PMAP_GROWKERNEL () {1;}' unless defined(&PMAP_GROWKERNEL);
	eval 'sub PMAP_PAGEIDLEZERO {
	    local($pg) = @_;
    	    eval q( &pmap_zero_page_uncached( &VM_PAGE_TO_PHYS($pg)));
	}' unless defined(&PMAP_PAGEIDLEZERO);
	if(defined( &I386_CPU)) {
	}
	if(defined( &I386_CPU)) {
	}
	if(defined( &USER_LDT)) {
	    eval 'sub PMAP_FORK () {1;}' unless defined(&PMAP_FORK);
	}
    }
}
1;
