Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
80e176fc
authored
Oct 21, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Added load_errors to assign error functions to handlers
parent
00b25e59
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
22 deletions
src/exceptions.c
src/idt.c
src/exceptions.c
View file @
80e176fc
...
@@ -3,89 +3,89 @@
...
@@ -3,89 +3,89 @@
void
int_div_by_zero
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_div_by_zero
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"DIV BY ZERO ERRO"
);
serial_writestring
(
"DIV BY ZERO ERRO
R
\n
"
);
}
}
void
int_debug
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_debug
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"DEBUG ERROR"
);
serial_writestring
(
"DEBUG ERROR
\n
"
);
}
}
void
int_non_maskable_interrupt
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_non_maskable_interrupt
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"NON MASKABLE INTERRUPT ERROR"
);
serial_writestring
(
"NON MASKABLE INTERRUPT ERROR
\n
"
);
}
}
void
int_breakpoint
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_breakpoint
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"BREAKPOINT ERROR"
);
serial_writestring
(
"BREAKPOINT ERROR
\n
"
);
}
}
void
int_overflow
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_overflow
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"OVERFLOW ERROR"
);
serial_writestring
(
"OVERFLOW ERROR
\n
"
);
}
}
void
int_bound_range_exceeded
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_bound_range_exceeded
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"BOUND RANGE EXCEEDED ERROR"
);
serial_writestring
(
"BOUND RANGE EXCEEDED ERROR
\n
"
);
}
}
void
int_invalid_opcode
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_invalid_opcode
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"INVALID OPCODE ERROR"
);
serial_writestring
(
"INVALID OPCODE ERROR
\n
"
);
}
}
void
int_device_not_available
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_device_not_available
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"DEVICE NOT AVAILABLE ERROR"
);
serial_writestring
(
"DEVICE NOT AVAILABLE ERROR
\n
"
);
}
}
void
int_double_fault
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_double_fault
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"DOUBLE FAULT ERROR"
);
serial_writestring
(
"DOUBLE FAULT ERROR
\n
"
);
}
}
void
int_coprocessor_segment_overrun
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_coprocessor_segment_overrun
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"COPROCESSOR SEGMENT OVERRUN ERROR"
);
serial_writestring
(
"COPROCESSOR SEGMENT OVERRUN ERROR
\n
"
);
}
}
void
int_invalid_tss
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_invalid_tss
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"INVALID TSS ERROR"
);
serial_writestring
(
"INVALID TSS ERROR
\n
"
);
}
}
void
int_segment_not_present
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_segment_not_present
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"SEGMENT NOT PRESENT ERROR"
);
serial_writestring
(
"SEGMENT NOT PRESENT ERROR
\n
"
);
}
}
void
int_stack_segment_fault
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_stack_segment_fault
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"STACK SEGMENT ERROR"
);
serial_writestring
(
"STACK SEGMENT ERROR
\n
"
);
}
}
void
int_general_protection_fault
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_general_protection_fault
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"GENERAL PROTECTION FAULT ERROR"
);
serial_writestring
(
"GENERAL PROTECTION FAULT ERROR
\n
"
);
}
}
void
int_page_fault
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_page_fault
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"PAGE FAULT ERROR"
);
serial_writestring
(
"PAGE FAULT ERROR
\n
"
);
}
}
void
int_reserved
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_reserved
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"RESERVED ERROR"
);
serial_writestring
(
"RESERVED ERROR
\n
"
);
}
}
void
int_x87_floating_point
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_x87_floating_point
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"X87 FLOATING POINT ERROR"
);
serial_writestring
(
"X87 FLOATING POINT ERROR
\n
"
);
}
}
void
int_alignment_check
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_alignment_check
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"ALIGNMENT ERROR"
);
serial_writestring
(
"ALIGNMENT ERROR
\n
"
);
}
}
void
int_machine_check
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_machine_check
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"MACHINE CHECK ERROR"
);
serial_writestring
(
"MACHINE CHECK ERROR
\n
"
);
}
}
void
int_simd_floating_point
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_simd_floating_point
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"SIMD FLOATING POINT ERROR"
);
serial_writestring
(
"SIMD FLOATING POINT ERROR
\n
"
);
}
}
void
int_virtualization
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_virtualization
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"VITUALIZATION ERROR"
);
serial_writestring
(
"VITUALIZATION ERROR
\n
"
);
}
}
void
int_security
(
uint32_t
__attribute__
((
unused
))
error
)
void
int_security
(
uint32_t
__attribute__
((
unused
))
error
)
{
{
serial_writestring
(
"SECURITY ERROR"
);
serial_writestring
(
"SECURITY ERROR
\n
"
);
}
}
src/idt.c
View file @
80e176fc
#include "idt.h"
#include "idt.h"
#include "string.h"
#include "string.h"
#include "serial.h"
#include "serial.h"
#include "exceptions.h"
#pragma GCC push_options
#pragma GCC push_options
#pragma GCC optimize ("0")
#pragma GCC optimize ("0")
...
@@ -27,6 +28,21 @@ void idt_install()
...
@@ -27,6 +28,21 @@ void idt_install()
asm
volatile
(
"lidt (%0)"
:
:
"r"
(
&
idtr
));
asm
volatile
(
"lidt (%0)"
:
:
"r"
(
&
idtr
));
}
}
void
load_error_handlers
()
{
void
(
*
errors
[])(
uint32_t
)
=
{
int_div_by_zero
,
int_debug
,
int_non_maskable_interrupt
,
int_breakpoint
,
int_overflow
,
int_bound_range_exceeded
,
int_invalid_opcode
,
int_device_not_available
,
int_double_fault
,
int_coprocessor_segment_overrun
,
int_invalid_tss
,
int_segment_not_present
,
int_stack_segment_fault
,
int_general_protection_fault
,
int_page_fault
,
int_reserved
,
int_x87_floating_point
,
int_alignment_check
,
int_machine_check
,
int_simd_floating_point
,
int_virtualization
,
int_reserved
,
int_reserved
,
int_reserved
,
int_reserved
,
int_reserved
,
int_reserved
,
int_reserved
,
int_reserved
,
int_reserved
,
int_security
,
int_reserved
};
for
(
int
i
=
0
;
i
<
32
;
i
++
)
{
handlers
[
i
]
=
errors
[
i
];
}
}
void
default_handler
(
struct
reg_state
reg
,
uint32_t
interrupt
,
uint32_t
error
,
struct
stack_state
stack
)
void
default_handler
(
struct
reg_state
reg
,
uint32_t
interrupt
,
uint32_t
error
,
struct
stack_state
stack
)
{
{
if
(
interrupt
<
32
)
if
(
interrupt
<
32
)
...
@@ -96,6 +112,7 @@ int idt_init(uint16_t code_sel)
...
@@ -96,6 +112,7 @@ int idt_init(uint16_t code_sel)
_code_sel
=
code_sel
;
_code_sel
=
code_sel
;
idtsetup
();
idtsetup
();
idt_install
();
idt_install
();
load_error_handlers
();
return
0
;
return
0
;
}
}
#pragma GCC pop_options
#pragma GCC pop_options
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment