@@ -43,7 +43,7 @@ impl BootloaderConfig {
4343 0x3D ,
4444 ] ;
4545 #[ doc( hidden) ]
46- pub const SERIALIZED_LEN : usize = 124 ;
46+ pub const SERIALIZED_LEN : usize = 133 ;
4747
4848 /// Creates a new default configuration with the following values:
4949 ///
@@ -77,6 +77,7 @@ impl BootloaderConfig {
7777 } = version;
7878 let Mappings {
7979 kernel_stack,
80+ kernel_code,
8081 boot_info,
8182 framebuffer,
8283 physical_memory,
@@ -97,53 +98,56 @@ impl BootloaderConfig {
9798 concat_4_3 ( one, two)
9899 } ;
99100 let buf = concat_16_7 ( Self :: UUID , version) ;
101+
100102 let buf = concat_23_8 ( buf, kernel_stack_size. to_le_bytes ( ) ) ;
101103
102104 let buf = concat_31_9 ( buf, kernel_stack. serialize ( ) ) ;
103- let buf = concat_40_9 ( buf, boot_info. serialize ( ) ) ;
104- let buf = concat_49_9 ( buf, framebuffer. serialize ( ) ) ;
105+ let buf = concat_40_9 ( buf, kernel_code. serialize ( ) ) ;
106+
107+ let buf = concat_49_9 ( buf, boot_info. serialize ( ) ) ;
108+ let buf = concat_58_9 ( buf, framebuffer. serialize ( ) ) ;
105109
106- let buf = concat_58_10 (
110+ let buf = concat_67_10 (
107111 buf,
108112 match physical_memory {
109113 Option :: None => [ 0 ; 10 ] ,
110114 Option :: Some ( m) => concat_1_9 ( [ 1 ] , m. serialize ( ) ) ,
111115 } ,
112116 ) ;
113- let buf = concat_68_10 (
117+ let buf = concat_77_10 (
114118 buf,
115119 match page_table_recursive {
116120 Option :: None => [ 0 ; 10 ] ,
117121 Option :: Some ( m) => concat_1_9 ( [ 1 ] , m. serialize ( ) ) ,
118122 } ,
119123 ) ;
120- let buf = concat_78_1 ( buf, [ ( * aslr) as u8 ] ) ;
121- let buf = concat_79_9 (
124+ let buf = concat_87_1 ( buf, [ ( * aslr) as u8 ] ) ;
125+ let buf = concat_88_9 (
122126 buf,
123127 match dynamic_range_start {
124128 Option :: None => [ 0 ; 9 ] ,
125129 Option :: Some ( addr) => concat_1_8 ( [ 1 ] , addr. to_le_bytes ( ) ) ,
126130 } ,
127131 ) ;
128- let buf = concat_88_9 (
132+ let buf = concat_97_9 (
129133 buf,
130134 match dynamic_range_end {
131135 Option :: None => [ 0 ; 9 ] ,
132136 Option :: Some ( addr) => concat_1_8 ( [ 1 ] , addr. to_le_bytes ( ) ) ,
133137 } ,
134138 ) ;
135139
136- let buf = concat_97_9 ( buf, ramdisk_memory. serialize ( ) ) ;
140+ let buf = concat_106_9 ( buf, ramdisk_memory. serialize ( ) ) ;
137141
138- let buf = concat_106_9 (
142+ let buf = concat_115_9 (
139143 buf,
140144 match minimum_framebuffer_height {
141145 Option :: None => [ 0 ; 9 ] ,
142146 Option :: Some ( addr) => concat_1_8 ( [ 1 ] , addr. to_le_bytes ( ) ) ,
143147 } ,
144148 ) ;
145149
146- concat_115_9 (
150+ concat_124_9 (
147151 buf,
148152 match minimum_framebuffer_width {
149153 Option :: None => [ 0 ; 9 ] ,
@@ -196,6 +200,7 @@ impl BootloaderConfig {
196200
197201 let ( mappings, s) = {
198202 let ( & kernel_stack, s) = split_array_ref ( s) ;
203+ let ( & kernel_code, s) = split_array_ref ( s) ;
199204 let ( & boot_info, s) = split_array_ref ( s) ;
200205 let ( & framebuffer, s) = split_array_ref ( s) ;
201206 let ( & physical_memory_some, s) = split_array_ref ( s) ;
@@ -211,6 +216,7 @@ impl BootloaderConfig {
211216
212217 let mappings = Mappings {
213218 kernel_stack : Mapping :: deserialize ( & kernel_stack) ?,
219+ kernel_code : Mapping :: deserialize ( & kernel_code) ?,
214220 boot_info : Mapping :: deserialize ( & boot_info) ?,
215221 framebuffer : Mapping :: deserialize ( & framebuffer) ?,
216222 physical_memory : match physical_memory_some {
@@ -371,6 +377,11 @@ pub struct Mappings {
371377 /// `FixedAddress(0xf_0000_0000)` will result in a guard page at address
372378 /// `0xf_0000_0000` and the kernel stack starting at address `0xf_0000_1000`.
373379 pub kernel_stack : Mapping ,
380+ /// Configures how the kernel code should be mapped.
381+ ///
382+ /// If a fixed address is set, it must be paged alignned and requires the kernel to
383+ /// be a shared object.
384+ pub kernel_code : Mapping ,
374385 /// Specifies where the [`crate::BootInfo`] struct should be placed in virtual memory.
375386 pub boot_info : Mapping ,
376387 /// Specifies the mapping of the frame buffer memory region.
@@ -413,6 +424,7 @@ impl Mappings {
413424 pub const fn new_default ( ) -> Self {
414425 Self {
415426 kernel_stack : Mapping :: new_default ( ) ,
427+ kernel_code : Mapping :: new_default ( ) ,
416428 boot_info : Mapping :: new_default ( ) ,
417429 framebuffer : Mapping :: new_default ( ) ,
418430 physical_memory : Option :: None ,
@@ -430,6 +442,7 @@ impl Mappings {
430442 let recursive = rand:: random ( ) ;
431443 Self {
432444 kernel_stack : Mapping :: random ( ) ,
445+ kernel_code : Mapping :: random ( ) ,
433446 boot_info : Mapping :: random ( ) ,
434447 framebuffer : Mapping :: random ( ) ,
435448 physical_memory : if phys {
0 commit comments