mirror of https://github.com/m-labs/artiq.git
firmware: do not link to C code in runtime and satman.
This commit is contained in:
parent
fd8b11532f
commit
cde2054926
|
@ -309,7 +309,7 @@ pub unsafe fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn exception_handler(vect: u32, _regs: *const u32, pc: u32, ea: u32) {
|
pub extern fn exception_handler(vect: u32, _regs: *const u32, pc: u32, ea: u32) {
|
||||||
println!("exception {:?} at PC 0x{:x}, EA 0x{:x}", vect, pc, ea);
|
println!("exception {:?} at PC 0x{:x}, EA 0x{:x}", vect, pc, ea);
|
||||||
send(&RunAborted)
|
send(&RunAborted)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
use csr;
|
||||||
|
|
||||||
pub struct Console;
|
pub struct Console;
|
||||||
|
|
||||||
impl fmt::Write for Console {
|
impl fmt::Write for Console {
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
|
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
|
||||||
extern { fn putchar(c: i32) -> i32; }
|
for c in s.bytes() {
|
||||||
for c in s.bytes() { unsafe { putchar(c as i32); } }
|
unsafe {
|
||||||
|
while csr::uart::txfull_read() != 0 {}
|
||||||
|
csr::uart::rxtx_write(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ path = "lib.rs"
|
||||||
build_artiq = { path = "../libbuild_artiq" }
|
build_artiq = { path = "../libbuild_artiq" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-builtins" }
|
|
||||||
alloc_artiq = { path = "../liballoc_artiq" }
|
alloc_artiq = { path = "../liballoc_artiq" }
|
||||||
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
|
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
|
||||||
logger_artiq = { path = "../liblogger_artiq" }
|
logger_artiq = { path = "../liblogger_artiq" }
|
||||||
|
@ -23,6 +22,10 @@ board = { path = "../libboard", features = ["uart_console"] }
|
||||||
fringe = { version = "= 1.1.0", default-features = false, features = ["alloc"] }
|
fringe = { version = "= 1.1.0", default-features = false, features = ["alloc"] }
|
||||||
byteorder = { version = "1.0", default-features = false }
|
byteorder = { version = "1.0", default-features = false }
|
||||||
|
|
||||||
|
[dependencies.compiler_builtins]
|
||||||
|
git = "https://github.com/rust-lang-nursery/compiler-builtins"
|
||||||
|
features = ["mem"]
|
||||||
|
|
||||||
[dependencies.smoltcp]
|
[dependencies.smoltcp]
|
||||||
git = "https://github.com/m-labs/smoltcp"
|
git = "https://github.com/m-labs/smoltcp"
|
||||||
rev = "e8ece3e"
|
rev = "e8ece3e"
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![feature(compiler_builtins_lib, libc, repr_simd, const_fn)]
|
#![feature(compiler_builtins_lib, repr_simd, const_fn)]
|
||||||
|
|
||||||
extern crate compiler_builtins;
|
extern crate compiler_builtins;
|
||||||
extern crate alloc_artiq;
|
extern crate alloc_artiq;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate std_artiq as std;
|
extern crate std_artiq as std;
|
||||||
extern crate libc;
|
|
||||||
extern crate cslice;
|
extern crate cslice;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
@ -19,11 +18,6 @@ extern crate board;
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
use smoltcp::wire::{EthernetAddress, IpAddress};
|
use smoltcp::wire::{EthernetAddress, IpAddress};
|
||||||
|
|
||||||
extern {
|
|
||||||
fn readchar() -> libc::c_char;
|
|
||||||
fn readchar_nonblock() -> libc::c_int;
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! borrow_mut {
|
macro_rules! borrow_mut {
|
||||||
($x:expr) => ({
|
($x:expr) => ({
|
||||||
match $x.try_borrow_mut() {
|
match $x.try_borrow_mut() {
|
||||||
|
@ -68,7 +62,7 @@ fn startup() {
|
||||||
let t = board::clock::get_ms();
|
let t = board::clock::get_ms();
|
||||||
info!("press 'e' to erase startup and idle kernels...");
|
info!("press 'e' to erase startup and idle kernels...");
|
||||||
while board::clock::get_ms() < t + 1000 {
|
while board::clock::get_ms() < t + 1000 {
|
||||||
if unsafe { readchar_nonblock() != 0 && readchar() == b'e' as libc::c_char } {
|
if unsafe { board::csr::uart::rxtx_read() == b'e' } {
|
||||||
config::remove("startup_kernel").unwrap();
|
config::remove("startup_kernel").unwrap();
|
||||||
config::remove("idle_kernel").unwrap();
|
config::remove("idle_kernel").unwrap();
|
||||||
info!("startup and idle kernels erased");
|
info!("startup and idle kernels erased");
|
||||||
|
@ -143,21 +137,13 @@ fn startup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use board::{irq, csr};
|
#[no_mangle]
|
||||||
|
pub extern fn main() -> i32 {
|
||||||
|
unsafe {
|
||||||
extern {
|
extern {
|
||||||
fn uart_init();
|
|
||||||
fn uart_isr();
|
|
||||||
|
|
||||||
static mut _fheap: u8;
|
static mut _fheap: u8;
|
||||||
static mut _eheap: u8;
|
static mut _eheap: u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe extern fn main() -> i32 {
|
|
||||||
irq::set_mask(0);
|
|
||||||
irq::set_ie(true);
|
|
||||||
uart_init();
|
|
||||||
|
|
||||||
alloc_artiq::seed(&mut _fheap as *mut u8,
|
alloc_artiq::seed(&mut _fheap as *mut u8,
|
||||||
&_eheap as *const u8 as usize - &_fheap as *const u8 as usize);
|
&_eheap as *const u8 as usize - &_fheap as *const u8 as usize);
|
||||||
|
|
||||||
|
@ -165,19 +151,22 @@ pub unsafe extern fn main() -> i32 {
|
||||||
logger_artiq::BufferLogger::new(&mut LOG_BUFFER[..]).register(startup);
|
logger_artiq::BufferLogger::new(&mut LOG_BUFFER[..]).register(startup);
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern fn isr() {
|
pub extern fn exception_handler(vect: u32, _regs: *const u32, pc: u32, ea: u32) {
|
||||||
let irqs = irq::pending() & irq::get_mask();
|
panic!("exception {:?} at PC 0x{:x}, EA 0x{:x}", vect, pc, ea)
|
||||||
if irqs & (1 << csr::UART_INTERRUPT) != 0 {
|
|
||||||
uart_isr()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern fn abort() {
|
||||||
|
panic!("aborted")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow linking with crates that are built as -Cpanic=unwind even if we use -Cpanic=abort.
|
// Allow linking with crates that are built as -Cpanic=unwind even if we use -Cpanic=abort.
|
||||||
// This is never called.
|
// This is never called.
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn _Unwind_Resume() -> ! {
|
pub extern fn _Unwind_Resume() -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ use std::{mem, str};
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::btree_set::BTreeSet;
|
|
||||||
use {config, rtio_mgt, mailbox, rpc_queue, kernel};
|
use {config, rtio_mgt, mailbox, rpc_queue, kernel};
|
||||||
use logger_artiq::BufferLogger;
|
use logger_artiq::BufferLogger;
|
||||||
use cache::Cache;
|
use cache::Cache;
|
||||||
|
|
|
@ -13,9 +13,12 @@ path = "lib.rs"
|
||||||
build_artiq = { path = "../libbuild_artiq" }
|
build_artiq = { path = "../libbuild_artiq" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-builtins" }
|
|
||||||
alloc_artiq = { path = "../liballoc_artiq" }
|
alloc_artiq = { path = "../liballoc_artiq" }
|
||||||
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
|
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
|
||||||
logger_artiq = { path = "../liblogger_artiq" }
|
logger_artiq = { path = "../liblogger_artiq" }
|
||||||
board = { path = "../libboard", features = ["uart_console"] }
|
board = { path = "../libboard", features = ["uart_console"] }
|
||||||
log = { version = "0.3", default-features = false }
|
log = { version = "0.3", default-features = false }
|
||||||
|
|
||||||
|
[dependencies.compiler_builtins]
|
||||||
|
git = "https://github.com/rust-lang-nursery/compiler-builtins"
|
||||||
|
features = ["mem"]
|
||||||
|
|
|
@ -23,11 +23,7 @@ $(RUSTOUT)/libsatman.a:
|
||||||
--manifest-path $(realpath $(SATMAN_DIRECTORY))/Cargo.toml
|
--manifest-path $(realpath $(SATMAN_DIRECTORY))/Cargo.toml
|
||||||
|
|
||||||
satman.elf: $(RUSTOUT)/libsatman.a
|
satman.elf: $(RUSTOUT)/libsatman.a
|
||||||
$(LD) $(LDFLAGS) \
|
$(LD) $(LDFLAGS) -T $(SATMAN_DIRECTORY)/satman.ld -o $@ $^
|
||||||
-T $(SATMAN_DIRECTORY)/satman.ld \
|
|
||||||
-o $@ \
|
|
||||||
$^ \
|
|
||||||
-lbase-nofloat
|
|
||||||
@chmod -x $@
|
@chmod -x $@
|
||||||
|
|
||||||
%.bin: %.elf
|
%.bin: %.elf
|
||||||
|
|
|
@ -41,26 +41,19 @@ fn startup() {
|
||||||
#[cfg(has_ad9516)]
|
#[cfg(has_ad9516)]
|
||||||
board::ad9516::init().expect("cannot initialize ad9516");
|
board::ad9516::init().expect("cannot initialize ad9516");
|
||||||
board::i2c::init();
|
board::i2c::init();
|
||||||
board::si5324::setup_hitless_clock_switching(&SI5324_SETTINGS).expect("cannot initialize si5324");
|
board::si5324::setup_hitless_clock_switching(&SI5324_SETTINGS)
|
||||||
|
.expect("cannot initialize si5324");
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
use board::{irq, csr};
|
#[no_mangle]
|
||||||
|
pub extern fn main() -> i32 {
|
||||||
|
unsafe {
|
||||||
extern {
|
extern {
|
||||||
fn uart_init();
|
|
||||||
fn uart_isr();
|
|
||||||
|
|
||||||
static mut _fheap: u8;
|
static mut _fheap: u8;
|
||||||
static mut _eheap: u8;
|
static mut _eheap: u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe extern fn main() -> i32 {
|
|
||||||
irq::set_mask(0);
|
|
||||||
irq::set_ie(true);
|
|
||||||
uart_init();
|
|
||||||
|
|
||||||
alloc_artiq::seed(&mut _fheap as *mut u8,
|
alloc_artiq::seed(&mut _fheap as *mut u8,
|
||||||
&_eheap as *const u8 as usize - &_fheap as *const u8 as usize);
|
&_eheap as *const u8 as usize - &_fheap as *const u8 as usize);
|
||||||
|
|
||||||
|
@ -68,13 +61,16 @@ pub unsafe extern fn main() -> i32 {
|
||||||
logger_artiq::BufferLogger::new(&mut LOG_BUFFER[..]).register(startup);
|
logger_artiq::BufferLogger::new(&mut LOG_BUFFER[..]).register(startup);
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern fn isr() {
|
pub extern fn exception_handler(vect: u32, _regs: *const u32, pc: u32, ea: u32) {
|
||||||
let irqs = irq::pending() & irq::get_mask();
|
panic!("exception {:?} at PC 0x{:x}, EA 0x{:x}", vect, pc, ea)
|
||||||
if irqs & (1 << csr::UART_INTERRUPT) != 0 {
|
|
||||||
uart_isr()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern fn abort() {
|
||||||
|
panic!("aborted")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow linking with crates that are built as -Cpanic=unwind even if we use -Cpanic=abort.
|
// Allow linking with crates that are built as -Cpanic=unwind even if we use -Cpanic=abort.
|
||||||
|
|
|
@ -45,11 +45,7 @@ $(RUSTOUT)/libruntime.a:
|
||||||
--manifest-path $(realpath $(RUNTIME_DIRECTORY)/../firmware/runtime/Cargo.toml)
|
--manifest-path $(realpath $(RUNTIME_DIRECTORY)/../firmware/runtime/Cargo.toml)
|
||||||
|
|
||||||
runtime.elf: $(RUSTOUT)/libruntime.a ksupport_data.o
|
runtime.elf: $(RUSTOUT)/libruntime.a ksupport_data.o
|
||||||
$(LD) $(LDFLAGS) \
|
$(LD) $(LDFLAGS) -T $(RUNTIME_DIRECTORY)/runtime.ld -o $@ $^
|
||||||
-T $(RUNTIME_DIRECTORY)/runtime.ld \
|
|
||||||
-o $@ \
|
|
||||||
$^ \
|
|
||||||
-lbase-nofloat
|
|
||||||
@chmod -x $@
|
@chmod -x $@
|
||||||
|
|
||||||
.PHONY: $(RUSTOUT_KSUPPORT)/libksupport.a
|
.PHONY: $(RUSTOUT_KSUPPORT)/libksupport.a
|
||||||
|
|
Loading…
Reference in New Issue