Skip to content

Commit

Permalink
Give capsules ownership of capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnrt committed Mar 29, 2023
1 parent 75d6454 commit f90c43f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions boards/components/src/udp_driver.rs
Expand Up @@ -125,8 +125,6 @@ impl<A: Alarm<'static>> Component for UDPDriverComponent<A> {
let udp_vis = s.1.write(UdpVisibilityCapability::new(&create_cap));
let udp_send = s.0.write(UDPSendStruct::new(self.udp_send_mux, udp_vis));

static DRIVER_CAP: Capability<UdpDriver> = unsafe { Capability::<UdpDriver>::new() };

let net_cap = s.2.write(NetworkCapability::new(
AddrRange::Any,
PortRange::Any,
Expand All @@ -143,11 +141,13 @@ impl<A: Alarm<'static>> Component for UDPDriverComponent<A> {
MAX_PAYLOAD_LEN,
self.port_table,
kernel::utilities::leasable_buffer::LeasableMutableBuffer::new(buffer),
&DRIVER_CAP,
unsafe { Capability::<UdpDriver>::new() },
net_cap,
));
udp_send.set_client(udp_driver);
self.port_table.set_user_ports(udp_driver, &DRIVER_CAP);

let driver_cap = unsafe { Capability::<UdpDriver>::new() };
self.port_table.set_user_ports(udp_driver, &driver_cap);

let udp_driver_rcvr = s.5.write(UDPReceiver::new());
self.udp_recv_mux.set_driver(udp_driver);
Expand Down
6 changes: 3 additions & 3 deletions capsules/extra/src/net/udp/driver.rs
Expand Up @@ -117,7 +117,7 @@ pub struct UDPDriver<'a> {

kernel_buffer: MapCell<LeasableMutableBuffer<'static, u8>>,

driver_send_cap: &'a Capability<UdpDriver>,
driver_send_cap: Capability<UdpDriver>,

net_cap: &'static NetworkCapability,
}
Expand All @@ -135,7 +135,7 @@ impl<'a> UDPDriver<'a> {
max_tx_pyld_len: usize,
port_table: &'static UdpPortManager,
kernel_buffer: LeasableMutableBuffer<'static, u8>,
driver_send_cap: &'a Capability<UdpDriver>,
driver_send_cap: Capability<UdpDriver>,
net_cap: &'static NetworkCapability,
) -> UDPDriver<'a> {
UDPDriver {
Expand Down Expand Up @@ -225,7 +225,7 @@ impl<'a> UDPDriver<'a> {
dst_port,
src_port,
kernel_buffer,
self.driver_send_cap,
&self.driver_send_cap,
self.net_cap,
) {
Ok(_) => Ok(()),
Expand Down

0 comments on commit f90c43f

Please sign in to comment.