Nucleus
Barry CPU specific segment c738dbb (3 years, 2 months ago)
#ifndef _NUCLEUS_CPU_H
#define _NUCLEUS_CPU_H
#include <stdint.h>
#include <nucleus/types.h>
typedef unsigned int cpu_t;
/* Structure for CPU specific data */
struct CPUData {
cpu_t id;
Task *task;
};
/* Structure for an Interrupt Frame */
struct InterruptFrame {
uint32_t ds;
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
uint32_t intnum, err;
uint32_t eip, cs, eflags, useresp, ss;
};
typedef void (*exc_handler_t)(struct InterruptFrame *);
typedef void (*int_handler_t)(struct InterruptFrame *);
extern struct CPUData __seg_gs *cpu;
extern int apic;
extern uintptr_t lapicPtr, ioapicPtr;
#define LAPIC(off) (*((uint32_t *) ((uint32_t) lapicPtr + (off))))
#define IOAPIC(off) (*((uint32_t *) ((uint32_t) ioapicPtr + (off))))
extern cpu_t lapicNums[];
#define CPUID (apic ? lapicNums[(cpu_t) (LAPIC(0x20) >> 24)] : 0)
#define MAX_CPUS 2
void register_exception(int num, exc_handler_t addr);
void register_interrupt(int num, int_handler_t addr);
void set_fs_base(uintptr_t base);
void set_gs_base(uintptr_t base);
#endif