mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 06:33:01 +00:00
Added CMOS configuration space handler.
svn path=/trunk/; revision=2130
This commit is contained in:
parent
4032632974
commit
cad3eb8c42
3 changed files with 203 additions and 62 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: bus.c,v 1.8 2001/06/13 22:17:01 ekohl Exp $
|
/* $Id: bus.c,v 1.9 2001/08/01 10:39:50 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -160,8 +160,8 @@ HalpInitBusHandlers(VOID)
|
||||||
0);
|
0);
|
||||||
if (BusHandler == NULL)
|
if (BusHandler == NULL)
|
||||||
return;
|
return;
|
||||||
// BusHandler->GetBusData = (pGetSetBusData)HalpGetCmosData;
|
BusHandler->GetBusData = (pGetSetBusData)HalpGetCmosData;
|
||||||
// BusHandler->SetBusData = (pGetSetBusData)HalpSetCmosData;
|
BusHandler->SetBusData = (pGetSetBusData)HalpSetCmosData;
|
||||||
|
|
||||||
/* add isa bus handler */
|
/* add isa bus handler */
|
||||||
BusHandler = HalpAllocateBusHandler(Isa,
|
BusHandler = HalpAllocateBusHandler(Isa,
|
||||||
|
|
|
@ -11,8 +11,9 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <internal/hal/mps.h>
|
#include <internal/hal/mps.h>
|
||||||
|
#include <internal/hal/bus.h>
|
||||||
|
|
||||||
#define NDEBUG
|
//#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* MACROS and CONSTANTS ******************************************************/
|
/* MACROS and CONSTANTS ******************************************************/
|
||||||
|
@ -35,10 +36,10 @@
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
|
||||||
static BYTE
|
static UCHAR
|
||||||
HalQueryCMOS (BYTE Reg)
|
HalpQueryCMOS(UCHAR Reg)
|
||||||
{
|
{
|
||||||
BYTE Val;
|
UCHAR Val;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
|
|
||||||
Reg |= 0x80;
|
Reg |= 0x80;
|
||||||
|
@ -54,7 +55,8 @@ HalQueryCMOS (BYTE Reg)
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
HalSetCMOS (BYTE Reg, BYTE Val)
|
HalpSetCMOS(UCHAR Reg,
|
||||||
|
UCHAR Val)
|
||||||
{
|
{
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
|
|
||||||
|
@ -68,20 +70,52 @@ HalSetCMOS (BYTE Reg, BYTE Val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static UCHAR
|
||||||
|
HalpQueryECMOS(USHORT Reg)
|
||||||
|
{
|
||||||
|
UCHAR Val;
|
||||||
|
ULONG Flags;
|
||||||
|
|
||||||
|
pushfl(Flags);
|
||||||
|
__asm__("cli\n"); // AP unsure as to whether to do this here
|
||||||
|
WRITE_PORT_UCHAR((PUCHAR)0x74, (UCHAR)(Reg & 0x00FF));
|
||||||
|
WRITE_PORT_UCHAR((PUCHAR)0x75, (UCHAR)(Reg>>8));
|
||||||
|
Val = READ_PORT_UCHAR((PUCHAR)0x76);
|
||||||
|
popfl(Flags);
|
||||||
|
|
||||||
|
return(Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
HalpSetECMOS(USHORT Reg,
|
||||||
|
UCHAR Val)
|
||||||
|
{
|
||||||
|
ULONG Flags;
|
||||||
|
|
||||||
|
pushfl(Flags);
|
||||||
|
__asm__("cli\n"); // AP unsure as to whether to do this here
|
||||||
|
WRITE_PORT_UCHAR((PUCHAR)0x74, (UCHAR)(Reg & 0x00FF));
|
||||||
|
WRITE_PORT_UCHAR((PUCHAR)0x75, (UCHAR)(Reg>>8));
|
||||||
|
WRITE_PORT_UCHAR((PUCHAR)0x76, Val);
|
||||||
|
popfl(Flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
HalQueryRealTimeClock(PTIME_FIELDS Time)
|
HalQueryRealTimeClock(PTIME_FIELDS Time)
|
||||||
{
|
{
|
||||||
/* check 'Update In Progress' bit */
|
/* check 'Update In Progress' bit */
|
||||||
while (HalQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP)
|
while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP)
|
||||||
;
|
;
|
||||||
|
|
||||||
Time->Second = BCD_INT(HalQueryCMOS (0));
|
Time->Second = BCD_INT(HalpQueryCMOS (0));
|
||||||
Time->Minute = BCD_INT(HalQueryCMOS (2));
|
Time->Minute = BCD_INT(HalpQueryCMOS (2));
|
||||||
Time->Hour = BCD_INT(HalQueryCMOS (4));
|
Time->Hour = BCD_INT(HalpQueryCMOS (4));
|
||||||
Time->Weekday = BCD_INT(HalQueryCMOS (6));
|
Time->Weekday = BCD_INT(HalpQueryCMOS (6));
|
||||||
Time->Day = BCD_INT(HalQueryCMOS (7));
|
Time->Day = BCD_INT(HalpQueryCMOS (7));
|
||||||
Time->Month = BCD_INT(HalQueryCMOS (8));
|
Time->Month = BCD_INT(HalpQueryCMOS (8));
|
||||||
Time->Year = BCD_INT(HalQueryCMOS (9));
|
Time->Year = BCD_INT(HalpQueryCMOS (9));
|
||||||
|
|
||||||
if (Time->Year > 80)
|
if (Time->Year > 80)
|
||||||
Time->Year += 1900;
|
Time->Year += 1900;
|
||||||
|
@ -90,7 +124,7 @@ HalQueryRealTimeClock(PTIME_FIELDS Time)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Century */
|
/* Century */
|
||||||
Time->Year += BCD_INT(HalQueryCMOS (RTC_REGISTER_CENTURY)) * 100;
|
Time->Year += BCD_INT(HalpQueryCMOS (RTC_REGISTER_CENTURY)) * 100;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -112,20 +146,20 @@ VOID STDCALL
|
||||||
HalSetRealTimeClock(PTIME_FIELDS Time)
|
HalSetRealTimeClock(PTIME_FIELDS Time)
|
||||||
{
|
{
|
||||||
/* check 'Update In Progress' bit */
|
/* check 'Update In Progress' bit */
|
||||||
while (HalQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP)
|
while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP)
|
||||||
;
|
;
|
||||||
|
|
||||||
HalSetCMOS (0, INT_BCD(Time->Second));
|
HalpSetCMOS (0, INT_BCD(Time->Second));
|
||||||
HalSetCMOS (2, INT_BCD(Time->Minute));
|
HalpSetCMOS (2, INT_BCD(Time->Minute));
|
||||||
HalSetCMOS (4, INT_BCD(Time->Hour));
|
HalpSetCMOS (4, INT_BCD(Time->Hour));
|
||||||
HalSetCMOS (6, INT_BCD(Time->Weekday));
|
HalpSetCMOS (6, INT_BCD(Time->Weekday));
|
||||||
HalSetCMOS (7, INT_BCD(Time->Day));
|
HalpSetCMOS (7, INT_BCD(Time->Day));
|
||||||
HalSetCMOS (8, INT_BCD(Time->Month));
|
HalpSetCMOS (8, INT_BCD(Time->Month));
|
||||||
HalSetCMOS (9, INT_BCD(Time->Year % 100));
|
HalpSetCMOS (9, INT_BCD(Time->Year % 100));
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Century */
|
/* Century */
|
||||||
HalSetCMOS (RTC_REGISTER_CENTURY, INT_BCD(Time->Year / 100));
|
HalpSetCMOS (RTC_REGISTER_CENTURY, INT_BCD(Time->Year / 100));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +174,7 @@ HalGetEnvironmentVariable(PCH Name,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HalQueryCMOS(RTC_REGISTER_B) & 0x01)
|
if (HalpQueryCMOS(RTC_REGISTER_B) & 0x01)
|
||||||
{
|
{
|
||||||
strncpy(Value, "FALSE", ValueLength);
|
strncpy(Value, "FALSE", ValueLength);
|
||||||
}
|
}
|
||||||
|
@ -160,24 +194,114 @@ HalSetEnvironmentVariable(PCH Name,
|
||||||
UCHAR Val;
|
UCHAR Val;
|
||||||
|
|
||||||
if (_stricmp(Name, "LastKnownGood") != 0)
|
if (_stricmp(Name, "LastKnownGood") != 0)
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
Val = HalQueryCMOS(RTC_REGISTER_B);
|
Val = HalpQueryCMOS(RTC_REGISTER_B);
|
||||||
|
|
||||||
if (_stricmp(Value, "TRUE") == 0)
|
if (_stricmp(Value, "TRUE") == 0)
|
||||||
{
|
HalpSetCMOS(RTC_REGISTER_B, Val | 0x01);
|
||||||
HalSetCMOS(RTC_REGISTER_B, Val | 0x01);
|
|
||||||
}
|
|
||||||
else if (_stricmp(Value, "FALSE") == 0)
|
else if (_stricmp(Value, "FALSE") == 0)
|
||||||
{
|
HalpSetCMOS(RTC_REGISTER_B, Val & ~0x01);
|
||||||
HalSetCMOS(RTC_REGISTER_B, Val & ~0x01);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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 */
|
||||||
|
while ((Len > 0) && (Address < 0x100))
|
||||||
|
{
|
||||||
|
*Ptr = HalpQueryCMOS((UCHAR)Address);
|
||||||
|
Ptr = Ptr + 1;
|
||||||
|
Address++;
|
||||||
|
Len--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (BusNumber == 1)
|
||||||
|
{
|
||||||
|
/* Extended CMOS */
|
||||||
|
while ((Len > 0) && (Address < 0x1000))
|
||||||
|
{
|
||||||
|
*Ptr = HalpQueryECMOS((USHORT)Address);
|
||||||
|
Ptr = Ptr + 1;
|
||||||
|
Address++;
|
||||||
|
Len--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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 */
|
||||||
|
while ((Len > 0) && (Address < 0x100))
|
||||||
|
{
|
||||||
|
HalpSetCMOS((UCHAR)Address, *Ptr);
|
||||||
|
Ptr = Ptr + 1;
|
||||||
|
Address++;
|
||||||
|
Len--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (BusNumber == 1)
|
||||||
|
{
|
||||||
|
/* Extended CMOS */
|
||||||
|
while ((Len > 0) && (Address < 0x1000))
|
||||||
|
{
|
||||||
|
HalpSetECMOS((USHORT)Address, *Ptr);
|
||||||
|
Ptr = Ptr + 1;
|
||||||
|
Address++;
|
||||||
|
Len--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Length - Len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
|
@ -99,6 +99,23 @@ HalpTranslateIsaBusAddress(PBUS_HANDLER BusHandler,
|
||||||
PULONG AddressSpace,
|
PULONG AddressSpace,
|
||||||
PPHYSICAL_ADDRESS TranslatedAddress);
|
PPHYSICAL_ADDRESS TranslatedAddress);
|
||||||
|
|
||||||
|
/* time.c */
|
||||||
|
ULONG STDCALL
|
||||||
|
HalpGetCmosData(PBUS_HANDLER BusHandler,
|
||||||
|
ULONG BusNumber,
|
||||||
|
ULONG SlotNumber,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG Offset,
|
||||||
|
ULONG Length);
|
||||||
|
|
||||||
|
ULONG STDCALL
|
||||||
|
HalpSetCmosData(PBUS_HANDLER BusHandler,
|
||||||
|
ULONG BusNumber,
|
||||||
|
ULONG SlotNumber,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG Offset,
|
||||||
|
ULONG Length);
|
||||||
|
|
||||||
#endif /* __INTERNAL_HAL_BUS_H */
|
#endif /* __INTERNAL_HAL_BUS_H */
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
Loading…
Add table
Add a link
Reference in a new issue