Re: 7.0 BETA1 and Thinkpad T61p : Wireless misadventure

[ Available lists | Index of freebsd-mobile | Month of Oct 2007 | Week of 31 Oct 2007 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Abdullah Ibn Hamad Al-Marri <wearabnet@yahoo.ca>
Date
31 Oct 2007 09:55:22
Subject
Re: 7.0 BETA1 and Thinkpad T61p : Wireless misadventure
Message-ID
322454.36756.qm@web33713.mail.mud.yahoo.com


[ Hide this part ]
 
----- Original Message ----

From: Scot Hetzel <swhetzel@gmail.com>

To: Mike Pumford <mpumford@mpc-data.co.uk>

Cc: freebsd-mobile@freebsd.org; freebsd-stable@freebsd.org; Abdullah Ibn Hamad Al-Marri <wearabnet@yahoo.ca>

Sent: Wednesday, October 31, 2007 6:56:58 AM

Subject: Re: 7.0 BETA1 and Thinkpad T61p : Wireless misadventure



On 10/30/07, Mike Pumford <mpumford@mpc-data.co.uk> wrote:

> Abdullah Ibn Hamad Al-Marri wrote:

>

> >

> > Previously I didn't mention that there are some functions missing from

> >

> > the FreeBSD's NDIS api. These are:

> >

> > With the help of NDIS reference and Linux ndiswrapper I have been able

> >

> > to implement all but KeBugCheckEx (they are all rather simple but I

> >

> Can help you with this one. This is the Windows equivalent of panic().

> So just call panic with an appropriate string. If the string includes

> the bugcheck code and parameters so much the better.

>

Thanks for your hint to use panic() in the KeBugCheckEx function.

I have KeBugCheckEx partially implemented. It currently prints the

bugcheck code

and the 4 paramators that are sent to KeBugCheckEx.



The KeBugCheckEx function still needs to be changed to display

the right information depending on the bugcheck code.







Abdullah, I made a minor change to your patch, strncat should be

prefixed with ntoskrnl_strncat.

changed IMPORT_CFUNC(strncat..) to IMPORT_CFUNC_MAP(ntoskrnl_strncat..).



Scot





-----Inline Attachment Follows-----



Index: ndis_var.h

===================================================================

RCS file: /home/ncvs/src/sys/compat/ndis/ndis_var.h,v

retrieving revision 1.47

diff -u -r1.47 ndis_var.h

--- ndis_var.h 6 Apr 2007 11:18:57 -0000 1.47

+++ ndis_var.h 31 Oct 2007 03:31:24 -0000

@@ -49,6 +49,10 @@

typedef register_t ndis_kspin_lock;

typedef uint8_t ndis_kirql;



+/* Version of NDIS supported by FreeBSD */

+#define NDIS_VERSION_51 0x00050001

+#define NDIS_VERSION NDIS_VERSION_51

+

/*

* NDIS status codes (there are lots of them). The ones that

* don't seem to fit the pattern are actually mapped to generic

Index: ntoskrnl_var.h

===================================================================

RCS file: /home/ncvs/src/sys/compat/ndis/ntoskrnl_var.h,v

retrieving revision 1.43

diff -u -r1.43 ntoskrnl_var.h

--- ntoskrnl_var.h 17 Aug 2006 22:50:32 -0000 1.43

+++ ntoskrnl_var.h 31 Oct 2007 03:31:24 -0000

@@ -1202,14 +1202,22 @@



/* Memory pool types, for ExAllocatePoolWithTag() */



-#define NonPagedPool 0x00000000

-#define PagedPool 0x00000001

-#define NonPagedPoolMustSucceed 0x00000002

-#define DontUseThisType 0x00000003

-#define NonPagedPoolCacheAligned 0x00000004

-#define PagedPoolCacheAligned 0x00000005

-#define NonPagedPoolCacheAlignedMustS 0x00000006

-#define MaxPoolType 0x00000007

+#define NonPagedPool 0x00000000

+#define PagedPool 0x00000001

+#define NonPagedPoolMustSucceed 0x00000002

+#define DontUseThisType 0x00000003

+#define NonPagedPoolCacheAligned 0x00000004

+#define PagedPoolCacheAligned 0x00000005

+#define NonPagedPoolCacheAlignedMustS 0x00000006

+#define MaxPoolType 0x00000007

+

+#define NonPagedPoolSession 0x00000020

+#define PagedPoolSession 0x00000021

+#define NonPagedPoolMustSucceedSession 0x00000022

+#define DontUseThisTypeSession 0x00000023

+#define NonPagedPoolCacheAlignedSession 0x00000024

+#define PagedPoolCacheAlignedSession 0x00000025

+#define NonPagedPoolCacheAlignedMustSSession 0x00000026



/*

* IO_WORKITEM is an opaque structures that must be allocated

@@ -1357,8 +1365,12 @@

extern uint8_t KeSynchronizeExecution(kinterrupt *, void *, void *);

extern uintptr_t InterlockedExchange(volatile uint32_t *,

uintptr_t);

+extern void *ExAllocatePool(uint32_t, size_t);

+extern void *ExAllocatePoolWithQuota(uint32_t, size_t);

+extern void *ExAllocatePoolWithQuotaTag(uint32_t, size_t, uint32_t);

extern void *ExAllocatePoolWithTag(uint32_t, size_t, uint32_t);

extern void ExFreePool(void *);

+extern void ExFreePoolWithTag(void *, uint32_t);

extern uint32_t IoConnectInterrupt(kinterrupt **, void *, void *,

kspin_lock *, uint32_t, uint8_t, uint8_t, uint8_t, uint8_t,

uint32_t, uint8_t);

Index: subr_ndis.c

===================================================================

RCS file: /home/ncvs/src/sys/compat/ndis/subr_ndis.c,v

retrieving revision 1.108

diff -u -r1.108 subr_ndis.c

--- subr_ndis.c 31 May 2007 11:51:49 -0000 1.108

+++ subr_ndis.c 31 Oct 2007 03:31:24 -0000

@@ -272,6 +272,7 @@

static void NdisUnmapFile(ndis_handle);

static void NdisCloseFile(ndis_handle);

static uint8_t NdisSystemProcessorCount(void);

+static void NdisGetCurrentProcessorCounts(uint32_t *, uint32_t *, uint32_t*);

static void NdisMIndicateStatusComplete(ndis_handle);

static void NdisMIndicateStatus(ndis_handle, ndis_status,

void *, uint32_t);

@@ -282,6 +283,7 @@

uint32_t, uint32_t, ndis_packet *, uint32_t, uint32_t *);

static void NdisCopyFromPacketToPacketSafe(ndis_packet *,

uint32_t, uint32_t, ndis_packet *, uint32_t, uint32_t *, uint32_t);

+static void NdisIMCopySendPerPacketInfo(ndis_packet *, ndis_packet *);

static ndis_status NdisMRegisterDevice(ndis_handle,

unicode_string *, unicode_string *, driver_dispatch **,

void **, ndis_handle *);

@@ -3115,6 +3117,20 @@

return(mp_ncpus);

}



+static void

+NdisGetCurrentProcessorCounts(idlecount, kerneluser, index)

+ uint32_t *idlecount;

+ uint32_t *kerneluser;

+ uint32_t *index;

+{

+ int cpu = 0; /* Current CPU */

+

+ *idlecount = cp_time[CP_IDLE];

+ *kerneluser = (cp_time[CP_USER] + cp_time[CP_NICE]) + \

+ (cp_time[CP_SYS] + cp_time[CP_INTR]);

+ *index = cpu;

+}

+

typedef void (*ndis_statusdone_handler)(ndis_handle);

typedef void (*ndis_status_handler)(ndis_handle, ndis_status,

void *, uint32_t);

@@ -3288,6 +3304,14 @@

return;

}



+static void

+NdisIMCopySendPerPacketInfo(dpkt, spkt)

+ ndis_packet *dpkt;

+ ndis_packet *spkt;

+{

+ memcpy(&dpkt->np_ext, &spkt->np_ext, sizeof(ndis_packet_extension));

+}

+

static ndis_status

NdisMRegisterDevice(handle, devname, symname, majorfuncs, devobj, devhandle)

ndis_handle handle;

@@ -3346,6 +3370,12 @@

return;

}



+static uint32_t

+NdisGetVersion()

+{

+ return(NDIS_VERSION);

+}

+

static void

dummy()

{

@@ -3365,10 +3395,12 @@

image_patch_table ndis_functbl[] = {

IMPORT_SFUNC(NdisCopyFromPacketToPacket, 6),

IMPORT_SFUNC(NdisCopyFromPacketToPacketSafe, 7),

+ IMPORT_SFUNC(NdisIMCopySendPerPacketInfo, 2),

IMPORT_SFUNC(NdisScheduleWorkItem, 1),

IMPORT_SFUNC(NdisMIndicateStatusComplete, 1),

IMPORT_SFUNC(NdisMIndicateStatus, 4),

IMPORT_SFUNC(NdisSystemProcessorCount, 0),

+ IMPORT_SFUNC(NdisGetCurrentProcessorCounts, 3),

IMPORT_SFUNC(NdisUnchainBufferAtBack, 2),

IMPORT_SFUNC(NdisGetFirstBufferFromPacket, 5),

IMPORT_SFUNC(NdisGetFirstBufferFromPacketSafe, 6),

@@ -3482,6 +3514,7 @@

IMPORT_SFUNC(NdisMDeregisterDevice, 1),

IMPORT_SFUNC(NdisMQueryAdapterInstanceName, 2),

IMPORT_SFUNC(NdisMRegisterUnloadHandler, 2),

+ IMPORT_SFUNC(NdisGetVersion, 0),

IMPORT_SFUNC(ndis_timercall, 4),

IMPORT_SFUNC(ndis_asyncmem_complete, 2),

IMPORT_SFUNC(ndis_intr, 2),

Index: subr_ntoskrnl.c

===================================================================

RCS file: /home/ncvs/src/sys/compat/ndis/subr_ntoskrnl.c,v

retrieving revision 1.91

diff -u -r1.91 subr_ntoskrnl.c

--- subr_ntoskrnl.c 20 Oct 2007 23:23:12 -0000 1.91

+++ subr_ntoskrnl.c 31 Oct 2007 03:31:24 -0000

@@ -219,6 +219,8 @@

static int rand(void);

static void srand(unsigned int);

static void ntoskrnl_time(uint64_t *);

+static void KeQuerySystemTime(uint64_t *);

+static uint32_t KeTickCount(void);

static uint8_t IoIsWdmVersionAvailable(uint8_t, uint8_t);

static void ntoskrnl_thrfunc(void *);

static ndis_status PsCreateSystemThread(ndis_handle *,

@@ -226,6 +228,8 @@

static ndis_status PsTerminateSystemThread(ndis_status);

static ndis_status IoGetDeviceProperty(device_object *, uint32_t,

uint32_t, void *, uint32_t *);

+static void KeBugCheckEx(uint32_t , uint32_t *, uint32_t *, uint32_t *,

+ uint32_t *);

static void KeInitializeMutex(kmutant *, uint32_t);

static uint32_t KeReleaseMutex(kmutant *, uint8_t);

static uint32_t KeReadStateMutex(kmutant *);

@@ -238,8 +242,10 @@

static uint32_t WmiTraceMessage(uint64_t, uint32_t, void *, uint16_t, ...);

static uint32_t IoWMIRegistrationControl(device_object *, uint32_t);

static void *ntoskrnl_memset(void *, int, size_t);

+static int ntoskrnl_memcmp(void *, void *, size_t);

static void *ntoskrnl_memmove(void *, void *, size_t);

static void *ntoskrnl_memchr(void *, unsigned char, size_t);

+static char *ntoskrnl_strncat(char *, char *, size_t);

static char *ntoskrnl_strstr(char *, char *);

static int ntoskrnl_toupper(int);

static int ntoskrnl_tolower(int);

@@ -429,6 +435,16 @@

return(memset(buf, ch, size));

}



+

+static int

+ntoskrnl_memcmp(buf1, buf2, size)

+ void *buf1;

+ void *buf2;

+ size_t size;

+{

+ return(memcmp(buf1, buf2, size));

+}

+

static void *

ntoskrnl_memmove(dst, src, size)

void *src;

@@ -456,6 +472,29 @@

return (NULL);

}



+/* Taken from libc */

+char *

+ntoskrnl_strncat(dst, src, n)

+ char *dst;

+ char *src;

+ size_t n;

+{

+ if (n != 0) {

+ char *d = dst;

+ const char *s = src;

+

+ while (*d != 0)

+ d++;

+ do {

+ if ((*d = *s++) == 0)

+ break;

+ d++;

+ } while (--n != 0);

+ *d = 0;

+ }

+ return (dst);

+}

+

static char *

ntoskrnl_strstr(s, find)

char *s, *find;

@@ -624,6 +663,31 @@

}



void *

+ExAllocatePool(pooltype, len)

+ uint32_t pooltype;

+ size_t len;

+{

+ return(ExAllocatePoolWithTag(pooltype, len, 0));

+}

+

+void *

+ExAllocatePoolWithQuota(pooltype, len)

+ uint32_t pooltype;

+ size_t len;

+{

+ return(ExAllocatePoolWithTag(pooltype, len, 0));

+}

+

+void *

+ExAllocatePoolWithQuotaTag(pooltype, len, tag)

+ uint32_t pooltype;

+ size_t len;

+ uint32_t tag;

+{

+ return(ExAllocatePoolWithTag(pooltype, len, tag));

+}

+

+void *

ExAllocatePoolWithTag(pooltype, len, tag)

uint32_t pooltype;

size_t len;

@@ -642,6 +706,14 @@

ExFreePool(buf)

void *buf;

{

+ ExFreePoolWithTag(buf, 0);

+}

+

+void

+ExFreePoolWithTag(buf, tag)

+ void *buf;

+ uint32_t tag;

+{

free(buf, M_DEVBUF);

return;

}

@@ -1587,6 +1659,21 @@

return;

}



+static void

+KeQuerySystemTime(current_time)

+ uint64_t *current_time;

+{

+ ntoskrnl_time(current_time);

+}

+

+static uint32_t

+KeTickCount(void)

+{

+ struct timeval tv;

+ getmicrouptime(&tv);

+ return tvtohz(&tv);

+}

+

/*

* KeWaitForSingleObject() is a tricky beast, because it can be used

* with several different object types: semaphores, timers, events,

@@ -2316,6 +2403,22 @@

}



void

+KeBugCheckEx(bugcheck, param1, param2, param3, param4)

+ uint32_t bugcheck;

+ uint32_t *param1;

+ uint32_t *param2;

+ uint32_t *param3;

+ uint32_t *param4;

+{

+ /* http://msdn2.microsoft.com/en-us/library/ms801645.aspx */

+

+ panic("KeBugCheckEx: STOP: %#08x, (%8p, %8p, %8p, %8p)",

+ bugcheck, param1, param2, param3, param4);

+

+ return;

+}

+

+void

KeInitializeSpinLock(lock)

kspin_lock *lock;

{

@@ -2814,7 +2917,7 @@

for (i = 0; i < WORKITEM_THREADS; i++) {

kq = wq_queues + i;

kq->kq_exit = 1;

- KeSetEvent(&kq->kq_proc, IO_NO_INCREMENT, FALSE);

+ KeSetEvent(&kq->kq_proc, IO_NO_INCREMENT, FALSE);

while (kq->kq_exit)

tsleep(kq->kq_td->td_proc, PWAIT, "waitiw", hz/10);

}

@@ -3182,7 +3285,10 @@

uint8_t major;

uint8_t minor;

{

- if (major == WDM_MAJOR && minor == WDM_MINOR_WINXP)

+ if (major == WDM_MAJOR &&

+ (minor == WDM_MINOR_WIN2003 || /* Windows 2003 */

+ minor == WDM_MINOR_WINXP || /* Windows XP */

+ minor == WDM_MINOR_WIN2000)) /* Windows 2000 */

return(TRUE);

return(FALSE);

}

@@ -4218,6 +4324,7 @@

IMPORT_CFUNC(strncmp, 0),

IMPORT_CFUNC(strcmp, 0),

IMPORT_CFUNC_MAP(stricmp, strcasecmp, 0),

+ IMPORT_CFUNC_MAP(strncat, ntoskrnl_strncat, 0),

IMPORT_CFUNC(strncpy, 0),

IMPORT_CFUNC(strcpy, 0),

IMPORT_CFUNC(strlen, 0),

@@ -4229,6 +4336,7 @@

IMPORT_CFUNC(memcpy, 0),

IMPORT_CFUNC_MAP(memmove, ntoskrnl_memmove, 0),

IMPORT_CFUNC_MAP(memset, ntoskrnl_memset, 0),

+ IMPORT_CFUNC_MAP(memcmp, ntoskrnl_memcmp, 0),

IMPORT_CFUNC_MAP(memchr, ntoskrnl_memchr, 0),

IMPORT_SFUNC(IoAllocateDriverObjectExtension, 4),

IMPORT_SFUNC(IoGetDriverObjectExtension, 2),

@@ -4290,8 +4398,12 @@

InterlockedPushEntrySList, 2),

IMPORT_FFUNC(ExInterlockedPopEntrySList, 2),

IMPORT_FFUNC(ExInterlockedPushEntrySList, 3),

+ IMPORT_SFUNC(ExAllocatePool, 2),

+ IMPORT_SFUNC(ExAllocatePoolWithQuota, 2),

+ IMPORT_SFUNC(ExAllocatePoolWithQuotaTag, 3),

IMPORT_SFUNC(ExAllocatePoolWithTag, 3),

IMPORT_SFUNC(ExFreePool, 1),

+ IMPORT_SFUNC(ExFreePoolWithTag, 2),

#ifdef __i386__

IMPORT_FFUNC(KefAcquireSpinLockAtDpcLevel, 1),

IMPORT_FFUNC(KefReleaseSpinLockFromDpcLevel,1),

@@ -4336,6 +4448,7 @@

IMPORT_SFUNC(IoQueueWorkItem, 4),

IMPORT_SFUNC(ExQueueWorkItem, 2),

IMPORT_SFUNC(ntoskrnl_workitem, 2),

+ IMPORT_SFUNC(KeBugCheckEx, 5),

IMPORT_SFUNC(KeInitializeMutex, 2),

IMPORT_SFUNC(KeReleaseMutex, 2),

IMPORT_SFUNC(KeReadStateMutex, 1),

@@ -4365,6 +4478,8 @@

IMPORT_SFUNC(IoWMIRegistrationControl, 2),

IMPORT_SFUNC(WmiQueryTraceInformation, 5),

IMPORT_CFUNC(WmiTraceMessage, 0),

+ IMPORT_SFUNC(KeQuerySystemTime, 1),

+ IMPORT_CFUNC(KeTickCount, 0),



/*

* This last entry is a catch-all for any function we haven't







-----Inline Attachment Follows-----



____________


Hello Marcin,

Could you please try this patch which modified by Mr. Scot Hetzel please?



--

Regards,

-Abdullah Ibn Hamad Al-Marri

Arab Portal

http://www.WeArab.Net/










__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


Elapsed time: 0.107 seconds