require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_I386_BIOSVAR_H_)) {
    eval 'sub _I386_BIOSVAR_H_ () {1;}' unless defined(&_I386_BIOSVAR_H_);
    eval 'sub BOOTARG_OFF () {( &NBPG*2);}' unless defined(&BOOTARG_OFF);
    eval 'sub BOOTARG_LEN () {( &NBPG*1);}' unless defined(&BOOTARG_LEN);
    eval 'sub BOOTBIOS_ADDR () {(0x7c00);}' unless defined(&BOOTBIOS_ADDR);
    eval 'sub BIOSF_BIOS32 () {0x1;}' unless defined(&BIOSF_BIOS32);
    eval 'sub BIOSF_PCIBIOS () {0x2;}' unless defined(&BIOSF_PCIBIOS);
    eval 'sub BIOSF_PROMSCAN () {0x4;}' unless defined(&BIOSF_PROMSCAN);
    eval 'sub BIOSM_F320K () {0xff;}' unless defined(&BIOSM_F320K);
    eval 'sub BIOSM_F160K () {0xfe;}' unless defined(&BIOSM_F160K);
    eval 'sub BIOSM_F360K () {0xfd;}' unless defined(&BIOSM_F360K);
    eval 'sub BIOSM_F180K () {0xfc;}' unless defined(&BIOSM_F180K);
    eval 'sub BIOSM_ROMD () {0xfa;}' unless defined(&BIOSM_ROMD);
    eval 'sub BIOSM_F120M () {0xf9;}' unless defined(&BIOSM_F120M);
    eval 'sub BIOSM_F720K () {0xf9;}' unless defined(&BIOSM_F720K);
    eval 'sub BIOSM_HD () {0xf8;}' unless defined(&BIOSM_HD);
    eval 'sub BIOSM_F144K () {0xf0;}' unless defined(&BIOSM_F144K);
    eval 'sub BIOSM_OTHER () {0xf0;}' unless defined(&BIOSM_OTHER);
    eval 'sub BIOS_MAP_END () {0x;}' unless defined(&BIOS_MAP_END);
    eval 'sub BIOS_MAP_FREE () {0x1;}' unless defined(&BIOS_MAP_FREE);
    eval 'sub BIOS_MAP_RES () {0x2;}' unless defined(&BIOS_MAP_RES);
    eval 'sub BIOS_MAP_ACPI () {0x3;}' unless defined(&BIOS_MAP_ACPI);
    eval 'sub BIOS_MAP_NVS () {0x4;}' unless defined(&BIOS_MAP_NVS);
    eval 'sub BIOS32_START () {0xe0000;}' unless defined(&BIOS32_START);
    eval 'sub BIOS32_SIZE () {0x20000;}' unless defined(&BIOS32_SIZE);
    eval 'sub BIOS32_END () {( &BIOS32_START +  &BIOS32_SIZE - 0x10);}' unless defined(&BIOS32_END);
    eval 'sub BIOS32_MAKESIG {
        local($a, $b, $c, $d) = @_;
	    eval q((($a) | (($b) << 8) | (($c) << 16) | (($d) << 24)));
    }' unless defined(&BIOS32_MAKESIG);
    eval 'sub BIOS32_SIGNATURE () { &BIOS32_MAKESIG(ord(\'_\', \'3\', \'2\', \'_\'));}' unless defined(&BIOS32_SIGNATURE);
    eval 'sub PCIBIOS_SIGNATURE () { &BIOS32_MAKESIG(ord(\'$\', \'P\', \'C\', \'I\'));}' unless defined(&PCIBIOS_SIGNATURE);
    eval 'sub BIOS_DEV () {1;}' unless defined(&BIOS_DEV);
    eval 'sub BIOS_DISKINFO () {2;}' unless defined(&BIOS_DISKINFO);
    eval 'sub BIOS_CKSUMLEN () {3;}' unless defined(&BIOS_CKSUMLEN);
    eval 'sub BIOS_MAXID () {4;}' unless defined(&BIOS_MAXID);
    eval 'sub CTL_BIOS_NAMES () {{ { 0, 0}, { "biosdev",  &CTLTYPE_INT }, { "diskinfo",  &CTLTYPE_STRUCT }, { "cksumlen",  &CTLTYPE_INT }, };}' unless defined(&CTL_BIOS_NAMES);
    eval 'sub BOOTARG_MEMMAP () {0;}' unless defined(&BOOTARG_MEMMAP);
    eval 'sub BOOTARG_DISKINFO () {1;}' unless defined(&BOOTARG_DISKINFO);
    eval 'sub BDI_INVALID () {0x1;}' unless defined(&BDI_INVALID);
    eval 'sub BDI_GOODLABEL () {0x2;}' unless defined(&BDI_GOODLABEL);
    eval 'sub BDI_BADLABEL () {0x4;}' unless defined(&BDI_BADLABEL);
    eval 'sub BDI_EL_TORITO () {0x8;}' unless defined(&BDI_EL_TORITO);
    eval 'sub BDI_PICKED () {0x80000000;}' unless defined(&BDI_PICKED);
    eval 'sub BOOTARG_APMINFO () {2;}' unless defined(&BOOTARG_APMINFO);
    eval 'sub BOOTARG_CKSUMLEN () {3;}' unless defined(&BOOTARG_CKSUMLEN);
    eval 'sub BOOTARG_PCIINFO () {4;}' unless defined(&BOOTARG_PCIINFO);
    eval 'sub BOOTARG_CONSDEV () {5;}' unless defined(&BOOTARG_CONSDEV);
    eval 'sub BOOTARG_SMPINFO () {6;}' unless defined(&BOOTARG_SMPINFO);
    if(defined( &_KERNEL) || defined ( &_STANDALONE)) {
	if(defined(&_LOCORE)) {
	    eval 'sub DOINT {
	        local($n) = @_;
    		eval q(\'int\' $0x20+($n));
	    }' unless defined(&DOINT);
	} else {
	    eval 'sub DOINT {
	        local($n) = @_;
    		eval q(\\"int $0x20+(\\" $n \\")\\");
	    }' unless defined(&DOINT);
	    if(defined(&_KERNEL)) {
		require 'machine/bus.ph';
		eval 'sub bios_apmp () { ($_->{_bios_apmp});}' unless defined(&bios_apmp);
	    }
	}
    }
}
1;
