require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_MACHINE_PMAP_H_)) {
    eval 'sub _MACHINE_PMAP_H_ () {1;}' unless defined(&_MACHINE_PMAP_H_);
    unless(defined(&_LOCORE)) {
	require 'machine/pte.ph';
	require 'sys/queue.ph';
    }
    eval 'sub HOLESHIFT () {(43);}' unless defined(&HOLESHIFT);
    eval 'sub PTSZ () {( &NBPG/8);}' unless defined(&PTSZ);
    eval 'sub PDSZ () {( &PTSZ);}' unless defined(&PDSZ);
    eval 'sub STSZ () {( &PTSZ);}' unless defined(&STSZ);
    eval 'sub PTSHIFT () {(13);}' unless defined(&PTSHIFT);
    eval 'sub PDSHIFT () {(10+ &PTSHIFT);}' unless defined(&PDSHIFT);
    eval 'sub STSHIFT () {(10+ &PDSHIFT);}' unless defined(&STSHIFT);
    eval 'sub PTMASK () {( &PTSZ-1);}' unless defined(&PTMASK);
    eval 'sub PDMASK () {( &PDSZ-1);}' unless defined(&PDMASK);
    eval 'sub STMASK () {( &STSZ-1);}' unless defined(&STMASK);
    unless(defined(&_LOCORE)) {
	if(defined(&DEBUG)) {
	}
	eval 'sub va_to_seg {
	    my($v) = @_;
    	    eval q((((( &paddr_t)($v))>> &STSHIFT) &STMASK));
	}' unless defined(&va_to_seg);
	eval 'sub va_to_dir {
	    my($v) = @_;
    	    eval q((((( &paddr_t)($v))>> &PDSHIFT) &PDMASK));
	}' unless defined(&va_to_dir);
	eval 'sub va_to_pte {
	    my($v) = @_;
    	    eval q((((( &paddr_t)($v))>> &PTSHIFT) &PTMASK));
	}' unless defined(&va_to_pte);
	if(defined(&_KERNEL)) {
	    eval 'sub PMAP_NC () {0x1;}' unless defined(&PMAP_NC);
	    eval 'sub PMAP_NVC () {0x2;}' unless defined(&PMAP_NVC);
	    eval 'sub PMAP_LITTLE () {0x4;}' unless defined(&PMAP_LITTLE);
	    eval 'sub PMAP_8K () {0x;}' unless defined(&PMAP_8K);
	    eval 'sub PMAP_64K () {0x8;}' unless defined(&PMAP_64K);
	    eval 'sub PMAP_512K () {0x10;}' unless defined(&PMAP_512K);
	    eval 'sub PMAP_4M () {0x18;}' unless defined(&PMAP_4M);
	    eval 'sub PMAP_SZ_TO_TTE {
	        my($x) = @_;
    		eval q(((($x)&0x18)<<58));
	    }' unless defined(&PMAP_SZ_TO_TTE);
	    eval 'sub VA_ALIAS_MASK () {(1<<13);}' unless defined(&VA_ALIAS_MASK);
	    eval 'sub PMAP_IOENC {
	        my($io) = @_;
    		eval q(0);
	    }' unless defined(&PMAP_IOENC);
	    eval 'sub pmap_kernel () {
	        eval q(( &kernel_pmap_));
	    }' unless defined(&pmap_kernel);
	    eval 'sub pmap_resident_count {
	        my($pm) = @_;
    		eval q((($pm)-> ($pm_stats->{resident_count})));
	    }' unless defined(&pmap_resident_count);
	    eval 'sub pmap_phys_address {
	        my($x) = @_;
    		eval q(($x));
	    }' unless defined(&pmap_phys_address);
	    eval 'sub pmap_update {
	        my($pm) = @_;
    		eval q();
	    }' unless defined(&pmap_update);
	    eval 'sub pmap_proc_iflush {
	        my($p,$va,$len) = @_;
    		eval q();
	    }' unless defined(&pmap_proc_iflush);
	    eval 'sub PMAP_PREFER {
	        my($pa, $va) = @_;
    		eval q((*($va) += (((*($va)) ^ ($pa)) &  &VA_ALIAS_MASK)));
	    }' unless defined(&PMAP_PREFER);
	    eval 'sub PMAP_GROWKERNEL () {1;}' unless defined(&PMAP_GROWKERNEL);
	}
    }
}
1;
