From b8cc156cfc08a53988a890d79587bb85cc8dc026 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 22 Feb 2023 00:58:26 +0800 Subject: [PATCH] compact phase 1 loader merge inie/inif routines more intelligently --- loader/src/phase1.rs | 616 ++++++++++++++++++------------------------- 1 file changed, 256 insertions(+), 360 deletions(-) diff --git a/loader/src/phase1.rs b/loader/src/phase1.rs index 7e12a0460..f7f05183d 100644 --- a/loader/src/phase1.rs +++ b/loader/src/phase1.rs @@ -148,398 +148,294 @@ pub fn copy_args(cfg: &mut BootConfig) { cfg.args = KernelArguments::new(runtime_arg_buffer); } +#[derive(Eq, PartialEq)] +enum TagType { + IniE, + IniF, + XKrn, + Other, +} +impl From for TagType { + fn from(code: u32) -> Self { + if code == u32::from_le_bytes(*b"IniE") { + TagType::IniE + } else if code == u32::from_le_bytes(*b"IniF") { + TagType::IniF + } else if code == u32::from_le_bytes(*b"XKrn") { + TagType::XKrn + } else { + TagType::Other + } + } +} +impl TagType { + #[cfg(feature="debug-print")] + pub fn to_str(&self) -> &'static str { + match self { + TagType::IniE => "IniE", + TagType::IniF => "IniF", + TagType::XKrn => "XKrn", + TagType::Other => "Other", + } + } +} + /// Copy program data from the SPI flash into newly-allocated RAM /// located at the end of memory space. fn copy_processes(cfg: &mut BootConfig) { let mut _pid = 1; for tag in cfg.args.iter() { - if tag.name == u32::from_le_bytes(*b"IniE") { - _pid += 1; - let mut page_addr: usize = 0; - let mut previous_addr: usize = 0; - let mut top = core::ptr::null_mut::(); + let tag_type = TagType::from(tag.name); + match tag_type { + TagType::IniF | + TagType::IniE => { + _pid += 1; + let mut page_addr: usize = 0; + let mut previous_addr: usize = 0; + let mut previous_ram_zero_addr: usize = 0; + let mut top = core::ptr::null_mut::(); - let inie = MiniElf::new(&tag); - let mut src_addr = unsafe { - cfg.base_addr - .add(inie.load_offset as usize / mem::size_of::()) - } as *const u8; + let inie = MiniElf::new(&tag); + let mut src_addr = unsafe { + cfg.base_addr + .add(inie.load_offset as usize / mem::size_of::()) + } as *const u8; - // Example: Page starts at 0xf0c0 and is 8192 bytes long. - // 1. Copy 3094 bytes to page 1 - // 2. Copy 4096 bytes to page 2 - // 3. Copy 192 bytes to page 3 - // - // Example: Page starts at 0xf000 and is 4096 bytes long - // 1. Copy 4096 bytes to page 1 - // - // Example: Page starts at 0xf000 and is 128 bytes long - // 1. Copy 128 bytes to page 1 - // - // Example: Page starts at oxf0c0 and is 128 bytes long - // 1. Copy 128 bytes to page 1 - println!("\n\nIniE {} has {} sections", _pid, inie.sections.len()); - println!("Initial top: {:x}, extra_pages: {:x}, init_size: {:x}, base_addr: {:x}", - cfg.get_top() as *mut u8 as u32, cfg.extra_pages, cfg.init_size, cfg.base_addr as u32); - for section in inie.sections.iter() { - if (section.virt as usize) < previous_addr { - panic!("init section addresses are not strictly increasing (new virt: {:08x}, last virt: {:08x})", section.virt, previous_addr); - } + // Example: Page starts at 0xf0c0 and is 8192 bytes long. + // 1. Copy 3094 bytes to page 1 + // 2. Copy 4096 bytes to page 2 + // 3. Copy 192 bytes to page 3 + // + // Example: Page starts at 0xf000 and is 4096 bytes long + // 1. Copy 4096 bytes to page 1 + // + // Example: Page starts at 0xf000 and is 128 bytes long + // 1. Copy 128 bytes to page 1 + // + // Example: Page starts at oxf0c0 and is 128 bytes long + // 1. Copy 128 bytes to page 1 + println!("\n\n{} {} has {} sections", tag_type.to_str(), _pid, inie.sections.len()); + println!("Initial top: {:x}, extra_pages: {:x}, init_size: {:x}, base_addr: {:x}", + cfg.get_top() as *mut u8 as u32, cfg.extra_pages, cfg.init_size, cfg.base_addr as u32); + for section in inie.sections.iter() { + let flags = section.flags() as u8; + // any section that requires "write" must be copied to RAM + // note that ELF helpfully adds a 4096-byte gap between non-write pages and write-pages + // allowing us to just trundle through the pages and not have to deal with partially + // writeable pages. + // IniE is always copy_to_ram + let copy_to_ram = (flags & MINIELF_FLG_W != 0) || (tag_type == TagType::IniE); - let this_page = section.virt as usize & !(PAGE_SIZE - 1); - let mut bytes_to_copy = section.len(); + if (section.virt as usize) < previous_addr { + panic!("init section addresses are not strictly increasing (new virt: {:08x}, last virt: {:08x})", section.virt, previous_addr); + } + + if copy_to_ram { + let this_page = section.virt as usize & !(PAGE_SIZE - 1); + let mut bytes_to_copy = section.len(); - if VDBG {println!( - "Section is {} bytes long, loaded to {:08x}", - bytes_to_copy, section.virt - );} - // If this is not a new page, ensure the uninitialized values from between - // this section and the previous one are all zeroed out. - if this_page != page_addr || previous_addr == page_addr { - if VDBG {println!("New page @ {:08x}", this_page);} - if previous_addr != 0 && previous_addr != page_addr { if VDBG {println!( - "Zeroing-out remainder of previous page: {:08x} (mapped to physical address {:08x})", - previous_addr, top as usize, + "Section is {} bytes long, loaded to {:08x}", + bytes_to_copy, section.virt );} - unsafe { - bzero( - top.add(previous_addr as usize & (PAGE_SIZE - 1)), - top.add(PAGE_SIZE as usize), - ) - }; - } + // If this is not a new page, ensure the uninitialized values from between + // this section and the previous one are all zeroed out. + if this_page != page_addr || previous_addr == page_addr { + if VDBG {println!("New page @ {:08x}", this_page);} + if previous_ram_zero_addr != 0 && previous_ram_zero_addr != page_addr && cfg.extra_pages > 0 { + if VDBG {println!( + "Zeroing-out remainder of previous page: {:08x} (mapped to physical address {:08x})", + previous_ram_zero_addr, top as usize, + );} + unsafe { + bzero( + top.add(previous_ram_zero_addr as usize & (PAGE_SIZE - 1)), + top.add(PAGE_SIZE as usize), + ) + }; + } - // Allocate a new page. - cfg.extra_pages += 1; - top = cfg.get_top() as *mut u8; + // Allocate a new page. + cfg.extra_pages += 1; + top = cfg.get_top() as *mut u8; - // Zero out the page, if necessary. - unsafe { bzero(top, top.add(section.virt as usize & (PAGE_SIZE - 1))) }; - } else { - if VDBG {println!("Reusing existing page @ {:08x}", this_page);} - } - - // Part 1: Copy the first chunk over. - let mut first_chunk_size = PAGE_SIZE - (section.virt as usize & (PAGE_SIZE - 1)); - if first_chunk_size > section.len() { - first_chunk_size = section.len(); - } - let first_chunk_offset = section.virt as usize & (PAGE_SIZE - 1); - if VDBG {println!( - "Section chunk is {} bytes, {} from {:08x}:{:08x} -> {:08x}:{:08x} (virt: {:08x})", - first_chunk_size, - if section.no_copy() { "zeroing" } else { "copying" }, - src_addr as usize, - unsafe { src_addr.add(first_chunk_size) as usize }, - unsafe { top.add(first_chunk_offset) as usize }, - unsafe { top.add(first_chunk_size + first_chunk_offset) - as usize }, - this_page + first_chunk_offset, - );} - // Perform the copy, if NOCOPY is not set - if !section.no_copy() { - unsafe { - memcpy(top.add(first_chunk_offset), src_addr, first_chunk_size); - src_addr = src_addr.add(first_chunk_size); - } - } else { - unsafe { - bzero( - top.add(first_chunk_offset), - top.add(first_chunk_offset + first_chunk_size), - ); - } - } - bytes_to_copy -= first_chunk_size; - - // Part 2: Copy any full pages. - while bytes_to_copy >= PAGE_SIZE { - cfg.extra_pages += 1; - top = cfg.get_top() as *mut u8; - // println!( - // "Copying next page from {:08x} {:08x} ({} bytes to go...)", - // src_addr as usize, top as usize, bytes_to_copy - // ); - if !section.no_copy() { - unsafe { - memcpy(top, src_addr, PAGE_SIZE); - src_addr = src_addr.add(PAGE_SIZE); + // Zero out the page, if necessary. + unsafe { bzero(top, top.add(section.virt as usize & (PAGE_SIZE - 1))) }; + } else { + if VDBG {println!("Reusing existing page @ {:08x}", this_page);} } - } else { - unsafe { bzero(top, top.add(PAGE_SIZE)) }; - } - bytes_to_copy -= PAGE_SIZE; - } - // Part 3: Copy the final residual partial page - if bytes_to_copy > 0 { - if VDBG {println!( - "Copying final section -- {} bytes @ {:08x}", - bytes_to_copy, - section.virt + (section.len() as u32) - (bytes_to_copy as u32) - );} - cfg.extra_pages += 1; - top = cfg.get_top() as *mut u8; - if !section.no_copy() { - unsafe { - memcpy(top, src_addr, bytes_to_copy); - src_addr = src_addr.add(bytes_to_copy); + // Part 1: Copy the first chunk over. + let mut first_chunk_size = PAGE_SIZE - (section.virt as usize & (PAGE_SIZE - 1)); + if first_chunk_size > section.len() { + first_chunk_size = section.len(); } - } else { - unsafe { bzero(top, top.add(bytes_to_copy)) }; - } - } - - previous_addr = section.virt as usize + section.len(); - page_addr = previous_addr & !(PAGE_SIZE - 1); - if VDBG { - println!("Looping to the next section"); - println!("top: {:x}, extra_pages: {:x}, init_size: {:x}, base_addr: {:x}", cfg.get_top() as *mut u8 as u32, cfg.extra_pages, cfg.init_size, cfg.base_addr as u32); - println!("previous_addr: {:x}, page_addr: {:x}", previous_addr, page_addr); - } - } - - println!("Done with sections"); - if previous_addr as usize & (PAGE_SIZE - 1) != 0 { - println!("Zeroing out remaining data"); - // Zero-out the trailing bytes - unsafe { - bzero( - top.add(previous_addr as usize & (PAGE_SIZE - 1)), - top.add(PAGE_SIZE as usize), - ) - }; - } else { - println!("Skipping zero step -- we ended on a page boundary"); - } - } else if tag.name == u32::from_le_bytes(*b"XKrn") { - let prog = unsafe { &*(tag.data.as_ptr() as *const ProgramDescription) }; - - // TEXT SECTION - // Round it off to a page boundary - let load_size_rounded = (prog.text_size as usize + PAGE_SIZE - 1) & !(PAGE_SIZE - 1); - cfg.extra_pages += load_size_rounded / PAGE_SIZE; - let top = cfg.get_top(); - println!("\n\nKernel top: {:x}, extra_pages: {:x}", top as u32, cfg.extra_pages); - unsafe { - // Copy the program to the target address, rounding it off to the load size. - let src_addr = cfg - .base_addr - .add(prog.load_offset as usize / mem::size_of::()); - println!( - " Copying TEXT from {:08x}-{:08x} to {:08x}-{:08x} ({} bytes long)", - src_addr as usize, - src_addr as u32 + prog.text_size, - top as usize, - top as u32 + prog.text_size + 4, - prog.text_size + 4 - ); - println!( - " Zeroing out TEXT from {:08x}-{:08x}", - top.add(prog.text_size as usize / mem::size_of::()) as usize, - top.add(load_size_rounded as usize / mem::size_of::()) as usize, - ); - - memcpy(top, src_addr, prog.text_size as usize + 1); - - // Zero out the remaining data. - bzero( - top.add(prog.text_size as usize / mem::size_of::()), - top.add(load_size_rounded as usize / mem::size_of::()), - ) - }; - - // DATA SECTION - // Round it off to a page boundary - let load_size_rounded = - ((prog.data_size + prog.bss_size) as usize + PAGE_SIZE - 1) & !(PAGE_SIZE - 1); - cfg.extra_pages += load_size_rounded / PAGE_SIZE; - let top = cfg.get_top(); - unsafe { - // Copy the program to the target address, rounding it off to the load size. - let src_addr = cfg.base_addr.add( - (prog.load_offset + prog.text_size + 4) as usize / mem::size_of::() - 1, - ); - println!( - " Copying DATA from {:08x}-{:08x} to {:08x}-{:08x} ({} bytes long)", - src_addr as usize, - src_addr as u32 + prog.data_size, - top as usize, - top as u32 + prog.data_size, - prog.data_size - ); - memcpy(top, src_addr, prog.data_size as usize + 1); - - // Zero out the remaining data. - println!( - " Zeroing out DATA from {:08x} - {:08x}", - top.add(prog.data_size as usize / mem::size_of::()) as usize, - top.add(load_size_rounded as usize / mem::size_of::()) as usize - ); - bzero( - top.add(prog.data_size as usize / mem::size_of::()), - top.add(load_size_rounded as usize / mem::size_of::()), - ) - }; - } else if tag.name == u32::from_le_bytes(*b"IniF") { - _pid += 1; - let mut page_addr: usize = 0; - let mut previous_addr: usize = 0; - let mut previous_ram_zero_addr: usize = 0; - let mut top = core::ptr::null_mut::(); - - let inif = MiniElf::new(&tag); - let mut src_addr = unsafe { - cfg.base_addr - .add(inif.load_offset as usize / mem::size_of::()) - } as *const u8; - // let mut accumulated_len = 0; - - println!("\n\nIniF {} has {} sections", _pid, inif.sections.len()); - println!("Initial top: {:x}, extra_pages: {:x}, init_size: {:x}, base_addr: {:x}", cfg.get_top() as *mut u8 as u32, cfg.extra_pages, cfg.init_size, cfg.base_addr as u32); - for section in inif.sections.iter() { - let flags = section.flags() as u8; - // any section that requires "write" must be copied to RAM - // note that ELF helpfully adds a 4096-byte gap between non-write pages and write-pages - // allowing us to just trundle through the pages and not have to deal with partially - // writeable pages. - let copy_to_ram = flags & MINIELF_FLG_W != 0; - if (section.virt as usize) < previous_addr { - panic!("init section addresses are not strictly increasing (new virt: {:08x}, last virt: {:08x})", section.virt, previous_addr); - } - if copy_to_ram { - let this_page = section.virt as usize & !(PAGE_SIZE - 1); - let mut bytes_to_copy = section.len(); - - if VDBG {println!( - "Section is {} bytes long, loaded to {:08x}", - bytes_to_copy, section.virt - );} - // If this is not a new page, ensure the uninitialized values from between - // this section and the previous one are all zeroed out. - if this_page != page_addr || previous_addr == page_addr { - if VDBG {println!("New page @ {:08x}", this_page);} - if previous_ram_zero_addr != 0 && previous_ram_zero_addr != page_addr && cfg.extra_pages > 0 { - if VDBG {println!( - "Zeroing-out remainder of previous page: {:08x} (mapped to physical address {:08x})", - previous_ram_zero_addr, top as usize, - );} + let first_chunk_offset = section.virt as usize & (PAGE_SIZE - 1); + if VDBG {println!( + "Section chunk is {} bytes, {} from {:08x}:{:08x} -> {:08x}:{:08x} (virt: {:08x})", + first_chunk_size, + if section.no_copy() { "zeroing" } else { "copying" }, + src_addr as usize, + unsafe { src_addr.add(first_chunk_size) as usize }, + unsafe { top.add(first_chunk_offset) as usize }, + unsafe { top.add(first_chunk_size + first_chunk_offset) + as usize }, + this_page + first_chunk_offset, + );} + // Perform the copy, if NOCOPY is not set + if !section.no_copy() { + unsafe { + memcpy(top.add(first_chunk_offset), src_addr, first_chunk_size); + src_addr = src_addr.add(first_chunk_size); + } + } else { unsafe { bzero( - top.add(previous_ram_zero_addr as usize & (PAGE_SIZE - 1)), - top.add(PAGE_SIZE as usize), - ) - }; - } - - // Allocate a new page. - cfg.extra_pages += 1; - top = cfg.get_top() as *mut u8; - - // Zero out the page, if necessary. - unsafe { bzero(top, top.add(section.virt as usize & (PAGE_SIZE - 1))) }; - } else { - if VDBG {println!("Reusing existing page @ {:08x}", this_page);} - } - - // Part 1: Copy the first chunk over. - let mut first_chunk_size = PAGE_SIZE - (section.virt as usize & (PAGE_SIZE - 1)); - if first_chunk_size > section.len() { - first_chunk_size = section.len(); - } - let first_chunk_offset = section.virt as usize & (PAGE_SIZE - 1); - if VDBG {println!( - "Section chunk is {} bytes, {} from {:08x}:{:08x} -> {:08x}:{:08x} (virt: {:08x})", - first_chunk_size, - if section.no_copy() { "zeroing" } else { "copying" }, - src_addr as usize, - unsafe { src_addr.add(first_chunk_size) as usize }, - unsafe { top.add(first_chunk_offset) as usize }, - unsafe { top.add(first_chunk_size + first_chunk_offset) - as usize }, - this_page + first_chunk_offset, - );} - // Perform the copy, if NOCOPY is not set - if !section.no_copy() { - unsafe { - memcpy(top.add(first_chunk_offset), src_addr, first_chunk_size); - src_addr = src_addr.add(first_chunk_size); - } - } else { - unsafe { - bzero( - top.add(first_chunk_offset), - top.add(first_chunk_offset + first_chunk_size), - ); - } - } - bytes_to_copy -= first_chunk_size; - - // Part 2: Copy any full pages. - while bytes_to_copy >= PAGE_SIZE { - cfg.extra_pages += 1; - top = cfg.get_top() as *mut u8; - // println!( - // "Copying next page from {:08x} {:08x} ({} bytes to go...)", - // src_addr as usize, top as usize, bytes_to_copy - // ); - if !section.no_copy() { - unsafe { - memcpy(top, src_addr, PAGE_SIZE); - src_addr = src_addr.add(PAGE_SIZE); + top.add(first_chunk_offset), + top.add(first_chunk_offset + first_chunk_size), + ); } - } else { - unsafe { bzero(top, top.add(PAGE_SIZE)) }; } - bytes_to_copy -= PAGE_SIZE; + bytes_to_copy -= first_chunk_size; + + // Part 2: Copy any full pages. + while bytes_to_copy >= PAGE_SIZE { + cfg.extra_pages += 1; + top = cfg.get_top() as *mut u8; + // println!( + // "Copying next page from {:08x} {:08x} ({} bytes to go...)", + // src_addr as usize, top as usize, bytes_to_copy + // ); + if !section.no_copy() { + unsafe { + memcpy(top, src_addr, PAGE_SIZE); + src_addr = src_addr.add(PAGE_SIZE); + } + } else { + unsafe { bzero(top, top.add(PAGE_SIZE)) }; + } + bytes_to_copy -= PAGE_SIZE; + } + + // Part 3: Copy the final residual partial page + if bytes_to_copy > 0 { + if VDBG {println!( + "Copying final section -- {} bytes @ {:08x}", + bytes_to_copy, + section.virt + (section.len() as u32) - (bytes_to_copy as u32) + );} + cfg.extra_pages += 1; + top = cfg.get_top() as *mut u8; + if !section.no_copy() { + unsafe { + memcpy(top, src_addr, bytes_to_copy); + src_addr = src_addr.add(bytes_to_copy); + } + } else { + unsafe { bzero(top, top.add(bytes_to_copy)) }; + } + } + previous_ram_zero_addr = section.virt as usize + section.len(); + } else { + top = cfg.get_top() as *mut u8; + src_addr = unsafe {src_addr.add(section.len())}; } - // Part 3: Copy the final residual partial page - if bytes_to_copy > 0 { - if VDBG {println!( - "Copying final section -- {} bytes @ {:08x}", - bytes_to_copy, - section.virt + (section.len() as u32) - (bytes_to_copy as u32) - );} - cfg.extra_pages += 1; - top = cfg.get_top() as *mut u8; - if !section.no_copy() { - unsafe { - memcpy(top, src_addr, bytes_to_copy); - src_addr = src_addr.add(bytes_to_copy); - } - } else { - unsafe { bzero(top, top.add(bytes_to_copy)) }; - } + previous_addr = section.virt as usize + section.len(); + page_addr = previous_addr & !(PAGE_SIZE - 1); + if VDBG { + println!("Looping to the next section"); + println!("top: {:x}, extra_pages: {:x}, init_size: {:x}, base_addr: {:x}", cfg.get_top() as *mut u8 as u32, cfg.extra_pages, cfg.init_size, cfg.base_addr as u32); + println!("previous_addr: {:x}, page_addr: {:x}", previous_addr, page_addr); } - previous_ram_zero_addr = section.virt as usize + section.len(); - } else { - top = cfg.get_top() as *mut u8; - src_addr = unsafe {src_addr.add(section.len())}; } - previous_addr = section.virt as usize + section.len(); - page_addr = previous_addr & !(PAGE_SIZE - 1); - if VDBG { - println!("Looping to the next section"); - println!("top: {:x}, extra_pages: {:x}, init_size: {:x}, base_addr: {:x}", cfg.get_top() as *mut u8 as u32, cfg.extra_pages, cfg.init_size, cfg.base_addr as u32); - println!("previous_addr: {:x}, page_addr: {:x}", previous_addr, page_addr); + println!("Done with sections"); + if previous_addr as usize & (PAGE_SIZE - 1) != 0 { + println!("Zeroing out remaining data"); + // Zero-out the trailing bytes + unsafe { + bzero( + top.add(previous_addr as usize & (PAGE_SIZE - 1)), + top.add(PAGE_SIZE as usize), + ) + }; + } else { + println!("Skipping zero step -- we ended on a page boundary"); } } + TagType::XKrn => { + let prog = unsafe { &*(tag.data.as_ptr() as *const ProgramDescription) }; - println!("Done with sections"); - if previous_addr as usize & (PAGE_SIZE - 1) != 0 { - println!("Zeroing out remaining data"); - // Zero-out the trailing bytes + // TEXT SECTION + // Round it off to a page boundary + let load_size_rounded = (prog.text_size as usize + PAGE_SIZE - 1) & !(PAGE_SIZE - 1); + cfg.extra_pages += load_size_rounded / PAGE_SIZE; + let top = cfg.get_top(); + println!("\n\nKernel top: {:x}, extra_pages: {:x}", top as u32, cfg.extra_pages); unsafe { + // Copy the program to the target address, rounding it off to the load size. + let src_addr = cfg + .base_addr + .add(prog.load_offset as usize / mem::size_of::()); + println!( + " Copying TEXT from {:08x}-{:08x} to {:08x}-{:08x} ({} bytes long)", + src_addr as usize, + src_addr as u32 + prog.text_size, + top as usize, + top as u32 + prog.text_size + 4, + prog.text_size + 4 + ); + println!( + " Zeroing out TEXT from {:08x}-{:08x}", + top.add(prog.text_size as usize / mem::size_of::()) as usize, + top.add(load_size_rounded as usize / mem::size_of::()) as usize, + ); + + memcpy(top, src_addr, prog.text_size as usize + 1); + + // Zero out the remaining data. bzero( - top.add(previous_addr as usize & (PAGE_SIZE - 1)), - top.add(PAGE_SIZE as usize), + top.add(prog.text_size as usize / mem::size_of::()), + top.add(load_size_rounded as usize / mem::size_of::()), ) }; - } else { - println!("Skipping zero step -- we ended on a page boundary"); + + // DATA SECTION + // Round it off to a page boundary + let load_size_rounded = + ((prog.data_size + prog.bss_size) as usize + PAGE_SIZE - 1) & !(PAGE_SIZE - 1); + cfg.extra_pages += load_size_rounded / PAGE_SIZE; + let top = cfg.get_top(); + unsafe { + // Copy the program to the target address, rounding it off to the load size. + let src_addr = cfg.base_addr.add( + (prog.load_offset + prog.text_size + 4) as usize / mem::size_of::() - 1, + ); + println!( + " Copying DATA from {:08x}-{:08x} to {:08x}-{:08x} ({} bytes long)", + src_addr as usize, + src_addr as u32 + prog.data_size, + top as usize, + top as u32 + prog.data_size, + prog.data_size + ); + memcpy(top, src_addr, prog.data_size as usize + 1); + + // Zero out the remaining data. + println!( + " Zeroing out DATA from {:08x} - {:08x}", + top.add(prog.data_size as usize / mem::size_of::()) as usize, + top.add(load_size_rounded as usize / mem::size_of::()) as usize + ); + bzero( + top.add(prog.data_size as usize / mem::size_of::()), + top.add(load_size_rounded as usize / mem::size_of::()), + ) + } + } + _ => { + } } }