From 54d9d37f9dec9e7a8129706c42389886cd4a02e5 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 3 Jun 2008 04:37:18 +0000 Subject: [PATCH] Added patch by Dustin Howett: header with HPET definitions and (empty) file for hpet implementation. Not yet added to the build. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25773 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/arch/x86/arch_hpet.h | 46 +++++++++++++++++++++ src/system/kernel/arch/x86/Jamfile | 1 + src/system/kernel/arch/x86/arch_hpet.c | 6 +++ 3 files changed, 53 insertions(+) create mode 100644 headers/private/kernel/arch/x86/arch_hpet.h create mode 100644 src/system/kernel/arch/x86/arch_hpet.c diff --git a/headers/private/kernel/arch/x86/arch_hpet.h b/headers/private/kernel/arch/x86/arch_hpet.h new file mode 100644 index 0000000000..4956e15e76 --- /dev/null +++ b/headers/private/kernel/arch/x86/arch_hpet.h @@ -0,0 +1,46 @@ +/* + * Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_x86_HPET_H +#define _KERNEL_ARCH_x86_HPET_H + +/* All masks are 64 bits wide to represent bit locations; + the HPET registers are 64 bits wide. */ + +/* Global Capability Register Masks */ +#define HPET_CAP_MASK_ID 0x00000000000000FF +#define HPET_CAP_MASK_NUMTIMERS 0x0000000000001F00 +#define HPET_CAP_MASK_WIDTH 0x0000000000002000 +#define HPET_CAP_MASK_LEGACY 0x0000000000008000 +#define HPET_CAP_MASK_VENDOR_ID 0x00000000FFFF0000 +#define HPET_CAP_MASK_PERIOD 0xFFFFFFFF00000000 + +/* Retrieve Global Capabilities */ +#define HPET_GET_ID(regs) ((regs)->caps & HPET_CAP_MASK_ID) +#define HPET_GET_NUM_TIMERS(regs) (((regs)->caps & HPET_CAP_MASK_NUMTIMERS) >> 8) +#define HPET_IS_64BIT_CAPABLE(regs) (((regs)->caps & HPET_CAP_MASK_WIDTH) >> 13) +#define HPET_IS_LEGACY_CAPABLE(regs) (((regs)->caps & HPET_CAP_MASK_LEGACY) >> 15) +#define HPET_GET_VENDOR_ID(regs) (((regs)->caps & HPET_CAP_MASK_VENDOR_ID) >> 16) +#define HPET_GET_PERIOD(regs) (((regs)->caps & HPET_CAP_MASK_PERIOD) >> 32) + +struct hpet_timer { + uint64 config, /* Timer configuration and capabilities */ + uint64 comparator, /* Comparator value */ + uint64 introute, /* FSB Interrupt Routing */ + uint64 reserved +}; + +struct hpet_regs { + uint64 caps, /* HPET Capabilities and ID */ + uint64 reserved1, + uint64 config, /* General Configuration */ + uint64 reserved2, + uint64 intstatus, /* General Interrupt Status */ + uint8 reserved3[200], + uint64 mainvalue, /* Main Counter Value */ + uint64 reserved3, + struct hpet_timer timers[1] /* Timers */ +}; + +#endif diff --git a/src/system/kernel/arch/x86/Jamfile b/src/system/kernel/arch/x86/Jamfile index bc76e30b12..3d6090a223 100644 --- a/src/system/kernel/arch/x86/Jamfile +++ b/src/system/kernel/arch/x86/Jamfile @@ -15,6 +15,7 @@ KernelMergeObject kernel_arch_x86.o : arch_debug.cpp arch_debug_console.c arch_elf.c +# arch_hpet.c arch_int.c arch_platform.c # arch_selector.c diff --git a/src/system/kernel/arch/x86/arch_hpet.c b/src/system/kernel/arch/x86/arch_hpet.c new file mode 100644 index 0000000000..90a1c56957 --- /dev/null +++ b/src/system/kernel/arch/x86/arch_hpet.c @@ -0,0 +1,6 @@ +/* + * Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include