rename libraries

fix

remove
This commit is contained in:
2025-11-17 16:37:02 -07:00
parent 55347be232
commit d77320d445
34 changed files with 129 additions and 128 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

56
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]]
@@ -1230,9 +1209,9 @@ 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]]
@@ -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

@@ -6,21 +6,22 @@ This project provides a minimal kernel, ABI, and user-space applications to expe
## 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 bufs 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 (task scheduling, drivers, memory, etc.)
- **`abi_sys/`** Shared application binary interface definitions for kernel ↔ userspace (Repr "C") - **`userlib_sys/`** FFI bindings for kernel syscalls - kernel ↔ userspace (Repr "C")
- **`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

@@ -9,7 +9,7 @@ kernel-release board:
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

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

@@ -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 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::{clk_sys_freq, RoscRng};
use embassy_time::Instant; 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::{
keyboard::*, AllocAbi, AudioBufferReady, CLayout, CPixel, DeallocAbi, DrawIterAbi, FileLen,
GenRand, GetMsAbi, ListDir, PrintAbi, ReadFile, RngRequest, SendAudioBuffer, SleepMsAbi,
WriteFile, AUDIO_BUFFER_SAMPLES,
};
#[cfg(feature = "psram")] #[cfg(feature = "psram")]
use crate::heap::HEAP; use crate::heap::HEAP;

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

@@ -2,7 +2,7 @@ use crate::{
abi, abi,
storage::{File, SDCARD}, storage::{File, SDCARD},
}; };
use abi_sys::{CallTable, EntryFn}; use userlib_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;

View File

@@ -39,7 +39,7 @@ use crate::{
storage::{SDCARD, SdCard}, storage::{SDCARD, SdCard},
ui::{SELECTIONS, clear_selection, ui_handler}, ui::{SELECTIONS, clear_selection, ui_handler},
}; };
use abi_sys::EntryFn; use userlib_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};

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

@@ -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> {

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) -> ! {

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;
pub use userlib_sys::{keyboard, print};
use userlib_sys::{keyboard::KeyEvent, RngRequest};
#[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,28 +33,28 @@ 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,
geometry::{Dimensions, Point}, geometry::{Dimensions, Point},
pixelcolor::Rgb565, pixelcolor::Rgb565,
prelude::{DrawTarget, Size}, prelude::{DrawTarget, Size},
primitives::Rectangle, primitives::Rectangle,
Pixel,
}; };
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_ready, AUDIO_BUFFER_LEN, AUDIO_BUFFER_SAMPLES};
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"