Added calls to read and write the MSR, the machine state register.
Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14537 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
/*
|
||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
* Copyright 2002-2005, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
* Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _KERNEL_ARCH_x86_CPU_H
|
||||
#define _KERNEL_ARCH_x86_CPU_H
|
||||
|
||||
@@ -10,10 +13,8 @@
|
||||
#include <arch/x86/descriptors.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// MSR registers (possibly Intel specific)
|
||||
#define IA32_MSR_APIC_BASE 0x1b
|
||||
|
||||
struct tss {
|
||||
uint16 prev_task;
|
||||
@@ -32,37 +33,40 @@ struct tss {
|
||||
uint16 io_map_base;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
struct iframe {
|
||||
unsigned int gs;
|
||||
unsigned int fs;
|
||||
unsigned int es;
|
||||
unsigned int ds;
|
||||
unsigned int edi;
|
||||
unsigned int esi;
|
||||
unsigned int ebp;
|
||||
unsigned int esp;
|
||||
unsigned int ebx;
|
||||
unsigned int edx;
|
||||
unsigned int ecx;
|
||||
unsigned int eax;
|
||||
unsigned int orig_eax;
|
||||
unsigned int orig_edx;
|
||||
unsigned int vector;
|
||||
unsigned int error_code;
|
||||
unsigned int eip;
|
||||
unsigned int cs;
|
||||
unsigned int flags;
|
||||
unsigned int user_esp;
|
||||
unsigned int user_ss;
|
||||
uint32 gs;
|
||||
uint32 fs;
|
||||
uint32 es;
|
||||
uint32 ds;
|
||||
uint32 edi;
|
||||
uint32 esi;
|
||||
uint32 ebp;
|
||||
uint32 esp;
|
||||
uint32 ebx;
|
||||
uint32 edx;
|
||||
uint32 ecx;
|
||||
uint32 eax;
|
||||
uint32 orig_eax;
|
||||
uint32 orig_edx;
|
||||
uint32 vector;
|
||||
uint32 error_code;
|
||||
uint32 eip;
|
||||
uint32 cs;
|
||||
uint32 flags;
|
||||
uint32 user_esp;
|
||||
uint32 user_ss;
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define nop() __asm__ ("nop"::)
|
||||
|
||||
struct arch_thread;
|
||||
|
||||
void setup_system_time(unsigned int cv_factor);
|
||||
void setup_system_time(uint32 cv_factor);
|
||||
void i386_context_switch(struct arch_thread *old_state, struct arch_thread *new_state, addr_t new_pgdir);
|
||||
void i386_enter_uspace(addr_t entry, void *args1, void *args2, addr_t ustack_top);
|
||||
void i386_set_tss_and_kstack(addr_t kstack);
|
||||
@@ -74,6 +78,8 @@ void i386_frstor(const void *fpu_state);
|
||||
void i386_fxrstor(const void *fpu_state);
|
||||
void i386_fsave_swap(void *old_fpu_state, const void *new_fpu_state);
|
||||
void i386_fxsave_swap(void *old_fpu_state, const void *new_fpu_state);
|
||||
uint64 x86_read_msr(uint32 register);
|
||||
void x86_write_msr(uint32 register, uint64 value);
|
||||
void x86_set_task_gate(int32 n, int32 segment);
|
||||
struct tss *x86_get_main_tss(void);
|
||||
|
||||
@@ -103,19 +109,19 @@ __asm__ ("outw %%ax,%%dx" : : "a" (value), "d" (port))
|
||||
__asm__ ("outl %%eax,%%dx" : : "a" (value), "d" (port))
|
||||
|
||||
#define in8(port) ({ \
|
||||
unsigned char _v; \
|
||||
uint8 _v; \
|
||||
__asm__ volatile ("inb %%dx,%%al" : "=a" (_v) : "d" (port)); \
|
||||
_v; \
|
||||
})
|
||||
|
||||
#define in16(port) ({ \
|
||||
unsigned short _v; \
|
||||
uint16 _v; \
|
||||
__asm__ volatile ("inw %%dx,%%ax":"=a" (_v) : "d" (port)); \
|
||||
_v; \
|
||||
})
|
||||
|
||||
#define in32(port) ({ \
|
||||
unsigned int _v; \
|
||||
uint32 _v; \
|
||||
__asm__ volatile ("inl %%dx,%%eax":"=a" (_v) : "d" (port)); \
|
||||
_v; \
|
||||
})
|
||||
@@ -127,7 +133,7 @@ __asm__ ("outb %%al,%%dx\n" \
|
||||
"1:" : : "a" (value), "d" (port))
|
||||
|
||||
#define in8_p(port) ({ \
|
||||
unsigned char _v; \
|
||||
uint8 _v; \
|
||||
__asm__ volatile ("inb %%dx,%%al\n" \
|
||||
"\tjmp 1f\n" \
|
||||
"1:\tjmp 1f\n" \
|
||||
|
||||
Reference in New Issue
Block a user