require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_MACHINE_BUS_H_)) {
    eval 'sub _MACHINE_BUS_H_ () {1;}' unless defined(&_MACHINE_BUS_H_);
    require 'machine/pio.ph';
    if(defined(&__STDC__)) {
	eval 'sub CAT {
	    my($a,$b) = @_;
    	    eval q($a$b);
	}' unless defined(&CAT);
	eval 'sub CAT3 {
	    my($a,$b,$c) = @_;
    	    eval q($a$b$c);
	}' unless defined(&CAT3);
    } else {
	eval 'sub CAT {
	    my($a,$b) = @_;
    	    eval q($a $b);
	}' unless defined(&CAT);
	eval 'sub CAT3 {
	    my($a,$b,$c) = @_;
    	    eval q($a $b $c);
	}' unless defined(&CAT3);
    }
    eval 'sub bus_space_read_1 {
        my($t, $h, $o) = @_;
	    eval q((*($t)-> &_space_read_1)(($t), ($h), ($o)));
    }' unless defined(&bus_space_read_1);
    eval 'sub bus_space_read_2 {
        my($t, $h, $o) = @_;
	    eval q((*($t)-> &_space_read_2)(($t), ($h), ($o)));
    }' unless defined(&bus_space_read_2);
    eval 'sub bus_space_read_4 {
        my($t, $h, $o) = @_;
	    eval q((*($t)-> &_space_read_4)(($t), ($h), ($o)));
    }' unless defined(&bus_space_read_4);
    eval 'sub bus_space_read_8 {
        my($t, $h, $o) = @_;
	    eval q((*($t)-> &_space_read_8)(($t), ($h), ($o)));
    }' unless defined(&bus_space_read_8);
    eval 'sub bus_space_write_1 {
        my($t, $h, $o, $v) = @_;
	    eval q((*($t)-> &_space_write_1)(($t), ($h), ($o), ($v)));
    }' unless defined(&bus_space_write_1);
    eval 'sub bus_space_write_2 {
        my($t, $h, $o, $v) = @_;
	    eval q((*($t)-> &_space_write_2)(($t), ($h), ($o), ($v)));
    }' unless defined(&bus_space_write_2);
    eval 'sub bus_space_write_4 {
        my($t, $h, $o, $v) = @_;
	    eval q((*($t)-> &_space_write_4)(($t), ($h), ($o), ($v)));
    }' unless defined(&bus_space_write_4);
    eval 'sub bus_space_write_8 {
        my($t, $h, $o, $v) = @_;
	    eval q((*($t)-> &_space_write_8)(($t), ($h), ($o), ($v)));
    }' unless defined(&bus_space_write_8);
    eval 'sub bus_space_map {
        my($t, $o, $s, $c, $p) = @_;
	    eval q((*($t)-> &_space_map)(($t), ($o), ($s), ($c), ($p)));
    }' unless defined(&bus_space_map);
    eval 'sub bus_space_unmap {
        my($t, $h, $s) = @_;
	    eval q((*($t)-> &_space_unmap)(($t), ($h), ($s)));
    }' unless defined(&bus_space_unmap);
    eval 'sub bus_space_subregion {
        my($t, $h, $o, $s, $p) = @_;
	    eval q((*($t)-> &_space_subregion)(($t), ($h), ($o), ($s), ($p)));
    }' unless defined(&bus_space_subregion);
    eval 'sub bus_space_read_multi {
        my($n,$m) = @_;
	    eval q( &static  &__inline  &void  &CAT( &bus_space_read_multi_,$n)( &bus_space_tag_t  &bst,  &bus_space_handle_t  &bsh,  &bus_size_t  &o,  &CAT3(\'u_int\',$m, &_t) * &x, \'size_t\'  &cnt) {  &while ( &cnt--) * &x++ =  &CAT( &bus_space_read_,$n)( &bst,  &bsh,  &o); });
    }' unless defined(&bus_space_read_multi);
    eval 'sub bus_space_read_multi_8 () {!!!  &bus_space_read_multi_8  &not  &implemented !!!;}' unless defined(&bus_space_read_multi_8);
    eval 'sub bus_space_read_region {
        my($n,$m) = @_;
	    eval q( &static  &__inline  &void  &CAT( &bus_space_read_region_,$n)( &bus_space_tag_t  &bst,  &bus_space_handle_t  &bsh,  &bus_addr_t  &ba,  &CAT3(\'u_int\',$m, &_t) * &x, \'size_t\'  &cnt) {  &while ( &cnt--) * &x++ =  &CAT( &bus_space_read_,$n)( &bst,  &bsh,  &ba++); });
    }' unless defined(&bus_space_read_region);
    eval 'sub bus_space_read_region_8 () {!!!  &bus_space_read_region_8  &not  &implemented !!!;}' unless defined(&bus_space_read_region_8);
    eval 'sub bus_space_write_multi {
        my($n,$m) = @_;
	    eval q( &static  &__inline  &void  &CAT( &bus_space_write_multi_,$n)( &bus_space_tag_t  &bst,  &bus_space_handle_t  &bsh,  &bus_size_t  &o,  &const  &CAT3(\'u_int\',$m, &_t) * &x, \'size_t\'  &cnt) {  &while ( &cnt--) {  &CAT( &bus_space_write_,$n)( &bst,  &bsh,  &o, * &x++); } });
    }' unless defined(&bus_space_write_multi);
    eval 'sub bus_space_write_multi_8 () {!!!  &bus_space_write_multi_8  &not  &implemented !!!;}' unless defined(&bus_space_write_multi_8);
    eval 'sub bus_space_write_region {
        my($n,$m) = @_;
	    eval q( &static  &__inline  &void  &CAT( &bus_space_write_region_,$n)( &bus_space_tag_t  &bst,  &bus_space_handle_t  &bsh,  &bus_addr_t  &ba,  &const  &CAT3(\'u_int\',$m, &_t) * &x, \'size_t\'  &cnt) {  &while ( &cnt--) {  &CAT( &bus_space_write_,$n)( &bst,  &bsh,  &ba, * &x++);  &ba += $sizeof{ &x}; } });
    }' unless defined(&bus_space_write_region);
    eval 'sub bus_space_write_region_8 () {!!!  &bus_space_write_region_8  &not  &implemented !!!;}' unless defined(&bus_space_write_region_8);
    eval 'sub bus_space_set_region {
        my($n,$m) = @_;
	    eval q( &static  &__inline  &void  &CAT( &bus_space_set_region_,$n)( &bus_space_tag_t  &bst,  &bus_space_handle_t  &bsh,  &bus_addr_t  &ba,  &CAT3(\'u_int\',$m, &_t)  &x, \'size_t\'  &cnt) {  &while ( &cnt--) {  &CAT( &bus_space_write_,$n)( &bst,  &bsh,  &ba,  &x);  &ba += $sizeof{ &x}; } });
    }' unless defined(&bus_space_set_region);
    eval 'sub bus_space_read_raw_multi {
        my($n,$m,$l) = @_;
	    eval q( &static  &__inline  &void  &CAT( &bus_space_read_raw_multi_,$n)( &bus_space_tag_t  &bst,  &bus_space_handle_t  &bsh,  &bus_addr_t  &ba,  &u_int8_t * &buf,  &bus_size_t  &cnt) {  &CAT( &bus_space_read_multi_,$n)( &bst,  &bsh,  &ba, ( &CAT3(\'u_int\',$m, &_t) *) &buf,  &cnt >> $l); });
    }' unless defined(&bus_space_read_raw_multi);
    eval 'sub bus_space_read_raw_multi_8 () {!!!  &bus_space_read_raw_multi_8  &not  &implemented !!!;}' unless defined(&bus_space_read_raw_multi_8);
    eval 'sub bus_space_write_raw_multi {
        my($n,$m,$l) = @_;
	    eval q( &static  &__inline  &void  &CAT( &bus_space_write_raw_multi_,$n)( &bus_space_tag_t  &bst,  &bus_space_handle_t  &bsh,  &bus_addr_t  &ba,  &const  &u_int8_t * &buf,  &bus_size_t  &cnt) {  &CAT( &bus_space_write_multi_,$n)( &bst,  &bsh,  &ba, ( &const  &CAT3(\'u_int\',$m, &_t) *) &buf,  &cnt >> $l); });
    }' unless defined(&bus_space_write_raw_multi);
    eval 'sub bus_space_write_raw_multi_8 () {!!!  &bus_space_write_raw_multi_8  &not  &implemented !!!;}' unless defined(&bus_space_write_raw_multi_8);
    eval 'sub bus_space_copy_2 {
        my($v,$h1,$o1,$h2,$o2,$c) = @_;
	    eval q({ \'short\' * &s = ($h1 + $o1); \'short\' * &d = ($h2 + $o2);  &while ($c--) * &d++ = * &s++; });
    }' unless defined(&bus_space_copy_2);
    eval 'sub bus_space_copy_4 {
        my($v,$h1,$o1,$h2,$o2,$c) = @_;
	    eval q({ \'int\' * &s = ($h1 + $o1); \'int\' * &d = ($h2 + $o2);  &while ($c--) * &d++ = * &s++; });
    }' unless defined(&bus_space_copy_4);
    eval 'sub bus_space_copy_8 () {!!!  &bus_space_write_raw_multi_8  &not  &implemented !!!;}' unless defined(&bus_space_copy_8);
    eval 'sub bus_space_barrier {
        my($t, $h, $o, $l, $f) = @_;
	    eval q((( &void)(( &void)($t), ( &void)($h), ( &void)($o), ( &void)($l), ( &void)($f))));
    }' unless defined(&bus_space_barrier);
    eval 'sub BUS_SPACE_BARRIER_READ () {0x1;}' unless defined(&BUS_SPACE_BARRIER_READ);
    eval 'sub BUS_SPACE_BARRIER_WRITE () {0x2;}' unless defined(&BUS_SPACE_BARRIER_WRITE);
    eval 'sub BUS_BARRIER_READ () { &BUS_SPACE_BARRIER_READ;}' unless defined(&BUS_BARRIER_READ);
    eval 'sub BUS_BARRIER_WRITE () { &BUS_SPACE_BARRIER_WRITE;}' unless defined(&BUS_BARRIER_WRITE);
    eval 'sub BUS_DMA_WAITOK () {0x;}' unless defined(&BUS_DMA_WAITOK);
    eval 'sub BUS_DMA_NOWAIT () {0x1;}' unless defined(&BUS_DMA_NOWAIT);
    eval 'sub BUS_DMA_ALLOCNOW () {0x2;}' unless defined(&BUS_DMA_ALLOCNOW);
    eval 'sub BUS_DMAMEM_NOSYNC () {0x4;}' unless defined(&BUS_DMAMEM_NOSYNC);
    eval 'sub BUS_DMA_COHERENT () {0x8;}' unless defined(&BUS_DMA_COHERENT);
    eval 'sub BUS_DMA_BUS1 () {0x10;}' unless defined(&BUS_DMA_BUS1);
    eval 'sub BUS_DMA_BUS2 () {0x20;}' unless defined(&BUS_DMA_BUS2);
    eval 'sub BUS_DMA_BUS3 () {0x40;}' unless defined(&BUS_DMA_BUS3);
    eval 'sub BUS_DMA_BUS4 () {0x80;}' unless defined(&BUS_DMA_BUS4);
    eval 'sub BUS_DMA_READ () {0x100;}' unless defined(&BUS_DMA_READ);
    eval 'sub BUS_DMA_WRITE () {0x200;}' unless defined(&BUS_DMA_WRITE);
    eval 'sub BUS_DMA_STREAMING () {0x400;}' unless defined(&BUS_DMA_STREAMING);
    eval 'sub BUS_DMASYNC_POSTREAD () {0x1;}' unless defined(&BUS_DMASYNC_POSTREAD);
    eval 'sub BUS_DMASYNC_POSTWRITE () {0x2;}' unless defined(&BUS_DMASYNC_POSTWRITE);
    eval 'sub BUS_DMASYNC_PREREAD () {0x4;}' unless defined(&BUS_DMASYNC_PREREAD);
    eval 'sub BUS_DMASYNC_PREWRITE () {0x8;}' unless defined(&BUS_DMASYNC_PREWRITE);
    eval 'sub bus_dmamap_create {
        my($t, $s, $n, $m, $b, $f, $p) = @_;
	    eval q((*($t)-> &_dmamap_create)(($t), ($s), ($n), ($m), ($b), ($f), ($p)));
    }' unless defined(&bus_dmamap_create);
    eval 'sub bus_dmamap_destroy {
        my($t, $p) = @_;
	    eval q((*($t)-> &_dmamap_destroy)(($t), ($p)));
    }' unless defined(&bus_dmamap_destroy);
    eval 'sub bus_dmamap_load {
        my($t, $m, $b, $s, $p, $f) = @_;
	    eval q((*($t)-> &_dmamap_load)(($t), ($m), ($b), ($s), ($p), ($f)));
    }' unless defined(&bus_dmamap_load);
    eval 'sub bus_dmamap_load_mbuf {
        my($t, $m, $b, $f) = @_;
	    eval q((*($t)-> &_dmamap_load_mbuf)(($t), ($m), ($b), ($f)));
    }' unless defined(&bus_dmamap_load_mbuf);
    eval 'sub bus_dmamap_load_uio {
        my($t, $m, $u, $f) = @_;
	    eval q((*($t)-> &_dmamap_load_uio)(($t), ($m), ($u), ($f)));
    }' unless defined(&bus_dmamap_load_uio);
    eval 'sub bus_dmamap_load_raw {
        my($t, $m, $sg, $n, $s, $f) = @_;
	    eval q((*($t)-> &_dmamap_load_raw)(($t), ($m), ($sg), ($n), ($s), ($f)));
    }' unless defined(&bus_dmamap_load_raw);
    eval 'sub bus_dmamap_unload {
        my($t, $p) = @_;
	    eval q((*($t)-> &_dmamap_unload)(($t), ($p)));
    }' unless defined(&bus_dmamap_unload);
    eval 'sub bus_dmamap_sync {
        my($t, $p, $a, $l, $o) = @_;
	    eval q(( &void)(($t)-> &_dmamap_sync ? (*($t)-> &_dmamap_sync)(($t), ($p), ($a), ($l), ($o)) : ( &void)0));
    }' unless defined(&bus_dmamap_sync);
    eval 'sub bus_dmamem_alloc {
        my($t, $s, $a, $b, $sg, $n, $r, $f) = @_;
	    eval q((*($t)-> &_dmamem_alloc)(($t), ($s), ($a), ($b), ($sg), ($n), ($r), ($f)));
    }' unless defined(&bus_dmamem_alloc);
    eval 'sub bus_dmamem_free {
        my($t, $sg, $n) = @_;
	    eval q((*($t)-> &_dmamem_free)(($t), ($sg), ($n)));
    }' unless defined(&bus_dmamem_free);
    eval 'sub bus_dmamem_map {
        my($t, $sg, $n, $s, $k, $f) = @_;
	    eval q((*($t)-> &_dmamem_map)(($t), ($sg), ($n), ($s), ($k), ($f)));
    }' unless defined(&bus_dmamem_map);
    eval 'sub bus_dmamem_unmap {
        my($t, $k, $s) = @_;
	    eval q((*($t)-> &_dmamem_unmap)(($t), ($k), ($s)));
    }' unless defined(&bus_dmamem_unmap);
    eval 'sub bus_dmamem_mmap {
        my($t, $sg, $n, $o, $p, $f) = @_;
	    eval q((*($t)-> &_dmamem_mmap)(($t), ($sg), ($n), ($o), ($p), ($f)));
    }' unless defined(&bus_dmamem_mmap);
}
1;
