forked from M-Labs/zynq-rs
Compare commits
3 Commits
6c9ff22a0a
...
7707399f51
Author | SHA1 | Date |
---|---|---|
Simon Renblad | 7707399f51 | |
Simon Renblad | 239bd2e65f | |
Simon Renblad | e4914f5872 |
|
@ -6,7 +6,6 @@ extern crate alloc;
|
||||||
|
|
||||||
use alloc::collections::BTreeMap;
|
use alloc::collections::BTreeMap;
|
||||||
use core::arch::asm;
|
use core::arch::asm;
|
||||||
use core::ptr::addr_of_mut;
|
|
||||||
use libasync::{
|
use libasync::{
|
||||||
delay,
|
delay,
|
||||||
smoltcp::{Sockets, TcpStream},
|
smoltcp::{Sockets, TcpStream},
|
||||||
|
@ -71,7 +70,7 @@ interrupt_handler!(IRQ, irq, __irq_stack0_start, __irq_stack1_start, {
|
||||||
if id.0 == 0 {
|
if id.0 == 0 {
|
||||||
gic.end_interrupt(id);
|
gic.end_interrupt(id);
|
||||||
asm::exit_irq();
|
asm::exit_irq();
|
||||||
SP.write(addr_of_mut!(__stack1_start) as *mut _ as u32);
|
SP.write(&mut __stack1_start as *mut _ as u32);
|
||||||
asm::enable_irq();
|
asm::enable_irq();
|
||||||
CORE1_RESTART.store(false, Ordering::Relaxed);
|
CORE1_RESTART.store(false, Ordering::Relaxed);
|
||||||
notify_spin_lock();
|
notify_spin_lock();
|
||||||
|
|
|
@ -350,7 +350,6 @@ impl<GEM: Gem> Eth<GEM, (), ()> {
|
||||||
|
|
||||||
impl<GEM: Gem, RX, TX> Eth<GEM, RX, TX> {
|
impl<GEM: Gem, RX, TX> Eth<GEM, RX, TX> {
|
||||||
pub fn start_rx(self, rx_size: usize) -> Eth<GEM, rx::DescList, TX> {
|
pub fn start_rx(self, rx_size: usize) -> Eth<GEM, rx::DescList, TX> {
|
||||||
info!("rx bisect 0");
|
|
||||||
let new_self = Eth {
|
let new_self = Eth {
|
||||||
rx: rx::DescList::new(rx_size),
|
rx: rx::DescList::new(rx_size),
|
||||||
tx: self.tx,
|
tx: self.tx,
|
||||||
|
@ -358,20 +357,15 @@ impl<GEM: Gem, RX, TX> Eth<GEM, RX, TX> {
|
||||||
phy: self.phy,
|
phy: self.phy,
|
||||||
idle: self.idle,
|
idle: self.idle,
|
||||||
};
|
};
|
||||||
info!("rx bisect 1");
|
|
||||||
let list_addr = new_self.rx.list_addr();
|
let list_addr = new_self.rx.list_addr();
|
||||||
info!("rx bisect 2");
|
|
||||||
assert!(list_addr & 0b11 == 0);
|
assert!(list_addr & 0b11 == 0);
|
||||||
info!("rx bisect 3");
|
|
||||||
GEM::regs().rx_qbar.write(
|
GEM::regs().rx_qbar.write(
|
||||||
regs::RxQbar::zeroed()
|
regs::RxQbar::zeroed()
|
||||||
.rx_q_baseaddr(list_addr >> 2)
|
.rx_q_baseaddr(list_addr >> 2)
|
||||||
);
|
);
|
||||||
info!("rx bisect 4");
|
|
||||||
GEM::regs().net_ctrl.modify(|_, w|
|
GEM::regs().net_ctrl.modify(|_, w|
|
||||||
w.rx_en(true)
|
w.rx_en(true)
|
||||||
);
|
);
|
||||||
info!("rx bisect 5");
|
|
||||||
new_self
|
new_self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ use core::ops::Deref;
|
||||||
use alloc::{vec, vec::Vec};
|
use alloc::{vec, vec::Vec};
|
||||||
use libcortex_a9::{asm::*, cache::*, UncachedSlice};
|
use libcortex_a9::{asm::*, cache::*, UncachedSlice};
|
||||||
use libregister::*;
|
use libregister::*;
|
||||||
use log::info;
|
|
||||||
use super::Buffer;
|
use super::Buffer;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -64,35 +63,27 @@ pub struct DescList {
|
||||||
|
|
||||||
impl DescList {
|
impl DescList {
|
||||||
pub fn new(size: usize) -> Self {
|
pub fn new(size: usize) -> Self {
|
||||||
info!("desc list bisect 0");
|
|
||||||
let mut list = UncachedSlice::new(size, || DescEntry::zeroed())
|
let mut list = UncachedSlice::new(size, || DescEntry::zeroed())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
info!("desc list bisect 1");
|
|
||||||
let mut buffers = vec![Buffer::new(); size];
|
let mut buffers = vec![Buffer::new(); size];
|
||||||
|
|
||||||
info!("desc list bisect 2");
|
|
||||||
let last = list.len().min(buffers.len()) - 1;
|
let last = list.len().min(buffers.len()) - 1;
|
||||||
info!("desc list bisect 3");
|
|
||||||
for (i, (entry, buffer)) in list.iter_mut().zip(buffers.iter_mut()).enumerate() {
|
for (i, (entry, buffer)) in list.iter_mut().zip(buffers.iter_mut()).enumerate() {
|
||||||
let is_last = i == last;
|
let is_last = i == last;
|
||||||
let buffer_addr = &mut buffer.0[0] as *mut _ as u32;
|
let buffer_addr = &mut buffer.0[0] as *mut _ as u32;
|
||||||
assert!(buffer_addr & 0b11 == 0);
|
assert!(buffer_addr & 0b11 == 0);
|
||||||
info!("desc list bisect 4");
|
|
||||||
entry.word0.write(
|
entry.word0.write(
|
||||||
DescWord0::zeroed()
|
DescWord0::zeroed()
|
||||||
.used(false)
|
.used(false)
|
||||||
.wrap(is_last)
|
.wrap(is_last)
|
||||||
.address(buffer_addr >> 2)
|
.address(buffer_addr >> 2)
|
||||||
);
|
);
|
||||||
info!("desc list bisect 5");
|
|
||||||
entry.word1.write(
|
entry.word1.write(
|
||||||
DescWord1::zeroed()
|
DescWord1::zeroed()
|
||||||
);
|
);
|
||||||
info!("desc list bisect 6");
|
|
||||||
// Flush buffer from cache, to be filled by the peripheral
|
// Flush buffer from cache, to be filled by the peripheral
|
||||||
// before next read
|
// before next read
|
||||||
dcci_slice(&buffer[..]);
|
dcci_slice(&buffer[..]);
|
||||||
info!("desc list bisect 7");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DescList {
|
DescList {
|
||||||
|
|
|
@ -189,10 +189,10 @@ impl Config {
|
||||||
if is_str {
|
if is_str {
|
||||||
let mut f = root_dir.create_file("/CONFIG.TXT")?;
|
let mut f = root_dir.create_file("/CONFIG.TXT")?;
|
||||||
f.seek(SeekFrom::End(0))?;
|
f.seek(SeekFrom::End(0))?;
|
||||||
f.write(key.as_bytes())?;
|
f.write(key.as_bytes());
|
||||||
f.write("=".as_bytes())?;
|
f.write("=".as_bytes());
|
||||||
f.write(value.as_slice())?;
|
f.write(value.as_slice());
|
||||||
f.write(NEWLINE)?;
|
f.write(NEWLINE);
|
||||||
} else {
|
} else {
|
||||||
let dir = root_dir.create_dir("/CONFIG")?;
|
let dir = root_dir.create_dir("/CONFIG")?;
|
||||||
let mut f = dir.create_file(&[key, ".BIN"].concat())?;
|
let mut f = dir.create_file(&[key, ".BIN"].concat())?;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use bit_field::BitField;
|
use bit_field::BitField;
|
||||||
use core::ptr::addr_of_mut;
|
|
||||||
use super::{regs::*, asm::*, cache::*};
|
use super::{regs::*, asm::*, cache::*};
|
||||||
use libregister::RegisterW;
|
use libregister::RegisterW;
|
||||||
|
|
||||||
|
@ -137,7 +136,7 @@ pub struct L1Table {
|
||||||
impl L1Table {
|
impl L1Table {
|
||||||
pub fn get() -> &'static mut Self {
|
pub fn get() -> &'static mut Self {
|
||||||
unsafe {
|
unsafe {
|
||||||
&mut *addr_of_mut!(L1_TABLE)
|
&mut L1_TABLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl<'a, T> Sender<'a, T> where T: Clone {
|
||||||
notify_spin_lock();
|
notify_spin_lock();
|
||||||
if !prev.is_null() {
|
if !prev.is_null() {
|
||||||
unsafe {
|
unsafe {
|
||||||
drop(Box::from_raw(prev));
|
Box::from_raw(prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -91,7 +91,7 @@ impl<'a, T> Sender<'a, T> where T: Clone {
|
||||||
for v in self.list.iter() {
|
for v in self.list.iter() {
|
||||||
let original = v.swap(core::ptr::null_mut(), Ordering::Relaxed);
|
let original = v.swap(core::ptr::null_mut(), Ordering::Relaxed);
|
||||||
if !original.is_null() {
|
if !original.is_null() {
|
||||||
drop(Box::from_raw(original));
|
Box::from_raw(original);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use core::{
|
use core::{
|
||||||
ops::{Deref, DerefMut},
|
mem::{align_of, size_of}, ops::{Deref, DerefMut}, panic
|
||||||
mem::{align_of, size_of},
|
|
||||||
};
|
};
|
||||||
use alloc::alloc::{dealloc, Layout, LayoutError};
|
use alloc::alloc::{dealloc, Layout, LayoutError};
|
||||||
use crate::mmu::{L1_PAGE_SIZE, L1Table};
|
use crate::mmu::{L1_PAGE_SIZE, L1Table};
|
||||||
|
@ -20,7 +19,6 @@ impl<T> UncachedSlice<T> {
|
||||||
let layout = Layout::from_size_align(size, align)?;
|
let layout = Layout::from_size_align(size, align)?;
|
||||||
let ptr = unsafe { alloc::alloc::alloc(layout).cast::<T>() };
|
let ptr = unsafe { alloc::alloc::alloc(layout).cast::<T>() };
|
||||||
let start = ptr as usize;
|
let start = ptr as usize;
|
||||||
assert_eq!(start & (L1_PAGE_SIZE - 1), 0);
|
|
||||||
|
|
||||||
for page_start in (start..(start + size)).step_by(L1_PAGE_SIZE) {
|
for page_start in (start..(start + size)).step_by(L1_PAGE_SIZE) {
|
||||||
// non-shareable device
|
// non-shareable device
|
||||||
|
@ -31,10 +29,7 @@ impl<T> UncachedSlice<T> {
|
||||||
l1_section.bufferable = false;
|
l1_section.bufferable = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let slice = unsafe { core::slice::from_raw_parts_mut(ptr, len) };
|
let slice = unsafe { core::slice::from_raw_parts_mut(ptr, len) };
|
||||||
// verify size
|
|
||||||
assert!(unsafe { slice.get_unchecked(len) } as *const _ as usize <= start + size);
|
|
||||||
// initialize
|
// initialize
|
||||||
for e in slice.iter_mut() {
|
for e in slice.iter_mut() {
|
||||||
*e = default();
|
*e = default();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use r0::zero_bss;
|
use r0::zero_bss;
|
||||||
use core::ptr::{write_volatile, addr_of_mut, addr_of};
|
use core::ptr::write_volatile;
|
||||||
use core::arch::asm;
|
use core::arch::asm;
|
||||||
use libregister::{
|
use libregister::{
|
||||||
VolatileCell,
|
VolatileCell,
|
||||||
|
@ -43,7 +43,7 @@ unsafe extern "C" fn boot_core0() -> ! {
|
||||||
let mpcore = mpcore::RegisterBlock::mpcore();
|
let mpcore = mpcore::RegisterBlock::mpcore();
|
||||||
mpcore.scu_invalidate.invalidate_all_cores();
|
mpcore.scu_invalidate.invalidate_all_cores();
|
||||||
|
|
||||||
zero_bss(addr_of_mut!(__bss_start), addr_of_mut!(__bss_end));
|
zero_bss(&mut __bss_start, &mut __bss_end);
|
||||||
|
|
||||||
let mmu_table = mmu::L1Table::get()
|
let mmu_table = mmu::L1Table::get()
|
||||||
.setup_flat_layout();
|
.setup_flat_layout();
|
||||||
|
@ -132,9 +132,7 @@ impl Core1 {
|
||||||
CORE1_ENABLED.set(true);
|
CORE1_ENABLED.set(true);
|
||||||
}
|
}
|
||||||
// Flush cache-line
|
// Flush cache-line
|
||||||
unsafe {
|
cache::dcc(unsafe { &CORE1_ENABLED });
|
||||||
cache::dcc(&*addr_of!(CORE1_ENABLED) );
|
|
||||||
}
|
|
||||||
if sdram {
|
if sdram {
|
||||||
cache::dccmvac(0);
|
cache::dccmvac(0);
|
||||||
asm::dsb();
|
asm::dsb();
|
||||||
|
@ -155,7 +153,7 @@ impl Core1 {
|
||||||
pub fn disable(&self) {
|
pub fn disable(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
CORE1_ENABLED.set(false);
|
CORE1_ENABLED.set(false);
|
||||||
cache::dccmvac(addr_of!(CORE1_ENABLED) as *const _ as usize);
|
cache::dccmvac(&CORE1_ENABLED as *const _ as usize);
|
||||||
asm::dsb();
|
asm::dsb();
|
||||||
}
|
}
|
||||||
self.restart();
|
self.restart();
|
||||||
|
|
|
@ -8,7 +8,6 @@ mod netboot;
|
||||||
|
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use core::ptr::{addr_of_mut, addr_of};
|
|
||||||
use libboard_zynq::{
|
use libboard_zynq::{
|
||||||
self as zynq,
|
self as zynq,
|
||||||
clocks::source::{ArmPll, ClockSource, IoPll},
|
clocks::source::{ArmPll, ClockSource, IoPll},
|
||||||
|
@ -116,18 +115,18 @@ pub fn main_core0() {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let max_len =
|
let max_len =
|
||||||
addr_of!(__runtime_end) as *const usize as usize - addr_of!(__runtime_start) as *const usize as usize;
|
&__runtime_end as *const usize as usize - &__runtime_start as *const usize as usize;
|
||||||
match slcr::RegisterBlock::unlocked(|slcr| slcr.boot_mode.read().boot_mode_pins()) {
|
match slcr::RegisterBlock::unlocked(|slcr| slcr.boot_mode.read().boot_mode_pins()) {
|
||||||
slcr::BootModePins::Jtag => netboot::netboot(
|
slcr::BootModePins::Jtag => netboot::netboot(
|
||||||
&mut bootgen_file,
|
&mut bootgen_file,
|
||||||
config,
|
config,
|
||||||
addr_of_mut!(__runtime_start) as *mut usize as *mut u8,
|
&mut __runtime_start as *mut usize as *mut u8,
|
||||||
max_len,
|
max_len,
|
||||||
),
|
),
|
||||||
slcr::BootModePins::SdCard => {
|
slcr::BootModePins::SdCard => {
|
||||||
if boot_sd(
|
if boot_sd(
|
||||||
&mut bootgen_file,
|
&mut bootgen_file,
|
||||||
addr_of_mut!(__runtime_start) as *mut usize as *mut u8,
|
&mut __runtime_start as *mut usize as *mut u8,
|
||||||
max_len,
|
max_len,
|
||||||
)
|
)
|
||||||
.is_err()
|
.is_err()
|
||||||
|
@ -137,7 +136,7 @@ pub fn main_core0() {
|
||||||
netboot::netboot(
|
netboot::netboot(
|
||||||
&mut bootgen_file,
|
&mut bootgen_file,
|
||||||
config,
|
config,
|
||||||
addr_of_mut!(__runtime_start) as *mut usize as *mut u8,
|
&mut __runtime_start as *mut usize as *mut u8,
|
||||||
max_len,
|
max_len,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -148,7 +147,7 @@ pub fn main_core0() {
|
||||||
netboot::netboot(
|
netboot::netboot(
|
||||||
&mut bootgen_file,
|
&mut bootgen_file,
|
||||||
config,
|
config,
|
||||||
addr_of_mut!(__runtime_start) as *mut usize as *mut u8,
|
&mut __runtime_start as *mut usize as *mut u8,
|
||||||
max_len,
|
max_len,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue