From 33e0393e4ad0f8bbaf93373a1994480f31af47bd Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 28 Dec 2017 14:40:15 +0000 Subject: [PATCH] firmware: move mod ethmac to libboard. --- artiq/firmware/libboard/Cargo.toml | 6 ++++++ artiq/firmware/{runtime => libboard}/ethmac.rs | 7 ++++--- artiq/firmware/libboard/lib.rs | 4 ++++ artiq/firmware/runtime/Cargo.toml | 2 +- artiq/firmware/runtime/main.rs | 4 ++-- 5 files changed, 17 insertions(+), 6 deletions(-) rename artiq/firmware/{runtime => libboard}/ethmac.rs (97%) diff --git a/artiq/firmware/libboard/Cargo.toml b/artiq/firmware/libboard/Cargo.toml index 9604e9a6e..be1129200 100644 --- a/artiq/firmware/libboard/Cargo.toml +++ b/artiq/firmware/libboard/Cargo.toml @@ -15,5 +15,11 @@ build_misoc = { path = "../libbuild_misoc" } [dependencies] byteorder = { version = "1.0", default-features = false } +[dependencies.smoltcp] +git = "https://github.com/m-labs/smoltcp" +rev = "507d2fe" +default-features = false +optional = true + [features] uart_console = [] diff --git a/artiq/firmware/runtime/ethmac.rs b/artiq/firmware/libboard/ethmac.rs similarity index 97% rename from artiq/firmware/runtime/ethmac.rs rename to artiq/firmware/libboard/ethmac.rs index a19a13933..1a1f29272 100644 --- a/artiq/firmware/runtime/ethmac.rs +++ b/artiq/firmware/libboard/ethmac.rs @@ -2,7 +2,8 @@ use core::{slice, fmt}; use smoltcp::Result; use smoltcp::phy::{self, DeviceCapabilities, Device}; -use board::{csr, mem}; +use csr; +use mem::ETHMAC_BASE; const RX_SLOTS: usize = csr::ETHMAC_RX_SLOTS as usize; const TX_SLOTS: usize = csr::ETHMAC_TX_SLOTS as usize; @@ -30,12 +31,12 @@ fn next_tx_slot() -> Option { fn rx_buffer(slot: usize) -> *const u8 { debug_assert!(slot < RX_SLOTS); - (mem::ETHMAC_BASE + SLOT_SIZE * slot) as _ + (ETHMAC_BASE + SLOT_SIZE * slot) as _ } fn tx_buffer(slot: usize) -> *mut u8 { debug_assert!(slot < TX_SLOTS); - (mem::ETHMAC_BASE + SLOT_SIZE * (RX_SLOTS + slot)) as _ + (ETHMAC_BASE + SLOT_SIZE * (RX_SLOTS + slot)) as _ } pub struct EthernetDevice(()); diff --git a/artiq/firmware/libboard/lib.rs b/artiq/firmware/libboard/lib.rs index 27de0b9e1..06e08a417 100644 --- a/artiq/firmware/libboard/lib.rs +++ b/artiq/firmware/libboard/lib.rs @@ -2,6 +2,8 @@ #![feature(asm)] extern crate byteorder; +#[cfg(feature = "smoltcp")] +extern crate smoltcp; #[cfg(target_arch = "or1k")] #[path = "or1k/mod.rs"] @@ -21,3 +23,5 @@ pub mod spiflash; pub mod config; #[cfg(feature = "uart_console")] pub mod uart_console; +#[cfg(all(has_ethmac, feature = "smoltcp"))] +pub mod ethmac; diff --git a/artiq/firmware/runtime/Cargo.toml b/artiq/firmware/runtime/Cargo.toml index 5802b84b2..f9d75b567 100644 --- a/artiq/firmware/runtime/Cargo.toml +++ b/artiq/firmware/runtime/Cargo.toml @@ -17,7 +17,7 @@ build_artiq = { path = "../libbuild_artiq" } byteorder = { version = "1.0", default-features = false } cslice = { version = "0.3" } log = { version = "0.3", default-features = false } -board = { path = "../libboard", features = ["uart_console"] } +board = { path = "../libboard", features = ["uart_console", "smoltcp"] } alloc_list = { path = "../liballoc_list" } std_artiq = { path = "../libstd_artiq", features = ["alloc", "io_error_alloc"] } logger_artiq = { path = "../liblogger_artiq" } diff --git a/artiq/firmware/runtime/main.rs b/artiq/firmware/runtime/main.rs index d5e9462f5..245acb8ba 100644 --- a/artiq/firmware/runtime/main.rs +++ b/artiq/firmware/runtime/main.rs @@ -26,11 +26,11 @@ extern crate drtioaux; use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr}; use board::config; +#[cfg(has_ethmac)] +use board::ethmac; use proto::{mgmt_proto, analyzer_proto, moninj_proto, rpc_proto, session_proto, kernel_proto}; use amp::{mailbox, rpc_queue}; -#[cfg(has_ethmac)] -mod ethmac; #[cfg(has_rtio_core)] mod rtio_mgt;