* Added missing prototypes for get_eflags() and set_eflags() to arch_system_info.h
* The boot loader now checks the CPU for the cpuid and rdtsc features, which we currently both rely on. * Removed old and no longer used stage2_priv.h header git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15534 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
025e63b08a
commit
484c80abd0
@ -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
|
||||
|
@ -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 <SupportDefs.h>
|
||||
#include <boot/stage2.h>
|
||||
|
||||
|
||||
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 */
|
@ -16,6 +16,7 @@
|
||||
#include <boot/stage2.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <arch_kernel.h>
|
||||
#include <arch_system_info.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user