/* * Copyright (c) 2003 * Bill Paul . All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Bill Paul. * 4. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD"); #include #include #include #ifdef _KERNEL #include #include #include #include #include #else #include #define DELAY(x) usleep(x) #define I386_BUS_SPACE_IO 0 #define bus_space_read_2(x, y, z) 0xffff #define bus_space_read_4(x, y, z) 0xffffffff #define bus_space_write_4(w, x, y, z) #define bus_space_write_2(w, x, y, z) #endif #include "pe_var.h" #include "hal_var.h" #define __stdcall __attribute__((__stdcall__)) #define FUNC void(*)() __stdcall static void hal_stall_exec_cpu(usecs) uint32_t usecs; { /*DELAY(usecs);*/ return; } __stdcall static void hal_writeport_ulong(port, val) uint32_t *port; uint32_t val; { bus_space_write_4(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val); return; } __stdcall static void hal_writeport_ushort(port, val) uint16_t *port; uint32_t val; { bus_space_write_2(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val); return; } __stdcall static uint16_t hal_readport_ushort(port) uint32_t *port; { return(bus_space_read_2(I386_BUS_SPACE_IO, 0x0, (uint32_t)port)); } __stdcall static uint32_t hal_readport_ulong(port) uint32_t *port; { return(bus_space_read_4(I386_BUS_SPACE_IO, 0x0, (uint32_t)port)); } __stdcall static void dummy() { printf ("dummy called...\n"); return; } image_patch_table hal_functbl[] = { { "KeStallExecutionProcessor", (FUNC)hal_stall_exec_cpu }, { "WRITE_PORT_ULONG", (FUNC)hal_writeport_ulong }, { "WRITE_PORT_USHORT", (FUNC)hal_writeport_ushort }, { "READ_PORT_ULONG", (FUNC)hal_readport_ulong }, { "READ_PORT_USHORT", (FUNC)hal_readport_ushort }, /* * This last entry is a catch-all for any function we haven't * implemented yet. The PE import list patching routine will * use it for any function that doesn't have an explicit match * in this table. */ { NULL, (FUNC)dummy }, /* End of list. */ { NULL, NULL }, };