mirror of
https://github.com/originalmk/mkos32.git
synced 2025-01-18 16:29:19 +00:00
Back to flat segmentation model
This commit is contained in:
parent
ee09437fb1
commit
0f8bbb8b10
11
boot.s
11
boot.s
@ -51,17 +51,6 @@ mov $stack_top, %esp
|
|||||||
/* Wywołanie kernela */
|
/* Wywołanie kernela */
|
||||||
call kernel_main
|
call kernel_main
|
||||||
|
|
||||||
mov $0x10, %ax
|
|
||||||
mov %ax, %ds
|
|
||||||
mov %ax, %es
|
|
||||||
mov %ax, %fs
|
|
||||||
mov %ax, %gs
|
|
||||||
mov %ax, %ss
|
|
||||||
jmp $0x08,$cs_refresh
|
|
||||||
cs_refresh:
|
|
||||||
mov $0x4000, %esp
|
|
||||||
push $5
|
|
||||||
|
|
||||||
/* Wieczne oczekiwanie po zakończeniu kodu kernela */
|
/* Wieczne oczekiwanie po zakończeniu kodu kernela */
|
||||||
cli
|
cli
|
||||||
1: hlt
|
1: hlt
|
||||||
|
31
kernel.c
31
kernel.c
@ -191,7 +191,8 @@ void terminal_writenumpad(uint64_t number, int base, int pad_length)
|
|||||||
// Write pad_length - size of zeros
|
// Write pad_length - size of zeros
|
||||||
// If padding won't be needed (number is longer than pad_legnth)
|
// If padding won't be needed (number is longer than pad_legnth)
|
||||||
// then loop won't run at all
|
// then loop won't run at all
|
||||||
while (pad_length > size) {
|
while (pad_length > size)
|
||||||
|
{
|
||||||
numChars[31 - size++] = digits[0];
|
numChars[31 - size++] = digits[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,13 +397,13 @@ void print_texts()
|
|||||||
void gdt_setup()
|
void gdt_setup()
|
||||||
{
|
{
|
||||||
struct gdt_entry kernel_code_entry =
|
struct gdt_entry kernel_code_entry =
|
||||||
gdt_entry_create(0, 0x400, KERNEL_SEGMENT, CODE_SEGMENT);
|
gdt_entry_create(0x0, 0x100000, KERNEL_SEGMENT, CODE_SEGMENT);
|
||||||
struct gdt_entry kernel_data_entry =
|
struct gdt_entry kernel_data_entry =
|
||||||
gdt_entry_create(0x400, 0x400, KERNEL_SEGMENT, DATA_SEGMENT);
|
gdt_entry_create(0x0, 0x100000, KERNEL_SEGMENT, DATA_SEGMENT);
|
||||||
struct gdt_entry user_code_entry =
|
struct gdt_entry user_code_entry =
|
||||||
gdt_entry_create(0x800, 0x400, USER_SEGMENT, CODE_SEGMENT);
|
gdt_entry_create(0x0, 0x100000, USER_SEGMENT, CODE_SEGMENT);
|
||||||
struct gdt_entry user_data_entry =
|
struct gdt_entry user_data_entry =
|
||||||
gdt_entry_create(0xC00, 0x400, USER_SEGMENT, DATA_SEGMENT);
|
gdt_entry_create(0x0, 0x100000, USER_SEGMENT, DATA_SEGMENT);
|
||||||
|
|
||||||
struct gdt_table gdt_table;
|
struct gdt_table gdt_table;
|
||||||
gdt_table.size_in_bytes = 39;
|
gdt_table.size_in_bytes = 39;
|
||||||
@ -416,20 +417,16 @@ void gdt_setup()
|
|||||||
terminal_writestring("GDT table applied\n");
|
terminal_writestring("GDT table applied\n");
|
||||||
|
|
||||||
__asm__ volatile(
|
__asm__ volatile(
|
||||||
"mov $stack_bottom, %%esi;"
|
"mov $0x10, %ax;"
|
||||||
"mov $0x500000, %%edi;"
|
"mov %ax, %ds;"
|
||||||
"mov $16384, %%ecx;"
|
"mov %ax, %es;"
|
||||||
"cld;"
|
"mov %ax, %fs;"
|
||||||
"rep movsb;"
|
"mov %ax, %gs;"
|
||||||
:
|
"mov %ax, %ss;"
|
||||||
:
|
"jmp $0x08,$csrefresh;"
|
||||||
:
|
|
||||||
"esi","edi","ecx"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
__asm__(
|
__asm__ volatile("csrefresh:");
|
||||||
"xchg %bx, %bx"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void kernel_main(void)
|
void kernel_main(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user