summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-05-20 08:37:02 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-05-20 08:37:02 +0200
commit45212640af40bed34a21c9b0b0640e17e945ed5c (patch)
treef6d8d6d14d9e1c7885ed762d53181f496dc94a8e
parentbd995b05f7ea2abdf88b8f7d990ec60df0e8e7db (diff)
downloadabaos-45212640af40bed34a21c9b0b0640e17e945ed5c.tar.gz
abaos-45212640af40bed34a21c9b0b0640e17e945ed5c.tar.bz2
started with interrupts, some struct cleanup
-rw-r--r--doc/LINKS.TODO4
-rw-r--r--src/console.h4
-rw-r--r--src/interrupts.asm18
-rw-r--r--src/interrupts.c7
-rw-r--r--src/interrupts.h29
-rw-r--r--src/kernel.c31
-rw-r--r--src/port.h4
-rw-r--r--src/serial.h4
-rw-r--r--src/vga.h4
9 files changed, 78 insertions, 27 deletions
diff --git a/doc/LINKS.TODO b/doc/LINKS.TODO
index 6e81c79..02b72c8 100644
--- a/doc/LINKS.TODO
+++ b/doc/LINKS.TODO
@@ -12,6 +12,10 @@ http://x86.renejeschke.de/html/file_module_x86_id_139.html
http://retired.beyondlogic.org/serial/serial1.htm
https://pdos.csail.mit.edu/6.828/2014/reference.html
+tutorials:
+
+https://littleosbook.github.io
+
In C#:
https://github.com/FlingOS/FlingOS
diff --git a/src/console.h b/src/console.h
index e922b98..b87eed4 100644
--- a/src/console.h
+++ b/src/console.h
@@ -1,10 +1,12 @@
#ifndef CONSOLE_H
#define CONSOLE_H
+#include <stdint.h>
+
#include "vga.h"
#include "serial.h"
-typedef struct console_t {
+typedef struct {
vga_t *vga;
serial_t *serial;
} console_t;
diff --git a/src/interrupts.asm b/src/interrupts.asm
index e69de29..d5d67c9 100644
--- a/src/interrupts.asm
+++ b/src/interrupts.asm
@@ -0,0 +1,18 @@
+[bits 32]
+
+global interrupts_enable
+global interrupts_disable
+
+; void interrupts_enable( void )
+interrupts_enable:
+ push ebp
+ sti
+ leave
+ ret
+
+; void interrupts_disable( void )
+interrupts_disable:
+ push ebp
+ cli
+ leave
+ ret
diff --git a/src/interrupts.c b/src/interrupts.c
index e04d063..a3eea59 100644
--- a/src/interrupts.c
+++ b/src/interrupts.c
@@ -1 +1,8 @@
#include "interrupts.h"
+
+#include "string.h"
+
+void interrupts_init( interrupt_t *interrupts )
+{
+ memset( interrupts, 0, sizeof( interrupt_t ) );
+}
diff --git a/src/interrupts.h b/src/interrupts.h
index d0a0ab3..01406e3 100644
--- a/src/interrupts.h
+++ b/src/interrupts.h
@@ -1,9 +1,38 @@
#ifndef INTERRUPTS_H
#define INTERRUPTS_H
+typedef struct {
+
+} interrupt_gate_descriptor_t;
+
+typedef struct {
+} interrupt_t;
+
+void interrupts_enable( void );
+void interrupts_disable( void );
+
+void interrupts_init( interrupt_t *interrupt );
+
// initialize IDT
// handle gates
// assembly trampolines calling C (static) functions
// later: tasks and stacks, queues
+ //~ struct GateDescriptor
+ //~ {
+ //~ myos::common::uint16_t handlerAddressLowBits;
+ //~ myos::common::uint16_t gdt_codeSegmentSelector;
+ //~ myos::common::uint8_t reserved;
+ //~ myos::common::uint8_t access;
+ //~ myos::common::uint16_t handlerAddressHighBits;
+ //~ } __attribute__((packed));
+//~ struct IDTDescr {
+ //~ uint16_t offset_1; // offset bits 0..15
+ //~ uint16_t selector; // a code segment selector in GDT or LDT
+ //~ uint8_t zero; // unused, set to 0
+ //~ uint8_t type_attr; // type and attributes, see below
+ //~ uint16_t offset_2; // offset bits 16..31
+//~ };
+
+
#endif // INTERRUPTS_H
diff --git a/src/kernel.c b/src/kernel.c
index 6408aa7..adebb21 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -4,6 +4,7 @@
#include "serial.h"
#include "console.h"
#include "stdlib.h"
+#include "interrupts.h"
void entry( void )
{
@@ -20,9 +21,13 @@ void entry( void )
console_add_vga_output( &console, &vga );
console_add_serial_output( &console, &serial );
-// for IDT testing
-// int y = 0;
-// int x = 12 / y;
+ interrupt_t interrupt;
+ interrupts_init( &interrupt );
+ interrupts_enable( );
+
+ int y = 1;
+ int x = 12 / y;
+ console_put_hex( &console, x );
console_put_string( &console, "Initializing hardware" );
@@ -37,7 +42,7 @@ void entry( void )
serial_put_char( &serial, '.' );
}
vga_put_char_at( &vga, x_pos, y_pos, bar[i%4] );
- for( int j = 0; j < 150; j++ ) {
+ for( int j = 0; j < 150000; j++ ) {
}
}
vga_put_char_at( &vga, x_pos, y_pos, '.' );
@@ -47,22 +52,4 @@ void entry( void )
console_put_string( &console, "Terminating" );
console_put_newline( &console );
-
- //~ vga_set_color( &vga, VGA_COLOR_WHITE );
- //~ vga_set_background_color( &vga, VGA_COLOR_RED );
- //~ vga_clear_screen( &vga );
-
- //~ for( int i = 0; i < 50; i++ ) {
- //~ for( int j = 0; j < i; j++ ) {
- //~ vga_put_char( &vga, '-' );
- //~ }
- //~ vga_put_char( &vga, '>' );
- //~ vga_put_string( &vga, (const char *)"TEST TEST TEST" );
- //~ vga_put_newline( &vga );
- //~ }
- //~ for( int j = 0; j < 50; j++ ) {
- //~ vga_put_char( &vga, '-' );
- //~ }
- //~ vga_put_char( &vga, '>' );
- //~ vga_put_string( &vga, (const char *)"TEST TEST TEST" );
}
diff --git a/src/port.h b/src/port.h
index 28d07b7..748945d 100644
--- a/src/port.h
+++ b/src/port.h
@@ -3,14 +3,14 @@
#include <stdint.h>
-typedef enum port_type_t {
+typedef enum {
PORT_TYPE_8BIT = 0,
PORT_TYPE_8BIT_SLOW = 1,
PORT_TYPE_16BIT = 2,
PORT_TYPE_32BIT = 3
} port_type_t;
-typedef struct port_t {
+typedef struct {
port_type_t type;
uint16_t number; // port number, e.g. 0x3d4 VGA index register
} port_t;
diff --git a/src/serial.h b/src/serial.h
index 81c1e83..15eca00 100644
--- a/src/serial.h
+++ b/src/serial.h
@@ -1,9 +1,11 @@
#ifndef SERIAL_H
#define SERIAL_H
+#include <stdint.h>
+
#include "port.h"
-typedef struct serial_t {
+typedef struct {
port_t port_3F8;
port_t port_3FD;
} serial_t;
diff --git a/src/vga.h b/src/vga.h
index bc2449a..47cc96f 100644
--- a/src/vga.h
+++ b/src/vga.h
@@ -1,6 +1,8 @@
#ifndef VGA_H
#define VGA_H
+#include <stdint.h>
+
#include "port.h"
enum {
@@ -27,7 +29,7 @@ typedef enum {
VGA_COLOR_WHITE = 15
} vga_color_t;
-typedef struct vga_t {
+typedef struct {
int res_x; // resolution, default 80
int res_y; // resolution, default 25
int cursor_x; // current cursor position X