require '_h2ph_pre.ph';

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 {
	    local($a,$b) = @_;
    	    eval q($a$b);
	}' unless defined(&CAT);
	eval 'sub CAT3 {
	    local($a,$b,$c) = @_;
    	    eval q($a$b$c);
	}' unless defined(&CAT3);
    } else {
	eval 'sub CAT {
	    local($a,$b) = @_;
    	    eval q($a $b);
	}' unless defined(&CAT);
	eval 'sub CAT3 {
	    local($a,$b,$c) = @_;
    	    eval q($a $b $c);
	}' unless defined(&CAT3);
    }
    eval 'sub POWERPC_BUS_TAG_BASE {
        local($x) = @_;
	    eval q((($x)-> &bus_base));
    }' unless defined(&POWERPC_BUS_TAG_BASE);
    eval 'sub bus_space_read {
        local($n,$m) = @_;
	    eval q( &static  &__inline  &CAT3(\'u_int\',$m, &_t)  &CAT( &bus_space_read_,$n)( &bus_space_tag_t  &bst,  &bus_space_handle_t  &bsh,  &bus_addr_t  &ba) {  &if( ($bst->{bus_reverse}))  &return  &CAT3( &in,$m, &rb)(( &volatile  &CAT3(\'u_int\',$m, &_t) *)( &bsh + ( &ba)));  &else  &return  &CAT( &in,$m)(( &volatile  &CAT3(\'u_int\',$m, &_t) *)( &bsh + ( &ba))); });
    }' unless defined(&bus_space_read);
    eval 'sub bus_space_read_8 () {!!!  &bus_space_read_8  &unimplemented !!!;}' unless defined(&bus_space_read_8);
    eval 'sub bus_space_write {
        local($n,$m) = @_;
	    eval q( &static  &__inline  &void  &CAT( &bus_space_write_,$n)( &bus_space_tag_t  &bst,  &bus_space_handle_t  &bsh,  &bus_addr_t  &ba,  &CAT3(\'u_int\',$m, &_t)  &x) {  &if( ($bst->{bus_reverse}))  &CAT3( &out,$m, &rb)(( &volatile  &CAT3(\'u_int\',$m, &_t) *)( &bsh + ( &ba)),  &x);  &else  &CAT( &out,$m)(( &volatile  &CAT3(\'u_int\',$m, &_t) *)( &bsh + ( &ba)),  &x); });
    }' unless defined(&bus_space_write);
    eval 'sub bus_space_write_8 () {!!!  &bus_space_write_8  &unimplemented !!!;}' unless defined(&bus_space_write_8);
    eval 'sub bus_space_read_multi {
        local($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  &ba,  &CAT3(\'u_int\',$m, &_t) * &buf,  &bus_size_t  &cnt) {  &while ( &cnt--) * &buf++ =  &CAT( &bus_space_read_,$n)( &bst,  &bsh,  &ba); });
    }' 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_write_multi_8 () {!!!  &bus_space_write_multi_8  &not  &implemented !!!;}' unless defined(&bus_space_write_multi_8);
    eval 'sub bus_space_write_multi {
        local($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  &ba,  &const  &CAT3(\'u_int\',$m, &_t) * &buf,  &bus_size_t  &cnt) {  &while ( &cnt--)  &CAT( &bus_space_write_,$n)( &bst,  &bsh,  &ba, * &buf++); });
    }' 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 __BA {
        local($t, $h, $o) = @_;
	    eval q(((($h) + ($o))));
    }' unless defined(&__BA);
    if(0) {
	eval 'sub bus_space_read_region_8 () {!!!  &unimplemented !!!;}' unless defined(&bus_space_read_region_8);
    }
    if(0) {
	eval 'sub bus_space_write_region_8 () {!!!  &bus_space_write_region_8  &unimplemented !!!;}' unless defined(&bus_space_write_region_8);
    }
    if(0) {
	eval 'sub bus_space_read_raw_region_8 () {!!!  &bus_space_read_raw_region_8  &unimplemented !!!;}' unless defined(&bus_space_read_raw_region_8);
    }
    if(0) {
	eval 'sub bus_space_write_raw_region_8 () {!!!  &bus_space_write_raw_region_8  &unimplemented !!!;}' unless defined(&bus_space_write_raw_region_8);
    }
    eval 'sub bus_space_set_multi_8 () {!!!  &bus_space_set_multi_8  &unimplemented !!!;}' unless defined(&bus_space_set_multi_8);
    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_8 () {!!!  &bus_space_write_raw_multi_8  &not  &implemented !!!;}' unless defined(&bus_space_write_raw_multi_8);
    eval 'sub bus_space_set_region_8 () {!!!  &bus_space_set_region_8  &not  &implemented !!!;}' unless defined(&bus_space_set_region_8);
    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 {
        local($t, $h, $o, $l, $f) = @_;
	    eval q(((, , , , ($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 {
        local($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 {
        local($t, $p) = @_;
	    eval q((*($t)-> &_dmamap_destroy)(($t), ($p)));
    }' unless defined(&bus_dmamap_destroy);
    eval 'sub bus_dmamap_load {
        local($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 {
        local($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 {
        local($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 {
        local($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 {
        local($t, $p) = @_;
	    eval q((*($t)-> &_dmamap_unload)(($t), ($p)));
    }' unless defined(&bus_dmamap_unload);
    eval 'sub bus_dmamap_sync {
        local($t, $p, $a, $l, $o) = @_;
	    eval q((-> &_dmamap_sync ? (*-> &_dmamap_sync)(, , , , ) : 0));
    }' unless defined(&bus_dmamap_sync);
    eval 'sub bus_dmamem_alloc {
        local($t, $s, $a, $b, $sg, $n, $r, $f) = @_;
	    eval q((*($t)-> &_dmamem_alloc)(($t)-> &_cookie, ($s), ($a), ($b), ($sg), ($n), ($r), ($f)));
    }' unless defined(&bus_dmamem_alloc);
    eval 'sub bus_dmamem_free {
        local($t, $sg, $n) = @_;
	    eval q((*($t)-> &_dmamem_free)(($t)-> &_cookie, ($sg), ($n)));
    }' unless defined(&bus_dmamem_free);
    eval 'sub bus_dmamem_map {
        local($t, $sg, $n, $s, $k, $f) = @_;
	    eval q((*($t)-> &_dmamem_map)(($t)-> &_cookie, ($sg), ($n), ($s), ($k), ($f)));
    }' unless defined(&bus_dmamem_map);
    eval 'sub bus_dmamem_unmap {
        local($t, $k, $s) = @_;
	    eval q((*($t)-> &_dmamem_unmap)(($t)-> &_cookie, ($k), ($s)));
    }' unless defined(&bus_dmamem_unmap);
    eval 'sub bus_dmamem_mmap {
        local($t, $sg, $n, $o, $p, $f) = @_;
	    eval q((*($t)-> &_dmamem_mmap)(($t)-> &_cookie, ($sg), ($n), ($o), ($p), ($f)));
    }' unless defined(&bus_dmamem_mmap);
}
1;
