diff options
author | wpaul <wpaul@FreeBSD.org> | 2003-12-13 09:07:35 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 2003-12-13 09:07:35 +0000 |
commit | 34759c3ef901d80fd05da9bece565040eb6437de (patch) | |
tree | fe35e6918639eaa040cfbefbd5fba79e6913aac3 | |
parent | 2dcb6042e5dca6b4da469eeede1fd8c6153adf22 (diff) | |
download | FreeBSD-src-34759c3ef901d80fd05da9bece565040eb6437de.zip FreeBSD-src-34759c3ef901d80fd05da9bece565040eb6437de.tar.gz |
Correct the implementation of NDIS_BUFFER_TO_SPAN_PAGES().
-rw-r--r-- | sys/compat/ndis/ntoskrnl_var.h | 6 | ||||
-rw-r--r-- | sys/compat/ndis/subr_ndis.c | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/sys/compat/ndis/ntoskrnl_var.h b/sys/compat/ndis/ntoskrnl_var.h index 68c79bd..9447d1b 100644 --- a/sys/compat/ndis/ntoskrnl_var.h +++ b/sys/compat/ndis/ntoskrnl_var.h @@ -35,6 +35,12 @@ #ifndef _NTOSKRNL_VAR_H_ #define _NTOSKRNL_VAR_H_ +/* Note: assumes x86 page size of 4K. */ +#define PAGE_SHIFT 12 +#define SPAN_PAGES(ptr, len) \ + ((uint32_t)((((uintptr_t)(ptr) & (PAGE_SIZE -1)) + \ + (len) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)) + typedef uint32_t kspin_lock; struct slist_entry { diff --git a/sys/compat/ndis/subr_ndis.c b/sys/compat/ndis/subr_ndis.c index c6e9a48..0c78da9 100644 --- a/sys/compat/ndis/subr_ndis.c +++ b/sys/compat/ndis/subr_ndis.c @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); #include <compat/ndis/pe_var.h> #include <compat/ndis/resource_var.h> +#include <compat/ndis/ntoskrnl_var.h> #include <compat/ndis/ndis_var.h> #include <compat/ndis/cfg_var.h> #include <dev/if_ndis/if_ndisvar.h> @@ -1684,7 +1685,9 @@ __stdcall static uint32_t ndis_numpages(buf) ndis_buffer *buf; { - return(howmany(buf->nb_bytecount, PAGE_SIZE)); + if (buf->nb_bytecount == 0) + return(1); + return(SPAN_PAGES(buf->nb_mappedsystemva, buf->nb_bytecount)); } __stdcall static void |