x86_64: rename struct cpu_context; move to machine/cpu.h
This commit is contained in:
@@ -11,6 +11,8 @@ extern "C" {
|
||||
|
||||
#define NR_IDT_ENTRIES 256
|
||||
|
||||
struct ml_cpu_context;
|
||||
|
||||
enum irq_vector {
|
||||
IRQ0 = 32,
|
||||
IRQ1,
|
||||
@@ -35,13 +37,6 @@ struct irq_hook {
|
||||
int (*irq_callback)(void);
|
||||
};
|
||||
|
||||
struct cpu_context {
|
||||
uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
|
||||
uint64_t rdi, rsi, rbp, unused_rsp, rbx, rdx, rcx, rax;
|
||||
uint64_t int_no, err_no;
|
||||
uint64_t rip, cs, rflags, rsp, ss;
|
||||
} __packed;
|
||||
|
||||
struct idt_entry {
|
||||
uint16_t base_low;
|
||||
uint16_t selector;
|
||||
@@ -64,7 +59,7 @@ struct idt_ptr {
|
||||
uintptr_t i_base;
|
||||
} __packed;
|
||||
|
||||
typedef void (*int_hook)(struct cpu_context *);
|
||||
typedef void (*int_hook)(struct ml_cpu_context *);
|
||||
|
||||
extern int idt_init(struct idt_ptr *idtp);
|
||||
extern int idt_load(struct idt_ptr *idtp);
|
||||
|
||||
@@ -27,6 +27,13 @@ typedef struct ml_cpu_block {
|
||||
struct cpu_data *c_data;
|
||||
} ml_cpu_block;
|
||||
|
||||
struct ml_cpu_context {
|
||||
uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
|
||||
uint64_t rdi, rsi, rbp, unused_rsp, rbx, rdx, rcx, rax;
|
||||
uint64_t int_no, err_no;
|
||||
uint64_t rip, cs, rflags, rsp, ss;
|
||||
} __packed;
|
||||
|
||||
#define ml_cpu_pause() __asm__ __volatile__("hlt")
|
||||
#define ml_cpu_relax() __asm__ __volatile__("pause")
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct cpu_context;
|
||||
struct ml_cpu_context;
|
||||
|
||||
extern void ml_print_cpu_state(struct cpu_context *ctx);
|
||||
extern void ml_print_cpu_state(struct ml_cpu_context *ctx);
|
||||
extern void ml_print_stack_trace(uintptr_t ip);
|
||||
extern void ml_print_stack_trace_irq(struct cpu_context *ctx);
|
||||
extern void ml_print_stack_trace_irq(struct ml_cpu_context *ctx);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,7 @@ static void set_idt_gate(
|
||||
idt->i_entries[index].reserved = 0;
|
||||
}
|
||||
|
||||
static void gpf_handler(struct cpu_context *regs)
|
||||
static void gpf_handler(struct ml_cpu_context *regs)
|
||||
{
|
||||
int ext = regs->err_no & 1;
|
||||
int table = (regs->err_no >> 1) & 0x03;
|
||||
@@ -55,7 +55,7 @@ static void gpf_handler(struct cpu_context *regs)
|
||||
regs->rip);
|
||||
}
|
||||
|
||||
static void pf_handler(struct cpu_context *regs)
|
||||
static void pf_handler(struct ml_cpu_context *regs)
|
||||
{
|
||||
panic_irq(
|
||||
regs,
|
||||
@@ -141,7 +141,7 @@ int idt_load(struct idt_ptr *ptr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void isr_dispatch(struct cpu_context *regs)
|
||||
void isr_dispatch(struct ml_cpu_context *regs)
|
||||
{
|
||||
int_hook h = isr_handlers[regs->int_no];
|
||||
if (h) {
|
||||
@@ -160,7 +160,7 @@ void irq_ack(unsigned int vec)
|
||||
outportb(0x20, 0x20);
|
||||
}
|
||||
|
||||
void irq_dispatch(struct cpu_context *regs)
|
||||
void irq_dispatch(struct ml_cpu_context *regs)
|
||||
{
|
||||
end_charge_period();
|
||||
|
||||
@@ -178,7 +178,7 @@ void irq_dispatch(struct cpu_context *regs)
|
||||
start_charge_period();
|
||||
}
|
||||
|
||||
void syscall_dispatch(struct cpu_context *regs)
|
||||
void syscall_dispatch(struct ml_cpu_context *regs)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ static void print_rflags(uintptr_t rflags)
|
||||
printk(buf);
|
||||
}
|
||||
|
||||
void ml_print_cpu_state(struct cpu_context *ctx)
|
||||
void ml_print_cpu_state(struct ml_cpu_context *ctx)
|
||||
{
|
||||
printk("cpu state:");
|
||||
if (ctx) {
|
||||
@@ -173,7 +173,7 @@ void ml_print_stack_trace(uintptr_t ip)
|
||||
print_stack_trace(ip, bp);
|
||||
}
|
||||
|
||||
void ml_print_stack_trace_irq(struct cpu_context *ctx)
|
||||
void ml_print_stack_trace_irq(struct ml_cpu_context *ctx)
|
||||
{
|
||||
print_stack_trace(ctx->rip, (uintptr_t *)ctx->rbp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user