require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&__SAVAGE_DRV_H__)) {
    eval 'sub __SAVAGE_DRV_H__ () {1;}' unless defined(&__SAVAGE_DRV_H__);
    eval 'sub DRIVER_AUTHOR () {"Felix Kuehling";}' unless defined(&DRIVER_AUTHOR);
    eval 'sub DRIVER_NAME () {"savage";}' unless defined(&DRIVER_NAME);
    eval 'sub DRIVER_DESC () {"Savage3D/MX/IX, Savage4, SuperSavage, Twister, ProSavage[DDR]";}' unless defined(&DRIVER_DESC);
    eval 'sub DRIVER_DATE () {"20050313";}' unless defined(&DRIVER_DATE);
    eval 'sub DRIVER_MAJOR () {2;}' unless defined(&DRIVER_MAJOR);
    eval 'sub DRIVER_MINOR () {4;}' unless defined(&DRIVER_MINOR);
    eval 'sub DRIVER_PATCHLEVEL () {1;}' unless defined(&DRIVER_PATCHLEVEL);
    eval 'sub SAVAGE_DMA_PAGE_SIZE () {1024;}' unless defined(&SAVAGE_DMA_PAGE_SIZE);
    eval 'sub SAVAGE_FAKE_DMA_SIZE () {( &SAVAGE_DMA_PAGE_SIZE*4*4);}' unless defined(&SAVAGE_FAKE_DMA_SIZE);
    eval("sub S3_UNKNOWN () { 0; }") unless defined(&S3_UNKNOWN);
    eval("sub S3_SAVAGE3D () { 1; }") unless defined(&S3_SAVAGE3D);
    eval("sub S3_SAVAGE_MX () { 2; }") unless defined(&S3_SAVAGE_MX);
    eval("sub S3_SAVAGE4 () { 3; }") unless defined(&S3_SAVAGE4);
    eval("sub S3_PROSAVAGE () { 4; }") unless defined(&S3_PROSAVAGE);
    eval("sub S3_TWISTER () { 5; }") unless defined(&S3_TWISTER);
    eval("sub S3_PROSAVAGEDDR () { 6; }") unless defined(&S3_PROSAVAGEDDR);
    eval("sub S3_SUPERSAVAGE () { 7; }") unless defined(&S3_SUPERSAVAGE);
    eval("sub S3_SAVAGE2000 () { 8; }") unless defined(&S3_SAVAGE2000);
    eval("sub S3_LAST () { 9; }") unless defined(&S3_LAST);
    eval 'sub S3_SAVAGE3D_SERIES {
        my($chip) = @_;
	    eval q((($chip>= &S3_SAVAGE3D)  && ($chip<= &S3_SAVAGE_MX)));
    }' unless defined(&S3_SAVAGE3D_SERIES);
    eval 'sub S3_SAVAGE4_SERIES {
        my($chip) = @_;
	    eval q((($chip== &S3_SAVAGE4) || ($chip== &S3_PROSAVAGE) || ($chip== &S3_TWISTER) || ($chip== &S3_PROSAVAGEDDR)));
    }' unless defined(&S3_SAVAGE4_SERIES);
    eval 'sub S3_SAVAGE_MOBILE_SERIES {
        my($chip) = @_;
	    eval q((($chip== &S3_SAVAGE_MX) || ($chip== &S3_SUPERSAVAGE)));
    }' unless defined(&S3_SAVAGE_MOBILE_SERIES);
    eval 'sub S3_SAVAGE_SERIES {
        my($chip) = @_;
	    eval q((($chip>= &S3_SAVAGE3D)  && ($chip<= &S3_SAVAGE2000)));
    }' unless defined(&S3_SAVAGE_SERIES);
    eval 'sub S3_MOBILE_TWISTER_SERIES {
        my($chip) = @_;
	    eval q((($chip== &S3_TWISTER) ||($chip== &S3_PROSAVAGEDDR)));
    }' unless defined(&S3_MOBILE_TWISTER_SERIES);
    eval 'sub SAVAGE_IS_AGP () {1;}' unless defined(&SAVAGE_IS_AGP);
    eval 'sub SAVAGE_FB_SIZE_S3 () {0x1000000;}' unless defined(&SAVAGE_FB_SIZE_S3);
    eval 'sub SAVAGE_FB_SIZE_S4 () {0x2000000;}' unless defined(&SAVAGE_FB_SIZE_S4);
    eval 'sub SAVAGE_MMIO_SIZE () {0x80000;}' unless defined(&SAVAGE_MMIO_SIZE);
    eval 'sub SAVAGE_APERTURE_OFFSET () {0x2000000;}' unless defined(&SAVAGE_APERTURE_OFFSET);
    eval 'sub SAVAGE_APERTURE_SIZE () {0x5000000;}' unless defined(&SAVAGE_APERTURE_SIZE);
    eval 'sub SAVAGE_BCI_OFFSET () {0x10000;}' unless defined(&SAVAGE_BCI_OFFSET);
    eval 'sub SAVAGE_BCI_FIFO_SIZE () {32;}' unless defined(&SAVAGE_BCI_FIFO_SIZE);
    eval 'sub SAVAGE_STATUS_WORD0 () {0x48c00;}' unless defined(&SAVAGE_STATUS_WORD0);
    eval 'sub SAVAGE_STATUS_WORD1 () {0x48c04;}' unless defined(&SAVAGE_STATUS_WORD1);
    eval 'sub SAVAGE_ALT_STATUS_WORD0 () {0x48c60;}' unless defined(&SAVAGE_ALT_STATUS_WORD0);
    eval 'sub SAVAGE_FIFO_USED_MASK_S3D () {0x1ffff;}' unless defined(&SAVAGE_FIFO_USED_MASK_S3D);
    eval 'sub SAVAGE_FIFO_USED_MASK_S4 () {0x1fffff;}' unless defined(&SAVAGE_FIFO_USED_MASK_S4);
    eval 'sub SAVAGE_BD_STRIDE_SHIFT () {0;}' unless defined(&SAVAGE_BD_STRIDE_SHIFT);
    eval 'sub SAVAGE_BD_BPP_SHIFT () {16;}' unless defined(&SAVAGE_BD_BPP_SHIFT);
    eval 'sub SAVAGE_BD_TILE_SHIFT () {24;}' unless defined(&SAVAGE_BD_TILE_SHIFT);
    eval 'sub SAVAGE_BD_BW_DISABLE () {(1<<28);}' unless defined(&SAVAGE_BD_BW_DISABLE);
    eval 'sub SAVAGE_BD_TILE_LINEAR () {0;}' unless defined(&SAVAGE_BD_TILE_LINEAR);
    eval 'sub SAVAGE_BD_TILE_16BPP () {2;}' unless defined(&SAVAGE_BD_TILE_16BPP);
    eval 'sub SAVAGE_BD_TILE_32BPP () {3;}' unless defined(&SAVAGE_BD_TILE_32BPP);
    eval 'sub SAVAGE_BD_TILE_DEST () {1;}' unless defined(&SAVAGE_BD_TILE_DEST);
    eval 'sub SAVAGE_BD_TILE_TEXTURE () {2;}' unless defined(&SAVAGE_BD_TILE_TEXTURE);
    eval 'sub SAVAGE_GBD_BCI_ENABLE () {8;}' unless defined(&SAVAGE_GBD_BCI_ENABLE);
    eval 'sub SAVAGE_GBD_BCI_ENABLE_TWISTER () {0;}' unless defined(&SAVAGE_GBD_BCI_ENABLE_TWISTER);
    eval 'sub SAVAGE_GBD_BIG_ENDIAN () {4;}' unless defined(&SAVAGE_GBD_BIG_ENDIAN);
    eval 'sub SAVAGE_GBD_LITTLE_ENDIAN () {0;}' unless defined(&SAVAGE_GBD_LITTLE_ENDIAN);
    eval 'sub SAVAGE_GBD_64 () {1;}' unless defined(&SAVAGE_GBD_64);
    eval 'sub SAVAGE_BCI_GLB_BD_LOW () {0x8168;}' unless defined(&SAVAGE_BCI_GLB_BD_LOW);
    eval 'sub SAVAGE_BCI_GLB_BD_HIGH () {0x816c;}' unless defined(&SAVAGE_BCI_GLB_BD_HIGH);
    eval 'sub SAVAGE_DRAWLOCALCTRL_S4 () {0x1e;}' unless defined(&SAVAGE_DRAWLOCALCTRL_S4);
    eval 'sub SAVAGE_TEXPALADDR_S4 () {0x1f;}' unless defined(&SAVAGE_TEXPALADDR_S4);
    eval 'sub SAVAGE_TEXCTRL0_S4 () {0x20;}' unless defined(&SAVAGE_TEXCTRL0_S4);
    eval 'sub SAVAGE_TEXCTRL1_S4 () {0x21;}' unless defined(&SAVAGE_TEXCTRL1_S4);
    eval 'sub SAVAGE_TEXADDR0_S4 () {0x22;}' unless defined(&SAVAGE_TEXADDR0_S4);
    eval 'sub SAVAGE_TEXADDR1_S4 () {0x23;}' unless defined(&SAVAGE_TEXADDR1_S4);
    eval 'sub SAVAGE_TEXBLEND0_S4 () {0x24;}' unless defined(&SAVAGE_TEXBLEND0_S4);
    eval 'sub SAVAGE_TEXBLEND1_S4 () {0x25;}' unless defined(&SAVAGE_TEXBLEND1_S4);
    eval 'sub SAVAGE_TEXXPRCLR_S4 () {0x26;}' unless defined(&SAVAGE_TEXXPRCLR_S4);
    eval 'sub SAVAGE_TEXDESCR_S4 () {0x27;}' unless defined(&SAVAGE_TEXDESCR_S4);
    eval 'sub SAVAGE_FOGTABLE_S4 () {0x28;}' unless defined(&SAVAGE_FOGTABLE_S4);
    eval 'sub SAVAGE_FOGCTRL_S4 () {0x30;}' unless defined(&SAVAGE_FOGCTRL_S4);
    eval 'sub SAVAGE_STENCILCTRL_S4 () {0x31;}' unless defined(&SAVAGE_STENCILCTRL_S4);
    eval 'sub SAVAGE_ZBUFCTRL_S4 () {0x32;}' unless defined(&SAVAGE_ZBUFCTRL_S4);
    eval 'sub SAVAGE_ZBUFOFF_S4 () {0x33;}' unless defined(&SAVAGE_ZBUFOFF_S4);
    eval 'sub SAVAGE_DESTCTRL_S4 () {0x34;}' unless defined(&SAVAGE_DESTCTRL_S4);
    eval 'sub SAVAGE_DRAWCTRL0_S4 () {0x35;}' unless defined(&SAVAGE_DRAWCTRL0_S4);
    eval 'sub SAVAGE_DRAWCTRL1_S4 () {0x36;}' unless defined(&SAVAGE_DRAWCTRL1_S4);
    eval 'sub SAVAGE_ZWATERMARK_S4 () {0x37;}' unless defined(&SAVAGE_ZWATERMARK_S4);
    eval 'sub SAVAGE_DESTTEXRWWATERMARK_S4 () {0x38;}' unless defined(&SAVAGE_DESTTEXRWWATERMARK_S4);
    eval 'sub SAVAGE_TEXBLENDCOLOR_S4 () {0x39;}' unless defined(&SAVAGE_TEXBLENDCOLOR_S4);
    eval 'sub SAVAGE_TEXPALADDR_S3D () {0x18;}' unless defined(&SAVAGE_TEXPALADDR_S3D);
    eval 'sub SAVAGE_TEXXPRCLR_S3D () {0x19;}' unless defined(&SAVAGE_TEXXPRCLR_S3D);
    eval 'sub SAVAGE_TEXADDR_S3D () {0x1a;}' unless defined(&SAVAGE_TEXADDR_S3D);
    eval 'sub SAVAGE_TEXDESCR_S3D () {0x1b;}' unless defined(&SAVAGE_TEXDESCR_S3D);
    eval 'sub SAVAGE_TEXCTRL_S3D () {0x1c;}' unless defined(&SAVAGE_TEXCTRL_S3D);
    eval 'sub SAVAGE_FOGTABLE_S3D () {0x20;}' unless defined(&SAVAGE_FOGTABLE_S3D);
    eval 'sub SAVAGE_FOGCTRL_S3D () {0x30;}' unless defined(&SAVAGE_FOGCTRL_S3D);
    eval 'sub SAVAGE_DRAWCTRL_S3D () {0x31;}' unless defined(&SAVAGE_DRAWCTRL_S3D);
    eval 'sub SAVAGE_ZBUFCTRL_S3D () {0x32;}' unless defined(&SAVAGE_ZBUFCTRL_S3D);
    eval 'sub SAVAGE_ZBUFOFF_S3D () {0x33;}' unless defined(&SAVAGE_ZBUFOFF_S3D);
    eval 'sub SAVAGE_DESTCTRL_S3D () {0x34;}' unless defined(&SAVAGE_DESTCTRL_S3D);
    eval 'sub SAVAGE_SCSTART_S3D () {0x35;}' unless defined(&SAVAGE_SCSTART_S3D);
    eval 'sub SAVAGE_SCEND_S3D () {0x36;}' unless defined(&SAVAGE_SCEND_S3D);
    eval 'sub SAVAGE_ZWATERMARK_S3D () {0x37;}' unless defined(&SAVAGE_ZWATERMARK_S3D);
    eval 'sub SAVAGE_DESTTEXRWWATERMARK_S3D () {0x38;}' unless defined(&SAVAGE_DESTTEXRWWATERMARK_S3D);
    eval 'sub SAVAGE_VERTBUFADDR () {0x3e;}' unless defined(&SAVAGE_VERTBUFADDR);
    eval 'sub SAVAGE_BITPLANEWTMASK () {0xd7;}' unless defined(&SAVAGE_BITPLANEWTMASK);
    eval 'sub SAVAGE_DMABUFADDR () {0x51;}' unless defined(&SAVAGE_DMABUFADDR);
    eval 'sub SAVAGE_TEXCTRL_TEXEN_MASK () {0x10000;}' unless defined(&SAVAGE_TEXCTRL_TEXEN_MASK);
    eval 'sub SAVAGE_TEXDESCR_TEX0EN_MASK () {0x2000000;}' unless defined(&SAVAGE_TEXDESCR_TEX0EN_MASK);
    eval 'sub SAVAGE_TEXDESCR_TEX1EN_MASK () {0x4000000;}' unless defined(&SAVAGE_TEXDESCR_TEX1EN_MASK);
    eval 'sub SAVAGE_DRAWCTRL_S3D_GLOBAL () {0x3f3c00c;}' unless defined(&SAVAGE_DRAWCTRL_S3D_GLOBAL);
    eval 'sub SAVAGE_ZBUFCTRL_S3D_GLOBAL () {0x27;}' unless defined(&SAVAGE_ZBUFCTRL_S3D_GLOBAL);
    eval 'sub SAVAGE_SCISSOR_MASK_S4 () {0xfff7ff;}' unless defined(&SAVAGE_SCISSOR_MASK_S4);
    eval 'sub SAVAGE_SCISSOR_MASK_S3D () {0x7ff07ff;}' unless defined(&SAVAGE_SCISSOR_MASK_S3D);
    eval 'sub BCI_CMD_NOP () {0x40000000;}' unless defined(&BCI_CMD_NOP);
    eval 'sub BCI_CMD_RECT () {0x48000000;}' unless defined(&BCI_CMD_RECT);
    eval 'sub BCI_CMD_RECT_XP () {0x1000000;}' unless defined(&BCI_CMD_RECT_XP);
    eval 'sub BCI_CMD_RECT_YP () {0x2000000;}' unless defined(&BCI_CMD_RECT_YP);
    eval 'sub BCI_CMD_SCANLINE () {0x50000000;}' unless defined(&BCI_CMD_SCANLINE);
    eval 'sub BCI_CMD_LINE () {0x5c000000;}' unless defined(&BCI_CMD_LINE);
    eval 'sub BCI_CMD_LINE_LAST_PIXEL () {0x58000000;}' unless defined(&BCI_CMD_LINE_LAST_PIXEL);
    eval 'sub BCI_CMD_BYTE_TEXT () {0x63000000;}' unless defined(&BCI_CMD_BYTE_TEXT);
    eval 'sub BCI_CMD_NT_BYTE_TEXT () {0x67000000;}' unless defined(&BCI_CMD_NT_BYTE_TEXT);
    eval 'sub BCI_CMD_BIT_TEXT () {0x6c000000;}' unless defined(&BCI_CMD_BIT_TEXT);
    eval 'sub BCI_CMD_GET_ROP {
        my($cmd) = @_;
	    eval q(((($cmd) >> 16) & 0xff));
    }' unless defined(&BCI_CMD_GET_ROP);
    eval 'sub BCI_CMD_SET_ROP {
        my($cmd, $rop) = @_;
	    eval q((($cmd) |= (($rop & 0xff) << 16)));
    }' unless defined(&BCI_CMD_SET_ROP);
    eval 'sub BCI_CMD_SEND_COLOR () {0x8000;}' unless defined(&BCI_CMD_SEND_COLOR);
    eval 'sub BCI_CMD_CLIP_NONE () {0x;}' unless defined(&BCI_CMD_CLIP_NONE);
    eval 'sub BCI_CMD_CLIP_CURRENT () {0x2000;}' unless defined(&BCI_CMD_CLIP_CURRENT);
    eval 'sub BCI_CMD_CLIP_LR () {0x4000;}' unless defined(&BCI_CMD_CLIP_LR);
    eval 'sub BCI_CMD_CLIP_NEW () {0x6000;}' unless defined(&BCI_CMD_CLIP_NEW);
    eval 'sub BCI_CMD_DEST_GBD () {0x;}' unless defined(&BCI_CMD_DEST_GBD);
    eval 'sub BCI_CMD_DEST_PBD () {0x800;}' unless defined(&BCI_CMD_DEST_PBD);
    eval 'sub BCI_CMD_DEST_PBD_NEW () {0xc00;}' unless defined(&BCI_CMD_DEST_PBD_NEW);
    eval 'sub BCI_CMD_DEST_SBD () {0x1000;}' unless defined(&BCI_CMD_DEST_SBD);
    eval 'sub BCI_CMD_DEST_SBD_NEW () {0x1400;}' unless defined(&BCI_CMD_DEST_SBD_NEW);
    eval 'sub BCI_CMD_SRC_TRANSPARENT () {0x200;}' unless defined(&BCI_CMD_SRC_TRANSPARENT);
    eval 'sub BCI_CMD_SRC_SOLID () {0x;}' unless defined(&BCI_CMD_SRC_SOLID);
    eval 'sub BCI_CMD_SRC_GBD () {0x20;}' unless defined(&BCI_CMD_SRC_GBD);
    eval 'sub BCI_CMD_SRC_COLOR () {0x40;}' unless defined(&BCI_CMD_SRC_COLOR);
    eval 'sub BCI_CMD_SRC_MONO () {0x60;}' unless defined(&BCI_CMD_SRC_MONO);
    eval 'sub BCI_CMD_SRC_PBD_COLOR () {0x80;}' unless defined(&BCI_CMD_SRC_PBD_COLOR);
    eval 'sub BCI_CMD_SRC_PBD_MONO () {0xa0;}' unless defined(&BCI_CMD_SRC_PBD_MONO);
    eval 'sub BCI_CMD_SRC_PBD_COLOR_NEW () {0xc0;}' unless defined(&BCI_CMD_SRC_PBD_COLOR_NEW);
    eval 'sub BCI_CMD_SRC_PBD_MONO_NEW () {0xe0;}' unless defined(&BCI_CMD_SRC_PBD_MONO_NEW);
    eval 'sub BCI_CMD_SRC_SBD_COLOR () {0x100;}' unless defined(&BCI_CMD_SRC_SBD_COLOR);
    eval 'sub BCI_CMD_SRC_SBD_MONO () {0x120;}' unless defined(&BCI_CMD_SRC_SBD_MONO);
    eval 'sub BCI_CMD_SRC_SBD_COLOR_NEW () {0x140;}' unless defined(&BCI_CMD_SRC_SBD_COLOR_NEW);
    eval 'sub BCI_CMD_SRC_SBD_MONO_NEW () {0x160;}' unless defined(&BCI_CMD_SRC_SBD_MONO_NEW);
    eval 'sub BCI_CMD_PAT_TRANSPARENT () {0x10;}' unless defined(&BCI_CMD_PAT_TRANSPARENT);
    eval 'sub BCI_CMD_PAT_NONE () {0x;}' unless defined(&BCI_CMD_PAT_NONE);
    eval 'sub BCI_CMD_PAT_COLOR () {0x2;}' unless defined(&BCI_CMD_PAT_COLOR);
    eval 'sub BCI_CMD_PAT_MONO () {0x3;}' unless defined(&BCI_CMD_PAT_MONO);
    eval 'sub BCI_CMD_PAT_PBD_COLOR () {0x4;}' unless defined(&BCI_CMD_PAT_PBD_COLOR);
    eval 'sub BCI_CMD_PAT_PBD_MONO () {0x5;}' unless defined(&BCI_CMD_PAT_PBD_MONO);
    eval 'sub BCI_CMD_PAT_PBD_COLOR_NEW () {0x6;}' unless defined(&BCI_CMD_PAT_PBD_COLOR_NEW);
    eval 'sub BCI_CMD_PAT_PBD_MONO_NEW () {0x7;}' unless defined(&BCI_CMD_PAT_PBD_MONO_NEW);
    eval 'sub BCI_CMD_PAT_SBD_COLOR () {0x8;}' unless defined(&BCI_CMD_PAT_SBD_COLOR);
    eval 'sub BCI_CMD_PAT_SBD_MONO () {0x9;}' unless defined(&BCI_CMD_PAT_SBD_MONO);
    eval 'sub BCI_CMD_PAT_SBD_COLOR_NEW () {0xa;}' unless defined(&BCI_CMD_PAT_SBD_COLOR_NEW);
    eval 'sub BCI_CMD_PAT_SBD_MONO_NEW () {0xb;}' unless defined(&BCI_CMD_PAT_SBD_MONO_NEW);
    eval 'sub BCI_BD_BW_DISABLE () {0x10000000;}' unless defined(&BCI_BD_BW_DISABLE);
    eval 'sub BCI_BD_TILE_MASK () {0x3000000;}' unless defined(&BCI_BD_TILE_MASK);
    eval 'sub BCI_BD_TILE_NONE () {0x;}' unless defined(&BCI_BD_TILE_NONE);
    eval 'sub BCI_BD_TILE_16 () {0x2000000;}' unless defined(&BCI_BD_TILE_16);
    eval 'sub BCI_BD_TILE_32 () {0x3000000;}' unless defined(&BCI_BD_TILE_32);
    eval 'sub BCI_BD_GET_BPP {
        my($bd) = @_;
	    eval q(((($bd) >> 16) & 0xff));
    }' unless defined(&BCI_BD_GET_BPP);
    eval 'sub BCI_BD_SET_BPP {
        my($bd, $bpp) = @_;
	    eval q((($bd) |= ((($bpp) & 0xff) << 16)));
    }' unless defined(&BCI_BD_SET_BPP);
    eval 'sub BCI_BD_GET_STRIDE {
        my($bd) = @_;
	    eval q((($bd) & 0xffff));
    }' unless defined(&BCI_BD_GET_STRIDE);
    eval 'sub BCI_BD_SET_STRIDE {
        my($bd, $st) = @_;
	    eval q((($bd) |= (($st) & 0xffff)));
    }' unless defined(&BCI_BD_SET_STRIDE);
    eval 'sub BCI_CMD_SET_REGISTER () {0x96000000;}' unless defined(&BCI_CMD_SET_REGISTER);
    eval 'sub BCI_CMD_WAIT () {0xc0000000;}' unless defined(&BCI_CMD_WAIT);
    eval 'sub BCI_CMD_WAIT_3D () {0x10000;}' unless defined(&BCI_CMD_WAIT_3D);
    eval 'sub BCI_CMD_WAIT_2D () {0x20000;}' unless defined(&BCI_CMD_WAIT_2D);
    eval 'sub BCI_CMD_UPDATE_EVENT_TAG () {0x98000000;}' unless defined(&BCI_CMD_UPDATE_EVENT_TAG);
    eval 'sub BCI_CMD_DRAW_PRIM () {0x80000000;}' unless defined(&BCI_CMD_DRAW_PRIM);
    eval 'sub BCI_CMD_DRAW_INDEXED_PRIM () {0x88000000;}' unless defined(&BCI_CMD_DRAW_INDEXED_PRIM);
    eval 'sub BCI_CMD_DRAW_CONT () {0x1000000;}' unless defined(&BCI_CMD_DRAW_CONT);
    eval 'sub BCI_CMD_DRAW_TRILIST () {0x;}' unless defined(&BCI_CMD_DRAW_TRILIST);
    eval 'sub BCI_CMD_DRAW_TRISTRIP () {0x2000000;}' unless defined(&BCI_CMD_DRAW_TRISTRIP);
    eval 'sub BCI_CMD_DRAW_TRIFAN () {0x4000000;}' unless defined(&BCI_CMD_DRAW_TRIFAN);
    eval 'sub BCI_CMD_DRAW_SKIPFLAGS () {0xff;}' unless defined(&BCI_CMD_DRAW_SKIPFLAGS);
    eval 'sub BCI_CMD_DRAW_NO_Z () {0x1;}' unless defined(&BCI_CMD_DRAW_NO_Z);
    eval 'sub BCI_CMD_DRAW_NO_W () {0x2;}' unless defined(&BCI_CMD_DRAW_NO_W);
    eval 'sub BCI_CMD_DRAW_NO_CD () {0x4;}' unless defined(&BCI_CMD_DRAW_NO_CD);
    eval 'sub BCI_CMD_DRAW_NO_CS () {0x8;}' unless defined(&BCI_CMD_DRAW_NO_CS);
    eval 'sub BCI_CMD_DRAW_NO_U0 () {0x10;}' unless defined(&BCI_CMD_DRAW_NO_U0);
    eval 'sub BCI_CMD_DRAW_NO_V0 () {0x20;}' unless defined(&BCI_CMD_DRAW_NO_V0);
    eval 'sub BCI_CMD_DRAW_NO_UV0 () {0x30;}' unless defined(&BCI_CMD_DRAW_NO_UV0);
    eval 'sub BCI_CMD_DRAW_NO_U1 () {0x40;}' unless defined(&BCI_CMD_DRAW_NO_U1);
    eval 'sub BCI_CMD_DRAW_NO_V1 () {0x80;}' unless defined(&BCI_CMD_DRAW_NO_V1);
    eval 'sub BCI_CMD_DRAW_NO_UV1 () {0xc0;}' unless defined(&BCI_CMD_DRAW_NO_UV1);
    eval 'sub BCI_CMD_DMA () {0xa8000000;}' unless defined(&BCI_CMD_DMA);
    eval 'sub BCI_W_H {
        my($w, $h) = @_;
	    eval q((((($h) << 16) | ($w)) & 0xfff0fff));
    }' unless defined(&BCI_W_H);
    eval 'sub BCI_X_Y {
        my($x, $y) = @_;
	    eval q((((($y) << 16) | ($x)) & 0xfff0fff));
    }' unless defined(&BCI_X_Y);
    eval 'sub BCI_X_W {
        my($x, $y) = @_;
	    eval q((((( &w) << 16) | ($x)) & 0xfff0fff));
    }' unless defined(&BCI_X_W);
    eval 'sub BCI_CLIP_LR {
        my($l, $r) = @_;
	    eval q((((($r) << 16) | ($l)) & 0xfff0fff));
    }' unless defined(&BCI_CLIP_LR);
    eval 'sub BCI_CLIP_TL {
        my($t, $l) = @_;
	    eval q((((($t) << 16) | ($l)) & 0xfff0fff));
    }' unless defined(&BCI_CLIP_TL);
    eval 'sub BCI_CLIP_BR {
        my($b, $r) = @_;
	    eval q((((($b) << 16) | ($r)) & 0xfff0fff));
    }' unless defined(&BCI_CLIP_BR);
    eval 'sub BCI_LINE_X_Y {
        my($x, $y) = @_;
	    eval q(((($y) << 16) | (($x) & 0xffff)));
    }' unless defined(&BCI_LINE_X_Y);
    eval 'sub BCI_LINE_STEPS {
        my($diag, $axi) = @_;
	    eval q(((($axi) << 16) | (($diag) & 0xffff)));
    }' unless defined(&BCI_LINE_STEPS);
    eval 'sub BCI_LINE_MISC {
        my($maj, $ym, $xp, $yp, $err) = @_;
	    eval q(((($maj) & 0x1fff) | (($ym) ? 1<<13: 0) | (($xp) ? 1<<14: 0) | (($yp) ? 1<<15: 0) | (($err) << 16)));
    }' unless defined(&BCI_LINE_MISC);
    eval 'sub BCI_SET_REGISTERS {
        my( $first, $n ) = @_;
	    eval q( &BCI_WRITE( &BCI_CMD_SET_REGISTER | (( &uint32_t)( &n) & 0xff) << 16| (( &uint32_t)($first) & 0xffff)));
    }' unless defined(&BCI_SET_REGISTERS);
    eval 'sub DMA_SET_REGISTERS {
        my( $first, $n ) = @_;
	    eval q( &DMA_WRITE( &BCI_CMD_SET_REGISTER | (( &uint32_t)( &n) & 0xff) << 16| (( &uint32_t)($first) & 0xffff)));
    }' unless defined(&DMA_SET_REGISTERS);
    eval 'sub BCI_DRAW_PRIMITIVE {
        my($n, $type, $skip) = @_;
	    eval q( &BCI_WRITE( &BCI_CMD_DRAW_PRIM | ($type) | ($skip) | (($n) << 16)));
    }' unless defined(&BCI_DRAW_PRIMITIVE);
    eval 'sub DMA_DRAW_PRIMITIVE {
        my($n, $type, $skip) = @_;
	    eval q( &DMA_WRITE( &BCI_CMD_DRAW_PRIM | ($type) | ($skip) | (($n) << 16)));
    }' unless defined(&DMA_DRAW_PRIMITIVE);
    eval 'sub BCI_DRAW_INDICES_S3D {
        my($n, $type, $i0) = @_;
	    eval q( &BCI_WRITE( &BCI_CMD_DRAW_INDEXED_PRIM | ($type) | (($n) << 16) | ($i0)));
    }' unless defined(&BCI_DRAW_INDICES_S3D);
    eval 'sub BCI_DRAW_INDICES_S4 {
        my($n, $type, $skip) = @_;
	    eval q( &BCI_WRITE( &BCI_CMD_DRAW_INDEXED_PRIM | ($type) | ($skip) | (($n) << 16)));
    }' unless defined(&BCI_DRAW_INDICES_S4);
    eval 'sub BCI_DMA {
        my($n) = @_;
	    eval q( &BCI_WRITE( &BCI_CMD_DMA | ((($n) >> 1) - 1)));
    }' unless defined(&BCI_DMA);
    eval 'sub SAVAGE_READ {
        my($reg) = @_;
	    eval q( &DRM_READ32(  ($dev_priv->{mmio}), ($reg) ));
    }' unless defined(&SAVAGE_READ);
    eval 'sub SAVAGE_WRITE {
        my($reg) = @_;
	    eval q( &DRM_WRITE32(  ($dev_priv->{mmio}), ($reg) ));
    }' unless defined(&SAVAGE_WRITE);
    eval 'sub SAVAGE_BCI_DEBUG () {1;}' unless defined(&SAVAGE_BCI_DEBUG);
    eval 'sub BCI_LOCALS () { &volatile  &uint32_t * &bci_ptr;;}' unless defined(&BCI_LOCALS);
    eval 'sub BEGIN_BCI {
        my( $n ) = @_;
	    eval q( &do {  ($dev_priv->{wait_fifo})( &dev_priv, ( &n));  &bci_ptr =  ($dev_priv->{bci_ptr}); }  &while(0));
    }' unless defined(&BEGIN_BCI);
    eval 'sub BCI_WRITE {
        my( $val ) = @_;
	    eval q(* &bci_ptr++ = ( &uint32_t)($val));
    }' unless defined(&BCI_WRITE);
    eval 'sub SAVAGE_DMA_DEBUG () {1;}' unless defined(&SAVAGE_DMA_DEBUG);
    eval 'sub DMA_LOCALS () { &uint32_t * &dma_ptr;;}' unless defined(&DMA_LOCALS);
    eval 'sub BEGIN_DMA {
        my( $n ) = @_;
	    eval q( &do { \'unsigned int cur\' =  ($dev_priv->{current_dma_page}); \'unsigned int rest\' =  &SAVAGE_DMA_PAGE_SIZE -  ($dev_priv->{dma_pages[&cur]}->{used});  &if (( &n) >  &rest) {  &dma_ptr =  &savage_dma_alloc( &dev_priv, ( &n)); }  &else {  &dma_ptr = ( &uint32_t *) ($dev_priv->{cmd_dma}->{handle}) +  &cur *  &SAVAGE_DMA_PAGE_SIZE +  ($dev_priv->{dma_pages[&cur]}->{used});  &if ( ($dev_priv->{dma_pages[&cur]}->{used}) == 0)  &savage_dma_wait( &dev_priv,  &cur);  ($dev_priv->{dma_pages[&cur]}->{used}) += ( &n); } }  &while(0));
    }' unless defined(&BEGIN_DMA);
    eval 'sub DMA_WRITE {
        my( $val ) = @_;
	    eval q(* &dma_ptr++ = ( &uint32_t)($val));
    }' unless defined(&DMA_WRITE);
    eval 'sub DMA_COPY {
        my($src, $n) = @_;
	    eval q( &do {  &memcpy( &dma_ptr, ($src), ($n)*4);  &dma_ptr += $n; }  &while(0));
    }' unless defined(&DMA_COPY);
    if((defined(&SAVAGE_DMA_DEBUG) ? &SAVAGE_DMA_DEBUG : 0)) {
	eval 'sub DMA_COMMIT () {
	    eval q( &do { \'unsigned int cur\' =  ($dev_priv->{current_dma_page});  &uint32_t * &expected = ( &uint32_t *) ($dev_priv->{cmd_dma}->{handle}) +  &cur *  &SAVAGE_DMA_PAGE_SIZE +  ($dev_priv->{dma_pages[&cur]}->{used});  &if ( &dma_ptr !=  &expected) {  &DRM_ERROR(\\"DMA allocation and use don\'t match: \\" \\"%p != %p\\\\n\\",  &expected,  &dma_ptr);  &savage_dma_reset( &dev_priv); } }  &while(0));
	}' unless defined(&DMA_COMMIT);
    } else {
	eval 'sub DMA_COMMIT () {
	    eval q( &do { }  &while(0));
	}' unless defined(&DMA_COMMIT);
    }
    eval 'sub DMA_FLUSH () {
        eval q( ($dev_priv->{dma_flush})( &dev_priv));
    }' unless defined(&DMA_FLUSH);
    eval 'sub UPDATE_EVENT_COUNTER {
        my( ) = @_;
	    eval q( &do {  &if ( ($dev_priv->{status_ptr})) {  &uint16_t  &count;  &count =  ($dev_priv->{status_ptr[1023]});  &if ( &count <  ($dev_priv->{event_counter}))  ($dev_priv->{event_wrap})++;  ($dev_priv->{event_counter}) =  &count; } }  &while(0));
    }' unless defined(&UPDATE_EVENT_COUNTER);
    eval 'sub SET_AGE {
        my( $age, $e, $w ) = @_;
	    eval q( &do { ($age)-> &event = $e; ($age)-> &wrap =  &w; }  &while(0));
    }' unless defined(&SET_AGE);
    eval 'sub TEST_AGE {
        my( $age, $e, $w ) = @_;
	    eval q(( ($age)-> &wrap < ( &w) || ( ($age)-> &wrap == ( &w)  && ($age)-> &event <= ($e) ) ));
    }' unless defined(&TEST_AGE);
}
1;
