@@ -43,7 +43,7 @@ impl BootloaderConfig {
43
43
0x3D ,
44
44
] ;
45
45
#[ doc( hidden) ]
46
- pub const SERIALIZED_LEN : usize = 124 ;
46
+ pub const SERIALIZED_LEN : usize = 133 ;
47
47
48
48
/// Creates a new default configuration with the following values:
49
49
///
@@ -77,6 +77,7 @@ impl BootloaderConfig {
77
77
} = version;
78
78
let Mappings {
79
79
kernel_stack,
80
+ kernel_base,
80
81
boot_info,
81
82
framebuffer,
82
83
physical_memory,
@@ -97,53 +98,56 @@ impl BootloaderConfig {
97
98
concat_4_3 ( one, two)
98
99
} ;
99
100
let buf = concat_16_7 ( Self :: UUID , version) ;
101
+
100
102
let buf = concat_23_8 ( buf, kernel_stack_size. to_le_bytes ( ) ) ;
101
103
102
104
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_base. serialize ( ) ) ;
106
+
107
+ let buf = concat_49_9 ( buf, boot_info. serialize ( ) ) ;
108
+ let buf = concat_58_9 ( buf, framebuffer. serialize ( ) ) ;
105
109
106
- let buf = concat_58_10 (
110
+ let buf = concat_67_10 (
107
111
buf,
108
112
match physical_memory {
109
113
Option :: None => [ 0 ; 10 ] ,
110
114
Option :: Some ( m) => concat_1_9 ( [ 1 ] , m. serialize ( ) ) ,
111
115
} ,
112
116
) ;
113
- let buf = concat_68_10 (
117
+ let buf = concat_77_10 (
114
118
buf,
115
119
match page_table_recursive {
116
120
Option :: None => [ 0 ; 10 ] ,
117
121
Option :: Some ( m) => concat_1_9 ( [ 1 ] , m. serialize ( ) ) ,
118
122
} ,
119
123
) ;
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 (
122
126
buf,
123
127
match dynamic_range_start {
124
128
Option :: None => [ 0 ; 9 ] ,
125
129
Option :: Some ( addr) => concat_1_8 ( [ 1 ] , addr. to_le_bytes ( ) ) ,
126
130
} ,
127
131
) ;
128
- let buf = concat_88_9 (
132
+ let buf = concat_97_9 (
129
133
buf,
130
134
match dynamic_range_end {
131
135
Option :: None => [ 0 ; 9 ] ,
132
136
Option :: Some ( addr) => concat_1_8 ( [ 1 ] , addr. to_le_bytes ( ) ) ,
133
137
} ,
134
138
) ;
135
139
136
- let buf = concat_97_9 ( buf, ramdisk_memory. serialize ( ) ) ;
140
+ let buf = concat_106_9 ( buf, ramdisk_memory. serialize ( ) ) ;
137
141
138
- let buf = concat_106_9 (
142
+ let buf = concat_115_9 (
139
143
buf,
140
144
match minimum_framebuffer_height {
141
145
Option :: None => [ 0 ; 9 ] ,
142
146
Option :: Some ( addr) => concat_1_8 ( [ 1 ] , addr. to_le_bytes ( ) ) ,
143
147
} ,
144
148
) ;
145
149
146
- concat_115_9 (
150
+ concat_124_9 (
147
151
buf,
148
152
match minimum_framebuffer_width {
149
153
Option :: None => [ 0 ; 9 ] ,
@@ -196,6 +200,7 @@ impl BootloaderConfig {
196
200
197
201
let ( mappings, s) = {
198
202
let ( & kernel_stack, s) = split_array_ref ( s) ;
203
+ let ( & kernel_base, s) = split_array_ref ( s) ;
199
204
let ( & boot_info, s) = split_array_ref ( s) ;
200
205
let ( & framebuffer, s) = split_array_ref ( s) ;
201
206
let ( & physical_memory_some, s) = split_array_ref ( s) ;
@@ -211,6 +216,7 @@ impl BootloaderConfig {
211
216
212
217
let mappings = Mappings {
213
218
kernel_stack : Mapping :: deserialize ( & kernel_stack) ?,
219
+ kernel_base : Mapping :: deserialize ( & kernel_base) ?,
214
220
boot_info : Mapping :: deserialize ( & boot_info) ?,
215
221
framebuffer : Mapping :: deserialize ( & framebuffer) ?,
216
222
physical_memory : match physical_memory_some {
@@ -371,6 +377,11 @@ pub struct Mappings {
371
377
/// `FixedAddress(0xf_0000_0000)` will result in a guard page at address
372
378
/// `0xf_0000_0000` and the kernel stack starting at address `0xf_0000_1000`.
373
379
pub kernel_stack : Mapping ,
380
+ /// Configures the base address of the kernel.
381
+ ///
382
+ /// If a fixed address is set, it must be paged aligned and the kernel must be
383
+ /// a position-independent exectuable.
384
+ pub kernel_base : Mapping ,
374
385
/// Specifies where the [`crate::BootInfo`] struct should be placed in virtual memory.
375
386
pub boot_info : Mapping ,
376
387
/// Specifies the mapping of the frame buffer memory region.
@@ -413,6 +424,7 @@ impl Mappings {
413
424
pub const fn new_default ( ) -> Self {
414
425
Self {
415
426
kernel_stack : Mapping :: new_default ( ) ,
427
+ kernel_base : Mapping :: new_default ( ) ,
416
428
boot_info : Mapping :: new_default ( ) ,
417
429
framebuffer : Mapping :: new_default ( ) ,
418
430
physical_memory : Option :: None ,
@@ -430,6 +442,7 @@ impl Mappings {
430
442
let recursive = rand:: random ( ) ;
431
443
Self {
432
444
kernel_stack : Mapping :: random ( ) ,
445
+ kernel_base : Mapping :: random ( ) ,
433
446
boot_info : Mapping :: random ( ) ,
434
447
framebuffer : Mapping :: random ( ) ,
435
448
physical_memory : if phys {
0 commit comments