core: added the shell structure
This commit is contained in:
parent
5fc5a3be0e
commit
232b19666a
@ -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,49 +38,35 @@ 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);
|
||||
memcpy((void *)gdtr.base, (void *)gdt_entries, (size_t)GDT_SIZE);
|
||||
|
||||
/* load the gdtr registry */
|
||||
asm("lgdtl (gdtr)");
|
||||
|
0
src/shell/color.c
Normal file
0
src/shell/color.c
Normal file
0
src/shell/echo.c
Normal file
0
src/shell/echo.c
Normal file
0
src/shell/exec.c
Normal file
0
src/shell/exec.c
Normal file
0
src/shell/poweroff.c
Normal file
0
src/shell/poweroff.c
Normal file
0
src/shell/reboot.c
Normal file
0
src/shell/reboot.c
Normal file
Loading…
Reference in New Issue
Block a user