diff --git a/lib/fast486/common.inl b/lib/fast486/common.inl index b9ef5872247..175fb018292 100644 --- a/lib/fast486/common.inl +++ b/lib/fast486/common.inl @@ -160,7 +160,7 @@ Fast486ReadLinearMemory(PFAST486_STATE State, if (Page == PAGE_ALIGN(LinearAddress + Size - 1)) { /* Read only a part of the page */ - PageLength = PAGE_OFFSET(LinearAddress) + Size - PageOffset; + PageLength = PAGE_OFFSET(LinearAddress + Size - 1) - PageOffset + 1; } /* Read the memory */ @@ -228,7 +228,7 @@ Fast486WriteLinearMemory(PFAST486_STATE State, if (Page == PAGE_ALIGN(LinearAddress + Size - 1)) { /* Write only a part of the page */ - PageLength = PAGE_OFFSET(LinearAddress) + Size - PageOffset; + PageLength = PAGE_OFFSET(LinearAddress + Size - 1) - PageOffset + 1; } /* Write the memory */