mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
- Fixed the implementation of MmMapIoSpace.
svn path=/trunk/; revision=9409
This commit is contained in:
parent
0dbe70cad7
commit
bdd1e9e8c6
11 changed files with 47 additions and 50 deletions
|
@ -441,7 +441,7 @@ BOOLEAN ConsoleInitHercules(void)
|
|||
|
||||
attr.u.Asuchar = 0x07;
|
||||
FrameBuffer.u.LowPart = 0xb0000;
|
||||
pScreenBufferHercules=MmMapIoSpace(FrameBuffer,FRAMEBUFFER_SIZE,FALSE);
|
||||
pScreenBufferHercules=MmMapIoSpace(FrameBuffer,FRAMEBUFFER_SIZE,MmNonCached);
|
||||
|
||||
DPRINT((0,"VGA memory phys. 0xb0000 mapped to virt. 0x%x\n",pScreenBufferHercules));
|
||||
|
||||
|
|
|
@ -516,11 +516,11 @@ BOOLEAN ConsoleInitVga(void)
|
|||
|
||||
// the real framebuffer
|
||||
FrameBuffer.u.LowPart = 0xB8000;
|
||||
pScreenBufferHardwareVga = MmMapIoSpace(FrameBuffer,SCREEN_BUFFER_SIZE,FALSE);
|
||||
pScreenBufferHardwareVga = MmMapIoSpace(FrameBuffer,SCREEN_BUFFER_SIZE,MmNonCached);
|
||||
|
||||
//The real font buffer
|
||||
FontBuffer.u.LowPart = 0xA0000;
|
||||
pFontBufferVga = MmMapIoSpace(FontBuffer,FONTBUFFERSIZE,FALSE);
|
||||
pFontBufferVga = MmMapIoSpace(FontBuffer,FONTBUFFERSIZE,MmNonCached);
|
||||
|
||||
// the console
|
||||
pScreenBufferVga = PICE_malloc(SCREEN_BUFFER_SIZE,NONPAGEDPOOL);
|
||||
|
|
|
@ -148,7 +148,7 @@ acpi_os_map_memory(ACPI_PHYSICAL_ADDRESS phys, u32 size, void **virt)
|
|||
}
|
||||
|
||||
Address.QuadPart = (ULONG)phys;
|
||||
*virt = MmMapIoSpace(Address, size, FALSE);
|
||||
*virt = MmMapIoSpace(Address, size, MmNonCached);
|
||||
if (!*virt)
|
||||
return AE_ERROR;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: blue.c,v 1.45 2004/05/10 18:02:19 gvg Exp $
|
||||
/* $Id: blue.c,v 1.46 2004/05/15 22:45:50 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -129,7 +129,7 @@ ScrCreate(PDEVICE_OBJECT DeviceObject,
|
|||
/* get pointer to video memory */
|
||||
BaseAddress.QuadPart = VIDMEM_BASE;
|
||||
DeviceExtension->VideoMemory =
|
||||
(PBYTE)MmMapIoSpace (BaseAddress, DeviceExtension->Rows * DeviceExtension->Columns * 2, FALSE);
|
||||
(PBYTE)MmMapIoSpace (BaseAddress, DeviceExtension->Rows * DeviceExtension->Columns * 2, MmNonCached);
|
||||
|
||||
DeviceExtension->CursorSize = 5; /* FIXME: value correct?? */
|
||||
DeviceExtension->CursorVisible = TRUE;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id: bootvid.c,v 1.7 2004/03/04 18:55:08 navaraf Exp $
|
||||
* $Id: bootvid.c,v 1.8 2004/05/15 22:45:50 hbirr Exp $
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
@ -123,7 +123,7 @@ InbvMapVideoMemory(VOID)
|
|||
PHYSICAL_ADDRESS PhysicalAddress;
|
||||
|
||||
PhysicalAddress.QuadPart = 0xA0000;
|
||||
VideoMemory = MmMapIoSpace(PhysicalAddress, 0x10000, FALSE);
|
||||
VideoMemory = MmMapIoSpace(PhysicalAddress, 0x10000, MmNonCached);
|
||||
|
||||
return VideoMemory != NULL;
|
||||
}
|
||||
|
|
|
@ -714,7 +714,7 @@ NdisMMapIoSpace(
|
|||
PAGED_CODE();
|
||||
ASSERT(VirtualAddress && MiniportAdapterHandle);
|
||||
|
||||
*VirtualAddress = MmMapIoSpace(PhysicalAddress, Length, FALSE);
|
||||
*VirtualAddress = MmMapIoSpace(PhysicalAddress, Length, MmNonCached);
|
||||
|
||||
if(!*VirtualAddress)
|
||||
return NDIS_STATUS_RESOURCES;
|
||||
|
@ -887,7 +887,7 @@ NdisMRegisterIoPortRange(
|
|||
NDIS_DbgPrint(MAX_TRACE, ("calling MmMapIoSpace\n"));
|
||||
|
||||
*PortOffset = 0;
|
||||
*PortOffset = MmMapIoSpace(TranslatedAddress, NumberOfPorts, 0);
|
||||
*PortOffset = MmMapIoSpace(TranslatedAddress, NumberOfPorts, MmNonCached);
|
||||
NDIS_DbgPrint(MAX_TRACE, ("Returning 0x%x for port range\n", *PortOffset));
|
||||
|
||||
if(!*PortOffset)
|
||||
|
|
|
@ -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: scsiport.c,v 1.55 2004/04/23 14:29:07 hbirr Exp $
|
||||
/* $Id: scsiport.c,v 1.56 2004/05/15 22:45:50 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -346,7 +346,7 @@ ScsiPortGetDeviceBase(IN PVOID HwDeviceExtension,
|
|||
|
||||
MappedAddress = MmMapIoSpace(TranslatedAddress,
|
||||
NumberOfBytes,
|
||||
FALSE);
|
||||
MmNonCached);
|
||||
|
||||
DeviceBase = ExAllocatePool(NonPagedPool,
|
||||
sizeof(SCSI_PORT_DEVICE_BASE));
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* If not, write to the Free Software Foundation,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id: resource.c,v 1.2 2004/03/19 20:58:32 navaraf Exp $
|
||||
* $Id: resource.c,v 1.3 2004/05/15 22:45:51 hbirr Exp $
|
||||
*/
|
||||
|
||||
#include "videoprt.h"
|
||||
|
@ -99,7 +99,7 @@ IntVideoPortMapMemory(
|
|||
MappedAddress = MmMapIoSpace(
|
||||
TranslatedAddress,
|
||||
NumberOfUchars,
|
||||
FALSE);
|
||||
MmNonCached);
|
||||
|
||||
if (MappedAddress)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: halinit.c,v 1.7 2004/03/18 19:58:35 dwelch Exp $
|
||||
/* $Id: halinit.c,v 1.8 2004/05/15 22:45:51 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -73,7 +73,7 @@ HalInitSystem (ULONG BootPhase,
|
|||
/* Go to blue screen */
|
||||
HalClearDisplay (0x17); /* grey on blue */
|
||||
|
||||
HalpZeroPageMapping = MmMapIoSpace((LARGE_INTEGER)0LL, PAGE_SIZE, FALSE);
|
||||
HalpZeroPageMapping = MmMapIoSpace((LARGE_INTEGER)0LL, PAGE_SIZE, MmNonCached);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef _INCLUDE_DDK_MMFUNCS_H
|
||||
#define _INCLUDE_DDK_MMFUNCS_H
|
||||
/* $Id: mmfuncs.h,v 1.21 2004/04/20 19:04:11 gdalsnes Exp $ */
|
||||
/* $Id: mmfuncs.h,v 1.22 2004/05/15 22:45:51 hbirr Exp $ */
|
||||
/* MEMORY MANAGMENT ******************************************************/
|
||||
|
||||
|
||||
|
@ -356,7 +356,7 @@ STDCALL
|
|||
MmMapIoSpace (
|
||||
PHYSICAL_ADDRESS PhysicalAddress,
|
||||
ULONG NumberOfBytes,
|
||||
BOOLEAN CacheEnable
|
||||
MEMORY_CACHING_TYPE CacheEnable
|
||||
);
|
||||
/*
|
||||
* FUNCTION: Maps the pages described by a given MDL
|
||||
|
|
|
@ -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.26 2004/04/10 22:35:25 gdalsnes Exp $
|
||||
/* $Id: iospace.c,v 1.27 2004/05/15 22:45:49 hbirr Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/iospace.c
|
||||
|
@ -52,7 +52,7 @@
|
|||
* Number of bytes to map;
|
||||
*
|
||||
* CacheEnable
|
||||
* TRUE if the range can be cached.
|
||||
* Type of memory caching.
|
||||
*
|
||||
* RETURN VALUE
|
||||
* The base virtual address which maps the region.
|
||||
|
@ -68,9 +68,10 @@
|
|||
PVOID STDCALL
|
||||
MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
|
||||
IN ULONG NumberOfBytes,
|
||||
IN BOOLEAN CacheEnable)
|
||||
IN MEMORY_CACHING_TYPE CacheEnable)
|
||||
{
|
||||
PVOID Result;
|
||||
ULONG Offset;
|
||||
MEMORY_AREA* marea;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
|
@ -79,9 +80,20 @@ MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
|
|||
|
||||
DPRINT("MmMapIoSpace(%lx, %d, %d)\n", PhysicalAddress, NumberOfBytes, CacheEnable);
|
||||
|
||||
if (CacheEnable != MmNonCached &&
|
||||
CacheEnable != MmCached &&
|
||||
CacheEnable != MmWriteCombined)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BoundaryAddressMultiple.QuadPart = 0;
|
||||
MmLockAddressSpace(MmGetKernelAddressSpace());
|
||||
Result = NULL;
|
||||
Offset = PhysicalAddress.u.LowPart % PAGE_SIZE;
|
||||
NumberOfBytes += Offset;
|
||||
PhysicalAddress.QuadPart -= Offset;
|
||||
|
||||
MmLockAddressSpace(MmGetKernelAddressSpace());
|
||||
Status = MmCreateMemoryArea (NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_IO_MAPPING,
|
||||
|
@ -100,43 +112,23 @@ MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
|
|||
return (NULL);
|
||||
}
|
||||
Attributes = PAGE_EXECUTE_READWRITE | PAGE_SYSTEM;
|
||||
if (!CacheEnable)
|
||||
if (CacheEnable != MmCached)
|
||||
{
|
||||
Attributes |= (PAGE_NOCACHE | PAGE_WRITETHROUGH);
|
||||
}
|
||||
for (i = 0; (i < (PAGE_ROUND_UP(NumberOfBytes) / PAGE_SIZE)); i++)
|
||||
for (i = 0; i < PAGE_ROUND_UP(NumberOfBytes); i += PAGE_SIZE, PhysicalAddress.QuadPart += PAGE_SIZE)
|
||||
{
|
||||
#if !defined(__GNUC__)
|
||||
PHYSICAL_ADDRESS dummyJunkNeeded;
|
||||
dummyJunkNeeded.QuadPart = PhysicalAddress.QuadPart + (i * PAGE_SIZE);
|
||||
#endif
|
||||
|
||||
Status =
|
||||
MmCreateVirtualMappingForKernel((char*)Result + (i * PAGE_SIZE),
|
||||
Attributes,
|
||||
#if defined(__GNUC__)
|
||||
(PHYSICAL_ADDRESS)
|
||||
(PhysicalAddress.QuadPart +
|
||||
(i * PAGE_SIZE))
|
||||
#else
|
||||
dummyJunkNeeded
|
||||
#endif
|
||||
);
|
||||
Status = MmCreateVirtualMappingForKernel((char*)Result + i,
|
||||
Attributes,
|
||||
PhysicalAddress);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("Unable to create virtual mapping\n");
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
#if defined(__GNUC__)
|
||||
MmMarkPageMapped((PHYSICAL_ADDRESS) (PhysicalAddress.QuadPart +
|
||||
(i * PAGE_SIZE)));
|
||||
#else
|
||||
|
||||
MmMarkPageMapped(dummyJunkNeeded);
|
||||
#endif
|
||||
|
||||
MmMarkPageMapped(PhysicalAddress);
|
||||
}
|
||||
return ((PVOID)((char*)Result + PhysicalAddress.QuadPart % PAGE_SIZE));
|
||||
return ((PVOID)((char*)Result + Offset));
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,9 +160,14 @@ VOID STDCALL
|
|||
MmUnmapIoSpace (IN PVOID BaseAddress,
|
||||
IN ULONG NumberOfBytes)
|
||||
{
|
||||
ULONG Offset;
|
||||
Offset = (ULONG_PTR)BaseAddress % PAGE_SIZE;
|
||||
BaseAddress = (PVOID)((PUCHAR)BaseAddress - Offset);
|
||||
NumberOfBytes += Offset;
|
||||
|
||||
MmLockAddressSpace(MmGetKernelAddressSpace());
|
||||
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||
(PVOID)(((ULONG)BaseAddress / PAGE_SIZE) * PAGE_SIZE),
|
||||
BaseAddress,
|
||||
NumberOfBytes,
|
||||
NULL,
|
||||
NULL);
|
||||
|
|
Loading…
Reference in a new issue