diff --git a/arch/x86/link.ld b/arch/x86/link.ld index 59b57578..29f2ebd4 100644 --- a/arch/x86/link.ld +++ b/arch/x86/link.ld @@ -52,6 +52,34 @@ SECTIONS *(.multiboot) } :init + .text.rmode BLOCK(4K) : ALIGN(4K) + { + . = ALIGN(4K); + __start_text_rmode = .; + *(.text.rmode) + . = ALIGN(4K); + __end_text_rmode = .; + } :init + + .bss.rmode BLOCK(4K) : ALIGN(4K) + { + . = ALIGN(4K); + __start_bss_rmode = .; + *(.bss.rmode) + *(COMMON.rmode) + . = ALIGN(4K); + __end_bss_rmode = .; + } :init + + .data.rmode BLOCK(4K) : ALIGN(4K) + { + . = ALIGN(4K); + __start_data_rmode = .; + *(.data.rmode) + . = ALIGN(4K); + __end_data_rmode = .; + } :init + .note : { . = ALIGN(4K); diff --git a/include/compiler.h b/include/compiler.h index 603b46f2..dade0e95 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -77,6 +77,10 @@ typedef uint64_t off_t; #define __data_init __section(".data.init") #define __bss_init __section(".bss.init") +#define __text_rmode __section(".text.rmode") +#define __data_rmode __section(".data.rmode") +#define __bss_rmode __section(".bss.rmode") + #define IS_INIT_SECTION(name) \ ((name) && (!strcmp(name, ".text.init") || !strcmp(name, ".data.init") || \ !strcmp(name, ".bss.init"))) diff --git a/include/mm/pmm.h b/include/mm/pmm.h index edc9d62c..903929d2 100644 --- a/include/mm/pmm.h +++ b/include/mm/pmm.h @@ -52,6 +52,9 @@ extern unsigned long __start_data_init[], __end_data_init[]; extern unsigned long __start_bss_init[], __end_bss_init[]; extern unsigned long __start_rmode[], __end_rmode[]; +extern unsigned long __start_text_rmode[], __end_text_rmode[]; +extern unsigned long __start_data_rmode[], __end_data_rmode[]; +extern unsigned long __start_bss_rmode[], __end_bss_rmode[]; extern struct ktf_param __start_cmdline[], __end_cmdline[]; diff --git a/mm/pmm.c b/mm/pmm.c index fc4cd6ac..bcaa4cf6 100644 --- a/mm/pmm.c +++ b/mm/pmm.c @@ -69,6 +69,9 @@ addr_range_t addr_ranges[] = { IDENT_RANGE( ".bss.init", L1_PROT, __start_bss_init, __end_bss_init ), IDENT_RANGE( ".rmode", L1_PROT, __start_rmode, __end_rmode ), + IDENT_RANGE( ".text.rmode", L1_PROT_RO, __start_text_rmode, __end_text_rmode), + IDENT_RANGE( ".data.rmode", L1_PROT, __start_data_rmode, __end_data_rmode), + IDENT_RANGE( ".bss.rmode", L1_PROT, __start_bss_rmode, __end_bss_rmode ), USER_RANGE( ".text.user", L1_PROT_USER_RO, __start_text_user, __end_text_user ), USER_RANGE( ".data.user", L1_PROT_USER, __start_data_user, __end_data_user ),