1/* 2 * Copyright (c) 2003 3 * Bill Paul <wpaul@windriver.com>. 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 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by Bill Paul. 16 * 4. Neither the name of the author nor the names of any co-contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h>
| 1/* 2 * Copyright (c) 2003 3 * Bill Paul <wpaul@windriver.com>. 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 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by Bill Paul. 16 * 4. Neither the name of the author nor the names of any co-contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h>
|
63#define FUNC void(*)(void) 64 65__stdcall static void hal_stall_exec_cpu(uint32_t); 66__stdcall static void hal_writeport_buf_ulong(uint32_t *, 67 uint32_t *, uint32_t); 68__stdcall static void hal_writeport_buf_ushort(uint16_t *, 69 uint16_t *, uint32_t); 70__stdcall static void hal_writeport_buf_uchar(uint8_t *, 71 uint8_t *, uint32_t); 72__stdcall static void hal_writeport_ulong(uint32_t *, uint32_t); 73__stdcall static void hal_writeport_ushort(uint16_t *, uint16_t); 74__stdcall static void hal_writeport_uchar(uint8_t *, uint8_t); 75__stdcall static uint32_t hal_readport_ulong(uint32_t *); 76__stdcall static uint16_t hal_readport_ushort(uint16_t *); 77__stdcall static uint8_t hal_readport_uchar(uint8_t *); 78__stdcall static void hal_readport_buf_ulong(uint32_t *, 79 uint32_t *, uint32_t); 80__stdcall static void hal_readport_buf_ushort(uint16_t *, 81 uint16_t *, uint32_t); 82__stdcall static void hal_readport_buf_uchar(uint8_t *, 83 uint8_t *, uint32_t); 84__stdcall static uint8_t hal_lock(/*kspin_lock * */void); 85__stdcall static void hal_unlock(/*kspin_lock *, uint8_t*/void); 86__stdcall static uint8_t hal_irql(void); 87__stdcall static void dummy (void); 88 89extern struct mtx_pool *ndis_mtxpool; 90 91__stdcall static void 92hal_stall_exec_cpu(usecs) 93 uint32_t usecs; 94{ 95 DELAY(usecs); 96 return; 97} 98 99__stdcall static void 100hal_writeport_ulong(port, val) 101 uint32_t *port; 102 uint32_t val; 103{ 104 bus_space_write_4(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val); 105 return; 106} 107 108__stdcall static void 109hal_writeport_ushort(port, val) 110 uint16_t *port; 111 uint16_t val; 112{ 113 bus_space_write_2(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val); 114 return; 115} 116 117__stdcall static void 118hal_writeport_uchar(port, val) 119 uint8_t *port; 120 uint8_t val; 121{ 122 bus_space_write_1(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val); 123 return; 124} 125 126__stdcall static void 127hal_writeport_buf_ulong(port, val, cnt) 128 uint32_t *port; 129 uint32_t *val; 130 uint32_t cnt; 131{ 132 bus_space_write_multi_4(I386_BUS_SPACE_IO, 0x0, 133 (bus_size_t)port, val, cnt); 134 return; 135} 136 137__stdcall static void 138hal_writeport_buf_ushort(port, val, cnt) 139 uint16_t *port; 140 uint16_t *val; 141 uint32_t cnt; 142{ 143 bus_space_write_multi_2(I386_BUS_SPACE_IO, 0x0, 144 (bus_size_t)port, val, cnt); 145 return; 146} 147 148__stdcall static void 149hal_writeport_buf_uchar(port, val, cnt) 150 uint8_t *port; 151 uint8_t *val; 152 uint32_t cnt; 153{ 154 bus_space_write_multi_1(I386_BUS_SPACE_IO, 0x0, 155 (bus_size_t)port, val, cnt); 156 return; 157} 158 159__stdcall static uint16_t 160hal_readport_ushort(port) 161 uint16_t *port; 162{ 163 return(bus_space_read_2(I386_BUS_SPACE_IO, 0x0, (uint32_t)port)); 164} 165 166__stdcall static uint32_t 167hal_readport_ulong(port) 168 uint32_t *port; 169{ 170 return(bus_space_read_4(I386_BUS_SPACE_IO, 0x0, (uint32_t)port)); 171} 172 173__stdcall static uint8_t 174hal_readport_uchar(port) 175 uint8_t *port; 176{ 177 return(bus_space_read_1(I386_BUS_SPACE_IO, 0x0, (uint32_t)port)); 178} 179 180__stdcall static void 181hal_readport_buf_ulong(port, val, cnt) 182 uint32_t *port; 183 uint32_t *val; 184 uint32_t cnt; 185{ 186 bus_space_read_multi_4(I386_BUS_SPACE_IO, 0x0, 187 (bus_size_t)port, val, cnt); 188 return; 189} 190 191__stdcall static void 192hal_readport_buf_ushort(port, val, cnt) 193 uint16_t *port; 194 uint16_t *val; 195 uint32_t cnt; 196{ 197 bus_space_read_multi_2(I386_BUS_SPACE_IO, 0x0, 198 (bus_size_t)port, val, cnt); 199 return; 200} 201 202__stdcall static void 203hal_readport_buf_uchar(port, val, cnt) 204 uint8_t *port; 205 uint8_t *val; 206 uint32_t cnt; 207{ 208 bus_space_read_multi_1(I386_BUS_SPACE_IO, 0x0, 209 (bus_size_t)port, val, cnt); 210 return; 211} 212 213__stdcall static uint8_t 214hal_lock(/*lock*/void) 215{ 216 kspin_lock *lock; 217 218 __asm__ __volatile__ ("" : "=c" (lock)); 219 220 mtx_pool_lock(ndis_mtxpool, (struct mtx *)*lock); 221 return(0); 222} 223 224__stdcall static void 225hal_unlock(/*lock, newirql*/void) 226{ 227 kspin_lock *lock; 228 uint8_t newiqrl; 229 230 __asm__ __volatile__ ("" : "=c" (lock), "=d" (newiqrl)); 231 232 mtx_pool_unlock(ndis_mtxpool, (struct mtx *)*lock); 233 return; 234} 235 236__stdcall static uint8_t 237hal_irql(void) 238{ 239 return(0); 240} 241 242__stdcall 243static void dummy() 244{ 245 printf ("hal dummy called...\n"); 246 return; 247} 248 249image_patch_table hal_functbl[] = { 250 { "KeStallExecutionProcessor", (FUNC)hal_stall_exec_cpu }, 251 { "WRITE_PORT_ULONG", (FUNC)hal_writeport_ulong }, 252 { "WRITE_PORT_USHORT", (FUNC)hal_writeport_ushort }, 253 { "WRITE_PORT_UCHAR", (FUNC)hal_writeport_uchar }, 254 { "WRITE_PORT_BUFFER_ULONG", (FUNC)hal_writeport_buf_ulong }, 255 { "WRITE_PORT_BUFFER_USHORT", (FUNC)hal_writeport_buf_ushort }, 256 { "WRITE_PORT_BUFFER_UCHAR", (FUNC)hal_writeport_buf_uchar }, 257 { "READ_PORT_ULONG", (FUNC)hal_readport_ulong }, 258 { "READ_PORT_USHORT", (FUNC)hal_readport_ushort }, 259 { "READ_PORT_UCHAR", (FUNC)hal_readport_uchar }, 260 { "READ_PORT_BUFFER_ULONG", (FUNC)hal_readport_buf_ulong }, 261 { "READ_PORT_BUFFER_USHORT", (FUNC)hal_readport_buf_ushort }, 262 { "READ_PORT_BUFFER_UCHAR", (FUNC)hal_readport_buf_uchar }, 263 { "KfAcquireSpinLock", (FUNC)hal_lock }, 264 { "KfReleaseSpinLock", (FUNC)hal_unlock }, 265 { "KeGetCurrentIrql", (FUNC)hal_irql }, 266 267 /* 268 * This last entry is a catch-all for any function we haven't 269 * implemented yet. The PE import list patching routine will 270 * use it for any function that doesn't have an explicit match 271 * in this table. 272 */ 273 274 { NULL, (FUNC)dummy }, 275 276 /* End of list. */ 277 278 { NULL, NULL }, 279};
| 58#define FUNC void(*)(void) 59 60__stdcall static void hal_stall_exec_cpu(uint32_t); 61__stdcall static void hal_writeport_buf_ulong(uint32_t *, 62 uint32_t *, uint32_t); 63__stdcall static void hal_writeport_buf_ushort(uint16_t *, 64 uint16_t *, uint32_t); 65__stdcall static void hal_writeport_buf_uchar(uint8_t *, 66 uint8_t *, uint32_t); 67__stdcall static void hal_writeport_ulong(uint32_t *, uint32_t); 68__stdcall static void hal_writeport_ushort(uint16_t *, uint16_t); 69__stdcall static void hal_writeport_uchar(uint8_t *, uint8_t); 70__stdcall static uint32_t hal_readport_ulong(uint32_t *); 71__stdcall static uint16_t hal_readport_ushort(uint16_t *); 72__stdcall static uint8_t hal_readport_uchar(uint8_t *); 73__stdcall static void hal_readport_buf_ulong(uint32_t *, 74 uint32_t *, uint32_t); 75__stdcall static void hal_readport_buf_ushort(uint16_t *, 76 uint16_t *, uint32_t); 77__stdcall static void hal_readport_buf_uchar(uint8_t *, 78 uint8_t *, uint32_t); 79__stdcall static uint8_t hal_lock(/*kspin_lock * */void); 80__stdcall static void hal_unlock(/*kspin_lock *, uint8_t*/void); 81__stdcall static uint8_t hal_irql(void); 82__stdcall static void dummy (void); 83 84extern struct mtx_pool *ndis_mtxpool; 85 86__stdcall static void 87hal_stall_exec_cpu(usecs) 88 uint32_t usecs; 89{ 90 DELAY(usecs); 91 return; 92} 93 94__stdcall static void 95hal_writeport_ulong(port, val) 96 uint32_t *port; 97 uint32_t val; 98{ 99 bus_space_write_4(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val); 100 return; 101} 102 103__stdcall static void 104hal_writeport_ushort(port, val) 105 uint16_t *port; 106 uint16_t val; 107{ 108 bus_space_write_2(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val); 109 return; 110} 111 112__stdcall static void 113hal_writeport_uchar(port, val) 114 uint8_t *port; 115 uint8_t val; 116{ 117 bus_space_write_1(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val); 118 return; 119} 120 121__stdcall static void 122hal_writeport_buf_ulong(port, val, cnt) 123 uint32_t *port; 124 uint32_t *val; 125 uint32_t cnt; 126{ 127 bus_space_write_multi_4(I386_BUS_SPACE_IO, 0x0, 128 (bus_size_t)port, val, cnt); 129 return; 130} 131 132__stdcall static void 133hal_writeport_buf_ushort(port, val, cnt) 134 uint16_t *port; 135 uint16_t *val; 136 uint32_t cnt; 137{ 138 bus_space_write_multi_2(I386_BUS_SPACE_IO, 0x0, 139 (bus_size_t)port, val, cnt); 140 return; 141} 142 143__stdcall static void 144hal_writeport_buf_uchar(port, val, cnt) 145 uint8_t *port; 146 uint8_t *val; 147 uint32_t cnt; 148{ 149 bus_space_write_multi_1(I386_BUS_SPACE_IO, 0x0, 150 (bus_size_t)port, val, cnt); 151 return; 152} 153 154__stdcall static uint16_t 155hal_readport_ushort(port) 156 uint16_t *port; 157{ 158 return(bus_space_read_2(I386_BUS_SPACE_IO, 0x0, (uint32_t)port)); 159} 160 161__stdcall static uint32_t 162hal_readport_ulong(port) 163 uint32_t *port; 164{ 165 return(bus_space_read_4(I386_BUS_SPACE_IO, 0x0, (uint32_t)port)); 166} 167 168__stdcall static uint8_t 169hal_readport_uchar(port) 170 uint8_t *port; 171{ 172 return(bus_space_read_1(I386_BUS_SPACE_IO, 0x0, (uint32_t)port)); 173} 174 175__stdcall static void 176hal_readport_buf_ulong(port, val, cnt) 177 uint32_t *port; 178 uint32_t *val; 179 uint32_t cnt; 180{ 181 bus_space_read_multi_4(I386_BUS_SPACE_IO, 0x0, 182 (bus_size_t)port, val, cnt); 183 return; 184} 185 186__stdcall static void 187hal_readport_buf_ushort(port, val, cnt) 188 uint16_t *port; 189 uint16_t *val; 190 uint32_t cnt; 191{ 192 bus_space_read_multi_2(I386_BUS_SPACE_IO, 0x0, 193 (bus_size_t)port, val, cnt); 194 return; 195} 196 197__stdcall static void 198hal_readport_buf_uchar(port, val, cnt) 199 uint8_t *port; 200 uint8_t *val; 201 uint32_t cnt; 202{ 203 bus_space_read_multi_1(I386_BUS_SPACE_IO, 0x0, 204 (bus_size_t)port, val, cnt); 205 return; 206} 207 208__stdcall static uint8_t 209hal_lock(/*lock*/void) 210{ 211 kspin_lock *lock; 212 213 __asm__ __volatile__ ("" : "=c" (lock)); 214 215 mtx_pool_lock(ndis_mtxpool, (struct mtx *)*lock); 216 return(0); 217} 218 219__stdcall static void 220hal_unlock(/*lock, newirql*/void) 221{ 222 kspin_lock *lock; 223 uint8_t newiqrl; 224 225 __asm__ __volatile__ ("" : "=c" (lock), "=d" (newiqrl)); 226 227 mtx_pool_unlock(ndis_mtxpool, (struct mtx *)*lock); 228 return; 229} 230 231__stdcall static uint8_t 232hal_irql(void) 233{ 234 return(0); 235} 236 237__stdcall 238static void dummy() 239{ 240 printf ("hal dummy called...\n"); 241 return; 242} 243 244image_patch_table hal_functbl[] = { 245 { "KeStallExecutionProcessor", (FUNC)hal_stall_exec_cpu }, 246 { "WRITE_PORT_ULONG", (FUNC)hal_writeport_ulong }, 247 { "WRITE_PORT_USHORT", (FUNC)hal_writeport_ushort }, 248 { "WRITE_PORT_UCHAR", (FUNC)hal_writeport_uchar }, 249 { "WRITE_PORT_BUFFER_ULONG", (FUNC)hal_writeport_buf_ulong }, 250 { "WRITE_PORT_BUFFER_USHORT", (FUNC)hal_writeport_buf_ushort }, 251 { "WRITE_PORT_BUFFER_UCHAR", (FUNC)hal_writeport_buf_uchar }, 252 { "READ_PORT_ULONG", (FUNC)hal_readport_ulong }, 253 { "READ_PORT_USHORT", (FUNC)hal_readport_ushort }, 254 { "READ_PORT_UCHAR", (FUNC)hal_readport_uchar }, 255 { "READ_PORT_BUFFER_ULONG", (FUNC)hal_readport_buf_ulong }, 256 { "READ_PORT_BUFFER_USHORT", (FUNC)hal_readport_buf_ushort }, 257 { "READ_PORT_BUFFER_UCHAR", (FUNC)hal_readport_buf_uchar }, 258 { "KfAcquireSpinLock", (FUNC)hal_lock }, 259 { "KfReleaseSpinLock", (FUNC)hal_unlock }, 260 { "KeGetCurrentIrql", (FUNC)hal_irql }, 261 262 /* 263 * This last entry is a catch-all for any function we haven't 264 * implemented yet. The PE import list patching routine will 265 * use it for any function that doesn't have an explicit match 266 * in this table. 267 */ 268 269 { NULL, (FUNC)dummy }, 270 271 /* End of list. */ 272 273 { NULL, NULL }, 274};
|