mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[HALXBOX] Fix clock drift (#2889)
Add a new rollover table for Original Xbox (base frequency is 1.125000 MHz). This fixes potential time issues in kernel and drivers. CORE-16216
This commit is contained in:
parent
092bc78a42
commit
17c5fb8866
7 changed files with 76 additions and 24 deletions
32
hal/halx86/generic/clock.c
Normal file
32
hal/halx86/generic/clock.c
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS Hardware Abstraction Layer
|
||||||
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
|
* PURPOSE: PIT rollover table
|
||||||
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||||
|
* Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
|
#include <hal.h>
|
||||||
|
|
||||||
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
HALP_ROLLOVER HalpRolloverTable[15] =
|
||||||
|
{
|
||||||
|
{1197, 10032}, /* 1 ms */
|
||||||
|
{2394, 20064},
|
||||||
|
{3591, 30096},
|
||||||
|
{4767, 39952},
|
||||||
|
{5964, 49984},
|
||||||
|
{7161, 60016},
|
||||||
|
{8358, 70048},
|
||||||
|
{9555, 80080},
|
||||||
|
{10731, 89936},
|
||||||
|
{11949, 100144},
|
||||||
|
{13125, 110000},
|
||||||
|
{14322, 120032},
|
||||||
|
{15519, 130064},
|
||||||
|
{16695, 139920},
|
||||||
|
{17892, 149952} /* 15 ms */
|
||||||
|
};
|
|
@ -10,6 +10,7 @@
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <hal.h>
|
#include <hal.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
@ -21,6 +22,8 @@
|
||||||
|
|
||||||
#define PIT_LATCH 0x00
|
#define PIT_LATCH 0x00
|
||||||
|
|
||||||
|
extern HALP_ROLLOVER HalpRolloverTable[15];
|
||||||
|
|
||||||
LARGE_INTEGER HalpLastPerfCounter;
|
LARGE_INTEGER HalpLastPerfCounter;
|
||||||
LARGE_INTEGER HalpPerfCounter;
|
LARGE_INTEGER HalpPerfCounter;
|
||||||
ULONG HalpPerfCounterCutoff;
|
ULONG HalpPerfCounterCutoff;
|
||||||
|
@ -30,29 +33,6 @@ ULONG HalpCurrentRollOver;
|
||||||
ULONG HalpNextMSRate = 14;
|
ULONG HalpNextMSRate = 14;
|
||||||
ULONG HalpLargestClockMS = 15;
|
ULONG HalpLargestClockMS = 15;
|
||||||
|
|
||||||
static struct _HALP_ROLLOVER
|
|
||||||
{
|
|
||||||
ULONG RollOver;
|
|
||||||
ULONG Increment;
|
|
||||||
} HalpRolloverTable[15] =
|
|
||||||
{
|
|
||||||
{1197, 10032},
|
|
||||||
{2394, 20064},
|
|
||||||
{3591, 30096},
|
|
||||||
{4767, 39952},
|
|
||||||
{5964, 49984},
|
|
||||||
{7161, 60016},
|
|
||||||
{8358, 70048},
|
|
||||||
{9555, 80080},
|
|
||||||
{10731, 89936},
|
|
||||||
{11949, 100144},
|
|
||||||
{13125, 110000},
|
|
||||||
{14322, 120032},
|
|
||||||
{15519, 130064},
|
|
||||||
{16695, 139920},
|
|
||||||
{17892, 149952}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS *********************************************************/
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
|
@ -88,7 +68,7 @@ HalpSetTimerRollOver(USHORT RollOver)
|
||||||
TimerControl.BcdMode = FALSE;
|
TimerControl.BcdMode = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Program the PIT to generate a normal rate wave (Mode 3) on channel 0.
|
* Program the PIT to generate a normal rate wave (Mode 2) on channel 0.
|
||||||
* Channel 0 is used for the IRQ0 clock interval timer, and channel
|
* Channel 0 is used for the IRQ0 clock interval timer, and channel
|
||||||
* 1 is used for DRAM refresh.
|
* 1 is used for DRAM refresh.
|
||||||
*
|
*
|
||||||
|
|
|
@ -223,6 +223,12 @@ INIT_FUNCTION VOID NTAPI HalpInitializeClock(VOID);
|
||||||
VOID __cdecl HalpClockInterrupt(VOID);
|
VOID __cdecl HalpClockInterrupt(VOID);
|
||||||
VOID __cdecl HalpProfileInterrupt(VOID);
|
VOID __cdecl HalpProfileInterrupt(VOID);
|
||||||
|
|
||||||
|
typedef struct _HALP_ROLLOVER
|
||||||
|
{
|
||||||
|
ULONG RollOver;
|
||||||
|
ULONG Increment;
|
||||||
|
} HALP_ROLLOVER, *PHALP_ROLLOVER;
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
HalpCalibrateStallExecution(VOID);
|
HalpCalibrateStallExecution(VOID);
|
||||||
|
|
|
@ -9,6 +9,7 @@ list(APPEND MINI_HAL_SOURCE
|
||||||
../legacy/bussupp.c
|
../legacy/bussupp.c
|
||||||
../generic/beep.c
|
../generic/beep.c
|
||||||
../generic/bios.c
|
../generic/bios.c
|
||||||
|
../generic/clock.c
|
||||||
../generic/cmos.c
|
../generic/cmos.c
|
||||||
../generic/dma.c
|
../generic/dma.c
|
||||||
../generic/display.c
|
../generic/display.c
|
||||||
|
|
|
@ -5,6 +5,7 @@ list(APPEND HAL_PIC_ASM_SOURCE
|
||||||
up/pic.S)
|
up/pic.S)
|
||||||
|
|
||||||
list(APPEND HAL_PIC_SOURCE
|
list(APPEND HAL_PIC_SOURCE
|
||||||
|
generic/clock.c
|
||||||
generic/profil.c
|
generic/profil.c
|
||||||
generic/timer.c
|
generic/timer.c
|
||||||
up/halinit_up.c
|
up/halinit_up.c
|
||||||
|
|
|
@ -31,6 +31,7 @@ list(APPEND HAL_XBOX_SOURCE
|
||||||
legacy/halpcat.c
|
legacy/halpcat.c
|
||||||
generic/profil.c
|
generic/profil.c
|
||||||
generic/timer.c
|
generic/timer.c
|
||||||
|
xbox/clock.c
|
||||||
xbox/part_xbox.c
|
xbox/part_xbox.c
|
||||||
xbox/halinit_xbox.c
|
xbox/halinit_xbox.c
|
||||||
xbox/reboot.c
|
xbox/reboot.c
|
||||||
|
|
31
hal/halx86/xbox/clock.c
Normal file
31
hal/halx86/xbox/clock.c
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: Xbox HAL
|
||||||
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
|
* PURPOSE: PIT rollover table
|
||||||
|
* COPYRIGHT: Copyright 2020 Dmitry Borisov (di.sean@protonmail.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
|
#include <hal.h>
|
||||||
|
|
||||||
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
HALP_ROLLOVER HalpRolloverTable[15] =
|
||||||
|
{
|
||||||
|
{1125, 10000}, /* 1 ms */
|
||||||
|
{2250, 20000},
|
||||||
|
{3375, 30000},
|
||||||
|
{4500, 40000},
|
||||||
|
{5625, 50000},
|
||||||
|
{6750, 60000},
|
||||||
|
{7875, 70000},
|
||||||
|
{9000, 80000},
|
||||||
|
{10125, 90000},
|
||||||
|
{11250, 100000},
|
||||||
|
{12375, 110000},
|
||||||
|
{13500, 120000},
|
||||||
|
{14625, 130000},
|
||||||
|
{15750, 140000},
|
||||||
|
{16875, 150000} /* 15 ms */
|
||||||
|
};
|
Loading…
Reference in a new issue