Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions arch/cortex-m/src/mpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,16 +754,16 @@ impl<const NUM_REGIONS: usize, const MIN_REGION_SIZE: usize> mpu::MPU
Ok(())
}

fn configure_mpu(&self, config: &Self::MpuConfig, app_id: &ProcessId) {
fn configure_mpu(&self, config: &Self::MpuConfig, processid: &ProcessId) {
// If the hardware is already configured for this app and the app's MPU
// configuration has not changed, then skip the hardware update.
if !self.hardware_is_configured_for.contains(app_id) || config.is_dirty.get() {
if !self.hardware_is_configured_for.contains(processid) || config.is_dirty.get() {
// Set MPU regions
for region in config.regions.iter() {
self.registers.rbar.write(region.base_address());
self.registers.rasr.write(region.attributes());
}
self.hardware_is_configured_for.set(*app_id);
self.hardware_is_configured_for.set(*processid);
config.is_dirty.set(false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions arch/rv32i/src/epmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,11 +741,11 @@ impl<const MAX_AVAILABLE_REGIONS_OVER_TWO: usize> kernel::platform::mpu::MPU
Ok(())
}

fn configure_mpu(&self, config: &Self::MpuConfig, app_id: &ProcessId) {
fn configure_mpu(&self, config: &Self::MpuConfig, processid: &ProcessId) {
// Is the PMP already configured for this app?
let last_configured_for_this_app = self
.last_configured_for
.map_or(false, |last_app_id| last_app_id == app_id);
.map_or(false, |last_processid| last_processid == processid);

if !last_configured_for_this_app || config.is_dirty.get() {
for (x, region) in config.regions.iter().enumerate() {
Expand Down Expand Up @@ -807,7 +807,7 @@ impl<const MAX_AVAILABLE_REGIONS_OVER_TWO: usize> kernel::platform::mpu::MPU
}

config.is_dirty.set(false);
self.last_configured_for.put(*app_id);
self.last_configured_for.put(*processid);
}
}

Expand Down
6 changes: 3 additions & 3 deletions arch/rv32i/src/pmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,11 @@ impl<const MAX_AVAILABLE_REGIONS_OVER_TWO: usize> kernel::platform::mpu::MPU
Ok(())
}

fn configure_mpu(&self, config: &Self::MpuConfig, app_id: &ProcessId) {
fn configure_mpu(&self, config: &Self::MpuConfig, processid: &ProcessId) {
// Is the PMP already configured for this app?
let last_configured_for_this_app = self
.last_configured_for
.map_or(false, |last_app_id| last_app_id == app_id);
.map_or(false, |last_processid| last_processid == processid);

// Skip PMP configuration if it is already configured for this app and the MPU
// configuration of this app has not changed.
Expand Down Expand Up @@ -545,7 +545,7 @@ impl<const MAX_AVAILABLE_REGIONS_OVER_TWO: usize> kernel::platform::mpu::MPU
};
}
config.is_dirty.set(false);
self.last_configured_for.put(*app_id);
self.last_configured_for.put(*processid);
}
}
}
Expand Down
76 changes: 38 additions & 38 deletions capsules/src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub struct AdcDedicated<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> {

// App state
apps: Grant<App, UpcallCount<1>, AllowRoCount<0>, AllowRwCount<2>>,
appid: OptionalCell<ProcessId>,
processid: OptionalCell<ProcessId>,
channel: Cell<usize>,

// ADC buffers
Expand Down Expand Up @@ -179,7 +179,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {

// App state
apps: grant,
appid: OptionalCell::empty(),
processid: OptionalCell::empty(),
channel: Cell::new(0),

// ADC buffers
Expand Down Expand Up @@ -332,7 +332,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {

// cannot sample a buffer without a buffer to sample into
let mut app_buf_length = 0;
let exists = self.appid.map_or(false, |id| {
let exists = self.processid.map_or(false, |id| {
self.apps
.enter(*id, |_, kernel_data| {
app_buf_length = kernel_data
Expand All @@ -345,7 +345,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
}
})
.unwrap_or(false)
Expand All @@ -357,7 +357,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
// save state for callback
self.active.set(true);
self.mode.set(AdcMode::SingleBuffer);
let ret = self.appid.map_or(Err(ErrorCode::NOMEM), |id| {
let ret = self.processid.map_or(Err(ErrorCode::NOMEM), |id| {
self.apps
.enter(*id, |app, _| {
app.app_buf_offset.set(0);
Expand Down Expand Up @@ -405,7 +405,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
}
})
.unwrap_or(Err(ErrorCode::NOMEM))
Expand All @@ -414,7 +414,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
// failure, clear state
self.active.set(false);
self.mode.set(AdcMode::NoMode);
self.appid.map(|id| {
self.processid.map(|id| {
self.apps
.enter(*id, |app, _| {
app.samples_remaining.set(0);
Expand All @@ -424,7 +424,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
}
})
});
Expand Down Expand Up @@ -455,7 +455,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
// cannot continuously sample without two buffers
let mut app_buf_length = 0;
let mut next_app_buf_length = 0;
let exists = self.appid.map_or(false, |id| {
let exists = self.processid.map_or(false, |id| {
self.apps
.enter(*id, |_, kernel_data| {
app_buf_length = kernel_data
Expand All @@ -472,7 +472,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
}
})
.unwrap_or(false)
Expand All @@ -485,7 +485,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
self.active.set(true);
self.mode.set(AdcMode::ContinuousBuffer);

let ret = self.appid.map_or(Err(ErrorCode::NOMEM), |id| {
let ret = self.processid.map_or(Err(ErrorCode::NOMEM), |id| {
self.apps
.enter(*id, |app, _| {
app.app_buf_offset.set(0);
Expand Down Expand Up @@ -546,7 +546,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
}
})
.unwrap_or(Err(ErrorCode::NOMEM))
Expand All @@ -555,7 +555,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
// failure, clear state
self.active.set(false);
self.mode.set(AdcMode::NoMode);
self.appid.map(|id| {
self.processid.map(|id| {
self.apps
.enter(*id, |app, _| {
app.samples_remaining.set(0);
Expand All @@ -565,7 +565,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
}
})
});
Expand All @@ -584,7 +584,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
}

// clean up state
self.appid.map_or(Err(ErrorCode::FAIL), |id| {
self.processid.map_or(Err(ErrorCode::FAIL), |id| {
self.apps
.enter(*id, |app, _| {
self.active.set(false);
Expand Down Expand Up @@ -615,7 +615,7 @@ impl<'a, A: hil::adc::Adc + hil::adc::AdcHighSpeed> AdcDedicated<'a, A> {
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
}
})
.unwrap_or(Err(ErrorCode::FAIL))
Expand Down Expand Up @@ -652,13 +652,13 @@ impl<'a> AdcVirtualized<'a> {
&self,
command: Operation,
channel: usize,
appid: ProcessId,
processid: ProcessId,
) -> Result<(), ErrorCode> {
if channel < self.drivers.len() {
self.apps
.enter(appid, |app, _| {
.enter(processid, |app, _| {
if self.current_app.is_none() {
self.current_app.set(appid);
self.current_app.set(processid);
let value = self.call_driver(command, channel);
if value != Ok(()) {
self.current_app.clear();
Expand Down Expand Up @@ -705,7 +705,7 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::Client for AdcDedicate

// perform callback

self.appid.map(|id| {
self.processid.map(|id| {
self.apps
.enter(*id, |_app, upcalls| {
calledback = true;
Expand All @@ -724,15 +724,15 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::Client for AdcDedicate
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
}
})
});
} else if self.active.get() && self.mode.get() == AdcMode::ContinuousSample {
// sample ready in continuous sampling operation, keep state

// perform callback
self.appid.map(|id| {
self.processid.map(|id| {
self.apps
.enter(*id, |_app, upcalls| {
calledback = true;
Expand All @@ -751,7 +751,7 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::Client for AdcDedicate
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
}
})
});
Expand Down Expand Up @@ -795,7 +795,7 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::HighSpeedClient for Ad
|| self.mode.get() == AdcMode::ContinuousBuffer)
{
// we did expect a buffer. Determine the current application state
self.appid.map(|id| {
self.processid.map(|id| {
self.apps
.enter(*id, |app, kernel_data| {
// Get both buffers, this shouldn't ever fail since the grant was created
Expand Down Expand Up @@ -1056,7 +1056,7 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::HighSpeedClient for Ad
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
unexpected_state = true;
}
})
Expand All @@ -1070,7 +1070,7 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::HighSpeedClient for Ad
// state is consistent. No callback.
self.active.set(false);
self.mode.set(AdcMode::NoMode);
self.appid.map(|id| {
self.processid.map(|id| {
self.apps
.enter(*id, |app, _| {
app.app_buf_offset.set(0);
Expand All @@ -1079,7 +1079,7 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> hil::adc::HighSpeedClient for Ad
if err == kernel::process::Error::NoSuchApp
|| err == kernel::process::Error::InactiveApp
{
self.appid.clear();
self.processid.clear();
}
})
});
Expand Down Expand Up @@ -1107,18 +1107,18 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> SyscallDriver for AdcDedicated<'
///
/// - `command_num` - which command call this is
/// - `data` - value sent by the application, varying uses
/// - `_appid` - application identifier, unused
/// - `_processid` - application identifier, unused
fn command(
&self,
command_num: usize,
channel: usize,
frequency: usize,
appid: ProcessId,
processid: ProcessId,
) -> CommandReturn {
// Return true if this app already owns the ADC capsule, if no app owns
// the ADC capsule, or if the app that is marked as owning the ADC
// capsule no longer exists.
let match_or_empty_or_nonexistant = self.appid.map_or(true, |owning_app| {
let match_or_empty_or_nonexistant = self.processid.map_or(true, |owning_app| {
// We have recorded that an app has ownership of the ADC.

// If the ADC is still active, then we need to wait for the operation
Expand All @@ -1127,7 +1127,7 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> SyscallDriver for AdcDedicated<'
// we need to verify that that application still exists, and remove
// it as owner if not.
if self.active.get() {
owning_app == &appid
owning_app == &processid
} else {
// Check the app still exists.
//
Expand All @@ -1137,12 +1137,12 @@ impl<A: hil::adc::Adc + hil::adc::AdcHighSpeed> SyscallDriver for AdcDedicated<'
// longer exists and we return `true` to signify the
// "or_nonexistant" case.
self.apps
.enter(*owning_app, |_, _| owning_app == &appid)
.enter(*owning_app, |_, _| owning_app == &processid)
.unwrap_or(true)
}
});
if match_or_empty_or_nonexistant {
self.appid.set(appid);
self.processid.set(processid);
} else {
return CommandReturn::failure(ErrorCode::NOMEM);
}
Expand Down Expand Up @@ -1228,21 +1228,21 @@ impl SyscallDriver for AdcVirtualized<'_> {
/// - `command_num` - which command call this is
/// - `channel` - requested channel value
/// - `_` - value sent by the application, unused
/// - `appid` - application identifier
/// - `processid` - application identifier
fn command(
&self,
command_num: usize,
channel: usize,
_: usize,
appid: ProcessId,
processid: ProcessId,
) -> CommandReturn {
match command_num {
// This driver exists and return the number of channels
0 => CommandReturn::success_u32(self.drivers.len() as u32),

// Single sample.
1 => {
let res = self.enqueue_command(Operation::OneSample, channel, appid);
let res = self.enqueue_command(Operation::OneSample, channel, processid);
if res == Ok(()) {
CommandReturn::success()
} else {
Expand Down Expand Up @@ -1286,8 +1286,8 @@ impl SyscallDriver for AdcVirtualized<'_> {

impl<'a> hil::adc::Client for AdcVirtualized<'a> {
fn sample_ready(&self, sample: u16) {
self.current_app.take().map(|appid| {
let _ = self.apps.enter(appid, |app, upcalls| {
self.current_app.take().map(|processid| {
let _ = self.apps.enter(processid, |app, upcalls| {
app.pending_command = false;
let channel = app.channel;
upcalls
Expand Down
Loading