Skip to content

Commit 555769c

Browse files
committed
Allow setting the ramdisk location via bootloader config
1 parent eb65960 commit 555769c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

api/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fn main() {
2222
(88, 9),
2323
(97, 9),
2424
(106, 9),
25+
(115, 9)
2526
];
2627

2728
let mut code = String::new();

api/src/config.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl BootloaderConfig {
3535
0x3D,
3636
];
3737
#[doc(hidden)]
38-
pub const SERIALIZED_LEN: usize = 115;
38+
pub const SERIALIZED_LEN: usize = 124;
3939

4040
/// Creates a new default configuration with the following values:
4141
///
@@ -77,6 +77,7 @@ impl BootloaderConfig {
7777
aslr,
7878
dynamic_range_start,
7979
dynamic_range_end,
80+
ramdisk_memory,
8081
} = mappings;
8182
let FrameBuffer {
8283
minimum_framebuffer_height,
@@ -133,13 +134,15 @@ impl BootloaderConfig {
133134
},
134135
);
135136

136-
concat_106_9(
137+
let buf = concat_106_9(
137138
buf,
138139
match minimum_framebuffer_width {
139140
Option::None => [0; 9],
140141
Option::Some(addr) => concat_1_8([1], addr.to_le_bytes()),
141142
},
142-
)
143+
);
144+
145+
concat_115_9(buf, ramdisk_memory.serialize())
143146
}
144147

145148
/// Tries to deserialize a config byte array that was created using [`Self::serialize`].
@@ -197,6 +200,7 @@ impl BootloaderConfig {
197200
let (&dynamic_range_start, s) = split_array_ref(s);
198201
let (&dynamic_range_end_some, s) = split_array_ref(s);
199202
let (&dynamic_range_end, s) = split_array_ref(s);
203+
let (&ramdisk_memory, s) = split_array_ref(s);
200204

201205
let mappings = Mappings {
202206
kernel_stack: Mapping::deserialize(&kernel_stack)?,
@@ -227,6 +231,7 @@ impl BootloaderConfig {
227231
[1] => Option::Some(u64::from_le_bytes(dynamic_range_end)),
228232
_ => return Err("invalid dynamic range end value"),
229233
},
234+
ramdisk_memory: Mapping::deserialize(&ramdisk_memory)?
230235
};
231236
(mappings, s)
232237
};
@@ -381,6 +386,9 @@ pub struct Mappings {
381386
///
382387
/// Defaults to `0xffff_ffff_ffff_f000`.
383388
pub dynamic_range_end: Option<u64>,
389+
/// Virtual address to map ramdisk image, if present on disk
390+
/// Defaults to dynamic
391+
pub ramdisk_memory: Mapping
384392
}
385393

386394
impl Mappings {
@@ -397,6 +405,7 @@ impl Mappings {
397405
aslr: false,
398406
dynamic_range_start: None,
399407
dynamic_range_end: None,
408+
ramdisk_memory: Mapping::new_default()
400409
}
401410
}
402411

@@ -429,6 +438,7 @@ impl Mappings {
429438
} else {
430439
Option::None
431440
},
441+
ramdisk_memory: Mapping::random()
432442
}
433443
}
434444
}

0 commit comments

Comments
 (0)