You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docker run -it -v $(pwd):/arceos -w /arceos arceos bash
43
44
@@ -46,6 +47,7 @@ make A=examples/helloworld ARCH=aarch64 run
46
47
```
47
48
48
49
### Manually Build and Run
50
+
49
51
#### 1. Install Build Dependencies
50
52
51
53
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
Copy file name to clipboardExpand all lines: doc/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ See [arceos-apps](https://github.com/arceos-org/arceos-apps) for example applica
37
37
38
38
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:
Copy file name to clipboardExpand all lines: doc/build.md
+65-56Lines changed: 65 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,75 +6,84 @@ We will provide an example to illustrate the process of building and running Arc
6
6
7
7
What happens when "make A=examples/httpserver ARCH=riscv64 LOG=info NET=y SMP=1 run" is executed?
8
8
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
13
15
features-$(FS) += axstd/fs
14
16
features-$(NET) += axstd/net
15
17
features-$(GRAPHIC) += axstd/display
16
18
```
17
19
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:
-`_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
+
-Takinghttpserverasanexample,let'sseehowArceOSareconditionallycompiled.First,inthe`Cargo.toml`fileofhttpserver,thedependencyisspecifiedas: `axstd = { workspace = true, features = ["paging", "multitask", "net"] }`. This indicates that axstd needs to be compiled and has the three features mentioned above.
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.
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.
36
41
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 selectthe corresponding app directory forconditional compilationin`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 functionmarked 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).
79
88
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 forsyscall and context switching, resultingin higher efficiency.
0 commit comments