1#![no_std]
2
3use core::ptr::addr_of_mut;
4
5mod bindings;
6pub use bindings::*;
7
8mod clint;
9pub use clint::*;
10
11mod encoding;
12pub use encoding::*;
13
14mod ethernet;
15pub use ethernet::*;
16mod gpio;
17pub use gpio::*;
18
19mod sysreg;
20pub use sysreg::*;
21
22mod timer;
23pub use timer::*;
24
25mod uart;
26pub use uart::*;
27
28mod usb;
29pub use usb::*;
30
31mod qspi;
32pub use qspi::*;
33
34#[inline]
35pub fn hart_id() -> usize {
36 let mut hart_id: usize;
37 unsafe {
38 core::arch::asm!("csrr {}, mhartid", out(reg) hart_id);
39 }
40 hart_id
41}
42
43pub fn last_linked_address() -> usize {
44 addr_of_mut!(__app_hart_common_end) as usize
45}
46
47pub fn last_address() -> usize {
48 let base_address = if cfg!(feature = "upper-memory-layout") {
49 0x10_0000_0000
50 } else {
51 0x8000_0000
52 };
53 let size_ram = if cfg!(feature = "beaglev-fire") {
54 0x8000_0000
56 } else {
57 panic!("Unsupported board: No RAM size defined");
58 };
59
60 base_address + size_ram
61}