require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_DEV_MII_MIIVAR_H_)) {
    eval 'sub _DEV_MII_MIIVAR_H_ () {1;}' unless defined(&_DEV_MII_MIIVAR_H_);
    require 'sys/queue.ph';
    require 'sys/timeout.ph';
    eval 'sub MII_TICK () {1;}' unless defined(&MII_TICK);
    eval 'sub MII_MEDIACHG () {2;}' unless defined(&MII_MEDIACHG);
    eval 'sub MII_POLLSTAT () {3;}' unless defined(&MII_POLLSTAT);
    eval 'sub MII_DOWN () {4;}' unless defined(&MII_DOWN);
    eval 'sub MII_ANEGTICKS () {5;}' unless defined(&MII_ANEGTICKS);
    eval 'sub MII_ANEGTICKS_GIGE () {10;}' unless defined(&MII_ANEGTICKS_GIGE);
    eval 'sub MIIF_INITDONE () {0x1;}' unless defined(&MIIF_INITDONE);
    eval 'sub MIIF_NOISOLATE () {0x2;}' unless defined(&MIIF_NOISOLATE);
    eval 'sub MIIF_NOLOOP () {0x4;}' unless defined(&MIIF_NOLOOP);
    eval 'sub MIIF_DOINGAUTO () {0x8;}' unless defined(&MIIF_DOINGAUTO);
    eval 'sub MIIF_AUTOTSLEEP () {0x10;}' unless defined(&MIIF_AUTOTSLEEP);
    eval 'sub MIIF_HAVEFIBER () {0x20;}' unless defined(&MIIF_HAVEFIBER);
    eval 'sub MIIF_HAVE_GTCR () {0x40;}' unless defined(&MIIF_HAVE_GTCR);
    eval 'sub MIIF_IS_1000X () {0x80;}' unless defined(&MIIF_IS_1000X);
    eval 'sub MIIF_DOPAUSE () {0x100;}' unless defined(&MIIF_DOPAUSE);
    eval 'sub MIIF_IS_HPNA () {0x200;}' unless defined(&MIIF_IS_HPNA);
    eval 'sub MIIF_FORCEANEG () {0x400;}' unless defined(&MIIF_FORCEANEG);
    eval 'sub MIIF_INHERIT_MASK () {( &MIIF_NOISOLATE| &MIIF_NOLOOP| &MIIF_AUTOTSLEEP);}' unless defined(&MIIF_INHERIT_MASK);
    eval 'sub MII_OFFSET_ANY () {-1;}' unless defined(&MII_OFFSET_ANY);
    eval 'sub MII_PHY_ANY () {-1;}' unless defined(&MII_PHY_ANY);
    eval 'sub MII_MEDIA_NONE () {0;}' unless defined(&MII_MEDIA_NONE);
    eval 'sub MII_MEDIA_10_T () {1;}' unless defined(&MII_MEDIA_10_T);
    eval 'sub MII_MEDIA_10_T_FDX () {2;}' unless defined(&MII_MEDIA_10_T_FDX);
    eval 'sub MII_MEDIA_100_T4 () {3;}' unless defined(&MII_MEDIA_100_T4);
    eval 'sub MII_MEDIA_100_TX () {4;}' unless defined(&MII_MEDIA_100_TX);
    eval 'sub MII_MEDIA_100_TX_FDX () {5;}' unless defined(&MII_MEDIA_100_TX_FDX);
    eval 'sub MII_MEDIA_1000_X () {6;}' unless defined(&MII_MEDIA_1000_X);
    eval 'sub MII_MEDIA_1000_X_FDX () {7;}' unless defined(&MII_MEDIA_1000_X_FDX);
    eval 'sub MII_MEDIA_1000_T () {8;}' unless defined(&MII_MEDIA_1000_T);
    eval 'sub MII_MEDIA_1000_T_FDX () {9;}' unless defined(&MII_MEDIA_1000_T_FDX);
    eval 'sub MII_NMEDIA () {10;}' unless defined(&MII_NMEDIA);
    if(defined(&_KERNEL)) {
	eval 'sub PHY_READ {
	    my($p, $r) = @_;
    	    eval q((*($p)-> ($mii_pdata->{mii_readreg}))(($p)-> ($mii_dev->{dv_parent}), ($p)-> &mii_phy, ($r)));
	}' unless defined(&PHY_READ);
	eval 'sub PHY_WRITE {
	    my($p, $r, $v) = @_;
    	    eval q((*($p)-> ($mii_pdata->{mii_writereg}))(($p)-> ($mii_dev->{d$v_parent}), ($p)-> &mii_phy, ($r), ($v)));
	}' unless defined(&PHY_WRITE);
	eval 'sub PHY_SERVICE {
	    my($p, $d, $o) = @_;
    	    eval q((*($p)-> ($mii_funcs->{pf_service}))(($p), ($d), ($o)));
	}' unless defined(&PHY_SERVICE);
	eval 'sub PHY_STATUS {
	    my($p) = @_;
    	    eval q((*($p)-> ($mii_funcs->{pf_status}))(($p)));
	}' unless defined(&PHY_STATUS);
	eval 'sub PHY_RESET {
	    my($p) = @_;
    	    eval q((*($p)-> ($mii_funcs->{pf_reset}))(($p)));
	}' unless defined(&PHY_RESET);
	eval 'sub mii_phy_probe {
	    my($x, $y, $z) = @_;
    	    eval q( &mii_attach(($x), ($y), ($z),  &MII_PHY_ANY,  &MII_OFFSET_ANY, 0));
	}' unless defined(&mii_phy_probe);
	eval 'sub MII_OUI {
	    my($id1, $id2) = @_;
    	    eval q(((($id1) << 6) | (($id2) >> 10)));
	}' unless defined(&MII_OUI);
	eval 'sub MII_MODEL {
	    my($id2) = @_;
    	    eval q(((($id2) &  &IDR2_MODEL) >> 4));
	}' unless defined(&MII_MODEL);
	eval 'sub MII_REV {
	    my($id2) = @_;
    	    eval q((($id2) &  &IDR2_REV));
	}' unless defined(&MII_REV);
    }
}
1;
