require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_IF_GEMVAR_H)) {
    eval 'sub _IF_GEMVAR_H () {1;}' unless defined(&_IF_GEMVAR_H);
    require 'sys/queue.ph';
    require 'sys/timeout.ph';
    eval 'sub GEM_NTXSEGS () {16;}' unless defined(&GEM_NTXSEGS);
    eval 'sub GEM_TXQUEUELEN () {64;}' unless defined(&GEM_TXQUEUELEN);
    eval 'sub GEM_NTXDESC () {( &GEM_TXQUEUELEN *  &GEM_NTXSEGS);}' unless defined(&GEM_NTXDESC);
    eval 'sub GEM_NTXDESC_MASK () {( &GEM_NTXDESC - 1);}' unless defined(&GEM_NTXDESC_MASK);
    eval 'sub GEM_NEXTTX {
        my($x) = @_;
	    eval q((($x + 1) &  &GEM_NTXDESC_MASK));
    }' unless defined(&GEM_NEXTTX);
    eval 'sub GEM_NRXDESC () {128;}' unless defined(&GEM_NRXDESC);
    eval 'sub GEM_NRXDESC_MASK () {( &GEM_NRXDESC - 1);}' unless defined(&GEM_NRXDESC_MASK);
    eval 'sub GEM_NEXTRX {
        my($x) = @_;
	    eval q((($x + 1) &  &GEM_NRXDESC_MASK));
    }' unless defined(&GEM_NEXTRX);
    eval 'sub GEM_CDOFF {
        my($x) = @_;
	    eval q( &offsetof(\'struct gem_control_data\', $x));
    }' unless defined(&GEM_CDOFF);
    eval 'sub GEM_CDTXOFF {
        my($x) = @_;
	    eval q( &GEM_CDOFF( $gcd_txdescs[($x)]));
    }' unless defined(&GEM_CDTXOFF);
    eval 'sub GEM_CDRXOFF {
        my($x) = @_;
	    eval q( &GEM_CDOFF( $gcd_rxdescs[($x)]));
    }' unless defined(&GEM_CDRXOFF);
    eval 'sub sc_media () { ($sc_mii->{mii_media});}' unless defined(&sc_media);
    if(0) {
    }
    eval 'sub GEM_UNKNOWN () {0;}' unless defined(&GEM_UNKNOWN);
    eval 'sub GEM_SUN_GEM () {1;}' unless defined(&GEM_SUN_GEM);
    eval 'sub GEM_SUN_ERI () {2;}' unless defined(&GEM_SUN_ERI);
    eval 'sub GEM_APPLE_INTREPID2_GMAC () {3;}' unless defined(&GEM_APPLE_INTREPID2_GMAC);
    eval 'sub GEM_APPLE_K2_GMAC () {4;}' unless defined(&GEM_APPLE_K2_GMAC);
    eval 'sub GEM_APPLE_PANGEA_GMAC () {5;}' unless defined(&GEM_APPLE_PANGEA_GMAC);
    eval 'sub GEM_APPLE_SHASTA_GMAC () {6;}' unless defined(&GEM_APPLE_SHASTA_GMAC);
    eval 'sub GEM_APPLE_UNINORTHGMAC () {7;}' unless defined(&GEM_APPLE_UNINORTHGMAC);
    eval 'sub GEM_APPLE_UNINORTH2GMAC () {8;}' unless defined(&GEM_APPLE_UNINORTH2GMAC);
    eval 'sub GEM_GIGABIT () {0x1;}' unless defined(&GEM_GIGABIT);
    eval 'sub sc_cddma () { ($sc_cddmamap->{dm_segs[0]}->{ds_addr});}' unless defined(&sc_cddma);
    eval 'sub sc_txdescs () { ($sc_control_data->{gcd_txdescs});}' unless defined(&sc_txdescs);
    eval 'sub sc_rxdescs () { ($sc_control_data->{gcd_rxdescs});}' unless defined(&sc_rxdescs);
    eval 'sub GEM_DMA_READ {
        my($sc, $v) = @_;
	    eval q(((($sc)-> &sc_pci) ?  &letoh64($v) :  &betoh64($v)));
    }' unless defined(&GEM_DMA_READ);
    eval 'sub GEM_DMA_WRITE {
        my($sc, $v) = @_;
	    eval q(((($sc)-> &sc_pci) ?  &htole64($v) :  &htobe64($v)));
    }' unless defined(&GEM_DMA_WRITE);
    eval 'sub GEM_CURRENT_MEDIA {
        my($sc) = @_;
	    eval q(( &IFM_SUBTYPE(($sc)-> ($sc_mii->{mii_media}->{ifm_cur}->{ifm_media})) !=  &IFM_AUTO ? ($sc)-> ($sc_mii->{mii_media}->{ifm_cur}) : ($sc)-> &sc_nway_active));
    }' unless defined(&GEM_CURRENT_MEDIA);
    eval 'sub GEM_MEDIA_NEEDSRESET {
        my($sc, $newbits) = @_;
	    eval q(((($sc)-> &sc_opmode &  &OPMODE_MEDIA_BITS) != (($newbits) &  &OPMODE_MEDIA_BITS)));
    }' unless defined(&GEM_MEDIA_NEEDSRESET);
    eval 'sub GEM_CDTXADDR {
        my($sc, $x) = @_;
	    eval q((($sc)-> &sc_cddma +  &GEM_CDTXOFF(($x))));
    }' unless defined(&GEM_CDTXADDR);
    eval 'sub GEM_CDRXADDR {
        my($sc, $x) = @_;
	    eval q((($sc)-> &sc_cddma +  &GEM_CDRXOFF(($x))));
    }' unless defined(&GEM_CDRXADDR);
    eval 'sub GEM_CDSPADDR {
        my($sc) = @_;
	    eval q((($sc)-> &sc_cddma +  &GEM_CDSPOFF));
    }' unless defined(&GEM_CDSPADDR);
    eval 'sub GEM_CDTXSYNC {
        my($sc, $x, $n, $ops) = @_;
	    eval q( &do { \'int\'  &__x,  &__n;  &__x = ($x);  &__n = ($n);  &if (( &__x +  &__n) >  &GEM_NTXDESC) {  &bus_dmamap_sync(($sc)-> &sc_dmatag, ($sc)-> &sc_cddmamap,  &GEM_CDTXOFF( &__x), $sizeof{\'struct gem_desc\'} * ( &GEM_NTXDESC -  &__x), ($ops));  &__n -= ( &GEM_NTXDESC -  &__x);  &__x = 0; }  &bus_dmamap_sync(($sc)-> &sc_dmatag, ($sc)-> &sc_cddmamap,  &GEM_CDTXOFF( &__x), $sizeof{\'struct gem_desc\'} *  &__n, ($ops)); }  &while (0));
    }' unless defined(&GEM_CDTXSYNC);
    eval 'sub GEM_CDRXSYNC {
        my($sc, $x, $ops) = @_;
	    eval q( &bus_dmamap_sync(($sc)-> &sc_dmatag, ($sc)-> &sc_cddmamap,  &GEM_CDRXOFF(($x)), $sizeof{\'struct gem_desc\'}, ($ops)));
    }' unless defined(&GEM_CDRXSYNC);
    eval 'sub GEM_CDSPSYNC {
        my($sc, $ops) = @_;
	    eval q( &bus_dmamap_sync(($sc)-> &sc_dmatag, ($sc)-> &sc_cddmamap,  &GEM_CDSPOFF,  &GEM_SETUP_PACKET_LEN, ($ops)));
    }' unless defined(&GEM_CDSPSYNC);
    eval 'sub GEM_INIT_RXDESC {
        my($sc, $x) = @_;
	    eval q( &do { \'struct gem_rxsoft\' * &__rxs =  ($sc->{sc_rxsoft[&(x)]}); \'struct gem_desc\' * &__rxd =  ($sc->{sc_rxdescs[&(x)]}); \'struct mbuf\' * &__m =  ($__rxs->{r$xs_mbuf});  ($__m->{m_data}) =  ($__m->{m_ext}->{e$xt_buf});  ($__rxd->{gd_addr}) =  &GEM_DMA_WRITE(($sc),  ($__rxs->{r$xs_dmamap}->{dm_segs[0]}->{ds_addr}));  ($__rxd->{gd_flags}) =  &GEM_DMA_WRITE(($sc), ((( ($__m->{m_ext}->{e$xt_size}))<< &GEM_RD_BUFSHIFT) &  &GEM_RD_BUFSIZE) |  &GEM_RD_OWN);  &GEM_CDRXSYNC(($sc), ($x),  &BUS_DMASYNC_PREREAD| &BUS_DMASYNC_PREWRITE); }  &while (0));
    }' unless defined(&GEM_INIT_RXDESC);
    eval 'sub GEM_IS_APPLE {
        my($sc) = @_;
	    eval q((($sc)-> &sc_variant >=  &GEM_APPLE_INTREPID2_GMAC  && ($sc)-> &sc_variant <=  &GEM_APPLE_UNINORTH2GMAC));
    }' unless defined(&GEM_IS_APPLE);
    if(defined(&_KERNEL)) {
    }
}
1;
