Skip to content

Commit

Permalink
doc: add docs for MAC-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed May 12, 2024
1 parent 1bb3b5f commit 1136b4b
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 86 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ arceos-fada.itb
.tmp_its
!tools/rk3588/ramdisk.img
linker_*
crates/
50 changes: 7 additions & 43 deletions Cargo.lock

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

29 changes: 26 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
[patch."https://github.com/rcore-os/smoltcp.git".smoltcp]
branch = "starryos"
git = "https://github.com/c0per/smoltcp"
[patch."https://github.com/Starry-OS/arch_boot.git".arch_boot]
path = "crates/arch_boot"

[patch."https://github.com/Starry-OS/axfs.git".axfs]
path = "crates/axfs"

[patch."https://github.com/Starry-OS/axhal.git".axhal]
path = "crates/axhal"

[patch."https://github.com/Starry-OS/axmem.git".axmem]
path = "crates/axmem"

[patch."https://github.com/Starry-OS/axnet.git".axnet]
path = "crates/axnet"

[patch."https://github.com/Starry-OS/axprocess.git".axprocess]
path = "crates/axprocess"

[patch."https://github.com/Starry-OS/axruntime.git".axruntime]
path = "crates/axruntime"

[patch."https://github.com/Starry-OS/axstarry.git".axstarry]
path = "crates/axstarry"

[patch."https://github.com/Starry-OS/linux_syscall_api.git".linux_syscall_api]
path = "crates/linux_syscall_api"

[profile.dev]
lto = true
Expand Down
99 changes: 99 additions & 0 deletions README-macOS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# `macOS` 开发 `StarryOS` 环境部署说明

这是一个介绍如何在`macOS`系统下部署 `StarryOS` 开发环境的说明文档。此文档默认构建`x86_64`架构的`fat`磁盘镜像

## 提交人员

[李扬(技安)](https://github.com/LyonRust/Starry)

## 操作步骤

以下所有的操作步骤都是在当前项目根目录中操作.

1. 安装 `rust`

```shell
$ xcode-select --install
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

2. 安装 `qemu`

```shell
$ brew install qemu
```

3. 安装 `cargo-binutils`

```shell
$ cargo install cargo-binutils
$ rustup component add llvm-tools
```

4. 创建磁盘文件

```shell
$ dd if=/dev/zero of=disk.img bs=4M count=30
```

5. 给磁盘文件添加文件系统

```shell
$ open disk.img
```

这个时候会弹出一个是否初始化的弹窗, 点击初始化,会打开磁盘管理器

![初始化](./doc/macOS/001.jpg)

6. 格式化磁盘

![002](./doc/macOS/002.png)
6-1 选中磁盘, 点击格式化

![003](./doc/macOS/003.png)
6-2 格式化选项选择 `MS-DOS [FAT]`格式

![004](./doc/macOS/004.png)
6-3 点击格式化按钮

![005](./doc/macOS/005.png)
6-4 格式化完成

![006](./doc/macOS/006.png)
6-5 弹出磁盘

7. 后续的磁盘操作

```shell
# 创建文件夹
$ mkdir -p mnt

# 挂载磁盘
$ hdiutil attach disk.img -mountpoint mnt

# 拷贝文件
$ cp -r ./testcases/$FILE/* ./mnt/

# 卸载磁盘
$ hdiutil detach mnt

# 改变文件权限
$ chmod 777 disk.img
```

8. 运行`StarryOS`

```shell
# 运行宏内核
$ make run

# 运行 shell
$ make A=apps/fs/shell AARCH=x86_64 FEATURES=fp_simd run
```

## 运行效果

`macOS`系统下运行`StarryOS`效果

![007](./doc/macOS/007.png)
42 changes: 3 additions & 39 deletions apps/monolithic_userboot/src/batch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! To allow for batch testing, we define a list of test cases that can be run in sequence.
extern crate alloc;
use alloc::{boxed::Box, string::String, string::ToString, vec::Vec};
use alloc::boxed::Box;

#[allow(dead_code)]
pub const SDCARD_TESTCASES: &[&str] = &[
Expand Down Expand Up @@ -56,49 +56,13 @@ pub const SDCARD_TESTCASES: &[&str] = &[
// "lmbench_all bw_mmap_rd -P 1 512k open2close /var/tmp/XXX",
// "busybox echo context switch overhead",
// "lmbench_all lat_ctx -P 1 -s 32 2 4 8 16 24 32 64 96",
"busybox sh libctest_testcode.sh",
// "busybox sh libctest_testcode.sh",
// "busybox sh lua_testcode.sh",
// "libc-bench",
// "busybox sh ./netperf_testcode.sh",
"busybox sh ./netperf_testcode.sh",
// "busybox sh ./cyclictest_testcode.sh",
];

#[allow(unused)]
/// 分割命令行参数
fn get_args(command_line: &[u8]) -> Vec<String> {
let mut args = Vec::new();
// 需要判断是否存在引号,如busybox_cmd.txt的第一条echo指令便有引号
// 若有引号时,不能把引号加进去,同时要注意引号内的空格不算是分割的标志
let mut in_quote = false;
let mut arg_start = 0; // 一个新的参数的开始位置
for pos in 0..command_line.len() {
if command_line[pos] == b'\"' {
in_quote = !in_quote;
}
if command_line[pos] == b' ' && !in_quote {
// 代表要进行分割
// 首先要防止是否有空串
if arg_start != pos {
args.push(
core::str::from_utf8(&command_line[arg_start..pos])
.unwrap()
.to_string(),
);
}
arg_start = pos + 1;
}
}
// 最后一个参数
if arg_start != command_line.len() {
args.push(
core::str::from_utf8(&command_line[arg_start..])
.unwrap()
.to_string(),
);
}
args
}

#[allow(unused)]
pub fn run_batch_testcases() {
let mut test_iter = Box::new(SDCARD_TESTCASES.iter());
Expand Down
Binary file added doc/macOS/001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/macOS/002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/macOS/003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/macOS/004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/macOS/005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/macOS/006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/macOS/007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion scripts/test/app_test_for_monolithic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

APP=
ROOT=$(realpath $(dirname $0))/../../
TIMEOUT=60s
TIMEOUT=120s
EXIT_STATUS=0

S_PASS=0
Expand Down

0 comments on commit 1136b4b

Please sign in to comment.