require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_ISP_TARGET_H)) {
    eval 'sub _ISP_TARGET_H () {1;}' unless defined(&_ISP_TARGET_H);
    eval 'sub QLTM_SVALID () {0x80;}' unless defined(&QLTM_SVALID);
    eval 'sub QLTM_SENSELEN () {18;}' unless defined(&QLTM_SENSELEN);
    eval 'sub LUN_TQAE () {0x2;}' unless defined(&LUN_TQAE);
    eval 'sub LUN_DSSM () {0x1000000;}' unless defined(&LUN_DSSM);
    eval 'sub LUN_DISAD () {0x2000000;}' unless defined(&LUN_DISAD);
    eval 'sub LUN_DM () {0x40000000;}' unless defined(&LUN_DM);
    eval 'sub LUN_CCINCR () {0x1;}' unless defined(&LUN_CCINCR);
    eval 'sub LUN_CCDECR () {0x2;}' unless defined(&LUN_CCDECR);
    eval 'sub LUN_ININCR () {0x40;}' unless defined(&LUN_ININCR);
    eval 'sub LUN_INDECR () {0x80;}' unless defined(&LUN_INDECR);
    eval 'sub LUN_OK () {0x1;}' unless defined(&LUN_OK);
    eval 'sub LUN_ERR () {0x4;}' unless defined(&LUN_ERR);
    eval 'sub LUN_INVAL () {0x6;}' unless defined(&LUN_INVAL);
    eval 'sub LUN_NOCAP () {0x16;}' unless defined(&LUN_NOCAP);
    eval 'sub LUN_ENABLED () {0x3e;}' unless defined(&LUN_ENABLED);
    eval 'sub IN_MSGLEN () {8;}' unless defined(&IN_MSGLEN);
    eval 'sub IN_RSVDLEN () {8;}' unless defined(&IN_RSVDLEN);
    eval 'sub IN_REJECT () {0xd;}' unless defined(&IN_REJECT);
    eval 'sub IN_RESET () {0xe;}' unless defined(&IN_RESET);
    eval 'sub IN_NO_RCAP () {0x16;}' unless defined(&IN_NO_RCAP);
    eval 'sub IN_IDE_RECEIVED () {0x33;}' unless defined(&IN_IDE_RECEIVED);
    eval 'sub IN_RSRC_UNAVAIL () {0x34;}' unless defined(&IN_RSRC_UNAVAIL);
    eval 'sub IN_MSG_RECEIVED () {0x36;}' unless defined(&IN_MSG_RECEIVED);
    eval 'sub IN_ABORT_TASK () {0x20;}' unless defined(&IN_ABORT_TASK);
    eval 'sub IN_PORT_LOGOUT () {0x29;}' unless defined(&IN_PORT_LOGOUT);
    eval 'sub IN_PORT_CHANGED () {0x2a;}' unless defined(&IN_PORT_CHANGED);
    eval 'sub IN_GLOBAL_LOGO () {0x2e;}' unless defined(&IN_GLOBAL_LOGO);
    eval 'sub IN_NO_NEXUS () {0x3b;}' unless defined(&IN_NO_NEXUS);
    eval 'sub TASK_FLAGS_ABORT_TASK () {(1<<9);}' unless defined(&TASK_FLAGS_ABORT_TASK);
    eval 'sub TASK_FLAGS_CLEAR_TASK_SET () {(1<<10);}' unless defined(&TASK_FLAGS_CLEAR_TASK_SET);
    eval 'sub TASK_FLAGS_TARGET_RESET () {(1<<13);}' unless defined(&TASK_FLAGS_TARGET_RESET);
    eval 'sub TASK_FLAGS_CLEAR_ACA () {(1<<14);}' unless defined(&TASK_FLAGS_CLEAR_ACA);
    eval 'sub TASK_FLAGS_TERMINATE_TASK () {(1<<15);}' unless defined(&TASK_FLAGS_TERMINATE_TASK);
    unless(defined(&MSG_ABORT_TAG)) {
	eval 'sub MSG_ABORT_TAG () {0x6;}' unless defined(&MSG_ABORT_TAG);
    }
    unless(defined(&MSG_CLEAR_QUEUE)) {
	eval 'sub MSG_CLEAR_QUEUE () {0xe;}' unless defined(&MSG_CLEAR_QUEUE);
    }
    unless(defined(&MSG_BUS_DEV_RESET)) {
	eval 'sub MSG_BUS_DEV_RESET () {0xb;}' unless defined(&MSG_BUS_DEV_RESET);
    }
    unless(defined(&MSG_REL_RECOVERY)) {
	eval 'sub MSG_REL_RECOVERY () {0x10;}' unless defined(&MSG_REL_RECOVERY);
    }
    unless(defined(&MSG_TERM_IO_PROC)) {
	eval 'sub MSG_TERM_IO_PROC () {0x11;}' unless defined(&MSG_TERM_IO_PROC);
    }
    eval 'sub NA_RSVDLEN () {22;}' unless defined(&NA_RSVDLEN);
    eval 'sub NA_RST_CLRD () {0x80;}' unless defined(&NA_RST_CLRD);
    eval 'sub NA_OK () {0x1;}' unless defined(&NA_OK);
    eval 'sub NA_INVALID () {0x6;}' unless defined(&NA_INVALID);
    eval 'sub NA2_RSVDLEN () {21;}' unless defined(&NA2_RSVDLEN);
    eval 'sub NAFC_RCOUNT () {0x80;}' unless defined(&NAFC_RCOUNT);
    eval 'sub NAFC_RST_CLRD () {0x20;}' unless defined(&NAFC_RST_CLRD);
    eval 'sub ATIO_CDBLEN () {26;}' unless defined(&ATIO_CDBLEN);
    eval 'sub AT_NODISC () {0x8000;}' unless defined(&AT_NODISC);
    eval 'sub AT_TQAE () {0x2;}' unless defined(&AT_TQAE);
    eval 'sub AT_PATH_INVALID () {0x7;}' unless defined(&AT_PATH_INVALID);
    eval 'sub AT_RESET () {0xe;}' unless defined(&AT_RESET);
    eval 'sub AT_PHASE_ERROR () {0x14;}' unless defined(&AT_PHASE_ERROR);
    eval 'sub AT_NOCAP () {0x16;}' unless defined(&AT_NOCAP);
    eval 'sub AT_BDR_MSG () {0x17;}' unless defined(&AT_BDR_MSG);
    eval 'sub AT_CDB () {0x3d;}' unless defined(&AT_CDB);
    eval 'sub AT_MAKE_TAGID {
        my($tid, $aep) = @_;
	    eval q($tid = (($aep)-> &at_handle << 16);  &if (($aep)-> &at_flags &  &AT_TQAE) ($tid) |= (($aep)-> &at_tag_val + 1));
    }' unless defined(&AT_MAKE_TAGID);
    eval 'sub CT_MAKE_TAGID {
        my($tid, $ct) = @_;
	    eval q($tid = (($ct)-> &ct_fwhandle << 16);  &if (($ct)-> &ct_flags &  &CT_TQAE) ($tid) |= (($ct)-> &ct_tag_val + 1));
    }' unless defined(&CT_MAKE_TAGID);
    eval 'sub AT_HAS_TAG {
        my($val) = @_;
	    eval q((($val) & 0xffff));
    }' unless defined(&AT_HAS_TAG);
    eval 'sub AT_GET_TAG {
        my($val) = @_;
	    eval q( &AT_HAS_TAG($val) - 1);
    }' unless defined(&AT_GET_TAG);
    eval 'sub AT_GET_HANDLE {
        my($val) = @_;
	    eval q((($val) >> 16));
    }' unless defined(&AT_GET_HANDLE);
    eval 'sub ATIO2_CDBLEN () {16;}' unless defined(&ATIO2_CDBLEN);
    eval 'sub ATIO2_WWPN_OFFSET () {0x2a;}' unless defined(&ATIO2_WWPN_OFFSET);
    eval 'sub ATIO2_OXID_OFFSET () {0x3e;}' unless defined(&ATIO2_OXID_OFFSET);
    eval 'sub ATIO2_TC_ATTR_MASK () {0x7;}' unless defined(&ATIO2_TC_ATTR_MASK);
    eval 'sub ATIO2_TC_ATTR_SIMPLEQ () {0;}' unless defined(&ATIO2_TC_ATTR_SIMPLEQ);
    eval 'sub ATIO2_TC_ATTR_HEADOFQ () {1;}' unless defined(&ATIO2_TC_ATTR_HEADOFQ);
    eval 'sub ATIO2_TC_ATTR_ORDERED () {2;}' unless defined(&ATIO2_TC_ATTR_ORDERED);
    eval 'sub ATIO2_TC_ATTR_ACAQ () {4;}' unless defined(&ATIO2_TC_ATTR_ACAQ);
    eval 'sub ATIO2_TC_ATTR_UNTAGGED () {5;}' unless defined(&ATIO2_TC_ATTR_UNTAGGED);
    eval 'sub ct_syshandle () { &ct_reserved;}' unless defined(&ct_syshandle);
    eval 'sub ct_dataseg () { ($_u->{ct_a});}' unless defined(&ct_dataseg);
    eval 'sub GET_IID_VAL {
        my($x) = @_;
	    eval q(($x & 0x3f));
    }' unless defined(&GET_IID_VAL);
    eval 'sub GET_BUS_VAL {
        my($x) = @_;
	    eval q((($x >> 7) & 0x1));
    }' unless defined(&GET_BUS_VAL);
    eval 'sub SET_IID_VAL {
        my($y, $x) = @_;
	    eval q($y = (($y & ~0x3f) | ($x & 0x3f)));
    }' unless defined(&SET_IID_VAL);
    eval 'sub SET_BUS_VAL {
        my($y, $x) = @_;
	    eval q($y = (($y & 0x3f) | (($x & 0x1) << 7)));
    }' unless defined(&SET_BUS_VAL);
    eval 'sub CT_TQAE () {0x2;}' unless defined(&CT_TQAE);
    eval 'sub CT_DATA_IN () {0x40;}' unless defined(&CT_DATA_IN);
    eval 'sub CT_DATA_OUT () {0x80;}' unless defined(&CT_DATA_OUT);
    eval 'sub CT_NO_DATA () {0xc0;}' unless defined(&CT_NO_DATA);
    eval 'sub CT_CCINCR () {0x100;}' unless defined(&CT_CCINCR);
    eval 'sub CT_DATAMASK () {0xc0;}' unless defined(&CT_DATAMASK);
    eval 'sub CT_INISYNCWIDE () {0x4000;}' unless defined(&CT_INISYNCWIDE);
    eval 'sub CT_NODISC () {0x8000;}' unless defined(&CT_NODISC);
    eval 'sub CT_DSDP () {0x1000000;}' unless defined(&CT_DSDP);
    eval 'sub CT_SENDRDP () {0x4000000;}' unless defined(&CT_SENDRDP);
    eval 'sub CT_SENDSTATUS () {0x80000000;}' unless defined(&CT_SENDSTATUS);
    eval 'sub CT_OK () {0x1;}' unless defined(&CT_OK);
    eval 'sub CT_ABORTED () {0x2;}' unless defined(&CT_ABORTED);
    eval 'sub CT_ERR () {0x4;}' unless defined(&CT_ERR);
    eval 'sub CT_INVAL () {0x6;}' unless defined(&CT_INVAL);
    eval 'sub CT_NOPATH () {0x7;}' unless defined(&CT_NOPATH);
    eval 'sub CT_INVRXID () {0x8;}' unless defined(&CT_INVRXID);
    eval 'sub CT_DATA_OVER () {0x9;}' unless defined(&CT_DATA_OVER);
    eval 'sub CT_RSELTMO () {0xa;}' unless defined(&CT_RSELTMO);
    eval 'sub CT_TIMEOUT () {0xb;}' unless defined(&CT_TIMEOUT);
    eval 'sub CT_RESET () {0xe;}' unless defined(&CT_RESET);
    eval 'sub CT_PARITY () {0xf;}' unless defined(&CT_PARITY);
    eval 'sub CT_BUS_ERROR () {0x10;}' unless defined(&CT_BUS_ERROR);
    eval 'sub CT_PANIC () {0x13;}' unless defined(&CT_PANIC);
    eval 'sub CT_PHASE_ERROR () {0x14;}' unless defined(&CT_PHASE_ERROR);
    eval 'sub CT_BDR_MSG () {0x17;}' unless defined(&CT_BDR_MSG);
    eval 'sub CT_DATA_UNDER () {0x15;}' unless defined(&CT_DATA_UNDER);
    eval 'sub CT_TERMINATED () {0x19;}' unless defined(&CT_TERMINATED);
    eval 'sub CT_PORTNOTAVAIL () {0x28;}' unless defined(&CT_PORTNOTAVAIL);
    eval 'sub CT_LOGOUT () {0x29;}' unless defined(&CT_LOGOUT);
    eval 'sub CT_PORTCHANGED () {0x2a;}' unless defined(&CT_PORTCHANGED);
    eval 'sub CT_IDE () {0x33;}' unless defined(&CT_IDE);
    eval 'sub CT_NOACK () {0x35;}' unless defined(&CT_NOACK);
    eval 'sub CTIO_SENSE_OFFSET () {0x2e;}' unless defined(&CTIO_SENSE_OFFSET);
    eval 'sub UINT32_ENTRY_SIZE () {($sizeof{ &at_entry_t}/$sizeof{ &u_int32_t});}' unless defined(&UINT32_ENTRY_SIZE);
    eval 'sub MAXRESPLEN () {26;}' unless defined(&MAXRESPLEN);
    eval 'sub ct_dataseg () { ($_u->{ct_a});}' unless defined(&ct_dataseg);
    eval 'sub ct_dataseg64 () { ($_u->{ct_b});}' unless defined(&ct_dataseg64);
    eval 'sub ct_dslist () { ($_u->{ct_c});}' unless defined(&ct_dslist);
    eval 'sub CT2_FLAG_MMASK () {0x3;}' unless defined(&CT2_FLAG_MMASK);
    eval 'sub CT2_FLAG_MODE0 () {0x;}' unless defined(&CT2_FLAG_MODE0);
    eval 'sub CT2_FLAG_MODE1 () {0x1;}' unless defined(&CT2_FLAG_MODE1);
    eval 'sub CT2_FLAG_MODE2 () {0x2;}' unless defined(&CT2_FLAG_MODE2);
    eval 'sub CT2_DATA_IN () { &CT_DATA_IN;}' unless defined(&CT2_DATA_IN);
    eval 'sub CT2_DATA_OUT () { &CT_DATA_OUT;}' unless defined(&CT2_DATA_OUT);
    eval 'sub CT2_NO_DATA () { &CT_NO_DATA;}' unless defined(&CT2_NO_DATA);
    eval 'sub CT2_DATAMASK () { &CT_DATAMASK;}' unless defined(&CT2_DATAMASK);
    eval 'sub CT2_CCINCR () {0x100;}' unless defined(&CT2_CCINCR);
    eval 'sub CT2_FASTPOST () {0x200;}' unless defined(&CT2_FASTPOST);
    eval 'sub CT2_SENDSTATUS () {0x8000;}' unless defined(&CT2_SENDSTATUS);
    eval 'sub CT2_RSPLEN_VALID () {0x100;}' unless defined(&CT2_RSPLEN_VALID);
    eval 'sub CT2_SNSLEN_VALID () {0x200;}' unless defined(&CT2_SNSLEN_VALID);
    eval 'sub CT2_DATA_OVER () {0x400;}' unless defined(&CT2_DATA_OVER);
    eval 'sub CT2_DATA_UNDER () {0x800;}' unless defined(&CT2_DATA_UNDER);
    eval 'sub ISP_TDQE {
        my($isp, $msg, $idx, $arg) = @_;
	    eval q( &if ( ($isp->{isp_dblev}) &  &ISP_LOGTDEBUG2)  &isp_print_qentry($isp, $msg, $idx, $arg));
    }' unless defined(&ISP_TDQE);
    if(defined(&ISP_TARGET_FUNCTIONS)) {
	eval 'sub DFLT_CMND_CNT () {0xfe;}' unless defined(&DFLT_CMND_CNT);
	eval 'sub DFLT_INOT_CNT () {16;}' unless defined(&DFLT_INOT_CNT);
	eval 'sub ECMD_SVALID () {0x100;}' unless defined(&ECMD_SVALID);
    }
}
1;
