mirror of
https://github.com/reactos/reactos.git
synced 2024-07-07 13:15:07 +00:00
- 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
This commit is contained in:
parent
4a33b4c040
commit
596c3bee62
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
304
reactos/hal/halx86/generic/cmos.c
Normal file
304
reactos/hal/halx86/generic/cmos.c
Normal file
|
@ -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 <hal.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* 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 */
|
|
@ -6,6 +6,7 @@
|
|||
<define name="_NTHAL_" />
|
||||
<file>beep.c</file>
|
||||
<file>bus.c</file>
|
||||
<file>cmos.c</file>
|
||||
<file>dma.c</file>
|
||||
<file>drive.c</file>
|
||||
<file>halinit.c</file>
|
||||
|
@ -18,7 +19,6 @@
|
|||
<file>reboot.c</file>
|
||||
<file>sysbus.c</file>
|
||||
<file>sysinfo.c</file>
|
||||
<file>time.c</file>
|
||||
<file>timer.c</file>
|
||||
<pch>../include/hal.h</pch>
|
||||
</module>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 <hal.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
/* 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 */
|
|
@ -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 */
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <halfuncs.h>
|
||||
#include <iofuncs.h>
|
||||
#include <ldrtypes.h>
|
||||
#include <obfuncs.h>
|
||||
|
||||
#define KPCR_BASE 0xFF000000 // HACK!
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue