From 596c3bee62267e6f94498294a2331cdcc1a06d4f Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Thu, 16 Nov 2006 17:30:52 +0000 Subject: [PATCH] - Reorganize HAL exports and export KeTRyToAcquireQueuedSpinlock and KeTryToAcquireQueuedSpinLockRaisetoSynch. - Add stub for HalSetTimeIncrement. - Cleanup CMOS-related routines (Get/Set environment value and get/set RTC). Fixup some prototypes as well. Inline HalpReadCmos/HalpWriteCmos instead of having a separate function. - Fixup wrong protypes for various Queued Spinlock functions. - Use __rdtsc intrinsic instead of Ke386RdTsc. - Other MSVC compilation fixes. svn path=/trunk/; revision=24770 --- reactos/hal/hal/hal.def | 37 ++- reactos/hal/halx86/generic/beep.c | 6 +- reactos/hal/halx86/generic/cmos.c | 304 ++++++++++++++++++ reactos/hal/halx86/generic/generic.rbuild | 4 +- reactos/hal/halx86/generic/irql.c | 8 +- reactos/hal/halx86/generic/spinlock.c | 12 +- reactos/hal/halx86/generic/time.c | 356 ---------------------- reactos/hal/halx86/generic/timer.c | 18 +- reactos/hal/halx86/include/hal.h | 1 + reactos/include/ndk/halfuncs.h | 24 +- reactos/lib/rtl/registry.c | 5 - 11 files changed, 369 insertions(+), 406 deletions(-) create mode 100644 reactos/hal/halx86/generic/cmos.c delete mode 100644 reactos/hal/halx86/generic/time.c diff --git a/reactos/hal/hal/hal.def b/reactos/hal/hal/hal.def index b6cdb04dd9f..47e5ad99608 100644 --- a/reactos/hal/hal/hal.def +++ b/reactos/hal/hal/hal.def @@ -6,6 +6,22 @@ EXPORTS @ExAcquireFastMutex@4=@ExiAcquireFastMutex@4 @ExReleaseFastMutex@4=@ExiReleaseFastMutex@4 @ExTryToAcquireFastMutex@4=@ExiTryToAcquireFastMutex@4 +@HalClearSoftwareInterrupt@4 +@HalRequestSoftwareInterrupt@4 +@HalSystemVectorDispatchEntry@12 +@KeAcquireInStackQueuedSpinLock@8 +@KeAcquireInStackQueuedSpinLockRaiseToSynch@8 +@KeAcquireSpinLockRaiseToSynch@4 +@KeAcquireQueuedSpinLock@4 +@KeReleaseInStackQueuedSpinLock@4 +@KeReleaseQueuedSpinLock@8 +@KeTryToAcquireQueuedSpinLock@8 +@KeTryToAcquireQueuedSpinLockRaiseToSynch@8 +@KfAcquireSpinLock@4 +@KfLowerIrql@4 +@KfRaiseIrql@4 +@KfReleaseSpinLock@8 + HalAcquireDisplayOwnership@4 HalAdjustResourceList@4 HalAllProcessorsStarted@0 @@ -15,7 +31,6 @@ HalAllocateCrashDumpRegisters@8 HalAssignSlotResources@32 HalBeginSystemInterrupt@12 HalCalibratePerformanceCounter@4 -@HalClearSoftwareInterrupt@4 HalDisableSystemInterrupt@8 HalDisplayString@4 HalEnableSystemInterrupt@12 @@ -37,7 +52,6 @@ HalQueryRealTimeClock@4 HalReadDmaCounter@4 HalReportResourceUsage@0 HalRequestIpi@4 -@HalRequestSoftwareInterrupt@4 HalReturnToFirmware@4 HalSetBusData@20 HalSetBusDataByOffset@24 @@ -45,14 +59,13 @@ HalSetDisplayParameters@8 HalSetEnvironmentVariable@8 ;HalSetProfileInterval@4 HalSetRealTimeClock@4 -;HalSetTimeIncrement@4 +HalSetTimeIncrement@4 HalStartNextProcessor@8 ;HalStartProfileInterrupt@4 ;HalStopProfileInterrupt@4 -@HalSystemVectorDispatchEntry@12 HalTranslateBusAddress@24 -IoFlushAdapterBuffers@24 IoAssignDriveLetters@16=HalpAssignDriveLetters@16 +IoFlushAdapterBuffers@24 IoFreeAdapterChannel@4 IoFreeMapRegisters@12 IoMapTransfer@24 @@ -60,6 +73,7 @@ IoReadPartitionTable@16=HalpReadPartitionTable@16 IoSetPartitionInformation@16=HalpSetPartitionInformation@16 IoWritePartitionTable@20=HalpWritePartitionTable@20 KdComPortInUse DATA +; FIXME: DEPRECATED KdPortGetByte@4 KdPortGetByteEx@8 KdPortInitialize@12 @@ -72,26 +86,17 @@ KdPortRestore@0 KdPortSave@0 KdPortDisableInterrupts@0 KdPortEnableInterrupts@0 +; FIXME: END DEPRECATED BLOCK KeAcquireSpinLock@8 -@KeAcquireInStackQueuedSpinLock@8 -@KeAcquireInStackQueuedSpinLockRaiseToSynch@8 -@KeAcquireSpinLockRaiseToSynch@4 -@KeAcquireQueuedSpinLock@4 -KeGetCurrentIrql@0 KeFlushWriteBuffer@0 +KeGetCurrentIrql@0 KeLowerIrql@4 KeQueryPerformanceCounter@4 KeRaiseIrql@8 KeRaiseIrqlToDpcLevel@0 KeRaiseIrqlToSynchLevel@0 -@KeReleaseInStackQueuedSpinLock@4 KeReleaseSpinLock@8 -@KeReleaseQueuedSpinLock@8 KeStallExecutionProcessor@4 -@KfAcquireSpinLock@4 -@KfLowerIrql@4 -@KfRaiseIrql@4 -@KfReleaseSpinLock@8 READ_PORT_BUFFER_UCHAR@12 READ_PORT_BUFFER_ULONG@12 READ_PORT_BUFFER_USHORT@12 diff --git a/reactos/hal/halx86/generic/beep.c b/reactos/hal/halx86/generic/beep.c index 5f1f4d1cc02..e352572ddce 100644 --- a/reactos/hal/halx86/generic/beep.c +++ b/reactos/hal/halx86/generic/beep.c @@ -2,7 +2,7 @@ * PROJECT: ReactOS HAL * LICENSE: GPL - See COPYING in the top level directory * FILE: ntoskrnl/hal/x86/beep.c - * PURPOSE: Speak support (beeping) + * PURPOSE: Speaker support (beeping) * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) * Eric Kohl (ekohl@abo.rhein-zeitung.de) */ @@ -22,6 +22,9 @@ /* FUNCTIONS *****************************************************************/ +/* + * @implemented + */ BOOLEAN NTAPI HalMakeBeep(IN ULONG Frequency) @@ -66,3 +69,4 @@ Cleanup: return Result; } + diff --git a/reactos/hal/halx86/generic/cmos.c b/reactos/hal/halx86/generic/cmos.c new file mode 100644 index 00000000000..8b1a6b78afe --- /dev/null +++ b/reactos/hal/halx86/generic/cmos.c @@ -0,0 +1,304 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: GPL - See COPYING in the top level directory + * FILE: ntoskrnl/hal/halx86/generic/cmos.c + * PURPOSE: CMOS Access Routines (Real Time Clock and LastKnownGood) + * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include +#define NDEBUG +#include + +/* CMOS Registers and Ports */ +#define CMOS_CONTROL_PORT (PUCHAR)0x70 +#define CMOS_DATA_PORT (PUCHAR)0x71 +#define RTC_REGISTER_A 0x0A +#define RTC_REGISTER_B 0x0B +#define RTC_REG_A_UIP 0x80 +#define RTC_REGISTER_CENTURY 0x32 + +/* Conversion functions */ +#define BCD_INT(bcd) \ + (((bcd & 0xF0) >> 4) * 10 + (bcd & 0x0F)) +#define INT_BCD(int) \ + (UCHAR)(((int / 10) << 4) + (int % 10)) + +/* PRIVATE FUNCTIONS *********************************************************/ + +UCHAR +FORCEINLINE +HalpReadCmos(IN UCHAR Reg) +{ + /* Select the register */ + WRITE_PORT_UCHAR(CMOS_CONTROL_PORT, Reg); + + /* Query the value */ + return READ_PORT_UCHAR(CMOS_DATA_PORT); +} + +VOID +FORCEINLINE +HalpWriteCmos(IN UCHAR Reg, + IN UCHAR Value) +{ + /* Select the register */ + WRITE_PORT_UCHAR(CMOS_CONTROL_PORT, Reg); + + /* Write the value */ + WRITE_PORT_UCHAR(CMOS_DATA_PORT, Value); +} + +ULONG +NTAPI +HalpGetCmosData(IN PBUS_HANDLER BusHandler, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length) +{ + PUCHAR Ptr = (PUCHAR)Buffer; + ULONG Address = SlotNumber; + ULONG Len = Length; + + /* FIXME: Acquire CMOS Lock */ + + /* Do nothing if we don't have a length */ + if (!Length) return 0; + + /* Check if this is simple CMOS */ + if (!BusNumber) + { + /* Loop the buffer up to 0xFF */ + while ((Len > 0) && (Address < 0x100)) + { + /* Read the data */ + *Ptr = HalpReadCmos((UCHAR)Address); + + /* Update position and length */ + Ptr++; + Address++; + Len--; + } + } + else if (BusNumber == 1) + { + /* Loop the buffer up to 0xFFFF */ + while ((Len > 0) && (Address < 0x10000)) + { + /* Write the data */ + *Ptr = HalpReadCmos((UCHAR)Address); + + /* Update position and length */ + Ptr++; + Address++; + Len--; + } + } + + /* FIXME: Release the CMOS Lock */ + + /* Return length read */ + return Length - Len; +} + +ULONG +NTAPI +HalpSetCmosData(IN PBUS_HANDLER BusHandler, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length) +{ + PUCHAR Ptr = (PUCHAR)Buffer; + ULONG Address = SlotNumber; + ULONG Len = Length; + + /* FIXME: Acquire CMOS Lock */ + + /* Do nothing if we don't have a length */ + if (!Length) return 0; + + /* Check if this is simple CMOS */ + if (!BusNumber) + { + /* Loop the buffer up to 0xFF */ + while ((Len > 0) && (Address < 0x100)) + { + /* Write the data */ + HalpWriteCmos((UCHAR)Address, *Ptr); + + /* Update position and length */ + Ptr++; + Address++; + Len--; + } + } + else if (BusNumber == 1) + { + /* Loop the buffer up to 0xFFFF */ + while ((Len > 0) && (Address < 0x10000)) + { + /* Write the data */ + HalpWriteCmos((UCHAR)Address, *Ptr); + + /* Update position and length */ + Ptr++; + Address++; + Len--; + } + } + + /* FIXME: Release the CMOS Lock */ + + /* Return length read */ + return Length - Len; +} + +/* PUBLIC FUNCTIONS **********************************************************/ + +/* + * @implemented + */ +ARC_STATUS +NTAPI +HalGetEnvironmentVariable(IN PCH Name, + IN USHORT ValueLength, + IN PCH Value) +{ + UCHAR Val; + + /* Only variable supported on x86 */ + if (_stricmp(Name, "LastKnownGood")) return ENOENT; + + /* FIXME: Acquire CMOS Lock */ + + /* Query the current value */ + Val = HalpReadCmos(RTC_REGISTER_B) & 0x01; + + /* FIXME: Release CMOS lock */ + + /* Check the flag */ + if (Val) + { + /* Return false */ + strncpy(Value, "FALSE", ValueLength); + } + else + { + /* Return true */ + strncpy(Value, "TRUE", ValueLength); + } + + /* Return success */ + return ESUCCESS; +} + +/* + * @implemented + */ +ARC_STATUS +NTAPI +HalSetEnvironmentVariable(IN PCH Name, + IN PCH Value) +{ + UCHAR Val; + + /* Only variable supported on x86 */ + if (_stricmp(Name, "LastKnownGood")) return ENOMEM; + + /* Check if this is true or false */ + if (!_stricmp(Value, "TRUE")) + { + /* It's true, acquire CMOS lock (FIXME) */ + + /* Read the current value and add the flag */ + Val = HalpReadCmos(RTC_REGISTER_B) | 1; + } + else if (!_stricmp(Value, "FALSE")) + { + /* It's false, acquire CMOS lock (FIXME) */ + + /* Read the current value and mask out the flag */ + Val = HalpReadCmos(RTC_REGISTER_B) & ~1; + } + else + { + /* Fail */ + return ENOMEM; + } + + /* Write new value */ + HalpWriteCmos(RTC_REGISTER_B, Val); + + /* Release the lock and return success */ + return ESUCCESS; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +HalQueryRealTimeClock(OUT PTIME_FIELDS Time) +{ + /* FIXME: Acquire CMOS Lock */ + + /* Loop while update is in progress */ + while ((HalpReadCmos(RTC_REGISTER_A)) & RTC_REG_A_UIP); + + /* Set the time data */ + Time->Second = BCD_INT(HalpReadCmos(0)); + Time->Minute = BCD_INT(HalpReadCmos(2)); + Time->Hour = BCD_INT(HalpReadCmos(4)); + Time->Weekday = BCD_INT(HalpReadCmos(6)); + Time->Day = BCD_INT(HalpReadCmos(7)); + Time->Month = BCD_INT(HalpReadCmos(8)); + Time->Year = BCD_INT(HalpReadCmos(9)); + Time->Milliseconds = 0; + + /* FIXME: Check century byte */ + + /* Compensate for the century field */ + Time->Year += (Time->Year > 80) ? 1900: 2000; + + /* FIXME: Release CMOS Lock */ + + /* Always return TRUE */ + return TRUE; +} + +/* + * @implemented + */ +BOOLEAN +NTAPI +HalSetRealTimeClock(IN PTIME_FIELDS Time) +{ + /* FIXME: Acquire CMOS Lock */ + + /* Loop while update is in progress */ + while ((HalpReadCmos(RTC_REGISTER_A)) & RTC_REG_A_UIP); + + /* Write time fields to CMOS RTC */ + HalpWriteCmos(0, INT_BCD(Time->Second)); + HalpWriteCmos(2, INT_BCD(Time->Minute)); + HalpWriteCmos(4, INT_BCD(Time->Hour)); + HalpWriteCmos(6, INT_BCD(Time->Weekday)); + HalpWriteCmos(7, INT_BCD(Time->Day)); + HalpWriteCmos(8, INT_BCD(Time->Month)); + HalpWriteCmos(9, INT_BCD(Time->Year % 100)); + + /* FIXME: Set the century byte */ + + /* FIXME: Release the CMOS Lock */ + + /* Always return TRUE */ + return TRUE; +} + +/* EOF */ diff --git a/reactos/hal/halx86/generic/generic.rbuild b/reactos/hal/halx86/generic/generic.rbuild index aaabc94fcc2..913fc394e84 100644 --- a/reactos/hal/halx86/generic/generic.rbuild +++ b/reactos/hal/halx86/generic/generic.rbuild @@ -6,7 +6,8 @@ beep.c bus.c - dma.c + cmos.c + dma.c drive.c halinit.c isa.c @@ -18,7 +19,6 @@ reboot.c sysbus.c sysinfo.c - time.c timer.c ../include/hal.h diff --git a/reactos/hal/halx86/generic/irql.c b/reactos/hal/halx86/generic/irql.c index f54f646d7fd..b8df560a830 100644 --- a/reactos/hal/halx86/generic/irql.c +++ b/reactos/hal/halx86/generic/irql.c @@ -24,8 +24,8 @@ typedef union USHORT both; struct { - BYTE master; - BYTE slave; + UCHAR master; + UCHAR slave; }; } PIC_MASK; @@ -121,7 +121,7 @@ VOID HalpEndSystemInterrupt(KIRQL Irql) Ki386RestoreFlags(flags); } -VOID STATIC +VOID HalpExecuteIrqs(KIRQL NewIrql) { ULONG IrqLimit, i; @@ -153,7 +153,7 @@ HalpExecuteIrqs(KIRQL NewIrql) } -VOID STATIC +VOID HalpLowerIrql(KIRQL NewIrql) { if (NewIrql >= PROFILE_LEVEL) diff --git a/reactos/hal/halx86/generic/spinlock.c b/reactos/hal/halx86/generic/spinlock.c index b88e269dcc4..2ff00340ef0 100644 --- a/reactos/hal/halx86/generic/spinlock.c +++ b/reactos/hal/halx86/generic/spinlock.c @@ -105,7 +105,7 @@ KfReleaseSpinLock(PKSPIN_LOCK SpinLock, */ KIRQL FASTCALL -KeAcquireQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle) +KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber) { /* Simply raise to dispatch */ return KfRaiseIrql(DISPATCH_LEVEL); @@ -151,7 +151,7 @@ KeAcquireInStackQueuedSpinLockRaiseToSynch(IN PKSPIN_LOCK SpinLock, */ VOID FASTCALL -KeReleaseQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle, +KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql) { /* Simply lower IRQL back */ @@ -174,7 +174,7 @@ KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle) */ BOOLEAN FASTCALL -KeTryToAcquireQueuedSpinLockRaiseToSynch(IN PKLOCK_QUEUE_HANDLE LockHandle, +KeTryToAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN PKIRQL OldIrql) { /* Simply raise to dispatch */ @@ -187,10 +187,10 @@ KeTryToAcquireQueuedSpinLockRaiseToSynch(IN PKLOCK_QUEUE_HANDLE LockHandle, /* * @implemented */ -BOOLEAN +LOGICAL FASTCALL -KeTryToAcquireQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle, - IN PKIRQL OldIrql) +KeTryToAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, + OUT PKIRQL OldIrql) { /* Simply raise to dispatch */ *OldIrql = KfRaiseIrql(DISPATCH_LEVEL); diff --git a/reactos/hal/halx86/generic/time.c b/reactos/hal/halx86/generic/time.c deleted file mode 100644 index aed7d7ec0da..00000000000 --- a/reactos/hal/halx86/generic/time.c +++ /dev/null @@ -1,356 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/hal/x86/time.c - * PURPOSE: Getting time information - * UPDATE HISTORY: - */ - -/* INCLUDES *****************************************************************/ - -#include -#define NDEBUG -#include - - -/* MACROS and CONSTANTS ******************************************************/ - -/* macro BCD_INT : convert bcd to int */ -#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f)) - -/* macro INT_BCD : convert int to bcd */ -#define INT_BCD(int) (((int / 10) << 4) + (int % 10)) - - -#define RTC_REGISTER_A 0x0A -#define RTC_REG_A_UIP 0x80 /* Update In Progress bit */ - -#define RTC_REGISTER_B 0x0B - -#define RTC_REGISTER_CENTURY 0x32 - -/* GLOBALS ******************************************************************/ - -static KSPIN_LOCK CmosLock = {0}; - -/* FUNCTIONS *****************************************************************/ - - -static UCHAR -HalpQueryCMOS(UCHAR Reg) -{ - UCHAR Val; - ULONG Flags; - - Reg |= 0x80; - - /* save flags and disable interrupts */ - Ki386SaveFlags(Flags); - Ki386DisableInterrupts(); - - WRITE_PORT_UCHAR((PUCHAR)0x70, Reg); - Val = READ_PORT_UCHAR((PUCHAR)0x71); - WRITE_PORT_UCHAR((PUCHAR)0x70, 0); - - /* restore flags */ - Ki386RestoreFlags(Flags); - - return(Val); -} - - -static VOID -HalpSetCMOS(UCHAR Reg, - UCHAR Val) -{ - ULONG Flags; - - Reg |= 0x80; - - /* save flags and disable interrupts */ - Ki386SaveFlags(Flags); - Ki386DisableInterrupts(); - - WRITE_PORT_UCHAR((PUCHAR)0x70, Reg); - WRITE_PORT_UCHAR((PUCHAR)0x71, Val); - WRITE_PORT_UCHAR((PUCHAR)0x70, 0); - - /* restore flags */ - Ki386RestoreFlags(Flags); -} - - -static UCHAR -HalpQueryECMOS(USHORT Reg) -{ - UCHAR Val; - ULONG Flags; - - /* save flags and disable interrupts */ - Ki386SaveFlags(Flags); - Ki386DisableInterrupts(); - - WRITE_PORT_UCHAR((PUCHAR)0x74, (UCHAR)(Reg & 0x00FF)); - WRITE_PORT_UCHAR((PUCHAR)0x75, (UCHAR)(Reg>>8)); - Val = READ_PORT_UCHAR((PUCHAR)0x76); - - /* restore flags */ - Ki386RestoreFlags(Flags); - - return(Val); -} - - -static VOID -HalpSetECMOS(USHORT Reg, - UCHAR Val) -{ - ULONG Flags; - - /* save flags and disable interrupts */ - Ki386SaveFlags(Flags); - Ki386DisableInterrupts(); - - WRITE_PORT_UCHAR((PUCHAR)0x74, (UCHAR)(Reg & 0x00FF)); - WRITE_PORT_UCHAR((PUCHAR)0x75, (UCHAR)(Reg>>8)); - WRITE_PORT_UCHAR((PUCHAR)0x76, Val); - - /* restore flags */ - Ki386RestoreFlags(Flags); -} - - -BOOLEAN STDCALL -HalQueryRealTimeClock(PTIME_FIELDS Time) -{ - KIRQL oldIrql; - - KeAcquireSpinLock(&CmosLock, &oldIrql); - - /* check 'Update In Progress' bit */ - while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP); - - Time->Second = BCD_INT(HalpQueryCMOS (0)); - Time->Minute = BCD_INT(HalpQueryCMOS (2)); - Time->Hour = BCD_INT(HalpQueryCMOS (4)); - Time->Weekday = BCD_INT(HalpQueryCMOS (6)); - Time->Day = BCD_INT(HalpQueryCMOS (7)); - Time->Month = BCD_INT(HalpQueryCMOS (8)); - Time->Year = BCD_INT(HalpQueryCMOS (9)); - - if (Time->Year > 80) - Time->Year += 1900; - else - Time->Year += 2000; - -#if 0 - /* Century */ - Time->Year += BCD_INT(HalpQueryCMOS (RTC_REGISTER_CENTURY)) * 100; -#endif - - KeReleaseSpinLock(&CmosLock, oldIrql); - -#ifndef NDEBUG - DbgPrint ("HalQueryRealTimeClock() %d:%d:%d %d/%d/%d\n", - Time->Hour, - Time->Minute, - Time->Second, - Time->Day, - Time->Month, - Time->Year - ); -#endif - - Time->Milliseconds = 0; - return TRUE; -} - - -VOID STDCALL -HalSetRealTimeClock(PTIME_FIELDS Time) -{ - KIRQL oldIrql; - - KeAcquireSpinLock(&CmosLock, &oldIrql); - - /* check 'Update In Progress' bit */ - while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP); - - HalpSetCMOS (0, (UCHAR)INT_BCD(Time->Second)); - HalpSetCMOS (2, (UCHAR)INT_BCD(Time->Minute)); - HalpSetCMOS (4, (UCHAR)INT_BCD(Time->Hour)); - HalpSetCMOS (6, (UCHAR)INT_BCD(Time->Weekday)); - HalpSetCMOS (7, (UCHAR)INT_BCD(Time->Day)); - HalpSetCMOS (8, (UCHAR)INT_BCD(Time->Month)); - HalpSetCMOS (9, (UCHAR)INT_BCD(Time->Year % 100)); - -#if 0 - /* Century */ - HalpSetCMOS (RTC_REGISTER_CENTURY, INT_BCD(Time->Year / 100)); -#endif - KeReleaseSpinLock(&CmosLock, oldIrql); -} - - -BOOLEAN STDCALL -HalGetEnvironmentVariable(PCH Name, - USHORT ValueLength, - PCH Value) -{ - KIRQL oldIrql; - - - if (_stricmp(Name, "LastKnownGood") != 0) - { - return FALSE; - } - - KeAcquireSpinLock(&CmosLock, &oldIrql); - if (HalpQueryCMOS(RTC_REGISTER_B) & 0x01) - { - strncpy(Value, "FALSE", ValueLength); - } - else - { - strncpy(Value, "TRUE", ValueLength); - } - KeReleaseSpinLock(&CmosLock, oldIrql); - - return TRUE; -} - - -BOOLEAN STDCALL -HalSetEnvironmentVariable(PCH Name, - PCH Value) -{ - UCHAR Val; - KIRQL oldIrql; - BOOLEAN result = TRUE; - - if (_stricmp(Name, "LastKnownGood") != 0) - return FALSE; - - KeAcquireSpinLock(&CmosLock, &oldIrql); - - Val = HalpQueryCMOS(RTC_REGISTER_B); - - if (_stricmp(Value, "TRUE") == 0) - HalpSetCMOS(RTC_REGISTER_B, (UCHAR)(Val | 0x01)); - else if (_stricmp(Value, "FALSE") == 0) - HalpSetCMOS(RTC_REGISTER_B, (UCHAR)(Val & ~0x01)); - else - result = FALSE; - - KeReleaseSpinLock(&CmosLock, oldIrql); - - return result; -} - - -ULONG STDCALL -HalpGetCmosData(PBUS_HANDLER BusHandler, - ULONG BusNumber, - ULONG SlotNumber, - PVOID Buffer, - ULONG Offset, - ULONG Length) -{ - PUCHAR Ptr = Buffer; - ULONG Address = SlotNumber; - ULONG Len = Length; - KIRQL oldIrql; - - DPRINT("HalpGetCmosData() called.\n"); - DPRINT(" BusNumber %lu\n", BusNumber); - DPRINT(" SlotNumber %lu\n", SlotNumber); - DPRINT(" Offset 0x%lx\n", Offset); - DPRINT(" Length 0x%lx\n", Length); - - if (Length == 0) - return 0; - - if (BusNumber == 0) - { - /* CMOS */ - KeAcquireSpinLock(&CmosLock, &oldIrql); - while ((Len > 0) && (Address < 0x100)) - { - *Ptr = HalpQueryCMOS((UCHAR)Address); - Ptr = Ptr + 1; - Address++; - Len--; - } - KeReleaseSpinLock(&CmosLock, oldIrql); - } - else if (BusNumber == 1) - { - /* Extended CMOS */ - KeAcquireSpinLock(&CmosLock, &oldIrql); - while ((Len > 0) && (Address < 0x1000)) - { - *Ptr = HalpQueryECMOS((USHORT)Address); - Ptr = Ptr + 1; - Address++; - Len--; - } - KeReleaseSpinLock(&CmosLock, oldIrql); - } - - return(Length - Len); -} - - -ULONG STDCALL -HalpSetCmosData(PBUS_HANDLER BusHandler, - ULONG BusNumber, - ULONG SlotNumber, - PVOID Buffer, - ULONG Offset, - ULONG Length) -{ - PUCHAR Ptr = (PUCHAR)Buffer; - ULONG Address = SlotNumber; - ULONG Len = Length; - KIRQL oldIrql; - - DPRINT("HalpSetCmosData() called.\n"); - DPRINT(" BusNumber %lu\n", BusNumber); - DPRINT(" SlotNumber %lu\n", SlotNumber); - DPRINT(" Offset 0x%lx\n", Offset); - DPRINT(" Length 0x%lx\n", Length); - - if (Length == 0) - return 0; - - if (BusNumber == 0) - { - /* CMOS */ - KeAcquireSpinLock(&CmosLock, &oldIrql); - while ((Len > 0) && (Address < 0x100)) - { - HalpSetCMOS((UCHAR)Address, *Ptr); - Ptr = Ptr + 1; - Address++; - Len--; - } - KeReleaseSpinLock(&CmosLock, oldIrql); - } - else if (BusNumber == 1) - { - /* Extended CMOS */ - KeAcquireSpinLock(&CmosLock, &oldIrql); - while ((Len > 0) && (Address < 0x1000)) - { - HalpSetECMOS((USHORT)Address, *Ptr); - Ptr = Ptr + 1; - Address++; - Len--; - } - KeReleaseSpinLock(&CmosLock, oldIrql); - } - - return(Length - Len); -} - -/* EOF */ diff --git a/reactos/hal/halx86/generic/timer.c b/reactos/hal/halx86/generic/timer.c index b768ecf4b95..fa5788fc13a 100644 --- a/reactos/hal/halx86/generic/timer.c +++ b/reactos/hal/halx86/generic/timer.c @@ -130,11 +130,11 @@ KeStallExecutionProcessor(ULONG Microseconds) if (Pcr->PrcbData.FeatureBits & KF_RDTSC) { LARGE_INTEGER EndCount, CurrentCount; - Ki386RdTSC(EndCount); + EndCount.QuadPart = (LONGLONG)__rdtsc; EndCount.QuadPart += Microseconds * (ULONGLONG)Pcr->PrcbData.MHz; do { - Ki386RdTSC(CurrentCount); + CurrentCount.QuadPart = (LONGLONG)__rdtsc; } while (CurrentCount.QuadPart < EndCount.QuadPart); } @@ -212,10 +212,10 @@ VOID HalpCalibrateStallExecution(VOID) { WaitFor8254Wraparound(); - Ki386RdTSC(StartCount); + StartCount.QuadPart = (LONGLONG)__rdtsc; WaitFor8254Wraparound(); - Ki386RdTSC(EndCount); + EndCount.QuadPart = (LONGLONG)__rdtsc; Pcr->PrcbData.MHz = (ULONG)(EndCount.QuadPart - StartCount.QuadPart) / 10000; DPRINT("%luMHz\n", Pcr->PrcbData.MHz); @@ -334,7 +334,7 @@ KeQueryPerformanceCounter(PLARGE_INTEGER PerformanceFreq) { PerformanceFreq->QuadPart = Pcr->PrcbData.MHz * (ULONGLONG)1000000; } - Ki386RdTSC(Value); + Value.QuadPart = (LONGLONG)__rdtsc; } else { @@ -361,4 +361,12 @@ KeQueryPerformanceCounter(PLARGE_INTEGER PerformanceFreq) return Value; } +ULONG +NTAPI +HalSetTimeIncrement(IN ULONG Increment) +{ + /* FIXME: TODO */ + return Increment; +} + /* EOF */ diff --git a/reactos/hal/halx86/include/hal.h b/reactos/hal/halx86/include/hal.h index 200bd8262a8..ac883c4560d 100644 --- a/reactos/hal/halx86/include/hal.h +++ b/reactos/hal/halx86/include/hal.h @@ -29,6 +29,7 @@ #include #include #include +#include #define KPCR_BASE 0xFF000000 // HACK! diff --git a/reactos/include/ndk/halfuncs.h b/reactos/include/ndk/halfuncs.h index 252bcdaaec5..a4fece2f555 100644 --- a/reactos/include/ndk/halfuncs.h +++ b/reactos/include/ndk/halfuncs.h @@ -162,15 +162,6 @@ HalEndSystemInterrupt( ULONG Vector ); -NTHALAPI -BOOLEAN -NTAPI -HalGetEnvironmentVariable( - PCH Variable, - USHORT Length, - PCH Buffer -); - NTHALAPI VOID NTAPI @@ -202,14 +193,25 @@ HalHandleNMI( // // Environment Functions // +#ifdef _ARC_ NTHALAPI -BOOLEAN +ARC_STATUS NTAPI HalSetEnvironmentVariable( IN PCH Name, IN PCH Value ); +NTHALAPI +ARC_STATUS +NTAPI +HalGetEnvironmentVariable( + IN PCH Variable, + IN USHORT Length, + OUT PCH Buffer +); +#endif + // // Time Functions // @@ -221,7 +223,7 @@ HalQueryRealTimeClock( ); NTHALAPI -VOID +BOOLEAN NTAPI HalSetRealTimeClock( IN PTIME_FIELDS RtcTime diff --git a/reactos/lib/rtl/registry.c b/reactos/lib/rtl/registry.c index 13187519e90..0da9966bba9 100644 --- a/reactos/lib/rtl/registry.c +++ b/reactos/lib/rtl/registry.c @@ -94,11 +94,6 @@ RtlpGetRegistryHandle(IN ULONG RelativeTo, } /* And now append the path */ - DPRINT1("I'm about to crash due to an overwrite problem, Alex thinks\n"); - DPRINT1("I'm about to crash due to a overwrite problem, Alex thinks\n"); - DPRINT1("I'm about to crash due to a overwrite problem, Alex thinks\n"); - DPRINT1("I'm about to crash due to a overwrite problem, Alex thinks\n"); - DPRINT1("I'm about to crash due to a overwrite problem, Alex thinks\n"); if (Path[0] == L'\\' && RelativeTo != RTL_REGISTRY_ABSOLUTE) Path++; // HACK! Status = RtlAppendUnicodeToString(&KeyName, Path); if (!NT_SUCCESS(Status)) return Status;