Compare commits

...

4 Commits

Author SHA1 Message Date
7ba3eead14 core: change main debug func 2025-01-22 14:06:44 +01:00
35b73e8004 clean: remove useless code 2025-01-22 14:06:44 +01:00
4ec1a4962d fix: (maybe): remove gdt address 2025-01-22 14:06:44 +01:00
24c7ea8b19 clean: remove useless code 2025-01-22 14:06:44 +01:00
5 changed files with 11 additions and 14 deletions
headers
src
gdt
interrupt
kernel.c
multitasking

View File

@ -3,8 +3,7 @@
#include "tss.h"
#include <stdint.h>
#define GDT_ADDRESS 0xC0105040
#define GDT_SIZE 8
#define GDT_SIZE 8
// https://wiki.osdev.org/Global_Descriptor_Table#GDTR
struct gdt_descriptor {

View File

@ -7,7 +7,7 @@ extern void set_gdt(uint32_t gdt_ptr);
struct tss TSS;
uint8_t gdt_entries[GDT_SIZE * 8];
struct gdt_descriptor *gdtr = (struct gdt_descriptor *)GDT_ADDRESS;
struct gdt_descriptor gdtr;
static void set_gdt_entry_value(uint8_t *target, uint32_t base, uint32_t limit,
uint8_t access, uint8_t granularity)
@ -37,8 +37,8 @@ static void set_gdt_entry_value(uint8_t *target, uint32_t base, uint32_t limit,
void init_gdt(void)
{
gdtr->size = 8 * GDT_SIZE - 1;
gdtr->base = (uint32_t)&gdt_entries[0];
gdtr.size = 8 * GDT_SIZE - 1;
gdtr.base = (uint32_t)&gdt_entries[0];
set_gdt_entry_value(gdt_entries + 0x00, 0, 0, 0, 0); // Null segment
@ -95,5 +95,5 @@ void init_gdt(void)
set_gdt_entry_value(gdt_entries + GDT_OFFSET_TSS, (uint32_t)&TSS,
sizeof(struct tss) - 1, 0x89, 0);
set_gdt(((uint32_t)gdtr));
set_gdt(((uint32_t)&gdtr));
}

View File

@ -38,10 +38,7 @@ irq_common_stub:
iret
irq0:
push eax
mov eax, [esp + 4]
mov [esp_backup], esp
pop eax
push 0
push 32
jmp irq_common_stub

View File

@ -61,7 +61,7 @@ void kernel_main(multiboot_info_t *mbd, uint32_t magic)
*/
/* "Martin 03:50, 22 March 2009 (UTC)\n"); */
create_kernel_task();
exec_fn(awa);
exec_fn(owo);
// exec_fn(owo);
shell_init();
}

View File

@ -11,7 +11,7 @@ switch_to_task:
// save the current stack pointer to the old stack
mov [current_task+0], esp
mov edi, [esp_backup] // get eip
mov [current_task+16], edi // save instruction before Interrupt
@ -31,13 +31,14 @@ switch_to_task:
je .END
// mov cr3, ebx
// TODO replace the eip store in stack by the [current_task+16](current_task->eip)
.END:
mov edi, [current_task+16]
mov [esp_backup], edi
.END:
pop esi
pop edi
pop ebp
pop ebx
ret // this will also change eip to the next task's instructions
ret