1/* 2 * Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Copyright 2001, Travis Geiselbrecht. All rights reserved. 6 * Distributed under the terms of the NewOS License. 7*/ 8 9 10#include "mmu.h" 11#include "acpi.h" 12#include "hpet.h" 13 14#include <KernelExport.h> 15 16#include <kernel.h> 17#include <safemode.h> 18#include <boot/stage2.h> 19#include <boot/menu.h> 20#include <arch/x86/arch_acpi.h> 21#include <arch/x86/arch_hpet.h> 22#include <arch/x86/arch_system_info.h> 23 24#include <string.h> 25 26//#define TRACE_HPET 27#ifdef TRACE_HPET 28# define TRACE(x) dprintf x 29#else 30# define TRACE(x) ; 31#endif 32 33 34void 35hpet_init(void) 36{ 37 // Try to find the HPET ACPI table. 38 TRACE(("hpet_init: Looking for HPET...\n")); 39 acpi_hpet *hpet = (acpi_hpet *)acpi_find_table(ACPI_HPET_SIGNATURE); 40 41 if (hpet == NULL) { 42 // No HPET table in the RSDT. 43 // Since there are no other methods for finding it, 44 // assume we don't have one. 45 TRACE(("hpet_init: HPET not found.\n")); 46 gKernelArgs.arch_args.hpet_phys = 0; 47 gKernelArgs.arch_args.hpet = NULL; 48 return; 49 } 50 51 TRACE(("hpet_init: found HPET at %x.\n", hpet->hpet_address.address)); 52 gKernelArgs.arch_args.hpet_phys = hpet->hpet_address.address; 53 gKernelArgs.arch_args.hpet = (void *)mmu_map_physical_memory( 54 gKernelArgs.arch_args.hpet_phys, B_PAGE_SIZE, kDefaultPageFlags); 55} 56