_bus.h revision 145255
1/*- 2 * Copyright (c) 2005 M. Warner Losh. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions, and the following disclaimer, 10 * without modification, immediately at the beginning of the file. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD: head/sys/pc98/include/_bus.h 145255 2005-04-19 03:19:19Z imp $ 29 */ 30 31#ifndef PC98_INCLUDE__BUS_H 32#define PC98_INCLUDE__BUS_H 33 34/* 35 * Bus address and size types 36 */ 37typedef u_int bus_addr_t; 38typedef u_int bus_size_t; 39 40#define BUS_SPACE_IAT_MAXSIZE 33 41 42/* 43 * bus space tag 44 */ 45#define _PASCAL_CALL (void) 46 47#define _BUS_SPACE_CALL_FUNCS_TAB(NAME,TYPE,BWN) \ 48 NAME##_space_read_##BWN, \ 49 NAME##_space_read_multi_##BWN, \ 50 NAME##_space_read_region_##BWN, \ 51 NAME##_space_write_##BWN, \ 52 NAME##_space_write_multi_##BWN, \ 53 NAME##_space_write_region_##BWN, \ 54 NAME##_space_set_multi_##BWN, \ 55 NAME##_space_set_region_##BWN, \ 56 NAME##_space_copy_region_##BWN 57 58#define _BUS_SPACE_CALL_FUNCS_PROTO(NAME,TYPE,BWN) \ 59 TYPE NAME##_space_read_##BWN _PASCAL_CALL; \ 60 void NAME##_space_read_multi_##BWN _PASCAL_CALL; \ 61 void NAME##_space_read_region_##BWN _PASCAL_CALL; \ 62 void NAME##_space_write_##BWN _PASCAL_CALL; \ 63 void NAME##_space_write_multi_##BWN _PASCAL_CALL; \ 64 void NAME##_space_write_region_##BWN _PASCAL_CALL; \ 65 void NAME##_space_set_multi_##BWN _PASCAL_CALL; \ 66 void NAME##_space_set_region_##BWN _PASCAL_CALL; \ 67 void NAME##_space_copy_region_##BWN _PASCAL_CALL; 68 69#define _BUS_SPACE_CALL_FUNCS(NAME,TYPE,BWN) \ 70 TYPE (* NAME##_read_##BWN) _PASCAL_CALL; \ 71 void (* NAME##_read_multi_##BWN) _PASCAL_CALL; \ 72 void (* NAME##_read_region_##BWN) _PASCAL_CALL; \ 73 void (* NAME##_write_##BWN) _PASCAL_CALL; \ 74 void (* NAME##_write_multi_##BWN) _PASCAL_CALL; \ 75 void (* NAME##_write_region_##BWN) _PASCAL_CALL; \ 76 void (* NAME##_set_multi_##BWN) _PASCAL_CALL; \ 77 void (* NAME##_set_region_##BWN) _PASCAL_CALL; \ 78 void (* NAME##_copy_region_##BWN) _PASCAL_CALL; 79 80struct bus_space_access_methods { 81 /* 8 bits access methods */ 82 _BUS_SPACE_CALL_FUNCS(bs,u_int8_t,1) 83 84 /* 16 bits access methods */ 85 _BUS_SPACE_CALL_FUNCS(bs,u_int16_t,2) 86 87 /* 32 bits access methods */ 88 _BUS_SPACE_CALL_FUNCS(bs,u_int32_t,4) 89}; 90 91/* 92 * Access methods for bus resources and address space. 93 */ 94struct bus_space_tag { 95#define BUS_SPACE_IO 0 96#define BUS_SPACE_MEM 1 97 u_int bs_tag; /* bus space flags */ 98 99 struct bus_space_access_methods bs_da; /* direct access */ 100 struct bus_space_access_methods bs_ra; /* relocate access */ 101#if 0 102 struct bus_space_access_methods bs_ida; /* indexed direct access */ 103#endif 104}; 105typedef struct bus_space_tag *bus_space_tag_t; 106 107/* 108 * bus space handle 109 */ 110struct bus_space_handle { 111 bus_addr_t bsh_base; 112 size_t bsh_sz; 113 114 bus_addr_t bsh_iat[BUS_SPACE_IAT_MAXSIZE]; 115 size_t bsh_maxiatsz; 116 size_t bsh_iatsz; 117 118 struct resource **bsh_res; 119 size_t bsh_ressz; 120 121 struct bus_space_access_methods bsh_bam; 122}; 123typedef struct bus_space_handle *bus_space_handle_t; 124 125#endif /* PC98_INCLUDE__BUS_H */ 126