ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
July 2016
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
18 participants
358 discussions
Start a n
N
ew thread
[apriyadarshi] 71996: Handled SCSIOP_TEST_UNIT_READY Changed Default status to SRB_STATUS_INVALID_REQUEST Added support for 48bits in GetLba function
by apriyadarshi@svn.reactos.org
Author: apriyadarshi Date: Mon Jul 25 11:09:25 2016 New Revision: 71996 URL:
http://svn.reactos.org/svn/reactos?rev=71996&view=rev
Log: Handled SCSIOP_TEST_UNIT_READY Changed Default status to SRB_STATUS_INVALID_REQUEST Added support for 48bits in GetLba function Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
============================================================================== --- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] (original) +++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] Mon Jul 25 11:09:25 2016 @@ -570,6 +570,7 @@ } else { + NT_ASSERT(Srb->SrbStatus == SRB_STATUS_PENDING); Srb->SrbStatus = SRB_STATUS_SUCCESS; StorPortNotification(RequestComplete, AdapterExtension, Srb); } @@ -839,8 +840,10 @@ Srb->SrbStatus = DeviceReportLuns(AdapterExtension, Srb, cdb); break; case SCSIOP_READ_CAPACITY: - case SCSIOP_READ_CAPACITY16: Srb->SrbStatus = DeviceRequestCapacity(AdapterExtension, Srb, cdb); + break; + case SCSIOP_TEST_UNIT_READY: + Srb->SrbStatus = DeviceRequestComplete(AdapterExtension, Srb, cdb); break; case SCSIOP_READ: //case SCSIOP_WRITE: @@ -848,7 +851,7 @@ break; default: AhciDebugPrint("\tOperationCode: %d\n", cdb->CDB10.OperationCode); - Srb->SrbStatus = SRB_STATUS_BAD_FUNCTION; + Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST; break; } } @@ -862,6 +865,10 @@ if (Srb->SrbStatus != SRB_STATUS_PENDING) { StorPortNotification(RequestComplete, AdapterExtension, Srb); + } + else + { + AhciProcessIO(AdapterExtension, Srb->PathId, Srb); } return TRUE; }// -- AhciHwStartIo(); @@ -1598,7 +1605,7 @@ PortExtension->DeviceParams.RemovableDevice = 1; } - if (IdentifyDeviceData->CommandSetSupport.BigLba && IdentifyDeviceData->CommandSetActive.BigLba) + if ((IdentifyDeviceData->CommandSetSupport.BigLba) && (IdentifyDeviceData->CommandSetActive.BigLba)) { PortExtension->DeviceParams.Lba48BitMode = 1; } @@ -1699,8 +1706,8 @@ __in PCDB Cdb ) { - ULONG64 SectorNo; BOOLEAN IsReading; + ULONG64 StartOffset; PAHCI_SRB_EXTENSION SrbExtension; PAHCI_PORT_EXTENSION PortExtension; ULONG DataTransferLength, BytesPerSector, SectorCount; @@ -1721,7 +1728,7 @@ ROUND_UP(DataTransferLength, BytesPerSector); SectorCount = DataTransferLength / BytesPerSector; - SectorNo = AhciGetLba(Cdb); + StartOffset = AhciGetLba(Cdb, Srb->CdbLength); IsReading = (Cdb->CDB10.OperationCode == SCSIOP_READ); NT_ASSERT(SectorCount > 0); @@ -1742,9 +1749,9 @@ } SrbExtension->FeaturesLow = 0; - SrbExtension->LBA0 = (SectorNo >> 0) & 0xFF; - SrbExtension->LBA1 = (SectorNo >> 8) & 0xFF; - SrbExtension->LBA2 = (SectorNo >> 16) & 0xFF; + SrbExtension->LBA0 = (StartOffset >> 0) & 0xFF; + SrbExtension->LBA1 = (StartOffset >> 8) & 0xFF; + SrbExtension->LBA2 = (StartOffset >> 16) & 0xFF; SrbExtension->Device = (0xA0 | IDE_LBA_MODE); @@ -1753,9 +1760,9 @@ SrbExtension->Flags |= ATA_FLAGS_48BIT_COMMAND; SrbExtension->CommandReg = IDE_COMMAND_READ_DMA_EXT; - SrbExtension->LBA3 = (SectorNo >> 24) & 0xFF; - SrbExtension->LBA4 = (SectorNo >> 32) & 0xFF; - SrbExtension->LBA5 = (SectorNo >> 40) & 0xFF; + SrbExtension->LBA3 = (StartOffset >> 24) & 0xFF; + SrbExtension->LBA4 = (StartOffset >> 32) & 0xFF; + SrbExtension->LBA5 = (StartOffset >> 40) & 0xFF; } else { @@ -1770,7 +1777,6 @@ SrbExtension->pSgl = (PLOCAL_SCATTER_GATHER_LIST)StorPortGetScatterGatherList(AdapterExtension, Srb); - AhciProcessIO(AdapterExtension, Srb->PathId, Srb); return SRB_STATUS_PENDING; }// -- DeviceRequestReadWrite(); @@ -1835,6 +1841,35 @@ return SRB_STATUS_SUCCESS; }// -- DeviceRequestCapacity(); + +/** + * @name DeviceRequestComplete + * @implemented + * + * Handle UnHandled Requests + * + * @param AdapterExtension + * @param Srb + * @param Cdb + * + * @return + * return STOR status for DeviceRequestComplete + */ +UCHAR DeviceRequestComplete ( + __in PAHCI_ADAPTER_EXTENSION AdapterExtension, + __in PSCSI_REQUEST_BLOCK Srb, + __in PCDB Cdb + ) +{ + AhciDebugPrint("DeviceRequestComplete()\n"); + + UNREFERENCED_PARAMETER(AdapterExtension); + UNREFERENCED_PARAMETER(Cdb); + + Srb->ScsiStatus = SCSISTAT_GOOD; + + return SRB_STATUS_SUCCESS; +}// -- DeviceRequestComplete(); /** * @name DeviceReportLuns @@ -1951,8 +1986,6 @@ SrbExtension->Sgl.List[0].Length = sizeof(IDENTIFY_DEVICE_DATA); SrbExtension->pSgl = &SrbExtension->Sgl; - - AhciProcessIO(AdapterExtension, Srb->PathId, Srb); return SRB_STATUS_PENDING; } else @@ -2224,21 +2257,41 @@ return (PAHCI_SRB_EXTENSION)(SrbExtension + Offset); }// -- PAHCI_SRB_EXTENSION(); - +/** + * @name AhciGetLba + * @implemented + * + * Find the logical address of demand block from Cdb + * + * @param Srb + * + * @return + * return Logical Address of the block + * + */ __inline ULONG64 AhciGetLba ( - __in PCDB Cdb + __in PCDB Cdb, + __in ULONG CdbLength ) { ULONG64 lba = 0; NT_ASSERT(Cdb != NULL); - - lba |= Cdb->CDB10.LogicalBlockByte3 << 0; - lba |= Cdb->CDB10.LogicalBlockByte2 << 8; - lba |= Cdb->CDB10.LogicalBlockByte1 << 16; - lba |= Cdb->CDB10.LogicalBlockByte0 << 24; + NT_ASSERT(CdbLength != 0); + + if (CdbLength == 0x10) + { + REVERSE_BYTES_QUAD(&lba, Cdb->CDB16.LogicalBlock); + } + else + { + lba |= Cdb->CDB10.LogicalBlockByte3 << 0; + lba |= Cdb->CDB10.LogicalBlockByte2 << 8; + lba |= Cdb->CDB10.LogicalBlockByte1 << 16; + lba |= Cdb->CDB10.LogicalBlockByte0 << 24; + } return lba; }// -- AhciGetLba(); Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
============================================================================== --- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h [iso-8859-1] (original) +++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h [iso-8859-1] Mon Jul 25 11:09:25 2016 @@ -565,6 +565,13 @@ // Declarations // ////////////////////////////////////////////////////////////// +VOID +AhciProcessIO ( + __in PAHCI_ADAPTER_EXTENSION AdapterExtension, + __in UCHAR PathId, + __in PSCSI_REQUEST_BLOCK Srb + ); + BOOLEAN AhciAdapterReset ( __in PAHCI_ADAPTER_EXTENSION AdapterExtension @@ -603,6 +610,12 @@ __in PCDB Cdb ); +UCHAR DeviceRequestComplete ( + __in PAHCI_ADAPTER_EXTENSION AdapterExtension, + __in PSCSI_REQUEST_BLOCK Srb, + __in PCDB Cdb + ); + UCHAR DeviceReportLuns ( __in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, @@ -631,7 +644,8 @@ __inline ULONG64 AhciGetLba ( - __in PCDB Cdb + __in PCDB Cdb, + __in ULONG CdbLength ); //////////////////////////////////////////////////////////////
8 years, 5 months
1
0
0
0
[cwittich] 71995: [ADVAPI32] silence debug spam
by cwittich@svn.reactos.org
Author: cwittich Date: Mon Jul 25 11:07:44 2016 New Revision: 71995 URL:
http://svn.reactos.org/svn/reactos?rev=71995&view=rev
Log: [ADVAPI32] silence debug spam Modified: trunk/reactos/dll/win32/advapi32/reg/hkcr.c Modified: trunk/reactos/dll/win32/advapi32/reg/hkcr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/hkc…
============================================================================== --- trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/reg/hkcr.c [iso-8859-1] Mon Jul 25 11:07:44 2016 @@ -746,8 +746,8 @@ NULL); if (ErrorCode != ERROR_SUCCESS) { - /* Most likely ERROR_NO_MORE_ITEMS */ - ERR("Returning %d.\n", ErrorCode); + if (ErrorCode != ERROR_NO_MORE_ITEMS) + ERR("Returning %d.\n", ErrorCode); goto Exit; } FallbackSubKeyName[FallbackSubkeyLen] = L'\0';
8 years, 5 months
1
0
0
0
[tfaber] 71994: [WIN32K:NTUSER] - Fix UserDrawCaptionBar debug spam
by tfaber@svn.reactos.org
Author: tfaber Date: Mon Jul 25 10:45:30 2016 New Revision: 71994 URL:
http://svn.reactos.org/svn/reactos?rev=71994&view=rev
Log: [WIN32K:NTUSER] - Fix UserDrawCaptionBar debug spam Modified: trunk/reactos/win32ss/user/ntuser/nonclient.c Modified: trunk/reactos/win32ss/user/ntuser/nonclient.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/noncli…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/nonclient.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/nonclient.c [iso-8859-1] Mon Jul 25 10:45:30 2016 @@ -846,7 +846,7 @@ if (!(Flags & DC_NOVISIBLE) && !IntIsWindowVisible(pWnd)) return; - ERR("UserDrawCaptionBar: pWnd %p, hDc %p, Flags 0x%x.\n", pWnd, hDC, Flags); + TRACE("UserDrawCaptionBar: pWnd %p, hDc %p, Flags 0x%x.\n", pWnd, hDC, Flags); Style = pWnd->style; ExStyle = pWnd->ExStyle;
8 years, 5 months
1
0
0
0
[tfaber] 71993: [NTOS:CC] - Unconditionally acquire the VACB lock during map/pin/unpin operations and release it appropriately CORE-11555 #resolve CORE-11654 CORE-11504 CORE-11328 #comment This mig...
by tfaber@svn.reactos.org
Author: tfaber Date: Mon Jul 25 08:48:50 2016 New Revision: 71993 URL:
http://svn.reactos.org/svn/reactos?rev=71993&view=rev
Log: [NTOS:CC] - Unconditionally acquire the VACB lock during map/pin/unpin operations and release it appropriately CORE-11555 #resolve CORE-11654 CORE-11504 CORE-11328 #comment This might be fixed with r71993. Could you retry please? Modified: trunk/reactos/ntoskrnl/cc/pin.c trunk/reactos/ntoskrnl/cc/view.c trunk/reactos/ntoskrnl/include/internal/cc.h Modified: trunk/reactos/ntoskrnl/cc/pin.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/pin.c?rev=7199…
============================================================================== --- trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] Mon Jul 25 08:48:50 2016 @@ -185,10 +185,8 @@ ASSERT(iBcb->Pinned == FALSE); iBcb->Pinned = TRUE; - if (InterlockedIncrement(&iBcb->Vacb->PinCount) == 1) - { - CcRosReleaseVacbLock(iBcb->Vacb); - } + iBcb->Vacb->PinCount++; + CcRosReleaseVacbLock(iBcb->Vacb); if (Flags & PIN_EXCLUSIVE) { @@ -281,10 +279,8 @@ { ExReleaseResourceForThreadLite(&iBcb->Lock, ResourceThreadId); iBcb->Pinned = FALSE; - if (InterlockedDecrement(&iBcb->Vacb->PinCount) == 0) - { - CcRosAcquireVacbLock(iBcb->Vacb, NULL); - } + CcRosAcquireVacbLock(iBcb->Vacb, NULL); + iBcb->Vacb->PinCount--; } CcRosReleaseVacb(iBcb->Vacb->SharedCacheMap, @@ -355,10 +351,8 @@ { ExReleaseResourceLite(&iBcb->Lock); iBcb->Pinned = FALSE; - if (InterlockedDecrement(&iBcb->Vacb->PinCount) == 0) - { - CcRosAcquireVacbLock(iBcb->Vacb, NULL); - } + CcRosAcquireVacbLock(iBcb->Vacb, NULL); + iBcb->Vacb->PinCount--; } ExDeleteResourceLite(&iBcb->Lock); ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb); Modified: trunk/reactos/ntoskrnl/cc/view.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=719…
============================================================================== --- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Mon Jul 25 08:48:50 2016 @@ -422,10 +422,7 @@ KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql); KeReleaseGuardedMutex(&ViewLock); - if (InterlockedCompareExchange(&Vacb->PinCount, 0, 0) == 0) - { - CcRosReleaseVacbLock(Vacb); - } + CcRosReleaseVacbLock(Vacb); return STATUS_SUCCESS; } @@ -462,10 +459,7 @@ CcRosVacbIncRefCount(current); KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql); KeReleaseGuardedMutex(&ViewLock); - if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0) - { - CcRosAcquireVacbLock(current, NULL); - } + CcRosAcquireVacbLock(current, NULL); return current; } if (current->FileOffset.QuadPart > FileOffset) @@ -712,10 +706,7 @@ KeReleaseGuardedMutex(&ViewLock); ExFreeToNPagedLookasideList(&VacbLookasideList, *Vacb); *Vacb = current; - if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0) - { - CcRosAcquireVacbLock(current, NULL); - } + CcRosAcquireVacbLock(current, NULL); return STATUS_SUCCESS; } if (current->FileOffset.QuadPart < FileOffset) @@ -945,10 +936,7 @@ } } - if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0) - { - CcRosReleaseVacbLock(current); - } + CcRosReleaseVacbLock(current); KeAcquireGuardedMutex(&ViewLock); KeAcquireSpinLock(&SharedCacheMap->CacheMapLock, &oldIrql); Modified: trunk/reactos/ntoskrnl/include/internal/cc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] Mon Jul 25 08:48:50 2016 @@ -185,7 +185,8 @@ /* Number of references. */ ULONG ReferenceCount; /* How many times was it pinned? */ - volatile LONG PinCount; + _Guarded_by_(Mutex) + LONG PinCount; /* Pointer to the shared cache map for the file which this view maps data for. */ PROS_SHARED_CACHE_MAP SharedCacheMap; /* Pointer to the next VACB in a chain. */
8 years, 5 months
1
0
0
0
[aandrejevic] 71992: [NTVDM] Implement the VGA AC Color Select register. Implement INT 0x10, AH = 0x10, subfunction AL = 0x13.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Sun Jul 24 18:25:50 2016 New Revision: 71992 URL:
http://svn.reactos.org/svn/reactos?rev=71992&view=rev
Log: [NTVDM] Implement the VGA AC Color Select register. Implement INT 0x10, AH = 0x10, subfunction AL = 0x13. Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c [iso-8859-1] Sun Jul 24 18:25:50 2016 @@ -3379,6 +3379,31 @@ break; } + /* Set Video DAC Color Page */ + case 0x13: + { + if (getBL() == 0) + { + /* Set the highest bit of the AC Mode Control register to BH */ + IOReadB(VGA_INSTAT1_READ); + IOWriteB(VGA_AC_INDEX, VGA_AC_CONTROL_REG); + IOWriteB(VGA_AC_WRITE, (IOReadB(VGA_AC_READ) & 0x7F) | (getBH() << 7)); + } + else if (getBL() == 1) + { + /* Set the AC Color Select register to BH */ + IOReadB(VGA_INSTAT1_READ); + IOWriteB(VGA_AC_INDEX, VGA_AC_COLOR_SEL_REG); + IOWriteB(VGA_AC_WRITE, getBH()); + } + else + { + DPRINT1("BIOS Palette Control Sub-sub-command BL = 0x%02X INVALID\n", getBL()); + } + + break; + } + /* Get Individual DAC Register */ case 0x15: { Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/svga.c [iso-8859-1] Sun Jul 24 18:25:50 2016 @@ -946,8 +946,26 @@ * if external palette access is disabled, otherwise (in case * of palette loading) it is a blank pixel. */ - PixelData = (VgaAcPalDisable ? VgaAcRegisters[PixelData & 0x0F] - : 0); + + if (VgaAcPalDisable) + { + if (!(VgaAcRegisters[VGA_AC_CONTROL_REG] & VGA_AC_CONTROL_P54S)) + { + /* Bits 4 and 5 are taken from the palette register */ + PixelData = ((VgaAcRegisters[VGA_AC_COLOR_SEL_REG] << 4) & 0xC0) + | (VgaAcRegisters[PixelData & 0x0F] & 0x3F); + } + else + { + /* Bits 4 and 5 are taken from the color select register */ + PixelData = (VgaAcRegisters[VGA_AC_COLOR_SEL_REG] << 4) + | (VgaAcRegisters[PixelData & 0x0F] & 0x0F); + } + } + else + { + PixelData = 0; + } } /* Take into account DoubleVision mode when checking for pixel updates */
8 years, 5 months
1
0
0
0
[tfaber] 71991: [NTOS:CC] - Centralize VACB locking/unlocking into inline functions for easier instrumentation
by tfaber@svn.reactos.org
Author: tfaber Date: Sun Jul 24 17:10:30 2016 New Revision: 71991 URL:
http://svn.reactos.org/svn/reactos?rev=71991&view=rev
Log: [NTOS:CC] - Centralize VACB locking/unlocking into inline functions for easier instrumentation Modified: trunk/reactos/ntoskrnl/cc/pin.c trunk/reactos/ntoskrnl/cc/view.c trunk/reactos/ntoskrnl/include/internal/cc.h Modified: trunk/reactos/ntoskrnl/cc/pin.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/pin.c?rev=7199…
============================================================================== --- trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cc/pin.c [iso-8859-1] Sun Jul 24 17:10:30 2016 @@ -187,7 +187,7 @@ iBcb->Pinned = TRUE; if (InterlockedIncrement(&iBcb->Vacb->PinCount) == 1) { - KeReleaseMutex(&iBcb->Vacb->Mutex, FALSE); + CcRosReleaseVacbLock(iBcb->Vacb); } if (Flags & PIN_EXCLUSIVE) @@ -283,11 +283,7 @@ iBcb->Pinned = FALSE; if (InterlockedDecrement(&iBcb->Vacb->PinCount) == 0) { - KeWaitForSingleObject(&iBcb->Vacb->Mutex, - Executive, - KernelMode, - FALSE, - NULL); + CcRosAcquireVacbLock(iBcb->Vacb, NULL); } } @@ -339,11 +335,7 @@ IoStatus->Information = 0; if (WriteThrough) { - KeWaitForSingleObject(&iBcb->Vacb->Mutex, - Executive, - KernelMode, - FALSE, - NULL); + CcRosAcquireVacbLock(iBcb->Vacb, NULL); if (iBcb->Vacb->Dirty) { IoStatus->Status = CcRosFlushVacb(iBcb->Vacb); @@ -352,7 +344,7 @@ { IoStatus->Status = STATUS_SUCCESS; } - KeReleaseMutex(&iBcb->Vacb->Mutex, FALSE); + CcRosReleaseVacbLock(iBcb->Vacb); } else { @@ -365,11 +357,7 @@ iBcb->Pinned = FALSE; if (InterlockedDecrement(&iBcb->Vacb->PinCount) == 0) { - KeWaitForSingleObject(&iBcb->Vacb->Mutex, - Executive, - KernelMode, - FALSE, - NULL); + CcRosAcquireVacbLock(iBcb->Vacb, NULL); } } ExDeleteResourceLite(&iBcb->Lock); Modified: trunk/reactos/ntoskrnl/cc/view.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cc/view.c?rev=719…
============================================================================== --- trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cc/view.c [iso-8859-1] Sun Jul 24 17:10:30 2016 @@ -199,11 +199,8 @@ continue; } - Status = KeWaitForSingleObject(¤t->Mutex, - Executive, - KernelMode, - FALSE, - Wait ? NULL : &ZeroTimeout); + Status = CcRosAcquireVacbLock(current, + Wait ? NULL : &ZeroTimeout); if (Status != STATUS_SUCCESS) { current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite( @@ -217,7 +214,7 @@ /* One reference is added above */ if (current->ReferenceCount > 2) { - KeReleaseMutex(¤t->Mutex, FALSE); + CcRosReleaseVacbLock(current); current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite( current->SharedCacheMap->LazyWriteContext); CcRosVacbDecRefCount(current); @@ -228,7 +225,7 @@ Status = CcRosFlushVacb(current); - KeReleaseMutex(¤t->Mutex, FALSE); + CcRosReleaseVacbLock(current); current->SharedCacheMap->Callbacks->ReleaseFromLazyWrite( current->SharedCacheMap->LazyWriteContext); @@ -427,7 +424,7 @@ KeReleaseGuardedMutex(&ViewLock); if (InterlockedCompareExchange(&Vacb->PinCount, 0, 0) == 0) { - KeReleaseMutex(&Vacb->Mutex, FALSE); + CcRosReleaseVacbLock(Vacb); } return STATUS_SUCCESS; @@ -467,11 +464,7 @@ KeReleaseGuardedMutex(&ViewLock); if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0) { - KeWaitForSingleObject(¤t->Mutex, - Executive, - KernelMode, - FALSE, - NULL); + CcRosAcquireVacbLock(current, NULL); } return current; } @@ -527,7 +520,7 @@ KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql); KeReleaseGuardedMutex(&ViewLock); - KeReleaseMutex(&Vacb->Mutex, FALSE); + CcRosReleaseVacbLock(Vacb); return STATUS_SUCCESS; } @@ -580,7 +573,7 @@ KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, oldIrql); KeReleaseGuardedMutex(&ViewLock); - KeReleaseMutex(&Vacb->Mutex, FALSE); + CcRosReleaseVacbLock(Vacb); return STATUS_SUCCESS; } @@ -683,11 +676,7 @@ current->ReferenceCount = 1; current->PinCount = 0; KeInitializeMutex(¤t->Mutex, 0); - KeWaitForSingleObject(¤t->Mutex, - Executive, - KernelMode, - FALSE, - NULL); + CcRosAcquireVacbLock(current, NULL); KeAcquireGuardedMutex(&ViewLock); *Vacb = current; @@ -719,17 +708,13 @@ current); } #endif - KeReleaseMutex(&(*Vacb)->Mutex, FALSE); + CcRosReleaseVacbLock(*Vacb); KeReleaseGuardedMutex(&ViewLock); ExFreeToNPagedLookasideList(&VacbLookasideList, *Vacb); *Vacb = current; if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0) { - KeWaitForSingleObject(¤t->Mutex, - Executive, - KernelMode, - FALSE, - NULL); + CcRosAcquireVacbLock(current, NULL); } return STATUS_SUCCESS; } @@ -962,7 +947,7 @@ if (InterlockedCompareExchange(¤t->PinCount, 0, 0) == 0) { - KeReleaseMutex(¤t->Mutex, FALSE); + CcRosReleaseVacbLock(current); } KeAcquireGuardedMutex(&ViewLock); Modified: trunk/reactos/ntoskrnl/include/internal/cc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/cc.h [iso-8859-1] Sun Jul 24 17:10:30 2016 @@ -341,6 +341,29 @@ CcTryToInitializeFileCache(PFILE_OBJECT FileObject); FORCEINLINE +NTSTATUS +CcRosAcquireVacbLock( + _Inout_ PROS_VACB Vacb, + _In_ PLARGE_INTEGER Timeout) +{ + NTSTATUS Status; + Status = KeWaitForSingleObject(&Vacb->Mutex, + Executive, + KernelMode, + FALSE, + Timeout); + return Status; +} + +FORCEINLINE +VOID +CcRosReleaseVacbLock( + _Inout_ PROS_VACB Vacb) +{ + KeReleaseMutex(&Vacb->Mutex, FALSE); +} + +FORCEINLINE BOOLEAN DoRangesIntersect( _In_ LONGLONG Offset1,
8 years, 5 months
1
0
0
0
[aandrejevic] 71990: [NTVDM] Always reset the AC latch before writing to the AC index register. CORE-11669 #resolve #comment Should be fixed in revision r71990.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Sun Jul 24 15:45:50 2016 New Revision: 71990 URL:
http://svn.reactos.org/svn/reactos?rev=71990&view=rev
Log: [NTVDM] Always reset the AC latch before writing to the AC index register. CORE-11669 #resolve #comment Should be fixed in revision r71990. Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c [iso-8859-1] Sun Jul 24 15:45:50 2016 @@ -3241,6 +3241,7 @@ /* Set the overscan register */ // VgaSetSinglePaletteRegister(VGA_AC_OVERSCAN_REG, Buffer[VGA_AC_PAL_F_REG + 1]); + IOReadB(VGA_INSTAT1_READ); IOWriteB(VGA_AC_INDEX, VGA_AC_OVERSCAN_REG); IOWriteB(VGA_AC_WRITE, Buffer[VGA_AC_PAL_F_REG + 1]); @@ -3255,6 +3256,8 @@ { /* Read the old AC mode control register value */ BYTE VgaAcControlReg; + + IOReadB(VGA_INSTAT1_READ); IOWriteB(VGA_AC_INDEX, VGA_AC_CONTROL_REG); VgaAcControlReg = IOReadB(VGA_AC_READ); @@ -3270,6 +3273,7 @@ Bda->CrtModeControl &= ~(1 << 5); } + IOReadB(VGA_INSTAT1_READ); IOWriteB(VGA_AC_INDEX, VGA_AC_CONTROL_REG); IOWriteB(VGA_AC_WRITE, VgaAcControlReg); @@ -3329,6 +3333,7 @@ } /* Get the overscan register */ + IOReadB(VGA_INSTAT1_READ); IOWriteB(VGA_AC_INDEX, VGA_AC_OVERSCAN_REG); Buffer[VGA_AC_PAL_F_REG + 1] = IOReadB(VGA_AC_READ);
8 years, 5 months
1
0
0
0
[hbelusca] 71989: [EVENTVWR] - Use helper functions for doing the filtering on the events (idea by Mark Jansen). - Fix the states of menu items, depending on which event log/item (log file/filter; ...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Jul 24 15:24:50 2016 New Revision: 71989 URL:
http://svn.reactos.org/svn/reactos?rev=71989&view=rev
Log: [EVENTVWR] - Use helper functions for doing the filtering on the events (idea by Mark Jansen). - Fix the states of menu items, depending on which event log/item (log file/filter; event item...) is currently selected. - Correctly empty the event items list & cache whenever an event log/filter is closed (and avoid a crash when all logs/filters are closed and someone attempts to open an event item), during concurrent accesses. I use a reference count and AddRef/Release helpers. - Get rid of the annoying log loading popup, and use instead the loading message displayed in the events listview as well as a progress-bar in the status bar. CORE-11637 Modified: trunk/reactos/base/applications/mscutils/eventvwr/eventvwr.c trunk/reactos/base/applications/mscutils/eventvwr/lang/bg-BG.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/cs-CZ.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/de-DE.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/el-GR.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/en-US.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/es-ES.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/fr-FR.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/he-IL.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/it-IT.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/ja-JP.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/ko-KR.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/no-NO.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/pl-PL.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/pt-BR.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/ro-RO.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/ru-RU.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/sk-SK.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/sq-AL.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/sv-SE.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/tr-TR.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/uk-UA.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/zh-CN.rc trunk/reactos/base/applications/mscutils/eventvwr/lang/zh-TW.rc trunk/reactos/base/applications/mscutils/eventvwr/resource.h Modified: trunk/reactos/base/applications/mscutils/eventvwr/eventvwr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/eventvwr.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/eventvwr.c [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -57,6 +57,21 @@ #define EnableDlgItem(hDlg, nID, bEnable) \ EnableWindow(GetDlgItem((hDlg), (nID)), (bEnable)) +#define ProgressBar_SetPos(hwndCtl,pos) \ + ((int)SNDMSG((hwndCtl),PBM_SETPOS,(WPARAM)(int)(pos),(LPARAM)0)) +#define ProgressBar_SetRange(hwndCtl,range) \ + ((int)SNDMSG((hwndCtl),PBM_SETRANGE,(WPARAM)0,(LPARAM)(range))) +#define ProgressBar_SetStep(hwndCtl,inc) \ + ((int)SNDMSG((hwndCtl),PBM_SETSTEP,(WPARAM)(int)(inc),(LPARAM)0)) +#define ProgressBar_StepIt(hwndCtl) \ + ((int)SNDMSG((hwndCtl),PBM_STEPIT,(WPARAM)0,(LPARAM)0)) + +#define StatusBar_GetItemRect(hwndCtl,index,lprc) \ + ((BOOL)SNDMSG((hwndCtl),SB_GETRECT,(WPARAM)(int)(index),(LPARAM)(RECT*)(lprc))) +#define StatusBar_SetText(hwndCtl,index,data) \ + ((BOOL)SNDMSG((hwndCtl),SB_SETTEXT,(WPARAM)(index),(LPARAM)(data))) + + #include <strsafe.h> /* Missing RichEdit flags in our richedit.h */ @@ -71,14 +86,8 @@ #ifndef WM_APP #define WM_APP 0x8000 #endif -#define PM_PROGRESS_DLG (WM_APP + 1) - - -typedef struct _DETAILDATA -{ - BOOL bDisplayWords; - HFONT hMonospaceFont; -} DETAILDATA, *PDETAILDATA; +#define LVM_PROGRESS (WM_APP + 1) + static const LPCWSTR szWindowClass = L"EVENTVWR"; /* The main window class name */ static const WCHAR EVENTLOG_BASE_KEY[] = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\"; @@ -117,8 +126,8 @@ HWND hwndTreeView; /* TreeView control */ HWND hwndListView; /* ListView control */ HWND hwndStatus; /* Status bar */ +HWND hwndStatusProgress; /* Progress bar in the status bar */ HMENU hMainMenu; /* The application's main menu */ -HWND hProgressDlg = NULL; /* A progress dialog that pops up */ HTREEITEM htiSystemLogs = NULL, htiAppLogs = NULL, htiUserLogs = NULL; @@ -150,6 +159,8 @@ typedef struct _EVENTLOGFILTER { LIST_ENTRY ListEntry; + + LONG ReferenceCount; // HANDLE hEnumEventsThread; // HANDLE hStopEnumEvent; @@ -195,20 +206,22 @@ HANDLE hStopEnumEvent = NULL; /* - * Event-enumerator command structures. + * Setting EnumFilter to a valid pointer and raising the hStartEnumEvent event + * triggers the event-enumerator thread to perform a new enumeration. */ -typedef struct _ENUM_COMMAND_PARAM -{ - BOOL Start; - PEVENTLOGFILTER EventLogFilter; -} ENUM_COMMAND_PARAM, *PENUM_COMMAND_PARAM; - -ENUM_COMMAND_PARAM EnumCommand; +PEVENTLOGFILTER EnumFilter = NULL; HANDLE hStartStopEnumEvent = NULL; // End-of-application event HANDLE hStartEnumEvent = NULL; // Command event /* Default Open/Save-As dialog box */ OPENFILENAMEW sfn; + +typedef struct _DETAILDATA +{ + PEVENTLOGFILTER EventLogFilter; + BOOL bDisplayWords; + HFONT hMonospaceFont; +} DETAILDATA, *PDETAILDATA; /* Forward declarations of functions included in this code module */ @@ -222,10 +235,9 @@ ATOM MyRegisterClass(HINSTANCE); BOOL InitInstance(HINSTANCE, int); -VOID CleanupInstance(HINSTANCE); +VOID ExitInstance(HINSTANCE); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); -static INT_PTR CALLBACK StatusMessageWindowProc(HWND, UINT, WPARAM, LPARAM); -INT_PTR EventLogProperties(HINSTANCE, HWND); +INT_PTR EventLogProperties(HINSTANCE, HWND, PEVENTLOGFILTER); INT_PTR CALLBACK EventDetails(HWND, UINT, WPARAM, LPARAM); @@ -326,7 +338,7 @@ if (hStartStopEnumEvent) CloseHandle(hStartStopEnumEvent); - CleanupInstance(hInstance); + ExitInstance(hInstance); Quit: FreeLibrary(hRichEdit); @@ -949,7 +961,7 @@ } VOID -FreeEventLog(IN PEVENTLOG EventLog) +EventLog_Free(IN PEVENTLOG EventLog) { if (EventLog->LogName) HeapFree(GetProcessHeap(), 0, EventLog->LogName); @@ -1019,11 +1031,14 @@ EventLogFilter->NumOfEventLogs = NumOfEventLogs; RtlCopyMemory(EventLogFilter->EventLogs, EventLogs, NumOfEventLogs * sizeof(PEVENTLOG)); + /* Initialize the filter reference count */ + EventLogFilter->ReferenceCount = 1; + return EventLogFilter; } VOID -FreeEventLogFilter(IN PEVENTLOGFILTER EventLogFilter) +EventLogFilter_Free(IN PEVENTLOGFILTER EventLogFilter) { if (EventLogFilter->Sources) HeapFree(GetProcessHeap(), 0, EventLogFilter->Sources); @@ -1037,6 +1052,29 @@ HeapFree(GetProcessHeap(), 0, EventLogFilter); } +LONG EventLogFilter_AddRef(IN PEVENTLOGFILTER EventLogFilter) +{ + ASSERT(EventLogFilter); + return InterlockedIncrement(&EventLogFilter->ReferenceCount); +} + +LONG EventLogFilter_Release(IN PEVENTLOGFILTER EventLogFilter) +{ + LONG RefCount; + + ASSERT(EventLogFilter); + + /* When the reference count reaches zero, delete the filter */ + RefCount = InterlockedDecrement(&EventLogFilter->ReferenceCount); + if (RefCount <= 0) + { + /* Remove the filter from the list */ + /** RemoveEntryList(&EventLogFilter->ListEntry); **/ + EventLogFilter_Free(EventLogFilter); + } + + return RefCount; +} void TrimNulls(LPWSTR s) @@ -1324,7 +1362,7 @@ } BOOL -GetEventUserName(PEVENTLOGRECORD pelr, +GetEventUserName(IN PEVENTLOGRECORD pelr, OUT PWCHAR pszUser) // TODO: Add IN DWORD BufLen { PSID lpSid; @@ -1374,6 +1412,76 @@ g_TotalRecords = 0; } +BOOL +FilterByType(IN PEVENTLOGFILTER EventLogFilter, + IN PEVENTLOGRECORD pevlr) +{ + if ((pevlr->EventType == EVENTLOG_SUCCESS && !EventLogFilter->Information ) || + (pevlr->EventType == EVENTLOG_INFORMATION_TYPE && !EventLogFilter->Information ) || + (pevlr->EventType == EVENTLOG_WARNING_TYPE && !EventLogFilter->Warning ) || + (pevlr->EventType == EVENTLOG_ERROR_TYPE && !EventLogFilter->Error ) || + (pevlr->EventType == EVENTLOG_AUDIT_SUCCESS && !EventLogFilter->AuditSuccess) || + (pevlr->EventType == EVENTLOG_AUDIT_FAILURE && !EventLogFilter->AuditFailure)) + { + return FALSE; + } + return TRUE; +} + +BOOL +FilterByString(IN PCWSTR FilterString, // This is a multi-string + IN PWSTR String) +{ + PCWSTR pStr; + + /* The filter string is NULL so it does not filter anything */ + if (!FilterString) + return TRUE; + + /* + * If the filter string filters for an empty string AND the source string + * is an empty string, we have a match (particular case of the last one). + */ + if (!*FilterString && !*String) + return TRUE; + + // if (*FilterString || *String) + + /* + * If the filter string is empty BUT the source string is not empty, + * OR vice-versa, we cannot have a match. + */ + if ( (!*FilterString && *String) || (*FilterString && !*String) ) + return FALSE; + + /* + * If the filter string filters for at least a non-empty string, + * browse it and search for a string that matches the source string. + */ + // else if (*FilterString && *String) + { + pStr = FilterString; + while (*pStr) + { + if (wcsicmp(pStr, String) == 0) + { + /* We have a match, break the loop */ + break; + } + + pStr += (wcslen(pStr) + 1); + } + if (!*pStr) // && *String + { + /* We do not have a match */ + return FALSE; + } + } + + /* We have a match */ + return TRUE; +} + /* * The events enumerator thread. */ @@ -1383,9 +1491,6 @@ PEVENTLOGFILTER EventLogFilter = (PEVENTLOGFILTER)lpParameter; LPWSTR lpMachineName = NULL; // EventLogFilter->ComputerName; PEVENTLOG EventLog; - PWSTR pStr; - - BOOL ProgressDlg = FALSE; ULONG LogIndex; HANDLE hEventLog; @@ -1398,6 +1503,8 @@ LPWSTR lpszComputerName; BOOL bResult = TRUE; /* Read succeeded */ + UINT uStep = 0, uStepAt = 0, uPos = 0; + WCHAR szWindowTitle[MAX_PATH]; WCHAR szStatusText[MAX_PATH]; WCHAR szLocalDate[MAX_PATH]; @@ -1413,16 +1520,20 @@ LVITEMW lviEventItem; /* Save the current event log filter globally */ + EventLogFilter_AddRef(EventLogFilter); ActiveFilter = EventLogFilter; /* Disable list view redraw */ SendMessageW(hwndListView, WM_SETREDRAW, FALSE, 0); - /* Clear the list view */ - (void)ListView_DeleteAllItems(hwndListView); + /* Clear the list view and free the cached records */ + ListView_DeleteAllItems(hwndListView); FreeRecords(); - SendMessage(hwndListView, PM_PROGRESS_DLG, 0, TRUE); + SendMessageW(hwndListView, LVM_PROGRESS, 0, TRUE); + ProgressBar_SetRange(hwndStatusProgress, 0); + StatusBar_SetText(hwndStatus, 0, NULL); + ShowWindow(hwndStatusProgress, SW_SHOW); /* Do a loop over the logs enumerated in the filter */ // FIXME: For now we only support 1 event log per filter! @@ -1469,14 +1580,11 @@ } g_TotalRecords = dwTotalRecords; - /* If we have at least 1000 records show the waiting dialog */ - if (dwTotalRecords > 1000) - { - ProgressDlg = SendMessage(hwndMainWindow, PM_PROGRESS_DLG, 0, TRUE); - } - if (WaitForSingleObject(hStopEnumEvent, 0) == WAIT_OBJECT_0) goto Quit; + + ProgressBar_SetRange(hwndStatusProgress, MAKELPARAM(0, 100)); + uStepAt = (dwTotalRecords / 100) + 1; dwFlags = EVENTLOG_SEQUENTIAL_READ | (NewestEventsFirst ? EVENTLOG_FORWARDS_READ @@ -1536,67 +1644,30 @@ while (dwRead > 0) { + // ProgressBar_StepIt(hwndStatusProgress); + uStep++; + if(uStep % uStepAt == 0) + { + ++uPos; + ProgressBar_SetPos(hwndStatusProgress, uPos); + } + if (WaitForSingleObject(hStopEnumEvent, 0) == WAIT_OBJECT_0) goto Quit; /* Filter by event type */ - if ((pevlr->EventType == EVENTLOG_SUCCESS && !EventLogFilter->Information ) || - (pevlr->EventType == EVENTLOG_INFORMATION_TYPE && !EventLogFilter->Information ) || - (pevlr->EventType == EVENTLOG_WARNING_TYPE && !EventLogFilter->Warning ) || - (pevlr->EventType == EVENTLOG_ERROR_TYPE && !EventLogFilter->Error ) || - (pevlr->EventType == EVENTLOG_AUDIT_SUCCESS && !EventLogFilter->AuditSuccess) || - (pevlr->EventType == EVENTLOG_AUDIT_FAILURE && !EventLogFilter->AuditFailure)) - { + if (!FilterByType(EventLogFilter, pevlr)) goto SkipEvent; - } - - /* Get the event source name */ + + /* Get the event source name and filter it */ lpszSourceName = (LPWSTR)((LPBYTE)pevlr + sizeof(EVENTLOGRECORD)); - if (EventLogFilter->Sources) - { - if (!*EventLogFilter->Sources && !*lpszSourceName) - { - // Sources filters for NO-source, and SourceName == NO-source - // so it's ok - } - else if ( (!*EventLogFilter->Sources && *lpszSourceName) || - (*EventLogFilter->Sources && !*lpszSourceName) ) - { - // Sources filters for NO-source, and SourceName == some-source, - // or, - // Sources filters for SOME-source, and SourceName == NO-source, - // so skip the event - goto SkipEvent; - } - else if (*EventLogFilter->Sources && *lpszSourceName) - { - // Sources filters for SOME-source, and SourceName == SOME-source - // so it's ok - - // if (*EventLogFilter->Sources || *lpszSourceName) - - pStr = EventLogFilter->Sources; - while (*pStr) - { - if (wcsicmp(pStr, lpszSourceName) == 0) - { - /* We have a match, break the loop */ - break; - } - - pStr += (wcslen(pStr) + 1); - } - if (!*pStr) // && *lpszSourceName - { - /* No match, skip the event */ - goto SkipEvent; - } - } - } - - /* Get the computer name */ + if (!FilterByString(EventLogFilter->Sources, lpszSourceName)) + goto SkipEvent; + + /* Get the computer name and filter it */ lpszComputerName = (LPWSTR)((LPBYTE)pevlr + sizeof(EVENTLOGRECORD) + (wcslen(lpszSourceName) + 1) * sizeof(WCHAR)); - // if (EventLogFilter->ComputerNames) { ... } + if (!FilterByString(EventLogFilter->ComputerNames, lpszComputerName)) + goto SkipEvent; /* Compute the event time */ EventTimeToSystemTime(pevlr->TimeWritten, &time); @@ -1606,9 +1677,12 @@ LoadStringW(hInst, IDS_NOT_AVAILABLE, szUsername, ARRAYSIZE(szUsername)); LoadStringW(hInst, IDS_NONE, szCategory, ARRAYSIZE(szCategory)); - /* Get the username that generated the event */ + /* Get the username that generated the event, and filter it */ GetEventUserName(pevlr, szUsername); - // if (EventLogFilter->Users) { ... } + if (!FilterByString(EventLogFilter->Users, szUsername)) + goto SkipEvent; + + // TODO: Filter by event ID and category GetEventType(pevlr->EventType, szEventTypeText); GetEventCategory(EventLog->LogName, lpszSourceName, pevlr, szCategory); @@ -1672,12 +1746,11 @@ } // end-for (LogIndex) /* All events loaded */ - if (ProgressDlg) - SendMessage(hwndMainWindow, PM_PROGRESS_DLG, 0, FALSE); Cleanup: - SendMessage(hwndListView, PM_PROGRESS_DLG, 0, FALSE); + ShowWindow(hwndStatusProgress, SW_HIDE); + SendMessageW(hwndListView, LVM_PROGRESS, 0, FALSE); // FIXME: Use something else instead of EventLog->LogName !! @@ -1716,13 +1789,15 @@ } /* Update the status bar */ - SendMessageW(hwndStatus, SB_SETTEXT, (WPARAM)0, (LPARAM)szStatusText); + StatusBar_SetText(hwndStatus, 0, szStatusText); /* Set the window title */ SetWindowTextW(hwndMainWindow, szWindowTitle); /* Resume list view redraw */ SendMessageW(hwndListView, WM_SETREDRAW, TRUE, 0); + + EventLogFilter_Release(EventLogFilter); CloseHandle(hStopEnumEvent); InterlockedExchangePointer((PVOID*)&hStopEnumEvent, NULL); @@ -1771,7 +1846,12 @@ hEnumEventsThread = NULL; } + /* Clear the list view and free the cached records */ + ListView_DeleteAllItems(hwndListView); FreeRecords(); + + /* Reset the active filter */ + ActiveFilter = NULL; return 0; } @@ -1779,7 +1859,7 @@ case WAIT_OBJECT_0 + 1: { /* Restart a new enumeration if needed */ - PEVENTLOGFILTER EventLogFilter = EnumCommand.EventLogFilter; + PEVENTLOGFILTER EventLogFilter; /* Stop the previous enumeration */ if (hEnumEventsThread) @@ -1796,9 +1876,15 @@ hEnumEventsThread = NULL; } - // FreeRecords(); - - if (!EnumCommand.Start) + /* Clear the list view and free the cached records */ + ListView_DeleteAllItems(hwndListView); + FreeRecords(); + + /* Reset the active filter */ + ActiveFilter = NULL; + + EventLogFilter = InterlockedExchangePointer((PVOID*)&EnumFilter, NULL); + if (!EventLogFilter) break; // Manual-reset event @@ -1839,10 +1925,35 @@ EnumEvents(IN PEVENTLOGFILTER EventLogFilter) { /* Signal the enumerator thread we want to enumerate events */ - EnumCommand.Start = TRUE; - EnumCommand.EventLogFilter = EventLogFilter; + InterlockedExchangePointer((PVOID*)&EnumFilter, EventLogFilter); SetEvent(hStartEnumEvent); return; +} + + +PEVENTLOGFILTER +GetSelectedFilter(OUT HTREEITEM* phti OPTIONAL) +{ + TVITEMEXW tvItemEx; + HTREEITEM hti; + + if (phti) + *phti = NULL; + + /* Get index of selected item */ + hti = TreeView_GetSelection(hwndTreeView); + if (hti == NULL) + return NULL; // No filter + + tvItemEx.mask = TVIF_PARAM; + tvItemEx.hItem = hti; + + TreeView_GetItem(hwndTreeView, &tvItemEx); + + if (phti) + *phti = tvItemEx.hItem; + + return (PEVENTLOGFILTER)tvItemEx.lParam; } @@ -1903,58 +2014,57 @@ } VOID -SaveEventLog(VOID) +SaveEventLog(IN PEVENTLOGFILTER EventLogFilter) { PEVENTLOG EventLog; HANDLE hEventLog; WCHAR szFileName[MAX_PATH]; - ZeroMemory(szFileName, sizeof(szFileName)); - - sfn.lpstrFile = szFileName; - sfn.nMaxFile = ARRAYSIZE(szFileName); - - if (!GetSaveFileNameW(&sfn)) - return; - - EventLog = ActiveFilter->EventLogs[0]; - hEventLog = OpenEventLogW(EventLog->ComputerName, EventLog->LogName); - if (!hEventLog) - { - ShowLastWin32Error(); - return; - } - - if (!BackupEventLogW(hEventLog, szFileName)) - { - ShowLastWin32Error(); - } - - CloseEventLog(hEventLog); -} - -VOID -CloseUserEventLog(VOID) -{ - PEVENTLOGFILTER EventLogFilter = NULL; - - TVITEMEXW tvItemEx; - HTREEITEM hti; - - /* Get index of selected item */ - hti = TreeView_GetSelection(hwndTreeView); - if (hti != NULL) - { - tvItemEx.mask = TVIF_PARAM; - tvItemEx.hItem = hti; - - TreeView_GetItem(hwndTreeView, &tvItemEx); - EventLogFilter = (PEVENTLOGFILTER)tvItemEx.lParam; - } - /* Bail out if there is no available filter */ if (!EventLogFilter) return; + + ZeroMemory(szFileName, sizeof(szFileName)); + + sfn.lpstrFile = szFileName; + sfn.nMaxFile = ARRAYSIZE(szFileName); + + if (!GetSaveFileNameW(&sfn)) + return; + + EventLogFilter_AddRef(EventLogFilter); + + EventLog = EventLogFilter->EventLogs[0]; + hEventLog = OpenEventLogW(EventLog->ComputerName, EventLog->LogName); + + EventLogFilter_Release(EventLogFilter); + + if (!hEventLog) + { + ShowLastWin32Error(); + return; + } + + if (!BackupEventLogW(hEventLog, szFileName)) + ShowLastWin32Error(); + + CloseEventLog(hEventLog); +} + +VOID +CloseUserEventLog(IN PEVENTLOGFILTER EventLogFilter, IN HTREEITEM hti) +{ + /* Bail out if there is no available filter */ + if (!EventLogFilter) + return; + + if (InterlockedCompareExchangePointer((PVOID*)&ActiveFilter, NULL, NULL) == EventLogFilter) + { + /* Signal the enumerator thread we want to stop enumerating events */ + // EnumEvents(NULL); + InterlockedExchangePointer((PVOID*)&EnumFilter, NULL); + SetEvent(hStartEnumEvent); + } /* * The deletion of the item automatically triggers a TVN_SELCHANGED @@ -1963,12 +2073,9 @@ */ TreeView_DeleteItem(hwndTreeView, hti); - if (ActiveFilter == EventLogFilter) - ActiveFilter = NULL; - /* Remove the filter from the list */ RemoveEntryList(&EventLogFilter->ListEntry); - FreeEventLogFilter(EventLogFilter); + EventLogFilter_Release(EventLogFilter); // /* Select the default event log */ // // TreeView_Expand(hwndTreeView, htiUserLogs, TVE_EXPAND); @@ -1979,13 +2086,18 @@ BOOL -ClearEvents(VOID) -{ +ClearEvents(IN PEVENTLOGFILTER EventLogFilter) +{ + BOOL Success; PEVENTLOG EventLog; HANDLE hEventLog; WCHAR szFileName[MAX_PATH]; WCHAR szMessage[MAX_LOADSTRING]; + /* Bail out if there is no available filter */ + if (!EventLogFilter) + return FALSE; + ZeroMemory(szFileName, sizeof(szFileName)); ZeroMemory(szMessage, sizeof(szMessage)); @@ -1997,52 +2109,49 @@ switch (MessageBoxW(hwndMainWindow, szMessage, szTitle, MB_YESNOCANCEL | MB_ICONINFORMATION)) { case IDCANCEL: - { return FALSE; - } case IDNO: - { sfn.lpstrFile = NULL; break; - } case IDYES: - { if (!GetSaveFileNameW(&sfn)) - { return FALSE; - } break; - } - } - - EventLog = ActiveFilter->EventLogs[0]; + } + + EventLogFilter_AddRef(EventLogFilter); + + EventLog = EventLogFilter->EventLogs[0]; hEventLog = OpenEventLogW(EventLog->ComputerName, EventLog->LogName); + + EventLogFilter_Release(EventLogFilter); + if (!hEventLog) { ShowLastWin32Error(); return FALSE; } - if (!ClearEventLogW(hEventLog, sfn.lpstrFile)) - { + Success = ClearEventLogW(hEventLog, sfn.lpstrFile); + if (!Success) ShowLastWin32Error(); - CloseEventLog(hEventLog); - return FALSE; - } CloseEventLog(hEventLog); - - return TRUE; + return Success; } VOID -Refresh(VOID) -{ - /* Reenumerate the events through the active filter */ - EnumEvents(ActiveFilter); +Refresh(IN PEVENTLOGFILTER EventLogFilter) +{ + /* Bail out if there is no available filter */ + if (!EventLogFilter) + return; + + /* Reenumerate the events through the filter */ + EnumEvents(EventLogFilter); } @@ -2343,7 +2452,7 @@ { Entry = RemoveHeadList(&EventLogList); EventLog = (PEVENTLOG)CONTAINING_RECORD(Entry, EVENTLOG, ListEntry); - FreeEventLog(EventLog); + EventLog_Free(EventLog); } return; @@ -2359,7 +2468,7 @@ { Entry = RemoveHeadList(&EventLogFilterList); EventLogFilter = (PEVENTLOGFILTER)CONTAINING_RECORD(Entry, EVENTLOGFILTER, ListEntry); - FreeEventLogFilter(EventLogFilter); + EventLogFilter_Free(EventLogFilter); } ActiveFilter = NULL; @@ -2382,11 +2491,11 @@ { switch (uMsg) { - case PM_PROGRESS_DLG: + case LVM_PROGRESS: { /* TRUE: Create the dialog; FALSE: Destroy the dialog */ IsLoading = !!(BOOL)lParam; - break; + return IsLoading; } case WM_PAINT: @@ -2402,6 +2511,7 @@ COLORREF crTextOld, crTextBkOld; NONCLIENTMETRICSW ncm; HFONT hFont, hFontOld; + LPWSTR lpszString; nItemCount = ListView_GetItemCount(hWnd); if (!IsLoading && nItemCount > 0) @@ -2464,21 +2574,15 @@ FillRect(hDC, &rc, GetSysColorBrush(COLOR_WINDOW)); if (nItemCount <= 0) - { - DrawTextW(hDC, - szEmptyList, - -1, - &rc, - DT_CENTER | DT_WORDBREAK | DT_NOPREFIX | DT_NOCLIP); - } + lpszString = szEmptyList; else // if (IsLoading) - { - DrawTextW(hDC, - szLoadingWait, - -1, - &rc, - DT_CENTER | DT_WORDBREAK | DT_NOPREFIX | DT_NOCLIP); - } + lpszString = szLoadingWait; + + DrawTextW(hDC, + lpszString, + -1, + &rc, + DT_CENTER | DT_WORDBREAK | DT_NOPREFIX | DT_NOCLIP); SelectObject(hDC, hFontOld); if (hFont) @@ -2535,12 +2639,24 @@ (HMENU)100, // window ID hInstance, // instance NULL); // window data - nSplitPos = 250; GetClientRect(hwndMainWindow, &rcClient); GetWindowRect(hwndStatus, &rs); StatusHeight = rs.bottom - rs.top; + + /* Create a progress bar in the status bar (hidden by default) */ + StatusBar_GetItemRect(hwndStatus, 0, &rs); + hwndStatusProgress = CreateWindowExW(0, // no extended styles + PROGRESS_CLASSW, // status bar + L"", // no text + WS_CHILD | PBS_SMOOTH, // styles + rs.left, rs.top, rs.right-rs.left, rs.bottom-rs.top, // x, y, cx, cy + hwndStatus, // parent window + NULL, // window ID + hInstance, // instance + NULL); // window data + ProgressBar_SetStep(hwndStatusProgress, 1); /* Create the TreeView */ hwndTreeView = CreateWindowExW(WS_EX_CLIENTEDGE, @@ -2598,7 +2714,7 @@ NULL); /* Add the extended ListView styles */ - (void)ListView_SetExtendedListViewStyle(hwndListView, LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT |LVS_EX_LABELTIP); + ListView_SetExtendedListViewStyle(hwndListView, LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT |LVS_EX_LABELTIP); /* Create the ImageList */ hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), @@ -2614,7 +2730,7 @@ ImageList_AddIcon(hSmall, LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_AUDITFAILUREICON))); /* Assign the ImageList to the List View */ - (void)ListView_SetImageList(hwndListView, hSmall, LVSIL_SMALL); + ListView_SetImageList(hwndListView, hSmall, LVSIL_SMALL); /* Now set up the listview with its columns */ lvc.mask = LVCF_TEXT | LVCF_WIDTH; @@ -2624,7 +2740,7 @@ szTemp, ARRAYSIZE(szTemp)); lvc.pszText = szTemp; - (void)ListView_InsertColumn(hwndListView, 0, &lvc); + ListView_InsertColumn(hwndListView, 0, &lvc); lvc.cx = 70; LoadStringW(hInstance, @@ -2632,7 +2748,7 @@ szTemp, ARRAYSIZE(szTemp)); lvc.pszText = szTemp; - (void)ListView_InsertColumn(hwndListView, 1, &lvc); + ListView_InsertColumn(hwndListView, 1, &lvc); lvc.cx = 70; LoadStringW(hInstance, @@ -2640,7 +2756,7 @@ szTemp, ARRAYSIZE(szTemp)); lvc.pszText = szTemp; - (void)ListView_InsertColumn(hwndListView, 2, &lvc); + ListView_InsertColumn(hwndListView, 2, &lvc); lvc.cx = 150; LoadStringW(hInstance, @@ -2648,7 +2764,7 @@ szTemp, ARRAYSIZE(szTemp)); lvc.pszText = szTemp; - (void)ListView_InsertColumn(hwndListView, 3, &lvc); + ListView_InsertColumn(hwndListView, 3, &lvc); lvc.cx = 100; LoadStringW(hInstance, @@ -2656,7 +2772,7 @@ szTemp, ARRAYSIZE(szTemp)); lvc.pszText = szTemp; - (void)ListView_InsertColumn(hwndListView, 4, &lvc); + ListView_InsertColumn(hwndListView, 4, &lvc); lvc.cx = 60; LoadStringW(hInstance, @@ -2664,7 +2780,7 @@ szTemp, ARRAYSIZE(szTemp)); lvc.pszText = szTemp; - (void)ListView_InsertColumn(hwndListView, 5, &lvc); + ListView_InsertColumn(hwndListView, 5, &lvc); lvc.cx = 120; LoadStringW(hInstance, @@ -2672,7 +2788,7 @@ szTemp, ARRAYSIZE(szTemp)); lvc.pszText = szTemp; - (void)ListView_InsertColumn(hwndListView, 6, &lvc); + ListView_InsertColumn(hwndListView, 6, &lvc); lvc.cx = 100; LoadStringW(hInstance, @@ -2680,7 +2796,7 @@ szTemp, ARRAYSIZE(szTemp)); lvc.pszText = szTemp; - (void)ListView_InsertColumn(hwndListView, 7, &lvc); + ListView_InsertColumn(hwndListView, 7, &lvc); /* Subclass the ListView */ // orgListViewWndProc = SubclassWindow(hwndListView, ListViewWndProc); @@ -2708,7 +2824,7 @@ } VOID -CleanupInstance(HINSTANCE hInstance) +ExitInstance(HINSTANCE hInstance) { /* Restore the original ListView WndProc */ // SubclassWindow(hwndListView, orgListViewWndProc); @@ -2726,6 +2842,12 @@ // SendMessageW(hwndStatus, WM_SIZE, 0, 0); GetWindowRect(hwndStatus, &rs); StatusHeight = rs.bottom - rs.top; + + /* Move the progress bar */ + StatusBar_GetItemRect(hwndStatus, 0, &rs); + MoveWindow(hwndStatusProgress, + rs.left, rs.top, rs.right-rs.left, rs.bottom-rs.top, + IsWindowVisible(hwndStatusProgress) ? TRUE : FALSE); nSplitPos = min(max(nSplitPos, SPLIT_WIDTH/2), cx - SPLIT_WIDTH/2); @@ -2778,12 +2900,16 @@ case NM_DBLCLK: { LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE)lParam; - if (lpnmitem->iItem != -1) + PEVENTLOGFILTER EventLogFilter = GetSelectedFilter(NULL); + if (lpnmitem->iItem != -1 && EventLogFilter) { - DialogBoxW(hInst, - MAKEINTRESOURCEW(IDD_EVENTPROPERTIES), - hWnd, - EventDetails); + EventLogFilter_AddRef(EventLogFilter); + DialogBoxParamW(hInst, + MAKEINTRESOURCEW(IDD_EVENTPROPERTIES), + hWnd, + EventDetails, + (LPARAM)EventLogFilter); + EventLogFilter_Release(EventLogFilter); } break; } @@ -2842,9 +2968,31 @@ if (EventLogFilter) { - ActiveFilter = EventLogFilter; + /* + * If we have selected a filter, enable the menu commands; + * they will possibly be updated after events enumeration. + */ + EnableMenuItem(hMainMenu, IDM_SAVE_EVENTLOG, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(hMainMenu, IDM_CLOSE_EVENTLOG, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(hMainMenu, IDM_CLEAR_EVENTS, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(hMainMenu, IDM_RENAME_EVENTLOG, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(hMainMenu, IDM_EVENTLOG_SETTINGS, MF_BYCOMMAND | MF_ENABLED); + } + else + { + EnableMenuItem(hMainMenu, IDM_SAVE_EVENTLOG, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hMainMenu, IDM_CLOSE_EVENTLOG, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hMainMenu, IDM_CLEAR_EVENTS, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hMainMenu, IDM_RENAME_EVENTLOG, MF_BYCOMMAND | MF_GRAYED); + EnableMenuItem(hMainMenu, IDM_EVENTLOG_SETTINGS, MF_BYCOMMAND | MF_GRAYED); + } + + /* + * The enumeration thread that is triggered by EnumEvents + * will set a new value for the 'ActiveFilter'. + */ + if (EventLogFilter) EnumEvents(EventLogFilter); - } break; } @@ -2863,17 +3011,24 @@ break; case IDM_SAVE_EVENTLOG: - SaveEventLog(); + SaveEventLog(GetSelectedFilter(NULL)); break; case IDM_CLOSE_EVENTLOG: - CloseUserEventLog(); + { + HTREEITEM hti; + PEVENTLOGFILTER EventLogFilter = GetSelectedFilter(&hti); + CloseUserEventLog(EventLogFilter, hti); break; + } case IDM_CLEAR_EVENTS: - if (ClearEvents()) - Refresh(); + { + PEVENTLOGFILTER EventLogFilter = GetSelectedFilter(NULL); + if (EventLogFilter && ClearEvents(EventLogFilter)) + Refresh(EventLogFilter); break; + } case IDM_RENAME_EVENTLOG: if (GetFocus() == hwndTreeView) @@ -2882,31 +3037,37 @@ case IDM_EVENTLOG_SETTINGS: { + PEVENTLOGFILTER EventLogFilter = GetSelectedFilter(NULL); // TODO: Check the returned value? - EventLogProperties(hInst, hWnd); + if (EventLogFilter) + EventLogProperties(hInst, hWnd, EventLogFilter); break; } case IDM_LIST_NEWEST: + { + CheckMenuRadioItem(hMainMenu, IDM_LIST_NEWEST, IDM_LIST_OLDEST, IDM_LIST_NEWEST, MF_BYCOMMAND); if (!NewestEventsFirst) { NewestEventsFirst = TRUE; - CheckMenuRadioItem(hMainMenu, IDM_LIST_NEWEST, IDM_LIST_OLDEST, IDM_LIST_NEWEST, MF_BYCOMMAND); - Refresh(); + Refresh(GetSelectedFilter(NULL)); } break; + } case IDM_LIST_OLDEST: + { + CheckMenuRadioItem(hMainMenu, IDM_LIST_NEWEST, IDM_LIST_OLDEST, IDM_LIST_OLDEST, MF_BYCOMMAND); if (NewestEventsFirst) { NewestEventsFirst = FALSE; - CheckMenuRadioItem(hMainMenu, IDM_LIST_NEWEST, IDM_LIST_OLDEST, IDM_LIST_OLDEST, MF_BYCOMMAND); - Refresh(); + Refresh(GetSelectedFilter(NULL)); } break; + } case IDM_REFRESH: - Refresh(); + Refresh(GetSelectedFilter(NULL)); break; case IDM_ABOUT: @@ -3002,35 +3163,6 @@ break; } - case PM_PROGRESS_DLG: - { - /* TRUE: Create the dialog; FALSE: Destroy the dialog */ - BOOL Create = !!(BOOL)lParam; - if (Create) - { - if (!IsWindow(hProgressDlg)) - { - hProgressDlg = CreateDialogW(hInst, - MAKEINTRESOURCEW(IDD_PROGRESSBOX), - hwndMainWindow, - StatusMessageWindowProc); - if (hProgressDlg) - ShowWindow(hProgressDlg, SW_SHOW); - } - return (!!hProgressDlg); - } - else - { - if (IsWindow(hProgressDlg)) - { - // EndDialog(hProgressDlg, 0); - DestroyWindow(hProgressDlg); - hProgressDlg = NULL; - } - return TRUE; - } - } - default: Default: return DefWindowProcW(hWnd, uMsg, wParam, lParam); } @@ -3222,23 +3354,20 @@ INT_PTR CALLBACK EventLogPropProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - PEVENTLOGFILTER EventLogFilter; - - UNREFERENCED_PARAMETER(lParam); - - EventLogFilter = (PEVENTLOGFILTER)GetWindowLongPtrW(hDlg, DWLP_USER); + PEVENTLOG EventLog; + + EventLog = (PEVENTLOG)GetWindowLongPtrW(hDlg, DWLP_USER); switch (uMsg) { case WM_INITDIALOG: { - EventLogFilter = (PEVENTLOGFILTER)((LPPROPSHEETPAGE)lParam)->lParam; - SetWindowLongPtrW(hDlg, DWLP_USER, (LONG_PTR)EventLogFilter); + EventLog = (PEVENTLOG)((LPPROPSHEETPAGE)lParam)->lParam; + SetWindowLongPtrW(hDlg, DWLP_USER, (LONG_PTR)EventLog); + + InitPropertiesDlg(hDlg, EventLog); PropSheet_UnChanged(GetParent(hDlg), hDlg); - - InitPropertiesDlg(hDlg, EventLogFilter->EventLogs[0]); - return (INT_PTR)TRUE; } @@ -3294,35 +3423,25 @@ } INT_PTR -EventLogProperties(HINSTANCE hInstance, HWND hWndParent) -{ +EventLogProperties(HINSTANCE hInstance, HWND hWndParent, PEVENTLOGFILTER EventLogFilter) +{ + INT_PTR ret = 0; PROPSHEETHEADERW psh; PROPSHEETPAGEW psp[1]; // 2 - - PEVENTLOGFILTER EventLogFilter = NULL; - - TVITEMEXW tvItemEx; - HTREEITEM hti; - - /* Get index of selected item */ - hti = TreeView_GetSelection(hwndTreeView); - if (hti != NULL) - { - tvItemEx.mask = TVIF_PARAM; - tvItemEx.hItem = hti; - - TreeView_GetItem(hwndTreeView, &tvItemEx); - EventLogFilter = (PEVENTLOGFILTER)tvItemEx.lParam; - } /* * Bail out if there is no available filter, or if the filter * contains more than one log. */ - if (!EventLogFilter || EventLogFilter->NumOfEventLogs > 1 || + if (!EventLogFilter) + return 0; + + EventLogFilter_AddRef(EventLogFilter); + + if (EventLogFilter->NumOfEventLogs > 1 || EventLogFilter->EventLogs[0] == NULL) { - return 0; + goto Quit; } /* Header */ @@ -3343,7 +3462,7 @@ psp[0].hInstance = hInstance; psp[0].pszTemplate = MAKEINTRESOURCEW(IDD_LOGPROPERTIES_GENERAL); psp[0].pfnDlgProc = EventLogPropProc; - psp[0].lParam = (LPARAM)EventLogFilter; + psp[0].lParam = (LPARAM)EventLogFilter->EventLogs[0]; #if 0 /* TODO: Log sources page */ @@ -3352,17 +3471,21 @@ psp[1].hInstance = hInstance; psp[1].pszTemplate = MAKEINTRESOURCEW(IDD_GENERAL_PAGE); psp[1].pfnDlgProc = GeneralPageWndProc; - psp[0].lParam = (LPARAM)EventLogFilter; + psp[0].lParam = (LPARAM)EventLogFilter->EventLogs[0]; #endif /* Create the property sheet */ - return PropertySheetW(&psh); + ret = PropertySheetW(&psh); + +Quit: + EventLogFilter_Release(EventLogFilter); + return ret; } VOID -DisplayEvent(HWND hDlg) +DisplayEvent(HWND hDlg, PEVENTLOGFILTER EventLogFilter) { WCHAR szEventType[MAX_PATH]; WCHAR szTime[MAX_PATH]; @@ -3393,7 +3516,7 @@ li.iItem = iIndex; li.iSubItem = 0; - (void)ListView_GetItem(hwndListView, &li); + ListView_GetItem(hwndListView, &li); pevlr = (PEVENTLOGRECORD)li.lParam; @@ -3419,7 +3542,8 @@ EnableDlgItem(hDlg, IDC_BYTESRADIO, bEventData); EnableDlgItem(hDlg, IDC_WORDRADIO, bEventData); - GetEventMessage(ActiveFilter->EventLogs[0]->LogName, szSource, pevlr, szEventText); + // FIXME: At the moment we support only one event log in the filter + GetEventMessage(EventLogFilter->EventLogs[0]->LogName, szSource, pevlr, szEventText); SetDlgItemTextW(hDlg, IDC_EVENTTEXTEDIT, szEventText); } @@ -3528,7 +3652,7 @@ li.iItem = iIndex; li.iSubItem = 0; - (void)ListView_GetItem(hwndListView, &li); + ListView_GetItem(hwndListView, &li); pevlr = (PEVENTLOGRECORD)li.lParam; if (pevlr->DataLength == 0) @@ -3648,25 +3772,6 @@ } static -INT_PTR CALLBACK -StatusMessageWindowProc(IN HWND hwndDlg, - IN UINT uMsg, - IN WPARAM wParam, - IN LPARAM lParam) -{ - UNREFERENCED_PARAMETER(hwndDlg); - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - - switch (uMsg) - { - case WM_INITDIALOG: - return TRUE; - } - return FALSE; -} - -static VOID InitDetailsDlg(HWND hDlg, PDETAILDATA pData) { @@ -3707,8 +3812,6 @@ { PDETAILDATA pData; - UNREFERENCED_PARAMETER(lParam); - pData = (PDETAILDATA)GetWindowLongPtrW(hDlg, DWLP_USER); switch (uMsg) @@ -3719,13 +3822,14 @@ { SetWindowLongPtrW(hDlg, DWLP_USER, (LONG_PTR)pData); + pData->EventLogFilter = (PEVENTLOGFILTER)lParam; pData->bDisplayWords = FALSE; pData->hMonospaceFont = CreateMonospaceFont(); InitDetailsDlg(hDlg, pData); /* Show event info on dialog box */ - DisplayEvent(hDlg); + DisplayEvent(hDlg, pData->EventLogFilter); DisplayEventData(hDlg, pData->bDisplayWords); } return (INT_PTR)TRUE; @@ -3750,7 +3854,7 @@ /* Show event info on dialog box */ if (pData) { - DisplayEvent(hDlg); + DisplayEvent(hDlg, pData->EventLogFilter); DisplayEventData(hDlg, pData->bDisplayWords); } return (INT_PTR)TRUE; @@ -3761,7 +3865,7 @@ /* Show event info on dialog box */ if (pData) { - DisplayEvent(hDlg); + DisplayEvent(hDlg, pData->EventLogFilter); DisplayEventData(hDlg, pData->bDisplayWords); } return (INT_PTR)TRUE; Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/bg-BG.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/bg-BG.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/bg-BG.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -36,14 +36,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "ÐоÑакайÑе..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "ÐаÑеждане на ÑÑбиÑиÑÑа. ÐоÑакайÑе...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/cs-CZ.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/cs-CZ.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/cs-CZ.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -36,14 +36,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Äekejte..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "NaÄÃtám protokol událostÃ. ProsÃm Äekejte...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/de-DE.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/de-DE.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/de-DE.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Bitte warten..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Ereignis-Protokolle werden geladen. Bitte warten...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/el-GR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/el-GR.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/el-GR.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "ΠεÏιμÎνεÏε..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "ÎίνεÏαι ÏÏÏÏÏÏη ÏÏν Logs ÏÏ Î¼Î²Î¬Î½ÏÏν. ΠαÏÎ±ÎºÎ±Î»Ï ÏεÏιμÎνεÏε...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/en-US.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/en-US.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/en-US.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -44,14 +44,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Wait..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Loading Event Logs. Please wait...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/es-ES.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/es-ES.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/es-ES.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Espere..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Recuperando eventos. Espere un momento...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/fr-FR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/fr-FR.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/fr-FR.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Patientez..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Chargement des journaux d'événements. Veuillez patienter...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/he-IL.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/he-IL.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/he-IL.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "× × ×××ת××..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "×××¢× ×××× × ××ר××¢××, × × ×××ת××...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/it-IT.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/it-IT.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/it-IT.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Attendere..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Caricamento eventi in corso. Attendere...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/ja-JP.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/ja-JP.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/ja-JP.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "ãå¾ ã¡ãã ãã..." -FONT 9, "MS UI Gothic", 0, 0, 0x0 -BEGIN - CTEXT "ã¤ãã³ã ãã°ãèªã¿è¾¼ãã§ãã¾ãã ãå¾ ã¡ãã ãã...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/ko-KR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/ko-KR.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/ko-KR.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "기ë¤ë¦¬ì¸ì..." -FONT 9, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "ì´ë²¤í¸ ë¡ê·¸ ë¡ë©ì¤. 기ë¤ë ¤ì£¼ì¸ì...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/no-NO.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/no-NO.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/no-NO.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -36,14 +36,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Vent..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Laster Hendelseliste. Venligst vent...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/pl-PL.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/pl-PL.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/pl-PL.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -40,14 +40,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Czekaj..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Åadowanie logów zdarzeÅ. ProszÄ czekaÄ...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/pt-BR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/pt-BR.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/pt-BR.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Aguarde..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Carregando Registros de Eventos. Por favor aguarde...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/ro-RO.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/ro-RO.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/ro-RO.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -41,14 +41,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "AÈteptaÈiâ¦" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Se încarcÄ jurnalul de evenimenteleâ¦", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 @@ -134,7 +126,7 @@ IDS_APP_TITLE "Observator de evenimente" IDS_APP_TITLE_EX "%s - %s autentificat pe \\\\" IDS_STATUS_MSG "%s are %lu eveniment(e)" - IDS_LOADING_WAIT "Se încarcÄ jurnalul de evenimenteleâ¦" + IDS_LOADING_WAIT "Se încarcÄ jurnalul de evenimentele. AÈteptaÈiâ¦" IDS_NO_ITEMS "There are no items to show in this view." // "No events in this log." IDS_EVENTLOG_SYSTEM "System Logs" IDS_EVENTLOG_APP "Application Logs" Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/ru-RU.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/ru-RU.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/ru-RU.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "ÐодождиÑе..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "ÐÐ´ÐµÑ Ð·Ð°Ð³ÑÑзка. ÐодождиÑе...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/sk-SK.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/sk-SK.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/sk-SK.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -41,14 +41,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "PoÄkajte..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Nahrávam záznamy s udalosÅ¥ami. PoÄkajte, prosÃm...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/sq-AL.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/sq-AL.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/sq-AL.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -44,14 +44,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Prit..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Ngarkim loget e ngjarjeve. Ju lutem prisni...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/sv-SE.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/sv-SE.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/sv-SE.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Vänta..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Laddar in Händelseloggen. Vänligen vänta...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/tr-TR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/tr-TR.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/tr-TR.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -44,14 +44,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "Yükleniyor..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "Olay kayıtları yükleniyor. Lütfen bekleyiniz...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/uk-UA.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/uk-UA.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/uk-UA.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -16,7 +16,7 @@ MENUITEM SEPARATOR MENUITEM "Ð&Ð¸Ñ Ñд", IDM_EXIT END - POPUP "&ÐиглÑд" + POPUP "&ÐиглÑд" BEGIN MENUITEM "&Newest first", IDM_LIST_NEWEST MENUITEM "&Oldest first", IDM_LIST_OLDEST @@ -24,7 +24,7 @@ MENUITEM "&ÐновиÑи\tF5", IDM_REFRESH END MENUITEM "&ÐлаÑÑивоÑÑÑ", IDM_OPTIONS - POPUP "&Ðопомога" + POPUP "&Ðопомога" BEGIN MENUITEM "Ð&опомога", IDM_HELP MENUITEM SEPARATOR @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "ÐаÑекайÑе..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "ÐаванÑÐ°Ð¶ÐµÐ½Ð½Ñ ÐвÑÑÑ Ð¿Ð¾Ð´Ñй. ÐÑÐ´Ñ Ð»Ð°Ñка, заÑекайÑе...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/zh-CN.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/zh-CN.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/zh-CN.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "请ç¨å..." -FONT 9, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "æ£å¨è½½å ¥æ¥å¿ã请ç¨å...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/lang/zh-TW.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/lang/zh-TW.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/lang/zh-TW.rc [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -38,14 +38,6 @@ "/", IDM_ABOUT, ASCII, ALT VK_F2, IDM_RENAME_EVENTLOG, VIRTKEY VK_F5, IDM_REFRESH, VIRTKEY -END - -IDD_PROGRESSBOX DIALOGEX 0, 0, 230, 40 -STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER -CAPTION "è«ç¨å..." -FONT 9, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "æ£å¨è¼å ¥æ¥èªã è«ç¨å...", IDC_STATIC, 0, 15, 230, 8, SS_NOPREFIX END IDD_EVENTPROPERTIES DIALOGEX 0, 0, 266, 251 Modified: trunk/reactos/base/applications/mscutils/eventvwr/resource.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/eventvwr/resource.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/eventvwr/resource.h [iso-8859-1] Sun Jul 24 15:24:50 2016 @@ -20,9 +20,8 @@ /* Dialog IDs */ -#define IDD_PROGRESSBOX 101 -#define IDD_EVENTPROPERTIES 102 -#define IDD_LOGPROPERTIES_GENERAL 103 +#define IDD_EVENTPROPERTIES 101 +#define IDD_LOGPROPERTIES_GENERAL 102 /* Control IDs */
8 years, 5 months
1
0
0
0
[apriyadarshi] 71988: Fixed SrbExtension == NULL bug! :D
by apriyadarshi@svn.reactos.org
Author: apriyadarshi Date: Sun Jul 24 12:41:07 2016 New Revision: 71988 URL:
http://svn.reactos.org/svn/reactos?rev=71988&view=rev
Log: Fixed SrbExtension == NULL bug! :D Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
============================================================================== --- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] (original) +++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] Sun Jul 24 12:41:07 2016 @@ -420,6 +420,7 @@ StorPortAcquireSpinLock(AdapterExtension, InterruptLock, NULL, &lockhandle); Srb = RemoveQueue(&PortExtension->CompletionQueue); + StorPortReleaseSpinLock(AdapterExtension, &lockhandle); NT_ASSERT(Srb != NULL); @@ -427,22 +428,21 @@ { Srb->SrbStatus = SRB_STATUS_SUCCESS; } + else + { + return; + } SrbExtension = GetSrbExtension(Srb); + CompletionRoutine = SrbExtension->CompletionRoutine; - - if (CompletionRoutine != NULL) - { - // now it's completion routine responsibility to set SrbStatus - CompletionRoutine(PortExtension, Srb); - } - else - { - Srb->SrbStatus = SRB_STATUS_SUCCESS; - //StorPortNotification(RequestComplete, AdapterExtension, Srb); - } - - StorPortReleaseSpinLock(AdapterExtension, &lockhandle); + NT_ASSERT(CompletionRoutine != NULL); + + // now it's completion routine responsibility to set SrbStatus + CompletionRoutine(PortExtension, Srb); + + StorPortNotification(RequestComplete, AdapterExtension, Srb); + return; }// -- AhciCommandCompletionDpcRoutine(); @@ -537,6 +537,7 @@ { ULONG NCS, i; PSCSI_REQUEST_BLOCK Srb; + PAHCI_SRB_EXTENSION SrbExtension; PAHCI_ADAPTER_EXTENSION AdapterExtension; AhciDebugPrint("AhciCompleteIssuedSrb()\n"); @@ -553,10 +554,25 @@ if (((1 << i) & CommandsToComplete) != 0) { Srb = PortExtension->Slot[i]; - NT_ASSERT(Srb != NULL); - - AddQueue(&PortExtension->CompletionQueue, Srb); - StorPortIssueDpc(AdapterExtension, &PortExtension->CommandCompletion, PortExtension, Srb); + + if (Srb == NULL) + { + continue; + } + + SrbExtension = GetSrbExtension(Srb); + NT_ASSERT(SrbExtension != NULL); + + if (SrbExtension->CompletionRoutine != NULL) + { + AddQueue(&PortExtension->CompletionQueue, Srb); + StorPortIssueDpc(AdapterExtension, &PortExtension->CommandCompletion, PortExtension, Srb); + } + else + { + Srb->SrbStatus = SRB_STATUS_SUCCESS; + StorPortNotification(RequestComplete, AdapterExtension, Srb); + } } } @@ -748,7 +764,6 @@ return TRUE; } - AhciDebugPrint("\tPathId: %d Function: %x\n", Srb->PathId, Srb->Function); switch(Srb->Function) { case SRB_FUNCTION_PNP: @@ -844,7 +859,10 @@ break; } - StorPortNotification(RequestComplete, AdapterExtension, Srb); + if (Srb->SrbStatus != SRB_STATUS_PENDING) + { + StorPortNotification(RequestComplete, AdapterExtension, Srb); + } return TRUE; }// -- AhciHwStartIo(); @@ -1054,7 +1072,6 @@ ConfigInfo->NumberOfPhysicalBreaks = 0x21; ConfigInfo->MaximumNumberOfLogicalUnits = 1; ConfigInfo->NumberOfBuses = MAXIMUM_AHCI_PORT_COUNT; - ConfigInfo->MapBuffers = STOR_MAP_NON_READ_WRITE_BUFFERS; ConfigInfo->MaximumTransferLength = MAXIMUM_TRANSFER_LENGTH; ConfigInfo->SynchronizationModel = StorSynchronizeFullDuplex; @@ -1396,7 +1413,6 @@ ) { AHCI_PORT_CMD cmd; - ULONG sact, ci; ULONG QueueSlots, slotToActivate, tmp; PAHCI_ADAPTER_EXTENSION AdapterExtension; @@ -1418,9 +1434,6 @@ { return; } - - sact = StorPortReadRegisterUlong(AdapterExtension, &PortExtension->Port->SACT); - ci = StorPortReadRegisterUlong(AdapterExtension, &PortExtension->Port->CI); // get the lowest set bit tmp = QueueSlots & (QueueSlots - 1); @@ -1703,6 +1716,8 @@ DataTransferLength = Srb->DataTransferLength; BytesPerSector = PortExtension->DeviceParams.BytesPerLogicalSector; + NT_ASSERT(BytesPerSector > 0); + ROUND_UP(DataTransferLength, BytesPerSector); SectorCount = DataTransferLength / BytesPerSector; @@ -1712,7 +1727,7 @@ NT_ASSERT(SectorCount > 0); SrbExtension->AtaFunction = ATA_FUNCTION_ATA_READ; - SrbExtension->Flags = ATA_FLAGS_USE_DMA; + SrbExtension->Flags |= ATA_FLAGS_USE_DMA; SrbExtension->CompletionRoutine = NULL; if (IsReading)
8 years, 5 months
1
0
0
0
[apriyadarshi] 71987: Completed SCSIOP_READ_CAPACITY, SCSIOP_REPORT_LUNS, SCSIOP_READ Updated INQUIRY Fields Code Fixes Stable, Tested, AHCI-Detection and Read working
by apriyadarshi@svn.reactos.org
Author: apriyadarshi Date: Sat Jul 23 22:53:15 2016 New Revision: 71987 URL:
http://svn.reactos.org/svn/reactos?rev=71987&view=rev
Log: Completed SCSIOP_READ_CAPACITY, SCSIOP_REPORT_LUNS, SCSIOP_READ Updated INQUIRY Fields Code Fixes Stable, Tested, AHCI-Detection and Read working Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
============================================================================== --- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] (original) +++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] Sat Jul 23 22:53:15 2016 @@ -29,7 +29,7 @@ PAHCI_ADAPTER_EXTENSION adapterExtension; STOR_PHYSICAL_ADDRESS commandListPhysical, receivedFISPhysical; - DebugPrint("AhciPortInitialize()\n"); + AhciDebugPrint("AhciPortInitialize()\n"); adapterExtension = PortExtension->AdapterExtension; abar = adapterExtension->ABAR_Address; @@ -47,7 +47,7 @@ if ((mappedLength == 0) || ((commandListPhysical.LowPart % 1024) != 0)) { - DebugPrint("\tcommandListPhysical mappedLength:%d\n", mappedLength); + AhciDebugPrint("\tcommandListPhysical mappedLength:%d\n", mappedLength); return FALSE; } @@ -58,7 +58,7 @@ if ((mappedLength == 0) || ((receivedFISPhysical.LowPart % 256) != 0)) { - DebugPrint("\treceivedFISPhysical mappedLength:%d\n", mappedLength); + AhciDebugPrint("\treceivedFISPhysical mappedLength:%d\n", mappedLength); return FALSE; } @@ -76,7 +76,7 @@ cmd.Status = StorPortReadRegisterUlong(adapterExtension, &PortExtension->Port->CMD); if ((cmd.FR != 0) || (cmd.CR != 0) || (cmd.FRE != 0) || (cmd.ST != 0)) { - DebugPrint("\tPort is not idle: %x\n", cmd); + AhciDebugPrint("\tPort is not idle: %x\n", cmd); } // 10.1.2 For each implemented port, system software shall allocate memory for and program: @@ -134,7 +134,7 @@ ULONG portCount, portImplemented, nonCachedExtensionSize; PAHCI_PORT_EXTENSION PortExtension; - DebugPrint("AhciAllocateResourceForAdapter()\n"); + AhciDebugPrint("AhciAllocateResourceForAdapter()\n"); NCS = AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP); AlignedNCS = ROUND_UP(NCS, 8); @@ -149,7 +149,7 @@ break; portCount = index + 1; - DebugPrint("\tPort Count: %d\n", portCount); + AhciDebugPrint("\tPort Count: %d\n", portCount); AdapterExtension->PortCount = portCount; nonCachedExtensionSize = sizeof(AHCI_COMMAND_HEADER) * AlignedNCS + //should be 1K aligned @@ -165,7 +165,7 @@ if (AdapterExtension->NonCachedExtension == NULL) { - DebugPrint("\tadapterExtension->NonCachedExtension == NULL\n"); + AhciDebugPrint("\tadapterExtension->NonCachedExtension == NULL\n"); return FALSE; } @@ -219,7 +219,7 @@ AHCI_SERIAL_ATA_CONTROL sctl; PAHCI_ADAPTER_EXTENSION AdapterExtension; - DebugPrint("AhciStartPort()\n"); + AhciDebugPrint("AhciStartPort()\n"); AdapterExtension = PortExtension->AdapterExtension; cmd.Status = StorPortReadRegisterUlong(AdapterExtension, &PortExtension->Port->CMD); @@ -236,7 +236,7 @@ if (((cmd.FR == 1) && (cmd.FRE == 0)) || ((cmd.CR == 1) && (cmd.ST == 0))) { - DebugPrint("\tCOMRESET\n"); + AhciDebugPrint("\tCOMRESET\n"); // perform COMRESET // section 10.4.2 @@ -313,7 +313,7 @@ if ((tfd.STS.BSY) || (tfd.STS.DRQ)) { - DebugPrint("\tUnhandled Case BSY-DRQ\n"); + AhciDebugPrint("\tUnhandled Case BSY-DRQ\n"); } // clear pending interrupts @@ -375,7 +375,7 @@ if (cmd.ST != 1) { - DebugPrint("\tFailed to start Port\n"); + AhciDebugPrint("\tFailed to start Port\n"); return FALSE; } @@ -383,7 +383,7 @@ } default: // unhandled case - DebugPrint("\tDET == %x Unsupported\n", ssts.DET); + AhciDebugPrint("\tDET == %x Unsupported\n", ssts.DET); return FALSE; } @@ -409,16 +409,14 @@ ) { PSCSI_REQUEST_BLOCK Srb; - STOR_LOCK_HANDLE lockhandle; PAHCI_SRB_EXTENSION SrbExtension; + STOR_LOCK_HANDLE lockhandle = {0}; PAHCI_COMPLETION_ROUTINE CompletionRoutine; UNREFERENCED_PARAMETER(Dpc); UNREFERENCED_PARAMETER(SystemArgument2); - DebugPrint("AhciCommandCompletionDpcRoutine()\n"); - - AhciZeroMemory(&lockhandle, sizeof(lockhandle)); + AhciDebugPrint("AhciCommandCompletionDpcRoutine()\n"); StorPortAcquireSpinLock(AdapterExtension, InterruptLock, NULL, &lockhandle); Srb = RemoveQueue(&PortExtension->CompletionQueue); @@ -441,7 +439,7 @@ else { Srb->SrbStatus = SRB_STATUS_SUCCESS; - StorPortNotification(RequestComplete, AdapterExtension, Srb); + //StorPortNotification(RequestComplete, AdapterExtension, Srb); } StorPortReleaseSpinLock(AdapterExtension, &lockhandle); @@ -467,7 +465,7 @@ ULONG index; PAHCI_PORT_EXTENSION PortExtension; - DebugPrint("AhciHwPassiveInitialize()\n"); + AhciDebugPrint("AhciHwPassiveInitialize()\n"); for (index = 0; index < AdapterExtension->PortCount; index++) { @@ -499,9 +497,8 @@ ) { AHCI_GHC ghc; - MESSAGE_INTERRUPT_INFORMATION messageInfo; - - DebugPrint("AhciHwInitialize()\n"); + + AhciDebugPrint("AhciHwInitialize()\n"); AdapterExtension->StateFlags.MessagePerPort = FALSE; @@ -515,7 +512,7 @@ if (ghc.MRSM == 0) { AdapterExtension->StateFlags.MessagePerPort = TRUE; - DebugPrint("\tMultiple MSI based message not supported\n"); + AhciDebugPrint("\tMultiple MSI based message not supported\n"); } StorPortEnablePassiveInitialization(AdapterExtension, AhciHwPassiveInitialize); @@ -542,11 +539,11 @@ PSCSI_REQUEST_BLOCK Srb; PAHCI_ADAPTER_EXTENSION AdapterExtension; - DebugPrint("AhciCompleteIssuedSrb()\n"); + AhciDebugPrint("AhciCompleteIssuedSrb()\n"); NT_ASSERT(CommandsToComplete != 0); - DebugPrint("\tCompleted Commands: %d\n", CommandsToComplete); + AhciDebugPrint("\tCompleted Commands: %d\n", CommandsToComplete); AdapterExtension = PortExtension->AdapterExtension; NCS = AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP); @@ -585,8 +582,8 @@ AHCI_INTERRUPT_STATUS PxISMasked; PAHCI_ADAPTER_EXTENSION AdapterExtension; - DebugPrint("AhciInterruptHandler()\n"); - DebugPrint("\tPort Number: %d\n", PortExtension->PortNumber); + AhciDebugPrint("AhciInterruptHandler()\n"); + AhciDebugPrint("\tPort Number: %d\n", PortExtension->PortNumber); AdapterExtension = PortExtension->AdapterExtension; NT_ASSERT(IsPortValid(AdapterExtension, PortExtension->PortNumber)); @@ -620,7 +617,7 @@ // software should perform the appropriate error recovery actions based on whether // non-queued commands were being issued or native command queuing commands were being issued. - DebugPrint("\tFatal Error: %x\n", PxIS.Status); + AhciDebugPrint("\tFatal Error: %x\n", PxIS.Status); } // Normal Command Completion @@ -719,7 +716,7 @@ return TRUE; } - DebugPrint("\tSomething went wrong"); + AhciDebugPrint("\tSomething went wrong"); return FALSE; }// -- AhciHwInterrupt(); @@ -738,111 +735,116 @@ */ BOOLEAN AhciHwStartIo ( - __in PVOID AdapterExtension, + __in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb ) { - UCHAR function, pathId; - PAHCI_ADAPTER_EXTENSION adapterExtension; - - DebugPrint("AhciHwStartIo()\n"); - - pathId = Srb->PathId; - function = Srb->Function; - adapterExtension = AdapterExtension; - - DebugPrint("\tFunction: %x\n", function); - - if (!IsPortValid(adapterExtension, pathId)) + AhciDebugPrint("AhciHwStartIo()\n"); + + if (!IsPortValid(AdapterExtension, Srb->PathId)) { Srb->SrbStatus = SRB_STATUS_NO_DEVICE; - StorPortNotification(RequestComplete, adapterExtension, Srb); + StorPortNotification(RequestComplete, AdapterExtension, Srb); return TRUE; } - //
https://msdn.microsoft.com/windows/hardware/drivers/storage/handling-srb-fu…
- // If the function member of an SRB is set to SRB_FUNCTION_PNP, - // the SRB is a structure of type SCSI_PNP_REQUEST_BLOCK. - if (function == SRB_FUNCTION_PNP) - { - PSCSI_PNP_REQUEST_BLOCK pnpRequest; - - pnpRequest = (PSCSI_PNP_REQUEST_BLOCK)Srb; - if ((pnpRequest->SrbPnPFlags & SRB_PNP_FLAGS_ADAPTER_REQUEST) != 0) - { - if ((pnpRequest->PnPAction == StorRemoveDevice) || - (pnpRequest->PnPAction == StorSurpriseRemoval)) + AhciDebugPrint("\tPathId: %d Function: %x\n", Srb->PathId, Srb->Function); + switch(Srb->Function) + { + case SRB_FUNCTION_PNP: { - Srb->SrbStatus = SRB_STATUS_SUCCESS; - adapterExtension->StateFlags.Removed = 1; - DebugPrint("\tAdapter removed\n"); + //
https://msdn.microsoft.com/windows/hardware/drivers/storage/handling-srb-fu…
+ // If the function member of an SRB is set to SRB_FUNCTION_PNP, + // the SRB is a structure of type SCSI_PNP_REQUEST_BLOCK. + + PSCSI_PNP_REQUEST_BLOCK pnpRequest; + pnpRequest = (PSCSI_PNP_REQUEST_BLOCK)Srb; + if ((pnpRequest->SrbPnPFlags & SRB_PNP_FLAGS_ADAPTER_REQUEST) != 0) + { + switch(pnpRequest->PnPAction) + { + case StorRemoveDevice: + case StorSurpriseRemoval: + { + Srb->SrbStatus = SRB_STATUS_SUCCESS; + AdapterExtension->StateFlags.Removed = 1; + AhciDebugPrint("\tAdapter removed\n"); + } + break; + case StorStopDevice: + { + Srb->SrbStatus = SRB_STATUS_SUCCESS; + AhciDebugPrint("\tRequested to Stop the adapter\n"); + } + break; + default: + Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST; + break; + } + } + else + { + Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST; + } } - else if (pnpRequest->PnPAction == StorStopDevice) + break; + case SRB_FUNCTION_EXECUTE_SCSI: { - Srb->SrbStatus = SRB_STATUS_SUCCESS; - DebugPrint("\tRequested to Stop the adapter\n"); + //
https://msdn.microsoft.com/en-us/windows/hardware/drivers/storage/handling-…
+ // On receipt of an SRB_FUNCTION_EXECUTE_SCSI request, a miniport driver's HwScsiStartIo + // routine does the following: + // + // - Gets and/or sets up whatever context the miniport driver maintains in its device, + // logical unit, and/or SRB extensions + // For example, a miniport driver might set up a logical unit extension with pointers + // to the SRB itself and the SRB DataBuffer pointer, the SRB DataTransferLength value, + // and a driver-defined value (or CDB SCSIOP_XXX value) indicating the operation to be + // carried out on the HBA. + // + // - Calls an internal routine to program the HBA, as partially directed by the SrbFlags, + // for the requested operation + // For a device I/O operation, such an internal routine generally selects the target device + // and sends the CDB over the bus to the target logical unit. + PCDB cdb = (PCDB)&Srb->Cdb; + if (Srb->CdbLength == 0) + { + AhciDebugPrint("\tOperationCode: %d\n", cdb->CDB10.OperationCode); + Srb->SrbStatus = SRB_STATUS_BAD_FUNCTION; + break; + } + + NT_ASSERT(cdb != NULL); + + switch(cdb->CDB10.OperationCode) + { + case SCSIOP_INQUIRY: + Srb->SrbStatus = DeviceInquiryRequest(AdapterExtension, Srb, cdb); + break; + case SCSIOP_REPORT_LUNS: + Srb->SrbStatus = DeviceReportLuns(AdapterExtension, Srb, cdb); + break; + case SCSIOP_READ_CAPACITY: + case SCSIOP_READ_CAPACITY16: + Srb->SrbStatus = DeviceRequestCapacity(AdapterExtension, Srb, cdb); + break; + case SCSIOP_READ: + //case SCSIOP_WRITE: + Srb->SrbStatus = DeviceRequestReadWrite(AdapterExtension, Srb, cdb); + break; + default: + AhciDebugPrint("\tOperationCode: %d\n", cdb->CDB10.OperationCode); + Srb->SrbStatus = SRB_STATUS_BAD_FUNCTION; + break; + } } - else - { - Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST; - } - - StorPortNotification(RequestComplete, adapterExtension, Srb); - return TRUE; - } - } - - if (function == SRB_FUNCTION_EXECUTE_SCSI) - { - DebugPrint("\tSRB_FUNCTION_EXECUTE_SCSI\n"); - //
https://msdn.microsoft.com/en-us/windows/hardware/drivers/storage/handling-…
- // On receipt of an SRB_FUNCTION_EXECUTE_SCSI request, a miniport driver's HwScsiStartIo - // routine does the following: - // - // - Gets and/or sets up whatever context the miniport driver maintains in its device, - // logical unit, and/or SRB extensions - // For example, a miniport driver might set up a logical unit extension with pointers - // to the SRB itself and the SRB DataBuffer pointer, the SRB DataTransferLength value, - // and a driver-defined value (or CDB SCSIOP_XXX value) indicating the operation to be - // carried out on the HBA. - // - // - Calls an internal routine to program the HBA, as partially directed by the SrbFlags, - // for the requested operation - // For a device I/O operation, such an internal routine generally selects the target device - // and sends the CDB over the bus to the target logical unit. - if (Srb->CdbLength > 0) - { - PCDB cdb = (PCDB)&Srb->Cdb; - NT_ASSERT(cdb != NULL); - - switch(cdb->CDB10.OperationCode) - { - case SCSIOP_INQUIRY: - Srb->SrbStatus = DeviceInquiryRequest(adapterExtension, Srb, cdb, TRUE); - break; - case SCSIOP_REPORT_LUNS: - Srb->SrbStatus = DeviceInquiryRequest(adapterExtension, Srb, cdb, FALSE); - break; - default: - { - DebugPrint("\tOperationCode: %d\n", cdb->CDB10.OperationCode); - Srb->SrbStatus = SRB_STATUS_NO_DEVICE; - } - break; - } - } - else - { - Srb->SrbStatus = SRB_STATUS_BAD_FUNCTION; - } - - StorPortNotification(RequestComplete, adapterExtension, Srb); - return TRUE; - } - - DebugPrint("\tUnknown function code recieved: %x\n", function); - Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST; - StorPortNotification(RequestComplete, adapterExtension, Srb); + break; + default: + AhciDebugPrint("\tUnknown function code recieved: %x\n", Srb->Function); + Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST; + break; + } + + StorPortNotification(RequestComplete, AdapterExtension, Srb); return TRUE; }// -- AhciHwStartIo(); @@ -864,17 +866,15 @@ __in ULONG PathId ) { - STOR_LOCK_HANDLE lockhandle; + STOR_LOCK_HANDLE lockhandle = {0}; PAHCI_ADAPTER_EXTENSION adapterExtension; - DebugPrint("AhciHwResetBus()\n"); + AhciDebugPrint("AhciHwResetBus()\n"); adapterExtension = AdapterExtension; if (IsPortValid(AdapterExtension, PathId)) { - AhciZeroMemory(&lockhandle, sizeof(lockhandle)); - // Acquire Lock StorPortAcquireSpinLock(AdapterExtension, InterruptLock, NULL, &lockhandle); @@ -938,7 +938,7 @@ PPCI_COMMON_CONFIG pciConfigData; PAHCI_ADAPTER_EXTENSION adapterExtension; - DebugPrint("AhciHwFindAdapter()\n"); + AhciDebugPrint("AhciHwFindAdapter()\n"); UNREFERENCED_PARAMETER(HwContext); UNREFERENCED_PARAMETER(BusInformation); @@ -960,18 +960,18 @@ if (pci_cfg_len != sizeof(PCI_COMMON_CONFIG)) { - DebugPrint("\tpci_cfg_len != %d :: %d", sizeof(PCI_COMMON_CONFIG), pci_cfg_len); + AhciDebugPrint("\tpci_cfg_len != %d :: %d", sizeof(PCI_COMMON_CONFIG), pci_cfg_len); return SP_RETURN_ERROR;//Not a valid device at the given bus number } - pciConfigData = pci_cfg_buf; + pciConfigData = (PPCI_COMMON_CONFIG)pci_cfg_buf; adapterExtension->VendorID = pciConfigData->VendorID; adapterExtension->DeviceID = pciConfigData->DeviceID; adapterExtension->RevisionID = pciConfigData->RevisionID; // The last PCI base address register (BAR[5], header offset 0x24) points to the AHCI base memory, itâs called ABAR (AHCI Base Memory Register). adapterExtension->AhciBaseAddress = pciConfigData->u.type0.BaseAddresses[5] & (0xFFFFFFF0); - DebugPrint("\tVendorID:%d DeviceID:%d RevisionID:%d\n", adapterExtension->VendorID, + AhciDebugPrint("\tVendorID:%d DeviceID:%d RevisionID:%d\n", adapterExtension->VendorID, adapterExtension->DeviceID, adapterExtension->RevisionID); @@ -997,7 +997,7 @@ if (abar == NULL) { - DebugPrint("\tabar == NULL\n"); + AhciDebugPrint("\tabar == NULL\n"); return SP_RETURN_ERROR; // corrupted information supplied } @@ -1005,7 +1005,7 @@ adapterExtension->CAP = StorPortReadRegisterUlong(adapterExtension, &abar->CAP); adapterExtension->CAP2 = StorPortReadRegisterUlong(adapterExtension, &abar->CAP2); adapterExtension->Version = StorPortReadRegisterUlong(adapterExtension, &abar->VS); - adapterExtension->LastInterruptPort = -1; + adapterExtension->LastInterruptPort = (ULONG)-1; // 10.1.2 // 1. Indicate that system software is AHCI aware by setting GHC.AE to â1â. @@ -1015,10 +1015,10 @@ if (ghc.AE != 0)// Hmm, controller was already in power state { // reset controller to have it in known state - DebugPrint("\tAE Already set, Reset()\n"); + AhciDebugPrint("\tAE Already set, Reset()\n"); if (!AhciAdapterReset(adapterExtension)) { - DebugPrint("\tReset Failed!\n"); + AhciDebugPrint("\tReset Failed!\n"); return SP_RETURN_ERROR;// reset failed } } @@ -1033,18 +1033,30 @@ if (adapterExtension->PortImplemented == 0) { - DebugPrint("\tadapterExtension->PortImplemented == 0\n"); + AhciDebugPrint("\tadapterExtension->PortImplemented == 0\n"); return SP_RETURN_ERROR; } - ConfigInfo->MaximumTransferLength = MAXIMUM_TRANSFER_LENGTH;//128 KB + ConfigInfo->Master = TRUE; + ConfigInfo->AlignmentMask = 0x3; + ConfigInfo->ScatterGather = TRUE; + ConfigInfo->DmaWidth = Width32Bits; + ConfigInfo->WmiDataProvider = FALSE; + ConfigInfo->Dma32BitAddresses = TRUE; + + if (IsAdapterCAPS64(adapterExtension->CAP)) + { + ConfigInfo->Dma64BitAddresses = TRUE; + } + + ConfigInfo->MaximumNumberOfTargets = 1; + ConfigInfo->ResetTargetSupported = TRUE; ConfigInfo->NumberOfPhysicalBreaks = 0x21; - ConfigInfo->MaximumNumberOfTargets = 1; ConfigInfo->MaximumNumberOfLogicalUnits = 1; - ConfigInfo->ResetTargetSupported = TRUE; ConfigInfo->NumberOfBuses = MAXIMUM_AHCI_PORT_COUNT; + ConfigInfo->MapBuffers = STOR_MAP_NON_READ_WRITE_BUFFERS; + ConfigInfo->MaximumTransferLength = MAXIMUM_TRANSFER_LENGTH; ConfigInfo->SynchronizationModel = StorSynchronizeFullDuplex; - ConfigInfo->ScatterGather = TRUE; // Turn IE -- Interrupt Enabled ghc.Status = StorPortReadRegisterUlong(adapterExtension, &abar->GHC); @@ -1054,7 +1066,7 @@ // allocate necessary resource for each port if (!AhciAllocateResourceForAdapter(adapterExtension, ConfigInfo)) { - DebugPrint("\tAhciAllocateResourceForAdapter() == FALSE\n"); + NT_ASSERT(FALSE); return SP_RETURN_ERROR; } @@ -1086,12 +1098,8 @@ ) { ULONG status; - HW_INITIALIZATION_DATA hwInitializationData; - - DebugPrint("Storahci Loaded\n"); - // initialize the hardware data structure - AhciZeroMemory(&hwInitializationData, sizeof(HW_INITIALIZATION_DATA)); + HW_INITIALIZATION_DATA hwInitializationData = {0}; // set size of hardware initialization structure hwInitializationData.HwInitializationDataSize = sizeof(HW_INITIALIZATION_DATA); @@ -1104,10 +1112,10 @@ hwInitializationData.HwFindAdapter = AhciHwFindAdapter; // adapter specific information - hwInitializationData.NeedPhysicalAddresses = TRUE; hwInitializationData.TaggedQueuing = TRUE; hwInitializationData.AutoRequestSense = TRUE; hwInitializationData.MultipleRequestPerLu = TRUE; + hwInitializationData.NeedPhysicalAddresses = TRUE; hwInitializationData.NumberOfAccessRanges = 6; hwInitializationData.AdapterInterfaceType = PCIBus; @@ -1123,7 +1131,7 @@ &hwInitializationData, NULL); - DebugPrint("\tstatus: %x\n", status); + NT_ASSERT(status == STATUS_SUCCESS); return status; }// -- DriverEntry(); @@ -1149,11 +1157,11 @@ UNREFERENCED_PARAMETER(PortExtension); - DebugPrint("AhciATA_CFIS()\n"); + AhciDebugPrint("AhciATA_CFIS()\n"); cmdTable = (PAHCI_COMMAND_TABLE)SrbExtension; - AhciZeroMemory(&cmdTable->CFIS, sizeof(cmdTable->CFIS)); + AhciZeroMemory((PCHAR)cmdTable->CFIS, sizeof(cmdTable->CFIS)); cmdTable->CFIS[AHCI_ATA_CFIS_FisType] = FIS_TYPE_REG_H2D; // FIS Type cmdTable->CFIS[AHCI_ATA_CFIS_PMPort_C] = (1 << 7); // PM Port & C @@ -1195,7 +1203,7 @@ UNREFERENCED_PARAMETER(PortExtension); UNREFERENCED_PARAMETER(SrbExtension); - DebugPrint("AhciATAPI_CFIS()\n"); + AhciDebugPrint("AhciATAPI_CFIS()\n"); return 2; }// -- AhciATAPI_CFIS(); @@ -1223,9 +1231,9 @@ PLOCAL_SCATTER_GATHER_LIST sgl; PAHCI_ADAPTER_EXTENSION AdapterExtension; - DebugPrint("AhciBuild_PRDT()\n"); - - sgl = &SrbExtension->Sgl; + AhciDebugPrint("AhciBuild_PRDT()\n"); + + sgl = SrbExtension->pSgl; cmdTable = (PAHCI_COMMAND_TABLE)SrbExtension; AdapterExtension = PortExtension->AdapterExtension; @@ -1275,7 +1283,7 @@ PAHCI_ADAPTER_EXTENSION AdapterExtension; STOR_PHYSICAL_ADDRESS CommandTablePhysicalAddress; - DebugPrint("AhciProcessSrb()\n"); + AhciDebugPrint("AhciProcessSrb()\n"); NT_ASSERT(Srb->PathId == PortExtension->PortNumber); @@ -1292,12 +1300,12 @@ sig = StorPortReadRegisterUlong(AdapterExtension, &PortExtension->Port->SIG); if (sig == 0x101) { - DebugPrint("\tATA Device Found!\n"); + AhciDebugPrint("\tATA Device Found!\n"); SrbExtension->CommandReg = IDE_COMMAND_IDENTIFY; } else { - DebugPrint("\tATAPI Device Found!\n"); + AhciDebugPrint("\tATAPI Device Found!\n"); SrbExtension->CommandReg = IDE_COMMAND_ATAPI_IDENTIFY; } } @@ -1309,13 +1317,17 @@ CommandHeader = &PortExtension->CommandList[SlotIndex]; cfl = 0; - if (IsAtaCommand(SrbExtension->AtaFunction)) + if (IsAtapiCommand(SrbExtension->AtaFunction)) + { + cfl = AhciATAPI_CFIS(PortExtension, SrbExtension); + } + else if (IsAtaCommand(SrbExtension->AtaFunction)) { cfl = AhciATA_CFIS(PortExtension, SrbExtension); } - else if (IsAtapiCommand(SrbExtension->AtaFunction)) - { - cfl = AhciATAPI_CFIS(PortExtension, SrbExtension); + else + { + NT_ASSERT(FALSE); } prdtlen = 0; @@ -1388,7 +1400,7 @@ ULONG QueueSlots, slotToActivate, tmp; PAHCI_ADAPTER_EXTENSION AdapterExtension; - DebugPrint("AhciActivatePort()\n"); + AhciDebugPrint("AhciActivatePort()\n"); AdapterExtension = PortExtension->AdapterExtension; QueueSlots = PortExtension->QueueSlots; @@ -1450,19 +1462,17 @@ __in PSCSI_REQUEST_BLOCK Srb ) { - STOR_LOCK_HANDLE lockhandle; PSCSI_REQUEST_BLOCK tmpSrb; + STOR_LOCK_HANDLE lockhandle = {0}; PAHCI_PORT_EXTENSION PortExtension; ULONG commandSlotMask, occupiedSlots, slotIndex, NCS; - DebugPrint("AhciProcessIO()\n"); - DebugPrint("\tPathId: %d\n", PathId); + AhciDebugPrint("AhciProcessIO()\n"); + AhciDebugPrint("\tPathId: %d\n", PathId); PortExtension = &AdapterExtension->PortExtension[PathId]; NT_ASSERT(PathId < AdapterExtension->PortCount); - - AhciZeroMemory(&lockhandle, sizeof(lockhandle)); // Acquire Lock StorPortAcquireSpinLock(AdapterExtension, InterruptLock, NULL, &lockhandle); @@ -1535,104 +1545,324 @@ ) { PCDB cdb; - PLUN_LIST LunList; + BOOLEAN status; + PINQUIRYDATA InquiryData; PAHCI_SRB_EXTENSION SrbExtension; + PAHCI_ADAPTER_EXTENSION AdapterExtension; PIDENTIFY_DEVICE_DATA IdentifyDeviceData; - ULONG SrbStatus, LunCount, DataBufferLength; - - DebugPrint("InquiryCompletion()\n"); - + + AhciDebugPrint("InquiryCompletion()\n"); + + NT_ASSERT(Srb != NULL); NT_ASSERT(PortExtension != NULL); - NT_ASSERT(Srb != NULL); cdb = (PCDB)&Srb->Cdb; - SrbStatus = Srb->SrbStatus; + InquiryData = Srb->DataBuffer; SrbExtension = GetSrbExtension(Srb); - - if (SrbStatus == SRB_STATUS_SUCCESS) - { - IdentifyDeviceData = PortExtension->IdentifyDeviceData; - - if (SrbExtension->CommandReg == IDE_COMMAND_IDENTIFY) + AdapterExtension = PortExtension->AdapterExtension; + IdentifyDeviceData = PortExtension->IdentifyDeviceData; + + if (Srb->SrbStatus != SRB_STATUS_SUCCESS) + { + if (Srb->SrbStatus == SRB_STATUS_NO_DEVICE) { - DebugPrint("Device: ATA\n"); - PortExtension->DeviceParams.DeviceType = AHCI_DEVICE_TYPE_ATA; - if (IdentifyDeviceData->GeneralConfiguration.RemovableMedia) - { - PortExtension->DeviceParams.RemovableDevice = 1; - } - - if (IdentifyDeviceData->CommandSetSupport.BigLba && IdentifyDeviceData->CommandSetActive.BigLba) - { - PortExtension->DeviceParams.Lba48BitMode = 1; - } - - PortExtension->DeviceParams.AccessType = DIRECT_ACCESS_DEVICE; - - // TODO: Add other device params + PortExtension->DeviceParams.DeviceType = AHCI_DEVICE_TYPE_NODEVICE; + } + return; + } + + NT_ASSERT(InquiryData != NULL); + NT_ASSERT(Srb->SrbStatus == SRB_STATUS_SUCCESS); + + // Device specific data + PortExtension->DeviceParams.MaxLba.QuadPart = 0; + + if (SrbExtension->CommandReg == IDE_COMMAND_IDENTIFY) + { + PortExtension->DeviceParams.DeviceType = AHCI_DEVICE_TYPE_ATA; + if (IdentifyDeviceData->GeneralConfiguration.RemovableMedia) + { + PortExtension->DeviceParams.RemovableDevice = 1; + } + + if (IdentifyDeviceData->CommandSetSupport.BigLba && IdentifyDeviceData->CommandSetActive.BigLba) + { + PortExtension->DeviceParams.Lba48BitMode = 1; + } + + PortExtension->DeviceParams.AccessType = DIRECT_ACCESS_DEVICE; + + /* Device max address lba */ + if (PortExtension->DeviceParams.Lba48BitMode) + { + PortExtension->DeviceParams.MaxLba.LowPart = IdentifyDeviceData->Max48BitLBA[0]; + PortExtension->DeviceParams.MaxLba.HighPart = IdentifyDeviceData->Max48BitLBA[1]; } else { - DebugPrint("Device: ATAPI\n"); - PortExtension->DeviceParams.DeviceType = AHCI_DEVICE_TYPE_ATAPI; - - PortExtension->DeviceParams.AccessType = READ_ONLY_DIRECT_ACCESS_DEVICE; + PortExtension->DeviceParams.MaxLba.LowPart = IdentifyDeviceData->UserAddressableSectors; } - } - else if (SrbStatus == SRB_STATUS_NO_DEVICE) - { - DebugPrint("Device: No Device\n"); - PortExtension->DeviceParams.DeviceType = AHCI_DEVICE_TYPE_NODEVICE; + + /* Bytes Per Logical Sector */ + if (IdentifyDeviceData->PhysicalLogicalSectorSize.LogicalSectorLongerThan256Words) + { + AhciDebugPrint("\tBytesPerLogicalSector != DEVICE_ATA_BLOCK_SIZE\n"); + NT_ASSERT(FALSE); + } + + PortExtension->DeviceParams.BytesPerLogicalSector = DEVICE_ATA_BLOCK_SIZE; + + /* Bytes Per Physical Sector */ + if (IdentifyDeviceData->PhysicalLogicalSectorSize.MultipleLogicalSectorsPerPhysicalSector) + { + AhciDebugPrint("\tBytesPerPhysicalSector != DEVICE_ATA_BLOCK_SIZE\n"); + NT_ASSERT(FALSE); + } + + PortExtension->DeviceParams.BytesPerPhysicalSector = DEVICE_ATA_BLOCK_SIZE; + + // TODO: Add other device params + AhciDebugPrint("\tATA Device\n"); } else { - return; - } - - if ((cdb != NULL) && (cdb->CDB10.OperationCode == SCSIOP_REPORT_LUNS)) - { - Srb->SrbStatus = SRB_STATUS_SUCCESS; - Srb->ScsiStatus = SCSISTAT_GOOD; - - SrbExtension->AtaFunction = 0; - DataBufferLength = Srb->DataTransferLength; - - LunList = (PLUN_LIST)Srb->DataBuffer; - if (PortExtension->DeviceParams.DeviceType == AHCI_DEVICE_TYPE_NODEVICE) - { - LunCount = 0; - } - else - { - LunCount = 1; - } - - if (DataBufferLength < sizeof(LUN_LIST)) - { - DebugPrint("\tSRB_STATUS_DATA_OVERRUN\n"); - Srb->SrbStatus = SRB_STATUS_DATA_OVERRUN; - } - else - { - LunList->LunListLength[0] = 0; - LunList->LunListLength[1] = 0; - LunList->LunListLength[2] = 0; - LunList->LunListLength[3] = 8; - - // followed by 8 entries - LunList->Lun[0][0] = 0; - LunList->Lun[0][1] = 0; - LunList->Lun[0][2] = 0; - LunList->Lun[0][3] = 0; - LunList->Lun[0][4] = 0; - LunList->Lun[0][5] = 0; - LunList->Lun[0][6] = 0; - LunList->Lun[0][7] = 0; - } - } - + AhciDebugPrint("\tATAPI Device\n"); + PortExtension->DeviceParams.DeviceType = AHCI_DEVICE_TYPE_ATAPI; + PortExtension->DeviceParams.AccessType = READ_ONLY_DIRECT_ACCESS_DEVICE; + } + + // INQUIRYDATABUFFERSIZE = 36 ; Defined in storport.h + if (Srb->DataTransferLength < INQUIRYDATABUFFERSIZE) + { + AhciDebugPrint("\tDataBufferLength < sizeof(INQUIRYDATA), Could crash the driver.\n"); + } + + // update data transfer length + Srb->DataTransferLength = INQUIRYDATABUFFERSIZE; + + // prepare data to send + InquiryData->Versions = 2; + InquiryData->Wide32Bit = 1; + InquiryData->CommandQueue = 0; // NCQ not supported + InquiryData->ResponseDataFormat = 0x2; + InquiryData->DeviceTypeModifier = 0; + InquiryData->DeviceTypeQualifier = DEVICE_CONNECTED; + InquiryData->AdditionalLength = INQUIRYDATABUFFERSIZE - 5; + InquiryData->DeviceType = PortExtension->DeviceParams.AccessType; + InquiryData->RemovableMedia = PortExtension->DeviceParams.RemovableDevice; + + // TODO: Fill VendorID, Product Revision Level and other string fields + InquiryData->VendorId[0] = '2'; + InquiryData->ProductId[0] = '3'; + InquiryData->ProductRevisionLevel[0] = '4'; + + // send queue depth + status = StorPortSetDeviceQueueDepth(PortExtension->AdapterExtension, + Srb->PathId, + Srb->TargetId, + Srb->Lun, + AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP)); + + NT_ASSERT(status == TRUE); return; }// -- InquiryCompletion(); + +/** + * @name DeviceRequestReadWrite + * @implemented + * + * Handle SCSIOP_READ SCSIOP_WRITE OperationCode + * + * @param AdapterExtension + * @param Srb + * @param Cdb + * + * @return + * return STOR status for DeviceReportLuns + */ +UCHAR DeviceRequestReadWrite ( + __in PAHCI_ADAPTER_EXTENSION AdapterExtension, + __in PSCSI_REQUEST_BLOCK Srb, + __in PCDB Cdb + ) +{ + ULONG64 SectorNo; + BOOLEAN IsReading; + PAHCI_SRB_EXTENSION SrbExtension; + PAHCI_PORT_EXTENSION PortExtension; + ULONG DataTransferLength, BytesPerSector, SectorCount; + + AhciDebugPrint("DeviceRequestReadWrite()\n"); + + NT_ASSERT(IsPortValid(AdapterExtension, Srb->PathId)); + NT_ASSERT((Cdb->CDB10.OperationCode == SCSIOP_READ) || (Cdb->CDB10.OperationCode == SCSIOP_WRITE)); + + SrbExtension = GetSrbExtension(Srb); + PortExtension = &AdapterExtension->PortExtension[Srb->PathId]; + + DataTransferLength = Srb->DataTransferLength; + BytesPerSector = PortExtension->DeviceParams.BytesPerLogicalSector; + + ROUND_UP(DataTransferLength, BytesPerSector); + + SectorCount = DataTransferLength / BytesPerSector; + SectorNo = AhciGetLba(Cdb); + IsReading = (Cdb->CDB10.OperationCode == SCSIOP_READ); + + NT_ASSERT(SectorCount > 0); + + SrbExtension->AtaFunction = ATA_FUNCTION_ATA_READ; + SrbExtension->Flags = ATA_FLAGS_USE_DMA; + SrbExtension->CompletionRoutine = NULL; + + if (IsReading) + { + SrbExtension->Flags |= ATA_FLAGS_DATA_IN; + SrbExtension->CommandReg = IDE_COMMAND_READ_DMA; + } + else + { + SrbExtension->Flags |= ATA_FLAGS_DATA_OUT; + NT_ASSERT(FALSE); + } + + SrbExtension->FeaturesLow = 0; + SrbExtension->LBA0 = (SectorNo >> 0) & 0xFF; + SrbExtension->LBA1 = (SectorNo >> 8) & 0xFF; + SrbExtension->LBA2 = (SectorNo >> 16) & 0xFF; + + SrbExtension->Device = (0xA0 | IDE_LBA_MODE); + + if (PortExtension->DeviceParams.Lba48BitMode) + { + SrbExtension->Flags |= ATA_FLAGS_48BIT_COMMAND; + SrbExtension->CommandReg = IDE_COMMAND_READ_DMA_EXT; + + SrbExtension->LBA3 = (SectorNo >> 24) & 0xFF; + SrbExtension->LBA4 = (SectorNo >> 32) & 0xFF; + SrbExtension->LBA5 = (SectorNo >> 40) & 0xFF; + } + else + { + NT_ASSERT(FALSE); + } + + SrbExtension->FeaturesHigh = 0; + SrbExtension->SectorCountLow = (SectorCount >> 0) & 0xFF; + SrbExtension->SectorCountHigh = (SectorCount >> 8) & 0xFF; + + NT_ASSERT(SectorCount < 0x100); + + SrbExtension->pSgl = (PLOCAL_SCATTER_GATHER_LIST)StorPortGetScatterGatherList(AdapterExtension, Srb); + + AhciProcessIO(AdapterExtension, Srb->PathId, Srb); + return SRB_STATUS_PENDING; +}// -- DeviceRequestReadWrite(); + +/** + * @name DeviceRequestCapacity + * @implemented + * + * Handle SCSIOP_READ_CAPACITY OperationCode + * + * @param AdapterExtension + * @param Srb + * @param Cdb + * + * @return + * return STOR status for DeviceReportLuns + */ +UCHAR DeviceRequestCapacity ( + __in PAHCI_ADAPTER_EXTENSION AdapterExtension, + __in PSCSI_REQUEST_BLOCK Srb, + __in PCDB Cdb + ) +{ + ULONG MaxLba, BytesPerLogicalSector; + PREAD_CAPACITY_DATA ReadCapacity; + PAHCI_PORT_EXTENSION PortExtension; + + AhciDebugPrint("DeviceRequestCapacity()\n"); + + UNREFERENCED_PARAMETER(AdapterExtension); + UNREFERENCED_PARAMETER(Cdb); + + NT_ASSERT(Srb->DataBuffer != NULL); + NT_ASSERT(IsPortValid(AdapterExtension, Srb->PathId)); + + PortExtension = &AdapterExtension->PortExtension[Srb->PathId]; + + if (Cdb->CDB10.OperationCode == SCSIOP_READ_CAPACITY) + { + ReadCapacity = (PREAD_CAPACITY_DATA)Srb->DataBuffer; + + + BytesPerLogicalSector = PortExtension->DeviceParams.BytesPerLogicalSector; + MaxLba = (ULONG)PortExtension->DeviceParams.MaxLba.QuadPart; + + // I trust you windows :D + NT_ASSERT(Srb->DataTransferLength >= sizeof(READ_CAPACITY_DATA)); + + // I trust you user :D + NT_ASSERT(PortExtension->DeviceParams.MaxLba.QuadPart < (ULONG)-1); + + // Actually I don't trust anyone :p + Srb->DataTransferLength = sizeof(READ_CAPACITY_DATA); + + REVERSE_BYTES(&ReadCapacity->BytesPerBlock, &BytesPerLogicalSector); + REVERSE_BYTES(&ReadCapacity->LogicalBlockAddress, &MaxLba); + } + else + { + AhciDebugPrint("\tSCSIOP_READ_CAPACITY16 not supported\n"); + NT_ASSERT(FALSE); + } + + return SRB_STATUS_SUCCESS; +}// -- DeviceRequestCapacity(); + +/** + * @name DeviceReportLuns + * @implemented + * + * Handle SCSIOP_REPORT_LUNS OperationCode + * + * @param AdapterExtension + * @param Srb + * @param Cdb + * + * @return + * return STOR status for DeviceReportLuns + */ +UCHAR DeviceReportLuns ( + __in PAHCI_ADAPTER_EXTENSION AdapterExtension, + __in PSCSI_REQUEST_BLOCK Srb, + __in PCDB Cdb + ) +{ + PLUN_LIST LunList; + + AhciDebugPrint("DeviceReportLuns()\n"); + + UNREFERENCED_PARAMETER(AdapterExtension); + UNREFERENCED_PARAMETER(Cdb); + + NT_ASSERT(Srb->DataTransferLength >= sizeof(LUN_LIST)); + NT_ASSERT(Cdb->CDB10.OperationCode == SCSIOP_REPORT_LUNS); + + LunList = (PLUN_LIST)Srb->DataBuffer; + + NT_ASSERT(LunList != NULL); + + AhciZeroMemory((PCHAR)LunList, sizeof(LUN_LIST)); + + LunList->LunListLength[3] = 8; + + Srb->ScsiStatus = SCSISTAT_GOOD; + Srb->DataTransferLength = sizeof(LUN_LIST); + + return SRB_STATUS_SUCCESS; +}// -- DeviceReportLuns(); /** * @name DeviceInquiryRequest @@ -1654,18 +1884,18 @@ DeviceInquiryRequest ( __in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, - __in PCDB Cdb, - __in BOOLEAN HasProductDataRequest + __in PCDB Cdb ) { PVOID DataBuffer; + PAHCI_SRB_EXTENSION SrbExtension; PAHCI_PORT_EXTENSION PortExtension; - PAHCI_SRB_EXTENSION SrbExtension; PVPD_SUPPORTED_PAGES_PAGE VpdOutputBuffer; ULONG DataBufferLength, RequiredDataBufferLength; - DebugPrint("DeviceInquiryRequest()\n"); - + AhciDebugPrint("DeviceInquiryRequest()\n"); + + NT_ASSERT(Cdb->CDB10.OperationCode == SCSIOP_INQUIRY); NT_ASSERT(IsPortValid(AdapterExtension, Srb->PathId)); SrbExtension = GetSrbExtension(Srb); @@ -1675,11 +1905,11 @@ { return SRB_STATUS_SELECTION_TIMEOUT; } - else if ((HasProductDataRequest == FALSE) || (Cdb->CDB6INQUIRY3.EnableVitalProductData == 0)) + else if (Cdb->CDB6INQUIRY3.EnableVitalProductData == 0) { // 3.6.1 // If the EVPD bit is set to zero, the device server shall return the standard INQUIRY data - DebugPrint("\tEVPD Inquired\n"); + AhciDebugPrint("\tEVPD Inquired\n"); NT_ASSERT(SrbExtension != NULL); SrbExtension->AtaFunction = ATA_FUNCTION_ATA_IDENTIFY; @@ -1705,15 +1935,18 @@ SrbExtension->Sgl.List[0].PhysicalAddress.HighPart = PortExtension->IdentifyDeviceDataPhysicalAddress.HighPart; SrbExtension->Sgl.List[0].Length = sizeof(IDENTIFY_DEVICE_DATA); + SrbExtension->pSgl = &SrbExtension->Sgl; + AhciProcessIO(AdapterExtension, Srb->PathId, Srb); return SRB_STATUS_PENDING; } - else if (HasProductDataRequest == TRUE) - { - DebugPrint("\tVPD Inquired\n"); + else + { + AhciDebugPrint("\tVPD Inquired\n"); DataBuffer = Srb->DataBuffer; DataBufferLength = Srb->DataTransferLength; + RequiredDataBufferLength = DataBufferLength; // make the compiler happy :p if (DataBuffer == NULL) { @@ -1725,34 +1958,47 @@ switch(Cdb->CDB6INQUIRY3.PageCode) { case VPD_SUPPORTED_PAGES: - { - DebugPrint("\tVPD_SUPPORTED_PAGES\n"); - RequiredDataBufferLength = sizeof(VPD_SUPPORTED_PAGES_PAGE); - if (DataBufferLength < RequiredDataBufferLength) { - DebugPrint("\tDataBufferLength: %d Required: %d\n", DataBufferLength, RequiredDataBufferLength); - return SRB_STATUS_INVALID_REQUEST; - } - else - { + AhciDebugPrint("\tVPD_SUPPORTED_PAGES\n"); + RequiredDataBufferLength = sizeof(VPD_SUPPORTED_PAGES_PAGE) + 1; + + if (DataBufferLength < RequiredDataBufferLength) + { + AhciDebugPrint("\tDataBufferLength: %d Required: %d\n", DataBufferLength, RequiredDataBufferLength); + return SRB_STATUS_INVALID_REQUEST; + } + VpdOutputBuffer = (PVPD_SUPPORTED_PAGES_PAGE)DataBuffer; - VpdOutputBuffer->DeviceType = PortExtension->DeviceParams.DeviceType; + + VpdOutputBuffer->DeviceType = PortExtension->DeviceParams.AccessType; VpdOutputBuffer->DeviceTypeQualifier = 0; VpdOutputBuffer->PageCode = VPD_SUPPORTED_PAGES; VpdOutputBuffer->PageLength = 1; VpdOutputBuffer->SupportedPageList[0] = VPD_SUPPORTED_PAGES; - - return SRB_STATUS_SUCCESS; + //VpdOutputBuffer->SupportedPageList[1] = VPD_SERIAL_NUMBER; + //VpdOutputBuffer->SupportedPageList[2] = VPD_DEVICE_IDENTIFIERS; + + NT_ASSERT(VpdOutputBuffer->DeviceType == DIRECT_ACCESS_DEVICE); } - } - break; + break; + case VPD_SERIAL_NUMBER: + { + AhciDebugPrint("\tVPD_SERIAL_NUMBER\n"); + } + break; + case VPD_DEVICE_IDENTIFIERS: + { + AhciDebugPrint("\tVPD_DEVICE_IDENTIFIERS\n"); + } + break; default: - DebugPrint("\tPageCode: %x\n", Cdb->CDB6INQUIRY3.PageCode); - break; + AhciDebugPrint("\tPageCode: %x\n", Cdb->CDB6INQUIRY3.PageCode); + return SRB_STATUS_INVALID_REQUEST; } - } - - return SRB_STATUS_INVALID_REQUEST; + + Srb->DataTransferLength = RequiredDataBufferLength; + return SRB_STATUS_SUCCESS; + } }// -- DeviceInquiryRequest(); /** @@ -1783,7 +2029,7 @@ AHCI_GHC ghc; PAHCI_MEMORY_REGISTERS abar = NULL; - DebugPrint("AhciAdapterReset()\n"); + AhciDebugPrint("AhciAdapterReset()\n"); abar = AdapterExtension->ABAR_Address; if (abar == NULL) // basic sanity @@ -1807,7 +2053,7 @@ if (ticks == 50)// 1 second { - DebugPrint("\tDevice Timeout\n"); + AhciDebugPrint("\tDevice Timeout\n"); return FALSE; } @@ -1962,3 +2208,22 @@ return (PAHCI_SRB_EXTENSION)(SrbExtension + Offset); }// -- PAHCI_SRB_EXTENSION(); + + +__inline +ULONG64 +AhciGetLba ( + __in PCDB Cdb + ) +{ + ULONG64 lba = 0; + + NT_ASSERT(Cdb != NULL); + + lba |= Cdb->CDB10.LogicalBlockByte3 << 0; + lba |= Cdb->CDB10.LogicalBlockByte2 << 8; + lba |= Cdb->CDB10.LogicalBlockByte1 << 16; + lba |= Cdb->CDB10.LogicalBlockByte0 << 24; + + return lba; +}// -- AhciGetLba(); Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
============================================================================== --- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h [iso-8859-1] (original) +++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h [iso-8859-1] Sat Jul 23 22:53:15 2016 @@ -18,6 +18,8 @@ #define MAXIMUM_AHCI_PORT_NCS 30 #define MAXIMUM_QUEUE_BUFFER_SIZE 255 #define MAXIMUM_TRANSFER_LENGTH (128*1024) // 128 KB + +#define DEVICE_ATA_BLOCK_SIZE 512 // device type (DeviceParams) #define AHCI_DEVICE_TYPE_ATA 1 @@ -54,6 +56,7 @@ // ATA Functions #define ATA_FUNCTION_ATA_COMMAND 0x100 #define ATA_FUNCTION_ATA_IDENTIFY 0x101 +#define ATA_FUNCTION_ATA_READ 0x102 // ATAPI Functions #define ATA_FUNCTION_ATAPI_COMMAND 0x200 @@ -61,6 +64,8 @@ // ATA Flags #define ATA_FLAGS_DATA_IN (1 << 1) #define ATA_FLAGS_DATA_OUT (1 << 2) +#define ATA_FLAGS_48BIT_COMMAND (1 << 3) +#define ATA_FLAGS_USE_DMA (1 << 4) #define IsAtaCommand(AtaFunction) (AtaFunction & ATA_FUNCTION_ATA_COMMAND) #define IsAtapiCommand(AtaFunction) (AtaFunction & ATA_FUNCTION_ATAPI_COMMAND) @@ -68,11 +73,11 @@ #define IsAdapterCAPS64(CAP) (CAP & AHCI_Global_HBA_CAP_S64A) // 3.1.1 NCS = CAP[12:08] -> Align -#define AHCI_Global_Port_CAP_NCS(x) (((x) & 0xF00) >> 8) +#define AHCI_Global_Port_CAP_NCS(x) (((x) & 0xF00) >> 8) #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S)) #ifdef DBG - #define DebugPrint(format, ...) StorPortDebugPrint(0, format, __VA_ARGS__) + #define AhciDebugPrint(format, ...) StorPortDebugPrint(0, format, __VA_ARGS__) #endif typedef @@ -464,6 +469,12 @@ UCHAR AccessType; UCHAR DeviceType; UCHAR IsActive; + LARGE_INTEGER MaxLba; + ULONG BytesPerLogicalSector; + ULONG BytesPerPhysicalSector; + // UCHAR VendorId[41]; + // UCHAR RevisionID[9]; + // UCHAR SerialNumber[21]; } DeviceParams; STOR_DPC CommandCompletion; @@ -542,7 +553,12 @@ ULONG SlotIndex; LOCAL_SCATTER_GATHER_LIST Sgl; + PLOCAL_SCATTER_GATHER_LIST pSgl; PAHCI_COMPLETION_ROUTINE CompletionRoutine; + + // for alignment purpose -- 128 byte alignment + // do not try to access (R/W) this field + UCHAR Reserved[128]; } AHCI_SRB_EXTENSION, *PAHCI_SRB_EXTENSION; ////////////////////////////////////////////////////////////// @@ -568,12 +584,29 @@ __in ULONG pathId ); +UCHAR DeviceRequestReadWrite ( + __in PAHCI_ADAPTER_EXTENSION AdapterExtension, + __in PSCSI_REQUEST_BLOCK Srb, + __in PCDB Cdb + ); + +UCHAR DeviceRequestCapacity ( + __in PAHCI_ADAPTER_EXTENSION AdapterExtension, + __in PSCSI_REQUEST_BLOCK Srb, + __in PCDB Cdb + ); + UCHAR DeviceInquiryRequest ( __in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, - __in PCDB Cdb, - __in BOOLEAN HasProductDataRequest + __in PCDB Cdb + ); + +UCHAR DeviceReportLuns ( + __in PAHCI_ADAPTER_EXTENSION AdapterExtension, + __in PSCSI_REQUEST_BLOCK Srb, + __in PCDB Cdb ); __inline @@ -593,6 +626,12 @@ PAHCI_SRB_EXTENSION GetSrbExtension( __in PSCSI_REQUEST_BLOCK Srb + ); + +__inline +ULONG64 +AhciGetLba ( + __in PCDB Cdb ); //////////////////////////////////////////////////////////////
8 years, 5 months
1
0
0
0
← Newer
1
...
5
6
7
8
9
10
11
...
36
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Results per page:
10
25
50
100
200