core: added the shell structure

This commit is contained in:
0x35c 2024-09-10 12:03:08 +02:00
parent 5fc5a3be0e
commit 232b19666a
6 changed files with 51 additions and 64 deletions

View File

@ -8,7 +8,8 @@ void encodeGdtEntry(uint8_t *target, struct gdt_entry source)
{
// Check the limit to make sure that it can be encoded
if (source.limit > 0xFFFFF) {
kprintf(KERN_ERR, "GDT cannot encode limits larger than 0xFFFFF");
kprintf(KERN_ERR,
"GDT cannot encode limits larger than 0xFFFFF");
}
// Encode the limit
@ -37,46 +38,32 @@ void initGdt()
gdtr.size = GDT_SIZE - 1;
gdtr.base = GDT_BASE;
struct gdt_entry gdt_entry_null_descriptor = { .base = 0,
.limit = 0x00000000,
.access_byte = 0x00,
.flags = 0x0};
struct gdt_entry gdt_entry_null_descriptor = {
.base = 0, .limit = 0x00000000, .access_byte = 0x00, .flags = 0x0};
encodeGdtEntry(gdt_entries[0], gdt_entry_null_descriptor);
struct gdt_entry gdt_entry_kernel_mode_code_segment = { .base = 0,
.limit = 0xFFFFF,
.access_byte = 0x9A,
.flags = 0xC };
struct gdt_entry gdt_entry_kernel_mode_code_segment = {
.base = 0, .limit = 0xFFFFF, .access_byte = 0x9A, .flags = 0xC};
encodeGdtEntry(gdt_entries[1], gdt_entry_kernel_mode_code_segment);
struct gdt_entry gdt_entry_kernel_mode_data_segment = { .base = 0,
.limit = 0xFFFFF,
.access_byte = 0x92,
.flags = 0xC };
struct gdt_entry gdt_entry_kernel_mode_data_segment = {
.base = 0, .limit = 0xFFFFF, .access_byte = 0x92, .flags = 0xC};
encodeGdtEntry(gdt_entries[2], gdt_entry_kernel_mode_data_segment);
struct gdt_entry gdt_entry_kernel_mode_stack_segment = { .base = 0x0,
.limit = 0x0,
.access_byte = 0x97,
.flags = 0x0D };
struct gdt_entry gdt_entry_kernel_mode_stack_segment = {
.base = 0x0, .limit = 0x0, .access_byte = 0x97, .flags = 0x0D};
encodeGdtEntry(gdt_entries[3], gdt_entry_kernel_mode_data_segment);
struct gdt_entry gdt_entry_user_mode_code_segment = { .base = 0,
.limit = 0xFFFFF,
.access_byte = 0xFA,
.flags = 0xC };
struct gdt_entry gdt_entry_user_mode_code_segment = {
.base = 0, .limit = 0xFFFFF, .access_byte = 0xFA, .flags = 0xC};
encodeGdtEntry(gdt_entries[4], gdt_entry_user_mode_code_segment);
struct gdt_entry gdt_entry_user_mode_data_segment = { .base = 0,
.limit = 0xFFFFF,
.access_byte = 0xF2,
.flags = 0xC };
struct gdt_entry gdt_entry_user_mode_data_segment = {
.base = 0, .limit = 0xFFFFF, .access_byte = 0xF2, .flags = 0xC};
encodeGdtEntry(gdt_entries[5], gdt_entry_user_mode_data_segment);
struct gdt_entry gdt_entry_user_mode_stack_segment = { .base = 0x0,
.limit = 0x0,
.access_byte = 0xF7,
.flags = 0x0D };
struct gdt_entry gdt_entry_user_mode_stack_segment = {
.base = 0x0, .limit = 0x0, .access_byte = 0xF7, .flags = 0x0D};
encodeGdtEntry(gdt_entries[6], gdt_entry_user_mode_data_segment);
memcpy((void *)gdtr.base, (void *)gdt_entries, (size_t)GDT_SIZE);

0
src/shell/color.c Normal file
View File

0
src/shell/echo.c Normal file
View File

0
src/shell/exec.c Normal file
View File

0
src/shell/poweroff.c Normal file
View File

0
src/shell/reboot.c Normal file
View File