blob: f8cc0321cfc9eb5c6994e253e62cf02a6c5de848 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
This repo contains a modified version [0] of Pintos [1] in which you can write
user programs, standard library, syscalls and kernel code in Rust and C at the
same time.
This README focuses on the Rust parts. [0] and [1] contain information about
Pintos in general.
[0]: https://www.ida.liu.se/~TDIU16/2020/info/courseinfo.sv.shtml
[1]: https://web.stanford.edu/class/cs140/projects/pintos/pintos.html
Kernel
------
The Rust kernel code is located in kernel-rs/. This is compiled and linked with
the normal kernel before being packaged into `os.dsk`.
Standard library
----------------
The Rust standard library is located in libpintos-rs/. This crate isn't compiled
to a static library. Instead, user programs depend on this crate and let Cargo
link them together. This means that the standard library doesn't need to `extern
"C"` its functions.
User programs
-------------
User programs can be located anywhere you want. halt-rs/ is included as an
example. The only requirement is that they are compiled as static libraries with
no_std and a `pub extern "C" entry()` that acts as the entry point.
In order for the Pintos Makefile to build your program you need to add the
binary's name to PROGS_RS and its crate path to $(BINARY)_SRC in
`src/examples/Makefile`. haltrs is included as an example.
The binaries are rather large, even with LTO enabled. halt-rs compiles to 4.3M
in debug and 1.6M with --release and LTO. This isn't an issue (at least not yet)
as the final binary when linked by the Pintos Makefile is 48k, compared with the
mostly equivalent halt.c that compiles to 42k.
TODO
----
* Merge the C and Rust kernel like we already do with the standard library.
* Automatically copy libc.a when building libpintos-rs (via build.rs?).
* println!-macro with formatting in libpintos-rs (and kernel?).
* Implement an allocator that calls malloc in libpintos-rs.
* Some sort of Cargo template for setting up new user programs.
|