require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_DEV_IC_ATWVAR_H_)) {
    eval 'sub _DEV_IC_ATWVAR_H_ () {1;}' unless defined(&_DEV_IC_ATWVAR_H_);
    require 'sys/queue.ph';
    require 'sys/time.ph';
    require 'sys/timeout.ph';
    eval 'sub ATW_NTXSEGS () {16;}' unless defined(&ATW_NTXSEGS);
    eval 'sub ATW_TXQUEUELEN () {64;}' unless defined(&ATW_TXQUEUELEN);
    eval 'sub ATW_NTXDESC () {( &ATW_TXQUEUELEN *  &ATW_NTXSEGS);}' unless defined(&ATW_NTXDESC);
    eval 'sub ATW_NTXDESC_MASK () {( &ATW_NTXDESC - 1);}' unless defined(&ATW_NTXDESC_MASK);
    eval 'sub ATW_NEXTTX {
        my($x) = @_;
	    eval q((($x + 1) &  &ATW_NTXDESC_MASK));
    }' unless defined(&ATW_NEXTTX);
    eval 'sub ATW_NRXDESC () {64;}' unless defined(&ATW_NRXDESC);
    eval 'sub ATW_NRXDESC_MASK () {( &ATW_NRXDESC - 1);}' unless defined(&ATW_NRXDESC_MASK);
    eval 'sub ATW_NEXTRX {
        my($x) = @_;
	    eval q((($x + 1) &  &ATW_NRXDESC_MASK));
    }' unless defined(&ATW_NEXTRX);
    eval 'sub ATW_CDOFF {
        my($x) = @_;
	    eval q( &offsetof(\'struct atw_control_data\', $x));
    }' unless defined(&ATW_CDOFF);
    eval 'sub ATW_CDTXOFF {
        my($x) = @_;
	    eval q( &ATW_CDOFF( $acd_txdescs[($x)]));
    }' unless defined(&ATW_CDTXOFF);
    eval 'sub ATW_CDRXOFF {
        my($x) = @_;
	    eval q( &ATW_CDOFF( $acd_rxdescs[($x)]));
    }' unless defined(&ATW_CDRXOFF);
    eval 'sub ATW_TXTHRESH_TAB_LO_RATE () {{ {  &ATW_NAR_TR_L64, "64 bytes" }, {  &ATW_NAR_TR_L160, "160 bytes" }, {  &ATW_NAR_TR_L192, "192 bytes" }, {  &ATW_NAR_SF, "store and forward" }, { 0,  &NULL }, };}' unless defined(&ATW_TXTHRESH_TAB_LO_RATE);
    eval 'sub ATW_TXTHRESH_TAB_HI_RATE () {{ {  &ATW_NAR_TR_H96, "96 bytes" }, {  &ATW_NAR_TR_H288, "288 bytes" }, {  &ATW_NAR_TR_H544, "544 bytes" }, {  &ATW_NAR_SF, "store and forward" }, { 0,  &NULL }, };}' unless defined(&ATW_TXTHRESH_TAB_HI_RATE);
    eval("sub ATW_RFTYPE_INTERSIL () { 0; }") unless defined(&ATW_RFTYPE_INTERSIL);
    eval("sub ATW_RFTYPE_RFMD () { 1; }") unless defined(&ATW_RFTYPE_RFMD);
    eval("sub ATW_RFTYPE_MARVEL () { 2; }") unless defined(&ATW_RFTYPE_MARVEL);
    eval("sub ATW_BBPTYPE_INTERSIL () { 0; }") unless defined(&ATW_BBPTYPE_INTERSIL);
    eval("sub ATW_BBPTYPE_RFMD () { 1; }") unless defined(&ATW_BBPTYPE_RFMD);
    eval("sub ATW_BBPTYPE_MARVEL () { 2; }") unless defined(&ATW_BBPTYPE_MARVEL);
    eval("sub ATW_C_BBPTYPE_RFMD () { 5; }") unless defined(&ATW_C_BBPTYPE_RFMD);
    eval 'sub ATW_RX_RADIOTAP_PRESENT () {((1<<  &IEEE80211_RADIOTAP_FLAGS) | (1<<  &IEEE80211_RADIOTAP_RATE) | (1<<  &IEEE80211_RADIOTAP_CHANNEL) | (1<<  &IEEE80211_RADIOTAP_DB_ANTSIGNAL));}' unless defined(&ATW_RX_RADIOTAP_PRESENT);
    eval 'sub ATW_TX_RADIOTAP_PRESENT () {((1<<  &IEEE80211_RADIOTAP_FLAGS) | (1<<  &IEEE80211_RADIOTAP_RATE) | (1<<  &IEEE80211_RADIOTAP_CHANNEL));}' unless defined(&ATW_TX_RADIOTAP_PRESENT);
    eval("sub ATW_REVISION_AB () { 0x11; }") unless defined(&ATW_REVISION_AB);
    eval("sub ATW_REVISION_AF () { 0x15; }") unless defined(&ATW_REVISION_AF);
    eval("sub ATW_REVISION_BA () { 0x20; }") unless defined(&ATW_REVISION_BA);
    eval("sub ATW_REVISION_CA () { 0x30; }") unless defined(&ATW_REVISION_CA);
    eval 'sub sc_cddma () { ($sc_cddmamap->{dm_segs[0]}->{ds_addr});}' unless defined(&sc_cddma);
    eval 'sub sc_txdescs () { ($sc_control_data->{acd_txdescs});}' unless defined(&sc_txdescs);
    eval 'sub sc_rxdescs () { ($sc_control_data->{acd_rxdescs});}' unless defined(&sc_rxdescs);
    eval 'sub sc_setup_desc () { ($sc_control_data->{acd_setup_desc});}' unless defined(&sc_setup_desc);
    eval 'sub sc_rxtap () { ($sc_rxtapu->{tap});}' unless defined(&sc_rxtap);
    eval 'sub sc_txtap () { ($sc_txtapu->{tap});}' unless defined(&sc_txtap);
    eval 'sub sc_if () { ($sc_ic->{ic_if});}' unless defined(&sc_if);
    eval 'sub atw_hdrctl () { ($u->{s1}->{hdrctl});}' unless defined(&atw_hdrctl);
    eval 'sub atw_fragthr () { ($u->{s1}->{fragthr});}' unless defined(&atw_fragthr);
    eval 'sub atw_fragnum () { ($u->{s1}->{fragnum});}' unless defined(&atw_fragnum);
    eval 'sub atw_rtylmt () { ($u->{s1}->{rtylmt});}' unless defined(&atw_rtylmt);
    eval 'sub atw_keyid () { ($u->{s1}->{keyid});}' unless defined(&atw_keyid);
    eval 'sub atw_ihdr () { ($u->{s2}->{ihdr});}' unless defined(&atw_ihdr);
    eval 'sub ATW_HDRCTL_SHORT_PREAMBLE () { &BIT(0);}' unless defined(&ATW_HDRCTL_SHORT_PREAMBLE);
    eval 'sub ATW_HDRCTL_RTSCTS () { &BIT(4);}' unless defined(&ATW_HDRCTL_RTSCTS);
    eval 'sub ATW_HDRCTL_WEP () { &BIT(5);}' unless defined(&ATW_HDRCTL_WEP);
    eval 'sub ATW_HDRCTL_UNKNOWN1 () { &BIT(15);}' unless defined(&ATW_HDRCTL_UNKNOWN1);
    eval 'sub ATW_HDRCTL_UNKNOWN2 () { &BIT(8);}' unless defined(&ATW_HDRCTL_UNKNOWN2);
    eval 'sub ATW_FRAGTHR_FRAGTHR_MASK () { &BITS(0, 11);}' unless defined(&ATW_FRAGTHR_FRAGTHR_MASK);
    eval 'sub ATW_FRAGNUM_FRAGNUM_MASK () { &BITS(4, 7);}' unless defined(&ATW_FRAGNUM_FRAGNUM_MASK);
    eval 'sub ATWF_MRL () {0x10;}' unless defined(&ATWF_MRL);
    eval 'sub ATWF_MRM () {0x20;}' unless defined(&ATWF_MRM);
    eval 'sub ATWF_MWI () {0x40;}' unless defined(&ATWF_MWI);
    eval 'sub ATWF_SHORT_PREAMBLE () {0x80;}' unless defined(&ATWF_SHORT_PREAMBLE);
    eval 'sub ATWF_RTSCTS () {0x100;}' unless defined(&ATWF_RTSCTS);
    eval 'sub ATWF_ATTACHED () {0x800;}' unless defined(&ATWF_ATTACHED);
    eval 'sub ATWF_ENABLED () {0x1000;}' unless defined(&ATWF_ENABLED);
    eval 'sub ATW_IS_ENABLED {
        my($sc) = @_;
	    eval q((($sc)-> &sc_flags &  &ATWF_ENABLED));
    }' unless defined(&ATW_IS_ENABLED);
    eval 'sub ATW_CDTXADDR {
        my($sc, $x) = @_;
	    eval q((($sc)-> &sc_cddma +  &ATW_CDTXOFF(($x))));
    }' unless defined(&ATW_CDTXADDR);
    eval 'sub ATW_CDRXADDR {
        my($sc, $x) = @_;
	    eval q((($sc)-> &sc_cddma +  &ATW_CDRXOFF(($x))));
    }' unless defined(&ATW_CDRXADDR);
    eval 'sub ATW_CDTXSYNC {
        my($sc, $x, $n, $ops) = @_;
	    eval q( &do { \'int\'  &__x,  &__n;  &__x = ($x);  &__n = ($n);  &if (( &__x +  &__n) >  &ATW_NTXDESC) {  &bus_dmamap_sync(($sc)-> &sc_dmat, ($sc)-> &sc_cddmamap,  &ATW_CDTXOFF( &__x), $sizeof{\'struct atw_txdesc\'} * ( &ATW_NTXDESC -  &__x), ($ops));  &__n -= ( &ATW_NTXDESC -  &__x);  &__x = 0; }  &bus_dmamap_sync(($sc)-> &sc_dmat, ($sc)-> &sc_cddmamap,  &ATW_CDTXOFF( &__x), $sizeof{\'struct atw_txdesc\'} *  &__n, ($ops)); }  &while (0));
    }' unless defined(&ATW_CDTXSYNC);
    eval 'sub ATW_CDRXSYNC {
        my($sc, $x, $ops) = @_;
	    eval q( &bus_dmamap_sync(($sc)-> &sc_dmat, ($sc)-> &sc_cddmamap,  &ATW_CDRXOFF(($x)), $sizeof{\'struct atw_rxdesc\'}, ($ops)));
    }' unless defined(&ATW_CDRXSYNC);
    eval 'sub ATW_INIT_RXDESC {
        my($sc, $x) = @_;
	    eval q( &do { \'struct atw_rxsoft\' * &__rxs =  ($sc->{sc_rxsoft[&(x)]}); \'struct atw_rxdesc\' * &__rxd =  ($sc->{sc_rxdescs[&(x)]}); \'struct mbuf\' * &__m =  ($__rxs->{r$xs_mbuf});  ($__rxd->{ar_buf1}) =  &htole32( ($__rxs->{r$xs_dmamap}->{dm_segs[0]}->{ds_addr}));  ($__rxd->{ar_buf2}) =  &htole32( &ATW_CDRXADDR(($sc),  &ATW_NEXTRX(($x))));  ($__rxd->{ar_ctl}) =  &htole32( &LSHIFT((( ($__m->{m_ext}->{e$xt_size}) - 1) & ~0x3),  &ATW_RXCTL_RBS1_MASK) | 0| (($x) == ( &ATW_NRXDESC - 1) ?  &ATW_RXCTL_RER : 0));  ($__rxd->{ar_stat}) =  &htole32( &ATW_RXSTAT_OWN);  &ATW_CDRXSYNC(($sc), ($x),  &BUS_DMASYNC_PREREAD| &BUS_DMASYNC_PREWRITE); }  &while (0));
    }' unless defined(&ATW_INIT_RXDESC);
    eval 'sub ATW_COUNTRY_FCC () {0;}' unless defined(&ATW_COUNTRY_FCC);
    eval 'sub ATW_COUNTRY_IC () {1;}' unless defined(&ATW_COUNTRY_IC);
    eval 'sub ATW_COUNTRY_ETSI () {2;}' unless defined(&ATW_COUNTRY_ETSI);
    eval 'sub ATW_COUNTRY_SPAIN () {3;}' unless defined(&ATW_COUNTRY_SPAIN);
    eval 'sub ATW_COUNTRY_FRANCE () {4;}' unless defined(&ATW_COUNTRY_FRANCE);
    eval 'sub ATW_COUNTRY_MKK () {5;}' unless defined(&ATW_COUNTRY_MKK);
    eval 'sub ATW_COUNTRY_MKK2 () {6;}' unless defined(&ATW_COUNTRY_MKK2);
    eval 'sub ATW_READ {
        my($sc, $reg) = @_;
	    eval q( &bus_space_read_4(($sc)-> &sc_st, ($sc)-> &sc_sh, ($reg)));
    }' unless defined(&ATW_READ);
    eval 'sub ATW_WRITE {
        my($sc, $reg, $val) = @_;
	    eval q( &bus_space_write_4(($sc)-> &sc_st, ($sc)-> &sc_sh, ($reg), ($val)));
    }' unless defined(&ATW_WRITE);
    eval 'sub ATW_SET {
        my($sc, $reg, $mask) = @_;
	    eval q( &ATW_WRITE(($sc), ($reg),  &ATW_READ(($sc), ($reg)) | ($mask)));
    }' unless defined(&ATW_SET);
    eval 'sub ATW_CLR {
        my($sc, $reg, $mask) = @_;
	    eval q( &ATW_WRITE(($sc), ($reg),  &ATW_READ(($sc), ($reg)) & ~($mask)));
    }' unless defined(&ATW_CLR);
    eval 'sub ATW_ISSET {
        my($sc, $reg, $mask) = @_;
	    eval q(( &ATW_READ(($sc), ($reg)) & ($mask)));
    }' unless defined(&ATW_ISSET);
}
1;
