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,7 +3,8 @@
#include "tss.h"
#include <stdint.h>
#define GDT_SIZE 8
#define GDT_ADDRESS 0xC0105040
#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 *gdtr = (struct gdt_descriptor *)GDT_ADDRESS;
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,7 +38,10 @@ 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(owo);
exec_fn(awa);
// 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,14 +31,13 @@ switch_to_task:
je .END
// mov cr3, ebx
.END:
// TODO replace the eip store in stack by the [current_task+16](current_task->eip)
mov edi, [current_task+16]
mov [esp_backup], edi
.END:
pop esi
pop edi
pop ebp
pop ebx
ret
ret // this will also change eip to the next task's instructions