File tree Expand file tree Collapse file tree 7 files changed +63
-0
lines changed Expand file tree Collapse file tree 7 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ # Rust sample hello world application crate.
2+
3+ [package ]
4+ name = " rust_hello"
5+ version = " 0.1.0"
6+ edition = " 2024"
7+ description = """
8+ Rust LK hello world application.
9+ """
10+ license = " MIT"
11+
12+ [dependencies .lk ]
13+ version = " 0.1.0"
14+ path = " ../../rust/lk"
15+
16+ [dependencies .log ]
17+ version = " 0.4.27"
Original file line number Diff line number Diff line change 1+ LOCAL_DIR := $(GET_LOCAL_DIR )
2+
3+ RUST_CRATES += $(LOCAL_DIR )
4+ $(info "Adding rust crate $(LOCAL_DIR)")
5+
6+ MODULE := $(LOCAL_DIR )
7+
8+ MODULES += $(MODULE )
9+
10+ MODULE :=
Original file line number Diff line number Diff line change 1+ // Sample application.
2+
3+ #![ no_std]
4+
5+ use core:: ffi:: c_void;
6+
7+ use lk:: sys:: { APP_FLAG_NO_AUTOSTART , app_descriptor} ;
8+
9+ pub fn must_link ( ) { }
10+
11+ /// Manual, and unsafe declration of an app.
12+ #[ unsafe( link_section = "apps" ) ]
13+ #[ used]
14+ static APP_RUST_HELLO : app_descriptor = app_descriptor {
15+ name : c"rust_hello" . as_ptr ( ) ,
16+ init : Some ( init) ,
17+ entry : Some ( main) ,
18+ flags : APP_FLAG_NO_AUTOSTART ,
19+ stack_size : 0 ,
20+ } ;
21+
22+ extern "C" fn init ( _desc : * const app_descriptor ) {
23+ log:: info!( "Rust hello app init" ) ;
24+ }
25+
26+ extern "C" fn main ( _desc : * const app_descriptor , _args : * mut c_void ) {
27+ log:: info!( "Rust hello app main" ) ;
28+ }
Original file line number Diff line number Diff line change 11# main project for qemu-aarch64
22MODULES += \
33 app/shell \
4+ app/rust_hello \
45 lib/uefi \
56
67include project/virtual/test.mk
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ fn main() -> anyhow::Result<()> {
5858 . allowlist_type ( "lk_init_struct" )
5959 . allowlist_function ( "register_int_handler" )
6060 . allowlist_function ( "unmask_interrupt" )
61+ . allowlist_type ( "app_descriptor" )
62+ . allowlist_item ( "APP_FLAG.*" )
6163 . generate ( ) ?;
6264
6365 bindings. write_to_file ( out_path. join ( "bindings.rs" ) ) ?;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ use core::ffi::c_char;
1515include ! ( concat!( env!( "OUT_DIR" ) , "/bindings.rs" ) ) ;
1616
1717unsafe impl Sync for lk_init_struct { }
18+ unsafe impl Sync for app_descriptor { }
1819
1920// lk_init_level constants have large gaps between them and some modules
2021// add or subtract from these constants to indicate that it wants to run
Original file line number Diff line number Diff line change 2828
2929#include <platform/interrupts.h>
3030
31+ #if WITH_APP
32+ #include <app.h>
33+ #endif
34+
3135// #include "error.h"
You can’t perform that action at this time.
0 commit comments