Skip to content

Commit 3d84ce9

Browse files
committed
Adapt ProcessArray to upstream
This commit adapts 61b5e50, implemented on a CHERI fork, to upstream. This includes reverting some unrelated changes that made there way into that commit.
1 parent 6571ffa commit 3d84ce9

File tree

59 files changed

+260
-417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+260
-417
lines changed

boards/apollo3/lora_things_plus/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#![reexport_test_harness_main = "test_main"]
4141

4242
use core::ptr::addr_of;
43-
use core::ptr::addr_of_mut;
4443

4544
use apollo3::chip::Apollo3DefaultPeripherals;
4645
use capsules_core::virtualizers::virtual_alarm::MuxAlarm;
@@ -81,7 +80,7 @@ mod tests;
8180
const NUM_PROCS: usize = 4;
8281

8382
// Actual memory for holding the active process structures.
84-
static mut PROCESSES: [Option<&'static dyn kernel::process::Process>; NUM_PROCS] = [None; 4];
83+
static mut PROCESSES: kernel::ProcessArray<NUM_PROCS> = kernel::init_process_array();
8584

8685
// Static reference to chip for panic dumps.
8786
static mut CHIP: Option<&'static apollo3::chip::Apollo3<Apollo3DefaultPeripherals>> = None;
@@ -905,7 +904,6 @@ unsafe fn setup() -> (
905904
// Create and start the asynchronous process loader.
906905
let _loader = components::loader::sequential::ProcessLoaderSequentialComponent::new(
907906
checker,
908-
&mut *addr_of_mut!(PROCESSES),
909907
board_kernel,
910908
chip,
911909
&FAULT_RESPONSE,

boards/apollo3/redboard_artemis_atp/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![reexport_test_harness_main = "test_main"]
1717

1818
use core::ptr::addr_of;
19-
use core::ptr::addr_of_mut;
2019

2120
use apollo3::chip::Apollo3DefaultPeripherals;
2221
use capsules_core::i2c_master_slave_driver::I2CMasterSlaveDriver;
@@ -42,7 +41,7 @@ mod tests;
4241
const NUM_PROCS: usize = 4;
4342

4443
// Actual memory for holding the active process structures.
45-
static mut PROCESSES: [Option<&'static dyn kernel::process::Process>; NUM_PROCS] = [None; 4];
44+
static mut PROCESSES: kernel::ProcessArray<NUM_PROCS> = kernel::init_process_array();
4645

4746
// Static reference to chip for panic dumps.
4847
static mut CHIP: Option<&'static apollo3::chip::Apollo3<Apollo3DefaultPeripherals>> = None;
@@ -408,7 +407,6 @@ unsafe fn setup() -> (
408407
core::ptr::addr_of_mut!(_sappmem),
409408
core::ptr::addr_of!(_eappmem) as usize - core::ptr::addr_of!(_sappmem) as usize,
410409
),
411-
&mut *addr_of_mut!(PROCESSES),
412410
&FAULT_RESPONSE,
413411
&process_mgmt_cap,
414412
)

boards/apollo3/redboard_artemis_nano/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![reexport_test_harness_main = "test_main"]
1717

1818
use core::ptr::addr_of;
19-
use core::ptr::addr_of_mut;
2019

2120
use apollo3::chip::Apollo3DefaultPeripherals;
2221
use capsules_core::virtualizers::virtual_alarm::MuxAlarm;
@@ -42,7 +41,7 @@ mod tests;
4241
const NUM_PROCS: usize = 4;
4342

4443
// Actual memory for holding the active process structures.
45-
static mut PROCESSES: kernel::ProcessArray<NUM_PROCS> = kernel::Kernel::init_process_array();
44+
static mut PROCESSES: kernel::ProcessArray<NUM_PROCS> = kernel::init_process_array();
4645

4746
// Static reference to chip for panic dumps.
4847
static mut CHIP: Option<&'static apollo3::chip::Apollo3<Apollo3DefaultPeripherals>> = None;

boards/arty_e21/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// https://github.com/rust-lang/rust/issues/62184.
1010
#![cfg_attr(not(doc), no_main)]
1111

12-
use core::ptr::{addr_of, addr_of_mut};
12+
use core::ptr::addr_of;
1313

1414
use arty_e21_chip::chip::ArtyExxDefaultPeripherals;
1515
use capsules_core::virtualizers::virtual_alarm::{MuxAlarm, VirtualMuxAlarm};
@@ -36,7 +36,7 @@ const FAULT_RESPONSE: capsules_system::process_policies::PanicFaultPolicy =
3636
capsules_system::process_policies::PanicFaultPolicy {};
3737

3838
// Actual memory for holding the active process structures.
39-
static mut PROCESSES: kernel::ProcessArray<NUM_PROCS> = kernel::Kernel::init_process_array();
39+
static mut PROCESSES: kernel::ProcessArray<NUM_PROCS> = kernel::init_process_array();
4040

4141
// Reference to the chip for panic dumps.
4242
static mut CHIP: Option<&'static arty_e21_chip::chip::ArtyExx<ArtyExxDefaultPeripherals>> = None;

boards/clue_nrf52840/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#![deny(missing_docs)]
1414

1515
use core::ptr::addr_of;
16-
use core::ptr::addr_of_mut;
1716

1817
use capsules_core::virtualizers::virtual_aes_ccm::MuxAES128CCM;
1918

@@ -110,7 +109,7 @@ const FAULT_RESPONSE: capsules_system::process_policies::StopWithDebugFaultPolic
110109
// Number of concurrent processes this platform supports.
111110
const NUM_PROCS: usize = 8;
112111

113-
static mut PROCESSES: kernel::ProcessArray<NUM_PROCS> = kernel::Kernel::init_process_array();
112+
static mut PROCESSES: kernel::ProcessArray<NUM_PROCS> = kernel::init_process_array();
114113

115114
static mut CHIP: Option<&'static nrf52840::chip::NRF52<Nrf52840DefaultPeripherals>> = None;
116115
static mut PROCESS_PRINTER: Option<&'static capsules_system::process_printer::ProcessPrinterText> =

boards/components/src/loader/sequential.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,29 +77,45 @@ impl<C: Chip, D: ProcessStandardDebug, const NUM_PROCS: usize> Component
7777

7878
type Output = &'static kernel::process::SequentialProcessLoaderMachine<'static, C, D>;
7979

80-
fn finalize(mut self, s: Self::StaticInput) -> Self::Output {
80+
fn finalize(self, s: Self::StaticInput) -> Self::Output {
8181
let proc_manage_cap =
8282
kernel::create_capability!(kernel::capabilities::ProcessManagementCapability);
8383

8484
const ARRAY_REPEAT_VALUE: Option<kernel::process::ProcessBinary> = None;
8585
let process_binary_array = s.1.write([ARRAY_REPEAT_VALUE; NUM_PROCS]);
8686

87-
let (flash, ram) = unsafe { kernel::process_loading::get_mems() };
87+
// These symbols are defined in the standard Tock linker script.
88+
extern "C" {
89+
/// Beginning of the ROM region containing app images.
90+
static _sapps: u8;
91+
/// End of the ROM region containing app images.
92+
static _eapps: u8;
93+
/// Beginning of the RAM region for app memory.
94+
static mut _sappmem: u8;
95+
/// End of the RAM region for app memory.
96+
static _eappmem: u8;
97+
}
8898

89-
let loader =
99+
let loader = unsafe {
90100
s.0.write(kernel::process::SequentialProcessLoaderMachine::new(
91101
self.checker,
92102
process_binary_array,
93103
self.kernel,
94104
self.chip,
95-
flash,
96-
ram,
105+
core::slice::from_raw_parts(
106+
core::ptr::addr_of!(_sapps),
107+
core::ptr::addr_of!(_eapps) as usize - core::ptr::addr_of!(_sapps) as usize,
108+
),
109+
core::slice::from_raw_parts_mut(
110+
core::ptr::addr_of_mut!(_sappmem),
111+
core::ptr::addr_of!(_eappmem) as usize - core::ptr::addr_of!(_sappmem) as usize,
112+
),
97113
self.fault_policy,
98114
self.storage_policy,
99115
self.appid_policy,
100116
&proc_manage_cap,
101-
));
102-
117+
))
118+
};
103119
self.checker.set_client(loader);
104120
loader.register();
105121
loader.start();

boards/components/src/sched/cooperative.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use core::mem::MaybeUninit;
1919
use kernel::component::Component;
2020
use kernel::scheduler::cooperative::{CoopProcessNode, CooperativeSched};
21-
use kernel::ProcEntry;
2221

2322
#[macro_export]
2423
macro_rules! cooperative_component_static {
@@ -34,11 +33,13 @@ macro_rules! cooperative_component_static {
3433
}
3534

3635
pub struct CooperativeComponent<const NUM_PROCS: usize> {
37-
processes: &'static [ProcEntry],
36+
processes: &'static kernel::ProcessArray<NUM_PROCS>,
3837
}
3938

4039
impl<const NUM_PROCS: usize> CooperativeComponent<NUM_PROCS> {
41-
pub fn new(processes: &'static [ProcEntry]) -> CooperativeComponent<NUM_PROCS> {
40+
pub fn new(
41+
processes: &'static kernel::ProcessArray<NUM_PROCS>,
42+
) -> CooperativeComponent<NUM_PROCS> {
4243
CooperativeComponent { processes }
4344
}
4445
}
@@ -57,7 +58,7 @@ impl<const NUM_PROCS: usize> Component for CooperativeComponent<NUM_PROCS> {
5758
let nodes = static_buffer.1.write([UNINIT; NUM_PROCS]);
5859

5960
for (i, node) in nodes.iter_mut().enumerate() {
60-
let init_node = node.write(CoopProcessNode::new(&self.processes[i].proc_ref));
61+
let init_node = node.write(CoopProcessNode::new(&self.processes[i]));
6162
scheduler.processes.push_head(init_node);
6263
}
6364
scheduler

boards/components/src/sched/mlfq.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use capsules_core::virtualizers::virtual_alarm::{MuxAlarm, VirtualMuxAlarm};
1515
use kernel::component::Component;
1616
use kernel::hil::time;
1717
use kernel::scheduler::mlfq::{MLFQProcessNode, MLFQSched};
18-
use kernel::ProcEntry;
1918

2019
#[macro_export]
2120
macro_rules! mlfq_component_static {
@@ -39,13 +38,13 @@ macro_rules! mlfq_component_static {
3938

4039
pub struct MLFQComponent<A: 'static + time::Alarm<'static>, const NUM_PROCS: usize> {
4140
alarm_mux: &'static MuxAlarm<'static, A>,
42-
processes: &'static [ProcEntry],
41+
processes: &'static kernel::ProcessArray<NUM_PROCS>,
4342
}
4443

4544
impl<A: 'static + time::Alarm<'static>, const NUM_PROCS: usize> MLFQComponent<A, NUM_PROCS> {
4645
pub fn new(
4746
alarm_mux: &'static MuxAlarm<'static, A>,
48-
processes: &'static [ProcEntry],
47+
processes: &'static kernel::ProcessArray<NUM_PROCS>,
4948
) -> MLFQComponent<A, NUM_PROCS> {
5049
MLFQComponent {
5150
alarm_mux,
@@ -74,7 +73,7 @@ impl<A: 'static + time::Alarm<'static>, const NUM_PROCS: usize> Component
7473
let nodes = static_buffer.2.write([UNINIT; NUM_PROCS]);
7574

7675
for (i, node) in nodes.iter_mut().enumerate() {
77-
let init_node = node.write(MLFQProcessNode::new(&self.processes[i].proc_ref));
76+
let init_node = node.write(MLFQProcessNode::new(&self.processes[i]));
7877
scheduler.processes[0].push_head(init_node);
7978
}
8079
scheduler

boards/components/src/sched/round_robin.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
// Last modified: 03/31/2020
1818

1919
use core::mem::MaybeUninit;
20-
use kernel::collections::list::ListLink;
2120
use kernel::component::Component;
2221
use kernel::scheduler::round_robin::{RoundRobinProcessNode, RoundRobinSched};
23-
use kernel::ProcEntry;
2422

2523
#[macro_export]
2624
macro_rules! round_robin_component_static {
@@ -37,11 +35,13 @@ macro_rules! round_robin_component_static {
3735
}
3836

3937
pub struct RoundRobinComponent<const NUM_PROCS: usize> {
40-
processes: &'static [ProcEntry],
38+
processes: &'static kernel::ProcessArray<NUM_PROCS>,
4139
}
4240

4341
impl<const NUM_PROCS: usize> RoundRobinComponent<NUM_PROCS> {
44-
pub fn new(processes: &'static [ProcEntry]) -> RoundRobinComponent<NUM_PROCS> {
42+
pub fn new(
43+
processes: &'static kernel::ProcessArray<NUM_PROCS>,
44+
) -> RoundRobinComponent<NUM_PROCS> {
4545
RoundRobinComponent { processes }
4646
}
4747
}

boards/configurations/nrf52840dk/nrf52840dk-test-appid-sha256/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#![cfg_attr(not(doc), no_main)]
1111
#![deny(missing_docs)]
1212

13-
use core::ptr::{addr_of, addr_of_mut};
13+
use core::ptr::addr_of;
1414

1515
use kernel::component::Component;
1616
use kernel::hil::led::LedLow;
@@ -46,8 +46,7 @@ const FAULT_RESPONSE: capsules_system::process_policies::PanicFaultPolicy =
4646
// Number of concurrent processes this platform supports.
4747
const NUM_PROCS: usize = 8;
4848

49-
static mut PROCESSES: [Option<&'static dyn kernel::process::Process>; NUM_PROCS] =
50-
[None; NUM_PROCS];
49+
static mut PROCESSES: kernel::ProcessArray<NUM_PROCS> = kernel::init_process_array();
5150

5251
static mut CHIP: Option<&'static nrf52840::chip::NRF52<Nrf52840DefaultPeripherals>> = None;
5352

@@ -290,7 +289,6 @@ pub unsafe fn main() {
290289
// Create and start the asynchronous process loader.
291290
let _loader = components::loader::sequential::ProcessLoaderSequentialComponent::new(
292291
checker,
293-
&mut *addr_of_mut!(PROCESSES),
294292
board_kernel,
295293
chip,
296294
&FAULT_RESPONSE,

0 commit comments

Comments
 (0)