summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2004-01-03 02:25:21 +0000
committerwpaul <wpaul@FreeBSD.org>2004-01-03 02:25:21 +0000
commita43e13682e205a5b9215890c7fd108fc0233c385 (patch)
tree9995657be93524c047e67520a27eb69f59507ffe /sys
parent03e299bc7355b8ba7ab265e4ee76a6453bf66647 (diff)
downloadFreeBSD-src-a43e13682e205a5b9215890c7fd108fc0233c385.zip
FreeBSD-src-a43e13682e205a5b9215890c7fd108fc0233c385.tar.gz
Tweak ndiscvt to support yet another flavor of .INF files (look for
the NTx86 section decoration). subr_ndis.c: correct the behavior of ndis_query_resources(): if the caller doesn't provide enough space to return the resources, tell it how much it needs to provide and return an error. subr_hal.c & subr_ntoskrnl.c: implement/stub a bunch of new routines; ntoskrnl: KefAcquireSpinLockAtDpcLevel KefReleaseSpinLockFromDpcLevel MmMapLockedPages InterlockedDecrement InterlockedIncrement IoFreeMdl KeInitializeSpinLock HAL: KfReleaseSpinLock KeGetCurrentIrql KfAcquireSpinLock Lastly, correct spelling of "_aullshr" in the ntoskrnl functable.
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/ndis/subr_hal.c39
-rw-r--r--sys/compat/ndis/subr_ndis.c11
-rw-r--r--sys/compat/ndis/subr_ntoskrnl.c111
3 files changed, 156 insertions, 5 deletions
diff --git a/sys/compat/ndis/subr_hal.c b/sys/compat/ndis/subr_hal.c
index 442b7ef..4c5313a 100644
--- a/sys/compat/ndis/subr_hal.c
+++ b/sys/compat/ndis/subr_hal.c
@@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$");
#include <sys/callout.h>
#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/systm.h>
#include <machine/clock.h>
@@ -51,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <compat/ndis/pe_var.h>
#include <compat/ndis/hal_var.h>
+#include <compat/ndis/ntoskrnl_var.h>
#define __stdcall __attribute__((__stdcall__))
#define FUNC void(*)(void)
@@ -62,6 +65,9 @@ __stdcall static void hal_writeport_uchar(uint8_t *, uint8_t);
__stdcall static uint32_t hal_readport_ulong(uint32_t *);
__stdcall static uint16_t hal_readport_ushort(uint16_t *);
__stdcall static uint8_t hal_readport_uchar(uint8_t *);
+__stdcall static uint8_t hal_lock(/*kspin_lock * */void);
+__stdcall static void hal_unlock(/*kspin_lock *, uint8_t*/void);
+__stdcall static uint8_t hal_irql(void);
__stdcall static void dummy (void);
__stdcall static void
@@ -120,6 +126,35 @@ hal_readport_uchar(port)
return(bus_space_read_1(I386_BUS_SPACE_IO, 0x0, (uint32_t)port));
}
+__stdcall static uint8_t
+hal_lock(/*lock*/void)
+{
+ kspin_lock *lock;
+
+ __asm__ __volatile__ ("" : "=c" (lock));
+
+ mtx_lock((struct mtx *)*lock);
+ return(0);
+}
+
+__stdcall static void
+hal_unlock(/*lock, newirql*/void)
+{
+ kspin_lock *lock;
+ uint8_t newiqrl;
+
+ __asm__ __volatile__ ("" : "=c" (lock), "=d" (newiqrl));
+
+ mtx_unlock((struct mtx *)*lock);
+ return;
+}
+
+__stdcall static uint8_t
+hal_irql(void)
+{
+ return(0);
+}
+
__stdcall
static void dummy()
{
@@ -127,7 +162,6 @@ static void dummy()
return;
}
-
image_patch_table hal_functbl[] = {
{ "KeStallExecutionProcessor", (FUNC)hal_stall_exec_cpu },
{ "WRITE_PORT_ULONG", (FUNC)hal_writeport_ulong },
@@ -136,6 +170,9 @@ image_patch_table hal_functbl[] = {
{ "READ_PORT_ULONG", (FUNC)hal_readport_ulong },
{ "READ_PORT_USHORT", (FUNC)hal_readport_ushort },
{ "READ_PORT_UCHAR", (FUNC)hal_readport_uchar },
+ { "KfAcquireSpinLock", (FUNC)hal_lock },
+ { "KfReleaseSpinLock", (FUNC)hal_unlock },
+ { "KeGetCurrentIrql", (FUNC)hal_irql },
/*
* This last entry is a catch-all for any function we haven't
diff --git a/sys/compat/ndis/subr_ndis.c b/sys/compat/ndis/subr_ndis.c
index 975e6ee..a396a7e 100644
--- a/sys/compat/ndis/subr_ndis.c
+++ b/sys/compat/ndis/subr_ndis.c
@@ -1017,12 +1017,18 @@ ndis_query_resources(status, adapter, list, buflen)
{
ndis_miniport_block *block;
struct ndis_softc *sc;
+ int rsclen;
block = (ndis_miniport_block *)adapter;
sc = (struct ndis_softc *)block->nmb_ifp;
-
- *buflen = sizeof(ndis_resource_list) +
+
+ rsclen = sizeof(ndis_resource_list) +
(sizeof(cm_partial_resource_desc) * (sc->ndis_rescnt - 1));
+ if (*buflen < rsclen) {
+ *buflen = rsclen;
+ *status = NDIS_STATUS_INVALID_LENGTH;
+ return;
+ }
bcopy((char *)block->nmb_rlist, (char *)list, *buflen);
*status = NDIS_STATUS_SUCCESS;
@@ -2415,4 +2421,3 @@ image_patch_table ndis_functbl[] = {
{ NULL, NULL },
};
-
diff --git a/sys/compat/ndis/subr_ntoskrnl.c b/sys/compat/ndis/subr_ntoskrnl.c
index 8e19e02..55b1f1b 100644
--- a/sys/compat/ndis/subr_ntoskrnl.c
+++ b/sys/compat/ndis/subr_ntoskrnl.c
@@ -106,6 +106,13 @@ __stdcall static slist_entry *ntoskrnl_push_slist_ex(/*slist_entry *,
slist_entry *,*/ kspin_lock *);
__stdcall static slist_entry *ntoskrnl_pop_slist_ex(/*slist_entry *,
kspin_lock * */void);
+__stdcall static void ntoskrnl_lock_dpc(/*kspin_lock * */ void);
+__stdcall static void ntoskrnl_unlock_dpc(/*kspin_lock * */ void);
+__stdcall static void ntoskrnl_interlock_inc(/*volatile uint32_t * */ void);
+__stdcall static void ntoskrnl_interlock_dec(/*volatile uint32_t * */ void);
+__stdcall static void ntoskrnl_freemdl(ndis_buffer *);
+__stdcall static void *ntoskrnl_mmaplockedpages(ndis_buffer *, uint8_t);
+__stdcall static void ntoskrnl_create_lock(kspin_lock *);
__stdcall static void dummy(void);
static struct mtx ntoskrnl_interlock;
@@ -551,6 +558,101 @@ ntoskrnl_pop_slist_ex(/*head, lock*/ void)
}
__stdcall static void
+ntoskrnl_lock_dpc(/*lock*/ void)
+{
+ kspin_lock *lock;
+
+ __asm__ __volatile__ ("" : "=c" (lock));
+
+ mtx_lock((struct mtx *)*lock);
+ return;
+}
+
+__stdcall static void
+ntoskrnl_unlock_dpc(/*lock*/ void)
+{
+ kspin_lock *lock;
+
+ __asm__ __volatile__ ("" : "=c" (lock));
+
+ mtx_unlock((struct mtx *)*lock);
+ return;
+}
+
+__stdcall static void
+ntoskrnl_interlock_inc(/*addend*/ void)
+{
+ volatile uint32_t *addend;
+
+ __asm__ __volatile__ ("" : "=c" (addend));
+
+ mtx_lock(&ntoskrnl_interlock);
+ (*addend)++;
+ mtx_unlock(&ntoskrnl_interlock);
+
+ return;
+}
+
+__stdcall static void
+ntoskrnl_interlock_dec(/*addend*/ void)
+{
+ volatile uint32_t *addend;
+
+ __asm__ __volatile__ ("" : "=c" (addend));
+
+ mtx_lock(&ntoskrnl_interlock);
+ (*addend)--;
+ mtx_unlock(&ntoskrnl_interlock);
+
+ return;
+}
+
+__stdcall static void
+ntoskrnl_freemdl(mdl)
+ ndis_buffer *mdl;
+{
+ ndis_buffer *head;
+
+ if (mdl == NULL || mdl->nb_process == NULL)
+ return;
+
+ head = mdl->nb_process;
+
+ if (head->nb_flags != 0x1)
+ return;
+
+ mdl->nb_next = head->nb_next;
+ head->nb_next = mdl;
+
+ return;
+}
+
+__stdcall static void *
+ntoskrnl_mmaplockedpages(buf, accessmode)
+ ndis_buffer *buf;
+ uint8_t accessmode;
+{
+ return(MDL_VA(buf));
+}
+
+__stdcall static void
+ntoskrnl_create_lock(lock)
+ kspin_lock *lock;
+{
+ struct mtx *mtx;
+
+ mtx = malloc(sizeof(struct mtx), M_DEVBUF, M_NOWAIT|M_ZERO);
+ if (mtx == NULL)
+ return;
+ mtx_init(mtx, "ntoslock", "ntoskrnl spinlock",
+ MTX_DEF | MTX_RECURSE | MTX_DUPOK);
+
+ *lock = (kspin_lock)mtx;
+
+ return;
+}
+
+__stdcall static void
dummy()
{
printf ("ntoskrnl dummy called...\n");
@@ -583,7 +685,7 @@ image_patch_table ntoskrnl_functbl[] = {
{ "_aullmul", (FUNC)_aullmul },
{ "_aulldiv", (FUNC)_aulldiv },
{ "_aullrem", (FUNC)_aullrem },
- { "_aullushr", (FUNC)_aullshr },
+ { "_aullshr", (FUNC)_aullshr },
{ "_aullshl", (FUNC)_aullshl },
{ "WRITE_REGISTER_USHORT", (FUNC)ntoskrnl_writereg_ushort },
{ "READ_REGISTER_USHORT", (FUNC)ntoskrnl_readreg_ushort },
@@ -599,6 +701,13 @@ image_patch_table ntoskrnl_functbl[] = {
{ "InterlockedPushEntrySList", (FUNC)ntoskrnl_push_slist },
{ "ExInterlockedPopEntrySList", (FUNC)ntoskrnl_pop_slist_ex },
{ "ExInterlockedPushEntrySList",(FUNC)ntoskrnl_push_slist_ex },
+ { "KefAcquireSpinLockAtDpcLevel", (FUNC)ntoskrnl_lock_dpc },
+ { "KefReleaseSpinLockFromDpcLevel", (FUNC)ntoskrnl_unlock_dpc },
+ { "InterlockedIncrement", (FUNC)ntoskrnl_interlock_inc },
+ { "InterlockedDecrement", (FUNC)ntoskrnl_interlock_dec },
+ { "IoFreeMdl", (FUNC)ntoskrnl_freemdl },
+ { "MmMapLockedPages", (FUNC)ntoskrnl_mmaplockedpages },
+ { "KeInitializeSpinLock", (FUNC)ntoskrnl_create_lock },
/*
* This last entry is a catch-all for any function we haven't
OpenPOWER on IntegriCloud