Skip to content

Commit

Permalink
gync: remove oro-sync in lieu of spin crate [no-ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Oct 10, 2024
1 parent b2c9247 commit d1a7050
Show file tree
Hide file tree
Showing 29 changed files with 135 additions and 695 deletions.
49 changes: 36 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ members = [
"oro-bootloader-limine",
"oro-mem",
"oro-elf",
"oro-sync",
"oro-macro",
"oro-macro-proc",
"oro-kernel",
Expand All @@ -41,7 +40,6 @@ oro-mem.path = "oro-mem"
oro-macro.path = "oro-macro"
oro-macro-proc.path = "oro-macro-proc"
oro-elf.path = "oro-elf"
oro-sync.path = "oro-sync"
oro-kernel.path = "oro-kernel"
oro-debug.path = "oro-debug"
oro-debug-pl011.path = "oro-debug-pl011"
Expand All @@ -54,6 +52,7 @@ oro-id.path = "oro-id"
limine = "0.2.0"
uart_16550 = "0.3.0"
volatile-register = "0.2.2"
spin = { version = "0.9.8", features = ["ticket_mutex", "fair_mutex"] }

bindgen = { git = "https://github.com/oro-os/dep.rust-bindgen.git" }
syn = { version = "2.0.60", features = ["full", "printing"] }
Expand Down
3 changes: 2 additions & 1 deletion oro-arch-aarch64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ oro-boot-protocol.workspace = true
oro-mem.workspace = true
oro-macro.workspace = true
oro-elf.workspace = true
oro-sync.workspace = true
oro-debug.workspace = true
oro-dtb.workspace = true
oro-type.workspace = true
oro-dbgutil.workspace = true

spin.workspace = true

[lints]
workspace = true
5 changes: 1 addition & 4 deletions oro-arch-aarch64/src/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ pub unsafe fn boot_primary() -> ! {
crate::init::initialize_primary(pat.clone(), pfa);

{
let mut pfa = crate::init::KERNEL_STATE
.assume_init_ref()
.pfa()
.lock::<crate::sync::InterruptController>();
let mut pfa = crate::init::KERNEL_STATE.assume_init_ref().pfa().lock();

// Boot secondaries.
let num_cores = secondary::boot_secondaries(&mut *pfa, &pat, SECONDARY_STACK_PAGES);
Expand Down
4 changes: 2 additions & 2 deletions oro-arch-aarch64/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::mem::MaybeUninit;

use oro_kernel::KernelState;
use oro_mem::translate::OffsetTranslator;
use oro_sync::spinlock::unfair_critical::UnfairCriticalSpinlock;
use spin::mutex::fair::FairMutex;

/// The global kernel state. Initialized once during boot
/// and re-used across all cores.
Expand Down Expand Up @@ -35,7 +35,7 @@ pub unsafe fn initialize_primary(pat: OffsetTranslator, pfa: crate::Pfa) {

// SAFETY(qix-): We know what we're doing here.
#[expect(static_mut_refs)]
KernelState::init(&mut KERNEL_STATE, pat, UnfairCriticalSpinlock::new(pfa))
KernelState::init(&mut KERNEL_STATE, pat, FairMutex::new(pfa))
.expect("failed to create global kernel state");
}

Expand Down
4 changes: 1 addition & 3 deletions oro-arch-aarch64/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub mod mair;
pub mod mem;
pub mod psci;
pub mod reg;
pub mod sync;

pub(crate) mod init;

Expand All @@ -63,13 +62,12 @@ pub(crate) struct Arch;

impl oro_kernel::Arch for Arch {
type AddrSpace = crate::mem::address_space::AddressSpaceLayout;
type IntCtrl = crate::sync::InterruptController;
type Pat = OffsetTranslator;
type Pfa = Pfa;
}

/// Type alias for the Oro kernel core-local instance type.
pub(crate) type Kernel = oro_kernel::Kernel<CoreState, Arch>;
pub(crate) type Kernel = oro_kernel::Kernel<Arch>;

/// Architecture-specific core-local state.
pub(crate) struct CoreState {
Expand Down
28 changes: 0 additions & 28 deletions oro-arch-aarch64/src/sync.rs

This file was deleted.

3 changes: 2 additions & 1 deletion oro-arch-x86_64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ oro-boot-protocol.workspace = true
oro-mem.workspace = true
oro-macro.workspace = true
oro-elf.workspace = true
oro-sync.workspace = true
oro-debug.workspace = true
oro-dbgutil.workspace = true
oro-acpi.workspace = true
oro-id.workspace = true

spin.workspace = true

[lints]
workspace = true
5 changes: 1 addition & 4 deletions oro-arch-x86_64/src/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ pub unsafe fn boot_primary() -> ! {
crate::init::initialize_primary(pat.clone(), pfa);

{
let mut pfa = crate::init::KERNEL_STATE
.assume_init_ref()
.pfa()
.lock::<crate::sync::InterruptController>();
let mut pfa = crate::init::KERNEL_STATE.assume_init_ref().pfa().lock();

let num_cores = if has_cs89 {
dbg!("physical pages 0x8000/0x9000 are valid; attempting to boot secondary cores");
Expand Down
21 changes: 6 additions & 15 deletions oro-arch-x86_64/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use oro_mem::{
pfa::alloc::Alloc,
translate::{OffsetTranslator, Translator},
};
use oro_sync::spinlock::unfair_critical::UnfairCriticalSpinlock;
use spin::mutex::fair::FairMutex;

use crate::{
gdt::{Gdt, SysEntry},
Expand Down Expand Up @@ -53,12 +53,8 @@ pub unsafe fn initialize_primary(pat: OffsetTranslator, pfa: crate::Pfa) {

// SAFETY(qix-): We know what we're doing here.
#[expect(static_mut_refs)]
KernelState::init(
&mut KERNEL_STATE,
pat.clone(),
UnfairCriticalSpinlock::new(pfa),
)
.expect("failed to create global kernel state");
KernelState::init(&mut KERNEL_STATE, pat.clone(), FairMutex::new(pfa))
.expect("failed to create global kernel state");

let state = KERNEL_STATE.assume_init_ref();

Expand Down Expand Up @@ -102,9 +98,7 @@ pub unsafe fn initialize_primary(pat: OffsetTranslator, pfa: crate::Pfa) {
.expect("failed to create root ring module");

let entry_point = {
let module_lock = module_handle
.try_lock::<crate::sync::InterruptController>()
.expect("failed to lock module");
let module_lock = module_handle.try_lock().expect("failed to lock module");

let mapper = module_lock.mapper();

Expand Down Expand Up @@ -146,10 +140,7 @@ pub unsafe fn initialize_primary(pat: OffsetTranslator, pfa: crate::Pfa) {
segment.target_size()
);

let mut pfa = state
.pfa()
.try_lock::<crate::sync::InterruptController>()
.expect("failed to lock pfa");
let mut pfa = state.pfa().try_lock().expect("failed to lock pfa");

// NOTE(qix-): This will almost definitely be improved in the future.
// NOTE(qix-): At the very least, hugepages will change this.
Expand Down Expand Up @@ -265,7 +256,7 @@ pub unsafe fn boot(lapic: Lapic) -> ! {

if let Some(user_ctx) = maybe_ctx {
let (thread_cr3_phys, thread_rsp, kernel_rsp, kernel_irq_rsp) = unsafe {
let ctx_lock = user_ctx.lock_noncritical();
let ctx_lock = user_ctx.lock();
let cr3 = ctx_lock.mapper().base_phys;
let rsp = ctx_lock.thread_state().irq_stack_ptr;
let kernel_rsp_ptr = kernel.core().kernel_stack.get() as u64;
Expand Down
7 changes: 2 additions & 5 deletions oro-arch-x86_64/src/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ unsafe extern "C" fn isr_sys_timer_rust() -> ! {
// If this is `None`, then the kernel is currently running.
// Otherwise it's a userspace task that we just jumped from.
if let Some(user_task) = scheduler_lock.current_thread().as_ref() {
user_task
.lock_noncritical()
.thread_state_mut()
.irq_stack_ptr = irq_stack_ptr;
user_task.lock().thread_state_mut().irq_stack_ptr = irq_stack_ptr;

coming_from_user = true;
} else {
Expand All @@ -126,7 +123,7 @@ unsafe extern "C" fn isr_sys_timer_rust() -> ! {

if let Some(user_ctx) = maybe_user_context {
let (thread_cr3_phys, thread_rsp) = unsafe {
let ctx_lock = user_ctx.lock_noncritical();
let ctx_lock = user_ctx.lock();
let cr3 = ctx_lock.mapper().base_phys;
let rsp = ctx_lock.thread_state().irq_stack_ptr;
(*handler.kernel().core().tss.get())
Expand Down
2 changes: 0 additions & 2 deletions oro-arch-x86_64/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub mod interrupt;
pub mod lapic;
pub mod mem;
pub mod reg;
pub mod sync;
pub mod task;
pub mod tss;

Expand Down Expand Up @@ -111,7 +110,6 @@ pub(crate) struct Arch;
impl oro_kernel::Arch for Arch {
type AddrSpace = crate::mem::address_space::AddressSpaceLayout;
type CoreState = CoreState;
type IntCtrl = crate::sync::InterruptController;
type Pat = OffsetTranslator;
type Pfa = Pfa;
type ThreadState = ThreadState;
Expand Down
37 changes: 0 additions & 37 deletions oro-arch-x86_64/src/sync.rs

This file was deleted.

Loading

0 comments on commit d1a7050

Please sign in to comment.