summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-05-24 15:32:37 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-05-24 15:32:37 +0200
commit96ed1f23c9c0318292e9371b3cb036351d64687a (patch)
tree6015c300c73d211d504483792dd44bce6ed2f2af
parent432abe67d09811486b3db2ac58bb324437aa69b9 (diff)
downloadabaos-96ed1f23c9c0318292e9371b3cb036351d64687a.tar.gz
abaos-96ed1f23c9c0318292e9371b3cb036351d64687a.tar.bz2
eliminated global IDT pointer, added to interrupt structure
-rw-r--r--DESIGN3
-rw-r--r--src/interrupts.asm4
-rw-r--r--src/interrupts.c8
-rw-r--r--src/interrupts.h9
-rw-r--r--src/kernel.c6
5 files changed, 15 insertions, 15 deletions
diff --git a/DESIGN b/DESIGN
index 55bd28c..3b76393 100644
--- a/DESIGN
+++ b/DESIGN
@@ -13,6 +13,9 @@ Use the cdecl calling convetion when calling assembly from C.
Stick to NASM assembly bare features (equ, org). Use only the absolute
minimum.
+Use only as much assembly as needed, if necessary call a stub function
+from C doing the things we would normally do in inlined assembly.
+
Make sure it compiles with every ANSI C99 compiler (gcc, clang, tcc, ...).
Use only what is needed, nothing fancy.
Try to compile as often as possible with different compilers on different
diff --git a/src/interrupts.asm b/src/interrupts.asm
index 6f991f4..c21229c 100644
--- a/src/interrupts.asm
+++ b/src/interrupts.asm
@@ -21,14 +21,12 @@ interrupts_disable:
leave
ret
-extern idt_pointer
-
; void interrupts_load_idt( interrupt_descriptor_table_pointer_t *idt_pointer )
interrupts_load_idt:
push ebp
mov ebp, esp
mov ecx, [ebp+8]
- lidt [idt_pointer]
+ lidt [ecx]
leave
ret
diff --git a/src/interrupts.c b/src/interrupts.c
index 6fd8024..77ba0d0 100644
--- a/src/interrupts.c
+++ b/src/interrupts.c
@@ -17,8 +17,6 @@
// types of IDT entries
#define IDT_TYPE_INTERRUPT_GATE 0xE
-interrupt_descriptor_table_pointer_t idt_pointer;
-
void interrupts_init( interrupt_t *interrupt )
{
memset( interrupt, 0, sizeof( interrupt_t ) );
@@ -32,10 +30,10 @@ void interrupts_init( interrupt_t *interrupt )
interrupts_register_interrupt( interrupt, 0x00, GDT_CODE_SEGMENT_SELECTOR,
&interrupts_handle_request_0x00, KERNEL_RING, IDT_TYPE_INTERRUPT_GATE );
- idt_pointer.size = 256 * sizeof( interrupt_gate_descriptor_t ) - 1;
- idt_pointer.base = (uint32_t)interrupt->descriptor_table;
+ interrupt->idt_pointer.size = 256 * sizeof( interrupt_gate_descriptor_t ) - 1;
+ interrupt->idt_pointer.base = (uint32_t)interrupt->descriptor_table;
- interrupts_load_idt( &idt_pointer );
+ interrupts_load_idt( &interrupt->idt_pointer );
}
void interrupts_register_interrupt( interrupt_t *interrupts,
diff --git a/src/interrupts.h b/src/interrupts.h
index a2d261a..d8a6d4b 100644
--- a/src/interrupts.h
+++ b/src/interrupts.h
@@ -26,10 +26,6 @@ typedef struct interrupt_gate_descriptor_t {
#define NOF_INTERRUPT_GATES 256
-typedef struct {
- interrupt_gate_descriptor_t descriptor_table[NOF_INTERRUPT_GATES];
-} interrupt_t;
-
#if defined( __TINYC__ )
#pragma pack(1)
#endif
@@ -43,6 +39,11 @@ typedef struct {
#pragma pack()
#endif
+typedef struct {
+ interrupt_descriptor_table_pointer_t idt_pointer;
+ interrupt_gate_descriptor_t descriptor_table[NOF_INTERRUPT_GATES];
+} interrupt_t;
+
void interrupts_enable( void );
void interrupts_disable( void );
void interrupts_init( interrupt_t *interrupt );
diff --git a/src/kernel.c b/src/kernel.c
index c943087..72b1222 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -46,9 +46,9 @@ void entry( void )
vga_put_char_at( &vga, x_pos, y_pos, '.' );
x_pos++;
// serial_put_char( &serial, '.' );
-//~ int y = 0;
-//~ int x = 12 / y;
-//~ printf( "Hex number is 0x%X and string is '%s'\n", x, "abaos" );
+int y = 0;
+int x = 12 / y;
+printf( "Hex number is 0x%X and string is '%s'\n", x, "abaos" );
}
vga_put_char_at( &vga, x_pos, y_pos, bar[i%4] );