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
*.uf2
abi_sys.h
userlib_sys.h
assets/gif/bad_apple.gif
picolibc
user-apps/gboy/Peanut-GB

56
Cargo.lock generated
View File

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

View File

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

View File

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

View File

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

View File

@@ -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" }

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 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;

View File

@@ -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];

View File

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

View File

@@ -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};

View File

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

View File

@@ -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};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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" }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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())
}
}

View File

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