From 19f2bac6962b80ce2879040292f1a5b7e15f0a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E5=8F=8B=E6=8D=B7?= Date: Thu, 2 May 2024 12:50:34 +0800 Subject: [PATCH] fix: update the environment variable and remove some warning --- .cargo/config.toml | 4 ++++ .gitignore | 1 + Cargo.lock | 9 ++++---- Cargo.toml | 34 +++++++---------------------- Makefile | 3 --- apps/display/src/display.rs | 24 +++++++++++++++----- apps/monolithic_userboot/Cargo.toml | 3 +-- apps/task/priority/src/main.rs | 1 + apps/task/tls/src/main.rs | 9 ++++---- tools/axlibc/.gitignore | 1 + 10 files changed, 43 insertions(+), 46 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..94c20e3 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,4 @@ + +[env] +AX_WORK_DIR = { value = ".", relative = true } +AX_LIBC_DIR = { value = "tools/axlibc", relative = true } \ No newline at end of file diff --git a/.gitignore b/.gitignore index faba1c3..2369bc5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ arceos-fada.itb !tools/rk3588/ramdisk.img !tools/axlibc linker_* +crates/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index f31d11f..9655bf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,7 +164,7 @@ dependencies = [ [[package]] name = "arceos_posix_api" version = "0.1.0" -source = "git+https://github.com/Starry-OS/arceos_posix_api.git#af0f3447d6dc95d1d54639279d897c9bedf435ed" +source = "git+https://github.com/Starry-OS/arceos_posix_api.git#45b2398e779c89e7507e03b3fe745f6ba8f75a5a" dependencies = [ "axalloc", "axconfig", @@ -453,7 +453,7 @@ dependencies = [ [[package]] name = "axmem" version = "0.1.0" -source = "git+https://github.com/Starry-OS/axmem.git#41cf833bfe6180f04773348c9b78d6f437913592" +source = "git+https://github.com/Starry-OS/axmem.git#315ef0914702cdff2726252c5971f2b358f7305e" dependencies = [ "axalloc", "axconfig", @@ -491,7 +491,7 @@ dependencies = [ [[package]] name = "axprocess" version = "0.1.0" -source = "git+https://github.com/Starry-OS/axprocess.git#11482a6247cb67cc68f20a9bfff7404f32f882e3" +source = "git+https://github.com/Starry-OS/axprocess.git#4eebad4d5d1022404b713c855d7d4cd85699e406" dependencies = [ "axalloc", "axconfig", @@ -539,7 +539,7 @@ dependencies = [ [[package]] name = "axsignal" version = "0.1.0" -source = "git+https://github.com/Starry-OS/axsignal.git#438a6e8cfb1e1a469e628fc7c2fcb5b856032d26" +source = "git+https://github.com/Starry-OS/axsignal.git#267cb5b0eb2570a0aba006c87360430b1a49e35c" dependencies = [ "axhal", "bitflags 2.5.0", @@ -1134,7 +1134,6 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" name = "monolithic_userboot" version = "0.1.0" dependencies = [ - "axlibc", "axstarry", ] diff --git a/Cargo.toml b/Cargo.toml index 9c629c8..5eb672b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,31 +1,13 @@ -[workspace] -resolver = "2" - -members = [ - "tools/axlibc", - "apps/display", - "apps/exception", - "apps/helloworld", - "apps/memtest", - "apps/fs/shell", - "apps/net/echoserver", - "apps/net/httpclient", - "apps/net/httpserver", - "apps/net/udpserver", - "apps/net/bwbench", - "apps/task/parallel", - "apps/task/sleep", - "apps/task/yield", - "apps/task/priority", - "apps/task/tls", - "apps/monolithic_userboot" -] +[patch."https://github.com/rcore-os/smoltcp.git".smoltcp] +branch = "starryos" +git = "https://github.com/c0per/smoltcp" -[profile.release] +[profile.dev] lto = true -[profile.dev] +[profile.release] lto = true -[patch."https://github.com/rcore-os/smoltcp.git"] -smoltcp = { git = "https://github.com/c0per/smoltcp", branch = "starryos" } +[workspace] +members = ["tools/axlibc", "apps/display", "apps/exception", "apps/helloworld", "apps/memtest", "apps/fs/shell", "apps/net/echoserver", "apps/net/httpclient", "apps/net/httpserver", "apps/net/udpserver", "apps/net/bwbench", "apps/task/parallel", "apps/task/sleep", "apps/task/yield", "apps/task/priority", "apps/task/tls", "apps/monolithic_userboot"] +resolver = "2" diff --git a/Makefile b/Makefile index f4edb89..21ac160 100644 --- a/Makefile +++ b/Makefile @@ -125,9 +125,6 @@ export AX_LOG=$(LOG) export AX_TARGET=$(TARGET) export AX_IP=$(IP) export AX_GW=$(GW) -# 获取当前的工作目录 -export AX_WORK_DIR=$(CURDIR) -export AX_LIBC_DIR=$(CURDIR)/tools/axlibc # Binutils CROSS_COMPILE ?= $(ARCH)-linux-musl- diff --git a/apps/display/src/display.rs b/apps/display/src/display.rs index 01601f1..89c35bb 100644 --- a/apps/display/src/display.rs +++ b/apps/display/src/display.rs @@ -1,7 +1,7 @@ use embedded_graphics::pixelcolor::Rgb888; use embedded_graphics::prelude::{RgbColor, Size}; use embedded_graphics::{draw_target::DrawTarget, prelude::OriginDimensions}; - +#[cfg(feature = "axstd")] use std::os::arceos::api::display as api; pub struct Display { @@ -11,14 +11,26 @@ pub struct Display { impl Display { pub fn new() -> Self { - let info = api::ax_framebuffer_info(); - let fb = - unsafe { core::slice::from_raw_parts_mut(info.fb_base_vaddr as *mut u8, info.fb_size) }; - let size = Size::new(info.width, info.height); - Self { size, fb } + #[cfg(feature = "axstd")] + { + let info = api::ax_framebuffer_info(); + let fb = unsafe { + core::slice::from_raw_parts_mut(info.fb_base_vaddr as *mut u8, info.fb_size) + }; + let size = Size::new(info.width, info.height); + Self { size, fb } + } + #[cfg(not(feature = "axstd"))] + { + Self { + size: Size::new(0, 0), + fb: &mut [], + } + } } pub fn flush(&self) { + #[cfg(feature = "axstd")] api::ax_framebuffer_flush(); } } diff --git a/apps/monolithic_userboot/Cargo.toml b/apps/monolithic_userboot/Cargo.toml index d706b33..057ad78 100644 --- a/apps/monolithic_userboot/Cargo.toml +++ b/apps/monolithic_userboot/Cargo.toml @@ -9,7 +9,6 @@ authors = ["Youjie Zheng "] [features] # Use "APP_FEATURES=batch" to enable batch mode batch = [] -ext4fs = ["axlibc/fs"] + [dependencies] axstarry = { git = "https://github.com/Starry-OS/axstarry.git" } -axlibc = { path = "../../tools/axlibc", optional = true } \ No newline at end of file diff --git a/apps/task/priority/src/main.rs b/apps/task/priority/src/main.rs index ff013ef..d68b7d8 100644 --- a/apps/task/priority/src/main.rs +++ b/apps/task/priority/src/main.rs @@ -77,6 +77,7 @@ fn main() { for i in 0..PAYLOAD_KIND { let vec = data[i].clone(); let data_len = TASK_PARAMS[i].data_len; + #[allow(unused_variables)] let nice = TASK_PARAMS[i].nice; tasks.push(thread::spawn(move || { #[cfg(feature = "axstd")] diff --git a/apps/task/tls/src/main.rs b/apps/task/tls/src/main.rs index 07d8709..f27f316 100644 --- a/apps/task/tls/src/main.rs +++ b/apps/task/tls/src/main.rs @@ -7,6 +7,7 @@ #[cfg(feature = "axstd")] extern crate axstd as std; +use core::ptr::addr_of; use std::{thread, vec::Vec}; #[thread_local] @@ -56,14 +57,14 @@ fn main() { get!(U16), get!(U32), get!(U64), - get!(std::str::from_utf8_unchecked(&STR)) + get!(std::str::from_utf8_unchecked(&*addr_of!(STR))) ); assert!(get!(BOOL)); assert_eq!(get!(U8), 0xAA); assert_eq!(get!(U16), 0xcafe); assert_eq!(get!(U32), 0xdeadbeed); assert_eq!(get!(U64), 0xa2ce05_a2ce05); - assert_eq!(get!(&STR), b"Hello, world!"); + assert_eq!(get!(&*addr_of!(STR)), b"Hello, world!"); let mut tasks = Vec::new(); for i in 1..=10 { @@ -85,7 +86,7 @@ fn main() { get!(U16), get!(U32), get!(U64), - get!(std::str::from_utf8_unchecked(&STR)) + get!(std::str::from_utf8_unchecked(&*addr_of!(STR))) ); assert_eq!(get!(BOOL), i % 2 == 0); assert_eq!(get!(U8), 0xAA + i as u8); @@ -105,7 +106,7 @@ fn main() { assert_eq!(get!(U16), 0xcafe); assert_eq!(get!(U32), 0xdeadbeed); assert_eq!(get!(U64), 0xa2ce05_a2ce05); - assert_eq!(get!(&STR), b"Hello, world!"); + assert_eq!(get!(&*addr_of!(STR)), b"Hello, world!"); println!("TLS tests run OK!"); } diff --git a/tools/axlibc/.gitignore b/tools/axlibc/.gitignore index b5b4526..3cea166 100644 --- a/tools/axlibc/.gitignore +++ b/tools/axlibc/.gitignore @@ -1,3 +1,4 @@ src/libctypes_gen.rs include/ax_pthread_mutex.h build_* +lwext4* \ No newline at end of file