Fixed Interrupts bug:

It was a problem about ports(cpu/ports.asm) functions.
This commit is contained in:
ice-bit 2019-07-06 00:32:41 +02:00
parent 3a0d674985
commit ba9feaba18
8 changed files with 26 additions and 9 deletions

View File

@ -20,12 +20,13 @@ Then you can run those commands:
iceOS already have/will have the following features: iceOS already have/will have the following features:
- [x] Bare metal booting; - [x] Bare metal booting;
- [x] VGA driver; - [x] VGA driver;
- [ ] Interrupts implementation; - [x] Interrupts implementation;
- [ ] PIC & PIT implementation; - [ ] PIC & PIT implementation;
- [ ] PS2 driver; - [ ] PS2 driver;
- [ ] Support for x86 architecture; - [x] Support for x86 architecture;
- [x] GRUB as bootloader. - [x] GRUB as bootloader;
- [ ] Paging;
- [ ] Dynamic memory allocation(heap).
## Resources ## Resources
This project is made with different kind of resources and different kind of knowledges, before starting it i read/studied the following resources: This project is made with different kind of resources and different kind of knowledges, before starting it i read/studied the following resources:
@ -34,5 +35,6 @@ This project is made with different kind of resources and different kind of know
- [Operating System Concepts - Silberschatz (2016)](https://www.amazon.it/Sistemi-operativi-Concetti-ed-esempi/dp/8865183713/ref=pd_lpo_sbs_14_img_1?_encoding=UTF8&psc=1&refRID=4A5T2C7KKH7RA0K1T7RV) - [Operating System Concepts - Silberschatz (2016)](https://www.amazon.it/Sistemi-operativi-Concetti-ed-esempi/dp/8865183713/ref=pd_lpo_sbs_14_img_1?_encoding=UTF8&psc=1&refRID=4A5T2C7KKH7RA0K1T7RV)
- [The Art Of Electronics - Horowitz (2015)](https://www.amazon.it/gp/product/0521809266/ref=ppx_od_dt_b_asin_title_s00?ie=UTF8&psc=1) - [The Art Of Electronics - Horowitz (2015)](https://www.amazon.it/gp/product/0521809266/ref=ppx_od_dt_b_asin_title_s00?ie=UTF8&psc=1)
- [OSDev wiki](https://wiki.osdev.org/Main_Page) - [OSDev wiki](https://wiki.osdev.org/Main_Page)
- [The Little Book About OS Development](https://littleosbook.github.io/)
## License ## License
iceOS is released under GPLv3, you can obtain a copy of this license by cloning the repository or by visiting [this](https://opensource.org/licenses/GPL-3.0) page. iceOS is released under GPLv3, you can obtain a copy of this license by cloning the repository or by visiting [this](https://opensource.org/licenses/GPL-3.0) page.

BIN
iceOS.iso Normal file

Binary file not shown.

View File

@ -0,0 +1,7 @@
set timeout = 0
set default = 0
menuentry "iceOS" {
multiboot2 /boot/iceOS.bin
boot
}

BIN
isodir/boot/iceOS.bin Executable file

Binary file not shown.

View File

@ -10,7 +10,7 @@ global outb ; Output from port
global inb ; Input to port global inb ; Input to port
outb: outb:
mov al, [esp + 3] mov al, [esp + 8]
mov dx, [esp + 4] mov dx, [esp + 4]
out dx, al out dx, al
ret ret

View File

@ -97,7 +97,7 @@ static void init_idt() {
__asm__ __volatile__ ("sti"); __asm__ __volatile__ ("sti");
} }
// Taken here: http://wiki.osdev.org/8259_PIC // Taken from: http://wiki.osdev.org/8259_PIC
static void pic_remap(uint8_t offset1, uint8_t offset2) { static void pic_remap(uint8_t offset1, uint8_t offset2) {
uint8_t a1, a2; uint8_t a1, a2;

View File

@ -56,7 +56,8 @@ void isr_handler(registers_t regs) {
isr_t handler = interrupt_handler[regs.int_num]; isr_t handler = interrupt_handler[regs.int_num];
handler(regs); handler(regs);
} else { } else {
kprint_c((uint8_t*)"Received interrupt: ", 20, LIGHT_BROWN, BLACK); uint8_t *buf = (uint8_t*)"\nReceived interrupt: ";
kprint_c((uint8_t*)buf,strlen(buf), LIGHT_BROWN, BLACK);
kprint_c(interrupts_messages[(uint8_t)regs.int_num], kprint_c(interrupts_messages[(uint8_t)regs.int_num],
strlen(interrupts_messages[(uint8_t)regs.int_num]), strlen(interrupts_messages[(uint8_t)regs.int_num]),
WHITE, WHITE,

View File

@ -4,10 +4,17 @@
#include "libc/stdio.h" #include "libc/stdio.h"
void kernel_main() { void kernel_main() {
clear_prompt();
init_prompt(); // Initialize frame buffer
gdt_setup(); // Setup Global Descriptor Table gdt_setup(); // Setup Global Descriptor Table
idt_setup(); // Setup Interrupt Descriptor Table idt_setup(); // Setup Interrupt Descriptor Table
clear_prompt();
init_prompt(); // Initialize frame buffer
puts("Hello World!"); puts("Hello World!");
/*
// Testing some interrupts
asm("int $0"); // Division by zero
asm("int $4"); // Stack overflow
asm("int $1"); // Page fault
*/
} }