[UNIATA] Fix 64 bit issues

This commit is contained in:
Timo Kreuzer 2018-02-27 22:15:44 +01:00
parent c1944118ca
commit f8bf0e9c3a
6 changed files with 74 additions and 15 deletions

View file

@ -1588,7 +1588,11 @@ AtapiChipInit(
IN ULONG c IN ULONG c
); );
#ifdef __REACTOS__
extern ULONG_PTR
#else
extern ULONG extern ULONG
#endif
NTAPI NTAPI
AtapiGetIoRange( AtapiGetIoRange(
IN PVOID HwDeviceExtension, IN PVOID HwDeviceExtension,

View file

@ -282,10 +282,10 @@ AtapiWritePort##sz( \
ASSERT(FALSE); /* We should never get here */ \ ASSERT(FALSE); /* We should never get here */ \
} \ } \
if(!res->MemIo) { \ if(!res->MemIo) { \
ScsiPortWritePort##_Type((_type*)(res->Addr), data); \ ScsiPortWritePort##_Type((_type*)(ULONG_PTR)(res->Addr), data); \
} else { \ } else { \
/*KdPrint(("r_mem @ (%x) %x\n", _port, port));*/ \ /*KdPrint(("r_mem @ (%x) %x\n", _port, port));*/ \
ScsiPortWriteRegister##_Type((_type*)(res->Addr), data); \ ScsiPortWriteRegister##_Type((_type*)(ULONG_PTR)(res->Addr), data); \
} \ } \
return; \ return; \
} }
@ -319,10 +319,10 @@ AtapiWritePortEx##sz( \
ASSERT(FALSE); /* We should never get here */ \ ASSERT(FALSE); /* We should never get here */ \
} \ } \
if(!res->MemIo) { \ if(!res->MemIo) { \
ScsiPortWritePort##_Type((_type*)(res->Addr+offs), data); \ ScsiPortWritePort##_Type((_type*)(ULONG_PTR)(res->Addr+offs), data); \
} else { \ } else { \
/*KdPrint(("r_mem @ (%x) %x\n", _port, port));*/ \ /*KdPrint(("r_mem @ (%x) %x\n", _port, port));*/ \
ScsiPortWriteRegister##_Type((_type*)(res->Addr+offs), data); \ ScsiPortWriteRegister##_Type((_type*)(ULONG_PTR)(res->Addr+offs), data); \
} \ } \
return; \ return; \
} }
@ -355,10 +355,10 @@ AtapiReadPort##sz( \
} \ } \
if(!res->MemIo) { \ if(!res->MemIo) { \
/*KdPrint(("r_io @ (%x) %x\n", _port, res->Addr));*/ \ /*KdPrint(("r_io @ (%x) %x\n", _port, res->Addr));*/ \
return ScsiPortReadPort##_Type((_type*)(res->Addr)); \ return ScsiPortReadPort##_Type((_type*)(ULONG_PTR)(res->Addr)); \
} else { \ } else { \
/*KdPrint(("r_mem @ (%x) %x\n", _port, res->Addr));*/ \ /*KdPrint(("r_mem @ (%x) %x\n", _port, res->Addr));*/ \
return ScsiPortReadRegister##_Type((_type*)(res->Addr)); \ return ScsiPortReadRegister##_Type((_type*)(ULONG_PTR)(res->Addr)); \
} \ } \
} }
@ -390,10 +390,10 @@ AtapiReadPortEx##sz( \
ASSERT(FALSE); /* We should never get here */ \ ASSERT(FALSE); /* We should never get here */ \
} \ } \
if(!res->MemIo) { \ if(!res->MemIo) { \
return ScsiPortReadPort##_Type((_type*)(res->Addr+offs)); \ return ScsiPortReadPort##_Type((_type*)(ULONG_PTR)(res->Addr+offs)); \
} else { \ } else { \
/*KdPrint(("r_mem @ (%x) %x\n", _port, port));*/ \ /*KdPrint(("r_mem @ (%x) %x\n", _port, port));*/ \
return ScsiPortReadRegister##_Type((_type*)(res->Addr+offs)); \ return ScsiPortReadRegister##_Type((_type*)(ULONG_PTR)(res->Addr+offs)); \
} \ } \
} }
@ -435,11 +435,11 @@ AtapiReadBuffer##sz( \
} \ } \
if(!res->MemIo) { \ if(!res->MemIo) { \
/*KdPrint(("r_io @ (%x) %x\n", _port, res->Addr));*/ \ /*KdPrint(("r_io @ (%x) %x\n", _port, res->Addr));*/ \
ScsiPortReadPortBuffer##_Type((_type*)(res->Addr), (_type*)Buffer, Count); \ ScsiPortReadPortBuffer##_Type((_type*)(ULONG_PTR)(res->Addr), (_type*)Buffer, Count); \
return; \ return; \
} \ } \
while(Count) { \ while(Count) { \
(*((_type*)Buffer)) = ScsiPortReadRegister##_Type((_type*)(res->Addr)); \ (*((_type*)Buffer)) = ScsiPortReadRegister##_Type((_type*)(ULONG_PTR)(res->Addr)); \
Count--; \ Count--; \
Buffer = ((_type*)Buffer)+1; \ Buffer = ((_type*)Buffer)+1; \
} \ } \
@ -480,11 +480,11 @@ AtapiWriteBuffer##sz( \
} \ } \
if(!res->MemIo) { \ if(!res->MemIo) { \
/*KdPrint(("r_io @ (%x) %x\n", _port, res->Addr));*/ \ /*KdPrint(("r_io @ (%x) %x\n", _port, res->Addr));*/ \
ScsiPortWritePortBuffer##_Type((_type*)(res->Addr), (_type*)Buffer, Count); \ ScsiPortWritePortBuffer##_Type((_type*)(ULONG_PTR)(res->Addr), (_type*)Buffer, Count); \
return; \ return; \
} \ } \
while(Count) { \ while(Count) { \
ScsiPortWriteRegister##_Type((_type*)(res->Addr), *((_type*)Buffer)); \ ScsiPortWriteRegister##_Type((_type*)(ULONG_PTR)(res->Addr), *((_type*)Buffer)); \
Count--; \ Count--; \
Buffer = ((_type*)Buffer)+1; \ Buffer = ((_type*)Buffer)+1; \
} \ } \
@ -10850,7 +10850,7 @@ DriverEntry(
newStatus = ScsiPortInitialize(DriverObject, newStatus = ScsiPortInitialize(DriverObject,
Argument2, Argument2,
&hwInitializationData.comm, &hwInitializationData.comm,
(PVOID)(i | ((alt ^ pref_alt) ? 0x80000000 : 0))); UlongToPtr(i | ((alt ^ pref_alt) ? 0x80000000 : 0)));
KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus)); KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus));
if (newStatus < statusToReturn) { if (newStatus < statusToReturn) {
statusToReturn = newStatus; statusToReturn = newStatus;
@ -10945,7 +10945,7 @@ DriverEntry(
newStatus = ScsiPortInitialize(DriverObject, newStatus = ScsiPortInitialize(DriverObject,
Argument2, Argument2,
&hwInitializationData.comm, &hwInitializationData.comm,
(PVOID)i); UlongToPtr(i));
KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus)); KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus));
if(newStatus == (ULONG)STATUS_DEVICE_DOES_NOT_EXIST && BMList[i].NeedAltInit) { if(newStatus == (ULONG)STATUS_DEVICE_DOES_NOT_EXIST && BMList[i].NeedAltInit) {
// Note: this is actually a BUG in scsiport.sys // Note: this is actually a BUG in scsiport.sys
@ -10958,7 +10958,7 @@ DriverEntry(
newStatus = ScsiPortInitialize(DriverObject, newStatus = ScsiPortInitialize(DriverObject,
Argument2, Argument2,
&hwInitializationData.comm, &hwInitializationData.comm,
(PVOID)(i | 0x80000000)); UlongToPtr(i | 0x80000000));
KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x (2)\n", newStatus)); KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x (2)\n", newStatus));
} }
if (newStatus < statusToReturn) if (newStatus < statusToReturn)

View file

@ -293,7 +293,11 @@ AtapiDmaSetup(
return FALSE; return FALSE;
} }
//KdPrint2((PRINT_PREFIX " checkpoint 3\n" )); //KdPrint2((PRINT_PREFIX " checkpoint 3\n" ));
#ifdef __REACTOS__
if((ULONG_PTR)data & deviceExtension->AlignmentMask) {
#else
if((ULONG)data & deviceExtension->AlignmentMask) { if((ULONG)data & deviceExtension->AlignmentMask) {
#endif
KdPrint2((PRINT_PREFIX "AtapiDmaSetup: unaligned data: %#x (%#x)\n", data, deviceExtension->AlignmentMask)); KdPrint2((PRINT_PREFIX "AtapiDmaSetup: unaligned data: %#x (%#x)\n", data, deviceExtension->AlignmentMask));
return FALSE; return FALSE;
} }
@ -341,7 +345,11 @@ retry_DB_IO:
return FALSE; return FALSE;
} }
#ifdef __REACTOS__
dma_count = min(count, (PAGE_SIZE - ((ULONG_PTR)data & PAGE_MASK)));
#else
dma_count = min(count, (PAGE_SIZE - ((ULONG)data & PAGE_MASK))); dma_count = min(count, (PAGE_SIZE - ((ULONG)data & PAGE_MASK)));
#endif
data += dma_count; data += dma_count;
count -= dma_count; count -= dma_count;
i = 0; i = 0;
@ -436,7 +444,11 @@ retry_DB_IO:
*((PULONG)&(AtaReq->ahci.ahci_cmd_ptr->prd_tab[i].DBC_ULONG)) = ((dma_count-1) & 0x3fffff); *((PULONG)&(AtaReq->ahci.ahci_cmd_ptr->prd_tab[i].DBC_ULONG)) = ((dma_count-1) & 0x3fffff);
//AtaReq->ahci.ahci_cmd_ptr->prd_tab[i].I = 1; // interrupt when ready //AtaReq->ahci.ahci_cmd_ptr->prd_tab[i].I = 1; // interrupt when ready
KdPrint2((PRINT_PREFIX " ph data[%d]=%x:%x (%x)\n", i, dma_baseu, dma_base, AtaReq->ahci.ahci_cmd_ptr->prd_tab[i].DBC)); KdPrint2((PRINT_PREFIX " ph data[%d]=%x:%x (%x)\n", i, dma_baseu, dma_base, AtaReq->ahci.ahci_cmd_ptr->prd_tab[i].DBC));
#ifdef __REACTOS__
if(((ULONG_PTR)&(AtaReq->ahci.ahci_cmd_ptr->prd_tab) & ~PAGE_MASK) != ((ULONG_PTR)&(AtaReq->ahci.ahci_cmd_ptr->prd_tab[i]) & ~PAGE_MASK)) {
#else
if(((ULONG)&(AtaReq->ahci.ahci_cmd_ptr->prd_tab) & ~PAGE_MASK) != ((ULONG)&(AtaReq->ahci.ahci_cmd_ptr->prd_tab[i]) & ~PAGE_MASK)) { if(((ULONG)&(AtaReq->ahci.ahci_cmd_ptr->prd_tab) & ~PAGE_MASK) != ((ULONG)&(AtaReq->ahci.ahci_cmd_ptr->prd_tab[i]) & ~PAGE_MASK)) {
#endif
KdPrint2((PRINT_PREFIX "PRD table crosses page boundary! %x vs %x\n", KdPrint2((PRINT_PREFIX "PRD table crosses page boundary! %x vs %x\n",
&AtaReq->ahci.ahci_cmd_ptr->prd_tab, &(AtaReq->ahci.ahci_cmd_ptr->prd_tab[i]) )); &AtaReq->ahci.ahci_cmd_ptr->prd_tab, &(AtaReq->ahci.ahci_cmd_ptr->prd_tab[i]) ));
//AtaReq->Flags |= REQ_FLAG_DMA_DBUF_PRD; //AtaReq->Flags |= REQ_FLAG_DMA_DBUF_PRD;
@ -444,7 +456,11 @@ retry_DB_IO:
} else { } else {
AtaReq->dma_tab[i].base = dma_base; AtaReq->dma_tab[i].base = dma_base;
AtaReq->dma_tab[i].count = (dma_count & 0xffff) | ATA_DMA_EOT; AtaReq->dma_tab[i].count = (dma_count & 0xffff) | ATA_DMA_EOT;
#ifdef __REACTOS__
if(((ULONG_PTR)&(AtaReq->dma_tab) & ~PAGE_MASK) != ((ULONG_PTR)&(AtaReq->dma_tab[i]) & ~PAGE_MASK)) {
#else
if(((ULONG)&(AtaReq->dma_tab) & ~PAGE_MASK) != ((ULONG)&(AtaReq->dma_tab[i]) & ~PAGE_MASK)) { if(((ULONG)&(AtaReq->dma_tab) & ~PAGE_MASK) != ((ULONG)&(AtaReq->dma_tab[i]) & ~PAGE_MASK)) {
#endif
KdPrint2((PRINT_PREFIX "DMA table crosses page boundary! %x vs %x\n", KdPrint2((PRINT_PREFIX "DMA table crosses page boundary! %x vs %x\n",
&AtaReq->dma_tab, &(AtaReq->dma_tab[i]) )); &AtaReq->dma_tab, &(AtaReq->dma_tab[i]) ));
//AtaReq->Flags |= REQ_FLAG_DMA_DBUF_PRD; //AtaReq->Flags |= REQ_FLAG_DMA_DBUF_PRD;

View file

@ -350,10 +350,17 @@ UniataChipDetect(
ULONG ChipFlags; ULONG ChipFlags;
ULONG tmp32; ULONG tmp32;
UCHAR tmp8; UCHAR tmp8;
#ifdef __REACTOS__
ULONG_PTR BaseMemAddress;
ULONG_PTR BaseIoAddress1;
ULONG_PTR BaseIoAddress2;
ULONG_PTR BaseIoAddressBM;
#else
ULONG BaseMemAddress; ULONG BaseMemAddress;
ULONG BaseIoAddress1; ULONG BaseIoAddress1;
ULONG BaseIoAddress2; ULONG BaseIoAddress2;
ULONG BaseIoAddressBM; ULONG BaseIoAddressBM;
#endif
BOOLEAN MemIo = FALSE; BOOLEAN MemIo = FALSE;
BOOLEAN IsPata = FALSE; BOOLEAN IsPata = FALSE;
@ -1203,7 +1210,11 @@ for_ugly_chips:
tmp8 = AtapiReadPortEx1(NULL, (ULONGIO_PTR)(&deviceExtension->BaseIoAddressBM_0),IDX_BM_Status); tmp8 = AtapiReadPortEx1(NULL, (ULONGIO_PTR)(&deviceExtension->BaseIoAddressBM_0),IDX_BM_Status);
KdPrint2((PRINT_PREFIX "BM status: %x\n", tmp8)); KdPrint2((PRINT_PREFIX "BM status: %x\n", tmp8));
/* cleanup */ /* cleanup */
#ifdef __REACTOS__
ScsiPortFreeDeviceBase(HwDeviceExtension, (PCHAR)(ULONG_PTR)BaseIoAddressBM);
#else
ScsiPortFreeDeviceBase(HwDeviceExtension, (PCHAR)BaseIoAddressBM); ScsiPortFreeDeviceBase(HwDeviceExtension, (PCHAR)BaseIoAddressBM);
#endif
UniataInitIoResEx(&deviceExtension->BaseIoAddressBM_0, 0, 0, FALSE); UniataInitIoResEx(&deviceExtension->BaseIoAddressBM_0, 0, 0, FALSE);
if(tmp8 == 0xff) { if(tmp8 == 0xff) {

View file

@ -148,7 +148,11 @@ UniataEnableIoPCI(
/* /*
Get PCI address by ConfigInfo and RID Get PCI address by ConfigInfo and RID
*/ */
#ifdef __REACTOS__
ULONG_PTR
#else
ULONG ULONG
#endif
NTAPI NTAPI
AtapiGetIoRange( AtapiGetIoRange(
IN PVOID HwDeviceExtension, IN PVOID HwDeviceExtension,
@ -953,7 +957,11 @@ UniataFindCompatBusMasterController2(
{ {
return UniataFindBusMasterController( return UniataFindBusMasterController(
HwDeviceExtension, HwDeviceExtension,
#ifdef __REACTOS__
UlongToPtr(0x80000000),
#else
(PVOID)0x80000000, (PVOID)0x80000000,
#endif
BusInformation, BusInformation,
ArgumentString, ArgumentString,
ConfigInfo, ConfigInfo,
@ -1071,7 +1079,11 @@ UniataFindBusMasterController(
KdPrint2((PRINT_PREFIX "AdapterInterfaceType: Isa\n")); KdPrint2((PRINT_PREFIX "AdapterInterfaceType: Isa\n"));
} }
if(InDriverEntry) { if(InDriverEntry) {
#ifdef __REACTOS__
i = PtrToUlong(Context);
#else
i = (ULONG)Context; i = (ULONG)Context;
#endif
if(i & 0x80000000) { if(i & 0x80000000) {
AltInit = TRUE; AltInit = TRUE;
} }
@ -1087,7 +1099,11 @@ UniataFindBusMasterController(
} }
if(i >= BMListLen) { if(i >= BMListLen) {
KdPrint2((PRINT_PREFIX "unexpected device arrival\n")); KdPrint2((PRINT_PREFIX "unexpected device arrival\n"));
#ifdef __REACTOS__
i = PtrToUlong(Context);
#else
i = (ULONG)Context; i = (ULONG)Context;
#endif
if(FirstMasterOk) { if(FirstMasterOk) {
channel = 1; channel = 1;
} }
@ -2549,14 +2565,22 @@ retryIdentifier:
if(BaseIoAddress2) { if(BaseIoAddress2) {
if(hasPCI) { if(hasPCI) {
#ifdef __REACTOS__
(*ConfigInfo->AccessRanges)[1].RangeStart = ScsiPortConvertUlongToPhysicalAddress((ULONG_PTR)BaseIoAddress2);
#else
(*ConfigInfo->AccessRanges)[1].RangeStart = ScsiPortConvertUlongToPhysicalAddress((ULONG)BaseIoAddress2); (*ConfigInfo->AccessRanges)[1].RangeStart = ScsiPortConvertUlongToPhysicalAddress((ULONG)BaseIoAddress2);
#endif
(*ConfigInfo->AccessRanges)[1].RangeLength = ATA_ALTIOSIZE; (*ConfigInfo->AccessRanges)[1].RangeLength = ATA_ALTIOSIZE;
(*ConfigInfo->AccessRanges)[1].RangeInMemory = FALSE; (*ConfigInfo->AccessRanges)[1].RangeInMemory = FALSE;
} else { } else {
// NT4 and NT3.51 on ISA-only hardware definitly fail floppy.sys load // NT4 and NT3.51 on ISA-only hardware definitly fail floppy.sys load
// when this range is claimed by other driver. // when this range is claimed by other driver.
// However, floppy should use only 0x3f0-3f5,3f7 // However, floppy should use only 0x3f0-3f5,3f7
#ifdef __REACTOS__
if((ULONG_PTR)BaseIoAddress2 >= 0x3f0 && (ULONG_PTR)BaseIoAddress2 <= 0x3f7) {
#else
if((ULONG)BaseIoAddress2 >= 0x3f0 && (ULONG)BaseIoAddress2 <= 0x3f7) { if((ULONG)BaseIoAddress2 >= 0x3f0 && (ULONG)BaseIoAddress2 <= 0x3f7) {
#endif
KdPrint2((PRINT_PREFIX "!!! Possible AltStatus vs Floppy IO range interference !!!\n")); KdPrint2((PRINT_PREFIX "!!! Possible AltStatus vs Floppy IO range interference !!!\n"));
} }
KdPrint2((PRINT_PREFIX "Do not expose to OS on old ISA\n")); KdPrint2((PRINT_PREFIX "Do not expose to OS on old ISA\n"));

View file

@ -902,7 +902,11 @@ UniataAhciDetect(
ULONG v_Mn, v_Mj; ULONG v_Mn, v_Mj;
#endif //_DEBUG #endif //_DEBUG
ULONG NumberChannels; ULONG NumberChannels;
#ifdef __REACTOS__
ULONG_PTR BaseMemAddress;
#else
ULONG BaseMemAddress; ULONG BaseMemAddress;
#endif
BOOLEAN MemIo = FALSE; BOOLEAN MemIo = FALSE;
BOOLEAN found = FALSE; BOOLEAN found = FALSE;