Added posix library to make files
[pwlib.git] / tools / PacketVxD / lock.c
blobe39feed9f980716af8053500d2d0e981734527a7
1 /*
2 * lock.c
4 * Ethernet Packet Interface to NDIS drivers.
6 * Copyright 1998 Equivalence Pty. Ltd.
8 * Original code by William Ingle (address unknown)
10 * $Log$
11 * Revision 1.1 1998/09/28 08:08:38 robertj
12 * Initial revision
16 #define WANTVXDWRAPS
18 #include <basedef.h>
19 #include <vmm.h>
20 #include <vxdwraps.h> // must come last
22 #include "lock.h"
25 #pragma VxD_LOCKED_CODE_SEG
26 #pragma VxD_LOCKED_DATA_SEG
29 DWORD _stdcall PacketPageLock(DWORD lpMem, DWORD cbSize)
31 // lock a page
33 DWORD LinOffset = lpMem & 0xfff; // page offset of memory to map
34 DWORD LinPageNum = lpMem >> 12; // generate page number
35 DWORD nPages = ((lpMem + cbSize) >> 12) - LinPageNum + 1; // Calculate # of pages to map globally
37 // Return global mapping of passed in pointer, as this new pointer
38 // is how the memory must be accessed out of context.
39 return _LinPageLock(LinPageNum, nPages, PAGEMAPGLOBAL) + LinOffset;
43 void _stdcall PacketPageUnlock(void * lpMem, DWORD cbSize)
45 // unlock a page
47 DWORD LinPageNum = (DWORD)lpMem >> 12;
48 DWORD nPages = (((DWORD)lpMem + cbSize) >> 12) - LinPageNum + 1;
50 // Free globally mapped memory
51 _LinPageUnlock(LinPageNum, nPages, PAGEMAPGLOBAL);
55 // End of File ////////////////////////////////////////////////////////////////