mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
* Locking the address space before accessing it.
* Fixed some length calculations. svn path=/trunk/; revision=3699
This commit is contained in:
parent
4096437ab3
commit
a4b5d8a978
3 changed files with 18 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: cont.c,v 1.24 2002/10/01 19:27:22 chorns Exp $
|
||||
/* $Id: cont.c,v 1.25 2002/11/05 20:35:33 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -63,11 +63,13 @@ MmAllocateContiguousAlignedMemory(IN ULONG NumberOfBytes,
|
|||
Alignment);
|
||||
if (PBase.QuadPart == 0LL)
|
||||
{
|
||||
MmLockAddressSpace(MmGetKernelAddressSpace());
|
||||
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||
BaseAddress,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
||||
return(NULL);
|
||||
}
|
||||
for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / 4096); i++)
|
||||
|
@ -142,11 +144,13 @@ MmAllocateContiguousMemory (IN ULONG NumberOfBytes,
|
|||
VOID STDCALL
|
||||
MmFreeContiguousMemory(IN PVOID BaseAddress)
|
||||
{
|
||||
MmLockAddressSpace(MmGetKernelAddressSpace());
|
||||
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||
BaseAddress,
|
||||
0,
|
||||
MmFreeContinuousPage,
|
||||
NULL);
|
||||
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: iospace.c,v 1.16 2002/10/01 19:27:22 chorns Exp $
|
||||
/* $Id: iospace.c,v 1.17 2002/11/05 20:35:33 hbirr Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/iospace.c
|
||||
|
@ -96,7 +96,7 @@ MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
|
|||
{
|
||||
Attributes |= (PAGE_NOCACHE | PAGE_WRITETHROUGH);
|
||||
}
|
||||
for (i = 0; (i < ((NumberOfBytes + PAGE_SIZE - 1) / PAGE_SIZE)); i++)
|
||||
for (i = 0; (i < (PAGE_ROUND_UP(NumberOfBytes) / PAGE_SIZE)); i++)
|
||||
{
|
||||
Status =
|
||||
MmCreateVirtualMappingForKernel(Result + (i * PAGE_SIZE),
|
||||
|
@ -141,11 +141,13 @@ VOID STDCALL
|
|||
MmUnmapIoSpace (IN PVOID BaseAddress,
|
||||
IN ULONG NumberOfBytes)
|
||||
{
|
||||
(VOID)MmFreeMemoryArea(&PsGetCurrentProcess()->AddressSpace,
|
||||
(PVOID)(((ULONG)BaseAddress / PAGE_SIZE) * PAGE_SIZE),
|
||||
NumberOfBytes,
|
||||
NULL,
|
||||
NULL);
|
||||
MmLockAddressSpace(MmGetKernelAddressSpace());
|
||||
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||
(PVOID)(((ULONG)BaseAddress / PAGE_SIZE) * PAGE_SIZE),
|
||||
NumberOfBytes,
|
||||
NULL,
|
||||
NULL);
|
||||
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: ncache.c,v 1.22 2002/10/01 19:27:23 chorns Exp $
|
||||
/* $Id: ncache.c,v 1.23 2002/11/05 20:35:33 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -71,7 +71,7 @@ MmAllocateNonCachedMemory(IN ULONG NumberOfBytes)
|
|||
}
|
||||
Attributes = PAGE_READWRITE | PAGE_SYSTEM | PAGE_NOCACHE |
|
||||
PAGE_WRITETHROUGH;
|
||||
for (i = 0; i <= (NumberOfBytes / PAGE_SIZE); i++)
|
||||
for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / PAGE_SIZE); i++)
|
||||
{
|
||||
PHYSICAL_ADDRESS NPage;
|
||||
|
||||
|
@ -125,11 +125,13 @@ MmFreeNonCachedPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
|||
VOID STDCALL MmFreeNonCachedMemory (IN PVOID BaseAddress,
|
||||
IN ULONG NumberOfBytes)
|
||||
{
|
||||
MmLockAddressSpace(MmGetKernelAddressSpace());
|
||||
MmFreeMemoryArea (MmGetKernelAddressSpace(),
|
||||
BaseAddress,
|
||||
NumberOfBytes,
|
||||
MmFreeNonCachedPage,
|
||||
NULL);
|
||||
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue