Compare commits
4 Commits
d2f7a3ce26
...
7ba3eead14
Author | SHA1 | Date | |
---|---|---|---|
7ba3eead14 | |||
35b73e8004 | |||
4ec1a4962d | |||
24c7ea8b19 |
@ -3,8 +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
|
||||||
struct gdt_descriptor {
|
struct gdt_descriptor {
|
||||||
|
@ -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 *)GDT_ADDRESS;
|
struct gdt_descriptor gdtr;
|
||||||
|
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,7 @@ 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
|
||||||
|
@ -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(awa);
|
exec_fn(owo);
|
||||||
// exec_fn(owo);
|
// exec_fn(owo);
|
||||||
shell_init();
|
shell_init();
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ switch_to_task:
|
|||||||
|
|
||||||
// save the current stack pointer to the old stack
|
// save the current stack pointer to the old stack
|
||||||
mov [current_task+0], esp
|
mov [current_task+0], esp
|
||||||
|
|
||||||
mov edi, [esp_backup] // get eip
|
mov edi, [esp_backup] // get eip
|
||||||
mov [current_task+16], edi // save instruction before Interrupt
|
mov [current_task+16], edi // save instruction before Interrupt
|
||||||
|
|
||||||
@ -31,13 +31,14 @@ 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 // this will also change eip to the next task's instructions
|
ret
|
||||||
|
Loading…
Reference in New Issue
Block a user