2
2
3
3
//! Enter point of, well, everything
4
4
//! Well, not really, more general metadata, module definitions etc...
5
- #![ feature( const_fn_fn_ptr_basics) ]
6
5
#![ feature( format_args_nl) ]
7
6
#![ feature( panic_info_message) ]
8
7
#![ feature( trait_alias) ]
@@ -36,26 +35,52 @@ unsafe fn kernel_init() -> ! {
36
35
kernel_main ( ) ;
37
36
}
38
37
38
+ const LOADER_LOGO : & str = r#"
39
+ .____ .___
40
+ | | _________ __| _/___________
41
+ | | / _ \__ \ / __ |/ __ \_ __ \
42
+ | |__( <_> ) __ \_/ /_/ \ ___/| | \/
43
+ |_______ \____(____ /\____ |\___ >__|
44
+ \/ \/ \/ \/
45
+ "# ;
46
+
39
47
fn kernel_main ( ) -> ! {
40
48
use bsp:: console:: console;
41
49
use console:: interface:: All ;
42
- use driver:: interface:: DeviceManager ;
43
50
44
- println ! ( "RpiOS is booting..." ) ;
45
- println ! ( "Communicating through PL011 UART" ) ;
51
+ println ! ( "{}" , LOADER_LOGO ) ;
52
+ println ! ( "Running on: {}" , bsp:: board_name( ) ) ;
53
+ println ! ( ) ;
54
+ println ! ( "Requesting binary!" ) ;
55
+ console ( ) . flush ( ) ;
56
+
57
+ console ( ) . clear_rx ( ) ;
46
58
47
- println ! ( "[1] Booting on: {}" , bsp:: board_name( ) ) ;
48
- println ! ( "[2] Drivers loaded:" ) ;
49
- for ( i, driver) in bsp:: driver:: driver_manager ( ) . all_device_drivers ( ) . iter ( ) . enumerate ( ) {
50
- println ! ( "{}. {}" , i+1 , driver. compatible( ) ) ;
59
+ // send three times '3' through UART to notify the pusher to send the kernel / binary
60
+ for _ in 0 ..3 {
61
+ console ( ) . write_char ( 3 as char ) ;
51
62
}
52
63
53
- println ! ( "[3] Chars written: {}" , bsp:: console:: console( ) . chars_written( ) ) ;
64
+ // Read the binary's size.
65
+ let mut size: u32 = u32:: from ( console ( ) . read_char ( ) as u8 ) ;
66
+ size |= u32:: from ( console ( ) . read_char ( ) as u8 ) << 8 ;
67
+ size |= u32:: from ( console ( ) . read_char ( ) as u8 ) << 16 ;
68
+ size |= u32:: from ( console ( ) . read_char ( ) as u8 ) << 24 ;
54
69
55
- println ! ( "[4] Entering echo mode" ) ;
56
- console ( ) . clear_rx ( ) ;
57
- loop {
58
- let c = bsp:: console:: console ( ) . read_char ( ) ;
59
- bsp:: console:: console ( ) . write_char ( c) ;
60
- }
61
- }
70
+ console ( ) . write_char ( 'O' ) ;
71
+ console ( ) . write_char ( 'K' ) ;
72
+
73
+ let kernel_addr = bsp:: memory:: board_default_load_address ( ) as * mut u8 ;
74
+
75
+ unsafe {
76
+ for i in 0 ..size {
77
+ core:: ptr:: write_volatile ( kernel_addr. offset ( i as isize ) , console ( ) . read_char ( ) as u8 ) ;
78
+ }
79
+ }
80
+
81
+ println ! ( "Received kernel, executing now!" ) ;
82
+ console ( ) . flush ( ) ;
83
+
84
+ let kernel: fn ( ) -> ! = unsafe { core:: mem:: transmute ( kernel_addr) } ;
85
+ kernel ( ) ;
86
+ }
0 commit comments