Skip to content

Commit

Permalink
fix: update the environment variable and remove some warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed May 2, 2024
1 parent 0880601 commit 19f2bac
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 46 deletions.
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[env]
AX_WORK_DIR = { value = ".", relative = true }
AX_LIBC_DIR = { value = "tools/axlibc", relative = true }
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ arceos-fada.itb
!tools/rk3588/ramdisk.img
!tools/axlibc
linker_*
crates/
9 changes: 4 additions & 5 deletions Cargo.lock

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

34 changes: 8 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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-
Expand Down
24 changes: 18 additions & 6 deletions apps/display/src/display.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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();
}
}
Expand Down
3 changes: 1 addition & 2 deletions apps/monolithic_userboot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ authors = ["Youjie Zheng <[email protected]>"]
[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 }
1 change: 1 addition & 0 deletions apps/task/priority/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
9 changes: 5 additions & 4 deletions apps/task/tls/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#[cfg(feature = "axstd")]
extern crate axstd as std;

use core::ptr::addr_of;
use std::{thread, vec::Vec};

#[thread_local]
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -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!");
}
1 change: 1 addition & 0 deletions tools/axlibc/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
src/libctypes_gen.rs
include/ax_pthread_mutex.h
build_*
lwext4*

0 comments on commit 19f2bac

Please sign in to comment.