pub fn load_items<T>(root: Dir<T>, config: config::Config) -> Result<usize, FileError>
where
    T: BlockDevice + Clone + Copy,
    <T as BlockDevice>::Error: Debug,
{
    let mut initrd_size = 0;

    // loading kernel img
    print!("  Loading {}...", config.kernel);
    let kernel_img = root.open_file(config.kernel).unwrap();
    let mut img_region = MemoryRegion::new(ELF_START as u64, kernel_img.len() as u64);
    let mut img = img_region.as_mut_slice::<u8>(0, img_region.len());
    kernel_img.read(&mut img)?;
    println!(" done!");

    // loading initrd if config exists
    if let Some(initrd) = config.initrd {
        print!("  Loading {}...", initrd);
        let initrd_img = root.open_file(initrd).unwrap();
        let mut rd_region = MemoryRegion::new(INITRD_START as u64, initrd_img.len() as u64);
        let mut rd = rd_region.as_mut_slice::<u8>(0, rd_region.len());
        initrd_img.read(&mut rd)?;
        initrd_size = initrd_img.len() as u32;
        println!(" done!")
    }

    // setting command line if config exists
    if let Some(cmdlin) = config.cmdlin {
        print!("  Setting command line...");
        setup_cmdline(cmdlin);
        println!(" done!");
    }

    // zero_page setup
    setup_zero_page(kernel_img.len() as u32, initrd_size);

    Ok(kernel_img.len())
}
// do loading kernel, initrd and command line and setting. return kernel size
do loading kernel, initrd and command line and setting. return kernel size
do loading kernel initrd and command line and setting . return kernel size
pub fn load_items<T>(root: Dir<T>, config: config::Config) -> Result<usize, FileError>
where
    T: BlockDevice + Clone + Copy,
    <T as BlockDevice>::Error: Debug,
{
    let mut initrd_size = 0;
    // loading kernel img
    print!("  Loading {}...", config.kernel);
    let kernel_img = root.open_file(config.kernel).unwrap();
    let mut img_region = MemoryRegion::new(ELF_START as u64, kernel_img.len() as u64);
    let mut img = img_region.as_mut_slice::<u8>(0, img_region.len());
    kernel_img.read(&mut img)?;
    println!(" done!");
    // loading initrd if config exists
    if let Some(initrd) = config.initrd {
        print!("  Loading {}...", initrd);
        let initrd_img = root.open_file(initrd).unwrap();
        let mut rd_region = MemoryRegion::new(INITRD_START as u64, initrd_img.len() as u64);
        let mut rd = rd_region.as_mut_slice::<u8>(0, rd_region.len());
        initrd_img.read(&mut rd)?;
        initrd_size = initrd_img.len() as u32;
        println!(" done!")
    }
    // setting command line if config exists
    if let Some(cmdlin) = config.cmdlin {
        print!("  Setting command line...");
        setup_cmdline(cmdlin);
        println!(" done!");
    }
    // zero_page setup
    setup_zero_page(kernel_img.len() as u32, initrd_size);
    Ok(kernel_img.len())
}
pub fn load_items < T > ( root : Dir < T > , config : config :: Config ) -> Result < usize , FileError > where T : BlockDevice + Clone + Copy , < T as BlockDevice > :: Error : Debug , { let mut initrd_size = 0 ; // loading kernel img print ! ( " " config kernel ) ; let kernel_img = root . open_file ( config . kernel ) . unwrap ( ) ; let mut img_region = MemoryRegion :: new ( ELF_START as u64 , kernel_img . len ( ) as u64 ) ; let mut img = img_region . as_mut_slice :: < u8 > ( 0 , img_region . len ( ) ) ; kernel_img . read ( & mut img ) ? ; println ! ( " " ) ; // loading initrd if config exists if let Some ( initrd ) = config . initrd { print ! ( " " initrd ) ; let initrd_img = root . open_file ( initrd ) . unwrap ( ) ; let mut rd_region = MemoryRegion :: new ( INITRD_START as u64 , initrd_img . len ( ) as u64 ) ; let mut rd = rd_region . as_mut_slice :: < u8 > ( 0 , rd_region . len ( ) ) ; initrd_img . read ( & mut rd ) ? ; initrd_size = initrd_img . len ( ) as u32 ; println ! ( " " ) } // setting command line if config exists if let Some ( cmdlin ) = config . cmdlin { print ! ( " " ) ; setup_cmdline ( cmdlin ) ; println ! ( " " ) ; } // zero_page setup setup_zero_page ( kernel_img . len ( ) as u32 , initrd_size ) ; Ok ( kernel_img . len ( ) ) }
do loading kernel, initrd and command line and setting.
do loading kernel initrd and command line and setting .
root
Dir<T>
config
config::Config