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
916a24fe
authored
Oct 26, 2015
by
malcolm
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Unified SW/HW interrupts, HW works now
parent
5db61b5c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
src/idt.c
src/kern.c
src/pit.c
src/idt.c
View file @
916a24fe
...
...
@@ -45,13 +45,21 @@ void load_error_handlers()
void
default_handler
(
struct
reg_state
reg
,
uint32_t
interrupt
,
uint32_t
error
,
struct
stack_state
stack
)
{
/*for(uint32_t i=stack.eip-16;i<=stack.eip+16;i+=4)
{
serial_hexword(i);
serial_writestring(": ");
serial_hexword(*((uint32_t*)(void*)i));
serial_writestring("\n");
}*/
if
(
interrupt
<
32
)
stack
.
eip
+=
2
;
serial_writestring
(
"int caught "
);
char
f
[
20
];
serial_val
(
interrupt
);
serial_val
(
error
);
serial_val
(
stack
.
eip
);
serial_hexword
(
error
);
serial_writestring
(
" "
);
serial_hexword
(
stack
.
eip
);
serial_writestring
(
" "
);
//serial_val(stack.eip);
serial_val
(
stack
.
cd
);
serial_val
(
stack
.
eflags
);
serial_writestring
(
"
\n
"
);
...
...
@@ -59,6 +67,7 @@ void default_handler(struct reg_state reg, uint32_t interrupt, uint32_t error, s
{
handlers
[
interrupt
](
error
);
}
//asm("hlt");
return
;
}
...
...
src/kern.c
View file @
916a24fe
...
...
@@ -31,11 +31,12 @@ void kernel_main(multiboot_info* mbt, uint32_t magic)
pit_init
();
pit_start_counter
(
100
,
PIT_OCW_CONT_0
,
PIT_OCW_MODE_SQWVGEN
);
enable_int
();
/* Since there is no support for newlines in terminal_putchar
* yet, '\n' will produce some VGA specific character instead.
* This is normal.
*/
serial_writestring
(
"Hello, kernel World!
\n
"
);
terminal_writestring
(
"Hello, kernel World!
\n
"
);
...
...
@@ -57,6 +58,13 @@ void kernel_main(multiboot_info* mbt, uint32_t magic)
int
o
=
0
;
int
j
=
5
/
o
;
serial_hexword
(
j
);
<<<<<<<
HEAD
test_mem
();
test_idt
();
=======
serial_writestring
(
"
\n
"
);
while
(
true
)
serial_writestring
(
""
);
asm
(
"hlt"
);
>>>>>>>
Unified
SW
/
HW
interrupts
,
HW
works
now
}
src/pit.c
View file @
916a24fe
...
...
@@ -2,6 +2,7 @@
#include "pic.h"
#include "idt.h"
#include "asm.h"
#include "serial.h"
#pragma GCC push_options
#pragma GCC optimize ("0")
...
...
@@ -11,10 +12,12 @@ static bool _pit_is_init = false;
void
pit_irq
()
{
asm
volatile
(
"add %esp, 12;
pusha"
);
//asm volatile ("
pusha");
_pit_ticks
++
;
//serial_writestring("PIT tick\n");
pic_command
(
0
,
PIC_OCW2_EOI
);
asm
volatile
(
"popa; iret"
);
//serial_writestring("PIT tickn\n");
//asm volatile("nop;nop;nop;popa; iret;");
}
void
pit_command
(
uint8_t
cmd
)
...
...
@@ -71,7 +74,8 @@ void pit_start_counter(uint32_t freq, uint8_t counter, uint8_t mode)
void
pit_init
()
{
install_ir
(
32
,
IDT_PR
|
IDT_32
,
0x8
,
pit_irq
);
//install_ir(32, IDT_PR|IDT_32, 0x8, pit_irq);
install_c_ir
(
32
,
pit_irq
);
_pit_is_init
=
true
;
}
...
...
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