diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-07-18 11:35:58 +0000 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-07-18 11:35:58 +0000 |
| commit | fd6282947bb13af4cfff8cf2209c442b568275f3 (patch) | |
| tree | bbd2af296e5735c51816dffc0115296912088cdc | |
| parent | 4ae38294b0db1870f82cc402dc4a8bb38cea4a67 (diff) | |
| download | teachos-fd6282947bb13af4cfff8cf2209c442b568275f3.tar.xz teachos-fd6282947bb13af4cfff8cf2209c442b568275f3.zip | |
x86_64: add data segment to boot GDT
| -rw-r--r-- | arch/x86_64/src/boot/boot.s | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/arch/x86_64/src/boot/boot.s b/arch/x86_64/src/boot/boot.s index ba5c6f0..2decf26 100644 --- a/arch/x86_64/src/boot/boot.s +++ b/arch/x86_64/src/boot/boot.s @@ -58,19 +58,22 @@ stack_top: .section .boot_rodata, "a", @progbits /** - * A valid Global Descriptor Table is still required in long mode. However, we - * only need a single entry for the "code segment", so we will setup a single - * segment table below. + * A valid Global Descriptor Table is still required in long mode. * + * Bit 41: "RW" in the access byte => mark the segment as readable (code) or writable (data). * Bit 43: "E" in the access byte => mark the segment as executable. * Bit 44: "S" in the access byte => mark the segment as code or data. * Bit 47: "P" in the access byte => mark the segment as being present. * Bit 53: "L" in the flags byte => mark the segment as being for long mode */ -global_descriptor_table: .quad 0 +global_descriptor_table: +global_descriptor_table_null = . - global_descriptor_table +.quad 0 global_descriptor_table_code = . - global_descriptor_table -.quad (1<<43) | (1<<44) | (1<<47) | (1<<53) +.quad (1<<41) | (1<<43) | (1<<44) | (1<<47) | (1<<53) +global_descriptor_table_data = . - global_descriptor_table +.quad (1<<41) | (1<<44) | (1<<47) global_descriptor_table_end: /** @@ -402,7 +405,7 @@ prepare_page_maps: .code64 _transition_to_long_mode: - xor %rax, %rax + mov $global_descriptor_table_data, %rax mov %rax, %ss mov %rax, %ds mov %rax, %es |
