@@ -42,7 +42,7 @@ const KERNEL_COPY_FILENAME: &str = "sel4.elf";
4242const KERNEL32_COPY_FILENAME : & str = "sel4_32.elf" ;
4343
4444fn print_usage ( ) {
45- println ! ( "usage: microkit [-h] [-o OUTPUT] [--image-type {{binary,elf,uimage}}] [-r REPORT] -- board BOARD --config CONFIG [--capdl-json CAPDL_SPEC] -- search-path [ SEARCH_PATH ...] system" )
45+ println ! ( "usage: microkit [-h] [OPTIONS] -- board BOARD --config CONFIG [--search-path SEARCH_PATH ...] system" )
4646}
4747
4848fn print_help ( available_boards : & [ String ] ) {
@@ -54,6 +54,7 @@ fn print_help(available_boards: &[String]) {
5454 println ! ( " -o, --output OUTPUT" ) ;
5555 println ! ( " -r, --report REPORT" ) ;
5656 println ! ( " --image-type {{binary,elf}}" ) ;
57+ println ! ( " --override-kernel KERNEL (for debugging purposes)" ) ;
5758 println ! ( " --board {}" , available_boards. join( "\n " ) ) ;
5859 println ! ( " --config CONFIG" ) ;
5960 println ! ( " --capdl-json CAPDL_SPEC (JSON format)" ) ;
@@ -107,6 +108,7 @@ struct Args<'a> {
107108 output : & ' a str ,
108109 search_paths : Vec < & ' a String > ,
109110 output_image_type : Option < & ' a str > ,
111+ override_kernel : Option < & ' a str > ,
110112}
111113
112114impl < ' a > Args < ' a > {
@@ -121,6 +123,7 @@ impl<'a> Args<'a> {
121123 let mut board = None ;
122124 let mut config = None ;
123125 let mut output_image_type = None ;
126+ let mut override_kernel = None ;
124127
125128 if args. len ( ) <= 1 {
126129 print_usage ( ) ;
@@ -198,6 +201,17 @@ impl<'a> Args<'a> {
198201 std:: process:: exit ( 1 ) ;
199202 }
200203 }
204+ "--override-kernel" => {
205+ if i < args. len ( ) - 1 {
206+ override_kernel = Some ( args[ i + 1 ] . as_str ( ) ) ;
207+ i += 1 ;
208+ } else {
209+ eprintln ! (
210+ "microkit: error: argument --override-kernel: expected one argument"
211+ ) ;
212+ std:: process:: exit ( 1 ) ;
213+ }
214+ }
201215 _ => {
202216 if in_search_path {
203217 search_paths. push ( & args[ i] ) ;
@@ -252,6 +266,7 @@ impl<'a> Args<'a> {
252266 output,
253267 search_paths,
254268 output_image_type,
269+ override_kernel,
255270 }
256271 }
257272}
@@ -339,7 +354,10 @@ fn main() -> Result<(), String> {
339354 . join ( args. config )
340355 . join ( "elf" ) ;
341356 let loader_elf_path = elf_path. join ( "loader.elf" ) ;
342- let kernel_elf_path = elf_path. join ( "sel4.elf" ) ;
357+ let kernel_elf_path = match args. override_kernel {
358+ Some ( path) => Path :: new ( path) ,
359+ None => & elf_path. join ( "sel4.elf" ) ,
360+ } ;
343361 let monitor_elf_path = elf_path. join ( "monitor.elf" ) ;
344362 let capdl_init_elf_path = elf_path. join ( "initialiser.elf" ) ;
345363
@@ -596,7 +614,7 @@ fn main() -> Result<(), String> {
596614 match kernel_config. arch {
597615 Arch :: X86_64 => ( None , None , None ) ,
598616 Arch :: Aarch64 | Arch :: Riscv64 => {
599- let kernel_elf = ElfFile :: from_path ( & kernel_elf_path) . unwrap_or_else ( |e| {
617+ let kernel_elf = ElfFile :: from_path ( kernel_elf_path) . unwrap_or_else ( |e| {
600618 eprintln ! (
601619 "ERROR: failed to parse kernel ELF ({}): {}" ,
602620 kernel_elf_path. display( ) ,
@@ -921,7 +939,7 @@ fn main() -> Result<(), String> {
921939 Ok ( size) => {
922940 // Copy the kernel to the build directory as well so users doesn't have to dig through the SDK.
923941 if let Err ( copy_err) = fs:: copy (
924- & kernel_elf_path,
942+ kernel_elf_path,
925943 image_out_path. parent ( ) . unwrap ( ) . join ( KERNEL_COPY_FILENAME ) ,
926944 ) {
927945 eprintln ! ( "ERROR: couldn't copy the kernel to image's output directory: {copy_err}" ) ;
0 commit comments