Skip to content

Commit

Permalink
Fixed a bug in HalReadWritePCISpace
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo720 committed Apr 17, 2024
1 parent 2581cd8 commit e1ea51e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nboxkrnl/hal/hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ EXPORTNUM(46) VOID XBOXAPI HalReadWritePCISpace
PBYTE Buffer1 = (PBYTE)Buffer;
ULONG SizeLeft = Length;
ULONG CfgAddr = 0x80000000 | ((BusNumber & 0xFF) << 16) | ((SlotNumber & 0x1F) << 11) | ((SlotNumber & 0xE0) << 3) | (RegisterNumber & 0xFC);
ULONG RegisterOffset = RegisterNumber % 4;

while (SizeLeft > 0) {
ULONG BytesToAccess = (SizeLeft > 4) ? 4 : (SizeLeft == 3) ? 2 : SizeLeft;
ULONG RegisterOffset = RegisterNumber % 4;
outl(PCI_CONFIG_ADDRESS, CfgAddr);

switch (BytesToAccess)
Expand Down Expand Up @@ -90,8 +90,8 @@ EXPORTNUM(46) VOID XBOXAPI HalReadWritePCISpace
}
}

CfgAddr += 4;
RegisterOffset = 0;
RegisterNumber += BytesToAccess;
CfgAddr = (CfgAddr & ~0xFF) | (RegisterNumber >> 2);
BufferOffset += BytesToAccess;
SizeLeft -= BytesToAccess;
}
Expand Down

0 comments on commit e1ea51e

Please sign in to comment.