Skip to content

Commit 4b75cfc

Browse files
committed
docs: format markdown files
1 parent 1d61c81 commit 4b75cfc

File tree

5 files changed

+137
-184
lines changed

5 files changed

+137
-184
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ docker build -t arceos -f Dockerfile .
3838
```
3939

4040
Create a container and build/run app:
41+
4142
```bash
4243
docker run -it -v $(pwd):/arceos -w /arceos arceos bash
4344

@@ -46,6 +47,7 @@ make A=examples/helloworld ARCH=aarch64 run
4647
```
4748

4849
### Manually Build and Run
50+
4951
#### 1. Install Build Dependencies
5052

5153
Install [cargo-binutils](https://github.com/rust-embedded/cargo-binutils) to use `rust-objcopy` and `rust-objdump` tools, and [axconfig-gen](https://github.com/arceos-org/axconfig-gen) for kernel configuration, and [cargo-axplat](https://github.com/arceos-org/axplat_crates/tree/dev/cargo-axplat) for platform configuration:
@@ -214,4 +216,4 @@ axhal = { git = "https://github.com/arceos-org/arceos.git", tag = "v0.2.0" } # m
214216

215217
## Design
216218

217-
![](doc/figures/ArceOS.svg)
219+
![ArceOS logo](doc/figures/ArceOS.svg)

doc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ See [arceos-apps](https://github.com/arceos-org/arceos-apps) for example applica
3737

3838
Documentation of ArceOS [modules](../modules), [api](../api), and [ulib](../ulib) are generated by [`rustdoc`](https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html) and hosted on GitHub Pages:
3939

40-
* https://arceos-org.github.io/arceos/
40+
* [arceos-org](https://arceos-org.github.io/arceos/)
4141

4242
## Discussions
4343

doc/build.md

Lines changed: 65 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,75 +6,84 @@ We will provide an example to illustrate the process of building and running Arc
66

77
What happens when "make A=examples/httpserver ARCH=riscv64 LOG=info NET=y SMP=1 run" is executed?
88

9-
- How ArceOS build?
10-
- Firstly check Makefile: Based on different parameters, select whether FS/NET/GRAPHIC param is yes or not. If it is y, it will be compiled in conditional compilation.
11-
- `cargo.mk` determines whether to add the corresponding feature based on whether FS/NET/GRAPHIC is set to y.
12-
```
9+
## How ArceOS build?
10+
11+
- Firstly check Makefile: Based on different parameters, select whether FS/NET/GRAPHIC param is yes or not. If it is y, it will be compiled in conditional compilation.
12+
- `cargo.mk` determines whether to add the corresponding feature based on whether FS/NET/GRAPHIC is set to y.
13+
14+
```makefile
1315
features-$(FS) += axstd/fs
1416
features-$(NET) += axstd/net
1517
features-$(GRAPHIC) += axstd/display
1618
```
1719

18-
- `_cargo_build`: The `_cargo_build` method is defined in cargo.mk. Different compilation methods are selected based on the language. For example, for Rust, when `cargo_build,--manifest-path $(APP)/Cargo.toml` is called, where $(APP) represents the current application to be run.
19-
- Taking httpserver as an example, let's see how ArceOS are conditionally compiled. First, in the `Cargo.toml` file of httpserver, the dependency is specified as: `axstd = { workspace = true, features = ["paging", "multitask", "net"] }`. This indicates that axstd needs to be compiled and has the three features mentioned above.
20-
- After checking axstd, the following three features were found:
21-
- `paging = ["axfeat/paging"]`
22-
- `multitask = ["arceos_api/multitask", "axfeat/multitask"]`
23-
- `net = ["arceos_api/net", "axfeat/net"]`
20+
- `_cargo_build`: The `_cargo_build` method is defined in cargo.mk. Different compilation methods are selected based on the language. For example, for Rust, when `cargo_build,--manifest-path $(APP)/Cargo.toml` is called, where $(APP) represents the current application to be run.
21+
- Taking httpserver as an example, let's see how ArceOS are conditionally compiled. First, in the `Cargo.toml` file of httpserver, the dependency is specified as: `axstd = { workspace = true, features = ["paging", "multitask", "net"] }`. This indicates that axstd needs to be compiled and has the three features mentioned above.
22+
- After checking axstd, the following three features were found:
23+
- `paging = ["axfeat/paging"]`
24+
- `multitask = ["arceos_api/multitask", "axfeat/multitask"]`
25+
- `net = ["arceos_api/net", "axfeat/net"]`
2426

25-
This involves modules such as arceos_api, axfeat, and their dependencies like axtask, axnet, etc., and conditional compilation is performed on these modules.
26-
- The above are some modules required for compilation, next we will look at how to perform conditional compilation. The `cargo.mk` file describes how to use the cargo method for conditional compilation, with the following build parameters:
27-
```
27+
This involves modules such as arceos_api, axfeat, and their dependencies like axtask, axnet, etc., and conditional compilation is performed on these modules.
28+
29+
- The above are some modules required for compilation, next we will look at how to perform conditional compilation. The `cargo.mk` file describes how to use the cargo method for conditional compilation, with the following build parameters:
30+
31+
```makefile
2832
build_args := \
2933
-Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem \
3034
--config "build.rustflags='-Clink-arg=-T$(LD_SCRIPT)'" \
3135
--target $(TARGET) \
3236
--target-dir $(CURDIR)/target \
3337
--features "$(features-y)" \
3438
```
39+
3540
Note that the -Zbuild-std option is mentioned here, indicating the replacement of the standard library for the application and the use of libraries provided by ArceOS.
3641
37-
- Therefore, to summarize: choose conditions in Makefile and select the corresponding app directory for conditional compilation in `cargo.mk`.
38-
- Next, describe how ArceOS run:
39-
- Firstly, examining the Makefile reveals that in addition to building, running an application also requires `justrun`.
40-
- Following this, it was found that the `qemu.mk` file would call run_qemu. Similar to the build process, the execution process would also use conditional selection and run.
41-
- At runtime, Arceos first performs some boot operations, such as executing in the riscv64 environment:
42-
```rust
43-
#[unsafe(naked)]
44-
#[unsafe(no_mangle)]
45-
#[unsafe(link_section = ".text.boot")]
46-
unsafe extern "C" fn _start() -> ! {
47-
// PC = 0x8020_0000
48-
// a0 = hartid
49-
// a1 = dtb
50-
core::arch::naked_asm!("
51-
mv s0, a0 // save hartid
52-
mv s1, a1 // save DTB pointer
53-
la sp, {boot_stack}
54-
li t0, {boot_stack_size}
55-
add sp, sp, t0 // setup boot stack
56-
57-
call {init_boot_page_table}
58-
call {init_mmu} // setup boot page table and enabel MMU
59-
60-
li s2, {phys_virt_offset} // fix up virtual high address
61-
add sp, sp, s2
62-
63-
mv a0, s0
64-
mv a1, s1
65-
la a2, {entry}
66-
add a2, a2, s2
67-
jalr a2 // call_main(cpu_id, dtb)
68-
j .",
69-
phys_virt_offset = const PHYS_VIRT_OFFSET,
70-
boot_stack_size = const BOOT_STACK_SIZE,
71-
boot_stack = sym BOOT_STACK,
72-
init_boot_page_table = sym init_boot_page_table,
73-
init_mmu = sym init_mmu,
74-
entry = sym axplat::call_main,
75-
)
76-
}
77-
```
78-
- Later, it calls `axplat::call_main`, which will jump to the function marked with the `axplat::main` procedural macro. In ArceOS it is the `rust_main` in `axruntime`. After some conditional initialization, `rust_main` executes `main()`. Since this main is defined by the application, symbol linkage should be established and jumped to (no context switch is needed since it's a single address space).
42+
- Therefore, to summarize: choose conditions in Makefile and select the corresponding app directory for conditional compilation in `cargo.mk`.
43+
44+
## Next, describe how ArceOS run
45+
46+
- Firstly, examining the Makefile reveals that in addition to building, running an application also requires `justrun`.
47+
- Following this, it was found that the `qemu.mk` file would call run_qemu. Similar to the build process, the execution process would also use conditional selection and run.
48+
- At runtime, Arceos first performs some boot operations, such as executing in the riscv64 environment:
49+
50+
```rust
51+
#[unsafe(naked)]
52+
#[unsafe(no_mangle)]
53+
#[unsafe(link_section = ".text.boot")]
54+
unsafe extern "C" fn _start() -> ! {
55+
// PC = 0x8020_0000
56+
// a0 = hartid
57+
// a1 = dtb
58+
core::arch::naked_asm!("
59+
mv s0, a0 // save hartid
60+
mv s1, a1 // save DTB pointer
61+
la sp, {boot_stack}
62+
li t0, {boot_stack_size}
63+
add sp, sp, t0 // setup boot stack
64+
65+
call {init_boot_page_table}
66+
call {init_mmu} // setup boot page table and enabel MMU
67+
68+
li s2, {phys_virt_offset} // fix up virtual high address
69+
add sp, sp, s2
70+
71+
mv a0, s0
72+
mv a1, s1
73+
la a2, {entry}
74+
add a2, a2, s2
75+
jalr a2 // call_main(cpu_id, dtb)
76+
j .",
77+
phys_virt_offset = const PHYS_VIRT_OFFSET,
78+
boot_stack_size = const BOOT_STACK_SIZE,
79+
boot_stack = sym BOOT_STACK,
80+
init_boot_page_table = sym init_boot_page_table,
81+
init_mmu = sym init_mmu,
82+
entry = sym axplat::call_main,
83+
)
84+
}
85+
```
86+
87+
- Later, it calls `axplat::call_main`, which will jump to the function marked with the `axplat::main` procedural macro. In ArceOS it is the `rust_main` in `axruntime`. After some conditional initialization, `rust_main` executes `main()`. Since this main is defined by the application, symbol linkage should be established and jumped to (no context switch is needed since it's a single address space).
7988
80-
- Then, the user program begins executing through `axstd`'s API. The application runs in kernel mode, without the need for syscall and context switching, resulting in higher efficiency.
89+
- Then, the user program begins executing through `axstd`'s API. The application runs in kernel mode, without the need for syscall and context switching, resulting in higher efficiency.

0 commit comments

Comments
 (0)