https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f8bf0e9c3a82203625eadb...
commit f8bf0e9c3a82203625eadb0408cf1e35351913ce Author: Timo Kreuzer timo.kreuzer@reactos.org AuthorDate: Tue Feb 27 22:15:44 2018 +0100 Commit: Timo Kreuzer timo.kreuzer@reactos.org CommitDate: Sat Aug 4 19:19:34 2018 +0200
[UNIATA] Fix 64 bit issues --- drivers/storage/ide/uniata/bsmaster.h | 4 ++++ drivers/storage/ide/uniata/id_ata.cpp | 30 +++++++++++++++--------------- drivers/storage/ide/uniata/id_dma.cpp | 16 ++++++++++++++++ drivers/storage/ide/uniata/id_init.cpp | 11 +++++++++++ drivers/storage/ide/uniata/id_probe.cpp | 24 ++++++++++++++++++++++++ drivers/storage/ide/uniata/id_sata.cpp | 4 ++++ 6 files changed, 74 insertions(+), 15 deletions(-)
diff --git a/drivers/storage/ide/uniata/bsmaster.h b/drivers/storage/ide/uniata/bsmaster.h index 9ea8af390d..1e2332d75e 100644 --- a/drivers/storage/ide/uniata/bsmaster.h +++ b/drivers/storage/ide/uniata/bsmaster.h @@ -1588,7 +1588,11 @@ AtapiChipInit( IN ULONG c );
+#ifdef __REACTOS__ +extern ULONG_PTR +#else extern ULONG +#endif NTAPI AtapiGetIoRange( IN PVOID HwDeviceExtension, diff --git a/drivers/storage/ide/uniata/id_ata.cpp b/drivers/storage/ide/uniata/id_ata.cpp index 6f0f1da94a..e8e5d009f2 100644 --- a/drivers/storage/ide/uniata/id_ata.cpp +++ b/drivers/storage/ide/uniata/id_ata.cpp @@ -282,10 +282,10 @@ AtapiWritePort##sz( \ ASSERT(FALSE); /* We should never get here */ \ } \ if(!res->MemIo) { \ - ScsiPortWritePort##_Type((_type*)(res->Addr), data); \ + ScsiPortWritePort##_Type((_type*)(ULONG_PTR)(res->Addr), data); \ } else { \ /*KdPrint(("r_mem @ (%x) %x\n", _port, port));*/ \ - ScsiPortWriteRegister##_Type((_type*)(res->Addr), data); \ + ScsiPortWriteRegister##_Type((_type*)(ULONG_PTR)(res->Addr), data); \ } \ return; \ } @@ -319,10 +319,10 @@ AtapiWritePortEx##sz( \ ASSERT(FALSE); /* We should never get here */ \ } \ if(!res->MemIo) { \ - ScsiPortWritePort##_Type((_type*)(res->Addr+offs), data); \ + ScsiPortWritePort##_Type((_type*)(ULONG_PTR)(res->Addr+offs), data); \ } else { \ /*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; \ } @@ -355,10 +355,10 @@ AtapiReadPort##sz( \ } \ if(!res->MemIo) { \ /*KdPrint(("r_io @ (%x) %x\n", _port, res->Addr));*/ \ - return ScsiPortReadPort##_Type((_type*)(res->Addr)); \ + return ScsiPortReadPort##_Type((_type*)(ULONG_PTR)(res->Addr)); \ } else { \ /*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 */ \ } \ if(!res->MemIo) { \ - return ScsiPortReadPort##_Type((_type*)(res->Addr+offs)); \ + return ScsiPortReadPort##_Type((_type*)(ULONG_PTR)(res->Addr+offs)); \ } else { \ /*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) { \ /*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; \ } \ while(Count) { \ - (*((_type*)Buffer)) = ScsiPortReadRegister##_Type((_type*)(res->Addr)); \ + (*((_type*)Buffer)) = ScsiPortReadRegister##_Type((_type*)(ULONG_PTR)(res->Addr)); \ Count--; \ Buffer = ((_type*)Buffer)+1; \ } \ @@ -480,11 +480,11 @@ AtapiWriteBuffer##sz( \ } \ if(!res->MemIo) { \ /*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; \ } \ while(Count) { \ - ScsiPortWriteRegister##_Type((_type*)(res->Addr), *((_type*)Buffer)); \ + ScsiPortWriteRegister##_Type((_type*)(ULONG_PTR)(res->Addr), *((_type*)Buffer)); \ Count--; \ Buffer = ((_type*)Buffer)+1; \ } \ @@ -10850,7 +10850,7 @@ DriverEntry( newStatus = ScsiPortInitialize(DriverObject, Argument2, &hwInitializationData.comm, - (PVOID)(i | ((alt ^ pref_alt) ? 0x80000000 : 0))); + UlongToPtr(i | ((alt ^ pref_alt) ? 0x80000000 : 0))); KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus)); if (newStatus < statusToReturn) { statusToReturn = newStatus; @@ -10945,7 +10945,7 @@ DriverEntry( newStatus = ScsiPortInitialize(DriverObject, Argument2, &hwInitializationData.comm, - (PVOID)i); + UlongToPtr(i)); KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x\n", newStatus)); if(newStatus == (ULONG)STATUS_DEVICE_DOES_NOT_EXIST && BMList[i].NeedAltInit) { // Note: this is actually a BUG in scsiport.sys @@ -10958,7 +10958,7 @@ DriverEntry( newStatus = ScsiPortInitialize(DriverObject, Argument2, &hwInitializationData.comm, - (PVOID)(i | 0x80000000)); + UlongToPtr(i | 0x80000000)); KdPrint2((PRINT_PREFIX "ScsiPortInitialize Status %#x (2)\n", newStatus)); } if (newStatus < statusToReturn) diff --git a/drivers/storage/ide/uniata/id_dma.cpp b/drivers/storage/ide/uniata/id_dma.cpp index eef324aa7a..9ce765552b 100644 --- a/drivers/storage/ide/uniata/id_dma.cpp +++ b/drivers/storage/ide/uniata/id_dma.cpp @@ -293,7 +293,11 @@ AtapiDmaSetup( return FALSE; } //KdPrint2((PRINT_PREFIX " checkpoint 3\n" )); +#ifdef __REACTOS__ + if((ULONG_PTR)data & deviceExtension->AlignmentMask) { +#else if((ULONG)data & deviceExtension->AlignmentMask) { +#endif KdPrint2((PRINT_PREFIX "AtapiDmaSetup: unaligned data: %#x (%#x)\n", data, deviceExtension->AlignmentMask)); return FALSE; } @@ -341,7 +345,11 @@ retry_DB_IO: 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))); +#endif data += dma_count; count -= dma_count; i = 0; @@ -436,7 +444,11 @@ retry_DB_IO: *((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 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)) { +#endif 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->Flags |= REQ_FLAG_DMA_DBUF_PRD; @@ -444,7 +456,11 @@ retry_DB_IO: } else { AtaReq->dma_tab[i].base = dma_base; 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)) { +#endif KdPrint2((PRINT_PREFIX "DMA table crosses page boundary! %x vs %x\n", &AtaReq->dma_tab, &(AtaReq->dma_tab[i]) )); //AtaReq->Flags |= REQ_FLAG_DMA_DBUF_PRD; diff --git a/drivers/storage/ide/uniata/id_init.cpp b/drivers/storage/ide/uniata/id_init.cpp index 39e2b23848..f27ddc3a2a 100644 --- a/drivers/storage/ide/uniata/id_init.cpp +++ b/drivers/storage/ide/uniata/id_init.cpp @@ -350,10 +350,17 @@ UniataChipDetect( ULONG ChipFlags; ULONG tmp32; UCHAR tmp8; +#ifdef __REACTOS__ + ULONG_PTR BaseMemAddress; + ULONG_PTR BaseIoAddress1; + ULONG_PTR BaseIoAddress2; + ULONG_PTR BaseIoAddressBM; +#else ULONG BaseMemAddress; ULONG BaseIoAddress1; ULONG BaseIoAddress2; ULONG BaseIoAddressBM; +#endif BOOLEAN MemIo = FALSE; BOOLEAN IsPata = FALSE;
@@ -1203,7 +1210,11 @@ for_ugly_chips: tmp8 = AtapiReadPortEx1(NULL, (ULONGIO_PTR)(&deviceExtension->BaseIoAddressBM_0),IDX_BM_Status); KdPrint2((PRINT_PREFIX "BM status: %x\n", tmp8)); /* cleanup */ +#ifdef __REACTOS__ + ScsiPortFreeDeviceBase(HwDeviceExtension, (PCHAR)(ULONG_PTR)BaseIoAddressBM); +#else ScsiPortFreeDeviceBase(HwDeviceExtension, (PCHAR)BaseIoAddressBM); +#endif UniataInitIoResEx(&deviceExtension->BaseIoAddressBM_0, 0, 0, FALSE);
if(tmp8 == 0xff) { diff --git a/drivers/storage/ide/uniata/id_probe.cpp b/drivers/storage/ide/uniata/id_probe.cpp index bfbfd924d5..57c0aa2eb4 100644 --- a/drivers/storage/ide/uniata/id_probe.cpp +++ b/drivers/storage/ide/uniata/id_probe.cpp @@ -148,7 +148,11 @@ UniataEnableIoPCI( /* Get PCI address by ConfigInfo and RID */ +#ifdef __REACTOS__ +ULONG_PTR +#else ULONG +#endif NTAPI AtapiGetIoRange( IN PVOID HwDeviceExtension, @@ -953,7 +957,11 @@ UniataFindCompatBusMasterController2( { return UniataFindBusMasterController( HwDeviceExtension, +#ifdef __REACTOS__ + UlongToPtr(0x80000000), +#else (PVOID)0x80000000, +#endif BusInformation, ArgumentString, ConfigInfo, @@ -1071,7 +1079,11 @@ UniataFindBusMasterController( KdPrint2((PRINT_PREFIX "AdapterInterfaceType: Isa\n")); } if(InDriverEntry) { +#ifdef __REACTOS__ + i = PtrToUlong(Context); +#else i = (ULONG)Context; +#endif if(i & 0x80000000) { AltInit = TRUE; } @@ -1087,7 +1099,11 @@ UniataFindBusMasterController( } if(i >= BMListLen) { KdPrint2((PRINT_PREFIX "unexpected device arrival\n")); +#ifdef __REACTOS__ + i = PtrToUlong(Context); +#else i = (ULONG)Context; +#endif if(FirstMasterOk) { channel = 1; } @@ -2549,14 +2565,22 @@ retryIdentifier:
if(BaseIoAddress2) { if(hasPCI) { +#ifdef __REACTOS__ + (*ConfigInfo->AccessRanges)[1].RangeStart = ScsiPortConvertUlongToPhysicalAddress((ULONG_PTR)BaseIoAddress2); +#else (*ConfigInfo->AccessRanges)[1].RangeStart = ScsiPortConvertUlongToPhysicalAddress((ULONG)BaseIoAddress2); +#endif (*ConfigInfo->AccessRanges)[1].RangeLength = ATA_ALTIOSIZE; (*ConfigInfo->AccessRanges)[1].RangeInMemory = FALSE; } else { // NT4 and NT3.51 on ISA-only hardware definitly fail floppy.sys load // when this range is claimed by other driver. // 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) { +#endif KdPrint2((PRINT_PREFIX "!!! Possible AltStatus vs Floppy IO range interference !!!\n")); } KdPrint2((PRINT_PREFIX "Do not expose to OS on old ISA\n")); diff --git a/drivers/storage/ide/uniata/id_sata.cpp b/drivers/storage/ide/uniata/id_sata.cpp index 5306fbe92f..6a16c16f09 100644 --- a/drivers/storage/ide/uniata/id_sata.cpp +++ b/drivers/storage/ide/uniata/id_sata.cpp @@ -902,7 +902,11 @@ UniataAhciDetect( ULONG v_Mn, v_Mj; #endif //_DEBUG ULONG NumberChannels; +#ifdef __REACTOS__ + ULONG_PTR BaseMemAddress; +#else ULONG BaseMemAddress; +#endif BOOLEAN MemIo = FALSE; BOOLEAN found = FALSE;