Organize interrupts

This commit is contained in:
Alex Kotov 2022-06-24 00:45:42 +03:00
parent 040693e30a
commit 67fec262e9
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
11 changed files with 43 additions and 47 deletions

View File

@ -24,16 +24,4 @@
#define GDT_USER_DS_SELECTOR (GDT_SEGMENT_SELECTOR(GDT_USER_DS_INDEX) | 3)
#define GDT_TSS_SELECTOR GDT_SEGMENT_SELECTOR(GDT_TSS_INDEX)
#define INT_EXCEPTION_COUNT 32
#define INT_HWINT_COUNT 16
#define INT_TOTAL_COUNT (INT_EXCEPTION_COUNT + INT_HWINT_COUNT)
#define INT_EXCEPTION_FIRST 0
#define INT_EXCEPTION_LAST (INT_EXCEPTION_FIRST + INT_EXCEPTION_COUNT - 1)
#define INT_HWINT_FIRST (INT_EXCEPTION_LAST + 1)
#define INT_HWINT_LAST (INT_HWINT_FIRST + INT_HWINT_COUNT - 1)
#define INT_SYSCALL 0x80
#endif

View File

@ -0,0 +1,16 @@
#ifndef KERNEL_INCLUDED_INTERRUPTS_CONFIG
#define KERNEL_INCLUDED_INTERRUPTS_CONFIG 1
#define INT_EXCEPTION_COUNT 32
#define INT_HWINT_COUNT 16
#define INT_TOTAL_COUNT (INT_EXCEPTION_COUNT + INT_HWINT_COUNT)
#define INT_EXCEPTION_FIRST 0
#define INT_EXCEPTION_LAST (INT_EXCEPTION_FIRST + INT_EXCEPTION_COUNT - 1)
#define INT_HWINT_FIRST (INT_EXCEPTION_LAST + 1)
#define INT_HWINT_LAST (INT_HWINT_FIRST + INT_HWINT_COUNT - 1)
#define INT_SYSCALL 0x80
#endif

View File

@ -1,5 +1,4 @@
#include "main.h"
#include "../config.h"
#include "../panic.h"
#include <kernaux/drivers/console.h>

View File

@ -1,7 +1,4 @@
#include "hwint.h"
#include "main.h"
#include "../config.h"
#include <kernaux/drivers/console.h>
#include <kernaux/drivers/intel_8259_pic.h>

View File

@ -1,9 +0,0 @@
#ifndef KERNEL_INCLUDED_HWINT
#define KERNEL_INCLUDED_HWINT 1
typedef void(*hwint_handler_t)();
void hwint_register_handler(unsigned int int_no, hwint_handler_t handler);
void hwint_unregister_handler(unsigned int int_no);
#endif

View File

@ -1,4 +1,5 @@
#include "../config.h"
#include "config.h"
%macro INTERRUPT_NOERRCODE 2
[GLOBAL interrupt_%2]

View File

@ -1,5 +1,7 @@
#ifndef KERNEL_INCLUDED_INTERRUPT
#define KERNEL_INCLUDED_INTERRUPT 1
#ifndef KERNEL_INCLUDED_INTERRUPTS_MAIN
#define KERNEL_INCLUDED_INTERRUPTS_MAIN 1
#include "config.h"
struct IsrRegisters {
unsigned int ds; // Data segment selector
@ -63,4 +65,25 @@ void interrupt_47();
// Syscalls
void interrupt_0x80();
/*********
* hwint *
*********/
typedef void(*hwint_handler_t)();
void hwint_register_handler(unsigned int int_no, hwint_handler_t handler);
void hwint_unregister_handler(unsigned int int_no);
/***********
* syscall *
***********/
enum Kernel_Syscall_Number {
KERNEL_SYSCALL_EXIT = 0,
};
#endif

View File

@ -1,7 +1,5 @@
#include "main.h"
#include "syscall.h"
#include <kernaux/drivers/console.h>
static void syscall_do_exit(struct IsrRegisters regs);

View File

@ -1,16 +0,0 @@
#ifndef KERNEL_INCLUDED_SYSCALL
#define KERNEL_INCLUDED_SYSCALL 1
#ifdef __cplusplus
extern "C" {
#endif
enum Kernel_Syscall_Number {
KERNEL_SYSCALL_EXIT = 0,
};
#ifdef __cplusplus
}
#endif
#endif

View File

@ -2,7 +2,6 @@
#include "config.h"
#include "interrupts/main.h"
#include "interrupts/hwint.h"
#include "tss.h"
#include <kernaux/drivers/console.h>

View File

@ -1,7 +1,7 @@
#ifndef KERNEL_INCLUDED_TIMER
#define KERNEL_INCLUDED_TIMER 1
#include "interrupts/hwint.h"
#include "interrupts/main.h"
typedef hwint_handler_t timer_handler_t;