diff --git a/headers/private/kernel/arch/x86/arch_system_info.h b/headers/private/kernel/arch/x86/arch_system_info.h index c49bae5afa..3575fe869c 100644 --- a/headers/private/kernel/arch/x86/arch_system_info.h +++ b/headers/private/kernel/arch/x86/arch_system_info.h @@ -1,5 +1,5 @@ /* - * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _KERNEL_ARCH_x86_SYSTEM_INFO_H @@ -14,6 +14,9 @@ extern "C" { #endif status_t get_current_cpuid(cpuid_info *info, uint32 eax); +uint32 get_eflags(void); +void set_eflags(uint32 value); + status_t _user_get_cpuid(cpuid_info *info, uint32 eax, uint32 cpu); #ifdef __cplusplus diff --git a/headers/private/kernel/arch/x86/stage2_priv.h b/headers/private/kernel/arch/x86/stage2_priv.h deleted file mode 100644 index 6b90f325e7..0000000000 --- a/headers/private/kernel/arch/x86/stage2_priv.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -** Copyright 2001, Travis Geiselbrecht. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ -#ifndef _STAGE2_PRIV_H -#define _STAGE2_PRIV_H - - -#include -#include - - -extern void clearscreen(void); -extern void kputs(const char *str); -extern int dprintf(const char *fmt, ...); -extern void spin(uint64 microseconds); -extern void execute_n_instructions(int count); -void system_time_setup(long a); -uint64 rdtsc(); -unsigned int get_eflags(void); -void set_eflags(uint32 val); -void cpuid(uint32 selector, uint32 *data); - -//void put_uint_dec(unsigned int a); -//void put_uint_hex(unsigned int a); -//void nmessage(const char *str1, unsigned int a, const char *str2); -//void nmessage2(const char *str1, unsigned int a, const char *str2, unsigned int b, const char *str3); - -#define ROUNDUP(a, b) (((a) + ((b) - 1)) & (~((b) - 1))) -#define ROUNDOWN(a, b) (((a) / (b)) * (b)) - -#define PAGE_SIZE 0x1000 -#define KERNEL_BASE 0x80000000 -#define KERNEL_ENTRY 0x80000080 -#define STACK_SIZE 2 -#define DEFAULT_PAGE_FLAGS (1 | 2) // present/rw -#define SCREEN_WIDTH 80 -#define SCREEN_HEIGHT 24 -#define ADDR_MASK 0xfffff000 - -struct gdt_idt_descr { - uint16 a; - uint32 *b; -} _PACKED; - -// SMP stuff -extern int smp_boot(kernel_args *ka, uint32 kernel_entry); -extern void smp_trampoline(void); -extern void smp_trampoline_end(void); - -#endif /* _STAGE2_PRIV_H */ diff --git a/src/system/boot/platform/bios_ia32/cpu.cpp b/src/system/boot/platform/bios_ia32/cpu.cpp index f4a5bffcc1..757148b271 100644 --- a/src/system/boot/platform/bios_ia32/cpu.cpp +++ b/src/system/boot/platform/bios_ia32/cpu.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -34,6 +35,9 @@ uint32 gTimeConversionFactor; #define TIMER_CLKNUM_HZ (14318180/12) +#define CPUID_EFLAGS (1UL << 21) +#define RDTSC_FEATURE (1UL << 4) + static void calculate_cpu_conversion_factor() @@ -213,7 +217,23 @@ not_so_quick_sample: static status_t check_cpu_features() { - // ToDo: for now + // check the eflags register to see if the cpuid instruction exists + if ((get_eflags() & CPUID_EFLAGS) == 0) { + // it's not set yet, but maybe we can set it manually + set_eflags(get_eflags() | CPUID_EFLAGS); + if ((get_eflags() & CPUID_EFLAGS) == 0) + return B_ERROR; + } + + cpuid_info info; + if (get_current_cpuid(&info, 1) != B_OK) + return B_ERROR; + + if ((info.eax_1.features & RDTSC_FEATURE) == 0) { + // we currently require RDTSC + return B_ERROR; + } + return B_OK; }