/* * 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"); /* * This file implements a translation layer between the BSD networking * infrasturcture and Windows NDIS network driver modules. A Windows * NDIS driver calls into several functions in the NDIS.SYS Windows * kernel module and exports a table of functions designed to be called * by the NDIS subsystem. Using the PE loader, we can patch our own * versions of the NDIS routines into a given Windows driver module and * convince the driver that it is in fact running on Windows. * * There are two significant differences between the Windows and FreeBSD * driver models that make life a little difficult for us. First, in * FreeBSD, the bus_space_xxx() register access routines accept bus * tag and bus handle arguments to specify the bus context where the * register access will be made. The tag and handle are obtained from * the resource manager and are opaque to the driver. In Windows however, * drivers still have knowledge of absolute I/O addresses, and hence * the Windows I/O port and memory access routines accept only a register * address as an argument. We can handle this, but in a mildly unpleasant * fashion. * * Second, in Windows, probing for devices is done within each device * driver, rather than by the parent bus handler code as is the case in * FreeBSD. This makes things like attaching PCI devices tricky, since * the driver expects to be able to walk the PCI bus looking for matching * devices even though the PCI bus code has already done this for us. * Again, we can get around this, but it's not very pleasant. * * We provide a table of all our implemented NDIS routines which is patched * into the driver object code. All our exported routines must use the * _stdcall calling convention, since that's what the Windows object code * expects. */ #include #include #include #ifdef _KERNEL #include #include #include #include #include #include #include #include #include #include #define NDIS_MALLOC(x) malloc(x, M_DEVBUF, M_NOWAIT) #define NDIS_FREE(x) free(x, M_DEVBUF) #else #include #include #include #include #include #include #define TRUE 1 #define FALSE 0 #define NDIS_MALLOC(x) malloc(x) #define NDIS_FREE(x) free(x) #endif #include "pe_var.h" #include "resource_var.h" #include "ndis_var.h" #define __stdcall __attribute__((__stdcall__)) #define FUNC void(*)() /* * NDIS deals with strings in unicode format, so we have * do deal with them that way too. For now, we only handle * conversion between unicode and ASCII since that's all * that device drivers care about. */ int ndis_ascii_to_unicode(ascii, unicode) char *ascii; uint16_t **unicode; { uint16_t *ustr; int i; if (*unicode == NULL) *unicode = NDIS_MALLOC(strlen(ascii) * 2); if (*unicode == NULL) return(ENOMEM); ustr = *unicode; for (i = 0; i < strlen(ascii); i++) { *ustr = (uint16_t)ascii[i]; ustr++; } return(0); } int ndis_unicode_to_ascii(unicode, ulen, ascii) uint16_t *unicode; int ulen; char **ascii; { uint8_t *astr; int i; if (*ascii == NULL) *ascii = NDIS_MALLOC(ulen); if (*ascii == NULL) return(ENOMEM); astr = *ascii; for (i = 0; i < ulen; i++) { *astr = (uint8_t)unicode[i]; astr++; } return(0); } __stdcall static void ndis_initwrap(wrapper, drv_obj, path, unused) ndis_handle wrapper; ndis_driver_object *drv_obj; void *path; void *unused; { ndis_driver_object **drv; printf ("NdisInitializeWrapper() called...\n"); printf ("ifname: %s\n", drv_obj->ndo_ifname); drv = wrapper; *drv = drv_obj; return; } __stdcall static ndis_status ndis_register_miniport(handle, characteristics, len) ndis_handle handle; ndis_miniport_characteristics *characteristics; int len; { ndis_driver_object *drv; printf ("NdisMRegisterMiniport() called...\n"); printf ("sizeof: %d\n", sizeof(ndis_miniport_characteristics)); drv = handle; bcopy((char *)characteristics, (char *)&drv->ndo_chars, sizeof(ndis_miniport_characteristics)); return(NDIS_STATUS_SUCCESS); } __stdcall static ndis_status ndis_malloc_withtag(vaddr, len, tag) void **vaddr; uint32_t len; uint32_t tag; { void *mem; mem = NDIS_MALLOC(len); if (mem == NULL) return(NDIS_STATUS_RESOURCES); *vaddr = mem; printf ("allocated %d bytes at %p\n", len, mem); return(NDIS_STATUS_SUCCESS); } __stdcall static void ndis_free(vaddr, len, flags) void *vaddr; uint32_t len; uint32_t flags; { printf ("ndis freeing %d bytes at %p\n", len, vaddr); if (len == 0) return; NDIS_FREE(vaddr); return; } __stdcall static ndis_status ndis_setattr_ex(adapter_handle, adapter_ctx, hangsecs, flags, iftype) ndis_handle adapter_handle; ndis_handle adapter_ctx; uint32_t hangsecs; uint32_t flags; ndis_interface_type iftype; { printf ("setattr...\n"); return(NDIS_STATUS_SUCCESS); } __stdcall static void ndis_open_cfg(status, cfg, wrapctx) ndis_status *status; ndis_handle *cfg; ndis_handle wrapctx; { *cfg = wrapctx; *status = NDIS_STATUS_SUCCESS; printf ("config open...\n"); return; } __stdcall static void ndis_read_cfg(status, parm, cfg, key, type) ndis_status *status; ndis_config_parm **parm; ndis_handle cfg; ndis_unicode_string *key; ndis_parm_type type; { char *keystr = NULL; uint16_t *unicode; ndis_miniport_block *block; ndis_unicode_string *ustr; block = (ndis_miniport_block *)cfg; ndis_unicode_to_ascii(key->nus_buf, key->nus_len, &keystr); printf ("key: %s type: ", keystr); *parm = &block->nmb_replyparm; bzero((char *)&block->nmb_replyparm, sizeof(ndis_config_parm)); unicode = (uint16_t *)&block->nmb_dummybuf; if (type == ndis_parm_string) { printf ("string\n"); ndis_ascii_to_unicode("test", &unicode); block->nmb_replyparm.ncp_type = ndis_parm_string; ustr = &block->nmb_replyparm.ncp_parmdata.ncp_stringdata; ustr->nus_len = strlen("test") * 2; ustr->nus_buf = unicode; } if (type == ndis_parm_int) { printf ("integer\n"); block->nmb_replyparm.ncp_type = ndis_parm_int; if (!strcmp(keystr, "FPGAEEPROMSize")) { printf ("512!!!!\n"); block->nmb_replyparm.ncp_parmdata.ncp_intdata = 512; } else if (!strcmp(keystr, "NdisVersion")) block->nmb_replyparm.ncp_parmdata.ncp_intdata = 5; else if (!strcmp(keystr, "AdapterType")) block->nmb_replyparm.ncp_parmdata.ncp_intdata = 5; else if (!strcmp(keystr, "RxPacketDesc")) block->nmb_replyparm.ncp_parmdata.ncp_intdata = 120; else if (!strcmp(keystr, "TxPacketDesc")) block->nmb_replyparm.ncp_parmdata.ncp_intdata = 75; else if (!strcmp(keystr, "RxDmaDesc")) block->nmb_replyparm.ncp_parmdata.ncp_intdata = 40; else if (!strcmp(keystr, "TxDmaDesc")) block->nmb_replyparm.ncp_parmdata.ncp_intdata = 150; else if (!strcmp(keystr, "PacketsPerTxInt") || !strcmp(keystr, "PacketsPerRxInt")) block->nmb_replyparm.ncp_parmdata.ncp_intdata = 10; else block->nmb_replyparm.ncp_parmdata.ncp_intdata = 0; } if (type == ndis_parm_binary) { printf ("binary\n"); block->nmb_replyparm.ncp_type = ndis_parm_binary; block->nmb_replyparm.ncp_parmdata.ncp_binarydata.nbd_buf = "0"; block->nmb_replyparm.ncp_parmdata.ncp_binarydata.nbd_len = 1; } NDIS_FREE(keystr); *status = NDIS_STATUS_SUCCESS; return; } __stdcall static void ndis_close_cfg(cfg) ndis_handle cfg; { printf ("config close\n"); return; } __stdcall static void ndis_create_lock(lock) ndis_spin_lock *lock; { #ifdef _KERNEL struct mtx *mtx, **dest; mtx = malloc(sizeof(struct mtx), M_DEVBUF, M_NOWAIT); if (mtx == NULL) return; mtx_init(mtx, "ndislock", MTX_NETWORK_LOCK, MTX_SPIN | MTX_RECURSE); dest = (struct mtx **)lock; *dest = mtx; #endif printf ("spinlock create...\n"); return; } __stdcall static void ndis_destroy_lock(lock) ndis_spin_lock *lock; { #ifdef _KERNEL struct mtx *ndis_mtx; ndis_mtx = *(struct mtx **)lock; mtx_destroy(ndis_mtx); free(ndis_mtx, M_DEVBUF); #endif printf ("spinlock destroyed\n"); return; } __stdcall static void ndis_lock(lock) ndis_spin_lock *lock; { #ifdef _KERNEL if (lock == NULL) return; mtx_lock_spin(*(struct mtx **)lock); #endif printf ("spinlock...\n"); return; } __stdcall static void ndis_unlock(lock) ndis_spin_lock *lock; { #ifdef _KERNEL if (lock == NULL) return; mtx_unlock_spin(*(struct mtx **)lock); #endif printf ("spinunlock...\n"); return; } /* * NDIS drivers for PCI devices do their own bus probing: they * search all available PCI devices looking for a vendor/device ID * that they support. In FreeBSD, drivers don't have to do this * probe since the system does the device probing for them. So * when the driver goes looking for devices, we lie to it and make * it think there's only one device in the whole system, which is * the one we want it to attach to. */ __stdcall static uint32_t ndis_read_pci(adapter, slot, offset, buf, len) ndis_handle adapter; uint32_t slot; uint32_t offset; void *buf; uint32_t len; { ndis_miniport_block *block; char *dest; block = (ndis_miniport_block *)adapter; dest = buf; #ifdef _KERNEL int i; device_t bus; bus = device_get_parent(block->nmb_dev); dest = buf; for (i = 0; i < len; i++) dest[i] = pci_read_config(bus, i + offset, 1); #endif if (offset == 0) { dest[0] = 0x17; dest[1] = 0x13; dest[2] = 0x85; dest[3] = 0x09; } else { dest[0] = 0x00; dest[1] = 0x00; dest[2] = 0x00; dest[3] = 0x00; } printf ("PCI read %d bytes at %d\n", len, offset); return(len); } __stdcall static uint32_t ndis_write_pci(adapter, slot, offset, buf, len) ndis_handle adapter; uint32_t slot; uint32_t offset; void *buf; uint32_t len; { #ifdef _KERNEL ndis_miniport_block *block; device_t bus; int i; char *dest; block = (ndis_miniport_block *)adapter; bus = device_get_parent(block->nmb_dev); dest = buf; for (i = 0; i < len; i++) pci_write_config(bus, i, dest[i], 1); #endif printf ("PCI write\n"); return(len); } /* * The errorlog routine uses a variable argument list, so we * have to declare it this way. */ __stdcall static void ndis_syslog(ndis_handle adapter, ndis_error_code code, uint32_t numerrors, ...) { ndis_miniport_block *block; va_list ap; int i; block = (ndis_miniport_block *)adapter; printf ("NDIS ERROR: %x\n", code); printf ("NDIS NUMERRORS: %x\n", numerrors); va_start(ap, numerrors); for (i = 0; i < numerrors; i++) printf ("argptr: %p\n", va_arg(ap, void *)); va_end(ap); return; } __stdcall static void ndis_vtophys_load(adapter, buf, mapreg, writedev, addrarray, arraysize) ndis_handle adapter; ndis_buffer *buf; uint32_t mapreg; uint8_t writedev; ndis_paddr_unit *addrarray; uint32_t *arraysize; { ndis_miniport_block *block; block = (ndis_miniport_block *)adapter; printf ("vtophys map\n"); return; } __stdcall static void ndis_vtophys_unload(adapter, buf, mapreg) ndis_handle adapter; ndis_buffer *buf; uint32_t mapreg; { ndis_miniport_block *block; block = (ndis_miniport_block *)adapter; printf ("vtophys unmap\n"); return; } __stdcall static void ndis_create_timer(timer, handle, func, ctx) ndis_miniport_timer *timer; ndis_handle *handle; ndis_timer_function func; void *ctx; { #ifdef _KERNEL struct callout_handle *ch; ch = (struct callout_handle *)&timer->nmt_ktimer; callout_handle_init(ch); timer->nmt_timerfunc = func; timer->nmt_timerctx = ctx; #endif printf ("Create timer...\n"); return; } /* * Windows specifies timeouts in milliseconds. We specify timeouts * in hz. Trying to compute a tenth of a second based on hz is tricky. * so we approximate. Note that we abuse the dpc portion of the * miniport timer structure to hold the UNIX callout handle. */ __stdcall static void ndis_set_timer(timer, msecs) ndis_miniport_timer *timer; uint32_t msecs; { #ifdef _KERNEL struct callout_handle *ch; ch = (struct callout_handle *)&timer->nmt_dpc; *ch = timeout((timeout_t *)timer->nmt_timerfunc, timer->nmt_timerctx, (hz >> 3) * msecs); #endif printf ("set timer\n"); return; } #ifdef _KEREL static void ndis_tick(arg) void *arg; { ndis_miniport_timer *timer; struct callout_handle *ch; (*timer->nmt_timerfunc) (NULL, timer->nmt_timerctx, NULL, NULL); /* Automatically reload timer. */ ch = (struct callout_handle *)&timer->nmt_dpc; *ch = timeout(ndis_tick, timer, (hz >> 3) * timer->nmt_ktimer.nk_period); return; } #endif __stdcall static void ndis_set_periodic_timer(timer, msecs) ndis_miniport_timer *timer; uint32_t msecs; { #ifdef _KERNEL struct callout_handle *ch; timer->nmt_ktimer.nk_period = msecs; ch = (struct callout_handle *)&timer->nmt_dpc; *ch = timeout(ndis_tick, timer, (hz >> 3) * msecs); #endif printf ("periodic timer...\n"); return; } __stdcall static void ndis_cancel_timer(timer, cancelled) ndis_miniport_timer *timer; uint8_t *cancelled; { #ifdef _KERNEL struct callout_handle *ch; ch = (struct callout_handle *)&timer->nmt_ktimer; untimeout((timeout_t *)timer->nmt_timerfunc, timer->nmt_timerctx, *ch); #endif printf ("cancel timer...\n"); return; } __stdcall static void ndis_query_resources(status, adapter, list, buflen) ndis_status *status; ndis_handle adapter; ndis_resource_list *list; uint32_t *buflen; { *status = NDIS_STATUS_FAILURE; printf ("query resources...\n"); return; } __stdcall static ndis_status ndis_register_ioport(offset, adapter, port, numports) void **offset; ndis_handle adapter; uint32_t port; uint32_t numports; { printf ("port: %x numports: %x\n", port, numports); *offset = 0x1000; return(NDIS_STATUS_SUCCESS); } char naddr[] = { 0, 0, 0xe8, 0x1, 0x2, 0x3 }; __stdcall static void ndis_read_netaddr(status, addr, addrlen, adapter) ndis_status *status; void **addr; uint32_t *addrlen; ndis_handle adapter; { printf ("read net address...\n"); *addr = naddr; *addrlen = 6; *status = NDIS_STATUS_SUCCESS; return; } __stdcall static ndis_status ndis_alloc_mapreg(adapter, dmachannel, dmasize, physmapneeded, maxmap) ndis_handle adapter; uint32_t dmachannel; uint8_t dmasize; uint32_t physmapneeded; uint32_t maxmap; { printf ("allocate map register...\n"); return(NDIS_STATUS_SUCCESS); } /* * This maps to bus_dmamem_alloc(). */ __stdcall static void ndis_alloc_sharedmem(adapter, len, cached, vaddr, paddr) ndis_handle adapter; uint32_t len; uint8_t cached; void **vaddr; ndis_physaddr *paddr; { *vaddr = malloc(len); printf ("alloc %d shared bytes at %p\n", len, *vaddr); #ifdef notdef paddr->np_low = (uint32_t)*vaddr; paddr->np_high = 0; #endif paddr->np_quad = *(uint64_t **)vaddr; return; } __stdcall static void ndis_free_sharedmem(adapter, len, cached, vaddr, paddr) ndis_handle adapter; uint32_t len; uint8_t cached; void **vaddr; ndis_physaddr *paddr; { free(*vaddr); return; } __stdcall static ndis_status ndis_map_iospace(vaddr, adapter, paddr, len) void **vaddr; ndis_handle adapter; ndis_physaddr paddr; uint32_t len; { *vaddr = 0xdeadbeef; printf ("map iospace...\n"); return(NDIS_STATUS_SUCCESS); } __stdcall static ndis_status ndis_init_sc_dma(adapter, is64, maxphysmap) ndis_handle adapter; uint8_t is64; uint32_t maxphysmap; { printf ("init sc dma...\n"); return(NDIS_STATUS_SUCCESS); } __stdcall static void ndis_alloc_packetpool(status, pool, descnum, protrsvdlen) ndis_status *status; ndis_handle *pool; uint32_t descnum; uint32_t protrsvdlen; { ndis_packet *cur; int i; printf ("status: %p pool: %p desc: %d prot: %d\n", status, pool, descnum, protrsvdlen); *pool = malloc(sizeof(ndis_packet) * (descnum + 1)); if (pool == NULL) { *status = NDIS_STATUS_RESOURCES; return; } bzero(*pool, sizeof(ndis_packet) * (descnum + 1)); cur = (ndis_packet *)*pool; cur->np_private.npp_flags = 0x1; /* mark the head of the list */ for (i = 0; i < descnum; i++) { cur->np_private.npp_head = (ndis_handle)(cur + 1); cur++; } printf ("alloc packet pool, %p, desc: %d rsvd: %d\n", *pool, descnum, protrsvdlen); *status = NDIS_STATUS_SUCCESS; return; } __stdcall static void ndis_alloc_packet(status, packet, pool) ndis_status *status; ndis_packet **packet; ndis_handle pool; { ndis_packet *head, *pkt; head = (ndis_packet *)pool; if (head->np_private.npp_flags != 0x1) { *status = NDIS_STATUS_FAILURE; return; } pkt = (ndis_packet *)head->np_private.npp_head; if (pkt == NULL) { *status = NDIS_STATUS_RESOURCES; return; } head->np_private.npp_head = pkt->np_private.npp_head; pkt->np_private.npp_head = pkt->np_private.npp_tail = NULL; /* Save pointer to the pool. */ pkt->np_private.npp_pool = head; /* Set the oob offset pointer. Lots of things expect this. */ pkt->np_private.npp_packetooboffset = offsetof(ndis_packet, np_oob); *packet = pkt; *status = NDIS_STATUS_SUCCESS; return; } /* * The NDIS "buffer" manipulation functions are somewhat misnamed. * They don't really allocate buffers: they allocate buffer mappings. * The idea is you reserve a chunk of DMA-able memory using * NdisMAllocateSharedMemory() and then use NdisAllocateBuffer() * to obtain the virtual address of the DMA-able region. * ndis_alloc_bufpool() is analagous to bus_dma_tag_create(). */ __stdcall static void ndis_alloc_bufpool(status, pool, descnum) ndis_status *status; ndis_handle *pool; uint32_t descnum; { ndis_buffer *cur; int i; *pool = malloc(sizeof(ndis_buffer) * (descnum + 1)); if (pool == NULL) { *status = NDIS_STATUS_RESOURCES; return; } bzero(*pool, sizeof(ndis_buffer) * (descnum + 1)); cur = (ndis_buffer *)*pool; cur->nb_flags = 0x1; /* mark the head of the list */ for (i = 0; i < descnum; i++) { cur->nb_next = cur + 1; cur++; } printf ("ALLOC bufpool %d bytes at %p\n", sizeof(ndis_buffer) * (descnum + 1), *pool); *status = NDIS_STATUS_SUCCESS; return; } __stdcall static void ndis_free_bufpool(pool) ndis_handle *pool; { free(pool); return; } /* * This maps to a bus_dmamap_create() and bus_dmamap_load(). */ __stdcall static void ndis_alloc_buf(status, buffer, pool, vaddr, len) ndis_status *status; ndis_buffer **buffer; ndis_handle pool; void *vaddr; uint32_t len; { ndis_buffer *head, *buf; head = (ndis_buffer *)pool; if (head->nb_flags != 0x1) { *status = NDIS_STATUS_FAILURE; return; } buf = head->nb_next; if (buf == NULL) { *status = NDIS_STATUS_RESOURCES; return; } head->nb_next = buf->nb_next; /* Save pointer to the pool. */ buf->nb_process = head; buf->nb_mappedsystemva = vaddr; buf->nb_size = len; *buffer = buf; *status = NDIS_STATUS_SUCCESS; return; } __stdcall static void ndis_free_buf(buf) ndis_buffer *buf; { ndis_buffer *head; if (buf == NULL || buf->nb_next == NULL) return; head = buf->nb_process; if (head->nb_flags != 0x1) return; buf->nb_next = head->nb_next; head->nb_next = buf; return; } /* Get the virtual address and length of a buffer */ __stdcall static void ndis_query_buf(buf, vaddr, len) ndis_buffer *buf; void **vaddr; uint32_t *len; { printf ("Query buffer...\n"); *vaddr = buf->nb_mappedsystemva; *len = buf->nb_bytecount; return; } __stdcall static uint32_t ndis_interlock_inc(addend) uint32_t *addend; { printf ("interlocked increment...\n"); return(*addend++); } __stdcall static uint32_t ndis_interlock_dec(addend) uint32_t *addend; { printf ("interlocked decrement...\n"); return(*addend--); } __stdcall static void ndis_init_event(event) ndis_event *event; { printf ("init event...\n"); return; } __stdcall static void ndis_set_event(event) ndis_event *event; { printf ("set event...\n"); return; } __stdcall static void ndis_reset_event(event) ndis_event *event; { printf ("Reset event...\n"); return; } __stdcall static uint8_t ndis_wait_event(event, msecs) ndis_event *event; uint32_t msecs; { printf ("Wait event...\n"); return(0); } __stdcall static ndis_status ndis_unicode2ansi(dstr, sstr) ndis_ansi_string *dstr; ndis_unicode_string *sstr; { printf ("unicode 2 ansi...\n"); return (NDIS_STATUS_SUCCESS); } __stdcall static ndis_status ndis_assign_pcirsrc(macctx, wrapctx, cfgctx, slot, list) ndis_handle macctx; ndis_handle wrapctx; ndis_handle cfgctx; uint32_t slot; ndis_resource_list **list; { printf ("assign PCI resources...\n"); return (NDIS_STATUS_SUCCESS); } __stdcall static ndis_status ndis_register_intr(intr, adapter, ivec, ilevel, reqisr, shared, imode) ndis_miniport_interrupt *intr; ndis_handle adapter; uint32_t ivec; uint32_t ilevel; uint8_t reqisr; uint8_t shared; ndis_interrupt_mode imode; { printf ("REGISTER INTERRUPT...\n"); return(NDIS_STATUS_SUCCESS); } __stdcall static void ndis_register_shutdown(adapter, shutdownctx, shutdownfunc) ndis_handle adapter; void *shutdownctx; void *shutdownfunc; { printf ("register shutdown\n"); return; } __stdcall static void dummy() { printf ("dummy called...\n"); return; } image_patch_table ndis_functbl[] = { { "NdisInitializeWrapper", (FUNC)ndis_initwrap }, { "NdisMRegisterMiniport", (FUNC)ndis_register_miniport }, { "NdisAllocateMemoryWithTag", (FUNC)ndis_malloc_withtag }, { "NdisMSetAttributesEx", (FUNC)ndis_setattr_ex }, { "NdisCloseConfiguration", (FUNC)ndis_close_cfg }, { "NdisReadConfiguration", (FUNC)ndis_read_cfg }, { "NdisOpenConfiguration", (FUNC)ndis_open_cfg }, { "NdisReleaseSpinLock", (FUNC)ndis_unlock }, { "NdisAcquireSpinLock", (FUNC)ndis_lock }, { "NdisAllocateSpinLock", (FUNC)ndis_create_lock }, { "NdisFreeSpinLock", (FUNC)ndis_destroy_lock }, { "NdisFreeMemory", (FUNC)ndis_free }, { "NdisReadPciSlotInformation", (FUNC)ndis_read_pci }, { "NdisWritePciSlotInformation",(FUNC)ndis_write_pci }, { "NdisWriteErrorLogEntry", (FUNC)ndis_syslog }, { "NdisMStartBufferPhysicalMapping", (FUNC)ndis_vtophys_load }, { "NdisMCompleteBufferPhysicalMapping", (FUNC)ndis_vtophys_unload }, { "NdisMInitializeTimer", (FUNC)ndis_create_timer }, { "NdisSetTimer", (FUNC)ndis_set_timer }, { "NdisMCancelTimer", (FUNC)ndis_cancel_timer }, { "NdisMSetPeriodicTimer", (FUNC)ndis_set_periodic_timer }, { "NdisMQueryAdapterResources", (FUNC)ndis_query_resources }, { "NdisMRegisterIoPortRange", (FUNC)ndis_register_ioport }, { "NdisReadNetworkAddress", (FUNC)ndis_read_netaddr }, { "NdisMAllocateMapRegisters", (FUNC)ndis_alloc_mapreg }, { "NdisMAllocateSharedMemory", (FUNC)ndis_alloc_sharedmem }, { "NdisMMapIoSpace", (FUNC)ndis_map_iospace }, { "NdisMInitializeScatterGatherDma", (FUNC)ndis_init_sc_dma }, { "NdisAllocatePacketPool", (FUNC)ndis_alloc_packetpool }, { "NdisAllocatePacket", (FUNC)ndis_alloc_packet }, { "NdisAllocateBufferPool", (FUNC)ndis_alloc_bufpool }, { "NdisAllocateBuffer", (FUNC)ndis_alloc_buf }, { "NdisQueryBuffer", (FUNC)ndis_query_buf }, { "NdisFreeBuffer", (FUNC)ndis_free_buf }, { "NdisFreeBufferPool", (FUNC)ndis_free_bufpool }, { "NdisInterlockedIncrement", (FUNC)ndis_interlock_inc }, { "NdisInterlockedDecrement", (FUNC)ndis_interlock_dec }, { "NdisInitializeEvent", (FUNC)ndis_init_event }, { "NdisSetEvent", (FUNC)ndis_set_event }, { "NdisResetEvent", (FUNC)ndis_reset_event }, { "NdisWaitEvent", (FUNC)ndis_wait_event }, { "NdisUnicodeStringToAnsiString", (FUNC)ndis_unicode2ansi }, { "NdisMPciAssignResources", (FUNC)ndis_assign_pcirsrc }, { "NdisMFreeSharedMemory", (FUNC)ndis_free_sharedmem }, { "NdisMRegisterInterrupt", (FUNC)ndis_register_intr }, { "NdisMRegisterAdapterShutdownHandler", (FUNC)ndis_register_shutdown }, #ifdef notdef { "NdisFreePacketPool", (FUNC)dummy }, { "NdisMFreeMapRegisters", (FUNC)dummy }, { "NdisMUnmapIoSpace", (FUNC)dummy }, { "NdisMDeregisterIoPortRange", (FUNC)dummy }, { "NdisFreePacket", (FUNC)dummy }, { "NdisMDeregisterAdapterShutdownHandler", (FUNC)dummy }, { "NdisMDeregisterInterrupt", (FUNC)dummy }, { "NdisAdjustBufferLength", (FUNC)dummy }, { "NdisUnchainBufferAtFront", (FUNC)dummy }, { "NDIS_BUFFER_TO_SPAN_PAGES", (FUNC)dummy }, { "NdisQueryBufferOffset", (FUNC)dummy }, #endif /* * 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 }, };