forked from M-Labs/artiq
1
0
Fork 0

firmware: fix drtio_routing compatibility with master and satellite

This commit is contained in:
Sebastien Bourdeauducq 2018-09-10 20:16:42 +08:00
parent 7ec45efdcf
commit 31bef9918e
1 changed files with 5 additions and 5 deletions

View File

@ -8,12 +8,12 @@ pub struct RoutingTable([[u8; MAX_HOPS]; DEST_COUNT]);
impl RoutingTable { impl RoutingTable {
// default routing table is for star topology with no hops // default routing table is for star topology with no hops
fn default_master() -> RoutingTable { fn default_master(default_n_links: usize) -> RoutingTable {
let mut ret = RoutingTable([[INVALID_HOP; MAX_HOPS]; DEST_COUNT]); let mut ret = RoutingTable([[INVALID_HOP; MAX_HOPS]; DEST_COUNT]);
for i in 0..csr::DRTIO.len() { for i in 0..default_n_links {
ret.0[i][0] = i as u8; ret.0[i][0] = i as u8;
} }
for i in 1..csr::DRTIO.len() { for i in 1..default_n_links {
ret.0[i][1] = 0x00; ret.0[i][1] = 0x00;
} }
ret ret
@ -26,8 +26,8 @@ impl RoutingTable {
} }
} }
pub fn config_routing_table() -> RoutingTable { pub fn config_routing_table(default_n_links: usize) -> RoutingTable {
let mut ret = RoutingTable::default_master(); let mut ret = RoutingTable::default_master(default_n_links);
let ok = config::read("routing_table", |result| { let ok = config::read("routing_table", |result| {
if let Ok(data) = result { if let Ok(data) = result {
if data.len() == DEST_COUNT*MAX_HOPS { if data.len() == DEST_COUNT*MAX_HOPS {