forked from M-Labs/zynq-rs
clean up
This commit is contained in:
parent
2c756ba32e
commit
0d4d021b1b
|
@ -6,7 +6,6 @@ extern crate alloc;
|
||||||
use core::{mem::transmute, task::Poll};
|
use core::{mem::transmute, task::Poll};
|
||||||
use alloc::{borrow::ToOwned, collections::BTreeMap, format};
|
use alloc::{borrow::ToOwned, collections::BTreeMap, format};
|
||||||
use log::info;
|
use log::info;
|
||||||
use embedded_hal::timer::CountDown;
|
|
||||||
use libregister::RegisterR;
|
use libregister::RegisterR;
|
||||||
use libcortex_a9::{mutex::Mutex, sync_channel::{self, sync_channel}};
|
use libcortex_a9::{mutex::Mutex, sync_channel::{self, sync_channel}};
|
||||||
use libboard_zynq::{
|
use libboard_zynq::{
|
||||||
|
@ -17,8 +16,6 @@ use libboard_zynq::{
|
||||||
wire::{EthernetAddress, IpAddress, IpCidr},
|
wire::{EthernetAddress, IpAddress, IpCidr},
|
||||||
iface::{NeighborCache, EthernetInterfaceBuilder, Routes},
|
iface::{NeighborCache, EthernetInterfaceBuilder, Routes},
|
||||||
time::Instant,
|
time::Instant,
|
||||||
socket::SocketSet,
|
|
||||||
socket::{TcpSocket, TcpSocketBuffer},
|
|
||||||
},
|
},
|
||||||
time::Milliseconds,
|
time::Milliseconds,
|
||||||
};
|
};
|
||||||
|
@ -109,7 +106,7 @@ pub fn main_core0() {
|
||||||
flash_io.erase(0);
|
flash_io.erase(0);
|
||||||
});
|
});
|
||||||
flash_io.write_enabled(|flash_io| {
|
flash_io.write_enabled(|flash_io| {
|
||||||
flash_io.program(0, [0x23054223; (0x100 >> 2)].iter().cloned());
|
flash_io.program(0, [0x23054223; 0x100 >> 2].iter().cloned());
|
||||||
});
|
});
|
||||||
|
|
||||||
flash = flash_io.stop();
|
flash = flash_io.stop();
|
||||||
|
@ -178,23 +175,13 @@ pub fn main_core0() {
|
||||||
unsafe { transmute(tx_descs.as_mut_slice()) },
|
unsafe { transmute(tx_descs.as_mut_slice()) },
|
||||||
unsafe { transmute(tx_buffers.as_mut_slice()) },
|
unsafe { transmute(tx_buffers.as_mut_slice()) },
|
||||||
);
|
);
|
||||||
// loop {
|
|
||||||
// match eth.recv_next() {
|
|
||||||
// Ok(None) => {},
|
|
||||||
// Ok(Some(pkt)) => println!("received {} bytes", pkt.len()),
|
|
||||||
// Err(e) => println!("e: {:?}", e),
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
println!("iface...");
|
|
||||||
let ethernet_addr = EthernetAddress(HWADDR);
|
let ethernet_addr = EthernetAddress(HWADDR);
|
||||||
// IP stack
|
// IP stack
|
||||||
let local_addr = IpAddress::v4(192, 168, 1, 51);
|
let local_addr = IpAddress::v4(192, 168, 1, 51);
|
||||||
let mut ip_addrs = [IpCidr::new(local_addr, 24)];
|
let mut ip_addrs = [IpCidr::new(local_addr, 24)];
|
||||||
let mut routes_storage = vec![None; 4];
|
let routes = Routes::new(BTreeMap::new());
|
||||||
let routes = Routes::new(/*BTreeMap::new()*/ &mut routes_storage[..]);
|
let neighbor_cache = NeighborCache::new(BTreeMap::new());
|
||||||
let mut neighbor_storage = vec![None; 256];
|
|
||||||
let neighbor_cache = NeighborCache::new(&mut neighbor_storage[..]);
|
|
||||||
let mut iface = EthernetInterfaceBuilder::new(&mut eth)
|
let mut iface = EthernetInterfaceBuilder::new(&mut eth)
|
||||||
.ethernet_addr(ethernet_addr)
|
.ethernet_addr(ethernet_addr)
|
||||||
.ip_addrs(&mut ip_addrs[..])
|
.ip_addrs(&mut ip_addrs[..])
|
||||||
|
@ -202,7 +189,7 @@ pub fn main_core0() {
|
||||||
.neighbor_cache(neighbor_cache)
|
.neighbor_cache(neighbor_cache)
|
||||||
.finalize();
|
.finalize();
|
||||||
|
|
||||||
// TODO: compare with ps7_init
|
ps7_init::report_differences();
|
||||||
|
|
||||||
Sockets::init(32);
|
Sockets::init(32);
|
||||||
/// `chargen`
|
/// `chargen`
|
||||||
|
@ -233,20 +220,20 @@ pub fn main_core0() {
|
||||||
None =>
|
None =>
|
||||||
stream.send("I had trouble reading your name.\n".bytes()).await?,
|
stream.send("I had trouble reading your name.\n".bytes()).await?,
|
||||||
}
|
}
|
||||||
stream.flush().await;
|
let _ = stream.flush().await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut counter = alloc::rc::Rc::new(core::cell::RefCell::new(0));
|
let counter = alloc::rc::Rc::new(core::cell::RefCell::new(0));
|
||||||
task::spawn(async move {
|
task::spawn(async move {
|
||||||
while let stream = TcpStream::accept(TCP_PORT, 2048, 2408).await.unwrap() {
|
while let Ok(stream) = TcpStream::accept(TCP_PORT, 2048, 2408).await {
|
||||||
let counter = counter.clone();
|
let counter = counter.clone();
|
||||||
task::spawn(async move {
|
task::spawn(async move {
|
||||||
*counter.borrow_mut() += 1;
|
*counter.borrow_mut() += 1;
|
||||||
println!("Serving {} connections", *counter.borrow());
|
println!("Serving {} connections", *counter.borrow());
|
||||||
handle_connection(stream)
|
handle_connection(stream)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| println!("Connection: {:?}", e));
|
.unwrap_or_else(|e| println!("Connection: {:?}", e));
|
||||||
*counter.borrow_mut() -= 1;
|
*counter.borrow_mut() -= 1;
|
||||||
println!("Now serving {} connections", *counter.borrow());
|
println!("Now serving {} connections", *counter.borrow());
|
||||||
});
|
});
|
||||||
|
@ -282,7 +269,7 @@ pub fn main_core1() {
|
||||||
while req.is_none() {
|
while req.is_none() {
|
||||||
req = CORE1_REQ.lock().take();
|
req = CORE1_REQ.lock().take();
|
||||||
}
|
}
|
||||||
let mut req = req.unwrap();
|
let req = req.unwrap();
|
||||||
let mut res = None;
|
let mut res = None;
|
||||||
while res.is_none() {
|
while res.is_none() {
|
||||||
res = CORE1_RES.lock().take();
|
res = CORE1_RES.lock().take();
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub struct GlobalTimer {
|
||||||
impl GlobalTimer {
|
impl GlobalTimer {
|
||||||
/// Get the potentially uninitialized timer
|
/// Get the potentially uninitialized timer
|
||||||
pub unsafe fn get() -> GlobalTimer {
|
pub unsafe fn get() -> GlobalTimer {
|
||||||
let mut regs = mpcore::RegisterBlock::new();
|
let regs = mpcore::RegisterBlock::new();
|
||||||
GlobalTimer { regs }
|
GlobalTimer { regs }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ impl L1Entry {
|
||||||
}
|
}
|
||||||
|
|
||||||
const L1_TABLE_SIZE: usize = 4096;
|
const L1_TABLE_SIZE: usize = 4096;
|
||||||
static mut l1_table: L1Table = L1Table {
|
static mut L1_TABLE: L1Table = L1Table {
|
||||||
table: [L1Entry(0); L1_TABLE_SIZE]
|
table: [L1Entry(0); L1_TABLE_SIZE]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ pub struct L1Table {
|
||||||
impl L1Table {
|
impl L1Table {
|
||||||
pub fn get() -> &'static mut Self {
|
pub fn get() -> &'static mut Self {
|
||||||
unsafe {
|
unsafe {
|
||||||
&mut l1_table
|
&mut L1_TABLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue