summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/compat/ndis/hal_var.h10
-rw-r--r--sys/compat/ndis/kern_ndis.c78
-rw-r--r--sys/compat/ndis/kern_windrv.c414
-rw-r--r--sys/compat/ndis/ndis_var.h18
-rw-r--r--sys/compat/ndis/ntoskrnl_var.h121
-rw-r--r--sys/compat/ndis/pe_var.h125
-rw-r--r--sys/compat/ndis/subr_hal.c127
-rw-r--r--sys/compat/ndis/subr_ndis.c694
-rw-r--r--sys/compat/ndis/subr_ntoskrnl.c684
-rw-r--r--sys/compat/ndis/subr_usbd.c20
-rw-r--r--sys/compat/ndis/winx32_wrap.S354
-rw-r--r--sys/dev/if_ndis/if_ndis.c43
-rw-r--r--sys/modules/ndis/Makefile4
13 files changed, 1727 insertions, 965 deletions
diff --git a/sys/compat/ndis/hal_var.h b/sys/compat/ndis/hal_var.h
index c2a534e..69950b3 100644
--- a/sys/compat/ndis/hal_var.h
+++ b/sys/compat/ndis/hal_var.h
@@ -48,11 +48,11 @@ extern image_patch_table hal_functbl[];
__BEGIN_DECLS
extern int hal_libinit(void);
extern int hal_libfini(void);
-__fastcall extern uint8_t KfAcquireSpinLock(REGARGS1(kspin_lock *lock));
-__fastcall void KfReleaseSpinLock(REGARGS2(kspin_lock *lock, uint8_t newirql));
-__fastcall extern uint8_t KfRaiseIrql(REGARGS1(uint8_t irql));
-__fastcall extern void KfLowerIrql(REGARGS1(uint8_t oldirql));
-__stdcall extern uint8_t KeGetCurrentIrql(void);
+extern uint8_t KfAcquireSpinLock(kspin_lock *);
+extern void KfReleaseSpinLock(kspin_lock *, uint8_t);
+extern uint8_t KfRaiseIrql(uint8_t);
+extern void KfLowerIrql(uint8_t);
+extern uint8_t KeGetCurrentIrql(void);
__END_DECLS
#endif /* _HAL_VAR_H_ */
diff --git a/sys/compat/ndis/kern_ndis.c b/sys/compat/ndis/kern_ndis.c
index 1552826..b7b472a 100644
--- a/sys/compat/ndis/kern_ndis.c
+++ b/sys/compat/ndis/kern_ndis.c
@@ -76,24 +76,23 @@ __FBSDID("$FreeBSD$");
#define NDIS_DUMMY_PATH "\\\\some\\bogus\\path"
-__stdcall static void ndis_status_func(ndis_handle, ndis_status,
- void *, uint32_t);
-__stdcall static void ndis_statusdone_func(ndis_handle);
-__stdcall static void ndis_setdone_func(ndis_handle, ndis_status);
-__stdcall static void ndis_getdone_func(ndis_handle, ndis_status);
-__stdcall static void ndis_resetdone_func(ndis_handle, ndis_status, uint8_t);
-__stdcall static void ndis_sendrsrcavail_func(ndis_handle);
-__stdcall static void ndis_intrhand(kdpc *, device_object *,
+static void ndis_status_func(ndis_handle, ndis_status, void *, uint32_t);
+static void ndis_statusdone_func(ndis_handle);
+static void ndis_setdone_func(ndis_handle, ndis_status);
+static void ndis_getdone_func(ndis_handle, ndis_status);
+static void ndis_resetdone_func(ndis_handle, ndis_status, uint8_t);
+static void ndis_sendrsrcavail_func(ndis_handle);
+static void ndis_intrhand(kdpc *, device_object *,
irp *, struct ndis_softc *);
static image_patch_table kernndis_functbl[] = {
- IMPORT_FUNC(ndis_status_func),
- IMPORT_FUNC(ndis_statusdone_func),
- IMPORT_FUNC(ndis_setdone_func),
- IMPORT_FUNC(ndis_getdone_func),
- IMPORT_FUNC(ndis_resetdone_func),
- IMPORT_FUNC(ndis_sendrsrcavail_func),
- IMPORT_FUNC(ndis_intrhand),
+ IMPORT_SFUNC(ndis_status_func, 4),
+ IMPORT_SFUNC(ndis_statusdone_func, 1),
+ IMPORT_SFUNC(ndis_setdone_func, 2),
+ IMPORT_SFUNC(ndis_getdone_func, 2),
+ IMPORT_SFUNC(ndis_resetdone_func, 3),
+ IMPORT_SFUNC(ndis_sendrsrcavail_func, 1),
+ IMPORT_SFUNC(ndis_intrhand, 4),
{ NULL, NULL, NULL }
};
@@ -156,7 +155,8 @@ ndis_modevent(module_t mod, int cmd, void *arg)
patch = kernndis_functbl;
while (patch->ipt_func != NULL) {
windrv_wrap((funcptr)patch->ipt_func,
- (funcptr *)&patch->ipt_wrap);
+ (funcptr *)&patch->ipt_wrap,
+ patch->ipt_argcnt, patch->ipt_ftype);
patch++;
}
@@ -559,14 +559,14 @@ ndis_thresume(p)
return;
}
-__stdcall static void
+static void
ndis_sendrsrcavail_func(adapter)
ndis_handle adapter;
{
return;
}
-__stdcall static void
+static void
ndis_status_func(adapter, status, sbuf, slen)
ndis_handle adapter;
ndis_status status;
@@ -585,7 +585,7 @@ ndis_status_func(adapter, status, sbuf, slen)
return;
}
-__stdcall static void
+static void
ndis_statusdone_func(adapter)
ndis_handle adapter;
{
@@ -601,7 +601,7 @@ ndis_statusdone_func(adapter)
return;
}
-__stdcall static void
+static void
ndis_setdone_func(adapter, status)
ndis_handle adapter;
ndis_status status;
@@ -614,7 +614,7 @@ ndis_setdone_func(adapter, status)
return;
}
-__stdcall static void
+static void
ndis_getdone_func(adapter, status)
ndis_handle adapter;
ndis_status status;
@@ -627,7 +627,7 @@ ndis_getdone_func(adapter, status)
return;
}
-__stdcall static void
+static void
ndis_resetdone_func(adapter, status, addressingreset)
ndis_handle adapter;
ndis_status status;
@@ -818,7 +818,7 @@ ndis_return(arg)
void *arg;
{
struct ndis_softc *sc;
- __stdcall ndis_return_handler returnfunc;
+ ndis_return_handler returnfunc;
ndis_handle adapter;
ndis_packet *p;
uint8_t irql;
@@ -1166,7 +1166,7 @@ ndis_set_info(arg, oid, buf, buflen)
struct ndis_softc *sc;
ndis_status rval;
ndis_handle adapter;
- __stdcall ndis_setinfo_handler setfunc;
+ ndis_setinfo_handler setfunc;
uint32_t byteswritten = 0, bytesneeded = 0;
int error;
uint8_t irql;
@@ -1244,8 +1244,8 @@ ndis_send_packets(arg, packets, cnt)
{
struct ndis_softc *sc;
ndis_handle adapter;
- __stdcall ndis_sendmulti_handler sendfunc;
- __stdcall ndis_senddone_func senddonefunc;
+ ndis_sendmulti_handler sendfunc;
+ ndis_senddone_func senddonefunc;
int i;
ndis_packet *p;
uint8_t irql;
@@ -1289,8 +1289,8 @@ ndis_send_packet(arg, packet)
struct ndis_softc *sc;
ndis_handle adapter;
ndis_status status;
- __stdcall ndis_sendsingle_handler sendfunc;
- __stdcall ndis_senddone_func senddonefunc;
+ ndis_sendsingle_handler sendfunc;
+ ndis_senddone_func senddonefunc;
uint8_t irql;
sc = arg;
@@ -1381,7 +1381,7 @@ ndis_reset_nic(arg)
{
struct ndis_softc *sc;
ndis_handle adapter;
- __stdcall ndis_reset_handler resetfunc;
+ ndis_reset_handler resetfunc;
uint8_t addressing_reset;
struct ifnet *ifp;
int rval;
@@ -1419,7 +1419,7 @@ ndis_halt_nic(arg)
{
struct ndis_softc *sc;
ndis_handle adapter;
- __stdcall ndis_halt_handler haltfunc;
+ ndis_halt_handler haltfunc;
struct ifnet *ifp;
sc = arg;
@@ -1456,7 +1456,7 @@ ndis_shutdown_nic(arg)
{
struct ndis_softc *sc;
ndis_handle adapter;
- __stdcall ndis_shutdown_handler shutdownfunc;
+ ndis_shutdown_handler shutdownfunc;
sc = arg;
NDIS_LOCK(sc);
@@ -1483,7 +1483,7 @@ ndis_init_nic(arg)
{
struct ndis_softc *sc;
ndis_miniport_block *block;
- __stdcall ndis_init_handler initfunc;
+ ndis_init_handler initfunc;
ndis_status status, openstatus = 0;
ndis_medium mediumarray[NdisMediumMax];
uint32_t chosenmedium, i;
@@ -1524,7 +1524,7 @@ ndis_enable_intr(arg)
{
struct ndis_softc *sc;
ndis_handle adapter;
- __stdcall ndis_enable_interrupts_handler intrenbfunc;
+ ndis_enable_interrupts_handler intrenbfunc;
sc = arg;
adapter = sc->ndis_block->nmb_miniportadapterctx;
@@ -1542,7 +1542,7 @@ ndis_disable_intr(arg)
{
struct ndis_softc *sc;
ndis_handle adapter;
- __stdcall ndis_disable_interrupts_handler intrdisfunc;
+ ndis_disable_interrupts_handler intrdisfunc;
sc = arg;
adapter = sc->ndis_block->nmb_miniportadapterctx;
@@ -1563,7 +1563,7 @@ ndis_isr(arg, ourintr, callhandler)
{
struct ndis_softc *sc;
ndis_handle adapter;
- __stdcall ndis_isr_handler isrfunc;
+ ndis_isr_handler isrfunc;
uint8_t accepted, queue;
if (arg == NULL || ourintr == NULL || callhandler == NULL)
@@ -1584,7 +1584,7 @@ ndis_isr(arg, ourintr, callhandler)
return(0);
}
-__stdcall static void
+static void
ndis_intrhand(dpc, dobj, ip, sc)
kdpc *dpc;
device_object *dobj;
@@ -1592,7 +1592,7 @@ ndis_intrhand(dpc, dobj, ip, sc)
struct ndis_softc *sc;
{
ndis_handle adapter;
- __stdcall ndis_interrupt_handler intrfunc;
+ ndis_interrupt_handler intrfunc;
uint8_t irql;
adapter = sc->ndis_block->nmb_miniportadapterctx;
@@ -1626,7 +1626,7 @@ ndis_get_info(arg, oid, buf, buflen)
struct ndis_softc *sc;
ndis_status rval;
ndis_handle adapter;
- __stdcall ndis_queryinfo_handler queryfunc;
+ ndis_queryinfo_handler queryfunc;
uint32_t byteswritten = 0, bytesneeded = 0;
int error;
uint8_t irql;
@@ -1688,7 +1688,7 @@ ndis_get_info(arg, oid, buf, buflen)
return(0);
}
-__stdcall uint32_t
+uint32_t
NdisAddDevice(drv, pdo)
driver_object *drv;
device_object *pdo;
diff --git a/sys/compat/ndis/kern_windrv.c b/sys/compat/ndis/kern_windrv.c
index 67c3c0e..81b3a6d 100644
--- a/sys/compat/ndis/kern_windrv.c
+++ b/sys/compat/ndis/kern_windrv.c
@@ -46,6 +46,9 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/mbuf.h>
#include <sys/bus.h>
+#include <sys/proc.h>
+#include <sys/sched.h>
+#include <sys/smp.h>
#include <sys/queue.h>
@@ -79,6 +82,20 @@ static STAILQ_HEAD(drvdb, drvdb_ent) drvdb_head;
static driver_object fake_pci_driver; /* serves both PCI and cardbus */
static driver_object fake_pccard_driver;
+#ifdef __i386__
+static void x86_oldldt(void *);
+static void x86_newldt(void *);
+
+struct tid {
+ void *tid_except_list; /* 0x00 */
+ uint32_t tid_oldfs; /* 0x04 */
+ uint32_t tid_selector; /* 0x08 */
+ struct tid *tid_self; /* 0x0C */
+ int tid_cpu; /* 0x10 */
+};
+
+static struct tid *my_tids;
+#endif /* __i386__ */
#define DUMMY_REGISTRY_PATH "\\\\some\\bogus\\path"
@@ -102,6 +119,20 @@ windrv_libinit(void)
windrv_bus_attach(&fake_pci_driver, "PCI Bus");
windrv_bus_attach(&fake_pccard_driver, "PCCARD Bus");
+#ifdef __i386__
+
+ /*
+ * In order to properly support SMP machines, we have
+ * to modify the GDT on each CPU, since we never know
+ * on which one we'll end up running.
+ */
+
+ my_tids = ExAllocatePoolWithTag(NonPagedPool,
+ sizeof(struct tid) * mp_ncpus, 0);
+ if (my_tids == NULL)
+ panic("failed to allocate thread info blocks");
+ smp_rendezvous(NULL, x86_newldt, NULL, NULL);
+#endif
return(0);
}
@@ -122,6 +153,11 @@ windrv_libfini(void)
free(fake_pccard_driver.dro_drivername.us_buf, M_DEVBUF);
mtx_destroy(&drvdb_mtx);
+
+#ifdef __i386__
+ smp_rendezvous(NULL, x86_oldldt, NULL, NULL);
+ ExFreePool(my_tids);
+#endif
return(0);
}
@@ -138,6 +174,8 @@ windrv_lookup(img, name)
struct drvdb_ent *d;
unicode_string us;
+ bzero((char *)&us, sizeof(us));
+
/* Damn unicode. */
if (name != NULL) {
@@ -150,9 +188,11 @@ windrv_lookup(img, name)
mtx_lock(&drvdb_mtx);
STAILQ_FOREACH(d, &drvdb_head, link) {
if (d->windrv_object->dro_driverstart == (void *)img ||
- bcmp((char *)d->windrv_object->dro_drivername.us_buf,
- (char *)us.us_buf, us.us_len) == 0) {
+ (bcmp((char *)d->windrv_object->dro_drivername.us_buf,
+ (char *)us.us_buf, us.us_len) == 0 && us.us_len)) {
mtx_unlock(&drvdb_mtx);
+ if (name != NULL)
+ ExFreePool(us.us_buf);
return(d->windrv_object);
}
}
@@ -273,7 +313,7 @@ windrv_load(mod, img, len)
/* Next step: allocate and store a driver object. */
- new = malloc(sizeof(struct drvdb_ent), M_DEVBUF, M_NOWAIT);
+ new = malloc(sizeof(struct drvdb_ent), M_DEVBUF, M_NOWAIT|M_ZERO);
if (new == NULL)
return (ENOMEM);
@@ -282,7 +322,7 @@ windrv_load(mod, img, len)
free (new, M_DEVBUF);
return (ENOMEM);
}
-
+
/* Allocate a driver extension structure too. */
drv->dro_driverext = malloc(sizeof(driver_extension),
@@ -410,7 +450,7 @@ windrv_bus_attach(drv, name)
{
struct drvdb_ent *new;
- new = malloc(sizeof(struct drvdb_ent), M_DEVBUF, M_NOWAIT);
+ new = malloc(sizeof(struct drvdb_ent), M_DEVBUF, M_NOWAIT|M_ZERO);
if (new == NULL)
return (ENOMEM);
@@ -419,6 +459,12 @@ windrv_bus_attach(drv, name)
drv->dro_drivername.us_buf = NULL;
ndis_ascii_to_unicode(name, &drv->dro_drivername.us_buf);
+ /*
+ * Set up a fake image pointer to avoid false matches
+ * in windrv_lookup().
+ */
+ drv->dro_driverstart = (void *)0xFFFFFFFF;
+
new->windrv_object = drv;
new->windrv_devlist = NULL;
new->windrv_regvals = NULL;
@@ -436,14 +482,13 @@ extern void x86_64_wrap(void);
extern void x86_64_wrap_call(void);
extern void x86_64_wrap_end(void);
-#endif /* __amd64__ */
-
int
-windrv_wrap(func, wrap)
+windrv_wrap(func, wrap, argcnt, ftype)
funcptr func;
funcptr *wrap;
+ int argcnt;
+ int ftype;
{
-#ifdef __amd64__
funcptr p;
vm_offset_t *calladdr;
vm_offset_t wrapstart, wrapend, wrapcall;
@@ -468,18 +513,359 @@ windrv_wrap(func, wrap)
*calladdr = (vm_offset_t)func;
*wrap = p;
-#else /* __amd64__ */
- *wrap = func;
-#endif /* __amd64__ */
+
return(0);
}
+#endif /* __amd64__ */
+
+
+#ifdef __i386__
+
+struct x86desc {
+ uint16_t x_lolimit;
+ uint16_t x_base0;
+ uint8_t x_base1;
+ uint8_t x_flags;
+ uint8_t x_hilimit;
+ uint8_t x_base2;
+};
+
+struct gdt {
+ uint16_t limit;
+ void *base;
+} __attribute__((__packed__));
+
+extern uint16_t x86_getfs(void);
+extern void x86_setfs(uint16_t);
+extern void *x86_gettid(void);
+extern void x86_critical_enter(void);
+extern void x86_critical_exit(void);
+extern void x86_getldt(struct gdt *, uint16_t *);
+extern void x86_setldt(struct gdt *, uint16_t);
+
+#define SEL_LDT 4 /* local descriptor table */
+#define SEL_TO_FS(x) (((x) << 3))
+#define FREEBSD_EMPTYSEL 7
+
+/*
+ * The meanings of various bits in a descriptor vary a little
+ * depending on whether the descriptor will be used as a
+ * code, data or system descriptor. (And that in turn depends
+ * on which segment register selects the descriptor.)
+ * We're only trying to create a data segment, so the definitions
+ * below are the ones that apply to a data descriptor.
+ */
+
+#define SEGFLAGLO_PRESENT 0x80 /* segment is present */
+#define SEGFLAGLO_PRIVLVL 0x60 /* privlevel needed for this seg */
+#define SEGFLAGLO_CD 0x10 /* 1 = code/data, 0 = system */
+#define SEGFLAGLO_MBZ 0x08 /* must be zero */
+#define SEGFLAGLO_EXPANDDOWN 0x04 /* limit expands down */
+#define SEGFLAGLO_WRITEABLE 0x02 /* segment is writeable */
+#define SEGGLAGLO_ACCESSED 0x01 /* segment has been accessed */
+
+#define SEGFLAGHI_GRAN 0x80 /* granularity, 1 = byte, 0 = page */
+#define SEGFLAGHI_BIG 0x40 /* 1 = 32 bit stack, 0 = 16 bit */
+
+/*
+ * Context switch from UNIX to Windows. Save the existing value
+ * of %fs for this processor, then change it to point to our
+ * fake TID. Note that it is also possible to pin ourselves
+ * to our current CPU, though I'm not sure this is really
+ * necessary. It depends on whether or not an interrupt might
+ * preempt us while Windows code is running and we wind up
+ * scheduled onto another CPU as a result. So far, it doesn't
+ * seem like this is what happens.
+ */
+
+void
+ctxsw_utow(void)
+{
+ struct tid *t;
+
+ t = &my_tids[curthread->td_oncpu];
+ t->tid_oldfs = x86_getfs();
+ t->tid_cpu = curthread->td_oncpu;
+
+ x86_setfs(SEL_TO_FS(t->tid_selector));
+
+ /* Now entering Windows land, population: you. */
+
+ return;
+}
+
+/*
+ * Context switch from Windows back to UNIX. Restore %fs to
+ * its previous value. This always occurs after a call to
+ * ctxsw_utow().
+ */
+
+void
+ctxsw_wtou(void)
+{
+ struct tid *t;
+
+ t = x86_gettid();
+ x86_setfs(t->tid_oldfs);
+
+ /* Welcome back to UNIX land, we missed you. */
+
+#ifdef EXTRA_SANITY
+ if (t->tid_cpu != curthread->td_oncpu)
+ panic("ctxswGOT MOVED TO OTHER CPU!");
+#endif
+
+ return;
+}
+
+static int windrv_wrap_stdcall(funcptr, funcptr *, int);
+static int windrv_wrap_fastcall(funcptr, funcptr *, int);
+static int windrv_wrap_regparm(funcptr, funcptr *);
+
+extern void x86_fastcall_wrap(void);
+extern void x86_fastcall_wrap_call(void);
+extern void x86_fastcall_wrap_arg(void);
+extern void x86_fastcall_wrap_end(void);
+
+static int
+windrv_wrap_fastcall(func, wrap, argcnt)
+ funcptr func;
+ funcptr *wrap;
+ int8_t argcnt;
+{
+ funcptr p;
+ vm_offset_t *calladdr;
+ uint8_t *argaddr;
+ vm_offset_t wrapstart, wrapend, wrapcall, wraparg;
+
+ wrapstart = (vm_offset_t)&x86_fastcall_wrap;
+ wrapend = (vm_offset_t)&x86_fastcall_wrap_end;
+ wrapcall = (vm_offset_t)&x86_fastcall_wrap_call;
+ wraparg = (vm_offset_t)&x86_fastcall_wrap_arg;
+
+ /* Allocate a new wrapper instance. */
+
+ p = malloc((wrapend - wrapstart), M_DEVBUF, M_NOWAIT);
+ if (p == NULL)
+ return(ENOMEM);
+
+ /* Copy over the code. */
+
+ bcopy((char *)wrapstart, p, (wrapend - wrapstart));
+
+ /* Insert the function address into the new wrapper instance. */
+
+ calladdr = (vm_offset_t *)((char *)p + ((wrapcall - wrapstart) + 1));
+ *calladdr = (vm_offset_t)func;
+
+ argcnt -= 2;
+ if (argcnt < 1)
+ argcnt = 0;
+
+ argaddr = (u_int8_t *)((char *)p + ((wraparg - wrapstart) + 1));
+ *argaddr = argcnt * sizeof(uint32_t);
+
+ *wrap = p;
+
+ return(0);
+}
+
+extern void x86_stdcall_wrap(void);
+extern void x86_stdcall_wrap_call(void);
+extern void x86_stdcall_wrap_arg(void);
+extern void x86_stdcall_wrap_end(void);
+
+static int
+windrv_wrap_stdcall(func, wrap, argcnt)
+ funcptr func;
+ funcptr *wrap;
+ uint8_t argcnt;
+{
+ funcptr p;
+ vm_offset_t *calladdr;
+ uint8_t *argaddr;
+ vm_offset_t wrapstart, wrapend, wrapcall, wraparg;
+
+ wrapstart = (vm_offset_t)&x86_stdcall_wrap;
+ wrapend = (vm_offset_t)&x86_stdcall_wrap_end;
+ wrapcall = (vm_offset_t)&x86_stdcall_wrap_call;
+ wraparg = (vm_offset_t)&x86_stdcall_wrap_arg;
+
+ /* Allocate a new wrapper instance. */
+
+ p = malloc((wrapend - wrapstart), M_DEVBUF, M_NOWAIT);
+ if (p == NULL)
+ return(ENOMEM);
+
+ /* Copy over the code. */
+
+ bcopy((char *)wrapstart, p, (wrapend - wrapstart));
+
+ /* Insert the function address into the new wrapper instance. */
+
+ calladdr = (vm_offset_t *)((char *)p + ((wrapcall - wrapstart) + 1));
+ *calladdr = (vm_offset_t)func;
+
+ argaddr = (u_int8_t *)((char *)p + ((wraparg - wrapstart) + 1));
+ *argaddr = argcnt * sizeof(uint32_t);
+
+ *wrap = p;
+
+ return(0);
+}
+
+extern void x86_regparm_wrap(void);
+extern void x86_regparm_wrap_call(void);
+extern void x86_regparm_wrap_end(void);
+
+static int
+windrv_wrap_regparm(func, wrap)
+ funcptr func;
+ funcptr *wrap;
+{
+ funcptr p;
+ vm_offset_t *calladdr;
+ vm_offset_t wrapstart, wrapend, wrapcall;
+
+ wrapstart = (vm_offset_t)&x86_regparm_wrap;
+ wrapend = (vm_offset_t)&x86_regparm_wrap_end;
+ wrapcall = (vm_offset_t)&x86_regparm_wrap_call;
+
+ /* Allocate a new wrapper instance. */
+
+ p = malloc((wrapend - wrapstart), M_DEVBUF, M_NOWAIT);
+ if (p == NULL)
+ return(ENOMEM);
+
+ /* Copy over the code. */
+
+ bcopy(x86_regparm_wrap, p, (wrapend - wrapstart));
+
+ /* Insert the function address into the new wrapper instance. */
+
+ calladdr = (vm_offset_t *)((char *)p + ((wrapcall - wrapstart) + 1));
+ *calladdr = (vm_offset_t)func;
+
+ *wrap = p;
+
+ return(0);
+}
+
+int
+windrv_wrap(func, wrap, argcnt, ftype)
+ funcptr func;
+ funcptr *wrap;
+ int argcnt;
+ int ftype;
+{
+ switch(ftype) {
+ case WINDRV_WRAP_FASTCALL:
+ return(windrv_wrap_fastcall(func, wrap, argcnt));
+ case WINDRV_WRAP_STDCALL:
+ return(windrv_wrap_stdcall(func, wrap, argcnt));
+ case WINDRV_WRAP_REGPARM:
+ return(windrv_wrap_regparm(func, wrap));
+ case WINDRV_WRAP_CDECL:
+ return(windrv_wrap_stdcall(func, wrap, 0));
+ default:
+ break;
+ }
+
+ return(EINVAL);
+}
+
+static void
+x86_oldldt(dummy)
+ void *dummy;
+{
+ struct thread *t;
+ struct x86desc *gdt;
+ struct gdt gtable;
+ uint16_t ltable;
+
+ mtx_lock_spin(&sched_lock);
+
+ t = curthread;
+
+ /* Grab location of existing GDT. */
+
+ x86_getldt(&gtable, &ltable);
+
+ /* Find the slot we updated. */
+
+ gdt = gtable.base;
+ gdt += FREEBSD_EMPTYSEL;
+
+ /* Empty it out. */
+
+ bzero((char *)gdt, sizeof(struct x86desc));
+
+ /* Restore GDT. */
+
+ x86_setldt(&gtable, ltable);
+
+ mtx_unlock_spin(&sched_lock);
+
+ return;
+}
+
+static void
+x86_newldt(dummy)
+ void *dummy;
+{
+ struct gdt gtable;
+ uint16_t ltable;
+ struct x86desc *l;
+ struct thread *t;
+
+ mtx_lock_spin(&sched_lock);
+
+ t = curthread;
+
+ /* Grab location of existing GDT. */
+
+ x86_getldt(&gtable, &ltable);
+
+ /* Get pointer to the GDT table. */
+
+ l = gtable.base;
+
+ /* Get pointer to empty slot */
+
+ l += FREEBSD_EMPTYSEL;
+
+ /* Initialize TID for this CPU. */
+
+ my_tids[t->td_oncpu].tid_selector = FREEBSD_EMPTYSEL;
+ my_tids[t->td_oncpu].tid_self = &my_tids[t->td_oncpu];
+
+ /* Set up new GDT entry. */
+
+ l->x_lolimit = sizeof(struct tid);
+ l->x_hilimit = SEGFLAGHI_GRAN|SEGFLAGHI_BIG;
+ l->x_base0 = (vm_offset_t)(&my_tids[t->td_oncpu]) & 0xFFFF;
+ l->x_base1 = ((vm_offset_t)(&my_tids[t->td_oncpu]) >> 16) & 0xFF;
+ l->x_base2 = ((vm_offset_t)(&my_tids[t->td_oncpu]) >> 24) & 0xFF;
+ l->x_flags = SEGFLAGLO_PRESENT|SEGFLAGLO_CD|SEGFLAGLO_WRITEABLE;
+
+ /* Update the GDT. */
+
+ x86_setldt(&gtable, ltable);
+
+ mtx_unlock_spin(&sched_lock);
+
+ /* Whew. */
+
+ return;
+}
+
+#endif /* __i386__ */
int
windrv_unwrap(func)
funcptr func;
{
-#ifdef __amd64__
free(func, M_DEVBUF);
-#endif /* __amd64__ */
+
return(0);
}
diff --git a/sys/compat/ndis/ndis_var.h b/sys/compat/ndis/ndis_var.h
index 7221862..ad67509 100644
--- a/sys/compat/ndis/ndis_var.h
+++ b/sys/compat/ndis/ndis_var.h
@@ -878,7 +878,7 @@ struct ndis_timer {
typedef struct ndis_timer ndis_timer;
-typedef __stdcall void (*ndis_timer_function)(void *, void *, void *, void *);
+typedef void (*ndis_timer_function)(void *, void *, void *, void *);
struct ndis_miniport_timer {
struct ktimer nmt_ktimer;
@@ -1497,7 +1497,7 @@ typedef void (*ndis_allocdone_handler)(ndis_handle, void *,
ndis_physaddr *, uint32_t, void *);
typedef uint8_t (*ndis_checkforhang_handler)(ndis_handle);
-typedef __stdcall ndis_status (*driver_entry)(void *, unicode_string *);
+typedef ndis_status (*driver_entry)(void *, unicode_string *);
extern image_patch_table ndis_functbl[];
@@ -1593,16 +1593,16 @@ extern void ndis_thresume(struct proc *);
extern int ndis_strcasecmp(const char *, const char *);
extern int ndis_strncasecmp(const char *, const char *, size_t);
-__stdcall extern uint32_t NdisAddDevice(driver_object *, device_object *);
-__stdcall extern void NdisAllocatePacketPool(ndis_status *,
+extern uint32_t NdisAddDevice(driver_object *, device_object *);
+extern void NdisAllocatePacketPool(ndis_status *,
ndis_handle *, uint32_t, uint32_t);
-__stdcall extern void NdisAllocatePacketPoolEx(ndis_status *,
+extern void NdisAllocatePacketPoolEx(ndis_status *,
ndis_handle *, uint32_t, uint32_t, uint32_t);
-__stdcall extern uint32_t NdisPacketPoolUsage(ndis_handle);
-__stdcall extern void NdisFreePacketPool(ndis_handle);
-__stdcall extern void NdisAllocatePacket(ndis_status *,
+extern uint32_t NdisPacketPoolUsage(ndis_handle);
+extern void NdisFreePacketPool(ndis_handle);
+extern void NdisAllocatePacket(ndis_status *,
ndis_packet **, ndis_handle);
-__stdcall extern void NdisFreePacket(ndis_packet *);
+extern void NdisFreePacket(ndis_packet *);
__END_DECLS
diff --git a/sys/compat/ndis/ntoskrnl_var.h b/sys/compat/ndis/ntoskrnl_var.h
index 3928db8..55e3c1e 100644
--- a/sys/compat/ndis/ntoskrnl_var.h
+++ b/sys/compat/ndis/ntoskrnl_var.h
@@ -351,7 +351,7 @@ typedef struct nt_kevent nt_kevent;
/* Kernel defered procedure call (i.e. timer callback) */
struct kdpc;
-typedef __stdcall void (*kdpc_func)(struct kdpc *, void *, void *, void *);
+typedef void (*kdpc_func)(struct kdpc *, void *, void *, void *);
struct kdpc {
uint16_t k_type;
@@ -808,9 +808,9 @@ struct kapc {
typedef struct kapc kapc;
-typedef __stdcall uint32_t (*completion_func)(device_object *,
+typedef uint32_t (*completion_func)(device_object *,
struct irp *, void *);
-typedef __stdcall uint32_t (*cancel_func)(device_object *,
+typedef uint32_t (*cancel_func)(device_object *,
struct irp *);
struct io_stack_location {
@@ -933,8 +933,7 @@ struct irp {
typedef struct irp irp;
#define InterlockedExchangePointer(dst, val) \
- (void *)FASTCALL2(InterlockedExchange, (uint32_t *)(dst), \
- (uintptr_t)(val))
+ (void *)InterlockedExchange((uint32_t *)(dst), (uintptr_t)(val))
#define IoSizeOfIrp(ssize) \
((uint16_t) (sizeof(irp) + ((ssize) * (sizeof(io_stack_location)))))
@@ -991,7 +990,7 @@ typedef struct irp irp;
#define IoRequestDpc(dobj, irp, ctx) \
KeInsertQueueDpc(&(dobj)->do_dpc, irp, ctx)
-typedef __stdcall uint32_t (*driver_dispatch)(device_object *, irp *);
+typedef uint32_t (*driver_dispatch)(device_object *, irp *);
/*
* The driver_object is allocated once for each driver that's loaded
@@ -1153,6 +1152,16 @@ typedef struct driver_object driver_object;
*/
#define NDIS_KSTACK_PAGES 8
+/*
+ * Different kinds of function wrapping we can do.
+ */
+
+#define WINDRV_WRAP_STDCALL 1
+#define WINDRV_WRAP_FASTCALL 2
+#define WINDRV_WRAP_REGPARM 3
+#define WINDRV_WRAP_CDECL 4
+#define WINDRV_WRAP_AMD64 5
+
extern image_patch_table ntoskrnl_functbl[];
typedef void (*funcptr)(void);
@@ -1166,74 +1175,74 @@ extern int windrv_create_pdo(driver_object *, device_t);
extern void windrv_destroy_pdo(driver_object *, device_t);
extern device_object *windrv_find_pdo(driver_object *, device_t);
extern int windrv_bus_attach(driver_object *, char *);
-extern int windrv_wrap(funcptr, funcptr *);
+extern int windrv_wrap(funcptr, funcptr *, int, int);
extern int windrv_unwrap(funcptr);
+extern void ctxsw_utow(void);
+extern void ctxsw_wtou(void);
extern int ntoskrnl_libinit(void);
extern int ntoskrnl_libfini(void);
-__stdcall extern void KeInitializeDpc(kdpc *, void *, void *);
-__stdcall extern uint8_t KeInsertQueueDpc(kdpc *, void *, void *);
-__stdcall extern uint8_t KeRemoveQueueDpc(kdpc *);
-__stdcall extern void KeInitializeTimer(ktimer *);
-__stdcall extern void KeInitializeTimerEx(ktimer *, uint32_t);
-__stdcall extern uint8_t KeSetTimer(ktimer *, int64_t, kdpc *);
-__stdcall extern uint8_t KeSetTimerEx(ktimer *, int64_t, uint32_t, kdpc *);
-__stdcall extern uint8_t KeCancelTimer(ktimer *);
-__stdcall extern uint8_t KeReadStateTimer(ktimer *);
-__stdcall extern uint32_t KeWaitForSingleObject(nt_dispatch_header *, uint32_t,
+extern void KeInitializeDpc(kdpc *, void *, void *);
+extern uint8_t KeInsertQueueDpc(kdpc *, void *, void *);
+extern uint8_t KeRemoveQueueDpc(kdpc *);
+extern void KeInitializeTimer(ktimer *);
+extern void KeInitializeTimerEx(ktimer *, uint32_t);
+extern uint8_t KeSetTimer(ktimer *, int64_t, kdpc *);
+extern uint8_t KeSetTimerEx(ktimer *, int64_t, uint32_t, kdpc *);
+extern uint8_t KeCancelTimer(ktimer *);
+extern uint8_t KeReadStateTimer(ktimer *);
+extern uint32_t KeWaitForSingleObject(nt_dispatch_header *, uint32_t,
uint32_t, uint8_t, int64_t *);
-__stdcall extern void KeInitializeEvent(nt_kevent *, uint32_t, uint8_t);
-__stdcall extern void KeClearEvent(nt_kevent *);
-__stdcall extern uint32_t KeReadStateEvent(nt_kevent *);
-__stdcall extern uint32_t KeSetEvent(nt_kevent *, uint32_t, uint8_t);
-__stdcall extern uint32_t KeResetEvent(nt_kevent *);
+extern void KeInitializeEvent(nt_kevent *, uint32_t, uint8_t);
+extern void KeClearEvent(nt_kevent *);
+extern uint32_t KeReadStateEvent(nt_kevent *);
+extern uint32_t KeSetEvent(nt_kevent *, uint32_t, uint8_t);
+extern uint32_t KeResetEvent(nt_kevent *);
#ifdef __i386__
-__fastcall extern void KefAcquireSpinLockAtDpcLevel(REGARGS1(kspin_lock *));
-__fastcall extern void KefReleaseSpinLockFromDpcLevel(REGARGS1(kspin_lock *));
-__stdcall extern uint8_t KeAcquireSpinLockRaiseToDpc(kspin_lock *);
+extern void KefAcquireSpinLockAtDpcLevel(kspin_lock *);
+extern void KefReleaseSpinLockFromDpcLevel(kspin_lock *);
+extern uint8_t KeAcquireSpinLockRaiseToDpc(kspin_lock *);
#else
-__stdcall extern void KeAcquireSpinLockAtDpcLevel(kspin_lock *);
-__stdcall extern void KeReleaseSpinLockFromDpcLevel(kspin_lock *);
+extern void KeAcquireSpinLockAtDpcLevel(kspin_lock *);
+extern void KeReleaseSpinLockFromDpcLevel(kspin_lock *);
#endif
-__stdcall extern void KeInitializeSpinLock(kspin_lock *);
-__fastcall extern uintptr_t InterlockedExchange(REGARGS2(volatile uint32_t *,
- uintptr_t));
-__stdcall extern void *ExAllocatePoolWithTag(uint32_t, size_t, uint32_t);
-__stdcall extern void ExFreePool(void *);
-__stdcall extern uint32_t IoAllocateDriverObjectExtension(driver_object *,
+extern void KeInitializeSpinLock(kspin_lock *);
+extern uintptr_t InterlockedExchange(volatile uint32_t *,
+ uintptr_t);
+extern void *ExAllocatePoolWithTag(uint32_t, size_t, uint32_t);
+extern void ExFreePool(void *);
+extern uint32_t IoAllocateDriverObjectExtension(driver_object *,
void *, uint32_t, void **);
-__stdcall extern void *IoGetDriverObjectExtension(driver_object *, void *);
-__stdcall extern uint32_t IoCreateDevice(driver_object *, uint32_t,
+extern void *IoGetDriverObjectExtension(driver_object *, void *);
+extern uint32_t IoCreateDevice(driver_object *, uint32_t,
unicode_string *, uint32_t, uint32_t, uint8_t, device_object **);
-__stdcall extern void IoDeleteDevice(device_object *);
-__stdcall extern device_object *IoGetAttachedDevice(device_object *);
-__fastcall extern uint32_t IofCallDriver(REGARGS2(device_object *, irp *));
-__fastcall extern void IofCompleteRequest(REGARGS2(irp *, uint8_t));
-__stdcall extern void IoAcquireCancelSpinLock(uint8_t *);
-__stdcall extern void IoReleaseCancelSpinLock(uint8_t);
-__stdcall extern uint8_t IoCancelIrp(irp *);
-__stdcall extern void IoDetachDevice(device_object *);
-__stdcall extern device_object *IoAttachDeviceToDeviceStack(device_object *,
+extern void IoDeleteDevice(device_object *);
+extern device_object *IoGetAttachedDevice(device_object *);
+extern uint32_t IofCallDriver(device_object *, irp *);
+extern void IofCompleteRequest(irp *, uint8_t);
+extern void IoAcquireCancelSpinLock(uint8_t *);
+extern void IoReleaseCancelSpinLock(uint8_t);
+extern uint8_t IoCancelIrp(irp *);
+extern void IoDetachDevice(device_object *);
+extern device_object *IoAttachDeviceToDeviceStack(device_object *,
device_object *);
-__stdcall mdl *IoAllocateMdl(void *, uint32_t, uint8_t, uint8_t, irp *);
-__stdcall void IoFreeMdl(mdl *);
+mdl *IoAllocateMdl(void *, uint32_t, uint8_t, uint8_t, irp *);
+void IoFreeMdl(mdl *);
-#define IoCallDriver(a, b) FASTCALL2(IofCallDriver, a, b)
-#define IoCompleteRequest(a, b) FASTCALL2(IofCompleteRequest, a, b)
+#define IoCallDriver(a, b) IofCallDriver(a, b)
+#define IoCompleteRequest(a, b) IofCompleteRequest(a, b)
/*
* On the Windows x86 arch, KeAcquireSpinLock() and KeReleaseSpinLock()
* routines live in the HAL. We try to imitate this behavior.
*/
#ifdef __i386__
-#define KeAcquireSpinLock(a, b) *(b) = FASTCALL1(KfAcquireSpinLock, a)
-#define KeReleaseSpinLock(a, b) FASTCALL2(KfReleaseSpinLock, a, b)
-#define KeRaiseIrql(a) FASTCALL1(KfRaiseIrql, a)
-#define KeLowerIrql(a) FASTCALL1(KfLowerIrql, a)
-#define KeAcquireSpinLockAtDpcLevel(a) \
- FASTCALL1(KefAcquireSpinLockAtDpcLevel, a)
-#define KeReleaseSpinLockFromDpcLevel(a) \
- FASTCALL1(KefReleaseSpinLockFromDpcLevel, a)
+#define KeAcquireSpinLock(a, b) *(b) = KfAcquireSpinLock(a)
+#define KeReleaseSpinLock(a, b) KfReleaseSpinLock(a, b)
+#define KeRaiseIrql(a) KfRaiseIrql(a)
+#define KeLowerIrql(a) KfLowerIrql(a)
+#define KeAcquireSpinLockAtDpcLevel(a) KefAcquireSpinLockAtDpcLevel(a)
+#define KeReleaseSpinLockFromDpcLevel(a) KefReleaseSpinLockFromDpcLevel(a)
#endif /* __i386__ */
#ifdef __amd64__
diff --git a/sys/compat/ndis/pe_var.h b/sys/compat/ndis/pe_var.h
index cfce36a..1717f32 100644
--- a/sys/compat/ndis/pe_var.h
+++ b/sys/compat/ndis/pe_var.h
@@ -407,80 +407,13 @@ struct image_patch_table {
char *ipt_name;
void (*ipt_func)(void);
void (*ipt_wrap)(void);
+ int ipt_argcnt;
+ int ipt_ftype;
};
typedef struct image_patch_table image_patch_table;
/*
- * Note: Windows uses the _stdcall calling convention. This means
- * that the callback functions provided in the function table must
- * be declared using __attribute__((__stdcall__)), otherwise the
- * Windows code will likely screw up the %esp register and cause
- * us to jump to an invalid address when it returns.
- */
-
-#ifdef __amd64__
-#define __stdcall
-#define __regcall
-#define __fastcall
-#define REGARGS1(decl1) decl1
-#define REGARGS2(decl1, decl2) decl1, decl2
-#define REGCALL1(arg1) arg1
-#define REGCALL2(arg1, arg2) arg1, arg2
-#else
-#define __stdcall __attribute__((__stdcall__))
-#define __regcall __attribute__((__regparm__(3)))
-#define __fastcall __stdcall __regcall
-#define REGARGS1(decl1) int dummy1, int dummy2, decl1
-#define REGARGS2(decl1, decl2) int dummy1, decl2, decl1
-#define REGCALL1(arg1) 0, 0, arg1
-#define REGCALL2(arg1, arg2) 0, arg2, arg1
-#endif
-
-
-/*
- * This mess allows us to call a _fastcall style routine with our
- * version of gcc, which lacks __attribute__((__fastcall__)). Only
- * has meaning on x86; everywhere else, it's a no-op.
- */
-
-#ifdef __i386__
-typedef __fastcall int (*fcall1)(REGARGS1(uint32_t));
-typedef __fastcall int (*fcall2)(REGARGS2(uint32_t, uint32_t));
-typedef __fastcall int (*fcall3)(REGARGS2(uint32_t, uint32_t), uint32_t);
-
-static __inline uint32_t
-fastcall1(fcall1 f, uint32_t a)
-{
- return(f(REGCALL1(a)));
-}
-
-static __inline uint32_t
-fastcall2(fcall2 f, uint32_t a, uint32_t b)
-{
- return(f(REGCALL2(a, b)));
-}
-
-static __inline uint32_t
-fastcall3(fcall3 f, uint32_t a, uint32_t b, uint32_t c)
-{
- return(f(REGCALL2(a, b), c));
-}
-
-#define FASTCALL1(f, a) \
- fastcall1((fcall1)(f), (uint32_t)(a))
-#define FASTCALL2(f, a, b) \
- fastcall2((fcall2)(f), (uint32_t)(a), (uint32_t)(b))
-#define FASTCALL3(f, a, b, c) \
- fastcall3((fcall3)(f), (uint32_t)(a), (uint32_t)(b), (uint32_t)(c))
-#else
-#define FASTCALL1(f, a) (f)((a))
-#define FASTCALL2(f, a, b) (f)((a), (b))
-#define FASTCALL3(f, a, b, c) (f)((a), (b), (c))
-#endif /* __i386__ */
-
-
-/*
* AMD64 support. Microsoft uses a different calling convention
* than everyone else on the amd64 platform. Sadly, gcc has no
* built-in support for it (yet).
@@ -536,21 +469,55 @@ extern uint64_t x86_64_call6(void *, uint64_t, uint64_t, uint64_t, uint64_t,
x86_64_call6((fn), (uint64_t)(a), (uint64_t)(b), \
(uint64_t)(c), (uint64_t)(d), (uint64_t)(e), (uint64_t)(f))
-#else /* __amd64__ */
+#endif /* __amd64__ */
-#define MSCALL1(fn, a) (fn)((a))
-#define MSCALL2(fn, a, b) (fn)((a), (b))
-#define MSCALL3(fn, a, b, c) (fn)((a), (b), (c))
-#define MSCALL4(fn, a, b, c, d) (fn)((a), (b), (c), (d))
-#define MSCALL5(fn, a, b, c, d, e) (fn)((a), (b), (c), (d), (e))
-#define MSCALL6(fn, a, b, c, d, e, f) (fn)((a), (b), (c), (d), (e), (f))
+#ifdef __i386__
-#endif /* __amd64__ */
+extern uint32_t x86_stdcall_call(void *, int, ...);
+
+#define MSCALL1(fn, a) x86_stdcall_call(fn, 1, (a))
+#define MSCALL2(fn, a, b) x86_stdcall_call(fn, 2, (a), (b))
+#define MSCALL3(fn, a, b, c) x86_stdcall_call(fn, 3, (a), (b), (c))
+#define MSCALL4(fn, a, b, c, d) x86_stdcall_call(fn, 4, (a), (b), (c), (d))
+#define MSCALL5(fn, a, b, c, d, e) \
+ x86_stdcall_call(fn, 5, (a), (b), (c), (d), (e))
+#define MSCALL6(fn, a, b, c, d, e, f) \
+ x86_stdcall_call(fn, 6, (a), (b), (c), (d), (e), (f))
+
+#endif /* __i386__ */
#define FUNC void(*)(void)
-#define IMPORT_FUNC(x) { #x, (FUNC)x, NULL }
-#define IMPORT_FUNC_MAP(x, y) { #x, (FUNC)y, NULL }
+
+#ifdef __i386__
+#define IMPORT_SFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_STDCALL }
+#define IMPORT_SFUNC_MAP(x, y, z) \
+ { #x, (FUNC)y, NULL, z, WINDRV_WRAP_STDCALL }
+#define IMPORT_FFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_FASTCALL }
+#define IMPORT_FFUNC_MAP(x, y, z) \
+ { #x, (FUNC)y, NULL, z, WINDRV_WRAP_FASTCALL }
+#define IMPORT_RFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_REGPARM }
+#define IMPORT_RFUNC_MAP(x, y, z) \
+ { #x, (FUNC)y, NULL, z, WINDRV_WRAP_REGPARM }
+#define IMPORT_CFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_CDECL }
+#define IMPORT_CFUNC_MAP(x, y, z) \
+ { #x, (FUNC)y, NULL, z, WINDRV_WRAP_CDECL }
+#endif /* __i386__ */
+
+#ifdef __amd64__
+#define IMPORT_SFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
+#define IMPORT_SFUNC_MAP(x, y, z) \
+ { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
+#define IMPORT_FFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
+#define IMPORT_FFUNC_MAP(x, y, z) \
+ { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
+#define IMPORT_RFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
+#define IMPORT_RFUNC_MAP(x, y, z) \
+ { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
+#define IMPORT_CFUNC(x, y) { #x, (FUNC)x, NULL, y, WINDRV_WRAP_AMD64 }
+#define IMPORT_CFUNC_MAP(x, y, z) \
+ { #x, (FUNC)y, NULL, z, WINDRV_WRAP_AMD64 }
+#endif /* __amd64__ */
__BEGIN_DECLS
extern int pe_get_dos_header(vm_offset_t, image_dos_header *);
diff --git a/sys/compat/ndis/subr_hal.c b/sys/compat/ndis/subr_hal.c
index 6389771..b4170f4 100644
--- a/sys/compat/ndis/subr_hal.c
+++ b/sys/compat/ndis/subr_hal.c
@@ -58,27 +58,27 @@ __FBSDID("$FreeBSD$");
#include <compat/ndis/ntoskrnl_var.h>
#include <compat/ndis/hal_var.h>
-__stdcall static void KeStallExecutionProcessor(uint32_t);
-__stdcall static void WRITE_PORT_BUFFER_ULONG(uint32_t *,
+static void KeStallExecutionProcessor(uint32_t);
+static void WRITE_PORT_BUFFER_ULONG(uint32_t *,
uint32_t *, uint32_t);
-__stdcall static void WRITE_PORT_BUFFER_USHORT(uint16_t *,
+static void WRITE_PORT_BUFFER_USHORT(uint16_t *,
uint16_t *, uint32_t);
-__stdcall static void WRITE_PORT_BUFFER_UCHAR(uint8_t *,
+static void WRITE_PORT_BUFFER_UCHAR(uint8_t *,
uint8_t *, uint32_t);
-__stdcall static void WRITE_PORT_ULONG(uint32_t *, uint32_t);
-__stdcall static void WRITE_PORT_USHORT(uint16_t *, uint16_t);
-__stdcall static void WRITE_PORT_UCHAR(uint8_t *, uint8_t);
-__stdcall static uint32_t READ_PORT_ULONG(uint32_t *);
-__stdcall static uint16_t READ_PORT_USHORT(uint16_t *);
-__stdcall static uint8_t READ_PORT_UCHAR(uint8_t *);
-__stdcall static void READ_PORT_BUFFER_ULONG(uint32_t *,
+static void WRITE_PORT_ULONG(uint32_t *, uint32_t);
+static void WRITE_PORT_USHORT(uint16_t *, uint16_t);
+static void WRITE_PORT_UCHAR(uint8_t *, uint8_t);
+static uint32_t READ_PORT_ULONG(uint32_t *);
+static uint16_t READ_PORT_USHORT(uint16_t *);
+static uint8_t READ_PORT_UCHAR(uint8_t *);
+static void READ_PORT_BUFFER_ULONG(uint32_t *,
uint32_t *, uint32_t);
-__stdcall static void READ_PORT_BUFFER_USHORT(uint16_t *,
+static void READ_PORT_BUFFER_USHORT(uint16_t *,
uint16_t *, uint32_t);
-__stdcall static void READ_PORT_BUFFER_UCHAR(uint8_t *,
+static void READ_PORT_BUFFER_UCHAR(uint8_t *,
uint8_t *, uint32_t);
-__stdcall static uint64_t KeQueryPerformanceCounter(uint64_t *);
-__stdcall static void dummy (void);
+static uint64_t KeQueryPerformanceCounter(uint64_t *);
+static void dummy (void);
extern struct mtx_pool *ndis_mtxpool;
@@ -90,7 +90,8 @@ hal_libinit()
patch = hal_functbl;
while (patch->ipt_func != NULL) {
windrv_wrap((funcptr)patch->ipt_func,
- (funcptr *)&patch->ipt_wrap);
+ (funcptr *)&patch->ipt_wrap,
+ patch->ipt_argcnt, patch->ipt_ftype);
patch++;
}
@@ -111,7 +112,7 @@ hal_libfini()
return(0);
}
-__stdcall static void
+static void
KeStallExecutionProcessor(usecs)
uint32_t usecs;
{
@@ -119,7 +120,7 @@ KeStallExecutionProcessor(usecs)
return;
}
-__stdcall static void
+static void
WRITE_PORT_ULONG(port, val)
uint32_t *port;
uint32_t val;
@@ -128,7 +129,7 @@ WRITE_PORT_ULONG(port, val)
return;
}
-__stdcall static void
+static void
WRITE_PORT_USHORT(port, val)
uint16_t *port;
uint16_t val;
@@ -137,7 +138,7 @@ WRITE_PORT_USHORT(port, val)
return;
}
-__stdcall static void
+static void
WRITE_PORT_UCHAR(port, val)
uint8_t *port;
uint8_t val;
@@ -146,7 +147,7 @@ WRITE_PORT_UCHAR(port, val)
return;
}
-__stdcall static void
+static void
WRITE_PORT_BUFFER_ULONG(port, val, cnt)
uint32_t *port;
uint32_t *val;
@@ -157,7 +158,7 @@ WRITE_PORT_BUFFER_ULONG(port, val, cnt)
return;
}
-__stdcall static void
+static void
WRITE_PORT_BUFFER_USHORT(port, val, cnt)
uint16_t *port;
uint16_t *val;
@@ -168,7 +169,7 @@ WRITE_PORT_BUFFER_USHORT(port, val, cnt)
return;
}
-__stdcall static void
+static void
WRITE_PORT_BUFFER_UCHAR(port, val, cnt)
uint8_t *port;
uint8_t *val;
@@ -179,28 +180,28 @@ WRITE_PORT_BUFFER_UCHAR(port, val, cnt)
return;
}
-__stdcall static uint16_t
+static uint16_t
READ_PORT_USHORT(port)
uint16_t *port;
{
return(bus_space_read_2(NDIS_BUS_SPACE_IO, 0x0, (bus_size_t)port));
}
-__stdcall static uint32_t
+static uint32_t
READ_PORT_ULONG(port)
uint32_t *port;
{
return(bus_space_read_4(NDIS_BUS_SPACE_IO, 0x0, (bus_size_t)port));
}
-__stdcall static uint8_t
+static uint8_t
READ_PORT_UCHAR(port)
uint8_t *port;
{
return(bus_space_read_1(NDIS_BUS_SPACE_IO, 0x0, (bus_size_t)port));
}
-__stdcall static void
+static void
READ_PORT_BUFFER_ULONG(port, val, cnt)
uint32_t *port;
uint32_t *val;
@@ -211,7 +212,7 @@ READ_PORT_BUFFER_ULONG(port, val, cnt)
return;
}
-__stdcall static void
+static void
READ_PORT_BUFFER_USHORT(port, val, cnt)
uint16_t *port;
uint16_t *val;
@@ -222,7 +223,7 @@ READ_PORT_BUFFER_USHORT(port, val, cnt)
return;
}
-__stdcall static void
+static void
READ_PORT_BUFFER_UCHAR(port, val, cnt)
uint8_t *port;
uint8_t *val;
@@ -286,8 +287,9 @@ READ_PORT_BUFFER_UCHAR(port, val, cnt)
* or HIGH_LEVEL, we panic.
*/
-__fastcall uint8_t
-KfAcquireSpinLock(REGARGS1(kspin_lock *lock))
+uint8_t
+KfAcquireSpinLock(lock)
+ kspin_lock *lock;
{
uint8_t oldirql;
@@ -301,8 +303,10 @@ KfAcquireSpinLock(REGARGS1(kspin_lock *lock))
return(oldirql);
}
-__fastcall void
-KfReleaseSpinLock(REGARGS2(kspin_lock *lock, uint8_t newirql))
+void
+KfReleaseSpinLock(lock, newirql)
+ kspin_lock *lock;
+ uint8_t newirql;
{
KeReleaseSpinLockFromDpcLevel(lock);
KeLowerIrql(newirql);
@@ -310,15 +314,15 @@ KfReleaseSpinLock(REGARGS2(kspin_lock *lock, uint8_t newirql))
return;
}
-__stdcall uint8_t
-KeGetCurrentIrql(void)
+ uint8_t
+KeGetCurrentIrql()
{
if (AT_DISPATCH_LEVEL(curthread))
return(DISPATCH_LEVEL);
return(PASSIVE_LEVEL);
}
-__stdcall static uint64_t
+static uint64_t
KeQueryPerformanceCounter(freq)
uint64_t *freq;
{
@@ -328,8 +332,9 @@ KeQueryPerformanceCounter(freq)
return((uint64_t)ticks);
}
-__fastcall uint8_t
-KfRaiseIrql(REGARGS1(uint8_t irql))
+uint8_t
+KfRaiseIrql(irql)
+ uint8_t irql;
{
uint8_t oldirql;
@@ -350,8 +355,9 @@ KfRaiseIrql(REGARGS1(uint8_t irql))
return(oldirql);
}
-__fastcall void
-KfLowerIrql(REGARGS1(uint8_t oldirql))
+void
+KfLowerIrql(oldirql)
+ uint8_t oldirql;
{
if (oldirql == DISPATCH_LEVEL)
return;
@@ -369,7 +375,6 @@ KfLowerIrql(REGARGS1(uint8_t oldirql))
return;
}
-__stdcall
static void dummy()
{
printf ("hal dummy called...\n");
@@ -377,25 +382,25 @@ static void dummy()
}
image_patch_table hal_functbl[] = {
- IMPORT_FUNC(KeStallExecutionProcessor),
- IMPORT_FUNC(WRITE_PORT_ULONG),
- IMPORT_FUNC(WRITE_PORT_USHORT),
- IMPORT_FUNC(WRITE_PORT_UCHAR),
- IMPORT_FUNC(WRITE_PORT_BUFFER_ULONG),
- IMPORT_FUNC(WRITE_PORT_BUFFER_USHORT),
- IMPORT_FUNC(WRITE_PORT_BUFFER_UCHAR),
- IMPORT_FUNC(READ_PORT_ULONG),
- IMPORT_FUNC(READ_PORT_USHORT),
- IMPORT_FUNC(READ_PORT_UCHAR),
- IMPORT_FUNC(READ_PORT_BUFFER_ULONG),
- IMPORT_FUNC(READ_PORT_BUFFER_USHORT),
- IMPORT_FUNC(READ_PORT_BUFFER_UCHAR),
- IMPORT_FUNC(KfAcquireSpinLock),
- IMPORT_FUNC(KfReleaseSpinLock),
- IMPORT_FUNC(KeGetCurrentIrql),
- IMPORT_FUNC(KeQueryPerformanceCounter),
- IMPORT_FUNC(KfLowerIrql),
- IMPORT_FUNC(KfRaiseIrql),
+ IMPORT_SFUNC(KeStallExecutionProcessor, 1),
+ IMPORT_SFUNC(WRITE_PORT_ULONG, 2),
+ IMPORT_SFUNC(WRITE_PORT_USHORT, 2),
+ IMPORT_SFUNC(WRITE_PORT_UCHAR, 2),
+ IMPORT_SFUNC(WRITE_PORT_BUFFER_ULONG, 3),
+ IMPORT_SFUNC(WRITE_PORT_BUFFER_USHORT, 3),
+ IMPORT_SFUNC(WRITE_PORT_BUFFER_UCHAR, 3),
+ IMPORT_SFUNC(READ_PORT_ULONG, 1),
+ IMPORT_SFUNC(READ_PORT_USHORT, 1),
+ IMPORT_SFUNC(READ_PORT_UCHAR, 1),
+ IMPORT_SFUNC(READ_PORT_BUFFER_ULONG, 2),
+ IMPORT_SFUNC(READ_PORT_BUFFER_USHORT, 2),
+ IMPORT_SFUNC(READ_PORT_BUFFER_UCHAR, 2),
+ IMPORT_FFUNC(KfAcquireSpinLock, 1),
+ IMPORT_FFUNC(KfReleaseSpinLock, 1),
+ IMPORT_SFUNC(KeGetCurrentIrql, 0),
+ IMPORT_SFUNC(KeQueryPerformanceCounter, 1),
+ IMPORT_FFUNC(KfLowerIrql, 1),
+ IMPORT_FFUNC(KfRaiseIrql, 1),
/*
* This last entry is a catch-all for any function we haven't
@@ -404,7 +409,7 @@ image_patch_table hal_functbl[] = {
* in this table.
*/
- { NULL, (FUNC)dummy, NULL },
+ { NULL, (FUNC)dummy, NULL, 0, WINDRV_WRAP_CDECL },
/* End of list. */
diff --git a/sys/compat/ndis/subr_ndis.c b/sys/compat/ndis/subr_ndis.c
index 1c3756f..992a539 100644
--- a/sys/compat/ndis/subr_ndis.c
+++ b/sys/compat/ndis/subr_ndis.c
@@ -112,180 +112,180 @@ extern struct nd_head ndis_devhead;
SYSCTL_STRING(_hw, OID_AUTO, ndis_filepath, CTLFLAG_RW, ndis_filepath,
MAXPATHLEN, "Path used by NdisOpenFile() to search for files");
-__stdcall static void NdisInitializeWrapper(ndis_handle *,
+static void NdisInitializeWrapper(ndis_handle *,
driver_object *, void *, void *);
-__stdcall static ndis_status NdisMRegisterMiniport(ndis_handle,
+static ndis_status NdisMRegisterMiniport(ndis_handle,
ndis_miniport_characteristics *, int);
-__stdcall static ndis_status NdisAllocateMemoryWithTag(void **,
+static ndis_status NdisAllocateMemoryWithTag(void **,
uint32_t, uint32_t);
-__stdcall static ndis_status NdisAllocateMemory(void **,
+static ndis_status NdisAllocateMemory(void **,
uint32_t, uint32_t, ndis_physaddr);
-__stdcall static void NdisFreeMemory(void *, uint32_t, uint32_t);
-__stdcall static ndis_status NdisMSetAttributesEx(ndis_handle, ndis_handle,
+static void NdisFreeMemory(void *, uint32_t, uint32_t);
+static ndis_status NdisMSetAttributesEx(ndis_handle, ndis_handle,
uint32_t, uint32_t, ndis_interface_type);
-__stdcall static void NdisOpenConfiguration(ndis_status *,
+static void NdisOpenConfiguration(ndis_status *,
ndis_handle *, ndis_handle);
-__stdcall static void NdisOpenConfigurationKeyByIndex(ndis_status *,
+static void NdisOpenConfigurationKeyByIndex(ndis_status *,
ndis_handle, uint32_t, ndis_unicode_string *, ndis_handle *);
-__stdcall static void NdisOpenConfigurationKeyByName(ndis_status *,
+static void NdisOpenConfigurationKeyByName(ndis_status *,
ndis_handle, ndis_unicode_string *, ndis_handle *);
static ndis_status ndis_encode_parm(ndis_miniport_block *,
struct sysctl_oid *, ndis_parm_type, ndis_config_parm **);
static ndis_status ndis_decode_parm(ndis_miniport_block *,
ndis_config_parm *, char *);
-__stdcall static void NdisReadConfiguration(ndis_status *, ndis_config_parm **,
+static void NdisReadConfiguration(ndis_status *, ndis_config_parm **,
ndis_handle, ndis_unicode_string *, ndis_parm_type);
-__stdcall static void NdisWriteConfiguration(ndis_status *, ndis_handle,
+static void NdisWriteConfiguration(ndis_status *, ndis_handle,
ndis_unicode_string *, ndis_config_parm *);
-__stdcall static void NdisCloseConfiguration(ndis_handle);
-__stdcall static void NdisAllocateSpinLock(ndis_spin_lock *);
-__stdcall static void NdisFreeSpinLock(ndis_spin_lock *);
-__stdcall static void NdisAcquireSpinLock(ndis_spin_lock *);
-__stdcall static void NdisReleaseSpinLock(ndis_spin_lock *);
-__stdcall static void NdisDprAcquireSpinLock(ndis_spin_lock *);
-__stdcall static void NdisDprReleaseSpinLock(ndis_spin_lock *);
-__stdcall static uint32_t NdisReadPciSlotInformation(ndis_handle, uint32_t,
+static void NdisCloseConfiguration(ndis_handle);
+static void NdisAllocateSpinLock(ndis_spin_lock *);
+static void NdisFreeSpinLock(ndis_spin_lock *);
+static void NdisAcquireSpinLock(ndis_spin_lock *);
+static void NdisReleaseSpinLock(ndis_spin_lock *);
+static void NdisDprAcquireSpinLock(ndis_spin_lock *);
+static void NdisDprReleaseSpinLock(ndis_spin_lock *);
+static uint32_t NdisReadPciSlotInformation(ndis_handle, uint32_t,
uint32_t, void *, uint32_t);
-__stdcall static uint32_t NdisWritePciSlotInformation(ndis_handle, uint32_t,
+static uint32_t NdisWritePciSlotInformation(ndis_handle, uint32_t,
uint32_t, void *, uint32_t);
static void NdisWriteErrorLogEntry(ndis_handle, ndis_error_code, uint32_t, ...);
static void ndis_map_cb(void *, bus_dma_segment_t *, int, int);
-__stdcall static void NdisMStartBufferPhysicalMapping(ndis_handle,
+static void NdisMStartBufferPhysicalMapping(ndis_handle,
ndis_buffer *, uint32_t, uint8_t, ndis_paddr_unit *, uint32_t *);
-__stdcall static void NdisMCompleteBufferPhysicalMapping(ndis_handle,
+static void NdisMCompleteBufferPhysicalMapping(ndis_handle,
ndis_buffer *, uint32_t);
-__stdcall static void NdisMInitializeTimer(ndis_miniport_timer *, ndis_handle,
+static void NdisMInitializeTimer(ndis_miniport_timer *, ndis_handle,
ndis_timer_function, void *);
-__stdcall static void NdisInitializeTimer(ndis_timer *,
+static void NdisInitializeTimer(ndis_timer *,
ndis_timer_function, void *);
-__stdcall static void NdisSetTimer(ndis_timer *, uint32_t);
-__stdcall static void NdisMSetPeriodicTimer(ndis_miniport_timer *, uint32_t);
-__stdcall static void NdisMCancelTimer(ndis_timer *, uint8_t *);
-__stdcall static void ndis_timercall(kdpc *, ndis_miniport_timer *,
+static void NdisSetTimer(ndis_timer *, uint32_t);
+static void NdisMSetPeriodicTimer(ndis_miniport_timer *, uint32_t);
+static void NdisMCancelTimer(ndis_timer *, uint8_t *);
+static void ndis_timercall(kdpc *, ndis_miniport_timer *,
void *, void *);
-__stdcall static void NdisMQueryAdapterResources(ndis_status *, ndis_handle,
+static void NdisMQueryAdapterResources(ndis_status *, ndis_handle,
ndis_resource_list *, uint32_t *);
-__stdcall static ndis_status NdisMRegisterIoPortRange(void **,
+static ndis_status NdisMRegisterIoPortRange(void **,
ndis_handle, uint32_t, uint32_t);
-__stdcall static void NdisMDeregisterIoPortRange(ndis_handle,
+static void NdisMDeregisterIoPortRange(ndis_handle,
uint32_t, uint32_t, void *);
-__stdcall static void NdisReadNetworkAddress(ndis_status *, void **,
+static void NdisReadNetworkAddress(ndis_status *, void **,
uint32_t *, ndis_handle);
-__stdcall static ndis_status NdisQueryMapRegisterCount(uint32_t, uint32_t *);
-__stdcall static ndis_status NdisMAllocateMapRegisters(ndis_handle,
+static ndis_status NdisQueryMapRegisterCount(uint32_t, uint32_t *);
+static ndis_status NdisMAllocateMapRegisters(ndis_handle,
uint32_t, uint8_t, uint32_t, uint32_t);
-__stdcall static void NdisMFreeMapRegisters(ndis_handle);
+static void NdisMFreeMapRegisters(ndis_handle);
static void ndis_mapshared_cb(void *, bus_dma_segment_t *, int, int);
-__stdcall static void NdisMAllocateSharedMemory(ndis_handle, uint32_t,
+static void NdisMAllocateSharedMemory(ndis_handle, uint32_t,
uint8_t, void **, ndis_physaddr *);
static void ndis_asyncmem_complete(void *);
-__stdcall static ndis_status NdisMAllocateSharedMemoryAsync(ndis_handle,
+static ndis_status NdisMAllocateSharedMemoryAsync(ndis_handle,
uint32_t, uint8_t, void *);
-__stdcall static void NdisMFreeSharedMemory(ndis_handle, uint32_t,
+static void NdisMFreeSharedMemory(ndis_handle, uint32_t,
uint8_t, void *, ndis_physaddr);
-__stdcall static ndis_status NdisMMapIoSpace(void **, ndis_handle,
+static ndis_status NdisMMapIoSpace(void **, ndis_handle,
ndis_physaddr, uint32_t);
-__stdcall static void NdisMUnmapIoSpace(ndis_handle, void *, uint32_t);
-__stdcall static uint32_t NdisGetCacheFillSize(void);
-__stdcall static uint32_t NdisMGetDmaAlignment(ndis_handle);
-__stdcall static ndis_status NdisMInitializeScatterGatherDma(ndis_handle,
+static void NdisMUnmapIoSpace(ndis_handle, void *, uint32_t);
+static uint32_t NdisGetCacheFillSize(void);
+static uint32_t NdisMGetDmaAlignment(ndis_handle);
+static ndis_status NdisMInitializeScatterGatherDma(ndis_handle,
uint8_t, uint32_t);
-__stdcall static void NdisUnchainBufferAtFront(ndis_packet *, ndis_buffer **);
-__stdcall static void NdisUnchainBufferAtBack(ndis_packet *, ndis_buffer **);
-__stdcall static void NdisAllocateBufferPool(ndis_status *,
+static void NdisUnchainBufferAtFront(ndis_packet *, ndis_buffer **);
+static void NdisUnchainBufferAtBack(ndis_packet *, ndis_buffer **);
+static void NdisAllocateBufferPool(ndis_status *,
ndis_handle *, uint32_t);
-__stdcall static void NdisFreeBufferPool(ndis_handle);
-__stdcall static void NdisAllocateBuffer(ndis_status *, ndis_buffer **,
+static void NdisFreeBufferPool(ndis_handle);
+static void NdisAllocateBuffer(ndis_status *, ndis_buffer **,
ndis_handle, void *, uint32_t);
-__stdcall static void NdisFreeBuffer(ndis_buffer *);
-__stdcall static uint32_t NdisBufferLength(ndis_buffer *);
-__stdcall static void NdisQueryBuffer(ndis_buffer *, void **, uint32_t *);
-__stdcall static void NdisQueryBufferSafe(ndis_buffer *, void **,
+static void NdisFreeBuffer(ndis_buffer *);
+static uint32_t NdisBufferLength(ndis_buffer *);
+static void NdisQueryBuffer(ndis_buffer *, void **, uint32_t *);
+static void NdisQueryBufferSafe(ndis_buffer *, void **,
uint32_t *, uint32_t);
-__stdcall static void *NdisBufferVirtualAddress(ndis_buffer *);
-__stdcall static void *NdisBufferVirtualAddressSafe(ndis_buffer *, uint32_t);
-__stdcall static void NdisAdjustBufferLength(ndis_buffer *, int);
-__stdcall static uint32_t NdisInterlockedIncrement(uint32_t *);
-__stdcall static uint32_t NdisInterlockedDecrement(uint32_t *);
-__stdcall static void NdisInitializeEvent(ndis_event *);
-__stdcall static void NdisSetEvent(ndis_event *);
-__stdcall static void NdisResetEvent(ndis_event *);
-__stdcall static uint8_t NdisWaitEvent(ndis_event *, uint32_t);
-__stdcall static ndis_status NdisUnicodeStringToAnsiString(ndis_ansi_string *,
+static void *NdisBufferVirtualAddress(ndis_buffer *);
+static void *NdisBufferVirtualAddressSafe(ndis_buffer *, uint32_t);
+static void NdisAdjustBufferLength(ndis_buffer *, int);
+static uint32_t NdisInterlockedIncrement(uint32_t *);
+static uint32_t NdisInterlockedDecrement(uint32_t *);
+static void NdisInitializeEvent(ndis_event *);
+static void NdisSetEvent(ndis_event *);
+static void NdisResetEvent(ndis_event *);
+static uint8_t NdisWaitEvent(ndis_event *, uint32_t);
+static ndis_status NdisUnicodeStringToAnsiString(ndis_ansi_string *,
ndis_unicode_string *);
-__stdcall static ndis_status
+static ndis_status
NdisAnsiStringToUnicodeString(ndis_unicode_string *,
ndis_ansi_string *);
-__stdcall static ndis_status NdisMPciAssignResources(ndis_handle,
+static ndis_status NdisMPciAssignResources(ndis_handle,
uint32_t, ndis_resource_list **);
-__stdcall static ndis_status NdisMRegisterInterrupt(ndis_miniport_interrupt *,
+static ndis_status NdisMRegisterInterrupt(ndis_miniport_interrupt *,
ndis_handle, uint32_t, uint32_t, uint8_t,
uint8_t, ndis_interrupt_mode);
-__stdcall static void NdisMDeregisterInterrupt(ndis_miniport_interrupt *);
-__stdcall static void NdisMRegisterAdapterShutdownHandler(ndis_handle, void *,
+static void NdisMDeregisterInterrupt(ndis_miniport_interrupt *);
+static void NdisMRegisterAdapterShutdownHandler(ndis_handle, void *,
ndis_shutdown_handler);
-__stdcall static void NdisMDeregisterAdapterShutdownHandler(ndis_handle);
-__stdcall static uint32_t NDIS_BUFFER_TO_SPAN_PAGES(ndis_buffer *);
-__stdcall static void NdisGetBufferPhysicalArraySize(ndis_buffer *,
+static void NdisMDeregisterAdapterShutdownHandler(ndis_handle);
+static uint32_t NDIS_BUFFER_TO_SPAN_PAGES(ndis_buffer *);
+static void NdisGetBufferPhysicalArraySize(ndis_buffer *,
uint32_t *);
-__stdcall static void NdisQueryBufferOffset(ndis_buffer *,
+static void NdisQueryBufferOffset(ndis_buffer *,
uint32_t *, uint32_t *);
-__stdcall static void NdisMSleep(uint32_t);
-__stdcall static uint32_t NdisReadPcmciaAttributeMemory(ndis_handle,
+static void NdisMSleep(uint32_t);
+static uint32_t NdisReadPcmciaAttributeMemory(ndis_handle,
uint32_t, void *, uint32_t);
-__stdcall static uint32_t NdisWritePcmciaAttributeMemory(ndis_handle,
+static uint32_t NdisWritePcmciaAttributeMemory(ndis_handle,
uint32_t, void *, uint32_t);
-__stdcall static list_entry *NdisInterlockedInsertHeadList(list_entry *,
+static list_entry *NdisInterlockedInsertHeadList(list_entry *,
list_entry *, ndis_spin_lock *);
-__stdcall static list_entry *NdisInterlockedRemoveHeadList(list_entry *,
+static list_entry *NdisInterlockedRemoveHeadList(list_entry *,
ndis_spin_lock *);
-__stdcall static list_entry *NdisInterlockedInsertTailList(list_entry *,
+static list_entry *NdisInterlockedInsertTailList(list_entry *,
list_entry *, ndis_spin_lock *);
-__stdcall static uint8_t
+static uint8_t
NdisMSynchronizeWithInterrupt(ndis_miniport_interrupt *,
void *, void *);
-__stdcall static void NdisGetCurrentSystemTime(uint64_t *);
-__stdcall static void NdisGetSystemUpTime(uint32_t *);
-__stdcall static void NdisInitializeString(ndis_unicode_string *, char *);
-__stdcall static void NdisInitAnsiString(ndis_ansi_string *, char *);
-__stdcall static void NdisInitUnicodeString(ndis_unicode_string *,
+static void NdisGetCurrentSystemTime(uint64_t *);
+static void NdisGetSystemUpTime(uint32_t *);
+static void NdisInitializeString(ndis_unicode_string *, char *);
+static void NdisInitAnsiString(ndis_ansi_string *, char *);
+static void NdisInitUnicodeString(ndis_unicode_string *,
uint16_t *);
-__stdcall static void NdisFreeString(ndis_unicode_string *);
-__stdcall static ndis_status NdisMRemoveMiniport(ndis_handle *);
-__stdcall static void NdisTerminateWrapper(ndis_handle, void *);
-__stdcall static void NdisMGetDeviceProperty(ndis_handle, device_object **,
+static void NdisFreeString(ndis_unicode_string *);
+static ndis_status NdisMRemoveMiniport(ndis_handle *);
+static void NdisTerminateWrapper(ndis_handle, void *);
+static void NdisMGetDeviceProperty(ndis_handle, device_object **,
device_object **, device_object **, cm_resource_list *,
cm_resource_list *);
-__stdcall static void NdisGetFirstBufferFromPacket(ndis_packet *,
+static void NdisGetFirstBufferFromPacket(ndis_packet *,
ndis_buffer **, void **, uint32_t *, uint32_t *);
-__stdcall static void NdisGetFirstBufferFromPacketSafe(ndis_packet *,
+static void NdisGetFirstBufferFromPacketSafe(ndis_packet *,
ndis_buffer **, void **, uint32_t *, uint32_t *, uint32_t);
static int ndis_find_sym(linker_file_t, char *, char *, caddr_t *);
-__stdcall static void NdisOpenFile(ndis_status *, ndis_handle *, uint32_t *,
+static void NdisOpenFile(ndis_status *, ndis_handle *, uint32_t *,
ndis_unicode_string *, ndis_physaddr);
-__stdcall static void NdisMapFile(ndis_status *, void **, ndis_handle);
-__stdcall static void NdisUnmapFile(ndis_handle);
-__stdcall static void NdisCloseFile(ndis_handle);
-__stdcall static uint8_t NdisSystemProcessorCount(void);
-__stdcall static void NdisMIndicateStatusComplete(ndis_handle);
-__stdcall static void NdisMIndicateStatus(ndis_handle, ndis_status,
+static void NdisMapFile(ndis_status *, void **, ndis_handle);
+static void NdisUnmapFile(ndis_handle);
+static void NdisCloseFile(ndis_handle);
+static uint8_t NdisSystemProcessorCount(void);
+static void NdisMIndicateStatusComplete(ndis_handle);
+static void NdisMIndicateStatus(ndis_handle, ndis_status,
void *, uint32_t);
static void ndis_workfunc(void *);
static funcptr ndis_findwrap(funcptr);
-__stdcall static ndis_status NdisScheduleWorkItem(ndis_work_item *);
-__stdcall static void NdisCopyFromPacketToPacket(ndis_packet *,
+static ndis_status NdisScheduleWorkItem(ndis_work_item *);
+static void NdisCopyFromPacketToPacket(ndis_packet *,
uint32_t, uint32_t, ndis_packet *, uint32_t, uint32_t *);
-__stdcall static void NdisCopyFromPacketToPacketSafe(ndis_packet *,
+static void NdisCopyFromPacketToPacketSafe(ndis_packet *,
uint32_t, uint32_t, ndis_packet *, uint32_t, uint32_t *, uint32_t);
-__stdcall static ndis_status NdisMRegisterDevice(ndis_handle,
+static ndis_status NdisMRegisterDevice(ndis_handle,
ndis_unicode_string *, ndis_unicode_string *, driver_dispatch **,
void **, ndis_handle *);
-__stdcall static ndis_status NdisMDeregisterDevice(ndis_handle);
-__stdcall static ndis_status
+static ndis_status NdisMDeregisterDevice(ndis_handle);
+static ndis_status
NdisMQueryAdapterInstanceName(ndis_unicode_string *,
ndis_handle);
-__stdcall static void NdisMRegisterUnloadHandler(ndis_handle, void *);
-__stdcall static void dummy(void);
+static void NdisMRegisterUnloadHandler(ndis_handle, void *);
+static void dummy(void);
/*
* Some really old drivers do not properly check the return value
@@ -307,7 +307,8 @@ ndis_libinit()
patch = ndis_functbl;
while (patch->ipt_func != NULL) {
windrv_wrap((funcptr)patch->ipt_func,
- (funcptr *)&patch->ipt_wrap);
+ (funcptr *)&patch->ipt_wrap,
+ patch->ipt_argcnt, patch->ipt_ftype);
patch++;
}
@@ -400,7 +401,7 @@ ndis_unicode_to_ascii(unicode, ulen, ascii)
* stuff on behalf of NDIS drivers. We register our own AddDevice
* routine here
*/
-__stdcall static void
+static void
NdisInitializeWrapper(wrapper, drv, path, unused)
ndis_handle *wrapper;
driver_object *drv;
@@ -432,7 +433,7 @@ NdisInitializeWrapper(wrapper, drv, path, unused)
return;
}
-__stdcall static void
+static void
NdisTerminateWrapper(handle, syspec)
ndis_handle handle;
void *syspec;
@@ -441,7 +442,7 @@ NdisTerminateWrapper(handle, syspec)
return;
}
-__stdcall static ndis_status
+static ndis_status
NdisMRegisterMiniport(handle, characteristics, len)
ndis_handle handle;
ndis_miniport_characteristics *characteristics;
@@ -480,7 +481,7 @@ NdisMRegisterMiniport(handle, characteristics, len)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static ndis_status
+static ndis_status
NdisAllocateMemoryWithTag(vaddr, len, tag)
void **vaddr;
uint32_t len;
@@ -497,7 +498,7 @@ NdisAllocateMemoryWithTag(vaddr, len, tag)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static ndis_status
+static ndis_status
NdisAllocateMemory(vaddr, len, flags, highaddr)
void **vaddr;
uint32_t len;
@@ -514,7 +515,7 @@ NdisAllocateMemory(vaddr, len, flags, highaddr)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
NdisFreeMemory(vaddr, len, flags)
void *vaddr;
uint32_t len;
@@ -528,7 +529,7 @@ NdisFreeMemory(vaddr, len, flags)
return;
}
-__stdcall static ndis_status
+static ndis_status
NdisMSetAttributesEx(adapter_handle, adapter_ctx, hangsecs,
flags, iftype)
ndis_handle adapter_handle;
@@ -551,7 +552,7 @@ NdisMSetAttributesEx(adapter_handle, adapter_ctx, hangsecs,
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
NdisOpenConfiguration(status, cfg, wrapctx)
ndis_status *status;
ndis_handle *cfg;
@@ -564,7 +565,7 @@ NdisOpenConfiguration(status, cfg, wrapctx)
return;
}
-__stdcall static void
+static void
NdisOpenConfigurationKeyByName(status, cfg, subkey, subhandle)
ndis_status *status;
ndis_handle cfg;
@@ -576,7 +577,7 @@ NdisOpenConfigurationKeyByName(status, cfg, subkey, subhandle)
return;
}
-__stdcall static void
+static void
NdisOpenConfigurationKeyByIndex(status, cfg, idx, subkey, subhandle)
ndis_status *status;
ndis_handle cfg;
@@ -682,7 +683,7 @@ ndis_strncasecmp(s1, s2, n)
return(0);
}
-__stdcall static void
+static void
NdisReadConfiguration(status, parm, cfg, key, type)
ndis_status *status;
ndis_config_parm **parm;
@@ -785,7 +786,7 @@ ndis_decode_parm(block, parm, val)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
NdisWriteConfiguration(status, cfg, key, parm)
ndis_status *status;
ndis_handle cfg;
@@ -837,7 +838,7 @@ NdisWriteConfiguration(status, cfg, key, parm)
return;
}
-__stdcall static void
+static void
NdisCloseConfiguration(cfg)
ndis_handle cfg;
{
@@ -847,7 +848,7 @@ NdisCloseConfiguration(cfg)
/*
* Initialize a Windows spinlock.
*/
-__stdcall static void
+static void
NdisAllocateSpinLock(lock)
ndis_spin_lock *lock;
{
@@ -865,7 +866,7 @@ NdisAllocateSpinLock(lock)
* the block of memory in which the spinlock resides. (Yes, ADMtek, I'm
* talking to you.)
*/
-__stdcall static void
+static void
NdisFreeSpinLock(lock)
ndis_spin_lock *lock;
{
@@ -880,7 +881,7 @@ NdisFreeSpinLock(lock)
* Acquire a spinlock from IRQL <= DISPATCH_LEVEL.
*/
-__stdcall static void
+static void
NdisAcquireSpinLock(lock)
ndis_spin_lock *lock;
{
@@ -892,7 +893,7 @@ NdisAcquireSpinLock(lock)
* Release a spinlock from IRQL == DISPATCH_LEVEL.
*/
-__stdcall static void
+static void
NdisReleaseSpinLock(lock)
ndis_spin_lock *lock;
{
@@ -903,7 +904,7 @@ NdisReleaseSpinLock(lock)
/*
* Acquire a spinlock when already running at IRQL == DISPATCH_LEVEL.
*/
-__stdcall static void
+static void
NdisDprAcquireSpinLock(lock)
ndis_spin_lock *lock;
{
@@ -914,7 +915,7 @@ NdisDprAcquireSpinLock(lock)
/*
* Release a spinlock without leaving IRQL == DISPATCH_LEVEL.
*/
-__stdcall static void
+static void
NdisDprReleaseSpinLock(lock)
ndis_spin_lock *lock;
{
@@ -922,7 +923,7 @@ NdisDprReleaseSpinLock(lock)
return;
}
-__stdcall static uint32_t
+static uint32_t
NdisReadPciSlotInformation(adapter, slot, offset, buf, len)
ndis_handle adapter;
uint32_t slot;
@@ -965,7 +966,7 @@ NdisReadPciSlotInformation(adapter, slot, offset, buf, len)
return(len);
}
-__stdcall static uint32_t
+static uint32_t
NdisWritePciSlotInformation(adapter, slot, offset, buf, len)
ndis_handle adapter;
uint32_t slot;
@@ -1061,7 +1062,7 @@ ndis_map_cb(arg, segs, nseg, error)
return;
}
-__stdcall static void
+static void
NdisMStartBufferPhysicalMapping(adapter, buf, mapreg, writedev, addrarray, arraysize)
ndis_handle adapter;
ndis_buffer *buf;
@@ -1103,7 +1104,7 @@ NdisMStartBufferPhysicalMapping(adapter, buf, mapreg, writedev, addrarray, array
return;
}
-__stdcall static void
+static void
NdisMCompleteBufferPhysicalMapping(adapter, buf, mapreg)
ndis_handle adapter;
ndis_buffer *buf;
@@ -1138,7 +1139,7 @@ NdisMCompleteBufferPhysicalMapping(adapter, buf, mapreg)
* never call this function.
*/
-__stdcall static void
+static void
NdisInitializeTimer(timer, func, ctx)
ndis_timer *timer;
ndis_timer_function func;
@@ -1150,7 +1151,7 @@ NdisInitializeTimer(timer, func, ctx)
return;
}
-__stdcall static void
+static void
ndis_timercall(dpc, timer, sysarg1, sysarg2)
kdpc *dpc;
ndis_miniport_timer *timer;
@@ -1192,7 +1193,7 @@ ndis_timercall(dpc, timer, sysarg1, sysarg2)
* SMP, you must acquire a lock as well, otherwise the other CPU is
* free to clobber you.
*/
-__stdcall static void
+static void
NdisMInitializeTimer(timer, handle, func, ctx)
ndis_miniport_timer *timer;
ndis_handle handle;
@@ -1222,7 +1223,7 @@ NdisMInitializeTimer(timer, handle, func, ctx)
* In Windows, there's both an NdisMSetTimer() and an NdisSetTimer(),
* but the former is just a macro wrapper around the latter.
*/
-__stdcall static void
+static void
NdisSetTimer(timer, msecs)
ndis_timer *timer;
uint32_t msecs;
@@ -1237,7 +1238,7 @@ NdisSetTimer(timer, msecs)
return;
}
-__stdcall static void
+static void
NdisMSetPeriodicTimer(timer, msecs)
ndis_miniport_timer *timer;
uint32_t msecs;
@@ -1255,7 +1256,7 @@ NdisMSetPeriodicTimer(timer, msecs)
* structure just to cancel a timer.
*/
-__stdcall static void
+static void
NdisMCancelTimer(timer, cancelled)
ndis_timer *timer;
uint8_t *cancelled;
@@ -1265,7 +1266,7 @@ NdisMCancelTimer(timer, cancelled)
return;
}
-__stdcall static void
+static void
NdisMQueryAdapterResources(status, adapter, list, buflen)
ndis_status *status;
ndis_handle adapter;
@@ -1293,7 +1294,7 @@ NdisMQueryAdapterResources(status, adapter, list, buflen)
return;
}
-__stdcall static ndis_status
+static ndis_status
NdisMRegisterIoPortRange(offset, adapter, port, numports)
void **offset;
ndis_handle adapter;
@@ -1321,7 +1322,7 @@ NdisMRegisterIoPortRange(offset, adapter, port, numports)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
NdisMDeregisterIoPortRange(adapter, port, numports, offset)
ndis_handle adapter;
uint32_t port;
@@ -1331,7 +1332,7 @@ NdisMDeregisterIoPortRange(adapter, port, numports, offset)
return;
}
-__stdcall static void
+static void
NdisReadNetworkAddress(status, addr, addrlen, adapter)
ndis_status *status;
void **addr;
@@ -1356,7 +1357,7 @@ NdisReadNetworkAddress(status, addr, addrlen, adapter)
return;
}
-__stdcall static ndis_status
+static ndis_status
NdisQueryMapRegisterCount(bustype, cnt)
uint32_t bustype;
uint32_t *cnt;
@@ -1365,7 +1366,7 @@ NdisQueryMapRegisterCount(bustype, cnt)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static ndis_status
+static ndis_status
NdisMAllocateMapRegisters(adapter, dmachannel, dmasize, physmapneeded, maxmap)
ndis_handle adapter;
uint32_t dmachannel;
@@ -1404,7 +1405,7 @@ NdisMAllocateMapRegisters(adapter, dmachannel, dmasize, physmapneeded, maxmap)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
NdisMFreeMapRegisters(adapter)
ndis_handle adapter;
{
@@ -1447,7 +1448,7 @@ ndis_mapshared_cb(arg, segs, nseg, error)
/*
* This maps to bus_dmamem_alloc().
*/
-__stdcall static void
+static void
NdisMAllocateSharedMemory(adapter, len, cached, vaddr, paddr)
ndis_handle adapter;
uint32_t len;
@@ -1536,7 +1537,7 @@ ndis_asyncmem_complete(arg)
struct ndis_allocwork *w;
void *vaddr;
ndis_physaddr paddr;
- __stdcall ndis_allocdone_handler donefunc;
+ ndis_allocdone_handler donefunc;
w = arg;
block = (ndis_miniport_block *)w->na_adapter;
@@ -1555,7 +1556,7 @@ ndis_asyncmem_complete(arg)
return;
}
-__stdcall static ndis_status
+static ndis_status
NdisMAllocateSharedMemoryAsync(adapter, len, cached, ctx)
ndis_handle adapter;
uint32_t len;
@@ -1589,7 +1590,7 @@ NdisMAllocateSharedMemoryAsync(adapter, len, cached, ctx)
return(NDIS_STATUS_PENDING);
}
-__stdcall static void
+static void
NdisMFreeSharedMemory(adapter, len, cached, vaddr, paddr)
ndis_handle adapter;
uint32_t len;
@@ -1634,7 +1635,7 @@ NdisMFreeSharedMemory(adapter, len, cached, vaddr, paddr)
return;
}
-__stdcall static ndis_status
+static ndis_status
NdisMMapIoSpace(vaddr, adapter, paddr, len)
void **vaddr;
ndis_handle adapter;
@@ -1665,7 +1666,7 @@ NdisMMapIoSpace(vaddr, adapter, paddr, len)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
NdisMUnmapIoSpace(adapter, vaddr, len)
ndis_handle adapter;
void *vaddr;
@@ -1674,13 +1675,13 @@ NdisMUnmapIoSpace(adapter, vaddr, len)
return;
}
-__stdcall static uint32_t
+static uint32_t
NdisGetCacheFillSize(void)
{
return(128);
}
-__stdcall static uint32_t
+static uint32_t
NdisMGetDmaAlignment(handle)
ndis_handle handle;
{
@@ -1698,7 +1699,7 @@ NdisMGetDmaAlignment(handle)
* method.
*/
-__stdcall static ndis_status
+static ndis_status
NdisMInitializeScatterGatherDma(adapter, is64, maxphysmap)
ndis_handle adapter;
uint8_t is64;
@@ -1727,7 +1728,7 @@ NdisMInitializeScatterGatherDma(adapter, is64, maxphysmap)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall void
+void
NdisAllocatePacketPool(status, pool, descnum, protrsvdlen)
ndis_status *status;
ndis_handle *pool;
@@ -1759,7 +1760,7 @@ NdisAllocatePacketPool(status, pool, descnum, protrsvdlen)
return;
}
-__stdcall void
+void
NdisAllocatePacketPoolEx(status, pool, descnum, oflowdescnum, protrsvdlen)
ndis_status *status;
ndis_handle *pool;
@@ -1771,7 +1772,7 @@ NdisAllocatePacketPoolEx(status, pool, descnum, oflowdescnum, protrsvdlen)
descnum + oflowdescnum, protrsvdlen));
}
-__stdcall uint32_t
+uint32_t
NdisPacketPoolUsage(pool)
ndis_handle pool;
{
@@ -1787,7 +1788,7 @@ NdisPacketPoolUsage(pool)
return(cnt);
}
-__stdcall void
+void
NdisFreePacketPool(pool)
ndis_handle pool;
{
@@ -1814,7 +1815,7 @@ NdisFreePacketPool(pool)
return;
}
-__stdcall void
+void
NdisAllocatePacket(status, packet, pool)
ndis_status *status;
ndis_packet **packet;
@@ -1858,8 +1859,7 @@ NdisAllocatePacket(status, packet, 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);
+ pkt->np_private.npp_packetooboffset = offsetof(ndis_packet, np_oob);
/*
* We must initialize the packet flags correctly in order
@@ -1880,7 +1880,7 @@ NdisAllocatePacket(status, packet, pool)
return;
}
-__stdcall void
+void
NdisFreePacket(packet)
ndis_packet *packet;
{
@@ -1916,7 +1916,7 @@ NdisFreePacket(packet)
return;
}
-__stdcall static void
+static void
NdisUnchainBufferAtFront(packet, buf)
ndis_packet *packet;
ndis_buffer **buf;
@@ -1941,7 +1941,7 @@ NdisUnchainBufferAtFront(packet, buf)
return;
}
-__stdcall static void
+static void
NdisUnchainBufferAtBack(packet, buf)
ndis_packet *packet;
ndis_buffer **buf;
@@ -1984,7 +1984,7 @@ NdisUnchainBufferAtBack(packet, buf)
* them, and IoAllocateMdl() just grabs them out of the heap.
*/
-__stdcall static void
+static void
NdisAllocateBufferPool(status, pool, descnum)
ndis_status *status;
ndis_handle *pool;
@@ -2001,14 +2001,14 @@ NdisAllocateBufferPool(status, pool, descnum)
return;
}
-__stdcall static void
+static void
NdisFreeBufferPool(pool)
ndis_handle pool;
{
return;
}
-__stdcall static void
+static void
NdisAllocateBuffer(status, buffer, pool, vaddr, len)
ndis_status *status;
ndis_buffer **buffer;
@@ -2030,7 +2030,7 @@ NdisAllocateBuffer(status, buffer, pool, vaddr, len)
return;
}
-__stdcall static void
+static void
NdisFreeBuffer(buf)
ndis_buffer *buf;
{
@@ -2040,7 +2040,7 @@ NdisFreeBuffer(buf)
/* Aw c'mon. */
-__stdcall static uint32_t
+static uint32_t
NdisBufferLength(buf)
ndis_buffer *buf;
{
@@ -2052,7 +2052,7 @@ NdisBufferLength(buf)
* Note: the vaddr argument is optional.
*/
-__stdcall static void
+static void
NdisQueryBuffer(buf, vaddr, len)
ndis_buffer *buf;
void **vaddr;
@@ -2067,7 +2067,7 @@ NdisQueryBuffer(buf, vaddr, len)
/* Same as above -- we don't care about the priority. */
-__stdcall static void
+static void
NdisQueryBufferSafe(buf, vaddr, len, prio)
ndis_buffer *buf;
void **vaddr;
@@ -2083,14 +2083,14 @@ NdisQueryBufferSafe(buf, vaddr, len, prio)
/* Damnit Microsoft!! How many ways can you do the same thing?! */
-__stdcall static void *
+static void *
NdisBufferVirtualAddress(buf)
ndis_buffer *buf;
{
return(MmGetMdlVirtualAddress(buf));
}
-__stdcall static void *
+static void *
NdisBufferVirtualAddressSafe(buf, prio)
ndis_buffer *buf;
uint32_t prio;
@@ -2098,7 +2098,7 @@ NdisBufferVirtualAddressSafe(buf, prio)
return(MmGetMdlVirtualAddress(buf));
}
-__stdcall static void
+static void
NdisAdjustBufferLength(buf, len)
ndis_buffer *buf;
int len;
@@ -2108,7 +2108,7 @@ NdisAdjustBufferLength(buf, len)
return;
}
-__stdcall static uint32_t
+static uint32_t
NdisInterlockedIncrement(addend)
uint32_t *addend;
{
@@ -2116,7 +2116,7 @@ NdisInterlockedIncrement(addend)
return(*addend);
}
-__stdcall static uint32_t
+static uint32_t
NdisInterlockedDecrement(addend)
uint32_t *addend;
{
@@ -2124,7 +2124,7 @@ NdisInterlockedDecrement(addend)
return(*addend);
}
-__stdcall static void
+static void
NdisInitializeEvent(event)
ndis_event *event;
{
@@ -2138,7 +2138,7 @@ NdisInitializeEvent(event)
return;
}
-__stdcall static void
+static void
NdisSetEvent(event)
ndis_event *event;
{
@@ -2146,7 +2146,7 @@ NdisSetEvent(event)
return;
}
-__stdcall static void
+static void
NdisResetEvent(event)
ndis_event *event;
{
@@ -2154,7 +2154,7 @@ NdisResetEvent(event)
return;
}
-__stdcall static uint8_t
+static uint8_t
NdisWaitEvent(event, msecs)
ndis_event *event;
uint32_t msecs;
@@ -2173,7 +2173,7 @@ NdisWaitEvent(event, msecs)
return(TRUE);
}
-__stdcall static ndis_status
+static ndis_status
NdisUnicodeStringToAnsiString(dstr, sstr)
ndis_ansi_string *dstr;
ndis_unicode_string *sstr;
@@ -2187,7 +2187,7 @@ NdisUnicodeStringToAnsiString(dstr, sstr)
return (NDIS_STATUS_SUCCESS);
}
-__stdcall static ndis_status
+static ndis_status
NdisAnsiStringToUnicodeString(dstr, sstr)
ndis_unicode_string *dstr;
ndis_ansi_string *sstr;
@@ -2209,7 +2209,7 @@ NdisAnsiStringToUnicodeString(dstr, sstr)
return (NDIS_STATUS_SUCCESS);
}
-__stdcall static ndis_status
+static ndis_status
NdisMPciAssignResources(adapter, slot, list)
ndis_handle adapter;
uint32_t slot;
@@ -2226,7 +2226,7 @@ NdisMPciAssignResources(adapter, slot, list)
return (NDIS_STATUS_SUCCESS);
}
-__stdcall static ndis_status
+static ndis_status
NdisMRegisterInterrupt(intr, adapter, ivec, ilevel, reqisr, shared, imode)
ndis_miniport_interrupt *intr;
ndis_handle adapter;
@@ -2250,14 +2250,14 @@ NdisMRegisterInterrupt(intr, adapter, ivec, ilevel, reqisr, shared, imode)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
NdisMDeregisterInterrupt(intr)
ndis_miniport_interrupt *intr;
{
return;
}
-__stdcall static void
+static void
NdisMRegisterAdapterShutdownHandler(adapter, shutdownctx, shutdownfunc)
ndis_handle adapter;
void *shutdownctx;
@@ -2280,7 +2280,7 @@ NdisMRegisterAdapterShutdownHandler(adapter, shutdownctx, shutdownfunc)
return;
}
-__stdcall static void
+static void
NdisMDeregisterAdapterShutdownHandler(adapter)
ndis_handle adapter;
{
@@ -2301,7 +2301,7 @@ NdisMDeregisterAdapterShutdownHandler(adapter)
return;
}
-__stdcall static uint32_t
+static uint32_t
NDIS_BUFFER_TO_SPAN_PAGES(buf)
ndis_buffer *buf;
{
@@ -2313,7 +2313,7 @@ NDIS_BUFFER_TO_SPAN_PAGES(buf)
MmGetMdlByteCount(buf)));
}
-__stdcall static void
+static void
NdisGetBufferPhysicalArraySize(buf, pages)
ndis_buffer *buf;
uint32_t *pages;
@@ -2325,7 +2325,7 @@ NdisGetBufferPhysicalArraySize(buf, pages)
return;
}
-__stdcall static void
+static void
NdisQueryBufferOffset(buf, off, len)
ndis_buffer *buf;
uint32_t *off;
@@ -2340,7 +2340,7 @@ NdisQueryBufferOffset(buf, off, len)
return;
}
-__stdcall static void
+static void
NdisMSleep(usecs)
uint32_t usecs;
{
@@ -2354,7 +2354,7 @@ NdisMSleep(usecs)
return;
}
-__stdcall static uint32_t
+static uint32_t
NdisReadPcmciaAttributeMemory(handle, offset, buf, len)
ndis_handle handle;
uint32_t offset;
@@ -2384,7 +2384,7 @@ NdisReadPcmciaAttributeMemory(handle, offset, buf, len)
return(i);
}
-__stdcall static uint32_t
+static uint32_t
NdisWritePcmciaAttributeMemory(handle, offset, buf, len)
ndis_handle handle;
uint32_t offset;
@@ -2414,7 +2414,7 @@ NdisWritePcmciaAttributeMemory(handle, offset, buf, len)
return(i);
}
-__stdcall static list_entry *
+static list_entry *
NdisInterlockedInsertHeadList(head, entry, lock)
list_entry *head;
list_entry *entry;
@@ -2433,7 +2433,7 @@ NdisInterlockedInsertHeadList(head, entry, lock)
return(flink);
}
-__stdcall static list_entry *
+static list_entry *
NdisInterlockedRemoveHeadList(head, lock)
list_entry *head;
ndis_spin_lock *lock;
@@ -2451,7 +2451,7 @@ NdisInterlockedRemoveHeadList(head, lock)
return(entry);
}
-__stdcall static list_entry *
+static list_entry *
NdisInterlockedInsertTailList(head, entry, lock)
list_entry *head;
list_entry *entry;
@@ -2470,13 +2470,13 @@ NdisInterlockedInsertTailList(head, entry, lock)
return(blink);
}
-__stdcall static uint8_t
+static uint8_t
NdisMSynchronizeWithInterrupt(intr, syncfunc, syncctx)
ndis_miniport_interrupt *intr;
void *syncfunc;
void *syncctx;
{
- __stdcall uint8_t (*sync)(void *);
+ uint8_t (*sync)(void *);
uint8_t rval;
uint8_t irql;
@@ -2495,7 +2495,7 @@ NdisMSynchronizeWithInterrupt(intr, syncfunc, syncctx)
* Return the number of 100 nanosecond intervals since
* January 1, 1601. (?!?!)
*/
-__stdcall static void
+static void
NdisGetCurrentSystemTime(tval)
uint64_t *tval;
{
@@ -2511,16 +2511,19 @@ NdisGetCurrentSystemTime(tval)
/*
* Return the number of milliseconds since the system booted.
*/
-__stdcall static void
+static void
NdisGetSystemUpTime(tval)
uint32_t *tval;
{
- *tval = (ticks * hz) / 1000;
+ struct timespec ts;
+
+ nanouptime(&ts);
+ *tval = ts.tv_nsec / 1000000 + ts.tv_sec * 1000;
return;
}
-__stdcall static void
+static void
NdisInitializeString(dst, src)
ndis_unicode_string *dst;
char *src;
@@ -2535,7 +2538,7 @@ NdisInitializeString(dst, src)
return;
}
-__stdcall static void
+static void
NdisFreeString(str)
ndis_unicode_string *str;
{
@@ -2547,14 +2550,14 @@ NdisFreeString(str)
return;
}
-__stdcall static ndis_status
+static ndis_status
NdisMRemoveMiniport(adapter)
ndis_handle *adapter;
{
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
NdisInitAnsiString(dst, src)
ndis_ansi_string *dst;
char *src;
@@ -2575,7 +2578,7 @@ NdisInitAnsiString(dst, src)
return;
}
-__stdcall static void
+static void
NdisInitUnicodeString(dst, src)
ndis_unicode_string *dst;
uint16_t *src;
@@ -2600,7 +2603,7 @@ NdisInitUnicodeString(dst, src)
return;
}
-__stdcall static void NdisMGetDeviceProperty(adapter, phydevobj,
+static void NdisMGetDeviceProperty(adapter, phydevobj,
funcdevobj, nextdevobj, resources, transresources)
ndis_handle adapter;
device_object **phydevobj;
@@ -2623,7 +2626,7 @@ __stdcall static void NdisMGetDeviceProperty(adapter, phydevobj,
return;
}
-__stdcall static void
+static void
NdisGetFirstBufferFromPacket(packet, buf, firstva, firstlen, totlen)
ndis_packet *packet;
ndis_buffer **buf;
@@ -2648,7 +2651,7 @@ NdisGetFirstBufferFromPacket(packet, buf, firstva, firstlen, totlen)
return;
}
-__stdcall static void
+static void
NdisGetFirstBufferFromPacketSafe(packet, buf, firstva, firstlen, totlen, prio)
ndis_packet *packet;
ndis_buffer **buf;
@@ -2703,7 +2706,7 @@ ndis_find_sym(lf, filename, suffix, sym)
}
/* can also return NDIS_STATUS_RESOURCES/NDIS_STATUS_ERROR_READING_FILE */
-__stdcall static void
+static void
NdisOpenFile(status, filehandle, filelength, filename, highestaddr)
ndis_status *status;
ndis_handle *filehandle;
@@ -2835,7 +2838,7 @@ NdisOpenFile(status, filehandle, filelength, filename, highestaddr)
return;
}
-__stdcall static void
+static void
NdisMapFile(status, mappedbuffer, filehandle)
ndis_status *status;
void **mappedbuffer;
@@ -2898,7 +2901,7 @@ NdisMapFile(status, mappedbuffer, filehandle)
return;
}
-__stdcall static void
+static void
NdisUnmapFile(filehandle)
ndis_handle filehandle;
{
@@ -2915,7 +2918,7 @@ NdisUnmapFile(filehandle)
return;
}
-__stdcall static void
+static void
NdisCloseFile(filehandle)
ndis_handle filehandle;
{
@@ -2947,7 +2950,7 @@ NdisCloseFile(filehandle)
return;
}
-__stdcall static uint8_t
+static uint8_t
NdisSystemProcessorCount()
{
return(mp_ncpus);
@@ -2957,12 +2960,12 @@ typedef void (*ndis_statusdone_handler)(ndis_handle);
typedef void (*ndis_status_handler)(ndis_handle, ndis_status,
void *, uint32_t);
-__stdcall static void
+static void
NdisMIndicateStatusComplete(adapter)
ndis_handle adapter;
{
ndis_miniport_block *block;
- __stdcall ndis_statusdone_handler statusdonefunc;
+ ndis_statusdone_handler statusdonefunc;
block = (ndis_miniport_block *)adapter;
statusdonefunc = block->nmb_statusdone_func;
@@ -2971,7 +2974,7 @@ NdisMIndicateStatusComplete(adapter)
return;
}
-__stdcall static void
+static void
NdisMIndicateStatus(adapter, status, sbuf, slen)
ndis_handle adapter;
ndis_status status;
@@ -2979,7 +2982,7 @@ NdisMIndicateStatus(adapter, status, sbuf, slen)
uint32_t slen;
{
ndis_miniport_block *block;
- __stdcall ndis_status_handler statusfunc;
+ ndis_status_handler statusfunc;
block = (ndis_miniport_block *)adapter;
statusfunc = block->nmb_status_func;
@@ -2993,7 +2996,7 @@ ndis_workfunc(ctx)
void *ctx;
{
ndis_work_item *work;
- __stdcall ndis_proc workfunc;
+ ndis_proc workfunc;
work = ctx;
workfunc = work->nwi_func;
@@ -3001,7 +3004,7 @@ ndis_workfunc(ctx)
return;
}
-__stdcall static ndis_status
+static ndis_status
NdisScheduleWorkItem(work)
ndis_work_item *work;
{
@@ -3009,7 +3012,7 @@ NdisScheduleWorkItem(work)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
NdisCopyFromPacketToPacket(dpkt, doff, reqlen, spkt, soff, cpylen)
ndis_packet *dpkt;
uint32_t doff;
@@ -3099,7 +3102,7 @@ NdisCopyFromPacketToPacket(dpkt, doff, reqlen, spkt, soff, cpylen)
return;
}
-__stdcall static void
+static void
NdisCopyFromPacketToPacketSafe(dpkt, doff, reqlen, spkt, soff, cpylen, prio)
ndis_packet *dpkt;
uint32_t doff;
@@ -3113,7 +3116,7 @@ NdisCopyFromPacketToPacketSafe(dpkt, doff, reqlen, spkt, soff, cpylen, prio)
return;
}
-__stdcall static ndis_status
+static ndis_status
NdisMRegisterDevice(handle, devname, symname, majorfuncs, devobj, devhandle)
ndis_handle handle;
ndis_unicode_string *devname;
@@ -3131,14 +3134,14 @@ NdisMRegisterDevice(handle, devname, symname, majorfuncs, devobj, devhandle)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static ndis_status
+static ndis_status
NdisMDeregisterDevice(handle)
ndis_handle handle;
{
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static ndis_status
+static ndis_status
NdisMQueryAdapterInstanceName(name, handle)
ndis_unicode_string *name;
ndis_handle handle;
@@ -3156,7 +3159,7 @@ NdisMQueryAdapterInstanceName(name, handle)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
NdisMRegisterUnloadHandler(handle, func)
ndis_handle handle;
void *func;
@@ -3164,131 +3167,140 @@ NdisMRegisterUnloadHandler(handle, func)
return;
}
-__stdcall static void
+static void
dummy()
{
printf ("NDIS dummy called...\n");
return;
}
+/*
+ * Note: a couple of entries in this table specify the
+ * number of arguments as "foo + 1". These are routines
+ * that accept a 64-bit argument, passed by value. On
+ * x86, these arguments consume two longwords on the stack,
+ * so we lie and say there's one additional argument so
+ * that the wrapping routines will do the right thing.
+ */
+
image_patch_table ndis_functbl[] = {
- IMPORT_FUNC(NdisCopyFromPacketToPacket),
- IMPORT_FUNC(NdisCopyFromPacketToPacketSafe),
- IMPORT_FUNC(NdisScheduleWorkItem),
- IMPORT_FUNC(NdisMIndicateStatusComplete),
- IMPORT_FUNC(NdisMIndicateStatus),
- IMPORT_FUNC(NdisSystemProcessorCount),
- IMPORT_FUNC(NdisUnchainBufferAtBack),
- IMPORT_FUNC(NdisGetFirstBufferFromPacket),
- IMPORT_FUNC(NdisGetFirstBufferFromPacketSafe),
- IMPORT_FUNC(NdisGetBufferPhysicalArraySize),
- IMPORT_FUNC(NdisMGetDeviceProperty),
- IMPORT_FUNC(NdisInitAnsiString),
- IMPORT_FUNC(NdisInitUnicodeString),
- IMPORT_FUNC(NdisWriteConfiguration),
- IMPORT_FUNC(NdisAnsiStringToUnicodeString),
- IMPORT_FUNC(NdisTerminateWrapper),
- IMPORT_FUNC(NdisOpenConfigurationKeyByName),
- IMPORT_FUNC(NdisOpenConfigurationKeyByIndex),
- IMPORT_FUNC(NdisMRemoveMiniport),
- IMPORT_FUNC(NdisInitializeString),
- IMPORT_FUNC(NdisFreeString),
- IMPORT_FUNC(NdisGetCurrentSystemTime),
- IMPORT_FUNC(NdisGetSystemUpTime),
- IMPORT_FUNC(NdisMSynchronizeWithInterrupt),
- IMPORT_FUNC(NdisMAllocateSharedMemoryAsync),
- IMPORT_FUNC(NdisInterlockedInsertHeadList),
- IMPORT_FUNC(NdisInterlockedInsertTailList),
- IMPORT_FUNC(NdisInterlockedRemoveHeadList),
- IMPORT_FUNC(NdisInitializeWrapper),
- IMPORT_FUNC(NdisMRegisterMiniport),
- IMPORT_FUNC(NdisAllocateMemoryWithTag),
- IMPORT_FUNC(NdisAllocateMemory),
- IMPORT_FUNC(NdisMSetAttributesEx),
- IMPORT_FUNC(NdisCloseConfiguration),
- IMPORT_FUNC(NdisReadConfiguration),
- IMPORT_FUNC(NdisOpenConfiguration),
- IMPORT_FUNC(NdisAcquireSpinLock),
- IMPORT_FUNC(NdisReleaseSpinLock),
- IMPORT_FUNC(NdisDprAcquireSpinLock),
- IMPORT_FUNC(NdisDprReleaseSpinLock),
- IMPORT_FUNC(NdisAllocateSpinLock),
- IMPORT_FUNC(NdisFreeSpinLock),
- IMPORT_FUNC(NdisFreeMemory),
- IMPORT_FUNC(NdisReadPciSlotInformation),
- IMPORT_FUNC(NdisWritePciSlotInformation),
- IMPORT_FUNC_MAP(NdisImmediateReadPciSlotInformation,
- NdisReadPciSlotInformation),
- IMPORT_FUNC_MAP(NdisImmediateWritePciSlotInformation,
- NdisWritePciSlotInformation),
- IMPORT_FUNC(NdisWriteErrorLogEntry),
- IMPORT_FUNC(NdisMStartBufferPhysicalMapping),
- IMPORT_FUNC(NdisMCompleteBufferPhysicalMapping),
- IMPORT_FUNC(NdisMInitializeTimer),
- IMPORT_FUNC(NdisInitializeTimer),
- IMPORT_FUNC(NdisSetTimer),
- IMPORT_FUNC(NdisMCancelTimer),
- IMPORT_FUNC_MAP(NdisCancelTimer, NdisMCancelTimer),
- IMPORT_FUNC(NdisMSetPeriodicTimer),
- IMPORT_FUNC(NdisMQueryAdapterResources),
- IMPORT_FUNC(NdisMRegisterIoPortRange),
- IMPORT_FUNC(NdisMDeregisterIoPortRange),
- IMPORT_FUNC(NdisReadNetworkAddress),
- IMPORT_FUNC(NdisQueryMapRegisterCount),
- IMPORT_FUNC(NdisMAllocateMapRegisters),
- IMPORT_FUNC(NdisMFreeMapRegisters),
- IMPORT_FUNC(NdisMAllocateSharedMemory),
- IMPORT_FUNC(NdisMMapIoSpace),
- IMPORT_FUNC(NdisMUnmapIoSpace),
- IMPORT_FUNC(NdisGetCacheFillSize),
- IMPORT_FUNC(NdisMGetDmaAlignment),
- IMPORT_FUNC(NdisMInitializeScatterGatherDma),
- IMPORT_FUNC(NdisAllocatePacketPool),
- IMPORT_FUNC(NdisAllocatePacketPoolEx),
- IMPORT_FUNC(NdisAllocatePacket),
- IMPORT_FUNC(NdisFreePacket),
- IMPORT_FUNC(NdisFreePacketPool),
- IMPORT_FUNC_MAP(NdisDprAllocatePacket, NdisAllocatePacket),
- IMPORT_FUNC_MAP(NdisDprFreePacket, NdisFreePacket),
- IMPORT_FUNC(NdisAllocateBufferPool),
- IMPORT_FUNC(NdisAllocateBuffer),
- IMPORT_FUNC(NdisQueryBuffer),
- IMPORT_FUNC(NdisQueryBufferSafe),
- IMPORT_FUNC(NdisBufferVirtualAddress),
- IMPORT_FUNC(NdisBufferVirtualAddressSafe),
- IMPORT_FUNC(NdisBufferLength),
- IMPORT_FUNC(NdisFreeBuffer),
- IMPORT_FUNC(NdisFreeBufferPool),
- IMPORT_FUNC(NdisInterlockedIncrement),
- IMPORT_FUNC(NdisInterlockedDecrement),
- IMPORT_FUNC(NdisInitializeEvent),
- IMPORT_FUNC(NdisSetEvent),
- IMPORT_FUNC(NdisResetEvent),
- IMPORT_FUNC(NdisWaitEvent),
- IMPORT_FUNC(NdisUnicodeStringToAnsiString),
- IMPORT_FUNC(NdisMPciAssignResources),
- IMPORT_FUNC(NdisMFreeSharedMemory),
- IMPORT_FUNC(NdisMRegisterInterrupt),
- IMPORT_FUNC(NdisMDeregisterInterrupt),
- IMPORT_FUNC(NdisMRegisterAdapterShutdownHandler),
- IMPORT_FUNC(NdisMDeregisterAdapterShutdownHandler),
- IMPORT_FUNC(NDIS_BUFFER_TO_SPAN_PAGES),
- IMPORT_FUNC(NdisQueryBufferOffset),
- IMPORT_FUNC(NdisAdjustBufferLength),
- IMPORT_FUNC(NdisPacketPoolUsage),
- IMPORT_FUNC(NdisMSleep),
- IMPORT_FUNC(NdisUnchainBufferAtFront),
- IMPORT_FUNC(NdisReadPcmciaAttributeMemory),
- IMPORT_FUNC(NdisWritePcmciaAttributeMemory),
- IMPORT_FUNC(NdisOpenFile),
- IMPORT_FUNC(NdisMapFile),
- IMPORT_FUNC(NdisUnmapFile),
- IMPORT_FUNC(NdisCloseFile),
- IMPORT_FUNC(NdisMRegisterDevice),
- IMPORT_FUNC(NdisMDeregisterDevice),
- IMPORT_FUNC(NdisMQueryAdapterInstanceName),
- IMPORT_FUNC(NdisMRegisterUnloadHandler),
- IMPORT_FUNC(ndis_timercall),
+ IMPORT_SFUNC(NdisCopyFromPacketToPacket, 6),
+ IMPORT_SFUNC(NdisCopyFromPacketToPacketSafe, 7),
+ IMPORT_SFUNC(NdisScheduleWorkItem, 1),
+ IMPORT_SFUNC(NdisMIndicateStatusComplete, 1),
+ IMPORT_SFUNC(NdisMIndicateStatus, 4),
+ IMPORT_SFUNC(NdisSystemProcessorCount, 0),
+ IMPORT_SFUNC(NdisUnchainBufferAtBack, 2),
+ IMPORT_SFUNC(NdisGetFirstBufferFromPacket, 5),
+ IMPORT_SFUNC(NdisGetFirstBufferFromPacketSafe, 6),
+ IMPORT_SFUNC(NdisGetBufferPhysicalArraySize, 2),
+ IMPORT_SFUNC(NdisMGetDeviceProperty, 6),
+ IMPORT_SFUNC(NdisInitAnsiString, 2),
+ IMPORT_SFUNC(NdisInitUnicodeString, 2),
+ IMPORT_SFUNC(NdisWriteConfiguration, 4),
+ IMPORT_SFUNC(NdisAnsiStringToUnicodeString, 2),
+ IMPORT_SFUNC(NdisTerminateWrapper, 2),
+ IMPORT_SFUNC(NdisOpenConfigurationKeyByName, 4),
+ IMPORT_SFUNC(NdisOpenConfigurationKeyByIndex, 5),
+ IMPORT_SFUNC(NdisMRemoveMiniport, 1),
+ IMPORT_SFUNC(NdisInitializeString, 2),
+ IMPORT_SFUNC(NdisFreeString, 1),
+ IMPORT_SFUNC(NdisGetCurrentSystemTime, 1),
+ IMPORT_SFUNC(NdisGetSystemUpTime, 1),
+ IMPORT_SFUNC(NdisMSynchronizeWithInterrupt, 3),
+ IMPORT_SFUNC(NdisMAllocateSharedMemoryAsync, 4),
+ IMPORT_SFUNC(NdisInterlockedInsertHeadList, 3),
+ IMPORT_SFUNC(NdisInterlockedInsertTailList, 3),
+ IMPORT_SFUNC(NdisInterlockedRemoveHeadList, 2),
+ IMPORT_SFUNC(NdisInitializeWrapper, 4),
+ IMPORT_SFUNC(NdisMRegisterMiniport, 3),
+ IMPORT_SFUNC(NdisAllocateMemoryWithTag, 3),
+ IMPORT_SFUNC(NdisAllocateMemory, 4 + 1),
+ IMPORT_SFUNC(NdisMSetAttributesEx, 5),
+ IMPORT_SFUNC(NdisCloseConfiguration, 1),
+ IMPORT_SFUNC(NdisReadConfiguration, 5),
+ IMPORT_SFUNC(NdisOpenConfiguration, 3),
+ IMPORT_SFUNC(NdisAcquireSpinLock, 1),
+ IMPORT_SFUNC(NdisReleaseSpinLock, 1),
+ IMPORT_SFUNC(NdisDprAcquireSpinLock, 1),
+ IMPORT_SFUNC(NdisDprReleaseSpinLock, 1),
+ IMPORT_SFUNC(NdisAllocateSpinLock, 1),
+ IMPORT_SFUNC(NdisFreeSpinLock, 1),
+ IMPORT_SFUNC(NdisFreeMemory, 3),
+ IMPORT_SFUNC(NdisReadPciSlotInformation, 5),
+ IMPORT_SFUNC(NdisWritePciSlotInformation, 5),
+ IMPORT_SFUNC_MAP(NdisImmediateReadPciSlotInformation,
+ NdisReadPciSlotInformation, 5),
+ IMPORT_SFUNC_MAP(NdisImmediateWritePciSlotInformation,
+ NdisWritePciSlotInformation, 5),
+ IMPORT_CFUNC(NdisWriteErrorLogEntry, 0),
+ IMPORT_SFUNC(NdisMStartBufferPhysicalMapping, 6),
+ IMPORT_SFUNC(NdisMCompleteBufferPhysicalMapping, 3),
+ IMPORT_SFUNC(NdisMInitializeTimer, 4),
+ IMPORT_SFUNC(NdisInitializeTimer, 3),
+ IMPORT_SFUNC(NdisSetTimer, 2),
+ IMPORT_SFUNC(NdisMCancelTimer, 2),
+ IMPORT_SFUNC_MAP(NdisCancelTimer, NdisMCancelTimer, 2),
+ IMPORT_SFUNC(NdisMSetPeriodicTimer, 2),
+ IMPORT_SFUNC(NdisMQueryAdapterResources, 4),
+ IMPORT_SFUNC(NdisMRegisterIoPortRange, 4),
+ IMPORT_SFUNC(NdisMDeregisterIoPortRange, 4),
+ IMPORT_SFUNC(NdisReadNetworkAddress, 4),
+ IMPORT_SFUNC(NdisQueryMapRegisterCount, 2),
+ IMPORT_SFUNC(NdisMAllocateMapRegisters, 5),
+ IMPORT_SFUNC(NdisMFreeMapRegisters, 1),
+ IMPORT_SFUNC(NdisMAllocateSharedMemory, 5),
+ IMPORT_SFUNC(NdisMMapIoSpace, 4 + 1),
+ IMPORT_SFUNC(NdisMUnmapIoSpace, 3),
+ IMPORT_SFUNC(NdisGetCacheFillSize, 0),
+ IMPORT_SFUNC(NdisMGetDmaAlignment, 1),
+ IMPORT_SFUNC(NdisMInitializeScatterGatherDma, 3),
+ IMPORT_SFUNC(NdisAllocatePacketPool, 4),
+ IMPORT_SFUNC(NdisAllocatePacketPoolEx, 5),
+ IMPORT_SFUNC(NdisAllocatePacket, 3),
+ IMPORT_SFUNC(NdisFreePacket, 1),
+ IMPORT_SFUNC(NdisFreePacketPool, 1),
+ IMPORT_SFUNC_MAP(NdisDprAllocatePacket, NdisAllocatePacket, 3),
+ IMPORT_SFUNC_MAP(NdisDprFreePacket, NdisFreePacket, 1),
+ IMPORT_SFUNC(NdisAllocateBufferPool, 3),
+ IMPORT_SFUNC(NdisAllocateBuffer, 5),
+ IMPORT_SFUNC(NdisQueryBuffer, 3),
+ IMPORT_SFUNC(NdisQueryBufferSafe, 4),
+ IMPORT_SFUNC(NdisBufferVirtualAddress, 1),
+ IMPORT_SFUNC(NdisBufferVirtualAddressSafe, 2),
+ IMPORT_SFUNC(NdisBufferLength, 1),
+ IMPORT_SFUNC(NdisFreeBuffer, 1),
+ IMPORT_SFUNC(NdisFreeBufferPool, 1),
+ IMPORT_SFUNC(NdisInterlockedIncrement, 1),
+ IMPORT_SFUNC(NdisInterlockedDecrement, 1),
+ IMPORT_SFUNC(NdisInitializeEvent, 1),
+ IMPORT_SFUNC(NdisSetEvent, 1),
+ IMPORT_SFUNC(NdisResetEvent, 1),
+ IMPORT_SFUNC(NdisWaitEvent, 2),
+ IMPORT_SFUNC(NdisUnicodeStringToAnsiString, 2),
+ IMPORT_SFUNC(NdisMPciAssignResources, 3),
+ IMPORT_SFUNC(NdisMFreeSharedMemory, 5 + 1),
+ IMPORT_SFUNC(NdisMRegisterInterrupt, 7),
+ IMPORT_SFUNC(NdisMDeregisterInterrupt, 1),
+ IMPORT_SFUNC(NdisMRegisterAdapterShutdownHandler, 3),
+ IMPORT_SFUNC(NdisMDeregisterAdapterShutdownHandler, 1),
+ IMPORT_SFUNC(NDIS_BUFFER_TO_SPAN_PAGES, 1),
+ IMPORT_SFUNC(NdisQueryBufferOffset, 3),
+ IMPORT_SFUNC(NdisAdjustBufferLength, 2),
+ IMPORT_SFUNC(NdisPacketPoolUsage, 1),
+ IMPORT_SFUNC(NdisMSleep, 1),
+ IMPORT_SFUNC(NdisUnchainBufferAtFront, 2),
+ IMPORT_SFUNC(NdisReadPcmciaAttributeMemory, 4),
+ IMPORT_SFUNC(NdisWritePcmciaAttributeMemory, 4),
+ IMPORT_SFUNC(NdisOpenFile, 5 + 1),
+ IMPORT_SFUNC(NdisMapFile, 3),
+ IMPORT_SFUNC(NdisUnmapFile, 1),
+ IMPORT_SFUNC(NdisCloseFile, 1),
+ IMPORT_SFUNC(NdisMRegisterDevice, 6),
+ IMPORT_SFUNC(NdisMDeregisterDevice, 1),
+ IMPORT_SFUNC(NdisMQueryAdapterInstanceName, 2),
+ IMPORT_SFUNC(NdisMRegisterUnloadHandler, 2),
+ IMPORT_SFUNC(ndis_timercall, 4),
/*
* This last entry is a catch-all for any function we haven't
@@ -3297,7 +3309,7 @@ image_patch_table ndis_functbl[] = {
* in this table.
*/
- { NULL, (FUNC)dummy, NULL },
+ { NULL, (FUNC)dummy, NULL, 0, WINDRV_WRAP_CDECL },
/* End of list. */
diff --git a/sys/compat/ndis/subr_ntoskrnl.c b/sys/compat/ndis/subr_ntoskrnl.c
index 46aefd4..bdb9c8f 100644
--- a/sys/compat/ndis/subr_ntoskrnl.c
+++ b/sys/compat/ndis/subr_ntoskrnl.c
@@ -75,115 +75,108 @@ __FBSDID("$FreeBSD$");
#define __regparm __attribute__((regparm(3)))
-__stdcall static uint8_t RtlEqualUnicodeString(ndis_unicode_string *,
+static uint8_t RtlEqualUnicodeString(ndis_unicode_string *,
ndis_unicode_string *, uint8_t);
-__stdcall static void RtlCopyUnicodeString(ndis_unicode_string *,
+static void RtlCopyUnicodeString(ndis_unicode_string *,
ndis_unicode_string *);
-__stdcall static ndis_status RtlUnicodeStringToAnsiString(ndis_ansi_string *,
+static ndis_status RtlUnicodeStringToAnsiString(ndis_ansi_string *,
ndis_unicode_string *, uint8_t);
-__stdcall static ndis_status RtlAnsiStringToUnicodeString(ndis_unicode_string *,
+static ndis_status RtlAnsiStringToUnicodeString(ndis_unicode_string *,
ndis_ansi_string *, uint8_t);
-__stdcall static irp *IoBuildSynchronousFsdRequest(uint32_t, device_object *,
+static irp *IoBuildSynchronousFsdRequest(uint32_t, device_object *,
void *, uint32_t, uint64_t *, nt_kevent *, io_status_block *);
-__stdcall static irp *IoBuildAsynchronousFsdRequest(uint32_t,
+static irp *IoBuildAsynchronousFsdRequest(uint32_t,
device_object *, void *, uint32_t, uint64_t *, io_status_block *);
-__stdcall static irp *IoBuildDeviceIoControlRequest(uint32_t,
+static irp *IoBuildDeviceIoControlRequest(uint32_t,
device_object *, void *, uint32_t, void *, uint32_t,
uint8_t, nt_kevent *, io_status_block *);
-__stdcall static irp *IoAllocateIrp(uint8_t, uint8_t);
-__stdcall static void IoReuseIrp(irp *, uint32_t);
-__stdcall static void IoFreeIrp(irp *);
-__stdcall static void IoInitializeIrp(irp *, uint16_t, uint8_t);
-__stdcall static irp *IoMakeAssociatedIrp(irp *, uint8_t);
-__stdcall static uint32_t KeWaitForMultipleObjects(uint32_t,
+static irp *IoAllocateIrp(uint8_t, uint8_t);
+static void IoReuseIrp(irp *, uint32_t);
+static void IoFreeIrp(irp *);
+static void IoInitializeIrp(irp *, uint16_t, uint8_t);
+static irp *IoMakeAssociatedIrp(irp *, uint8_t);
+static uint32_t KeWaitForMultipleObjects(uint32_t,
nt_dispatch_header **, uint32_t, uint32_t, uint32_t, uint8_t,
int64_t *, wait_block *);
static void ntoskrnl_wakeup(void *);
static void ntoskrnl_timercall(void *);
static void ntoskrnl_run_dpc(void *);
-__stdcall static void WRITE_REGISTER_USHORT(uint16_t *, uint16_t);
-__stdcall static uint16_t READ_REGISTER_USHORT(uint16_t *);
-__stdcall static void WRITE_REGISTER_ULONG(uint32_t *, uint32_t);
-__stdcall static uint32_t READ_REGISTER_ULONG(uint32_t *);
-__stdcall static void WRITE_REGISTER_UCHAR(uint8_t *, uint8_t);
-__stdcall static uint8_t READ_REGISTER_UCHAR(uint8_t *);
-__stdcall static int64_t _allmul(int64_t, int64_t);
-__stdcall static int64_t _alldiv(int64_t, int64_t);
-__stdcall static int64_t _allrem(int64_t, int64_t);
-__regparm static int64_t _allshr(int64_t, uint8_t);
-__regparm static int64_t _allshl(int64_t, uint8_t);
-__stdcall static uint64_t _aullmul(uint64_t, uint64_t);
-__stdcall static uint64_t _aulldiv(uint64_t, uint64_t);
-__stdcall static uint64_t _aullrem(uint64_t, uint64_t);
-__regparm static uint64_t _aullshr(uint64_t, uint8_t);
-__regparm static uint64_t _aullshl(uint64_t, uint8_t);
+static void WRITE_REGISTER_USHORT(uint16_t *, uint16_t);
+static uint16_t READ_REGISTER_USHORT(uint16_t *);
+static void WRITE_REGISTER_ULONG(uint32_t *, uint32_t);
+static uint32_t READ_REGISTER_ULONG(uint32_t *);
+static void WRITE_REGISTER_UCHAR(uint8_t *, uint8_t);
+static uint8_t READ_REGISTER_UCHAR(uint8_t *);
+static int64_t _allmul(int64_t, int64_t);
+static int64_t _alldiv(int64_t, int64_t);
+static int64_t _allrem(int64_t, int64_t);
+static int64_t _allshr(int64_t, uint8_t);
+static int64_t _allshl(int64_t, uint8_t);
+static uint64_t _aullmul(uint64_t, uint64_t);
+static uint64_t _aulldiv(uint64_t, uint64_t);
+static uint64_t _aullrem(uint64_t, uint64_t);
+static uint64_t _aullshr(uint64_t, uint8_t);
+static uint64_t _aullshl(uint64_t, uint8_t);
static slist_entry *ntoskrnl_pushsl(slist_header *, slist_entry *);
static slist_entry *ntoskrnl_popsl(slist_header *);
-__stdcall static void ExInitializePagedLookasideList(paged_lookaside_list *,
+static void ExInitializePagedLookasideList(paged_lookaside_list *,
lookaside_alloc_func *, lookaside_free_func *,
uint32_t, size_t, uint32_t, uint16_t);
-__stdcall static void ExDeletePagedLookasideList(paged_lookaside_list *);
-__stdcall static void ExInitializeNPagedLookasideList(npaged_lookaside_list *,
+static void ExDeletePagedLookasideList(paged_lookaside_list *);
+static void ExInitializeNPagedLookasideList(npaged_lookaside_list *,
lookaside_alloc_func *, lookaside_free_func *,
uint32_t, size_t, uint32_t, uint16_t);
-__stdcall static void ExDeleteNPagedLookasideList(npaged_lookaside_list *);
-__fastcall static slist_entry
- *InterlockedPushEntrySList(REGARGS2(slist_header *head,
- slist_entry *entry));
-__fastcall static slist_entry *InterlockedPopEntrySList(REGARGS1(slist_header
- *head));
-__fastcall static slist_entry
- *ExInterlockedPushEntrySList(REGARGS2(slist_header *head,
- slist_entry *entry), kspin_lock *lock);
-__fastcall static slist_entry
- *ExInterlockedPopEntrySList(REGARGS2(slist_header *head,
- kspin_lock *lock));
-__stdcall static uint16_t
- ExQueryDepthSList(slist_header *);
-__fastcall static uint32_t
- InterlockedIncrement(REGARGS1(volatile uint32_t *addend));
-__fastcall static uint32_t
- InterlockedDecrement(REGARGS1(volatile uint32_t *addend));
-__fastcall static void
- ExInterlockedAddLargeStatistic(REGARGS2(uint64_t *addend, uint32_t));
-__stdcall static uint32_t MmSizeOfMdl(void *, size_t);
-__stdcall static void MmBuildMdlForNonPagedPool(mdl *);
-__stdcall static void *MmMapLockedPages(mdl *, uint8_t);
-__stdcall static void *MmMapLockedPagesSpecifyCache(mdl *,
+static void ExDeleteNPagedLookasideList(npaged_lookaside_list *);
+static slist_entry
+ *InterlockedPushEntrySList(slist_header *, slist_entry *);
+static slist_entry *InterlockedPopEntrySList(slist_header *);
+static slist_entry
+ *ExInterlockedPushEntrySList(slist_header *,
+ slist_entry *, kspin_lock *);
+static slist_entry
+ *ExInterlockedPopEntrySList(slist_header *, kspin_lock *);
+static uint16_t ExQueryDepthSList(slist_header *);
+static uint32_t InterlockedIncrement(volatile uint32_t *);
+static uint32_t InterlockedDecrement(volatile uint32_t *);
+static void ExInterlockedAddLargeStatistic(uint64_t *, uint32_t);
+static uint32_t MmSizeOfMdl(void *, size_t);
+static void MmBuildMdlForNonPagedPool(mdl *);
+static void *MmMapLockedPages(mdl *, uint8_t);
+static void *MmMapLockedPagesSpecifyCache(mdl *,
uint8_t, uint32_t, void *, uint32_t, uint32_t);
-__stdcall static void MmUnmapLockedPages(void *, mdl *);
-__stdcall static size_t RtlCompareMemory(const void *, const void *, size_t);
-__stdcall static void RtlInitAnsiString(ndis_ansi_string *, char *);
-__stdcall static void RtlInitUnicodeString(ndis_unicode_string *,
+static void MmUnmapLockedPages(void *, mdl *);
+static size_t RtlCompareMemory(const void *, const void *, size_t);
+static void RtlInitAnsiString(ndis_ansi_string *, char *);
+static void RtlInitUnicodeString(ndis_unicode_string *,
uint16_t *);
-__stdcall static void RtlFreeUnicodeString(ndis_unicode_string *);
-__stdcall static void RtlFreeAnsiString(ndis_ansi_string *);
-__stdcall static ndis_status RtlUnicodeStringToInteger(ndis_unicode_string *,
+static void RtlFreeUnicodeString(ndis_unicode_string *);
+static void RtlFreeAnsiString(ndis_ansi_string *);
+static ndis_status RtlUnicodeStringToInteger(ndis_unicode_string *,
uint32_t, uint32_t *);
static int atoi (const char *);
static long atol (const char *);
static int rand(void);
static void srand(unsigned int);
static void ntoskrnl_time(uint64_t *);
-__stdcall static uint8_t IoIsWdmVersionAvailable(uint8_t, uint8_t);
+static uint8_t IoIsWdmVersionAvailable(uint8_t, uint8_t);
static void ntoskrnl_thrfunc(void *);
-__stdcall static ndis_status PsCreateSystemThread(ndis_handle *,
+static ndis_status PsCreateSystemThread(ndis_handle *,
uint32_t, void *, ndis_handle, void *, void *, void *);
-__stdcall static ndis_status PsTerminateSystemThread(ndis_status);
-__stdcall static ndis_status IoGetDeviceProperty(device_object *, uint32_t,
+static ndis_status PsTerminateSystemThread(ndis_status);
+static ndis_status IoGetDeviceProperty(device_object *, uint32_t,
uint32_t, void *, uint32_t *);
-__stdcall static void KeInitializeMutex(kmutant *, uint32_t);
-__stdcall static uint32_t KeReleaseMutex(kmutant *, uint8_t);
-__stdcall static uint32_t KeReadStateMutex(kmutant *);
-__stdcall static ndis_status ObReferenceObjectByHandle(ndis_handle,
+static void KeInitializeMutex(kmutant *, uint32_t);
+static uint32_t KeReleaseMutex(kmutant *, uint8_t);
+static uint32_t KeReadStateMutex(kmutant *);
+static ndis_status ObReferenceObjectByHandle(ndis_handle,
uint32_t, void *, uint8_t, void **, void **);
-__fastcall static void ObfDereferenceObject(REGARGS1(void *object));
-__stdcall static uint32_t ZwClose(ndis_handle);
+static void ObfDereferenceObject(void *);
+static uint32_t ZwClose(ndis_handle);
static void *ntoskrnl_memset(void *, int, size_t);
static funcptr ntoskrnl_findwrap(funcptr);
static uint32_t DbgPrint(char *, ...);
-__stdcall static void DbgBreakPoint(void);
-__stdcall static void dummy(void);
+static void DbgBreakPoint(void);
+static void dummy(void);
static struct mtx ntoskrnl_dispatchlock;
static kspin_lock ntoskrnl_global;
@@ -206,7 +199,8 @@ ntoskrnl_libinit()
patch = ntoskrnl_functbl;
while (patch->ipt_func != NULL) {
windrv_wrap((funcptr)patch->ipt_func,
- (funcptr *)&patch->ipt_wrap);
+ (funcptr *)&patch->ipt_wrap,
+ patch->ipt_argcnt, patch->ipt_ftype);
patch++;
}
@@ -215,7 +209,7 @@ ntoskrnl_libinit()
* buffers containing some number of pages, but we don't
* know ahead of time how many pages that will be). But
* always allocating them off the heap is very slow. As
- * a compromize, we create an MDL UMA zone big enough to
+ * a compromise, we create an MDL UMA zone big enough to
* handle any buffer requiring up to 16 pages, and we
* use those for any MDLs for buffers of 16 pages or less
* in size. For buffers larger than that (which we assume
@@ -260,7 +254,7 @@ ntoskrnl_memset(buf, ch, size)
return(memset(buf, ch, size));
}
-__stdcall static uint8_t
+static uint8_t
RtlEqualUnicodeString(str1, str2, caseinsensitive)
ndis_unicode_string *str1;
ndis_unicode_string *str2;
@@ -285,7 +279,7 @@ RtlEqualUnicodeString(str1, str2, caseinsensitive)
return(TRUE);
}
-__stdcall static void
+static void
RtlCopyUnicodeString(dest, src)
ndis_unicode_string *dest;
ndis_unicode_string *src;
@@ -299,7 +293,7 @@ RtlCopyUnicodeString(dest, src)
return;
}
-__stdcall static ndis_status
+static ndis_status
RtlUnicodeStringToAnsiString(dest, src, allocate)
ndis_ansi_string *dest;
ndis_unicode_string *src;
@@ -325,7 +319,7 @@ RtlUnicodeStringToAnsiString(dest, src, allocate)
return (NDIS_STATUS_SUCCESS);
}
-__stdcall static ndis_status
+static ndis_status
RtlAnsiStringToUnicodeString(dest, src, allocate)
ndis_unicode_string *dest;
ndis_ansi_string *src;
@@ -350,7 +344,7 @@ RtlAnsiStringToUnicodeString(dest, src, allocate)
return (NDIS_STATUS_SUCCESS);
}
-__stdcall void *
+void *
ExAllocatePoolWithTag(pooltype, len, tag)
uint32_t pooltype;
size_t len;
@@ -364,7 +358,7 @@ ExAllocatePoolWithTag(pooltype, len, tag)
return(buf);
}
-__stdcall void
+void
ExFreePool(buf)
void *buf;
{
@@ -372,7 +366,7 @@ ExFreePool(buf)
return;
}
-__stdcall uint32_t
+uint32_t
IoAllocateDriverObjectExtension(drv, clid, extlen, ext)
driver_object *drv;
void *clid;
@@ -395,7 +389,7 @@ IoAllocateDriverObjectExtension(drv, clid, extlen, ext)
return(STATUS_SUCCESS);
}
-__stdcall void *
+void *
IoGetDriverObjectExtension(drv, clid)
driver_object *drv;
void *clid;
@@ -403,6 +397,14 @@ IoGetDriverObjectExtension(drv, clid)
list_entry *e;
custom_extension *ce;
+ /*
+ * Sanity check. Our dummy bus drivers don't have
+ * any driver extentions.
+ */
+
+ if (drv->dro_driverext == NULL)
+ return(NULL);
+
e = drv->dro_driverext->dre_usrext.nle_flink;
while (e != &drv->dro_driverext->dre_usrext) {
ce = (custom_extension *)e;
@@ -415,7 +417,7 @@ IoGetDriverObjectExtension(drv, clid)
}
-__stdcall uint32_t
+uint32_t
IoCreateDevice(drv, devextlen, devname, devtype, devchars, exclusive, newdev)
driver_object *drv;
uint32_t devextlen;
@@ -501,7 +503,7 @@ IoCreateDevice(drv, devextlen, devname, devtype, devchars, exclusive, newdev)
return(STATUS_SUCCESS);
}
-__stdcall void
+void
IoDeleteDevice(dev)
device_object *dev;
{
@@ -532,7 +534,7 @@ IoDeleteDevice(dev)
return;
}
-__stdcall device_object *
+device_object *
IoGetAttachedDevice(dev)
device_object *dev;
{
@@ -549,7 +551,7 @@ IoGetAttachedDevice(dev)
return (d);
}
-__stdcall static irp *
+static irp *
IoBuildSynchronousFsdRequest(func, dobj, buf, len, off, event, status)
uint32_t func;
device_object *dobj;
@@ -569,7 +571,7 @@ IoBuildSynchronousFsdRequest(func, dobj, buf, len, off, event, status)
return(ip);
}
-__stdcall static irp *
+static irp *
IoBuildAsynchronousFsdRequest(func, dobj, buf, len, off, status)
uint32_t func;
device_object *dobj;
@@ -640,7 +642,7 @@ IoBuildAsynchronousFsdRequest(func, dobj, buf, len, off, status)
return(ip);
}
-__stdcall static irp *
+static irp *
IoBuildDeviceIoControlRequest(iocode, dobj, ibuf, ilen, obuf, olen,
isinternal, event, status)
uint32_t iocode;
@@ -736,7 +738,7 @@ IoBuildDeviceIoControlRequest(iocode, dobj, ibuf, ilen, obuf, olen,
return (ip);
}
-__stdcall static irp *
+static irp *
IoAllocateIrp(stsize, chargequota)
uint8_t stsize;
uint8_t chargequota;
@@ -752,7 +754,7 @@ IoAllocateIrp(stsize, chargequota)
return (i);
}
-__stdcall static irp *
+static irp *
IoMakeAssociatedIrp(ip, stsize)
irp *ip;
uint8_t stsize;
@@ -773,7 +775,7 @@ IoMakeAssociatedIrp(ip, stsize)
return(associrp);
}
-__stdcall static void
+static void
IoFreeIrp(ip)
irp *ip;
{
@@ -781,7 +783,7 @@ IoFreeIrp(ip)
return;
}
-__stdcall static void
+static void
IoInitializeIrp(io, psize, ssize)
irp *io;
uint16_t psize;
@@ -798,7 +800,7 @@ IoInitializeIrp(io, psize, ssize)
return;
}
-__stdcall static void
+static void
IoReuseIrp(ip, status)
irp *ip;
uint32_t status;
@@ -813,7 +815,7 @@ IoReuseIrp(ip, status)
return;
}
-__stdcall void
+void
IoAcquireCancelSpinLock(irql)
uint8_t *irql;
{
@@ -821,7 +823,7 @@ IoAcquireCancelSpinLock(irql)
return;
}
-__stdcall void
+void
IoReleaseCancelSpinLock(irql)
uint8_t irql;
{
@@ -829,7 +831,7 @@ IoReleaseCancelSpinLock(irql)
return;
}
-__stdcall uint8_t
+uint8_t
IoCancelIrp(irp *ip)
{
cancel_func cfunc;
@@ -845,8 +847,10 @@ IoCancelIrp(irp *ip)
return(TRUE);
}
-__fastcall uint32_t
-IofCallDriver(REGARGS2(device_object *dobj, irp *ip))
+uint32_t
+IofCallDriver(dobj, ip)
+ device_object *dobj;
+ irp *ip;
{
driver_object *drvobj;
io_stack_location *sl;
@@ -869,8 +873,10 @@ IofCallDriver(REGARGS2(device_object *dobj, irp *ip))
return(status);
}
-__fastcall void
-IofCompleteRequest(REGARGS2(irp *ip, uint8_t prioboost))
+void
+IofCompleteRequest(ip, prioboost)
+ irp *ip;
+ uint8_t prioboost;
{
uint32_t i;
uint32_t status;
@@ -915,8 +921,8 @@ IofCompleteRequest(REGARGS2(irp *ip, uint8_t prioboost))
mdl *m;
masterirp = ip->irp_assoc.irp_master;
- masterirpcnt = FASTCALL1(InterlockedDecrement,
- &masterirp->irp_assoc.irp_irpcnt);
+ masterirpcnt =
+ InterlockedDecrement(&masterirp->irp_assoc.irp_irpcnt);
while ((m = ip->irp_mdl) != NULL) {
ip->irp_mdl = m->mdl_next;
@@ -945,7 +951,7 @@ IofCompleteRequest(REGARGS2(irp *ip, uint8_t prioboost))
return;
}
-__stdcall device_object *
+device_object *
IoAttachDeviceToDeviceStack(src, dst)
device_object *src;
device_object *dst;
@@ -962,7 +968,7 @@ IoAttachDeviceToDeviceStack(src, dst)
return(attached);
}
-__stdcall void
+void
IoDetachDevice(topdev)
device_object *topdev;
{
@@ -1087,7 +1093,7 @@ ntoskrnl_time(tval)
* the non-signalled state once the wakeup is done.
*/
-__stdcall uint32_t
+uint32_t
KeWaitForSingleObject(obj, reason, mode, alertable, duetime)
nt_dispatch_header *obj;
uint32_t reason;
@@ -1200,7 +1206,7 @@ KeWaitForSingleObject(obj, reason, mode, alertable, duetime)
return(STATUS_SUCCESS);
}
-__stdcall static uint32_t
+static uint32_t
KeWaitForMultipleObjects(cnt, obj, wtype, reason, mode,
alertable, duetime, wb_array)
uint32_t cnt;
@@ -1345,7 +1351,7 @@ KeWaitForMultipleObjects(cnt, obj, wtype, reason, mode,
return(STATUS_SUCCESS);
}
-__stdcall static void
+static void
WRITE_REGISTER_USHORT(reg, val)
uint16_t *reg;
uint16_t val;
@@ -1354,14 +1360,14 @@ WRITE_REGISTER_USHORT(reg, val)
return;
}
-__stdcall static uint16_t
+static uint16_t
READ_REGISTER_USHORT(reg)
uint16_t *reg;
{
return(bus_space_read_2(NDIS_BUS_SPACE_MEM, 0x0, (bus_size_t)reg));
}
-__stdcall static void
+static void
WRITE_REGISTER_ULONG(reg, val)
uint32_t *reg;
uint32_t val;
@@ -1370,21 +1376,21 @@ WRITE_REGISTER_ULONG(reg, val)
return;
}
-__stdcall static uint32_t
+static uint32_t
READ_REGISTER_ULONG(reg)
uint32_t *reg;
{
return(bus_space_read_4(NDIS_BUS_SPACE_MEM, 0x0, (bus_size_t)reg));
}
-__stdcall static uint8_t
+static uint8_t
READ_REGISTER_UCHAR(reg)
uint8_t *reg;
{
return(bus_space_read_1(NDIS_BUS_SPACE_MEM, 0x0, (bus_size_t)reg));
}
-__stdcall static void
+static void
WRITE_REGISTER_UCHAR(reg, val)
uint8_t *reg;
uint8_t val;
@@ -1393,7 +1399,7 @@ WRITE_REGISTER_UCHAR(reg, val)
return;
}
-__stdcall static int64_t
+static int64_t
_allmul(a, b)
int64_t a;
int64_t b;
@@ -1401,7 +1407,7 @@ _allmul(a, b)
return (a * b);
}
-__stdcall static int64_t
+static int64_t
_alldiv(a, b)
int64_t a;
int64_t b;
@@ -1409,7 +1415,7 @@ _alldiv(a, b)
return (a / b);
}
-__stdcall static int64_t
+static int64_t
_allrem(a, b)
int64_t a;
int64_t b;
@@ -1417,7 +1423,7 @@ _allrem(a, b)
return (a % b);
}
-__stdcall static uint64_t
+static uint64_t
_aullmul(a, b)
uint64_t a;
uint64_t b;
@@ -1425,7 +1431,7 @@ _aullmul(a, b)
return (a * b);
}
-__stdcall static uint64_t
+static uint64_t
_aulldiv(a, b)
uint64_t a;
uint64_t b;
@@ -1433,7 +1439,7 @@ _aulldiv(a, b)
return (a / b);
}
-__stdcall static uint64_t
+static uint64_t
_aullrem(a, b)
uint64_t a;
uint64_t b;
@@ -1441,7 +1447,7 @@ _aullrem(a, b)
return (a % b);
}
-__regparm static int64_t
+static int64_t
_allshl(a, b)
int64_t a;
uint8_t b;
@@ -1449,7 +1455,7 @@ _allshl(a, b)
return (a << b);
}
-__regparm static uint64_t
+static uint64_t
_aullshl(a, b)
uint64_t a;
uint8_t b;
@@ -1457,7 +1463,7 @@ _aullshl(a, b)
return (a << b);
}
-__regparm static int64_t
+static int64_t
_allshr(a, b)
int64_t a;
uint8_t b;
@@ -1465,7 +1471,7 @@ _allshr(a, b)
return (a >> b);
}
-__regparm static uint64_t
+static uint64_t
_aullshr(a, b)
uint64_t a;
uint8_t b;
@@ -1532,7 +1538,7 @@ ntoskrnl_findwrap(func)
return(NULL);
}
-__stdcall static void
+static void
ExInitializePagedLookasideList(lookaside, allocfunc, freefunc,
flags, size, tag, depth)
paged_lookaside_list *lookaside;
@@ -1573,12 +1579,12 @@ ExInitializePagedLookasideList(lookaside, allocfunc, freefunc,
return;
}
-__stdcall static void
+static void
ExDeletePagedLookasideList(lookaside)
paged_lookaside_list *lookaside;
{
void *buf;
- __stdcall void (*freefunc)(void *);
+ void (*freefunc)(void *);
freefunc = lookaside->nll_l.gl_freefunc;
while((buf = ntoskrnl_popsl(&lookaside->nll_l.gl_listhead)) != NULL)
@@ -1587,7 +1593,7 @@ ExDeletePagedLookasideList(lookaside)
return;
}
-__stdcall static void
+static void
ExInitializeNPagedLookasideList(lookaside, allocfunc, freefunc,
flags, size, tag, depth)
npaged_lookaside_list *lookaside;
@@ -1628,12 +1634,12 @@ ExInitializeNPagedLookasideList(lookaside, allocfunc, freefunc,
return;
}
-__stdcall static void
+static void
ExDeleteNPagedLookasideList(lookaside)
npaged_lookaside_list *lookaside;
{
void *buf;
- __stdcall void (*freefunc)(void *);
+ void (*freefunc)(void *);
freefunc = lookaside->nll_l.gl_freefunc;
while((buf = ntoskrnl_popsl(&lookaside->nll_l.gl_listhead)) != NULL)
@@ -1642,39 +1648,34 @@ ExDeleteNPagedLookasideList(lookaside)
return;
}
-/*
- * Note: the interlocked slist push and pop routines are
- * declared to be _fastcall in Windows. gcc 3.4 is supposed
- * to have support for this calling convention, however we
- * don't have that version available yet, so we kludge things
- * up using __regparm__(3) and some argument shuffling.
- */
-
-__fastcall static slist_entry *
-InterlockedPushEntrySList(REGARGS2(slist_header *head, slist_entry *entry))
+static slist_entry *
+InterlockedPushEntrySList(head, entry)
+ slist_header *head;
+ slist_entry *entry;
{
slist_entry *oldhead;
- oldhead = (slist_entry *)FASTCALL3(ExInterlockedPushEntrySList,
- head, entry, &ntoskrnl_global);
+ oldhead = ExInterlockedPushEntrySList(head, entry, &ntoskrnl_global);
return(oldhead);
}
-__fastcall static slist_entry *
-InterlockedPopEntrySList(REGARGS1(slist_header *head))
+static slist_entry *
+InterlockedPopEntrySList(head)
+ slist_header *head;
{
slist_entry *first;
- first = (slist_entry *)FASTCALL2(ExInterlockedPopEntrySList,
- head, &ntoskrnl_global);
+ first = ExInterlockedPopEntrySList(head, &ntoskrnl_global);
return(first);
}
-__fastcall static slist_entry *
-ExInterlockedPushEntrySList(REGARGS2(slist_header *head,
- slist_entry *entry), kspin_lock *lock)
+static slist_entry *
+ExInterlockedPushEntrySList(head, entry, lock)
+ slist_header *head;
+ slist_entry *entry;
+ kspin_lock *lock;
{
slist_entry *oldhead;
uint8_t irql;
@@ -1686,8 +1687,10 @@ ExInterlockedPushEntrySList(REGARGS2(slist_header *head,
return(oldhead);
}
-__fastcall static slist_entry *
-ExInterlockedPopEntrySList(REGARGS2(slist_header *head, kspin_lock *lock))
+static slist_entry *
+ExInterlockedPopEntrySList(head, lock)
+ slist_header *head;
+ kspin_lock *lock;
{
slist_entry *first;
uint8_t irql;
@@ -1699,7 +1702,7 @@ ExInterlockedPopEntrySList(REGARGS2(slist_header *head, kspin_lock *lock))
return(first);
}
-__stdcall static uint16_t
+static uint16_t
ExQueryDepthSList(head)
slist_header *head;
{
@@ -1720,7 +1723,7 @@ ExQueryDepthSList(head)
* lock here because there is no complimentary KeFreeSpinLock()
* function. Instead, we grab a mutex from the mutex pool.
*/
-__stdcall void
+void
KeInitializeSpinLock(lock)
kspin_lock *lock;
{
@@ -1730,8 +1733,9 @@ KeInitializeSpinLock(lock)
}
#ifdef __i386__
-__fastcall void
-KefAcquireSpinLockAtDpcLevel(REGARGS1(kspin_lock *lock))
+void
+KefAcquireSpinLockAtDpcLevel(lock)
+ kspin_lock *lock;
{
while (atomic_cmpset_acq_int((volatile u_int *)lock, 0, 1) == 0)
/* sit and spin */;
@@ -1739,15 +1743,16 @@ KefAcquireSpinLockAtDpcLevel(REGARGS1(kspin_lock *lock))
return;
}
-__fastcall void
-KefReleaseSpinLockFromDpcLevel(REGARGS1(kspin_lock *lock))
+void
+KefReleaseSpinLockFromDpcLevel(lock)
+ kspin_lock *lock;
{
atomic_store_rel_int((volatile u_int *)lock, 0);
return;
}
-__stdcall uint8_t
+uint8_t
KeAcquireSpinLockRaiseToDpc(kspin_lock *lock)
{
uint8_t oldirql;
@@ -1761,7 +1766,7 @@ KeAcquireSpinLockRaiseToDpc(kspin_lock *lock)
return(oldirql);
}
#else
-__stdcall void
+void
KeAcquireSpinLockAtDpcLevel(kspin_lock *lock)
{
while (atomic_cmpset_acq_int((volatile u_int *)lock, 0, 1) == 0)
@@ -1770,7 +1775,7 @@ KeAcquireSpinLockAtDpcLevel(kspin_lock *lock)
return;
}
-__stdcall void
+void
KeReleaseSpinLockFromDpcLevel(kspin_lock *lock)
{
atomic_store_rel_int((volatile u_int *)lock, 0);
@@ -1779,8 +1784,10 @@ KeReleaseSpinLockFromDpcLevel(kspin_lock *lock)
}
#endif /* __i386__ */
-__fastcall uintptr_t
-InterlockedExchange(REGARGS2(volatile uint32_t *dst, uintptr_t val))
+uintptr_t
+InterlockedExchange(dst, val)
+ volatile uint32_t *dst;
+ uintptr_t val;
{
uint8_t irql;
uintptr_t r;
@@ -1793,22 +1800,26 @@ InterlockedExchange(REGARGS2(volatile uint32_t *dst, uintptr_t val))
return(r);
}
-__fastcall static uint32_t
-InterlockedIncrement(REGARGS1(volatile uint32_t *addend))
+static uint32_t
+InterlockedIncrement(addend)
+ volatile uint32_t *addend;
{
atomic_add_long((volatile u_long *)addend, 1);
return(*addend);
}
-__fastcall static uint32_t
-InterlockedDecrement(REGARGS1(volatile uint32_t *addend))
+static uint32_t
+InterlockedDecrement(addend)
+ volatile uint32_t *addend;
{
atomic_subtract_long((volatile u_long *)addend, 1);
return(*addend);
}
-__fastcall static void
-ExInterlockedAddLargeStatistic(REGARGS2(uint64_t *addend, uint32_t inc))
+static void
+ExInterlockedAddLargeStatistic(addend, inc)
+ uint64_t *addend;
+ uint32_t inc;
{
uint8_t irql;
@@ -1819,7 +1830,7 @@ ExInterlockedAddLargeStatistic(REGARGS2(uint64_t *addend, uint32_t inc))
return;
};
-__stdcall mdl *
+mdl *
IoAllocateMdl(vaddr, len, secondarybuf, chargequota, iopkt)
void *vaddr;
uint32_t len;
@@ -1869,7 +1880,7 @@ IoAllocateMdl(vaddr, len, secondarybuf, chargequota, iopkt)
return (m);
}
-__stdcall void
+void
IoFreeMdl(m)
mdl *m;
{
@@ -1884,7 +1895,7 @@ IoFreeMdl(m)
return;
}
-__stdcall static uint32_t
+static uint32_t
MmSizeOfMdl(vaddr, len)
void *vaddr;
size_t len;
@@ -1904,7 +1915,7 @@ MmSizeOfMdl(vaddr, len)
* Instead, we just fill in the page array with the kernel virtual
* addresses of the buffers.
*/
-__stdcall static void
+static void
MmBuildMdlForNonPagedPool(m)
mdl *m;
{
@@ -1927,7 +1938,7 @@ MmBuildMdlForNonPagedPool(m)
return;
}
-__stdcall static void *
+static void *
MmMapLockedPages(buf, accessmode)
mdl *buf;
uint8_t accessmode;
@@ -1936,7 +1947,7 @@ MmMapLockedPages(buf, accessmode)
return(MmGetMdlVirtualAddress(buf));
}
-__stdcall static void *
+static void *
MmMapLockedPagesSpecifyCache(buf, accessmode, cachetype, vaddr,
bugcheck, prio)
mdl *buf;
@@ -1949,7 +1960,7 @@ MmMapLockedPagesSpecifyCache(buf, accessmode, cachetype, vaddr,
return(MmMapLockedPages(buf, accessmode));
}
-__stdcall static void
+static void
MmUnmapLockedPages(vaddr, buf)
void *vaddr;
mdl *buf;
@@ -1958,7 +1969,7 @@ MmUnmapLockedPages(vaddr, buf)
return;
}
-__stdcall static size_t
+static size_t
RtlCompareMemory(s1, s2, len)
const void *s1;
const void *s2;
@@ -1977,7 +1988,7 @@ RtlCompareMemory(s1, s2, len)
return(total);
}
-__stdcall static void
+static void
RtlInitAnsiString(dst, src)
ndis_ansi_string *dst;
char *src;
@@ -1998,7 +2009,7 @@ RtlInitAnsiString(dst, src)
return;
}
-__stdcall static void
+static void
RtlInitUnicodeString(dst, src)
ndis_unicode_string *dst;
uint16_t *src;
@@ -2023,7 +2034,7 @@ RtlInitUnicodeString(dst, src)
return;
}
-__stdcall ndis_status
+ndis_status
RtlUnicodeStringToInteger(ustr, base, val)
ndis_unicode_string *ustr;
uint32_t base;
@@ -2077,7 +2088,7 @@ RtlUnicodeStringToInteger(ustr, base, val)
return(NDIS_STATUS_SUCCESS);
}
-__stdcall static void
+static void
RtlFreeUnicodeString(ustr)
ndis_unicode_string *ustr;
{
@@ -2088,7 +2099,7 @@ RtlFreeUnicodeString(ustr)
return;
}
-__stdcall static void
+static void
RtlFreeAnsiString(astr)
ndis_ansi_string *astr;
{
@@ -2131,7 +2142,7 @@ srand(seed)
return;
}
-__stdcall static uint8_t
+static uint8_t
IoIsWdmVersionAvailable(major, minor)
uint8_t major;
uint8_t minor;
@@ -2141,7 +2152,7 @@ IoIsWdmVersionAvailable(major, minor)
return(FALSE);
}
-__stdcall static ndis_status
+static ndis_status
IoGetDeviceProperty(devobj, regprop, buflen, prop, reslen)
device_object *devobj;
uint32_t regprop;
@@ -2168,7 +2179,7 @@ IoGetDeviceProperty(devobj, regprop, buflen, prop, reslen)
return(STATUS_SUCCESS);
}
-__stdcall static void
+static void
KeInitializeMutex(kmutex, level)
kmutant *kmutex;
uint32_t level;
@@ -2184,7 +2195,7 @@ KeInitializeMutex(kmutex, level)
return;
}
-__stdcall static uint32_t
+static uint32_t
KeReleaseMutex(kmutex, kwait)
kmutant *kmutex;
uint8_t kwait;
@@ -2204,14 +2215,14 @@ KeReleaseMutex(kmutex, kwait)
return(kmutex->km_acquirecnt);
}
-__stdcall static uint32_t
+static uint32_t
KeReadStateMutex(kmutex)
kmutant *kmutex;
{
return(kmutex->km_header.dh_sigstate);
}
-__stdcall void
+void
KeInitializeEvent(kevent, type, state)
nt_kevent *kevent;
uint32_t type;
@@ -2224,7 +2235,7 @@ KeInitializeEvent(kevent, type, state)
return;
}
-__stdcall uint32_t
+uint32_t
KeResetEvent(kevent)
nt_kevent *kevent;
{
@@ -2238,7 +2249,7 @@ KeResetEvent(kevent)
return(prevstate);
}
-__stdcall uint32_t
+uint32_t
KeSetEvent(kevent, increment, kwait)
nt_kevent *kevent;
uint32_t increment;
@@ -2254,7 +2265,7 @@ KeSetEvent(kevent, increment, kwait)
return(prevstate);
}
-__stdcall void
+void
KeClearEvent(kevent)
nt_kevent *kevent;
{
@@ -2262,14 +2273,14 @@ KeClearEvent(kevent)
return;
}
-__stdcall uint32_t
+uint32_t
KeReadStateEvent(kevent)
nt_kevent *kevent;
{
return(kevent->k_header.dh_sigstate);
}
-__stdcall static ndis_status
+static ndis_status
ObReferenceObjectByHandle(handle, reqaccess, otype,
accessmode, object, handleinfo)
ndis_handle handle;
@@ -2294,8 +2305,9 @@ ObReferenceObjectByHandle(handle, reqaccess, otype,
return(NDIS_STATUS_SUCCESS);
}
-__fastcall static void
-ObfDereferenceObject(REGARGS1(void *object))
+static void
+ObfDereferenceObject(object)
+ void *object;
{
nt_objref *nr;
@@ -2306,7 +2318,7 @@ ObfDereferenceObject(REGARGS1(void *object))
return;
}
-__stdcall static uint32_t
+static uint32_t
ZwClose(handle)
ndis_handle handle;
{
@@ -2322,7 +2334,7 @@ ntoskrnl_thrfunc(arg)
void *arg;
{
thread_context *thrctx;
- __stdcall uint32_t (*tfunc)(void *);
+ uint32_t (*tfunc)(void *);
void *tctx;
uint32_t rval;
@@ -2337,7 +2349,7 @@ ntoskrnl_thrfunc(arg)
return; /* notreached */
}
-__stdcall static ndis_status
+static ndis_status
PsCreateSystemThread(handle, reqaccess, objattrs, phandle,
clientid, thrfunc, thrctx)
ndis_handle *handle;
@@ -2378,7 +2390,7 @@ PsCreateSystemThread(handle, reqaccess, objattrs, phandle,
* reference list, and if someone holds a reference to us, we poke
* them.
*/
-__stdcall static ndis_status
+static ndis_status
PsTerminateSystemThread(status)
ndis_status status;
{
@@ -2415,7 +2427,7 @@ DbgPrint(char *fmt, ...)
return(STATUS_SUCCESS);
}
-__stdcall static void
+static void
DbgBreakPoint(void)
{
@@ -2469,7 +2481,7 @@ ntoskrnl_timercall(arg)
return;
}
-__stdcall void
+void
KeInitializeTimer(timer)
ktimer *timer;
{
@@ -2481,7 +2493,7 @@ KeInitializeTimer(timer)
return;
}
-__stdcall void
+void
KeInitializeTimerEx(timer, type)
ktimer *timer;
uint32_t type;
@@ -2509,7 +2521,7 @@ static void
ntoskrnl_run_dpc(arg)
void *arg;
{
- __stdcall kdpc_func dpcfunc;
+ kdpc_func dpcfunc;
kdpc *dpc;
uint8_t irql;
@@ -2523,7 +2535,7 @@ ntoskrnl_run_dpc(arg)
return;
}
-__stdcall void
+void
KeInitializeDpc(dpc, dpcfunc, dpcctx)
kdpc *dpc;
void *dpcfunc;
@@ -2539,7 +2551,7 @@ KeInitializeDpc(dpc, dpcfunc, dpcctx)
return;
}
-__stdcall uint8_t
+uint8_t
KeInsertQueueDpc(dpc, sysarg1, sysarg2)
kdpc *dpc;
void *sysarg1;
@@ -2554,7 +2566,7 @@ KeInsertQueueDpc(dpc, sysarg1, sysarg2)
return(TRUE);
}
-__stdcall uint8_t
+uint8_t
KeRemoveQueueDpc(dpc)
kdpc *dpc;
{
@@ -2564,7 +2576,7 @@ KeRemoveQueueDpc(dpc)
return(TRUE);
}
-__stdcall uint8_t
+uint8_t
KeSetTimerEx(timer, duetime, period, dpc)
ktimer *timer;
int64_t duetime;
@@ -2615,7 +2627,7 @@ KeSetTimerEx(timer, duetime, period, dpc)
return(pending);
}
-__stdcall uint8_t
+uint8_t
KeSetTimer(timer, duetime, dpc)
ktimer *timer;
int64_t duetime;
@@ -2624,7 +2636,7 @@ KeSetTimer(timer, duetime, dpc)
return (KeSetTimerEx(timer, duetime, 0, dpc));
}
-__stdcall uint8_t
+uint8_t
KeCancelTimer(timer)
ktimer *timer;
{
@@ -2646,14 +2658,14 @@ KeCancelTimer(timer)
return(pending);
}
-__stdcall uint8_t
+uint8_t
KeReadStateTimer(timer)
ktimer *timer;
{
return(timer->k_header.dh_sigstate);
}
-__stdcall static void
+static void
dummy()
{
printf ("ntoskrnl dummy called...\n");
@@ -2662,91 +2674,92 @@ dummy()
image_patch_table ntoskrnl_functbl[] = {
- IMPORT_FUNC(RtlCompareMemory),
- IMPORT_FUNC(RtlEqualUnicodeString),
- IMPORT_FUNC(RtlCopyUnicodeString),
- IMPORT_FUNC(RtlUnicodeStringToAnsiString),
- IMPORT_FUNC(RtlAnsiStringToUnicodeString),
- IMPORT_FUNC(RtlInitAnsiString),
- IMPORT_FUNC_MAP(RtlInitString, RtlInitAnsiString),
- IMPORT_FUNC(RtlInitUnicodeString),
- IMPORT_FUNC(RtlFreeAnsiString),
- IMPORT_FUNC(RtlFreeUnicodeString),
- IMPORT_FUNC(RtlUnicodeStringToInteger),
- IMPORT_FUNC(sprintf),
- IMPORT_FUNC(vsprintf),
- IMPORT_FUNC_MAP(_snprintf, snprintf),
- IMPORT_FUNC_MAP(_vsnprintf, vsnprintf),
- IMPORT_FUNC(DbgPrint),
- IMPORT_FUNC(DbgBreakPoint),
- IMPORT_FUNC(strncmp),
- IMPORT_FUNC(strcmp),
- IMPORT_FUNC(strncpy),
- IMPORT_FUNC(strcpy),
- IMPORT_FUNC(strlen),
- IMPORT_FUNC(memcpy),
- IMPORT_FUNC_MAP(memmove, ntoskrnl_memset),
- IMPORT_FUNC_MAP(memset, ntoskrnl_memset),
- IMPORT_FUNC(IoAllocateDriverObjectExtension),
- IMPORT_FUNC(IoGetDriverObjectExtension),
- IMPORT_FUNC(IofCallDriver),
- IMPORT_FUNC(IofCompleteRequest),
- IMPORT_FUNC(IoAcquireCancelSpinLock),
- IMPORT_FUNC(IoReleaseCancelSpinLock),
- IMPORT_FUNC(IoCancelIrp),
- IMPORT_FUNC(IoCreateDevice),
- IMPORT_FUNC(IoDeleteDevice),
- IMPORT_FUNC(IoGetAttachedDevice),
- IMPORT_FUNC(IoAttachDeviceToDeviceStack),
- IMPORT_FUNC(IoDetachDevice),
- IMPORT_FUNC(IoBuildSynchronousFsdRequest),
- IMPORT_FUNC(IoBuildAsynchronousFsdRequest),
- IMPORT_FUNC(IoBuildDeviceIoControlRequest),
- IMPORT_FUNC(IoAllocateIrp),
- IMPORT_FUNC(IoReuseIrp),
- IMPORT_FUNC(IoMakeAssociatedIrp),
- IMPORT_FUNC(IoFreeIrp),
- IMPORT_FUNC(IoInitializeIrp),
- IMPORT_FUNC(KeWaitForSingleObject),
- IMPORT_FUNC(KeWaitForMultipleObjects),
- IMPORT_FUNC(_allmul),
- IMPORT_FUNC(_alldiv),
- IMPORT_FUNC(_allrem),
- IMPORT_FUNC(_allshr),
- IMPORT_FUNC(_allshl),
- IMPORT_FUNC(_aullmul),
- IMPORT_FUNC(_aulldiv),
- IMPORT_FUNC(_aullrem),
- IMPORT_FUNC(_aullshr),
- IMPORT_FUNC(_aullshl),
- IMPORT_FUNC(atoi),
- IMPORT_FUNC(atol),
- IMPORT_FUNC(rand),
- IMPORT_FUNC(srand),
- IMPORT_FUNC(WRITE_REGISTER_USHORT),
- IMPORT_FUNC(READ_REGISTER_USHORT),
- IMPORT_FUNC(WRITE_REGISTER_ULONG),
- IMPORT_FUNC(READ_REGISTER_ULONG),
- IMPORT_FUNC(READ_REGISTER_UCHAR),
- IMPORT_FUNC(WRITE_REGISTER_UCHAR),
- IMPORT_FUNC(ExInitializePagedLookasideList),
- IMPORT_FUNC(ExDeletePagedLookasideList),
- IMPORT_FUNC(ExInitializeNPagedLookasideList),
- IMPORT_FUNC(ExDeleteNPagedLookasideList),
- IMPORT_FUNC(InterlockedPopEntrySList),
- IMPORT_FUNC(InterlockedPushEntrySList),
- IMPORT_FUNC(ExQueryDepthSList),
- IMPORT_FUNC_MAP(ExpInterlockedPopEntrySList, InterlockedPopEntrySList),
- IMPORT_FUNC_MAP(ExpInterlockedPushEntrySList,
- InterlockedPushEntrySList),
- IMPORT_FUNC(ExInterlockedPopEntrySList),
- IMPORT_FUNC(ExInterlockedPushEntrySList),
- IMPORT_FUNC(ExAllocatePoolWithTag),
- IMPORT_FUNC(ExFreePool),
+ IMPORT_SFUNC(RtlCompareMemory, 3),
+ IMPORT_SFUNC(RtlEqualUnicodeString, 3),
+ IMPORT_SFUNC(RtlCopyUnicodeString, 2),
+ IMPORT_SFUNC(RtlUnicodeStringToAnsiString, 3),
+ IMPORT_SFUNC(RtlAnsiStringToUnicodeString, 3),
+ IMPORT_SFUNC(RtlInitAnsiString, 2),
+ IMPORT_SFUNC_MAP(RtlInitString, RtlInitAnsiString, 2),
+ IMPORT_SFUNC(RtlInitUnicodeString, 2),
+ IMPORT_SFUNC(RtlFreeAnsiString, 1),
+ IMPORT_SFUNC(RtlFreeUnicodeString, 1),
+ IMPORT_SFUNC(RtlUnicodeStringToInteger, 3),
+ IMPORT_CFUNC(sprintf, 0),
+ IMPORT_CFUNC(vsprintf, 0),
+ IMPORT_CFUNC_MAP(_snprintf, snprintf, 0),
+ IMPORT_CFUNC_MAP(_vsnprintf, vsnprintf, 0),
+ IMPORT_CFUNC(DbgPrint, 0),
+ IMPORT_SFUNC(DbgBreakPoint, 0),
+ IMPORT_CFUNC(strncmp, 0),
+ IMPORT_CFUNC(strcmp, 0),
+ IMPORT_CFUNC(strncpy, 0),
+ IMPORT_CFUNC(strcpy, 0),
+ IMPORT_CFUNC(strlen, 0),
+ IMPORT_CFUNC(memcpy, 0),
+ IMPORT_CFUNC_MAP(memmove, ntoskrnl_memset, 0),
+ IMPORT_CFUNC_MAP(memset, ntoskrnl_memset, 0),
+ IMPORT_SFUNC(IoAllocateDriverObjectExtension, 4),
+ IMPORT_SFUNC(IoGetDriverObjectExtension, 2),
+ IMPORT_FFUNC(IofCallDriver, 2),
+ IMPORT_FFUNC(IofCompleteRequest, 2),
+ IMPORT_SFUNC(IoAcquireCancelSpinLock, 1),
+ IMPORT_SFUNC(IoReleaseCancelSpinLock, 1),
+ IMPORT_SFUNC(IoCancelIrp, 1),
+ IMPORT_SFUNC(IoCreateDevice, 7),
+ IMPORT_SFUNC(IoDeleteDevice, 1),
+ IMPORT_SFUNC(IoGetAttachedDevice, 1),
+ IMPORT_SFUNC(IoAttachDeviceToDeviceStack, 2),
+ IMPORT_SFUNC(IoDetachDevice, 1),
+ IMPORT_SFUNC(IoBuildSynchronousFsdRequest, 7),
+ IMPORT_SFUNC(IoBuildAsynchronousFsdRequest, 6),
+ IMPORT_SFUNC(IoBuildDeviceIoControlRequest, 9),
+ IMPORT_SFUNC(IoAllocateIrp, 2),
+ IMPORT_SFUNC(IoReuseIrp, 2),
+ IMPORT_SFUNC(IoMakeAssociatedIrp, 2),
+ IMPORT_SFUNC(IoFreeIrp, 1),
+ IMPORT_SFUNC(IoInitializeIrp, 3),
+ IMPORT_SFUNC(KeWaitForSingleObject, 5),
+ IMPORT_SFUNC(KeWaitForMultipleObjects, 8),
+ IMPORT_SFUNC(_allmul, 2),
+ IMPORT_SFUNC(_alldiv, 2),
+ IMPORT_SFUNC(_allrem, 2),
+ IMPORT_RFUNC(_allshr, 0),
+ IMPORT_RFUNC(_allshl, 0),
+ IMPORT_SFUNC(_aullmul, 2),
+ IMPORT_SFUNC(_aulldiv, 2),
+ IMPORT_SFUNC(_aullrem, 2),
+ IMPORT_RFUNC(_aullshr, 0),
+ IMPORT_RFUNC(_aullshl, 0),
+ IMPORT_CFUNC(atoi, 0),
+ IMPORT_CFUNC(atol, 0),
+ IMPORT_CFUNC(rand, 0),
+ IMPORT_CFUNC(srand, 0),
+ IMPORT_SFUNC(WRITE_REGISTER_USHORT, 2),
+ IMPORT_SFUNC(READ_REGISTER_USHORT, 1),
+ IMPORT_SFUNC(WRITE_REGISTER_ULONG, 2),
+ IMPORT_SFUNC(READ_REGISTER_ULONG, 1),
+ IMPORT_SFUNC(READ_REGISTER_UCHAR, 1),
+ IMPORT_SFUNC(WRITE_REGISTER_UCHAR, 2),
+ IMPORT_SFUNC(ExInitializePagedLookasideList, 7),
+ IMPORT_SFUNC(ExDeletePagedLookasideList, 1),
+ IMPORT_SFUNC(ExInitializeNPagedLookasideList, 7),
+ IMPORT_SFUNC(ExDeleteNPagedLookasideList, 1),
+ IMPORT_FFUNC(InterlockedPopEntrySList, 1),
+ IMPORT_FFUNC(InterlockedPushEntrySList, 2),
+ IMPORT_SFUNC(ExQueryDepthSList, 1),
+ IMPORT_FFUNC_MAP(ExpInterlockedPopEntrySList,
+ InterlockedPopEntrySList, 1),
+ IMPORT_FFUNC_MAP(ExpInterlockedPushEntrySList,
+ InterlockedPushEntrySList, 2),
+ IMPORT_FFUNC(ExInterlockedPopEntrySList, 2),
+ IMPORT_FFUNC(ExInterlockedPushEntrySList, 3),
+ IMPORT_SFUNC(ExAllocatePoolWithTag, 3),
+ IMPORT_SFUNC(ExFreePool, 1),
#ifdef __i386__
- IMPORT_FUNC(KefAcquireSpinLockAtDpcLevel),
- IMPORT_FUNC(KefReleaseSpinLockFromDpcLevel),
- IMPORT_FUNC(KeAcquireSpinLockRaiseToDpc),
+ IMPORT_FFUNC(KefAcquireSpinLockAtDpcLevel, 1),
+ IMPORT_FFUNC(KefReleaseSpinLockFromDpcLevel,1),
+ IMPORT_FFUNC(KeAcquireSpinLockRaiseToDpc, 1),
#else
/*
* For AMD64, we can get away with just mapping
@@ -2755,46 +2768,47 @@ image_patch_table ntoskrnl_functbl[] = {
* On i386, we have to be careful because KfAcquireSpinLock()
* is _fastcall but KeAcquireSpinLockRaiseToDpc() isn't.
*/
- IMPORT_FUNC(KeAcquireSpinLockAtDpcLevel),
- IMPORT_FUNC(KeReleaseSpinLockFromDpcLevel),
- IMPORT_FUNC_MAP(KeAcquireSpinLockRaiseToDpc, KfAcquireSpinLock),
+ IMPORT_SFUNC(KeAcquireSpinLockAtDpcLevel, 1),
+ IMPORT_SFUNC(KeReleaseSpinLockFromDpcLevel, 1),
+ IMPORT_SFUNC_MAP(KeAcquireSpinLockRaiseToDpc, KfAcquireSpinLock, 1),
#endif
- IMPORT_FUNC_MAP(KeReleaseSpinLock, KfReleaseSpinLock),
- IMPORT_FUNC(InterlockedIncrement),
- IMPORT_FUNC(InterlockedDecrement),
- IMPORT_FUNC(ExInterlockedAddLargeStatistic),
- IMPORT_FUNC(IoAllocateMdl),
- IMPORT_FUNC(IoFreeMdl),
- IMPORT_FUNC(MmSizeOfMdl),
- IMPORT_FUNC(MmMapLockedPages),
- IMPORT_FUNC(MmMapLockedPagesSpecifyCache),
- IMPORT_FUNC(MmUnmapLockedPages),
- IMPORT_FUNC(MmBuildMdlForNonPagedPool),
- IMPORT_FUNC(KeInitializeSpinLock),
- IMPORT_FUNC(IoIsWdmVersionAvailable),
- IMPORT_FUNC(IoGetDeviceProperty),
- IMPORT_FUNC(KeInitializeMutex),
- IMPORT_FUNC(KeReleaseMutex),
- IMPORT_FUNC(KeReadStateMutex),
- IMPORT_FUNC(KeInitializeEvent),
- IMPORT_FUNC(KeSetEvent),
- IMPORT_FUNC(KeResetEvent),
- IMPORT_FUNC(KeClearEvent),
- IMPORT_FUNC(KeReadStateEvent),
- IMPORT_FUNC(KeInitializeTimer),
- IMPORT_FUNC(KeInitializeTimerEx),
- IMPORT_FUNC(KeSetTimer),
- IMPORT_FUNC(KeSetTimerEx),
- IMPORT_FUNC(KeCancelTimer),
- IMPORT_FUNC(KeReadStateTimer),
- IMPORT_FUNC(KeInitializeDpc),
- IMPORT_FUNC(KeInsertQueueDpc),
- IMPORT_FUNC(KeRemoveQueueDpc),
- IMPORT_FUNC(ObReferenceObjectByHandle),
- IMPORT_FUNC(ObfDereferenceObject),
- IMPORT_FUNC(ZwClose),
- IMPORT_FUNC(PsCreateSystemThread),
- IMPORT_FUNC(PsTerminateSystemThread),
+ IMPORT_SFUNC_MAP(KeReleaseSpinLock, KfReleaseSpinLock, 1),
+ IMPORT_FFUNC(InterlockedIncrement, 1),
+ IMPORT_FFUNC(InterlockedDecrement, 1),
+ IMPORT_FFUNC(InterlockedExchange, 2),
+ IMPORT_FFUNC(ExInterlockedAddLargeStatistic, 2),
+ IMPORT_SFUNC(IoAllocateMdl, 5),
+ IMPORT_SFUNC(IoFreeMdl, 1),
+ IMPORT_SFUNC(MmSizeOfMdl, 1),
+ IMPORT_SFUNC(MmMapLockedPages, 2),
+ IMPORT_SFUNC(MmMapLockedPagesSpecifyCache, 6),
+ IMPORT_SFUNC(MmUnmapLockedPages, 2),
+ IMPORT_SFUNC(MmBuildMdlForNonPagedPool, 1),
+ IMPORT_SFUNC(KeInitializeSpinLock, 1),
+ IMPORT_SFUNC(IoIsWdmVersionAvailable, 2),
+ IMPORT_SFUNC(IoGetDeviceProperty, 5),
+ IMPORT_SFUNC(KeInitializeMutex, 2),
+ IMPORT_SFUNC(KeReleaseMutex, 2),
+ IMPORT_SFUNC(KeReadStateMutex, 1),
+ IMPORT_SFUNC(KeInitializeEvent, 3),
+ IMPORT_SFUNC(KeSetEvent, 3),
+ IMPORT_SFUNC(KeResetEvent, 1),
+ IMPORT_SFUNC(KeClearEvent, 1),
+ IMPORT_SFUNC(KeReadStateEvent, 1),
+ IMPORT_SFUNC(KeInitializeTimer, 1),
+ IMPORT_SFUNC(KeInitializeTimerEx, 2),
+ IMPORT_SFUNC(KeSetTimer, 3),
+ IMPORT_SFUNC(KeSetTimerEx, 4),
+ IMPORT_SFUNC(KeCancelTimer, 1),
+ IMPORT_SFUNC(KeReadStateTimer, 1),
+ IMPORT_SFUNC(KeInitializeDpc, 3),
+ IMPORT_SFUNC(KeInsertQueueDpc, 3),
+ IMPORT_SFUNC(KeRemoveQueueDpc, 1),
+ IMPORT_SFUNC(ObReferenceObjectByHandle, 6),
+ IMPORT_FFUNC(ObfDereferenceObject, 1),
+ IMPORT_SFUNC(ZwClose, 1),
+ IMPORT_SFUNC(PsCreateSystemThread, 7),
+ IMPORT_SFUNC(PsTerminateSystemThread, 1),
/*
* This last entry is a catch-all for any function we haven't
@@ -2803,7 +2817,7 @@ image_patch_table ntoskrnl_functbl[] = {
* in this table.
*/
- { NULL, (FUNC)dummy, NULL },
+ { NULL, (FUNC)dummy, NULL, 0, WINDRV_WRAP_CDECL },
/* End of list. */
diff --git a/sys/compat/ndis/subr_usbd.c b/sys/compat/ndis/subr_usbd.c
index a9b30e4..8df78a4 100644
--- a/sys/compat/ndis/subr_usbd.c
+++ b/sys/compat/ndis/subr_usbd.c
@@ -59,10 +59,10 @@ __FBSDID("$FreeBSD$");
static driver_object usbd_driver;
-__stdcall static uint32_t usbd_iodispatch(device_object *, irp *);
+static uint32_t usbd_iodispatch(device_object *, irp *);
-__stdcall static void USBD_GetUSBDIVersion(usbd_version_info *);
-__stdcall static void dummy(void);
+static void USBD_GetUSBDIVersion(usbd_version_info *);
+static void dummy(void);
int
usbd_libinit(void)
@@ -72,7 +72,8 @@ usbd_libinit(void)
patch = usbd_functbl;
while (patch->ipt_func != NULL) {
windrv_wrap((funcptr)patch->ipt_func,
- (funcptr *)&patch->ipt_wrap);
+ (funcptr *)&patch->ipt_wrap,
+ patch->ipt_argcnt, patch->ipt_ftype);
patch++;
}
@@ -104,7 +105,7 @@ usbd_libfini(void)
return(0);
}
-__stdcall static uint32_t
+static uint32_t
usbd_iodispatch(dobj, ip)
device_object *dobj;
irp *ip;
@@ -112,7 +113,7 @@ usbd_iodispatch(dobj, ip)
return(0);
}
-__stdcall static void
+static void
USBD_GetUSBDIVersion(ui)
usbd_version_info *ui;
{
@@ -124,7 +125,7 @@ USBD_GetUSBDIVersion(ui)
return;
}
-__stdcall static void
+static void
dummy(void)
{
printf("USBD dummy called\n");
@@ -132,7 +133,8 @@ dummy(void)
}
image_patch_table usbd_functbl[] = {
- IMPORT_FUNC(USBD_GetUSBDIVersion),
+ IMPORT_SFUNC(USBD_GetUSBDIVersion, 0),
+ IMPORT_SFUNC(usbd_iodispatch, 2),
#ifdef notyet
IMPORT_FUNC_MAP(_USBD_ParseConfigurationDescriptorEx@28,
USBD_ParseConfigurationDescriptorEx),
@@ -147,7 +149,7 @@ image_patch_table usbd_functbl[] = {
* in this table.
*/
- { NULL, (FUNC)dummy, NULL },
+ { NULL, (FUNC)dummy, NULL, 0, WINDRV_WRAP_CDECL },
/* End of list. */
diff --git a/sys/compat/ndis/winx32_wrap.S b/sys/compat/ndis/winx32_wrap.S
new file mode 100644
index 0000000..4014e88
--- /dev/null
+++ b/sys/compat/ndis/winx32_wrap.S
@@ -0,0 +1,354 @@
+/*-
+ * Copyright (c) 2005
+ * Bill Paul <wpaul@windriver.com>. 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asmacros.h>
+
+/*
+ * This file contains assembly language wrappers for the different
+ * calling conventions supported by Windows on the i386 architecture.
+ * In FreeBSD, the whole OS typically use same C calling convention
+ * everywhere, namely _cdecl. Windows, on the other hand, uses several
+ * different C calling conventions depending on the circumstances:
+ *
+ * _stdcall: Used for most ordinary Windows APIs. With _stdcall,
+ * arguments are passed on the stack, and the callee unwinds the stack
+ * before returning control to the caller. Not suitable for variadic
+ * functions.
+ *
+ * _fastcall: Used for some APIs that may be invoked frequently and
+ * where speed is a critical factor (e.g. KeAcquireSpinLock() and
+ * KeReleaseSpinLock()) Similar to _stdcall, except the first 2 32-bit
+ * or smaller arguments are passed in the %ecx and %edx registers
+ * instead of on the stack. Not suitable for variadic functions.
+ *
+ * _cdecl: Used for standard C library routines and for variadic
+ * functions.
+ *
+ * _regparm(3): Used for certain assembly routines. All arguments
+ * passed in %eax, %ecx and %edx.
+ *
+ * Furthermore, there is an additional wrinkle that's not obvious
+ * with all code: Microsoft supports the use of exceptions in C
+ * (__try/__except) both in user _and_ kernel mode. Sadly, Windows
+ * structured exception handling uses machine-specific features
+ * that conflict rather badly with FreeBSD. (See utility routines
+ * at the end of this module for more details.)
+ *
+ * We want to support these calling conventions in as portable a manner
+ * as possible. The trick is doing it not only with different versions
+ * of GNU C, but with compilers other than GNU C (e.g. the Solaris
+ * SunOne C compiler). The only sure fire method is with assembly
+ * language trampoline code which both fixes up the argument passing,
+ * stack unwinding and exception/thread context all at once.
+ *
+ * You'll notice that we call the thunk/unthunk routines in the
+ * *_wrap() functions in an awkward way. Rather than branching
+ * directly to the address, we load the address into a register
+ * first as a literal value, then we branch to it. This is done
+ * to insure that the assembler doesn't translate the branch into
+ * a relative branch. We use the *_wrap() routines here as templates
+ * and create the actual trampolines at run time, at which point
+ * we only know the absolute addresses of the thunk and unthunk
+ * routines. So we need to make sure the templates have enough
+ * room in them for the full address.
+ */
+
+/*
+ * Handle _stdcall going from Windows to UNIX.
+ * This is frustrating, because to do it right you have to
+ * know how many arguments the called function takes, and there's
+ * no way to figure this out on the fly: you just have to be told
+ * ahead of time. We assume there will be 16 arguments. I don't
+ * think there are any Windows APIs that require this many.
+ */
+
+ .globl x86_stdcall_wrap_call
+ .globl x86_stdcall_wrap_arg
+ .globl x86_stdcall_wrap_end
+
+ENTRY(x86_stdcall_wrap)
+ push %esi
+ push %edi
+ sub $64,%esp
+ mov %esp,%esi
+ add $64+8+4,%esi
+ mov %esp,%edi
+ mov $16,%ecx # handle up to 16 args
+ rep
+ movsl
+
+ movl $ctxsw_wtou, %eax
+ call *%eax # unthunk
+
+x86_stdcall_wrap_call:
+ movl $0,%eax
+ call *%eax # jump to routine
+ mov %eax,%esi # preserve return val
+
+ movl $ctxsw_utow, %eax
+ call *%eax # thunk
+
+ add $64,%esp # clean the stack
+ mov %esi,%eax # restore return val
+ pop %edi
+ pop %esi
+x86_stdcall_wrap_arg:
+ ret $0xFF
+x86_stdcall_wrap_end:
+
+
+/*
+ * Handle _stdcall going from UNIX to Windows. This routine
+ * expects to be passed the function to be called, number of
+ * args and the arguments for the Windows function on the stack.
+ */
+
+ENTRY(x86_stdcall_call)
+ push %esi # must preserve %esi
+ push %edi # and %edi
+
+ mov 16(%esp),%eax # get arg cnt
+ mov %eax,%ecx # save as copy count
+ mov %esp,%esi # Set source address register to point to
+ add $20,%esi # first agument to be forwarded.
+ shl $2,%eax # turn arg cnt into offset
+ sub %eax,%esp # shift stack to new location
+ mov %esp,%edi # store dest copy addr
+ rep # do the copy
+ movsl
+
+ call ctxsw_utow # thunk
+
+ call *12(%edi) # branch to stdcall routine
+ mov %eax,%esi # preserve return val
+
+ call ctxsw_wtou # unthunk
+
+ mov %edi,%esp # restore stack
+ mov %esi,%eax # restore return val
+ pop %edi # restore %edi
+ pop %esi # and %esi
+ ret
+
+/*
+ * Fastcall support. Similar to _stdcall, except the first
+ * two arguments are passed in %ecx and %edx. It happens we
+ * only support a small number of _fastcall APIs, none of them
+ * take more than three arguments. So to keep the code size
+ * and complexity down, we only handle 3 arguments here.
+ */
+
+/* Call _fastcall function going from Windows to UNIX. */
+
+ .globl x86_fastcall_wrap_call
+ .globl x86_fastcall_wrap_arg
+ .globl x86_fastcall_wrap_end
+
+ENTRY(x86_fastcall_wrap)
+ mov 4(%esp),%eax
+ push %eax
+ push %edx
+ push %ecx
+
+ movl $ctxsw_wtou, %eax
+ call *%eax # unthunk
+
+x86_fastcall_wrap_call:
+ mov $0,%eax
+ call *%eax # branch to fastcall routine
+
+ movl $ctxsw_utow, %eax
+ call *%eax # thunk
+
+ add $12,%esp # clean the stack
+x86_fastcall_wrap_arg:
+ ret $0xFF
+x86_fastcall_wrap_end:
+
+/*
+ * Call _fastcall function going from UNIX to Windows.
+ * This routine isn't normally used since NDIS miniport drivers
+ * only have _stdcall entry points, but it's provided anyway
+ * to round out the API, and for testing purposes.
+ */
+
+ENTRY(x86_fastcall_call)
+ mov 4(%esp),%eax
+ push 16(%esp)
+
+ call ctxsw_utow # thunk
+
+ mov 12(%esp),%ecx
+ mov 16(%esp),%edx
+ call *8(%esp) # branch to fastcall routine
+ mov %eax,%esi # preserve return val
+
+ call ctxsw_wtou # unthunk
+
+ mov %esi,%eax # restore return val
+ add $4,%esp # clean the stack
+ ret
+
+/*
+ * Call regparm(3) function going from Windows to UNIX. Arguments
+ * are passed in %eax, %edx and %ecx. Note that while additional
+ * arguments are passed on the stack, we never bother when them,
+ * since the only regparm(3) routines we need to wrap never take
+ * more than 3 arguments.
+ */
+
+ .globl x86_regparm_wrap_call
+ .globl x86_regparm_wrap_end
+
+ENTRY(x86_regparm_wrap)
+ push %ecx
+ push %edx
+ push %eax
+
+ movl $ctxsw_wtou, %eax
+ call *%eax # unthunk
+
+x86_regparm_wrap_call:
+ movl $0,%eax
+ call *%eax # jump to routine
+ mov %eax,%esi # preserve return val
+ mov %edx,%edi # preserve return val
+
+ movl $ctxsw_utow, %eax
+ call *%eax # thunk
+
+ mov %esi,%eax # restore return val
+ mov %edi,%edx # restore return val
+ add $12,%esp # restore stack
+ ret
+x86_regparm_wrap_end:
+
+/*
+ * Call regparm(3) function going from UNIX to Windows.
+ * This routine isn't normally used since NDIS miniport drivers
+ * only have _stdcall entry points, but it's provided anyway
+ * to round out the API, and for testing purposes.
+ */
+
+ENTRY(x86_regparm_call)
+ call ctxsw_utow # thunk
+
+ mov 8(%esp),%eax
+ mov 12(%esp),%edx
+ mov 16(%esp),%ecx
+ call *4(%esp) # branch to fastcall routine
+ mov %eax,%esi # preserve return val
+ mov %edx,%edi # preserve return val
+
+ call ctxsw_wtou # unthunk
+
+ mov %esi,%eax # restore return val
+ mov %edi,%edx # restore return val
+ ret
+
+/*
+ * Ugly hack alert:
+ *
+ * On Win32/i386, using __try/__except results in code that tries to
+ * manipulate what's supposed to be the Windows Threada Environment
+ * Block (TEB), which one accesses via the %fs register. In particular,
+ * %fs:0 (the first DWORD in the TEB) points to the exception
+ * registration list. Unfortunately, FreeBSD uses %fs for the
+ * per-cpu data structure (pcpu), and we can't allow Windows code
+ * to muck with that. I don't even know what Solaris uses %fs for
+ * (or if it even uses it at all).
+ *
+ * Even worse, in 32-bit protected mode, %fs is a selector that
+ * refers to an entry in either the GDT or the LDT. Ideally, we would
+ * like to be able to temporarily point it at another descriptor
+ * while Windows code executes, but to do that we need a separate
+ * descriptor entry of our own to play with.
+ *
+ * Therefore, we go to some trouble to learn the existing layout of
+ * the GDT and update it to include an extra entry that we can use.
+ * We need the following utility routines to help us do that. On
+ * FreeBSD, index #7 in the GDT happens to be unused, so we turn
+ * this into our own data segment descriptor. It would be better
+ * if we could use a private LDT entry, but there's no easy way to
+ * do that in SMP mode because of the way FreeBSD handles user LDTs.
+ *
+ * Once we have a custom descriptor, we have to thunk/unthunk whenever
+ * we cross between FreeBSD code and Windows code. The thunking is
+ * based on the premise that when executing instructions in the
+ * Windows binary itself, we won't go to sleep. This is because in
+ * order to yield the CPU, the code has to call back out to a FreeBSD
+ * routine first, and when that happens we can unthunk in order to
+ * restore FreeBSD context. What we're desperately trying to avoid is
+ * being involuntarily pre-empted with the %fs register still pointing
+ * to our fake TIB: if FreeBSD code runs with %fs pointing at our
+ * Windows TIB instead of pcpu, we'll panic the kernel. Fortunately,
+ * the only way involuntary preemption can occur is if an interrupt
+ * fires, and the trap handler saves/restores %fs for us.
+ *
+ * The thunking routines themselves, ctxsw_utow() (Context SWitch UNIX
+ * to Windows) and ctxsw_wtou() (Context SWitch Windows to UNIX), are
+ * external to this module. This is done simply because it's easier
+ * to manipulate data structures in C rather than assembly.
+ */
+
+ENTRY(x86_getldt)
+ movl 4(%esp),%eax
+ sgdtl (%eax)
+ movl 8(%esp),%eax
+ sldt (%eax)
+ xor %eax,%eax
+ ret
+
+ENTRY(x86_setldt)
+ movl 4(%esp),%eax
+ lgdt (%eax)
+ jmp 1f
+ nop
+1:
+ movl 8(%esp),%eax
+ lldt %ax
+ xor %eax,%eax
+ ret
+
+ENTRY(x86_getfs)
+ mov %fs,%ax
+ ret
+
+ENTRY(x86_setfs)
+ movl 4(%esp),%fs
+ ret
+
+ENTRY(x86_gettid)
+ mov %fs:12,%eax
+ ret
diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index 57dd266..45da8c9 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -94,13 +94,10 @@ void ndis_shutdown (device_t);
int ndisdrv_modevent (module_t, int, void *);
-static __stdcall void ndis_txeof (ndis_handle,
- ndis_packet *, ndis_status);
-static __stdcall void ndis_rxeof (ndis_handle,
- ndis_packet **, uint32_t);
-static __stdcall void ndis_linksts (ndis_handle,
- ndis_status, void *, uint32_t);
-static __stdcall void ndis_linksts_done (ndis_handle);
+static void ndis_txeof (ndis_handle, ndis_packet *, ndis_status);
+static void ndis_rxeof (ndis_handle, ndis_packet **, uint32_t);
+static void ndis_linksts (ndis_handle, ndis_status, void *, uint32_t);
+static void ndis_linksts_done (ndis_handle);
/* We need to wrap these functions for amd64. */
@@ -157,12 +154,16 @@ ndisdrv_modevent(mod, cmd, arg)
ndisdrv_loaded++;
if (ndisdrv_loaded > 1)
break;
- windrv_load(mod, (vm_offset_t)drv_data, 0);
- windrv_wrap((funcptr)ndis_rxeof, &ndis_rxeof_wrap);
- windrv_wrap((funcptr)ndis_txeof, &ndis_txeof_wrap);
- windrv_wrap((funcptr)ndis_linksts, &ndis_linksts_wrap);
+ if (windrv_load(mod, (vm_offset_t)drv_data, 0))
+ return(EINVAL);
+ windrv_wrap((funcptr)ndis_rxeof, &ndis_rxeof_wrap,
+ 3, WINDRV_WRAP_STDCALL);
+ windrv_wrap((funcptr)ndis_txeof, &ndis_txeof_wrap,
+ 3, WINDRV_WRAP_STDCALL);
+ windrv_wrap((funcptr)ndis_linksts, &ndis_linksts_wrap,
+ 4, WINDRV_WRAP_STDCALL);
windrv_wrap((funcptr)ndis_linksts_done,
- &ndis_linksts_done_wrap);
+ &ndis_linksts_done_wrap, 1, WINDRV_WRAP_STDCALL);
break;
case MOD_UNLOAD:
ndisdrv_loaded--;
@@ -493,7 +494,15 @@ ndis_attach(dev)
*/
img = drv_data;
+
drv = windrv_lookup((vm_offset_t)img, NULL);
+
+ if (drv == NULL) {
+ device_printf(dev, "failed to find driver_object!\n");
+ error = ENXIO;
+ goto fail;
+ }
+
if (NdisAddDevice(drv, pdo) != STATUS_SUCCESS) {
device_printf(dev, "failed to create FDO!\n");
error = ENXIO;
@@ -950,7 +959,7 @@ ndis_resume(dev)
* copy the packet data into local storage and let the driver keep the
* packet.
*/
-__stdcall static void
+static void
ndis_rxeof(adapter, packets, pktcnt)
ndis_handle adapter;
ndis_packet **packets;
@@ -1030,7 +1039,7 @@ ndis_rxeof(adapter, packets, pktcnt)
* A frame was downloaded to the chip. It's safe for us to clean up
* the list buffers.
*/
-__stdcall static void
+static void
ndis_txeof(adapter, packet, status)
ndis_handle adapter;
ndis_packet *packet;
@@ -1072,7 +1081,7 @@ ndis_txeof(adapter, packet, status)
return;
}
-__stdcall static void
+static void
ndis_linksts(adapter, status, sbuf, slen)
ndis_handle adapter;
ndis_status status;
@@ -1090,7 +1099,7 @@ ndis_linksts(adapter, status, sbuf, slen)
return;
}
-__stdcall static void
+static void
ndis_linksts_done(adapter)
ndis_handle adapter;
{
@@ -1178,7 +1187,7 @@ ndis_ticktask(xsc)
void *xsc;
{
struct ndis_softc *sc;
- __stdcall ndis_checkforhang_handler hangfunc;
+ ndis_checkforhang_handler hangfunc;
uint8_t rval;
ndis_media_state linkstate;
int error, len;
diff --git a/sys/modules/ndis/Makefile b/sys/modules/ndis/Makefile
index f51ddc9..688cf97 100644
--- a/sys/modules/ndis/Makefile
+++ b/sys/modules/ndis/Makefile
@@ -11,4 +11,8 @@ SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h vnode_if.h
SRCS+= winx64_wrap.S
.endif
+.if ${MACHINE_ARCH} == "i386"
+SRCS+= winx32_wrap.S
+.endif
+
.include <bsd.kmod.mk>
OpenPOWER on IntegriCloud