forked from M-Labs/artiq
1
0
Fork 0

firmware: make libbsp a crate

This commit is contained in:
Sebastien Bourdeauducq 2016-12-16 21:28:25 +08:00
parent c99388f80f
commit 9a564e07c0
18 changed files with 43 additions and 20 deletions

View File

@ -0,0 +1,8 @@
[package]
authors = ["M-Labs"]
name = "bsp"
version = "0.0.0"
[lib]
name = "bsp"
path = "lib.rs"

View File

@ -0,0 +1,4 @@
#![feature(asm)]
#![no_std]
pub mod board;

View File

@ -2,6 +2,7 @@
name = "ksupport"
version = "0.0.0"
dependencies = [
"bsp 0.0.0",
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"std_artiq 0.0.0",
]
@ -10,6 +11,10 @@ dependencies = [
name = "alloc_artiq"
version = "0.0.0"
[[package]]
name = "bsp"
version = "0.0.0"
[[package]]
name = "byteorder"
version = "0.5.3"

View File

@ -10,6 +10,7 @@ crate-type = ["staticlib"]
[dependencies]
std_artiq = { path = "../libstd_artiq" }
bsp = { path = "../libbsp" }
byteorder = { version = "0.5", default-features = false }
[profile.dev]

View File

@ -1,4 +1,4 @@
use board::csr;
use bsp::board::csr;
fn half_period() {
unsafe {
@ -16,7 +16,7 @@ fn half_period() {
#[cfg(has_i2c)]
mod imp {
use board::csr;
use bsp::board::csr;
fn sda_bit(busno: u32) -> u32 { 1 << (2 * busno + 1) }
fn scl_bit(busno: u32) -> u32 { 1 << (2 * busno) }

View File

@ -7,9 +7,8 @@
extern crate std_artiq as std;
extern crate libc;
extern crate byteorder;
extern crate bsp;
#[path = "../libbsp/board.rs"]
mod board;
#[path = "../runtime/mailbox.rs"]
mod mailbox;

View File

@ -1,7 +1,7 @@
#[path = "../runtime/kernel_proto.rs"]
mod kernel_proto;
use board::csr;
use bsp::board::csr;
use core::ptr::{read_volatile, write_volatile};
use ::ArtiqList;
use ::send;

View File

@ -2,6 +2,7 @@
name = "runtime"
version = "0.0.0"
dependencies = [
"bsp 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)",
@ -15,6 +16,10 @@ dependencies = [
name = "alloc_artiq"
version = "0.0.0"
[[package]]
name = "bsp"
version = "0.0.0"
[[package]]
name = "byteorder"
version = "0.5.3"

View File

@ -15,6 +15,7 @@ path = "lib.rs"
[dependencies]
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
lwip = { path = "../liblwip", default-features = false }
bsp = { path = "../libbsp" }
fringe = { version = "= 1.1.0", default-features = false, features = ["alloc"] }
log = { version = "0.3", default-features = false, features = ["max_level_debug"] }
log_buffer = { version = "1.0" }

View File

@ -1,5 +1,5 @@
use std::io::{self, Write};
use board::{self, csr};
use bsp::board::{self, csr};
use sched::{Waiter, Spawner};
use sched::{TcpListener, TcpStream, SocketAddr, IP_ANY};
use analyzer_proto::*;

View File

@ -1,7 +1,7 @@
use board::csr;
use bsp::board::csr;
const INIT: u64 = ::core::i64::MAX as u64;
const FREQ: u64 = ::board::csr::CONFIG_CLOCK_FREQUENCY as u64;
const FREQ: u64 = csr::CONFIG_CLOCK_FREQUENCY as u64;
pub fn init() {
unsafe {

View File

@ -1,5 +1,5 @@
use core::ptr;
use board::csr;
use bsp::board::csr;
use mailbox;
use rpc_queue;

View File

@ -11,6 +11,7 @@ extern crate log_buffer;
extern crate byteorder;
extern crate fringe;
extern crate lwip;
extern crate bsp;
use core::fmt::Write;
use logger::BufferLogger;
@ -55,8 +56,6 @@ extern fn panic_fmt(args: self::core::fmt::Arguments, file: &'static str, line:
}
}
#[path = "../libbsp/board.rs"]
mod board;
mod config;
mod clock;
mod rtio_mgt;
@ -105,7 +104,7 @@ pub unsafe extern fn rust_main() {
clock::init();
info!("booting ARTIQ");
info!("software version {}", GIT_COMMIT);
info!("gateware version {}", ::board::ident(&mut [0; 64]));
info!("gateware version {}", bsp::board::ident(&mut [0; 64]));
let t = clock::get_ms();
info!("press 'e' to erase startup and idle kernels...");
@ -138,7 +137,7 @@ pub unsafe extern fn rust_main() {
#[no_mangle]
pub unsafe extern fn isr() {
use board::{irq, csr};
use bsp::board::{irq, csr};
extern { fn uart_isr(); }
let irqs = irq::pending() & irq::get_mask();

View File

@ -1,5 +1,5 @@
use core::ptr::{read_volatile, write_volatile};
use board;
use bsp::board;
const MAILBOX: *mut usize = board::mem::MAILBOX_BASE as *mut usize;
static mut last: usize = 0;

View File

@ -1,6 +1,6 @@
use std::vec::Vec;
use std::io;
use board::csr;
use bsp::board::csr;
use sched::{Waiter, Spawner};
use sched::{UdpSocket, SocketAddr, IP_ANY};
use moninj_proto::*;

View File

@ -2,7 +2,7 @@
use core::ptr::{read_volatile, write_volatile};
use core::slice;
use board;
use bsp::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;

View File

@ -1,11 +1,11 @@
use config;
use board::csr;
use bsp::board::csr;
use sched::Scheduler;
#[cfg(has_rtio_crg)]
pub mod crg {
use clock;
use board::csr;
use bsp::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 board::csr;
use bsp::board::csr;
use sched::{Scheduler, Waiter, Spawner};
pub fn startup(scheduler: &Scheduler) {

View File

@ -10,6 +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 rpc_proto as rpc;
use session_proto as host;
@ -201,7 +202,7 @@ fn process_host_message(waiter: Waiter,
session: &mut Session) -> io::Result<()> {
match try!(host_read(stream)) {
host::Request::Ident =>
host_write(stream, host::Reply::Ident(::board::ident(&mut [0; 64]))),
host_write(stream, host::Reply::Ident(board::ident(&mut [0; 64]))),
// artiq_corelog
host::Request::Log => {