Skip to content

Commit

Permalink
Move cpu into system
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Feb 6, 2025
1 parent 26dd850 commit 2598243
Show file tree
Hide file tree
Showing 57 changed files with 251 additions and 249 deletions.
2 changes: 1 addition & 1 deletion esp-hal-embassy/src/executor/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use core::{cell::UnsafeCell, mem::MaybeUninit};

use embassy_executor::SendSpawner;
use esp_hal::{
cpu::Cpu,
interrupt::{self, software::SoftwareInterrupt, InterruptHandler},
system::Cpu,
};
use portable_atomic::{AtomicUsize, Ordering};

Expand Down
2 changes: 1 addition & 1 deletion esp-hal-embassy/src/executor/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::marker::PhantomData;
use embassy_executor::Spawner;
#[cfg(all(low_power_wait, multi_core))]
use esp_hal::interrupt::software::SoftwareInterrupt;
use esp_hal::{cpu::Cpu, interrupt::Priority};
use esp_hal::{interrupt::Priority, system::Cpu};
#[cfg(low_power_wait)]
use portable_atomic::{AtomicBool, Ordering};

Expand Down
4 changes: 2 additions & 2 deletions esp-hal/src/analog/adc/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ impl<ADCI> crate::private::Sealed for Adc<'_, ADCI, Blocking> {}

impl<ADCI> InterruptConfigurable for Adc<'_, ADCI, Blocking> {
fn set_interrupt_handler(&mut self, handler: InterruptHandler) {
for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, InterruptSource);
}
unsafe { crate::interrupt::bind_interrupt(InterruptSource, handler.handler()) };
Expand Down Expand Up @@ -643,7 +643,7 @@ where
pub fn into_blocking(self) -> Adc<'d, ADCI, Blocking> {
if asynch::release_async_adc() {
// Disable ADC interrupt on all cores if the last async ADC instance is disabled
for cpu in crate::cpu::Cpu::all() {
for cpu in crate::system::Cpu::all() {
crate::interrupt::disable(cpu, InterruptSource);
}
}
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/assist_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<'d> DebugAssist<'d> {
/// handlers.
#[instability::unstable]
pub fn set_interrupt_handler(&mut self, handler: InterruptHandler) {
for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, Interrupt::ASSIST_DEBUG);
}
unsafe { crate::interrupt::bind_interrupt(Interrupt::ASSIST_DEBUG, handler.handler()) };
Expand Down
153 changes: 0 additions & 153 deletions esp-hal/src/cpu.rs

This file was deleted.

6 changes: 3 additions & 3 deletions esp-hal/src/dma/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ pub use self::m2m::*;
#[cfg(pdma)]
pub use self::pdma::*;
use crate::{
cpu::Cpu,
interrupt::InterruptHandler,
peripheral::{Peripheral, PeripheralRef},
peripherals::Interrupt,
soc::{is_slice_in_dram, is_valid_memory_address, is_valid_ram_address},
system,
system::Cpu,
Async,
Blocking,
DriverMode,
Expand Down Expand Up @@ -1873,7 +1873,7 @@ where
self.clear_in(EnumSet::all());

if let Some(interrupt) = self.rx_impl.peripheral_interrupt() {
for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, interrupt);
}
unsafe { crate::interrupt::bind_interrupt(interrupt, handler.handler()) };
Expand Down Expand Up @@ -2167,7 +2167,7 @@ where
self.clear_out(EnumSet::all());

if let Some(interrupt) = self.tx_impl.peripheral_interrupt() {
for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, interrupt);
}
unsafe { crate::interrupt::bind_interrupt(interrupt, handler.handler()) };
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ impl<Dm: DriverMode> Ecc<'_, Dm> {
/// handlers.
#[instability::unstable]
pub fn set_interrupt_handler(&mut self, handler: InterruptHandler) {
for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, Interrupt::ECC);
}
unsafe { crate::interrupt::bind_interrupt(Interrupt::ECC, handler.handler()) };
Expand Down
5 changes: 3 additions & 2 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ pub(crate) fn bind_default_interrupt_handler() {
}
// The vector table doesn't contain a custom entry.Still, the
// peripheral interrupt may already be bound to something else.
if interrupt::bound_cpu_interrupt_for(crate::cpu::Cpu::current(), Interrupt::GPIO).is_some() {
if interrupt::bound_cpu_interrupt_for(crate::system::Cpu::current(), Interrupt::GPIO).is_some()
{
info!("Not using default GPIO interrupt handler: peripheral interrupt already in use");
return;
}
Expand Down Expand Up @@ -773,7 +774,7 @@ impl Io {
/// `None`)
#[instability::unstable]
pub fn set_interrupt_handler(&mut self, handler: InterruptHandler) {
for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, Interrupt::GPIO);
}
self.set_interrupt_priority(handler.priority());
Expand Down
4 changes: 2 additions & 2 deletions esp-hal/src/i2c/master/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ impl Info {
}

fn set_interrupt_handler(&self, handler: InterruptHandler) {
for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, self.interrupt);
}
self.enable_listen(EnumSet::all(), false);
Expand All @@ -1342,7 +1342,7 @@ impl Info {
}

fn disable_interrupts(&self) {
crate::interrupt::disable(crate::cpu::Cpu::current(), self.interrupt);
crate::interrupt::disable(crate::system::Cpu::current(), self.interrupt);
}
}

Expand Down
4 changes: 2 additions & 2 deletions esp-hal/src/i2s/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ mod private {

impl RegisterAccessPrivate for I2S0 {
fn set_interrupt_handler(&self, handler: InterruptHandler) {
for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, Interrupt::I2S0);
}
unsafe { crate::peripherals::I2S0::steal() }.bind_i2s0_interrupt(handler.handler());
Expand Down Expand Up @@ -1627,7 +1627,7 @@ mod private {
#[cfg(i2s1)]
impl RegisterAccessPrivate for I2S1 {
fn set_interrupt_handler(&self, handler: InterruptHandler) {
for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, Interrupt::I2S1);
}
unsafe { crate::peripherals::I2S1::steal() }.bind_i2s1_interrupt(handler.handler());
Expand Down
6 changes: 3 additions & 3 deletions esp-hal/src/interrupt/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pub use self::plic::*;
pub use self::vectored::*;
use super::InterruptStatus;
use crate::{
cpu::Cpu,
pac,
peripherals::{Interrupt, INTERRUPT_CORE0},
system::Cpu,
};

/// Interrupt Error
Expand Down Expand Up @@ -560,7 +560,7 @@ mod vectored {
#[cfg(not(plic))]
mod classic {
use super::{CpuInterrupt, InterruptKind, Priority};
use crate::{cpu::Cpu, peripherals::INTERRUPT_CORE0};
use crate::{peripherals::INTERRUPT_CORE0, system::Cpu};

#[cfg_attr(place_switch_tables_in_ram, link_section = ".rwtext")]
pub(super) static DISABLED_CPU_INTERRUPT: u32 = 0;
Expand Down Expand Up @@ -710,7 +710,7 @@ mod classic {
#[cfg(plic)]
mod plic {
use super::{CpuInterrupt, InterruptKind, Priority};
use crate::{cpu::Cpu, peripherals::PLIC_MX};
use crate::{peripherals::PLIC_MX, system::Cpu};

#[cfg_attr(place_switch_tables_in_ram, link_section = ".rwtext")]
pub(super) static DISABLED_CPU_INTERRUPT: u32 = 31;
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/interrupt/software.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<const NUM: u8> SoftwareInterrupt<NUM> {
_ => unreachable!(),
};

for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, interrupt);
}
unsafe { crate::interrupt::bind_interrupt(interrupt, handler.handler()) };
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/interrupt/xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use xtensa_lx_rt::exception::Context;

pub use self::vectored::*;
use super::InterruptStatus;
use crate::{cpu::Cpu, pac, peripherals::Interrupt};
use crate::{pac, peripherals::Interrupt, system::Cpu};

/// Interrupt Error
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand Down
5 changes: 2 additions & 3 deletions esp-hal/src/lcd_cam/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ use core::marker::PhantomData;

use crate::{
asynch::AtomicWaker,
cpu::Cpu,
handler,
interrupt::InterruptHandler,
lcd_cam::{cam::Cam, lcd::Lcd},
peripheral::Peripheral,
peripherals::{Interrupt, LCD_CAM},
system::GenericPeripheralGuard,
system::{Cpu, GenericPeripheralGuard},
Async,
Blocking,
};
Expand Down Expand Up @@ -71,7 +70,7 @@ impl<'d> LcdCam<'d, Blocking> {
/// handlers.
#[instability::unstable]
pub fn set_interrupt_handler(&mut self, handler: InterruptHandler) {
for core in crate::cpu::Cpu::other() {
for core in crate::system::Cpu::other() {
crate::interrupt::disable(core, Interrupt::LCD_CAM);
}
unsafe { crate::interrupt::bind_interrupt(Interrupt::LCD_CAM, handler.handler()) };
Expand Down
1 change: 0 additions & 1 deletion esp-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ pub use self::soc::ulp_core;

#[cfg(any(dport, hp_sys, pcr, system))]
pub mod clock;
pub mod cpu;
#[cfg(gpio)]
pub mod gpio;
#[cfg(any(i2c0, i2c1))]
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/otg_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub mod asynch {
use procmacros::handler;

use super::*;
use crate::cpu::Cpu;
use crate::system::Cpu;

// From ESP32-S3 TRM:
// Six additional endpoints (endpoint numbers 1 to 6), configurable as IN or OUT
Expand Down
Loading

0 comments on commit 2598243

Please sign in to comment.