From 4480a1c2ff31079e00c6aef063ac20ac95e3b554 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 31 Dec 2016 13:32:50 +0000 Subject: [PATCH] =?UTF-8?q?firmware:=20libbsp::board=20=E2=86=92=20libboar?= =?UTF-8?q?d.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- artiq/firmware/Cargo.lock | 6 +++--- .../firmware/{libbsp => libboard}/Cargo.toml | 4 ++-- .../{libbsp/board.rs => libboard/lib.rs} | 3 ++- artiq/firmware/libbsp/lib.rs | 4 ---- artiq/firmware/libksupport/Cargo.toml | 2 +- artiq/firmware/libksupport/ad9154.rs | 2 +- artiq/firmware/libksupport/i2c.rs | 20 +++++++++---------- artiq/firmware/libksupport/lib.rs | 2 +- artiq/firmware/libksupport/rtio.rs | 2 +- artiq/firmware/runtime/Cargo.toml | 2 +- artiq/firmware/runtime/analyzer.rs | 2 +- artiq/firmware/runtime/clock.rs | 2 +- artiq/firmware/runtime/kernel.rs | 2 +- artiq/firmware/runtime/lib.rs | 6 +++--- artiq/firmware/runtime/mailbox.rs | 2 +- artiq/firmware/runtime/moninj.rs | 2 +- artiq/firmware/runtime/rpc_queue.rs | 2 +- artiq/firmware/runtime/rtio_mgt.rs | 6 +++--- artiq/firmware/runtime/session.rs | 2 +- 19 files changed, 35 insertions(+), 38 deletions(-) rename artiq/firmware/{libbsp => libboard}/Cargo.toml (70%) rename artiq/firmware/{libbsp/board.rs => libboard/lib.rs} (99%) delete mode 100644 artiq/firmware/libbsp/lib.rs diff --git a/artiq/firmware/Cargo.lock b/artiq/firmware/Cargo.lock index dba7c50be..61af3ba1e 100644 --- a/artiq/firmware/Cargo.lock +++ b/artiq/firmware/Cargo.lock @@ -11,7 +11,7 @@ name = "alloc_none" version = "0.0.0" [[package]] -name = "bsp" +name = "board" version = "0.0.0" [[package]] @@ -41,7 +41,7 @@ name = "ksupport" version = "0.0.0" dependencies = [ "alloc_none 0.0.0", - "bsp 0.0.0", + "board 0.0.0", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "std_artiq 0.0.0", ] @@ -78,7 +78,7 @@ name = "runtime" version = "0.0.0" dependencies = [ "alloc_artiq 0.0.0", - "bsp 0.0.0", + "board 0.0.0", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "fringe 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/artiq/firmware/libbsp/Cargo.toml b/artiq/firmware/libboard/Cargo.toml similarity index 70% rename from artiq/firmware/libbsp/Cargo.toml rename to artiq/firmware/libboard/Cargo.toml index 03adef376..c006dca4a 100644 --- a/artiq/firmware/libbsp/Cargo.toml +++ b/artiq/firmware/libboard/Cargo.toml @@ -1,8 +1,8 @@ [package] authors = ["M-Labs"] -name = "bsp" +name = "board" version = "0.0.0" [lib] -name = "bsp" +name = "board" path = "lib.rs" diff --git a/artiq/firmware/libbsp/board.rs b/artiq/firmware/libboard/lib.rs similarity index 99% rename from artiq/firmware/libbsp/board.rs rename to artiq/firmware/libboard/lib.rs index c73ffd0f5..63397e7b2 100644 --- a/artiq/firmware/libbsp/board.rs +++ b/artiq/firmware/libboard/lib.rs @@ -1,4 +1,5 @@ -#![allow(dead_code)] +#![feature(asm)] +#![no_std] use core::{cmp, ptr, str}; diff --git a/artiq/firmware/libbsp/lib.rs b/artiq/firmware/libbsp/lib.rs deleted file mode 100644 index b75091413..000000000 --- a/artiq/firmware/libbsp/lib.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![feature(asm)] -#![no_std] - -pub mod board; diff --git a/artiq/firmware/libksupport/Cargo.toml b/artiq/firmware/libksupport/Cargo.toml index 581dee017..d009c2267 100644 --- a/artiq/firmware/libksupport/Cargo.toml +++ b/artiq/firmware/libksupport/Cargo.toml @@ -11,5 +11,5 @@ crate-type = ["staticlib"] [dependencies] alloc_none = { path = "../liballoc_none" } std_artiq = { path = "../libstd_artiq" } -bsp = { path = "../libbsp" } +board = { path = "../libboard" } byteorder = { version = "0.5", default-features = false } diff --git a/artiq/firmware/libksupport/ad9154.rs b/artiq/firmware/libksupport/ad9154.rs index 3f9867862..ab7026258 100644 --- a/artiq/firmware/libksupport/ad9154.rs +++ b/artiq/firmware/libksupport/ad9154.rs @@ -1,4 +1,4 @@ -use bsp::board::csr; +use board::csr; pub extern fn init() { unsafe { diff --git a/artiq/firmware/libksupport/i2c.rs b/artiq/firmware/libksupport/i2c.rs index 0bbf753ad..96dedcabe 100644 --- a/artiq/firmware/libksupport/i2c.rs +++ b/artiq/firmware/libksupport/i2c.rs @@ -1,4 +1,4 @@ -use bsp::board::csr; +use board::csr; fn half_period() { unsafe { @@ -16,7 +16,7 @@ fn half_period() { #[cfg(has_i2c)] mod imp { - use bsp::board::csr; + use board::csr; fn sda_bit(busno: u32) -> u32 { 1 << (2 * busno + 1) } fn scl_bit(busno: u32) -> u32 { 1 << (2 * busno) } @@ -64,14 +64,14 @@ mod imp { } } -// #[cfg(not(has_i2c))] -// mod imp { -// pub fn sda_i(busno: u32) -> bool { true } -// pub fn sda_oe(busno: u32, oe: bool) {} -// pub fn sda_o(busno: u32, o: bool) {} -// pub fn scl_oe(busno: u32, oe: bool) {} -// pub fn scl_o(busno: u32, o: bool) {} -// } +#[cfg(not(has_i2c))] +mod imp { + pub fn sda_i(busno: u32) -> bool { true } + pub fn sda_oe(busno: u32, oe: bool) {} + pub fn sda_o(busno: u32, o: bool) {} + pub fn scl_oe(busno: u32, oe: bool) {} + pub fn scl_o(busno: u32, o: bool) {} +} use self::imp::*; diff --git a/artiq/firmware/libksupport/lib.rs b/artiq/firmware/libksupport/lib.rs index 93306e565..76c8c420d 100644 --- a/artiq/firmware/libksupport/lib.rs +++ b/artiq/firmware/libksupport/lib.rs @@ -8,7 +8,7 @@ extern crate alloc_none; extern crate std_artiq as std; extern crate libc; extern crate byteorder; -extern crate bsp; +extern crate board; #[path = "../runtime/mailbox.rs"] mod mailbox; diff --git a/artiq/firmware/libksupport/rtio.rs b/artiq/firmware/libksupport/rtio.rs index fbe9c015a..b7e8cafd0 100644 --- a/artiq/firmware/libksupport/rtio.rs +++ b/artiq/firmware/libksupport/rtio.rs @@ -1,7 +1,7 @@ #[path = "../runtime/kernel_proto.rs"] mod kernel_proto; -use bsp::board::csr; +use board::csr; use core::ptr::{read_volatile, write_volatile}; use ::ArtiqList; use ::send; diff --git a/artiq/firmware/runtime/Cargo.toml b/artiq/firmware/runtime/Cargo.toml index 1fe70abe9..bffe58cc6 100644 --- a/artiq/firmware/runtime/Cargo.toml +++ b/artiq/firmware/runtime/Cargo.toml @@ -16,7 +16,7 @@ path = "lib.rs" alloc_artiq = { path = "../liballoc_artiq" } std_artiq = { path = "../libstd_artiq", features = ["alloc"] } lwip = { path = "../liblwip", default-features = false } -bsp = { path = "../libbsp" } +board = { path = "../libboard" } fringe = { version = "= 1.1.0", default-features = false, features = ["alloc"] } log = { version = "0.3", default-features = false } log_buffer = { version = "1.0" } diff --git a/artiq/firmware/runtime/analyzer.rs b/artiq/firmware/runtime/analyzer.rs index 22297c4d3..ea126512e 100644 --- a/artiq/firmware/runtime/analyzer.rs +++ b/artiq/firmware/runtime/analyzer.rs @@ -1,5 +1,5 @@ use std::io::{self, Write}; -use bsp::board::{self, csr}; +use board::{self, csr}; use sched::{Waiter, Spawner}; use sched::{TcpListener, TcpStream, SocketAddr, IP_ANY}; use analyzer_proto::*; diff --git a/artiq/firmware/runtime/clock.rs b/artiq/firmware/runtime/clock.rs index 4d90e266f..19bfa6c9c 100644 --- a/artiq/firmware/runtime/clock.rs +++ b/artiq/firmware/runtime/clock.rs @@ -1,4 +1,4 @@ -use bsp::board::csr; +use board::csr; const INIT: u64 = ::core::i64::MAX as u64; const FREQ: u64 = csr::CONFIG_CLOCK_FREQUENCY as u64; diff --git a/artiq/firmware/runtime/kernel.rs b/artiq/firmware/runtime/kernel.rs index 4ffb322b0..5096badc1 100644 --- a/artiq/firmware/runtime/kernel.rs +++ b/artiq/firmware/runtime/kernel.rs @@ -1,5 +1,5 @@ use core::ptr; -use bsp::board::csr; +use board::csr; use mailbox; use rpc_queue; diff --git a/artiq/firmware/runtime/lib.rs b/artiq/firmware/runtime/lib.rs index 38be35401..0fb41da5a 100644 --- a/artiq/firmware/runtime/lib.rs +++ b/artiq/firmware/runtime/lib.rs @@ -11,7 +11,7 @@ extern crate log_buffer; extern crate byteorder; extern crate fringe; extern crate lwip; -extern crate bsp; +extern crate board; use core::fmt::Write; use logger::BufferLogger; @@ -105,7 +105,7 @@ pub unsafe extern fn rust_main() { clock::init(); info!("booting ARTIQ"); info!("software version {}", GIT_COMMIT); - info!("gateware version {}", bsp::board::ident(&mut [0; 64])); + info!("gateware version {}", board::ident(&mut [0; 64])); let t = clock::get_ms(); info!("press 'e' to erase startup and idle kernels..."); @@ -138,7 +138,7 @@ pub unsafe extern fn rust_main() { #[no_mangle] pub unsafe extern fn isr() { - use bsp::board::{irq, csr}; + use board::{irq, csr}; extern { fn uart_isr(); } let irqs = irq::pending() & irq::get_mask(); diff --git a/artiq/firmware/runtime/mailbox.rs b/artiq/firmware/runtime/mailbox.rs index bbf5f302b..b573734ed 100644 --- a/artiq/firmware/runtime/mailbox.rs +++ b/artiq/firmware/runtime/mailbox.rs @@ -1,5 +1,5 @@ use core::ptr::{read_volatile, write_volatile}; -use bsp::board; +use board; const MAILBOX: *mut usize = board::mem::MAILBOX_BASE as *mut usize; static mut LAST: usize = 0; diff --git a/artiq/firmware/runtime/moninj.rs b/artiq/firmware/runtime/moninj.rs index 88f6f370f..4db0aca0f 100644 --- a/artiq/firmware/runtime/moninj.rs +++ b/artiq/firmware/runtime/moninj.rs @@ -1,6 +1,6 @@ use std::vec::Vec; use std::io; -use bsp::board::csr; +use board::csr; use sched::{Waiter, Spawner}; use sched::{UdpSocket, SocketAddr, IP_ANY}; use moninj_proto::*; diff --git a/artiq/firmware/runtime/rpc_queue.rs b/artiq/firmware/runtime/rpc_queue.rs index 7bac85146..3155813eb 100644 --- a/artiq/firmware/runtime/rpc_queue.rs +++ b/artiq/firmware/runtime/rpc_queue.rs @@ -2,7 +2,7 @@ use core::ptr::{read_volatile, write_volatile}; use core::slice; -use bsp::board; +use board; const SEND_MAILBOX: *mut usize = (board::mem::MAILBOX_BASE + 4) as *mut usize; const RECV_MAILBOX: *mut usize = (board::mem::MAILBOX_BASE + 8) as *mut usize; diff --git a/artiq/firmware/runtime/rtio_mgt.rs b/artiq/firmware/runtime/rtio_mgt.rs index fc94b7992..216706f0a 100644 --- a/artiq/firmware/runtime/rtio_mgt.rs +++ b/artiq/firmware/runtime/rtio_mgt.rs @@ -1,11 +1,11 @@ use config; -use bsp::board::csr; +use board::csr; use sched::Scheduler; #[cfg(has_rtio_crg)] pub mod crg { use clock; - use bsp::board::csr; + use board::csr; pub fn init() { unsafe { csr::rtio_crg::pll_reset_write(0) } @@ -39,7 +39,7 @@ pub mod crg { #[cfg(has_drtio)] mod drtio { - use bsp::board::csr; + use board::csr; use sched::{Scheduler, Waiter, Spawner}; pub fn startup(scheduler: &Scheduler) { diff --git a/artiq/firmware/runtime/session.rs b/artiq/firmware/runtime/session.rs index 08dea473c..e4458398a 100644 --- a/artiq/firmware/runtime/session.rs +++ b/artiq/firmware/runtime/session.rs @@ -10,7 +10,7 @@ use urc::Urc; use sched::{ThreadHandle, Waiter, Spawner}; use sched::{TcpListener, TcpStream, SocketAddr, IP_ANY}; use byteorder::{ByteOrder, NetworkEndian}; -use bsp::board; +use board; use rpc_proto as rpc; use session_proto as host;