From d77320d445c0aa82278544e521eb1a209390be7e Mon Sep 17 00:00:00 2001 From: sawyer bristol Date: Mon, 17 Nov 2025 16:37:02 -0700 Subject: [PATCH] rename libraries fix remove --- .gitignore | 2 +- Cargo.lock | 56 +++++++++---------- Cargo.toml | 14 ++--- README.md | 13 +++-- justfile | 2 +- kernel/Cargo.toml | 2 +- kernel/src/abi.rs | 12 ++-- kernel/src/audio.rs | 2 +- kernel/src/elf.rs | 2 +- kernel/src/main.rs | 2 +- kernel/src/peripherals/keyboard.rs | 2 +- kernel/src/ui.rs | 2 +- selection_ui/Cargo.toml | 2 +- selection_ui/src/lib.rs | 16 +++--- .../calculator/Cargo.toml | 2 +- {user-apps => user_apps}/calculator/build.rs | 0 .../calculator/src/main.rs | 12 ++-- {user-apps => user_apps}/gallery/Cargo.toml | 2 +- {user-apps => user_apps}/gallery/build.rs | 0 {user-apps => user_apps}/gallery/src/main.rs | 14 ++--- {user-apps => user_apps}/gif/Cargo.toml | 2 +- {user-apps => user_apps}/gif/build.rs | 0 {user-apps => user_apps}/gif/src/main.rs | 18 +++--- {user-apps => user_apps}/memory.x | 0 {user-apps => user_apps}/snake/Cargo.toml | 2 +- {user-apps => user_apps}/snake/build.rs | 0 {user-apps => user_apps}/snake/src/main.rs | 8 +-- .../wav_player/Cargo.toml | 2 +- {user-apps => user_apps}/wav_player/build.rs | 0 .../wav_player/src/main.rs | 24 ++++---- {abi => userlib}/Cargo.toml | 4 +- {abi => userlib}/src/lib.rs | 36 ++++++------ {abi_sys => userlib_sys}/Cargo.toml | 2 +- {abi_sys => userlib_sys}/src/lib.rs | 0 34 files changed, 129 insertions(+), 128 deletions(-) rename {user-apps => user_apps}/calculator/Cargo.toml (78%) rename {user-apps => user_apps}/calculator/build.rs (100%) rename {user-apps => user_apps}/calculator/src/main.rs (99%) rename {user-apps => user_apps}/gallery/Cargo.toml (77%) rename {user-apps => user_apps}/gallery/build.rs (100%) rename {user-apps => user_apps}/gallery/src/main.rs (99%) rename {user-apps => user_apps}/gif/Cargo.toml (85%) rename {user-apps => user_apps}/gif/build.rs (100%) rename {user-apps => user_apps}/gif/src/main.rs (93%) rename {user-apps => user_apps}/memory.x (100%) rename {user-apps => user_apps}/snake/Cargo.toml (86%) rename {user-apps => user_apps}/snake/build.rs (100%) rename {user-apps => user_apps}/snake/src/main.rs (99%) rename {user-apps => user_apps}/wav_player/Cargo.toml (88%) rename {user-apps => user_apps}/wav_player/build.rs (100%) rename {user-apps => user_apps}/wav_player/src/main.rs (91%) rename {abi => userlib}/Cargo.toml (73%) rename {abi => userlib}/src/lib.rs (88%) rename {abi_sys => userlib_sys}/Cargo.toml (94%) rename {abi_sys => userlib_sys}/src/lib.rs (100%) diff --git a/.gitignore b/.gitignore index 62db18b..573ce9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /target *.uf2 -abi_sys.h +userlib_sys.h assets/gif/bad_apple.gif picolibc user-apps/gboy/Peanut-GB diff --git a/Cargo.lock b/Cargo.lock index 3dce1b4..a47adf1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,27 +12,6 @@ dependencies = [ "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]] name = "ahash" version = "0.8.12" @@ -243,9 +222,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" name = "calculator" version = "0.1.0" dependencies = [ - "abi", "embedded-graphics", "embedded-layout", + "userlib", ] [[package]] @@ -1230,9 +1209,9 @@ dependencies = [ name = "gallery" version = "0.1.0" dependencies = [ - "abi", "embedded-graphics", "tinybmp", + "userlib", ] [[package]] @@ -1272,10 +1251,10 @@ dependencies = [ name = "gif" version = "0.1.0" dependencies = [ - "abi", "embedded-graphics", "selection_ui", "tinygif", + "userlib", ] [[package]] @@ -1450,7 +1429,6 @@ dependencies = [ name = "kernel" version = "0.0.1" dependencies = [ - "abi_sys", "assign-resources", "bitflags 2.10.0", "bt-hci", @@ -1493,6 +1471,7 @@ dependencies = [ "strum", "talc", "trouble-host", + "userlib_sys", ] [[package]] @@ -2157,10 +2136,10 @@ checksum = "c1257cd4248b4132760d6524d6dda4e053bc648c9070b960929bf50cfb1e7add" name = "selection_ui" version = "0.1.0" dependencies = [ - "abi", "embedded-graphics", "embedded-layout", "embedded-text", + "userlib", ] [[package]] @@ -2271,10 +2250,10 @@ dependencies = [ name = "snake" version = "0.1.0" dependencies = [ - "abi", "embedded-graphics", "embedded-snake", "rand", + "userlib", ] [[package]] @@ -2647,6 +2626,27 @@ dependencies = [ "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]] name = "uuid" version = "1.18.1" @@ -2758,11 +2758,11 @@ dependencies = [ name = "wav_player" version = "0.1.0" dependencies = [ - "abi", "embedded-audio", "embedded-graphics", "rand", "selection_ui", + "userlib", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 314eaf6..4973709 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,14 +2,14 @@ resolver = "3" members = [ "kernel", - "abi_sys", - "abi", + "userlib_sys", + "userlib", "selection_ui", - "user-apps/calculator", - "user-apps/snake", - "user-apps/gallery", - "user-apps/gif", - "user-apps/wav_player", + "user_apps/calculator", + "user_apps/snake", + "user_apps/gallery", + "user_apps/gif", + "user_apps/wav_player", ] [profile.release] diff --git a/README.md b/README.md index 2d4d4e0..15b7c77 100644 --- a/README.md +++ b/README.md @@ -6,21 +6,22 @@ This project provides a minimal kernel, ABI, and user-space applications to expe ## Status 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 bufs in ffi, and making sure the kernel is as stable as possible. ## Project Structure - **`kernel/`** – The core OS kernel (task scheduling, drivers, memory, etc.) -- **`abi_sys/`** – Shared application binary interface definitions for kernel ↔ userspace (Repr "C") -- **`abi/`** – Rust focused ABI helpers and abstractions for easier development -- **`user-apps/`** – Collection of userspace programs (calculator, snake, etc.) +- **`userlib_sys/`** – FFI bindings for kernel syscalls - kernel ↔ userspace (Repr "C") +- **`userlib/`** – Rust wrapper on top of `userlib_sys` +- **`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 - 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 -- Hardware drivers tailored for the PicoCalc +- Hardware drivers tailored for the PicoCalc( Audio, Display, Keyboard, ans Storage ) ## Getting Started diff --git a/justfile b/justfile index ccddf36..913f0b5 100644 --- a/justfile +++ b/justfile @@ -9,7 +9,7 @@ kernel-release board: binary-args := "RUSTFLAGS=\"-C link-arg=-pie -C relocation-model=pic\"" cbindgen: - cbindgen abi_sys --output abi_sys.h -q + cbindgen userlib_sys --output userlib_sys.h -q newlib: #!/bin/bash diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index aae1192..58f380c 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -99,4 +99,4 @@ embedded-alloc = { version = "0.6.0", features = [ ], optional = true } bumpalo = "3.19.0" -abi_sys = { path = "../abi_sys" } +userlib_sys = { path = "../userlib_sys" } diff --git a/kernel/src/abi.rs b/kernel/src/abi.rs index 8f77bd7..b5eec81 100644 --- a/kernel/src/abi.rs +++ b/kernel/src/abi.rs @@ -1,15 +1,15 @@ -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 core::{ffi::c_char, ptr, sync::atomic::Ordering}; -use embassy_rp::clocks::{RoscRng, clk_sys_freq}; +use embassy_rp::clocks::{clk_sys_freq, RoscRng}; use embassy_time::Instant; use embedded_graphics::draw_target::DrawTarget; use embedded_sdmmc::LfnBuffer; use heapless::spsc::Queue; +use userlib_sys::{ + keyboard::*, AllocAbi, AudioBufferReady, CLayout, CPixel, DeallocAbi, DrawIterAbi, FileLen, + GenRand, GetMsAbi, ListDir, PrintAbi, ReadFile, RngRequest, SendAudioBuffer, SleepMsAbi, + WriteFile, AUDIO_BUFFER_SAMPLES, +}; #[cfg(feature = "psram")] use crate::heap::HEAP; diff --git a/kernel/src/audio.rs b/kernel/src/audio.rs index 7b883dc..e26c939 100644 --- a/kernel/src/audio.rs +++ b/kernel/src/audio.rs @@ -15,7 +15,7 @@ use fixed::traits::ToFixed; pub const SAMPLE_RATE_HZ: u32 = 22_050; 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 pub static mut AUDIO_BUFFER: [u8; AUDIO_BUFFER_SAMPLES * 2] = [0; AUDIO_BUFFER_SAMPLES * 2]; diff --git a/kernel/src/elf.rs b/kernel/src/elf.rs index 11e4855..05aba55 100644 --- a/kernel/src/elf.rs +++ b/kernel/src/elf.rs @@ -2,7 +2,7 @@ use crate::{ abi, storage::{File, SDCARD}, }; -use abi_sys::{CallTable, EntryFn}; +use userlib_sys::{CallTable, EntryFn}; use alloc::{vec, vec::Vec}; use bumpalo::Bump; use core::ptr; diff --git a/kernel/src/main.rs b/kernel/src/main.rs index d738dbf..f32bfca 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -39,7 +39,7 @@ use crate::{ storage::{SDCARD, SdCard}, ui::{SELECTIONS, clear_selection, ui_handler}, }; -use abi_sys::EntryFn; +use userlib_sys::EntryFn; use bumpalo::Bump; use core::sync::atomic::{AtomicBool, Ordering}; use embassy_executor::{Executor, Spawner}; diff --git a/kernel/src/peripherals/keyboard.rs b/kernel/src/peripherals/keyboard.rs index 28b65e7..77d60a8 100644 --- a/kernel/src/peripherals/keyboard.rs +++ b/kernel/src/peripherals/keyboard.rs @@ -1,5 +1,5 @@ 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_FIF: u8 = 0x09; diff --git a/kernel/src/ui.rs b/kernel/src/ui.rs index 2a304a9..6416276 100644 --- a/kernel/src/ui.rs +++ b/kernel/src/ui.rs @@ -2,7 +2,7 @@ use crate::{ BINARY_CH, display::FRAMEBUFFER, elf::load_binary, framebuffer::FB_PAUSED, 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 core::sync::atomic::Ordering; use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, mutex::Mutex}; diff --git a/selection_ui/Cargo.toml b/selection_ui/Cargo.toml index 263d6e3..1aa0ac7 100644 --- a/selection_ui/Cargo.toml +++ b/selection_ui/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] -abi = { path = "../abi" } +userlib = { path = "../userlib" } embedded-graphics = "0.8.1" embedded-layout = "0.4.2" embedded-text = "0.7.3" diff --git a/selection_ui/src/lib.rs b/selection_ui/src/lib.rs index e21d533..9844fce 100644 --- a/selection_ui/src/lib.rs +++ b/selection_ui/src/lib.rs @@ -2,25 +2,25 @@ extern crate alloc; -use abi::{ - display::Display, - get_key, - keyboard::{KeyCode, KeyState}, -}; use alloc::vec::Vec; use embedded_graphics::{ - Drawable, - mono_font::{MonoTextStyle, ascii::FONT_10X20}, + mono_font::{ascii::FONT_10X20, MonoTextStyle}, pixelcolor::Rgb565, prelude::{Dimensions, DrawTarget, Point, Primitive, RgbColor}, primitives::{PrimitiveStyle, Rectangle}, - text::{Alignment, Text, renderer::TextRenderer}, + text::{renderer::TextRenderer, Alignment, Text}, + Drawable, }; use embedded_layout::{ align::{horizontal, vertical}, layout::linear::{FixedMargin, LinearLayout}, prelude::*, }; +use userlib::{ + display::Display, + get_key, + keyboard::{KeyCode, KeyState}, +}; #[derive(Debug)] pub enum SelectionUiError { diff --git a/user-apps/calculator/Cargo.toml b/user_apps/calculator/Cargo.toml similarity index 78% rename from user-apps/calculator/Cargo.toml rename to user_apps/calculator/Cargo.toml index 19115f3..8d210d1 100644 --- a/user-apps/calculator/Cargo.toml +++ b/user_apps/calculator/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" edition = "2024" [dependencies] -abi = { path = "../../abi" } +userlib = { path = "../../userlib" } embedded-graphics = "0.8.1" embedded-layout = "0.4.2" diff --git a/user-apps/calculator/build.rs b/user_apps/calculator/build.rs similarity index 100% rename from user-apps/calculator/build.rs rename to user_apps/calculator/build.rs diff --git a/user-apps/calculator/src/main.rs b/user_apps/calculator/src/main.rs similarity index 99% rename from user-apps/calculator/src/main.rs rename to user_apps/calculator/src/main.rs index 0b42eb9..fe559c7 100644 --- a/user-apps/calculator/src/main.rs +++ b/user_apps/calculator/src/main.rs @@ -2,12 +2,6 @@ #![no_main] extern crate alloc; -use abi::{ - display::Display, - get_key, - keyboard::{KeyCode, KeyState}, - println, -}; use alloc::{format, string::String, vec, vec::Vec}; use core::panic::PanicInfo; use embedded_graphics::{ @@ -25,6 +19,12 @@ use embedded_layout::{ layout::linear::LinearLayout, prelude::Chain, }; +use userlib::{ + display::Display, + get_key, + keyboard::{KeyCode, KeyState}, + println, +}; #[panic_handler] fn panic(info: &PanicInfo) -> ! { diff --git a/user-apps/gallery/Cargo.toml b/user_apps/gallery/Cargo.toml similarity index 77% rename from user-apps/gallery/Cargo.toml rename to user_apps/gallery/Cargo.toml index 610805a..f9f06f7 100644 --- a/user-apps/gallery/Cargo.toml +++ b/user_apps/gallery/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" edition = "2024" [dependencies] -abi = { path = "../../abi" } +userlib = { path = "../../userlib" } embedded-graphics = "0.8.1" tinybmp = "0.6.0" diff --git a/user-apps/gallery/build.rs b/user_apps/gallery/build.rs similarity index 100% rename from user-apps/gallery/build.rs rename to user_apps/gallery/build.rs diff --git a/user-apps/gallery/src/main.rs b/user_apps/gallery/src/main.rs similarity index 99% rename from user-apps/gallery/src/main.rs rename to user_apps/gallery/src/main.rs index 17c5dfc..35c9e34 100644 --- a/user-apps/gallery/src/main.rs +++ b/user_apps/gallery/src/main.rs @@ -3,13 +3,6 @@ #![allow(static_mut_refs)] 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 core::panic::PanicInfo; use embedded_graphics::{ @@ -17,6 +10,13 @@ use embedded_graphics::{ pixelcolor::Rgb565, prelude::*, text::Text, }; 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] fn panic(info: &PanicInfo) -> ! { diff --git a/user-apps/gif/Cargo.toml b/user_apps/gif/Cargo.toml similarity index 85% rename from user-apps/gif/Cargo.toml rename to user_apps/gif/Cargo.toml index cc45976..fb9d4bd 100644 --- a/user-apps/gif/Cargo.toml +++ b/user_apps/gif/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] -abi = { path = "../../abi" } +userlib = { path = "../../userlib" } selection_ui = { path = "../../selection_ui" } embedded-graphics = "0.8.1" tinygif = { git = "https://github.com/LegitCamper/tinygif" } diff --git a/user-apps/gif/build.rs b/user_apps/gif/build.rs similarity index 100% rename from user-apps/gif/build.rs rename to user_apps/gif/build.rs diff --git a/user-apps/gif/src/main.rs b/user_apps/gif/src/main.rs similarity index 93% rename from user-apps/gif/src/main.rs rename to user_apps/gif/src/main.rs index e449096..0e263b8 100644 --- a/user-apps/gif/src/main.rs +++ b/user_apps/gif/src/main.rs @@ -2,24 +2,24 @@ #![no_main] 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 core::panic::PanicInfo; use embedded_graphics::{ image::ImageDrawable, - mono_font::{MonoTextStyle, ascii::FONT_6X10}, + mono_font::{ascii::FONT_6X10, MonoTextStyle}, pixelcolor::Rgb565, prelude::{Point, RgbColor}, transform::Transform, }; -use selection_ui::{SelectionUi, SelectionUiError, draw_text_center}; +use selection_ui::{draw_text_center, SelectionUi, SelectionUiError}; 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] fn panic(info: &PanicInfo) -> ! { diff --git a/user-apps/memory.x b/user_apps/memory.x similarity index 100% rename from user-apps/memory.x rename to user_apps/memory.x diff --git a/user-apps/snake/Cargo.toml b/user_apps/snake/Cargo.toml similarity index 86% rename from user-apps/snake/Cargo.toml rename to user_apps/snake/Cargo.toml index 7eb0d67..7d1a6ae 100644 --- a/user-apps/snake/Cargo.toml +++ b/user_apps/snake/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] -abi = { path = "../../abi" } +userlib = { path = "../../userlib" } embedded-graphics = "0.8.1" embedded-snake = { git = "https://github.com/LegitCamper/embedded-snake-rs" } rand = { version = "0.9.0", default-features = false } diff --git a/user-apps/snake/build.rs b/user_apps/snake/build.rs similarity index 100% rename from user-apps/snake/build.rs rename to user_apps/snake/build.rs diff --git a/user-apps/snake/src/main.rs b/user_apps/snake/src/main.rs similarity index 99% rename from user-apps/snake/src/main.rs rename to user_apps/snake/src/main.rs index a1e078a..2beda43 100644 --- a/user-apps/snake/src/main.rs +++ b/user_apps/snake/src/main.rs @@ -2,16 +2,16 @@ #![no_main] extern crate alloc; -use abi::{ +use core::panic::PanicInfo; +use embedded_graphics::{pixelcolor::Rgb565, prelude::RgbColor}; +use embedded_snake::{Direction, SnakeGame}; +use userlib::{ Rng, display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH}, get_key, keyboard::{KeyCode, KeyState}, println, sleep, }; -use core::panic::PanicInfo; -use embedded_graphics::{pixelcolor::Rgb565, prelude::RgbColor}; -use embedded_snake::{Direction, SnakeGame}; #[panic_handler] fn panic(info: &PanicInfo) -> ! { diff --git a/user-apps/wav_player/Cargo.toml b/user_apps/wav_player/Cargo.toml similarity index 88% rename from user-apps/wav_player/Cargo.toml rename to user_apps/wav_player/Cargo.toml index 37b1594..ca309d7 100644 --- a/user-apps/wav_player/Cargo.toml +++ b/user_apps/wav_player/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] -abi = { path = "../../abi" } +userlib = { path = "../../userlib" } selection_ui = { path = "../../selection_ui" } embedded-graphics = "0.8.1" rand = { version = "0.9.0", default-features = false } diff --git a/user-apps/wav_player/build.rs b/user_apps/wav_player/build.rs similarity index 100% rename from user-apps/wav_player/build.rs rename to user_apps/wav_player/build.rs diff --git a/user-apps/wav_player/src/main.rs b/user_apps/wav_player/src/main.rs similarity index 91% rename from user-apps/wav_player/src/main.rs rename to user_apps/wav_player/src/main.rs index b3605b4..8a94659 100644 --- a/user-apps/wav_player/src/main.rs +++ b/user_apps/wav_player/src/main.rs @@ -2,24 +2,24 @@ #![no_main] extern crate alloc; -use abi::{ - audio::{AUDIO_BUFFER_LEN, audio_buffer_ready, send_audio_buffer}, +use alloc::{string::String, vec::Vec}; +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, format, - fs::{Entries, file_len, list_dir, read_file}, + fs::{file_len, list_dir, read_file, Entries}, get_key, keyboard::{KeyCode, KeyState}, 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] fn panic(info: &PanicInfo) -> ! { diff --git a/abi/Cargo.toml b/userlib/Cargo.toml similarity index 73% rename from abi/Cargo.toml rename to userlib/Cargo.toml index 591ddaa..7555aa3 100644 --- a/abi/Cargo.toml +++ b/userlib/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "abi" +name = "userlib" version = "0.1.0" edition = "2024" [dependencies] -abi_sys = { path = "../abi_sys" } +userlib_sys = { path = "../userlib_sys" } embedded-graphics = "0.8.1" once_cell = { version = "1", default-features = false } rand_core = "0.9.3" diff --git a/abi/src/lib.rs b/userlib/src/lib.rs similarity index 88% rename from abi/src/lib.rs rename to userlib/src/lib.rs index 18f453a..43aad4a 100644 --- a/abi/src/lib.rs +++ b/userlib/src/lib.rs @@ -3,11 +3,11 @@ extern crate alloc; -use abi_sys::{RngRequest, keyboard::KeyEvent}; -pub use abi_sys::{keyboard, print}; pub use alloc::format; use core::alloc::{GlobalAlloc, Layout}; use rand_core::RngCore; +pub use userlib_sys::{keyboard, print}; +use userlib_sys::{keyboard::KeyEvent, RngRequest}; #[global_allocator] static ALLOC: Alloc = Alloc; @@ -16,11 +16,11 @@ struct Alloc; unsafe impl GlobalAlloc for Alloc { 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) { - abi_sys::dealloc(ptr, layout.into()); + userlib_sys::dealloc(ptr, layout.into()); } } @@ -33,28 +33,28 @@ macro_rules! println { } pub fn sleep(ms: u64) { - abi_sys::sleep(ms); + userlib_sys::sleep(ms); } pub fn get_ms() -> u64 { - abi_sys::get_ms() + userlib_sys::get_ms() } pub fn get_key() -> KeyEvent { - abi_sys::keyboard::get_key().into() + userlib_sys::keyboard::get_key().into() } pub mod display { use core::sync::atomic::{AtomicBool, Ordering}; - use abi_sys::CPixel; use embedded_graphics::{ - Pixel, geometry::{Dimensions, Point}, pixelcolor::Rgb565, prelude::{DrawTarget, Size}, primitives::Rectangle, + Pixel, }; + use userlib_sys::CPixel; pub const SCREEN_WIDTH: usize = 320; pub const SCREEN_HEIGHT: usize = 320; @@ -110,13 +110,13 @@ pub mod display { count += 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; } } if count > 0 { - abi_sys::draw_iter(unsafe { BUF.as_ptr() }, count); + userlib_sys::draw_iter(unsafe { BUF.as_ptr() }, count); } Ok(()) @@ -125,7 +125,7 @@ pub mod display { } fn gen_rand(req: &mut RngRequest) { - abi_sys::gen_rand(req); + userlib_sys::gen_rand(req); } pub struct Rng; @@ -162,7 +162,7 @@ pub mod fs { use core::fmt::Display; 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.len(), start_from, @@ -172,7 +172,7 @@ pub mod fs { } pub fn write_file(file: &str, start_from: usize, buf: &[u8]) { - abi_sys::write_file( + userlib_sys::write_file( file.as_ptr(), file.len(), start_from, @@ -254,7 +254,7 @@ pub mod fs { } pub fn list_dir(path: &str, entries: &mut Entries) -> usize { - abi_sys::list_dir( + userlib_sys::list_dir( path.as_ptr(), path.len(), entries.as_ptrs().as_mut_ptr(), @@ -264,14 +264,14 @@ pub mod fs { } 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 use abi_sys::{AUDIO_BUFFER_LEN, AUDIO_BUFFER_SAMPLES, audio_buffer_ready}; + pub use userlib_sys::{audio_buffer_ready, AUDIO_BUFFER_LEN, AUDIO_BUFFER_SAMPLES}; 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()) } } diff --git a/abi_sys/Cargo.toml b/userlib_sys/Cargo.toml similarity index 94% rename from abi_sys/Cargo.toml rename to userlib_sys/Cargo.toml index 5a83d0b..c16eb9a 100644 --- a/abi_sys/Cargo.toml +++ b/userlib_sys/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "abi_sys" +name = "userlib_sys" version = "0.1.0" edition = "2024" diff --git a/abi_sys/src/lib.rs b/userlib_sys/src/lib.rs similarity index 100% rename from abi_sys/src/lib.rs rename to userlib_sys/src/lib.rs