forked from M-Labs/zynq-rs
eth: add safety asserts
This commit is contained in:
parent
824e91e6cb
commit
74bd81f87f
|
@ -277,6 +277,7 @@ impl<'rx> Eth<'rx> {
|
|||
pub fn start_rx(&mut self, rx_buffers: [&'rx mut [u8]; rx::DESCS]) {
|
||||
self.rx = Some(rx::DescList::new(rx_buffers));
|
||||
let list_addr = self.rx.as_ref().unwrap() as *const _ as u32;
|
||||
assert!(list_addr & 0b11 == 0);
|
||||
self.regs.rx_qbar.write(
|
||||
regs::RxQbar::zeroed()
|
||||
.rx_q_baseaddr(list_addr >> 2)
|
||||
|
|
|
@ -45,7 +45,9 @@ impl<'a> DescList<'a> {
|
|||
pub fn new(buffers: [&'a mut [u8]; DESCS]) -> Self {
|
||||
let mut list: [DescEntry; DESCS] = unsafe { uninitialized() };
|
||||
for i in 0..DESCS {
|
||||
assert!(buffers[i].len() >= 1536);
|
||||
let buffer_addr = &mut buffers[i][0] as *mut _ as u32;
|
||||
assert!(buffer_addr & 0b11 == 0);
|
||||
list[i].word0.write(
|
||||
DescWord0::zeroed()
|
||||
.used(false)
|
||||
|
|
Loading…
Reference in New Issue