Skip to content

Commit

Permalink
feat(exec2.5-multiprogram support): batch implment
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyliu16 committed Nov 19, 2023
1 parent 724adc8 commit 5d04c0d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 50 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/loader/Cargo.toml
Expand Up @@ -7,4 +7,5 @@ edition = "2021"

[dependencies]
axstd = { path = "../../ulib/axstd", optional = true }
log = "0.4.0"
arceos_api = { path = "../../api/arceos_api" }
72 changes: 22 additions & 50 deletions apps/loader/src/main.rs
@@ -1,3 +1,4 @@
#![allow(dead_code, unused)]
#![feature(asm_const)]
#![cfg_attr(feature = "axstd", no_std)]
#![cfg_attr(feature = "axstd", no_main)]
Expand All @@ -8,10 +9,14 @@ use core::mem::size_of;
use axstd::println;
const PLASH_START: usize = 0x22000000;
const LOAD_START: usize = 0xffff_ffc0_8010_0000;

use log::{debug, error, info, trace, warn};

#[cfg_attr(feature = "axstd", no_mangle)]
fn main() {
println!("RUN LOADER");
let apps_start = PLASH_START as *const u8;
let load_start = LOAD_START as *const u8;

// Gain NUM
let byte_num = unsafe { core::slice::from_raw_parts(apps_start, size_of::<u8>()) };
Expand Down Expand Up @@ -43,59 +48,26 @@ fn main() {
}

println!("{apps:?}");
// let read_only_app1 = unsafe {
// core::slice::from_raw_parts(
// apps_start.offset(size_of::<u16>() as isize),
// app_size_1 as usize,
// )
// };
// let read_only_app2 = unsafe {
// core::slice::from_raw_parts(
// apps_start.offset((size_of::<u16>() + app_size_1 as usize) as isize),
// app_size_2 as usize,
// )
// };

// // println!("content: {:?}: ", code);
// println!("Load payload ok!");

// println!("Copy app ...");
// let load_start = LOAD_START as *const u8;

// // load app 1
// let load_app_1 =
// unsafe { core::slice::from_raw_parts_mut(load_start as *mut u8, app_size_1 as usize) };
// let load_app_2 = unsafe {
// core::slice::from_raw_parts_mut(
// load_start.offset(app_size_1 as isize) as *mut u8,
// app_size_2 as usize,
// )
// };

// // Copy App Data From ReadOnly Areas
// load_app_1.copy_from_slice(read_only_app1);
// load_app_2.copy_from_slice(read_only_app2);
// LOAD APPLICATION
for i in 0..app_num {
let i = i as usize;
let read_only_app =
unsafe { core::slice::from_raw_parts(apps[i].start_addr, apps[i].size) };
let load_app =
unsafe { core::slice::from_raw_parts_mut(load_start as *mut u8, apps[i].size) };
println!("Copy App {i} data from {}", apps[i].start_addr as usize);

// println!("Original App: ");
// println!("1: {read_only_app1:?}");
// println!("2: {read_only_app2:?}");
load_app.copy_from_slice(read_only_app);

// println!("Load App:");
// println!("1: {load_app_1:?}");
// println!("2: {load_app_2:?}");
trace!("Original App: ");
trace!("{i}: {read_only_app:?}");

// println!("ORIGINAL AREAS: ");
// println!("{:?}", unsafe {
// core::slice::from_raw_parts(
// apps_start,
// (app_size_1 + app_size_2 + size_of::<u16>() as u8) as usize,
// )
// });
trace!("Load App:");
trace!("{i}: {load_app:?}");

// println!("LOADING AREAS: ");
// println!("{:?}", unsafe {
// core::slice::from_raw_parts(load_start, (app_size_1 + app_size_2) as usize)
// });
println!("Executing App {i}");
}

// register_abi(SYS_HELLO, abi_hello as usize);
// register_abi(SYS_PUTCHAR, abi_putchar as usize);
Expand Down Expand Up @@ -157,8 +129,8 @@ fn abi_terminate() -> ! {
const MAX_APP_NUM: usize = u8::MAX as usize;
#[derive(Clone, Copy)]
struct APP {
start_addr: *const u8,
size: usize,
pub start_addr: *const u8,
pub size: usize,
}

impl APP {
Expand Down

0 comments on commit 5d04c0d

Please sign in to comment.