Skip to content

Commit

Permalink
crates/examples/sel4cp/http-server: Reduce heap requirements of drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
nspin committed Aug 22, 2023
1 parent 5cbebd0 commit 7eb38cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const CLIENT: Channel = Channel::new(1);
const QUEUE_SIZE: usize = 4;

#[protection_domain(
heap_size = 16 * 1024 * 1024,
heap_size = 64 * 1024,
)]
fn init() -> ThisHandler {
HalImpl::init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#![feature(never_type)]
#![feature(strict_provenance)]

extern crate alloc;

use core::ptr::NonNull;

use virtio_drivers::{
Expand All @@ -32,7 +30,7 @@ const NET_BUFFER_LEN: usize = 2048;
const NET_QUEUE_SIZE: usize = 16;

#[protection_domain(
heap_size = 16 * 1024 * 1024,
heap_size = 512 * 1024,
)]
fn init() -> ThisHandler {
HalImpl::init(
Expand Down Expand Up @@ -135,9 +133,11 @@ impl Handler for ThisHandler {
let start = desc.encoded_addr() - self.client_dma_region_paddr;
let end = start + usize::try_from(desc.len()).unwrap();
let range = start..end;
let v = self.client_region.as_ptr().index(range).copy_to_vec();
let mut tx_buf = self.dev.new_tx_buffer(v.len());
tx_buf.packet_mut().copy_from_slice(&v);
let mut tx_buf = self.dev.new_tx_buffer(range.len());
self.client_region
.as_ptr()
.index(range)
.copy_into_slice(tx_buf.packet_mut());
self.dev.send(tx_buf).unwrap();
self.tx_ring_buffers.used_mut().enqueue(desc).unwrap();
notify_tx = true;
Expand Down

0 comments on commit 7eb38cb

Please sign in to comment.