boot/x86: move HPET initialization to arch folder

Change-Id: Iac3f4923f132c4c3328fde5af1dad75af5b2efbd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4864
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
David Karoly 2022-01-13 14:16:53 +01:00 committed by Adrien Destugues
parent 8d743ebd60
commit 367beefadc
7 changed files with 31 additions and 72 deletions

View File

@ -2,8 +2,8 @@
* Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef HPET_H
#define HPET_H
#ifndef BOOT_ARCH_HPET_H
#define BOOT_ARCH_HPET_H
#include <SupportDefs.h>
#include <arch/x86/arch_hpet.h>
@ -18,4 +18,4 @@ void hpet_init(void);
}
#endif
#endif /* HPET_H */
#endif /* BOOT_ARCH_HPET_H */

View File

@ -5,6 +5,8 @@ local defines = $(DEFINES) ;
local platform ;
for platform in [ MultiBootSubDirSetup bios_ia32 efi pxe_ia32 ] {
on $(platform) {
SubDirHdrs $(HAIKU_TOP) src system boot platform $(TARGET_BOOT_PLATFORM) ;
DEFINES = $(defines) ;
DEFINES += _BOOT_MODE ;
@ -43,6 +45,7 @@ for platform in [ MultiBootSubDirSetup bios_ia32 efi pxe_ia32 ] {
$(kernelLibArchSpecificSources)
$(librootOsArchSources)
arch_cpu.cpp
arch_hpet.cpp
: -std=c++11 # additional flags
;

View File

@ -1,4 +1,7 @@
/*
* Copyright 2021 Haiku, Inc. All rights reserved.
* Released under the terms of the MIT License.
*
* Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved.
* Distributed under the terms of the MIT License.
*
@ -7,27 +10,24 @@
*/
#include "mmu.h"
#include "acpi.h"
#include "hpet.h"
#include "mmu.h"
#include <KernelExport.h>
#include <kernel.h>
#include <safemode.h>
#include <boot/stage2.h>
#include <boot/menu.h>
#include <arch/x86/arch_acpi.h>
#include <arch/x86/arch_hpet.h>
#include <arch/x86/arch_system_info.h>
#include <boot/arch/x86/arch_cpu.h>
#include <boot/arch/x86/arch_hpet.h>
#include <kernel/arch/x86/arch_acpi.h>
#include <kernel/arch/x86/arch_hpet.h>
#include <string.h>
//#define TRACE_HPET
#ifdef TRACE_HPET
# define TRACE(x) dprintf x
# define TRACE(x...) dprintf(x)
#else
# define TRACE(x) ;
# define TRACE(x...) ;
#endif
@ -35,21 +35,23 @@ void
hpet_init(void)
{
// Try to find the HPET ACPI table.
TRACE(("hpet_init: Looking for HPET...\n"));
TRACE("hpet_init: Looking for HPET...\n");
acpi_hpet *hpet = (acpi_hpet *)acpi_find_table(ACPI_HPET_SIGNATURE);
// Clear hpet kernel args to known invalid state;
gKernelArgs.arch_args.hpet_phys = 0;
gKernelArgs.arch_args.hpet = NULL;
if (hpet == NULL) {
// No HPET table in the RSDT.
// Since there are no other methods for finding it,
// assume we don't have one.
TRACE(("hpet_init: HPET not found.\n"));
gKernelArgs.arch_args.hpet_phys = 0;
gKernelArgs.arch_args.hpet = NULL;
TRACE("hpet_init: HPET not found.\n");
return;
}
TRACE(("hpet_init: found HPET at 0x%" B_PRIx64 ".\n",
hpet->hpet_address.address));
TRACE("hpet_init: found HPET at 0x%" B_PRIx64 ".\n",
hpet->hpet_address.address);
gKernelArgs.arch_args.hpet_phys = hpet->hpet_address.address;
gKernelArgs.arch_args.hpet = (void *)mmu_map_physical_memory(
gKernelArgs.arch_args.hpet_phys, B_PAGE_SIZE, kDefaultPageFlags);

View File

@ -40,7 +40,6 @@ for platform in [ MultiBootSubDirSetup bios_ia32 ] {
support.S
video.cpp
apm.cpp
hpet.cpp
interrupts.cpp
interrupts_asm.S
long.cpp

View File

@ -11,6 +11,7 @@
#include <arch/x86/arch_cpu.h>
#include <boot/arch/x86/arch_cpu.h>
#include <boot/arch/x86/arch_hpet.h>
#include <boot/platform.h>
#include <boot/heap.h>
#include <boot/stage2.h>
@ -21,7 +22,6 @@
#include "console.h"
#include "cpu.h"
#include "debug.h"
#include "hpet.h"
#include "interrupts.h"
#include "keyboard.h"
#include "long.h"

View File

@ -1,63 +1,19 @@
/*
* Copyright 2021 Haiku, Inc. All rights reserved.
* Released under the terms of the MIT License.
*
* Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Copyright 2001, Travis Geiselbrecht. All rights reserved.
* Distributed under the terms of the NewOS License.
*/
*/
#include "arch_timer.h"
#include "mmu.h"
#include "acpi.h"
#include <KernelExport.h>
#include <SupportDefs.h>
#include <kernel.h>
#include <safemode.h>
#include <boot/stage2.h>
#include <boot/menu.h>
#include <boot/arch/x86/arch_cpu.h>
#include <arch/x86/arch_acpi.h>
#include <arch/x86/arch_hpet.h>
#include <arch/x86/arch_system_info.h>
#include <string.h>
//#define TRACE_TIMER
#ifdef TRACE_TIMER
# define TRACE(x) dprintf x
#else
# define TRACE(x) ;
#endif
static void
hpet_init(void)
{
// Try to find the HPET ACPI table.
TRACE(("hpet_init: Looking for HPET...\n"));
acpi_hpet *hpet = (acpi_hpet *)acpi_find_table(ACPI_HPET_SIGNATURE);
// Clear hpet kernel args to known invalid state;
gKernelArgs.arch_args.hpet_phys = 0;
gKernelArgs.arch_args.hpet = NULL;
if (hpet == NULL) {
// No HPET table in the RSDT.
// Since there are no other methods for finding it,
// assume we don't have one.
TRACE(("hpet_init: HPET not found.\n"));
return;
}
TRACE(("hpet_init: found HPET at %x.\n", hpet->hpet_address.address));
gKernelArgs.arch_args.hpet_phys = hpet->hpet_address.address;
gKernelArgs.arch_args.hpet = (void *)mmu_map_physical_memory(
gKernelArgs.arch_args.hpet_phys, B_PAGE_SIZE, EfiACPIReclaimMemory);
}
#include <boot/arch/x86/arch_hpet.h>
void

View File

@ -33,7 +33,6 @@ local bios_ia32_src =
smp.cpp
support.S
video.cpp
hpet.cpp
apm.cpp
interrupts.cpp
interrupts_asm.S