Compare commits

..

No commits in common. "7ba3eead14a2cd2db4880a7b1c2e94ade802181c" and "d2f7a3ce26f183bb59295cafcaf72ce06c5b0a9e" have entirely different histories.

5 changed files with 14 additions and 11 deletions

View File

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

View File

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

View File

@ -38,7 +38,10 @@ irq_common_stub:
iret iret
irq0: irq0:
push eax
mov eax, [esp + 4]
mov [esp_backup], esp mov [esp_backup], esp
pop eax
push 0 push 0
push 32 push 32
jmp irq_common_stub 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"); */ /* "Martin 03:50, 22 March 2009 (UTC)\n"); */
create_kernel_task(); create_kernel_task();
exec_fn(owo); exec_fn(awa);
// exec_fn(owo); // exec_fn(owo);
shell_init(); shell_init();
} }

View File

@ -31,14 +31,13 @@ switch_to_task:
je .END je .END
// mov cr3, ebx // 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 edi, [current_task+16]
mov [esp_backup], edi mov [esp_backup], edi
.END:
pop esi pop esi
pop edi pop edi
pop ebp pop ebp
pop ebx pop ebx
ret ret // this will also change eip to the next task's instructions