mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 02:10:07 +00:00
- Double fail: Fix a math bug, calculate the actual offset in the mapping and return it, and don't forget to return the total length read too.
svn path=/trunk/; revision=34661
This commit is contained in:
parent
04dfc992a1
commit
22a37283cc
|
@ -276,6 +276,7 @@ RamdiskMapPages(IN PRAMDISK_DRIVE_EXTENSION DeviceExtension,
|
|||
{
|
||||
PHYSICAL_ADDRESS PhysicalAddress;
|
||||
PVOID MappedBase;
|
||||
ULONG PageOffset;
|
||||
SIZE_T ActualLength;
|
||||
LARGE_INTEGER ActualOffset;
|
||||
LARGE_INTEGER ActualPages;
|
||||
|
@ -295,13 +296,13 @@ RamdiskMapPages(IN PRAMDISK_DRIVE_EXTENSION DeviceExtension,
|
|||
//
|
||||
// Convert to pages
|
||||
//
|
||||
ActualOffset.QuadPart = BYTES_TO_PAGES(ActualOffset.QuadPart);
|
||||
ActualPages.QuadPart = BYTES_TO_PAGES(ActualOffset.QuadPart);
|
||||
DPRINT1("Offset in pages is: %d\n", ActualOffset);
|
||||
|
||||
//
|
||||
// Now add the base page
|
||||
//
|
||||
ActualPages.QuadPart = DeviceExtension->BasePage + ActualOffset.QuadPart;
|
||||
ActualPages.QuadPart = DeviceExtension->BasePage + ActualPages.QuadPart;
|
||||
DPRINT1("Ramdisk mapped at page: %d, actual page is: %I64d\n",
|
||||
DeviceExtension->BasePage, ActualPages);
|
||||
|
||||
|
@ -323,10 +324,22 @@ RamdiskMapPages(IN PRAMDISK_DRIVE_EXTENSION DeviceExtension,
|
|||
ActualLength <<= PAGE_SHIFT;
|
||||
DPRINT1("Length in bytes: %d\n", ActualLength);
|
||||
|
||||
//
|
||||
// Get the offset within the page
|
||||
//
|
||||
PageOffset = BYTE_OFFSET(ActualOffset.QuadPart);
|
||||
DPRINT1("Page offset: %lx\n", PageOffset);
|
||||
|
||||
//
|
||||
// Map the I/O Space from the loader
|
||||
//
|
||||
MappedBase = MmMapIoSpace(PhysicalAddress, ActualLength, MmCached);
|
||||
|
||||
//
|
||||
// Return actual offset within the page as well as the length
|
||||
//
|
||||
if (MappedBase) MappedBase = (PVOID)((ULONG_PTR)MappedBase + PageOffset);
|
||||
*OutputLength = Length;
|
||||
DPRINT1("Mapped at: %p\n", MappedBase);
|
||||
return MappedBase;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue