7 Commits

Author SHA1 Message Date
49c11978d5 rename syscall table from abi 2025-11-18 13:37:50 -07:00
9035ebc757 fix heap deallocation 2025-11-18 13:18:36 -07:00
f015f67c87 fix readme
fix
2025-11-18 12:55:57 -07:00
02877d03a6 clean 2025-11-17 18:27:32 -07:00
d77320d445 rename libraries
fix

remove
2025-11-17 16:44:30 -07:00
55347be232 show selected file 2025-11-17 16:13:33 -07:00
ccf4499f89 Merge branch 'audio-driver' 2025-11-17 15:16:20 -07:00
35 changed files with 214 additions and 201 deletions

2
.gitignore vendored
View File

@@ -1,6 +1,6 @@
/target /target
*.uf2 *.uf2
abi_sys.h userlib_sys.h
assets/gif/bad_apple.gif assets/gif/bad_apple.gif
picolibc picolibc
user-apps/gboy/Peanut-GB user-apps/gboy/Peanut-GB

64
Cargo.lock generated
View File

@@ -12,27 +12,6 @@ dependencies = [
"regex", "regex",
] ]
[[package]]
name = "abi"
version = "0.1.0"
dependencies = [
"abi_sys",
"embedded-graphics",
"once_cell",
"rand_core 0.9.3",
]
[[package]]
name = "abi_sys"
version = "0.1.0"
dependencies = [
"bitflags 2.10.0",
"cbindgen",
"defmt 0.3.100",
"embedded-graphics",
"strum",
]
[[package]] [[package]]
name = "ahash" name = "ahash"
version = "0.8.12" version = "0.8.12"
@@ -243,9 +222,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
name = "calculator" name = "calculator"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"abi",
"embedded-graphics", "embedded-graphics",
"embedded-layout", "embedded-layout",
"userlib",
] ]
[[package]] [[package]]
@@ -377,9 +356,9 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]] [[package]]
name = "crypto-common" name = "crypto-common"
version = "0.1.6" version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
dependencies = [ dependencies = [
"generic-array", "generic-array",
"typenum", "typenum",
@@ -1230,16 +1209,16 @@ dependencies = [
name = "gallery" name = "gallery"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"abi",
"embedded-graphics", "embedded-graphics",
"tinybmp", "tinybmp",
"userlib",
] ]
[[package]] [[package]]
name = "generic-array" name = "generic-array"
version = "0.14.9" version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [ dependencies = [
"typenum", "typenum",
"version_check", "version_check",
@@ -1272,10 +1251,10 @@ dependencies = [
name = "gif" name = "gif"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"abi",
"embedded-graphics", "embedded-graphics",
"selection_ui", "selection_ui",
"tinygif", "tinygif",
"userlib",
] ]
[[package]] [[package]]
@@ -1450,7 +1429,6 @@ dependencies = [
name = "kernel" name = "kernel"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"abi_sys",
"assign-resources", "assign-resources",
"bitflags 2.10.0", "bitflags 2.10.0",
"bt-hci", "bt-hci",
@@ -1493,6 +1471,7 @@ dependencies = [
"strum", "strum",
"talc", "talc",
"trouble-host", "trouble-host",
"userlib_sys",
] ]
[[package]] [[package]]
@@ -2157,10 +2136,10 @@ checksum = "c1257cd4248b4132760d6524d6dda4e053bc648c9070b960929bf50cfb1e7add"
name = "selection_ui" name = "selection_ui"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"abi",
"embedded-graphics", "embedded-graphics",
"embedded-layout", "embedded-layout",
"embedded-text", "embedded-text",
"userlib",
] ]
[[package]] [[package]]
@@ -2271,10 +2250,10 @@ dependencies = [
name = "snake" name = "snake"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"abi",
"embedded-graphics", "embedded-graphics",
"embedded-snake", "embedded-snake",
"rand", "rand",
"userlib",
] ]
[[package]] [[package]]
@@ -2647,6 +2626,27 @@ dependencies = [
"usbd-hid-descriptors", "usbd-hid-descriptors",
] ]
[[package]]
name = "userlib"
version = "0.1.0"
dependencies = [
"embedded-graphics",
"once_cell",
"rand_core 0.9.3",
"userlib_sys",
]
[[package]]
name = "userlib_sys"
version = "0.1.0"
dependencies = [
"bitflags 2.10.0",
"cbindgen",
"defmt 0.3.100",
"embedded-graphics",
"strum",
]
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.18.1" version = "1.18.1"
@@ -2758,11 +2758,11 @@ dependencies = [
name = "wav_player" name = "wav_player"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"abi",
"embedded-audio", "embedded-audio",
"embedded-graphics", "embedded-graphics",
"rand", "rand",
"selection_ui", "selection_ui",
"userlib",
] ]
[[package]] [[package]]

View File

@@ -2,14 +2,14 @@
resolver = "3" resolver = "3"
members = [ members = [
"kernel", "kernel",
"abi_sys", "userlib_sys",
"abi", "userlib",
"selection_ui", "selection_ui",
"user-apps/calculator", "user_apps/calculator",
"user-apps/snake", "user_apps/snake",
"user-apps/gallery", "user_apps/gallery",
"user-apps/gif", "user_apps/gif",
"user-apps/wav_player", "user_apps/wav_player",
] ]
[profile.release] [profile.release]

View File

@@ -1,26 +1,27 @@
# PicoCalc OS (Rust) # PicoCalc OS (Rust)
A simple operating system for the **Clockwork PicoCalc**, written in Rust. A simple kernel and applications for the **Clockwork PicoCalc**, written in Rust.
This project provides a minimal kernel, ABI, and user-space applications to experiment with OS development on constrained hardware. This project provides a minimal kernel, syscall table, and user-space applications to experiment with kernel development on constrained hardware.
## Status ## Status
Basic synchronous applications are working great. Basic synchronous applications are working great.
Current focus is on **expanding the ABI syscalls** and **fixing the MSC/USB-SCSI driver** to make application development easier and smoother. Current focus is on exanding applications and porting software, finding bugs in ffi, and making sure the kernel is as stable as possible.
## Project Structure ## Project Structure
- **`kernel/`** The core OS kernel (task scheduling, drivers, memory, etc.) - **`kernel/`** The core OS kernel
- **`abi_sys/`** Shared application binary interface definitions for kernel ↔ userspace (Repr "C") - **`userlib_sys/`** C FFI bindings for kernel syscall
- **`abi/`** Rust focused ABI helpers and abstractions for easier development - **`userlib/`** Rust wrapper on top of `userlib_sys`
- **`user-apps/`** Collection of userspace programs (calculator, snake, etc.) - **`picolib/`** Built with ```just newlib```, and provides libc symbols when linking with C libraries
- **`user-apps/`** Collection of userspace programs (gif player, wav player, calculator, snake, etc.)
## Features ## Features
- Minimal Rust-based kernel targeting the PicoCalc - Minimal Rust-based kernel targeting the PicoCalc
- Custom ABI for safe communication between kernel and applications - Custom ABI for *Mostly* safe communication between kernel and applications
- Support for multiple user-space applications - Support for multiple user-space applications
- Hardware drivers tailored for the PicoCalc - Hardware drivers tailored for the PicoCalc( Audio, Display, Keyboard, ans Storage )
## Getting Started ## Getting Started

View File

@@ -1,15 +1,17 @@
target := "thumbv8m.main-none-eabihf"
kernel-dev board: kernel-dev board:
cargo run --bin kernel --features {{board}} --features fps cargo run --bin kernel --features {{board}} --features fps
kernel-release-probe board: kernel-release-probe board:
cargo run --bin kernel --profile release --features {{board}} --features fps cargo run --bin kernel --profile release --features {{board}} --features fps
kernel-release board: kernel-release board:
cargo build --bin kernel --release --no-default-features --features {{board}} cargo build --bin kernel --release --no-default-features --features {{board}}
elf2uf2-rs -d target/thumbv8m.main-none-eabihf/release/kernel elf2uf2-rs -d target/{{target}}/release/kernel
binary-args := "RUSTFLAGS=\"-C link-arg=-pie -C relocation-model=pic\"" binary-args := "RUSTFLAGS=\"-C link-arg=-pie -C relocation-model=pic\""
cbindgen: cbindgen:
cbindgen abi_sys --output abi_sys.h -q cbindgen userlib_sys --output userlib_sys.h -q
newlib: newlib:
#!/bin/bash #!/bin/bash
@@ -42,7 +44,7 @@ userapps: cbindgen
just userapp wav_player just userapp wav_player
copy-userapp app: copy-userapp app:
cp ./target/thumbv8m.main-none-eabihf/release-binary/{{app}} /run/media/$(whoami)/PICOCALC/{{app}}.bin cp ./target/{{target}}/release-binary/{{app}} /run/media/$(whoami)/PICOCALC/{{app}}.bin
copy-userapps: copy-userapps:
#!/bin/bash #!/bin/bash

View File

@@ -99,4 +99,4 @@ embedded-alloc = { version = "0.6.0", features = [
], optional = true } ], optional = true }
bumpalo = "3.19.0" bumpalo = "3.19.0"
abi_sys = { path = "../abi_sys" } userlib_sys = { path = "../userlib_sys" }

View File

@@ -15,7 +15,7 @@ use fixed::traits::ToFixed;
pub const SAMPLE_RATE_HZ: u32 = 22_050; pub const SAMPLE_RATE_HZ: u32 = 22_050;
const AUDIO_BUFFER_SAMPLES: usize = 1024; const AUDIO_BUFFER_SAMPLES: usize = 1024;
const _: () = assert!(AUDIO_BUFFER_SAMPLES == abi_sys::AUDIO_BUFFER_SAMPLES); const _: () = assert!(AUDIO_BUFFER_SAMPLES == userlib_sys::AUDIO_BUFFER_SAMPLES);
// 8bit stereo interleaved PCM audio buffers // 8bit stereo interleaved PCM audio buffers
pub static mut AUDIO_BUFFER: [u8; AUDIO_BUFFER_SAMPLES * 2] = [0; AUDIO_BUFFER_SAMPLES * 2]; pub static mut AUDIO_BUFFER: [u8; AUDIO_BUFFER_SAMPLES * 2] = [0; AUDIO_BUFFER_SAMPLES * 2];

View File

@@ -1,8 +1,7 @@
use crate::{ use crate::{
abi,
storage::{File, SDCARD}, storage::{File, SDCARD},
syscalls,
}; };
use abi_sys::{CallTable, EntryFn};
use alloc::{vec, vec::Vec}; use alloc::{vec, vec::Vec};
use bumpalo::Bump; use bumpalo::Bump;
use core::ptr; use core::ptr;
@@ -17,6 +16,7 @@ use goblin::{
elf32::{header, reloc::Rel, section_header::SectionHeader, sym::Sym}, elf32::{header, reloc::Rel, section_header::SectionHeader, sym::Sym},
}; };
use strum::IntoEnumIterator; use strum::IntoEnumIterator;
use userlib_sys::{EntryFn, SyscallTable};
const ELF32_HDR_SIZE: usize = 52; const ELF32_HDR_SIZE: usize = 52;
@@ -70,7 +70,7 @@ pub async unsafe fn load_binary(name: &ShortFileName) -> Option<(EntryFn, Bump)>
} }
} }
patch_abi(&elf_header, base.as_mut_ptr(), min_vaddr, &mut file).unwrap(); patch_syscalls(&elf_header, base.as_mut_ptr(), min_vaddr, &mut file).unwrap();
// entry pointer is base_ptr + (entry - min_vaddr) // entry pointer is base_ptr + (entry - min_vaddr)
let entry_ptr: EntryFn = unsafe { let entry_ptr: EntryFn = unsafe {
@@ -150,7 +150,7 @@ fn apply_relocations(
Ok(()) Ok(())
} }
fn patch_abi( fn patch_syscalls(
elf_header: &Header, elf_header: &Header,
base: *mut u8, base: *mut u8,
min_vaddr: u32, min_vaddr: u32,
@@ -188,27 +188,27 @@ fn patch_abi(
} }
let symbol_name = core::str::from_utf8(&name).unwrap(); let symbol_name = core::str::from_utf8(&name).unwrap();
if symbol_name == "CALL_ABI_TABLE" { if symbol_name == stringify!(SYS_CALL_TABLE) {
let table_base = let table_base =
unsafe { base.add((sym.st_value as usize) - min_vaddr as usize) } unsafe { base.add((sym.st_value as usize) - min_vaddr as usize) }
as *mut usize; as *mut usize;
for (idx, call) in CallTable::iter().enumerate() { for (idx, call) in SyscallTable::iter().enumerate() {
let ptr = match call { let ptr = match call {
CallTable::Alloc => abi::alloc as usize, SyscallTable::Alloc => syscalls::alloc as usize,
CallTable::Dealloc => abi::dealloc as usize, SyscallTable::Dealloc => syscalls::dealloc as usize,
CallTable::PrintString => abi::print as usize, SyscallTable::PrintString => syscalls::print as usize,
CallTable::SleepMs => abi::sleep as usize, SyscallTable::SleepMs => syscalls::sleep as usize,
CallTable::GetMs => abi::get_ms as usize, SyscallTable::GetMs => syscalls::get_ms as usize,
CallTable::DrawIter => abi::draw_iter as usize, SyscallTable::DrawIter => syscalls::draw_iter as usize,
CallTable::GetKey => abi::get_key as usize, SyscallTable::GetKey => syscalls::get_key as usize,
CallTable::GenRand => abi::gen_rand as usize, SyscallTable::GenRand => syscalls::gen_rand as usize,
CallTable::ListDir => abi::list_dir as usize, SyscallTable::ListDir => syscalls::list_dir as usize,
CallTable::ReadFile => abi::read_file as usize, SyscallTable::ReadFile => syscalls::read_file as usize,
CallTable::WriteFile => abi::write_file as usize, SyscallTable::WriteFile => syscalls::write_file as usize,
CallTable::FileLen => abi::file_len as usize, SyscallTable::FileLen => syscalls::file_len as usize,
CallTable::AudioBufferReady => abi::audio_buffer_ready as usize, SyscallTable::AudioBufferReady => syscalls::audio_buffer_ready as usize,
CallTable::SendAudioBuffer => abi::send_audio_buffer as usize, SyscallTable::SendAudioBuffer => syscalls::send_audio_buffer as usize,
}; };
unsafe { unsafe {
table_base.add(idx as usize).write(ptr); table_base.add(idx as usize).write(ptr);

View File

@@ -22,7 +22,7 @@ impl Region {
fn contains(&self, address: usize) -> bool { fn contains(&self, address: usize) -> bool {
let start = self.start.load(Ordering::Relaxed); let start = self.start.load(Ordering::Relaxed);
let end = self.start.load(Ordering::Relaxed); let end = start + self.size.load(Ordering::Relaxed);
(start..start + end).contains(&address) (start..start + end).contains(&address)
} }

View File

@@ -8,7 +8,6 @@
extern crate alloc; extern crate alloc;
mod abi;
mod audio; mod audio;
mod display; mod display;
mod elf; mod elf;
@@ -16,6 +15,7 @@ mod framebuffer;
mod peripherals; mod peripherals;
mod scsi; mod scsi;
mod storage; mod storage;
mod syscalls;
mod ui; mod ui;
mod usb; mod usb;
mod utils; mod utils;
@@ -31,18 +31,14 @@ mod psram;
use crate::{heap::HEAP, heap::init_qmi_psram_heap, psram::init_psram, psram::init_psram_qmi}; use crate::{heap::HEAP, heap::init_qmi_psram_heap, psram::init_psram, psram::init_psram_qmi};
use crate::{ use crate::{
abi::{KEY_CACHE, MS_SINCE_LAUNCH},
audio::audio_handler, audio::audio_handler,
display::{FRAMEBUFFER, display_handler, init_display}, display::{FRAMEBUFFER, display_handler, init_display},
peripherals::{ peripherals::{conf_peripherals, keyboard::read_keyboard_fifo},
conf_peripherals,
keyboard::{KeyState, read_keyboard_fifo},
},
scsi::MSC_SHUTDOWN, scsi::MSC_SHUTDOWN,
storage::{SDCARD, SdCard}, storage::{SDCARD, SdCard},
syscalls::{KEY_CACHE, MS_SINCE_LAUNCH},
ui::{SELECTIONS, clear_selection, ui_handler}, ui::{SELECTIONS, clear_selection, ui_handler},
}; };
use abi_sys::EntryFn;
use bumpalo::Bump; use bumpalo::Bump;
use core::sync::atomic::{AtomicBool, Ordering}; use core::sync::atomic::{AtomicBool, Ordering};
use embassy_executor::{Executor, Spawner}; use embassy_executor::{Executor, Spawner};
@@ -76,6 +72,7 @@ use embedded_hal_bus::spi::ExclusiveDevice;
use embedded_sdmmc::SdCard as SdmmcSdCard; use embedded_sdmmc::SdCard as SdmmcSdCard;
use static_cell::StaticCell; use static_cell::StaticCell;
use talc::*; use talc::*;
use userlib_sys::EntryFn;
use {defmt_rtt as _, panic_probe as _}; use {defmt_rtt as _, panic_probe as _};
embassy_rp::bind_interrupts!(struct Irqs { embassy_rp::bind_interrupts!(struct Irqs {

View File

@@ -1,5 +1,5 @@
use crate::peripherals::PERIPHERAL_BUS; use crate::peripherals::PERIPHERAL_BUS;
pub use abi_sys::keyboard::{KeyCode, KeyEvent, KeyState, Modifiers}; pub use userlib_sys::keyboard::{KeyCode, KeyEvent, KeyState, Modifiers};
const REG_ID_KEY: u8 = 0x04; const REG_ID_KEY: u8 = 0x04;
const REG_ID_FIF: u8 = 0x09; const REG_ID_FIF: u8 = 0x09;

View File

@@ -1,8 +1,3 @@
use abi_sys::{
AUDIO_BUFFER_SAMPLES, AllocAbi, AudioBufferReady, CLayout, CPixel, DeallocAbi, DrawIterAbi,
FileLen, GenRand, GetMsAbi, ListDir, PrintAbi, ReadFile, RngRequest, SendAudioBuffer,
SleepMsAbi, WriteFile, keyboard::*,
};
use alloc::{string::ToString, vec::Vec}; use alloc::{string::ToString, vec::Vec};
use core::{ffi::c_char, ptr, sync::atomic::Ordering}; use core::{ffi::c_char, ptr, sync::atomic::Ordering};
use embassy_rp::clocks::{RoscRng, clk_sys_freq}; use embassy_rp::clocks::{RoscRng, clk_sys_freq};
@@ -10,6 +5,11 @@ use embassy_time::Instant;
use embedded_graphics::draw_target::DrawTarget; use embedded_graphics::draw_target::DrawTarget;
use embedded_sdmmc::LfnBuffer; use embedded_sdmmc::LfnBuffer;
use heapless::spsc::Queue; use heapless::spsc::Queue;
use userlib_sys::{
AUDIO_BUFFER_SAMPLES, Alloc, AudioBufferReady, CLayout, CPixel, Dealloc, DrawIter, FileLen,
GenRand, GetMs, ListDir, Print, ReadFile, RngRequest, SendAudioBuffer, SleepMs, WriteFile,
keyboard::*,
};
#[cfg(feature = "psram")] #[cfg(feature = "psram")]
use crate::heap::HEAP; use crate::heap::HEAP;
@@ -24,7 +24,7 @@ use crate::{
storage::{Dir, File, SDCARD}, storage::{Dir, File, SDCARD},
}; };
const _: AllocAbi = alloc; const _: Alloc = alloc;
pub extern "C" fn alloc(layout: CLayout) -> *mut u8 { pub extern "C" fn alloc(layout: CLayout) -> *mut u8 {
// SAFETY: caller guarantees layout is valid // SAFETY: caller guarantees layout is valid
unsafe { unsafe {
@@ -40,7 +40,7 @@ pub extern "C" fn alloc(layout: CLayout) -> *mut u8 {
} }
} }
const _: DeallocAbi = dealloc; const _: Dealloc = dealloc;
pub extern "C" fn dealloc(ptr: *mut u8, layout: CLayout) { pub extern "C" fn dealloc(ptr: *mut u8, layout: CLayout) {
// SAFETY: caller guarantees ptr and layout are valid // SAFETY: caller guarantees ptr and layout are valid
#[cfg(feature = "psram")] #[cfg(feature = "psram")]
@@ -54,7 +54,7 @@ pub extern "C" fn dealloc(ptr: *mut u8, layout: CLayout) {
} }
} }
const _: PrintAbi = print; const _: Print = print;
pub extern "C" fn print(ptr: *const u8, len: usize) { pub extern "C" fn print(ptr: *const u8, len: usize) {
// SAFETY: caller guarantees `ptr` is valid for `len` bytes // SAFETY: caller guarantees `ptr` is valid for `len` bytes
let slice = unsafe { core::slice::from_raw_parts(ptr, len) }; let slice = unsafe { core::slice::from_raw_parts(ptr, len) };
@@ -68,7 +68,7 @@ pub extern "C" fn print(ptr: *const u8, len: usize) {
} }
} }
const _: SleepMsAbi = sleep; const _: SleepMs = sleep;
pub extern "C" fn sleep(ms: u64) { pub extern "C" fn sleep(ms: u64) {
let cycles_per_ms = clk_sys_freq() / 1000; let cycles_per_ms = clk_sys_freq() / 1000;
let total_cycles = ms * cycles_per_ms as u64; let total_cycles = ms * cycles_per_ms as u64;
@@ -80,14 +80,14 @@ pub extern "C" fn sleep(ms: u64) {
pub static mut MS_SINCE_LAUNCH: Option<Instant> = None; pub static mut MS_SINCE_LAUNCH: Option<Instant> = None;
const _: GetMsAbi = get_ms; const _: GetMs = get_ms;
pub extern "C" fn get_ms() -> u64 { pub extern "C" fn get_ms() -> u64 {
Instant::now() Instant::now()
.duration_since(unsafe { MS_SINCE_LAUNCH.unwrap() }) .duration_since(unsafe { MS_SINCE_LAUNCH.unwrap() })
.as_millis() .as_millis()
} }
const _: DrawIterAbi = draw_iter; const _: DrawIter = draw_iter;
pub extern "C" fn draw_iter(cpixels: *const CPixel, len: usize) { pub extern "C" fn draw_iter(cpixels: *const CPixel, len: usize) {
// SAFETY: caller guarantees `ptr` is valid for `len` bytes // SAFETY: caller guarantees `ptr` is valid for `len` bytes
let cpixels = unsafe { core::slice::from_raw_parts(cpixels, len) }; let cpixels = unsafe { core::slice::from_raw_parts(cpixels, len) };
@@ -101,7 +101,7 @@ pub extern "C" fn draw_iter(cpixels: *const CPixel, len: usize) {
pub static mut KEY_CACHE: Queue<KeyEvent, 32> = Queue::new(); pub static mut KEY_CACHE: Queue<KeyEvent, 32> = Queue::new();
const _: GetKeyAbi = get_key; const _: GetKey = get_key;
pub extern "C" fn get_key() -> KeyEventC { pub extern "C" fn get_key() -> KeyEventC {
if let Some(event) = unsafe { KEY_CACHE.dequeue() } { if let Some(event) = unsafe { KEY_CACHE.dequeue() } {
event.into() event.into()

View File

@@ -2,7 +2,7 @@ use crate::{
BINARY_CH, display::FRAMEBUFFER, elf::load_binary, framebuffer::FB_PAUSED, BINARY_CH, display::FRAMEBUFFER, elf::load_binary, framebuffer::FB_PAUSED,
peripherals::keyboard, storage::FileName, peripherals::keyboard, storage::FileName,
}; };
use abi_sys::keyboard::{KeyCode, KeyState}; use userlib_sys::keyboard::{KeyCode, KeyState};
use alloc::{str::FromStr, string::String, vec::Vec}; use alloc::{str::FromStr, string::String, vec::Vec};
use core::sync::atomic::Ordering; use core::sync::atomic::Ordering;
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, mutex::Mutex}; use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, mutex::Mutex};

View File

@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
abi = { path = "../abi" } userlib = { path = "../userlib" }
embedded-graphics = "0.8.1" embedded-graphics = "0.8.1"
embedded-layout = "0.4.2" embedded-layout = "0.4.2"
embedded-text = "0.7.3" embedded-text = "0.7.3"

View File

@@ -2,25 +2,25 @@
extern crate alloc; extern crate alloc;
use abi::{
display::Display,
get_key,
keyboard::{KeyCode, KeyState},
};
use alloc::vec::Vec; use alloc::vec::Vec;
use embedded_graphics::{ use embedded_graphics::{
Drawable, mono_font::{ascii::FONT_10X20, MonoTextStyle},
mono_font::{MonoTextStyle, ascii::FONT_10X20},
pixelcolor::Rgb565, pixelcolor::Rgb565,
prelude::{Dimensions, DrawTarget, Point, Primitive, RgbColor}, prelude::{Dimensions, DrawTarget, Point, Primitive, RgbColor},
primitives::{PrimitiveStyle, Rectangle}, primitives::{PrimitiveStyle, Rectangle},
text::{Alignment, Text, renderer::TextRenderer}, text::{renderer::TextRenderer, Alignment, Text},
Drawable,
}; };
use embedded_layout::{ use embedded_layout::{
align::{horizontal, vertical}, align::{horizontal, vertical},
layout::linear::{FixedMargin, LinearLayout}, layout::linear::{FixedMargin, LinearLayout},
prelude::*, prelude::*,
}; };
use userlib::{
display::Display,
get_key,
keyboard::{KeyCode, KeyState},
};
#[derive(Debug)] #[derive(Debug)]
pub enum SelectionUiError<DisplayError> { pub enum SelectionUiError<DisplayError> {
@@ -144,5 +144,11 @@ pub fn draw_text_center<'a, S>(
where where
S: TextRenderer<Color = <Display as DrawTarget>::Color>, S: TextRenderer<Color = <Display as DrawTarget>::Color>,
{ {
Text::with_alignment(text, Point::zero(), style, Alignment::Center).draw(display) Text::with_alignment(
text,
display.bounding_box().center(),
style,
Alignment::Center,
)
.draw(display)
} }

View File

@@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
abi = { path = "../../abi" } userlib = { path = "../../userlib" }
embedded-graphics = "0.8.1" embedded-graphics = "0.8.1"
embedded-layout = "0.4.2" embedded-layout = "0.4.2"

View File

@@ -2,12 +2,6 @@
#![no_main] #![no_main]
extern crate alloc; extern crate alloc;
use abi::{
display::Display,
get_key,
keyboard::{KeyCode, KeyState},
println,
};
use alloc::{format, string::String, vec, vec::Vec}; use alloc::{format, string::String, vec, vec::Vec};
use core::panic::PanicInfo; use core::panic::PanicInfo;
use embedded_graphics::{ use embedded_graphics::{
@@ -25,6 +19,12 @@ use embedded_layout::{
layout::linear::LinearLayout, layout::linear::LinearLayout,
prelude::Chain, prelude::Chain,
}; };
use userlib::{
display::Display,
get_key,
keyboard::{KeyCode, KeyState},
println,
};
#[panic_handler] #[panic_handler]
fn panic(info: &PanicInfo) -> ! { fn panic(info: &PanicInfo) -> ! {

View File

@@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
abi = { path = "../../abi" } userlib = { path = "../../userlib" }
embedded-graphics = "0.8.1" embedded-graphics = "0.8.1"
tinybmp = "0.6.0" tinybmp = "0.6.0"

View File

@@ -3,13 +3,6 @@
#![allow(static_mut_refs)] #![allow(static_mut_refs)]
extern crate alloc; extern crate alloc;
use abi::{
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
fs::{Entries, list_dir, read_file},
get_key,
keyboard::{KeyCode, KeyState},
println,
};
use alloc::{format, vec}; use alloc::{format, vec};
use core::panic::PanicInfo; use core::panic::PanicInfo;
use embedded_graphics::{ use embedded_graphics::{
@@ -17,6 +10,13 @@ use embedded_graphics::{
pixelcolor::Rgb565, prelude::*, text::Text, pixelcolor::Rgb565, prelude::*, text::Text,
}; };
use tinybmp::Bmp; use tinybmp::Bmp;
use userlib::{
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
fs::{Entries, list_dir, read_file},
get_key,
keyboard::{KeyCode, KeyState},
println,
};
#[panic_handler] #[panic_handler]
fn panic(info: &PanicInfo) -> ! { fn panic(info: &PanicInfo) -> ! {

View File

@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
abi = { path = "../../abi" } userlib = { path = "../../userlib" }
selection_ui = { path = "../../selection_ui" } selection_ui = { path = "../../selection_ui" }
embedded-graphics = "0.8.1" embedded-graphics = "0.8.1"
tinygif = { git = "https://github.com/LegitCamper/tinygif" } tinygif = { git = "https://github.com/LegitCamper/tinygif" }

View File

@@ -2,24 +2,24 @@
#![no_main] #![no_main]
extern crate alloc; extern crate alloc;
use abi::{
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
fs::{Entries, file_len, list_dir, read_file},
get_key, get_ms,
keyboard::{KeyCode, KeyState},
println, sleep,
};
use alloc::{format, vec, vec::Vec}; use alloc::{format, vec, vec::Vec};
use core::panic::PanicInfo; use core::panic::PanicInfo;
use embedded_graphics::{ use embedded_graphics::{
image::ImageDrawable, image::ImageDrawable,
mono_font::{MonoTextStyle, ascii::FONT_6X10}, mono_font::{ascii::FONT_6X10, MonoTextStyle},
pixelcolor::Rgb565, pixelcolor::Rgb565,
prelude::{Point, RgbColor}, prelude::{Point, RgbColor},
transform::Transform, transform::Transform,
}; };
use selection_ui::{SelectionUi, SelectionUiError, draw_text_center}; use selection_ui::{draw_text_center, SelectionUi, SelectionUiError};
use tinygif::Gif; use tinygif::Gif;
use userlib::{
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
fs::{file_len, list_dir, read_file, Entries},
get_key, get_ms,
keyboard::{KeyCode, KeyState},
println, sleep,
};
#[panic_handler] #[panic_handler]
fn panic(info: &PanicInfo) -> ! { fn panic(info: &PanicInfo) -> ! {

View File

@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
abi = { path = "../../abi" } userlib = { path = "../../userlib" }
embedded-graphics = "0.8.1" embedded-graphics = "0.8.1"
embedded-snake = { git = "https://github.com/LegitCamper/embedded-snake-rs" } embedded-snake = { git = "https://github.com/LegitCamper/embedded-snake-rs" }
rand = { version = "0.9.0", default-features = false } rand = { version = "0.9.0", default-features = false }

View File

@@ -2,16 +2,16 @@
#![no_main] #![no_main]
extern crate alloc; extern crate alloc;
use abi::{ use core::panic::PanicInfo;
use embedded_graphics::{pixelcolor::Rgb565, prelude::RgbColor};
use embedded_snake::{Direction, SnakeGame};
use userlib::{
Rng, Rng,
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH}, display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
get_key, get_key,
keyboard::{KeyCode, KeyState}, keyboard::{KeyCode, KeyState},
println, sleep, println, sleep,
}; };
use core::panic::PanicInfo;
use embedded_graphics::{pixelcolor::Rgb565, prelude::RgbColor};
use embedded_snake::{Direction, SnakeGame};
#[panic_handler] #[panic_handler]
fn panic(info: &PanicInfo) -> ! { fn panic(info: &PanicInfo) -> ! {

View File

@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
abi = { path = "../../abi" } userlib = { path = "../../userlib" }
selection_ui = { path = "../../selection_ui" } selection_ui = { path = "../../selection_ui" }
embedded-graphics = "0.8.1" embedded-graphics = "0.8.1"
rand = { version = "0.9.0", default-features = false } rand = { version = "0.9.0", default-features = false }

View File

@@ -2,24 +2,24 @@
#![no_main] #![no_main]
extern crate alloc; extern crate alloc;
use abi::{ use alloc::{string::String, vec::Vec};
audio::{AUDIO_BUFFER_LEN, audio_buffer_ready, send_audio_buffer}, use core::panic::PanicInfo;
use embedded_audio::{wav::Wav, AudioFile, PlatformFile, PlatformFileError};
use embedded_graphics::{
mono_font::{ascii::FONT_6X10, MonoTextStyle},
pixelcolor::Rgb565,
prelude::RgbColor,
};
use selection_ui::{draw_text_center, SelectionUi, SelectionUiError};
use userlib::{
audio::{audio_buffer_ready, send_audio_buffer, AUDIO_BUFFER_LEN},
display::Display, display::Display,
format, format,
fs::{Entries, file_len, list_dir, read_file}, fs::{file_len, list_dir, read_file, Entries},
get_key, get_key,
keyboard::{KeyCode, KeyState}, keyboard::{KeyCode, KeyState},
println, println,
}; };
use alloc::{string::String, vec::Vec};
use core::panic::PanicInfo;
use embedded_audio::{AudioFile, PlatformFile, PlatformFileError, wav::Wav};
use embedded_graphics::{
mono_font::{MonoTextStyle, ascii::FONT_6X10},
pixelcolor::Rgb565,
prelude::RgbColor,
};
use selection_ui::{SelectionUi, SelectionUiError, draw_text_center};
#[panic_handler] #[panic_handler]
fn panic(info: &PanicInfo) -> ! { fn panic(info: &PanicInfo) -> ! {
@@ -52,7 +52,7 @@ pub fn main() {
SelectionUiError::SelectionListEmpty => { SelectionUiError::SelectionListEmpty => {
draw_text_center( draw_text_center(
&mut display, &mut display,
"No Wavs were found in /gifs", "No Wavs were found in /music",
MonoTextStyle::new(&FONT_6X10, Rgb565::RED), MonoTextStyle::new(&FONT_6X10, Rgb565::RED),
) )
.expect("Display Error"); .expect("Display Error");
@@ -64,6 +64,13 @@ pub fn main() {
assert!(selection.is_some()); assert!(selection.is_some());
draw_text_center(
&mut display,
&format!("Now playing {}", wavs[selection.unwrap()]),
MonoTextStyle::new(&FONT_6X10, Rgb565::WHITE),
)
.expect("Display Error");
let file_name = format!("/music/{}", wavs[selection.unwrap()]); let file_name = format!("/music/{}", wavs[selection.unwrap()]);
let file = File::new(String::from(file_name)); let file = File::new(String::from(file_name));
let mut wav = Wav::new(file).unwrap(); let mut wav = Wav::new(file).unwrap();

View File

@@ -1,10 +1,10 @@
[package] [package]
name = "abi" name = "userlib"
version = "0.1.0" version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
abi_sys = { path = "../abi_sys" } userlib_sys = { path = "../userlib_sys" }
embedded-graphics = "0.8.1" embedded-graphics = "0.8.1"
once_cell = { version = "1", default-features = false } once_cell = { version = "1", default-features = false }
rand_core = "0.9.3" rand_core = "0.9.3"

View File

@@ -3,11 +3,11 @@
extern crate alloc; extern crate alloc;
use abi_sys::{RngRequest, keyboard::KeyEvent};
pub use abi_sys::{keyboard, print};
pub use alloc::format; pub use alloc::format;
use core::alloc::{GlobalAlloc, Layout}; use core::alloc::{GlobalAlloc, Layout};
use rand_core::RngCore; use rand_core::RngCore;
use userlib_sys::{RngRequest, keyboard::KeyEvent};
pub use userlib_sys::{keyboard, print};
#[global_allocator] #[global_allocator]
static ALLOC: Alloc = Alloc; static ALLOC: Alloc = Alloc;
@@ -16,11 +16,11 @@ struct Alloc;
unsafe impl GlobalAlloc for Alloc { unsafe impl GlobalAlloc for Alloc {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 { unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
abi_sys::alloc(layout.into()) userlib_sys::alloc(layout.into())
} }
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
abi_sys::dealloc(ptr, layout.into()); userlib_sys::dealloc(ptr, layout.into());
} }
} }
@@ -33,21 +33,20 @@ macro_rules! println {
} }
pub fn sleep(ms: u64) { pub fn sleep(ms: u64) {
abi_sys::sleep(ms); userlib_sys::sleep(ms);
} }
pub fn get_ms() -> u64 { pub fn get_ms() -> u64 {
abi_sys::get_ms() userlib_sys::get_ms()
} }
pub fn get_key() -> KeyEvent { pub fn get_key() -> KeyEvent {
abi_sys::keyboard::get_key().into() userlib_sys::keyboard::get_key().into()
} }
pub mod display { pub mod display {
use core::sync::atomic::{AtomicBool, Ordering}; use core::sync::atomic::{AtomicBool, Ordering};
use abi_sys::CPixel;
use embedded_graphics::{ use embedded_graphics::{
Pixel, Pixel,
geometry::{Dimensions, Point}, geometry::{Dimensions, Point},
@@ -55,6 +54,7 @@ pub mod display {
prelude::{DrawTarget, Size}, prelude::{DrawTarget, Size},
primitives::Rectangle, primitives::Rectangle,
}; };
use userlib_sys::CPixel;
pub const SCREEN_WIDTH: usize = 320; pub const SCREEN_WIDTH: usize = 320;
pub const SCREEN_HEIGHT: usize = 320; pub const SCREEN_HEIGHT: usize = 320;
@@ -110,13 +110,13 @@ pub mod display {
count += 1; count += 1;
if count == BUF_SIZE - 1 { if count == BUF_SIZE - 1 {
abi_sys::draw_iter(unsafe { BUF.as_ptr() }, count); userlib_sys::draw_iter(unsafe { BUF.as_ptr() }, count);
count = 0; count = 0;
} }
} }
if count > 0 { if count > 0 {
abi_sys::draw_iter(unsafe { BUF.as_ptr() }, count); userlib_sys::draw_iter(unsafe { BUF.as_ptr() }, count);
} }
Ok(()) Ok(())
@@ -125,7 +125,7 @@ pub mod display {
} }
fn gen_rand(req: &mut RngRequest) { fn gen_rand(req: &mut RngRequest) {
abi_sys::gen_rand(req); userlib_sys::gen_rand(req);
} }
pub struct Rng; pub struct Rng;
@@ -162,7 +162,7 @@ pub mod fs {
use core::fmt::Display; use core::fmt::Display;
pub fn read_file(file: &str, start_from: usize, buf: &mut [u8]) -> usize { pub fn read_file(file: &str, start_from: usize, buf: &mut [u8]) -> usize {
abi_sys::read_file( userlib_sys::read_file(
file.as_ptr(), file.as_ptr(),
file.len(), file.len(),
start_from, start_from,
@@ -172,7 +172,7 @@ pub mod fs {
} }
pub fn write_file(file: &str, start_from: usize, buf: &[u8]) { pub fn write_file(file: &str, start_from: usize, buf: &[u8]) {
abi_sys::write_file( userlib_sys::write_file(
file.as_ptr(), file.as_ptr(),
file.len(), file.len(),
start_from, start_from,
@@ -254,7 +254,7 @@ pub mod fs {
} }
pub fn list_dir(path: &str, entries: &mut Entries) -> usize { pub fn list_dir(path: &str, entries: &mut Entries) -> usize {
abi_sys::list_dir( userlib_sys::list_dir(
path.as_ptr(), path.as_ptr(),
path.len(), path.len(),
entries.as_ptrs().as_mut_ptr(), entries.as_ptrs().as_mut_ptr(),
@@ -264,14 +264,14 @@ pub mod fs {
} }
pub fn file_len(str: &str) -> usize { pub fn file_len(str: &str) -> usize {
abi_sys::file_len(str.as_ptr(), str.len()) userlib_sys::file_len(str.as_ptr(), str.len())
} }
} }
pub mod audio { pub mod audio {
pub use abi_sys::{AUDIO_BUFFER_LEN, AUDIO_BUFFER_SAMPLES, audio_buffer_ready}; pub use userlib_sys::{AUDIO_BUFFER_LEN, AUDIO_BUFFER_SAMPLES, audio_buffer_ready};
pub fn send_audio_buffer(buf: &[u8]) { pub fn send_audio_buffer(buf: &[u8]) {
abi_sys::send_audio_buffer(buf.as_ptr(), buf.len()) userlib_sys::send_audio_buffer(buf.as_ptr(), buf.len())
} }
} }

View File

@@ -1,5 +1,5 @@
[package] [package]
name = "abi_sys" name = "userlib_sys"
version = "0.1.0" version = "0.1.0"
edition = "2024" edition = "2024"

View File

@@ -12,12 +12,12 @@ use strum::{EnumCount, EnumIter};
pub type EntryFn = fn(); pub type EntryFn = fn();
pub const ABI_CALL_TABLE_COUNT: usize = 14; pub const SYS_CALL_TABLE_COUNT: usize = 14;
const _: () = assert!(ABI_CALL_TABLE_COUNT == CallTable::COUNT); const _: () = assert!(SYS_CALL_TABLE_COUNT == SyscallTable::COUNT);
#[derive(Clone, Copy, EnumIter, EnumCount)] #[derive(Clone, Copy, EnumIter, EnumCount)]
#[repr(u8)] #[repr(u8)]
pub enum CallTable { pub enum SyscallTable {
Alloc = 0, Alloc = 0,
Dealloc = 1, Dealloc = 1,
PrintString = 2, PrintString = 2,
@@ -36,7 +36,7 @@ pub enum CallTable {
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
#[unsafe(link_section = ".syscall_table")] #[unsafe(link_section = ".syscall_table")]
pub static mut CALL_ABI_TABLE: [usize; ABI_CALL_TABLE_COUNT] = [0; ABI_CALL_TABLE_COUNT]; pub static mut SYS_CALL_TABLE: [usize; SYS_CALL_TABLE_COUNT] = [0; SYS_CALL_TABLE_COUNT];
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[repr(C)] #[repr(C)]
@@ -62,46 +62,46 @@ impl From<Layout> for CLayout {
} }
} }
pub type AllocAbi = extern "C" fn(layout: CLayout) -> *mut u8; pub type Alloc = extern "C" fn(layout: CLayout) -> *mut u8;
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub extern "C" fn alloc(layout: CLayout) -> *mut u8 { pub extern "C" fn alloc(layout: CLayout) -> *mut u8 {
let f: AllocAbi = unsafe { core::mem::transmute(CALL_ABI_TABLE[CallTable::Alloc as usize]) }; let f: Alloc = unsafe { core::mem::transmute(SYS_CALL_TABLE[SyscallTable::Alloc as usize]) };
f(layout) f(layout)
} }
pub type DeallocAbi = extern "C" fn(ptr: *mut u8, layout: CLayout); pub type Dealloc = extern "C" fn(ptr: *mut u8, layout: CLayout);
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub extern "C" fn dealloc(ptr: *mut u8, layout: CLayout) { pub extern "C" fn dealloc(ptr: *mut u8, layout: CLayout) {
let f: DeallocAbi = let f: Dealloc =
unsafe { core::mem::transmute(CALL_ABI_TABLE[CallTable::Dealloc as usize]) }; unsafe { core::mem::transmute(SYS_CALL_TABLE[SyscallTable::Dealloc as usize]) };
f(ptr, layout) f(ptr, layout)
} }
pub type PrintAbi = extern "C" fn(ptr: *const u8, len: usize); pub type Print = extern "C" fn(ptr: *const u8, len: usize);
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub extern "C" fn print(ptr: *const u8, len: usize) { pub extern "C" fn print(ptr: *const u8, len: usize) {
let f: PrintAbi = let f: Print =
unsafe { core::mem::transmute(CALL_ABI_TABLE[CallTable::PrintString as usize]) }; unsafe { core::mem::transmute(SYS_CALL_TABLE[SyscallTable::PrintString as usize]) };
f(ptr, len); f(ptr, len);
} }
pub type SleepMsAbi = extern "C" fn(ms: u64); pub type SleepMs = extern "C" fn(ms: u64);
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub extern "C" fn sleep(ms: u64) { pub extern "C" fn sleep(ms: u64) {
let f: SleepMsAbi = let f: SleepMs =
unsafe { core::mem::transmute(CALL_ABI_TABLE[CallTable::SleepMs as usize]) }; unsafe { core::mem::transmute(SYS_CALL_TABLE[SyscallTable::SleepMs as usize]) };
f(ms); f(ms);
} }
pub type GetMsAbi = extern "C" fn() -> u64; pub type GetMs = extern "C" fn() -> u64;
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub extern "C" fn get_ms() -> u64 { pub extern "C" fn get_ms() -> u64 {
let f: GetMsAbi = unsafe { core::mem::transmute(CALL_ABI_TABLE[CallTable::GetMs as usize]) }; let f: GetMs = unsafe { core::mem::transmute(SYS_CALL_TABLE[SyscallTable::GetMs as usize]) };
f() f()
} }
@@ -139,17 +139,17 @@ impl Into<Pixel<Rgb565>> for CPixel {
} }
} }
pub type DrawIterAbi = extern "C" fn(ptr: *const CPixel, len: usize); pub type DrawIter = extern "C" fn(ptr: *const CPixel, len: usize);
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub extern "C" fn draw_iter(ptr: *const CPixel, len: usize) { pub extern "C" fn draw_iter(ptr: *const CPixel, len: usize) {
let f: DrawIterAbi = let f: DrawIter =
unsafe { core::mem::transmute(CALL_ABI_TABLE[CallTable::DrawIter as usize]) }; unsafe { core::mem::transmute(SYS_CALL_TABLE[SyscallTable::DrawIter as usize]) };
f(ptr, len); f(ptr, len);
} }
pub mod keyboard { pub mod keyboard {
use crate::{CALL_ABI_TABLE, CallTable}; use crate::{SYS_CALL_TABLE, SyscallTable};
bitflags::bitflags! { bitflags::bitflags! {
#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] #[derive(Default, Debug, PartialEq, Eq, Clone, Copy)]
@@ -367,12 +367,12 @@ pub mod keyboard {
} }
} }
pub type GetKeyAbi = extern "C" fn() -> KeyEventC; pub type GetKey = extern "C" fn() -> KeyEventC;
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub extern "C" fn get_key() -> KeyEventC { pub extern "C" fn get_key() -> KeyEventC {
let f: GetKeyAbi = let f: GetKey =
unsafe { core::mem::transmute(CALL_ABI_TABLE[CallTable::GetKey as usize]) }; unsafe { core::mem::transmute(SYS_CALL_TABLE[SyscallTable::GetKey as usize]) };
f() f()
} }
} }
@@ -389,7 +389,7 @@ pub type GenRand = extern "C" fn(req: &mut RngRequest);
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub extern "C" fn gen_rand(req: &mut RngRequest) { pub extern "C" fn gen_rand(req: &mut RngRequest) {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallTable::GenRand as usize]; let ptr = SYS_CALL_TABLE[SyscallTable::GenRand as usize];
let f: GenRand = core::mem::transmute(ptr); let f: GenRand = core::mem::transmute(ptr);
f(req) f(req)
} }
@@ -412,7 +412,7 @@ pub extern "C" fn list_dir(
max_entry_str_len: usize, max_entry_str_len: usize,
) -> usize { ) -> usize {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallTable::ListDir as usize]; let ptr = SYS_CALL_TABLE[SyscallTable::ListDir as usize];
let f: ListDir = core::mem::transmute(ptr); let f: ListDir = core::mem::transmute(ptr);
f(str, len, entries, entry_count, max_entry_str_len) f(str, len, entries, entry_count, max_entry_str_len)
} }
@@ -435,7 +435,7 @@ pub extern "C" fn read_file(
buf_len: usize, buf_len: usize,
) -> usize { ) -> usize {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallTable::ReadFile as usize]; let ptr = SYS_CALL_TABLE[SyscallTable::ReadFile as usize];
let f: ReadFile = core::mem::transmute(ptr); let f: ReadFile = core::mem::transmute(ptr);
f(str, len, read_from, buf, buf_len) f(str, len, read_from, buf, buf_len)
} }
@@ -453,7 +453,7 @@ pub extern "C" fn write_file(
buf_len: usize, buf_len: usize,
) { ) {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallTable::WriteFile as usize]; let ptr = SYS_CALL_TABLE[SyscallTable::WriteFile as usize];
let f: WriteFile = core::mem::transmute(ptr); let f: WriteFile = core::mem::transmute(ptr);
f(str, len, write_from, buf, buf_len) f(str, len, write_from, buf, buf_len)
} }
@@ -464,7 +464,7 @@ pub type FileLen = extern "C" fn(str: *const u8, len: usize) -> usize;
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub extern "C" fn file_len(str: *const u8, len: usize) -> usize { pub extern "C" fn file_len(str: *const u8, len: usize) -> usize {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallTable::FileLen as usize]; let ptr = SYS_CALL_TABLE[SyscallTable::FileLen as usize];
let f: FileLen = core::mem::transmute(ptr); let f: FileLen = core::mem::transmute(ptr);
f(str, len) f(str, len)
} }
@@ -475,7 +475,7 @@ pub type AudioBufferReady = extern "C" fn() -> bool;
#[allow(unused)] #[allow(unused)]
pub fn audio_buffer_ready() -> bool { pub fn audio_buffer_ready() -> bool {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallTable::AudioBufferReady as usize]; let ptr = SYS_CALL_TABLE[SyscallTable::AudioBufferReady as usize];
let f: AudioBufferReady = core::mem::transmute(ptr); let f: AudioBufferReady = core::mem::transmute(ptr);
f() f()
} }
@@ -489,7 +489,7 @@ pub type SendAudioBuffer = extern "C" fn(ptr: *const u8, len: usize);
#[allow(unused)] #[allow(unused)]
pub fn send_audio_buffer(buf: *const u8, len: usize) { pub fn send_audio_buffer(buf: *const u8, len: usize) {
unsafe { unsafe {
let ptr = CALL_ABI_TABLE[CallTable::SendAudioBuffer as usize]; let ptr = SYS_CALL_TABLE[SyscallTable::SendAudioBuffer as usize];
let f: SendAudioBuffer = core::mem::transmute(ptr); let f: SendAudioBuffer = core::mem::transmute(ptr);
f(buf, len) f(buf, len)
} }