mirror of
https://github.com/0Nera/BMOSP.git
synced 2024-12-23 14:26:50 +03:00
Поддержка обработки прерываний в модулях
This commit is contained in:
parent
e36201c412
commit
cc7c21f0fd
@ -98,7 +98,7 @@ void mod_init( ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
module_info_t (*module_init)(env_t * env) =
|
||||
module_info_t (*module_init)(env_t *env) =
|
||||
(module_info_t(*)(env_t * env)) elf_entry((elf64_header_t *)module_ptr->address);
|
||||
|
||||
LOG("\t->Точка входа: 0x%x\n", module_init);
|
||||
@ -115,6 +115,13 @@ void mod_init( ) {
|
||||
module_list[modules_count].data_size = ret.data_size;
|
||||
|
||||
if (ret.data_size != 0) { module_list[modules_count].data = ret.data; }
|
||||
if (ret.irq != 0) {
|
||||
if (ret.irq_handler != 0) {
|
||||
LOG("Установлен обработчик прерывания [%u] по адресу 0x%x в модуле %s\n", ret.irq, ret.irq_handler,
|
||||
ret.name);
|
||||
idt_set_int(ret.irq, ret.irq_handler);
|
||||
}
|
||||
}
|
||||
|
||||
modules_count++;
|
||||
}
|
||||
|
@ -45,4 +45,34 @@ static void *realloc(void *addr, size_t size) {
|
||||
return new_addr;
|
||||
}
|
||||
|
||||
static inline void outb(uint16_t port, uint8_t val) {
|
||||
asm volatile("outb %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
||||
static inline uint8_t inb(uint16_t port) {
|
||||
uint8_t ret;
|
||||
asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void outw(uint16_t port, uint16_t val) {
|
||||
asm volatile("outw %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
||||
static inline uint16_t inw(uint16_t port) {
|
||||
uint16_t ret;
|
||||
asm volatile("inw %1, %0" : "=a"(ret) : "Nd"(port));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint32_t inl(uint16_t port) {
|
||||
uint32_t data;
|
||||
asm volatile("inl %1, %0" : "=a"(data) : "Nd"(port));
|
||||
return data;
|
||||
}
|
||||
|
||||
static inline void outl(uint16_t port, uint32_t data) {
|
||||
asm volatile("outl %0, %1" : : "a"(data), "Nd"(port));
|
||||
}
|
||||
|
||||
#endif // system.h
|
||||
|
@ -54,6 +54,33 @@ typedef struct {
|
||||
uint8_t second;
|
||||
} time_t;
|
||||
|
||||
struct frame {
|
||||
uint64_t rbp;
|
||||
uint64_t rbx;
|
||||
uint64_t r15;
|
||||
uint64_t r14;
|
||||
uint64_t r13;
|
||||
uint64_t r12;
|
||||
uint64_t r11;
|
||||
uint64_t r10;
|
||||
uint64_t r9;
|
||||
uint64_t r8;
|
||||
uint64_t rax;
|
||||
uint64_t rcx;
|
||||
uint64_t rdx;
|
||||
uint64_t rsi;
|
||||
uint64_t rdi;
|
||||
uint64_t int_number;
|
||||
uint64_t err;
|
||||
uint64_t rip;
|
||||
uint64_t cs;
|
||||
uint64_t rflags;
|
||||
uint64_t rsp;
|
||||
uint64_t ss;
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef void (*int_entry_t)(struct frame *state);
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
char *message;
|
||||
@ -62,11 +89,14 @@ typedef struct {
|
||||
void *data;
|
||||
int64_t err_code;
|
||||
uint64_t module_id;
|
||||
uint8_t irq;
|
||||
int_entry_t irq_handler;
|
||||
void *(*get_func)(uint64_t id);
|
||||
} __attribute__((packed)) module_info_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t offset;
|
||||
void (*fb_printf)(char *str, ...); // Временная функция
|
||||
void (*fb_printf)(char *str, ...);
|
||||
framebuffer_t *(*alloc_framebuffer)( );
|
||||
void (*free_framebuffer)(framebuffer_t *frame);
|
||||
void *(*alloc)(uint64_t size);
|
||||
@ -75,6 +105,7 @@ typedef struct {
|
||||
int (*get_error)( );
|
||||
sys_info_t *(*get_info)( );
|
||||
module_info_t *(*get_module)(char *module_id);
|
||||
void *(*get_module_func)(char *module_id, uint64_t func_id);
|
||||
uint64_t (*new_thread)(uint64_t func);
|
||||
int (*delete_thread)(uint64_t thread_id);
|
||||
time_t (*get_time)( );
|
||||
|
Loading…
Reference in New Issue
Block a user