mirror of
https://github.com/tailix/kernel.git
synced 2024-10-30 12:03:52 -04:00
Add guards
This commit is contained in:
parent
545e2aef7d
commit
3eb3c34275
3 changed files with 29 additions and 1 deletions
|
@ -20,4 +20,14 @@
|
|||
#define GDT_USER_CS_SELECTOR GDT_SEGMENT_SELECTOR(GDT_USER_CS_INDEX)
|
||||
#define GDT_USER_DS_SELECTOR GDT_SEGMENT_SELECTOR(GDT_USER_DS_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)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "config.h"
|
||||
#include "logger.h"
|
||||
|
||||
struct IsrRegisters {
|
||||
|
@ -44,5 +45,12 @@ static const char *const messages[] = {
|
|||
|
||||
void exception_handler(struct IsrRegisters regs)
|
||||
{
|
||||
if (
|
||||
!(regs.int_no >= INT_EXCEPTION_FIRST &&
|
||||
regs.int_no <= INT_EXCEPTION_LAST)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger_warn(messages[regs.int_no]);
|
||||
}
|
||||
|
|
12
arch/hwint.c
12
arch/hwint.c
|
@ -1,3 +1,4 @@
|
|||
#include "config.h"
|
||||
#include "logger.h"
|
||||
|
||||
struct IsrRegisters {
|
||||
|
@ -28,5 +29,14 @@ static const char *const messages[] = {
|
|||
|
||||
void hwint_handler(struct IsrRegisters regs)
|
||||
{
|
||||
logger_warn(messages[regs.int_no - 32]);
|
||||
if (
|
||||
!(regs.int_no >= INT_HWINT_FIRST &&
|
||||
regs.int_no <= INT_HWINT_LAST)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unsigned char hwint_no = regs.int_no - INT_HWINT_FIRST;
|
||||
|
||||
logger_warn(messages[hwint_no]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue