forked from M-Labs/artiq
1
0
Fork 0

firmware: update Rust from 1.18.0 to 1.20.0.

This commit is contained in:
whitequark 2017-09-24 17:49:34 +00:00
parent 57b12abf1e
commit 7799413a41
19 changed files with 228 additions and 259 deletions

View File

@ -3,11 +3,11 @@ name = "std_artiq"
version = "0.0.0" version = "0.0.0"
[[package]] [[package]]
name = "alloc_artiq" name = "alloc_list"
version = "0.0.0" version = "0.0.0"
[[package]] [[package]]
name = "alloc_none" name = "alloc_stub"
version = "0.0.0" version = "0.0.0"
[[package]] [[package]]
@ -67,7 +67,7 @@ version = "0.0.0"
[[package]] [[package]]
name = "fringe" name = "fringe"
version = "1.1.0" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/m-labs/libfringe?rev=bd23494#bd2349467157969324ca7da5d2ae033c7ffac0c0"
dependencies = [ dependencies = [
"libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -90,7 +90,7 @@ dependencies = [
name = "ksupport" name = "ksupport"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"alloc_none 0.0.0", "alloc_stub 0.0.0",
"amp 0.0.0", "amp 0.0.0",
"board 0.0.0", "board 0.0.0",
"build_artiq 0.0.0", "build_artiq 0.0.0",
@ -127,7 +127,7 @@ dependencies = [
[[package]] [[package]]
name = "managed" name = "managed"
version = "0.3.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -145,7 +145,7 @@ dependencies = [
name = "runtime" name = "runtime"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"alloc_artiq 0.0.0", "alloc_list 0.0.0",
"amp 0.0.0", "amp 0.0.0",
"board 0.0.0", "board 0.0.0",
"build_artiq 0.0.0", "build_artiq 0.0.0",
@ -153,11 +153,11 @@ dependencies = [
"compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins?rev=631b568)", "compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins?rev=631b568)",
"cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"drtioaux 0.0.0", "drtioaux 0.0.0",
"fringe 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "fringe 1.1.0 (git+https://github.com/m-labs/libfringe?rev=bd23494)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"logger_artiq 0.0.0", "logger_artiq 0.0.0",
"proto 0.0.0", "proto 0.0.0",
"smoltcp 0.4.0-pre (git+https://github.com/m-labs/smoltcp?rev=546b367)", "smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp?rev=bf4ddef)",
"std_artiq 0.0.0", "std_artiq 0.0.0",
] ]
@ -170,7 +170,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "satman" name = "satman"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"alloc_artiq 0.0.0", "alloc_list 0.0.0",
"board 0.0.0", "board 0.0.0",
"build_artiq 0.0.0", "build_artiq 0.0.0",
"compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins?rev=631b568)", "compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins?rev=631b568)",
@ -182,12 +182,12 @@ dependencies = [
[[package]] [[package]]
name = "smoltcp" name = "smoltcp"
version = "0.4.0-pre" version = "0.4.0"
source = "git+https://github.com/m-labs/smoltcp?rev=546b367#546b3670eff4867891ab0288264d47ea72ab0dd8" source = "git+https://github.com/m-labs/smoltcp?rev=bf4ddef#bf4ddef87dae0e671dc8041b7fffd03376518e1e"
dependencies = [ dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"managed 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "managed 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -213,15 +213,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8" "checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8"
"checksum compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins?rev=631b568)" = "<none>" "checksum compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins?rev=631b568)" = "<none>"
"checksum cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0f8cb7306107e4b10e64994de6d3274bd08996a7c1322a27b86482392f96be0a" "checksum cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0f8cb7306107e4b10e64994de6d3274bd08996a7c1322a27b86482392f96be0a"
"checksum fringe 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "987689dcfad85eee8d76b477865641ec483e63fb86d52966bfc350c4a647d78a" "checksum fringe 1.1.0 (git+https://github.com/m-labs/libfringe?rev=bd23494)" = "<none>"
"checksum gcc 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)" = "291055c78f59ca3d84c99026c9501c469413d386bb46be1e1cf1d285cd1db3b0" "checksum gcc 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)" = "291055c78f59ca3d84c99026c9501c469413d386bb46be1e1cf1d285cd1db3b0"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a51822fc847e7a8101514d1d44e354ba2ffa7d4c194dcab48870740e327cac70" "checksum libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a51822fc847e7a8101514d1d44e354ba2ffa7d4c194dcab48870740e327cac70"
"checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054"
"checksum log_buffer 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec57723b84bbe7bdf76aa93169c9b59e67473317c6de3a83cb2a0f8ccb2aa493" "checksum log_buffer 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec57723b84bbe7bdf76aa93169c9b59e67473317c6de3a83cb2a0f8ccb2aa493"
"checksum managed 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61eb783b4fa77e8fa4d27ec400f97ed9168546b8b30341a120b7ba9cc6571aaf" "checksum managed 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5d48e8c30a4363e2981fe4db20527f6ab0f32a243bbc75379dea5a64f60dae4"
"checksum rustc-cfg 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "56a596b5718bf5e059d59a30af12f7f462a152de147aa462b70892849ee18704" "checksum rustc-cfg 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "56a596b5718bf5e059d59a30af12f7f462a152de147aa462b70892849ee18704"
"checksum smoltcp 0.4.0-pre (git+https://github.com/m-labs/smoltcp?rev=546b367)" = "<none>" "checksum smoltcp 0.4.0 (git+https://github.com/m-labs/smoltcp?rev=bf4ddef)" = "<none>"
"checksum walkdir 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd7c16466ecc507c7cb5988db03e6eab4aaeab89a5c37a29251fcfd3ac9b7afe" "checksum walkdir 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd7c16466ecc507c7cb5988db03e6eab4aaeab89a5c37a29251fcfd3ac9b7afe"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"

View File

@ -15,7 +15,7 @@ build_artiq = { path = "../libbuild_artiq" }
[dependencies] [dependencies]
byteorder = { version = "1.0", default-features = false } byteorder = { version = "1.0", default-features = false }
cslice = { version = "0.3" } cslice = { version = "0.3" }
alloc_none = { path = "../liballoc_none" } alloc_stub = { path = "../liballoc_stub" }
std_artiq = { path = "../libstd_artiq" } std_artiq = { path = "../libstd_artiq" }
dyld = { path = "../libdyld" } dyld = { path = "../libdyld" }
board = { path = "../libboard" } board = { path = "../libboard" }

View File

@ -1,4 +1,4 @@
#![feature(lang_items, asm, libc, panic_unwind, unwind_attributes)] #![feature(lang_items, asm, libc, panic_unwind, unwind_attributes, global_allocator)]
#![no_std] #![no_std]
extern crate unwind; extern crate unwind;
@ -6,7 +6,7 @@ extern crate libc;
extern crate byteorder; extern crate byteorder;
extern crate cslice; extern crate cslice;
extern crate alloc_none; extern crate alloc_stub;
extern crate std_artiq as std; extern crate std_artiq as std;
extern crate board; extern crate board;
@ -17,12 +17,16 @@ extern crate amp;
use core::{mem, ptr, slice, str}; use core::{mem, ptr, slice, str};
use std::io::Cursor; use std::io::Cursor;
use cslice::{CSlice, AsCSlice}; use cslice::{CSlice, AsCSlice};
use alloc_stub::StubAlloc;
use board::csr; use board::csr;
use dyld::Library; use dyld::Library;
use proto::{kernel_proto, rpc_proto}; use proto::{kernel_proto, rpc_proto};
use proto::kernel_proto::*; use proto::kernel_proto::*;
use amp::{mailbox, rpc_queue}; use amp::{mailbox, rpc_queue};
#[global_allocator]
static mut ALLOC: StubAlloc = StubAlloc;
fn send(request: &Message) { fn send(request: &Message) {
unsafe { mailbox::send(request as *const _ as usize) } unsafe { mailbox::send(request as *const _ as usize) }
while !mailbox::acknowledged() {} while !mailbox::acknowledged() {}

View File

@ -1,158 +0,0 @@
#![feature(allocator)]
#![no_std]
#![allocator]
use core::{mem, ptr, cmp, fmt};
// The minimum alignment guaranteed by the architecture.
const MIN_ALIGN: usize = 4;
const MAGIC_FREE: usize = 0xDEADDEAD;
const MAGIC_BUSY: usize = 0xFEEDFEED;
#[derive(Debug)]
struct Header {
magic: usize,
size: usize,
next: *mut Header
}
static mut ROOT: *mut Header = 0 as *mut _;
pub unsafe fn seed(ptr: *mut u8, size: usize) {
let header_size = mem::size_of::<Header>();
if size < header_size * 2 { return }
let curr = ptr as *mut Header;
(*curr).magic = MAGIC_FREE;
(*curr).size = size - header_size;
(*curr).next = ROOT;
ROOT = curr;
}
#[no_mangle]
pub extern fn __rust_allocate(mut size: usize, align: usize) -> *mut u8 {
assert!(align <= MIN_ALIGN);
let header_size = mem::size_of::<Header>();
if size % header_size != 0 {
size += header_size - (size % header_size);
}
unsafe {
let mut curr = ROOT;
while !curr.is_null() {
match (*curr).magic {
MAGIC_BUSY => (),
MAGIC_FREE => {
let mut next = (*curr).next;
while !next.is_null() && (*next).magic == MAGIC_FREE {
// Join
(*next).magic = 0;
(*curr).size += (*next).size + header_size;
(*curr).next = (*next).next;
next = (*curr).next;
}
if (*curr).size > size + header_size * 2 {
// Split
let offset = header_size + size;
let next = (curr as *mut u8).offset(offset as isize) as *mut Header;
(*next).magic = MAGIC_FREE;
(*next).size = (*curr).size - offset;
(*next).next = (*curr).next;
(*curr).next = next;
(*curr).size = size;
}
if (*curr).size >= size {
(*curr).magic = MAGIC_BUSY;
return curr.offset(1) as *mut u8
}
},
_ => panic!("heap corruption detected at {:p}", curr)
}
curr = (*curr).next;
}
}
ptr::null_mut()
}
#[no_mangle]
pub extern fn __rust_allocate_zeroed(size: usize, align: usize) -> *mut u8 {
let ptr = __rust_allocate(size, align);
unsafe { ptr::write_bytes(ptr, 0, size); }
ptr
}
#[no_mangle]
pub extern fn __rust_deallocate(ptr: *mut u8, _old_size: usize, _align: usize) {
unsafe {
let curr = (ptr as *mut Header).offset(-1);
if (*curr).magic != MAGIC_BUSY {
panic!("heap corruption detected at {:p}", curr)
}
(*curr).magic = MAGIC_FREE;
}
}
#[no_mangle]
pub extern fn __rust_reallocate(ptr: *mut u8, old_size: usize, size: usize,
align: usize) -> *mut u8 {
unsafe {
let new_ptr = __rust_allocate(size, align);
if !new_ptr.is_null() {
ptr::copy_nonoverlapping(ptr, new_ptr, cmp::min(old_size, size));
__rust_deallocate(ptr, old_size, align);
}
new_ptr
}
}
#[no_mangle]
pub extern fn __rust_reallocate_inplace(_ptr: *mut u8, old_size: usize, _size: usize,
_align: usize) -> usize {
old_size
}
#[no_mangle]
pub extern fn __rust_usable_size(size: usize, _align: usize) -> usize {
size
}
pub fn debug_dump(f: &mut fmt::Write) -> fmt::Result {
unsafe {
let mut total_busy = 0;
let mut total_idle = 0;
let mut total_meta = 0;
write!(f, "Heap view:\n")?;
let mut curr = ROOT;
while !curr.is_null() {
total_meta += mem::size_of::<Header>();
let desc = match (*curr).magic {
MAGIC_FREE => { total_idle += (*curr).size; "IDLE" },
MAGIC_BUSY => { total_busy += (*curr).size; "BUSY" },
_ => "!!!!"
};
write!(f, "{} {:p} + {:#x} + {:#x} -> {:p}\n",
desc, curr, mem::size_of::<Header>(), (*curr).size, (*curr).next)?;
match (*curr).magic {
MAGIC_FREE | MAGIC_BUSY => (),
_ => break
}
curr = (*curr).next;
}
write!(f, " === busy: {:#x} idle: {:#x} meta: {:#x} total: {:#x}\n",
total_busy, total_idle, total_meta,
total_busy + total_idle + total_meta)
}
}

View File

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

View File

@ -0,0 +1,145 @@
#![feature(alloc, allocator_api)]
#![no_std]
extern crate alloc;
use core::{mem, fmt};
use alloc::allocator::{Layout, AllocErr, Alloc};
// The minimum alignment guaranteed by the architecture.
const MIN_ALIGN: usize = 4;
const MAGIC_FREE: usize = 0xDEADDEAD;
const MAGIC_BUSY: usize = 0xFEEDFEED;
#[derive(Debug)]
struct Header {
magic: usize,
size: usize,
next: *mut Header
}
pub struct ListAlloc {
root: *mut Header
}
pub const EMPTY: ListAlloc = ListAlloc { root: 0 as *mut Header };
impl ListAlloc {
pub unsafe fn add(&mut self, ptr: *mut u8, size: usize) {
let header_size = mem::size_of::<Header>();
if size < header_size * 2 { return }
let curr = ptr as *mut Header;
(*curr).magic = MAGIC_FREE;
(*curr).size = size - header_size;
(*curr).next = self.root;
self.root = curr;
}
pub unsafe fn add_range(&mut self, begin: *mut u8, end: *mut u8) {
self.add(begin, end as usize - begin as usize)
}
}
unsafe impl<'a> Alloc for &'a ListAlloc {
unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
if layout.align() > MIN_ALIGN {
return Err(AllocErr::Unsupported { details: "alignment too large" })
}
let header_size = mem::size_of::<Header>();
let size;
if layout.size() % header_size != 0 {
size = layout.size() + header_size - (layout.size() % header_size);
} else {
size = layout.size()
}
let mut curr = self.root;
while !curr.is_null() {
match (*curr).magic {
MAGIC_BUSY => (),
MAGIC_FREE => {
let mut next = (*curr).next;
while !next.is_null() && (*next).magic == MAGIC_FREE {
// Join
(*next).magic = 0;
(*curr).size += (*next).size + header_size;
(*curr).next = (*next).next;
next = (*curr).next;
}
if (*curr).size > size + header_size * 2 {
// Split
let offset = header_size + size;
let next = (curr as *mut u8).offset(offset as isize) as *mut Header;
(*next).magic = MAGIC_FREE;
(*next).size = (*curr).size - offset;
(*next).next = (*curr).next;
(*curr).next = next;
(*curr).size = size;
}
if (*curr).size >= size {
(*curr).magic = MAGIC_BUSY;
return Ok(curr.offset(1) as *mut u8)
}
},
_ => panic!("heap corruption detected at {:p}", curr)
}
curr = (*curr).next;
}
Err(AllocErr::Exhausted { request: layout })
}
unsafe fn dealloc(&mut self, ptr: *mut u8, _layout: Layout) {
let curr = (ptr as *mut Header).offset(-1);
if (*curr).magic != MAGIC_BUSY {
panic!("heap corruption detected at {:p}", curr)
}
(*curr).magic = MAGIC_FREE;
}
fn oom(&mut self, err: AllocErr) -> ! {
panic!("cannot allocate: {:?}", err)
}
}
impl ListAlloc {
pub fn debug_dump(&self, f: &mut fmt::Write) -> fmt::Result {
unsafe {
let mut total_busy = 0;
let mut total_idle = 0;
let mut total_meta = 0;
write!(f, "Heap view:\n")?;
let mut curr = self.root;
while !curr.is_null() {
total_meta += mem::size_of::<Header>();
let desc = match (*curr).magic {
MAGIC_FREE => { total_idle += (*curr).size; "IDLE" },
MAGIC_BUSY => { total_busy += (*curr).size; "BUSY" },
_ => "!!!!"
};
write!(f, "{} {:p} + {:#x} + {:#x} -> {:p}\n",
desc, curr, mem::size_of::<Header>(), (*curr).size, (*curr).next)?;
match (*curr).magic {
MAGIC_FREE | MAGIC_BUSY => (),
_ => break
}
curr = (*curr).next;
}
write!(f, " === busy: {:#x} idle: {:#x} meta: {:#x} total: {:#x}\n",
total_busy, total_idle, total_meta,
total_busy + total_idle + total_meta)
}
}
}

View File

@ -1,41 +0,0 @@
#![feature(allocator)]
#![no_std]
#![allocator]
#[no_mangle]
pub extern "C" fn __rust_allocate(_size: usize, _align: usize) -> *mut u8 {
unimplemented!()
}
#[no_mangle]
pub extern fn __rust_allocate_zeroed(_size: usize, _align: usize) -> *mut u8 {
unimplemented!()
}
#[no_mangle]
pub extern "C" fn __rust_deallocate(_ptr: *mut u8, _old_size: usize, _align: usize) {
unimplemented!()
}
#[no_mangle]
pub extern "C" fn __rust_reallocate(_ptr: *mut u8,
_old_size: usize,
_size: usize,
_align: usize)
-> *mut u8 {
unimplemented!()
}
#[no_mangle]
pub extern "C" fn __rust_reallocate_inplace(_ptr: *mut u8,
_old_size: usize,
_size: usize,
_align: usize)
-> usize {
unimplemented!()
}
#[no_mangle]
pub extern "C" fn __rust_usable_size(_size: usize, _align: usize) -> usize {
unimplemented!()
}

View File

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

View File

@ -0,0 +1,18 @@
#![feature(alloc, allocator_api)]
#![no_std]
extern crate alloc;
use alloc::allocator::{Layout, AllocErr, Alloc};
pub struct StubAlloc;
unsafe impl<'a> Alloc for &'a StubAlloc {
unsafe fn alloc(&mut self, _layout: Layout) -> Result<*mut u8, AllocErr> {
unimplemented!()
}
unsafe fn dealloc(&mut self, _ptr: *mut u8, _layout: Layout) {
unimplemented!()
}
}

View File

@ -18,7 +18,7 @@ use core::fmt;
use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom};
use io::memchr; use io::memchr;
use alloc::boxed::Box; use alloc::boxed::Box;
use collections::vec::Vec; use alloc::vec::Vec;
/// The `BufReader` struct adds buffering to any reader. /// The `BufReader` struct adds buffering to any reader.
/// ///

View File

@ -14,7 +14,7 @@ use io::prelude::*;
use core::cmp; use core::cmp;
use io::{self, SeekFrom, Error, ErrorKind}; use io::{self, SeekFrom, Error, ErrorKind};
use alloc::boxed::Box; use alloc::boxed::Box;
use collections::vec::Vec; use alloc::vec::Vec;
/// A `Cursor` wraps another type and provides it with a /// A `Cursor` wraps another type and provides it with a
/// [`Seek`](trait.Seek.html) implementation. /// [`Seek`](trait.Seek.html) implementation.

View File

@ -14,8 +14,8 @@ use io::{self, SeekFrom, Read, Write, Seek, Error, ErrorKind};
use io::BufRead; use io::BufRead;
use core::fmt; use core::fmt;
use core::mem; use core::mem;
use collections::string::String; use alloc::string::String;
use collections::vec::Vec; use alloc::vec::Vec;
// ============================================================================= // =============================================================================
// Forwarding implementations // Forwarding implementations

View File

@ -255,9 +255,9 @@ use core::marker::Sized;
use core::option::Option::{self, Some, None}; use core::option::Option::{self, Some, None};
use core::result::Result::{Ok, Err}; use core::result::Result::{Ok, Err};
use core::result; use core::result;
use collections::string::String; use alloc::string::String;
use collections::vec::Vec; use alloc::vec::Vec;
use collections::str; use alloc::str;
mod memchr; mod memchr;
pub use self::buffered::{BufReader, BufWriter, LineWriter}; pub use self::buffered::{BufReader, BufWriter, LineWriter};

View File

@ -1,29 +1,28 @@
#![feature(lang_items, asm, alloc, collections, needs_panic_runtime, #![feature(lang_items, asm, alloc, needs_panic_runtime,
unicode, raw, int_error_internals, try_from, macro_reexport, unicode, raw, int_error_internals, try_from, macro_reexport,
allow_internal_unstable, stmt_expr_attributes, str_internals)] allow_internal_unstable, stmt_expr_attributes, str_internals)]
#![no_std] #![no_std]
#![needs_panic_runtime] #![needs_panic_runtime]
extern crate std_unicode; extern crate std_unicode;
extern crate alloc;
#[macro_use] #[macro_use]
#[macro_reexport(vec, format)] #[macro_reexport(vec, format)]
extern crate collections; extern crate alloc;
pub use core::{any, cell, clone, cmp, convert, default, hash, iter, marker, mem, num, pub use core::{any, cell, clone, cmp, convert, default, hash, iter, marker, mem, num,
ops, option, ptr, result, sync, ops, option, ptr, result, sync,
char, i16, i32, i64, i8, isize, u16, u32, u64, u8, usize, f32, f64}; char, i16, i32, i64, i8, isize, u16, u32, u64, u8, usize, f32, f64};
pub use alloc::{arc, rc, oom, raw_vec}; pub use alloc::{arc, rc, raw_vec};
pub use collections::{binary_heap, borrow, boxed, btree_map, btree_set, fmt, linked_list, slice, pub use alloc::{binary_heap, borrow, boxed, btree_map, btree_set, fmt, linked_list, slice,
str, string, vec, vec_deque}; str, string, vec, vec_deque};
pub mod prelude { pub mod prelude {
pub mod v1 { pub mod v1 {
pub use core::prelude::v1::*; pub use core::prelude::v1::*;
pub use collections::boxed::Box; pub use alloc::boxed::Box;
pub use collections::borrow::ToOwned; pub use alloc::borrow::ToOwned;
pub use collections::string::{String, ToString}; pub use alloc::string::{String, ToString};
pub use collections::vec::Vec; pub use alloc::vec::Vec;
} }
} }

View File

@ -16,8 +16,7 @@ build_artiq = { path = "../libbuild_artiq" }
byteorder = { version = "1.0", default-features = false } byteorder = { version = "1.0", default-features = false }
cslice = { version = "0.3" } cslice = { version = "0.3" }
log = { version = "0.3", default-features = false } log = { version = "0.3", default-features = false }
fringe = { version = "= 1.1.0", default-features = false, features = ["alloc"] } alloc_list = { path = "../liballoc_list" }
alloc_artiq = { path = "../liballoc_artiq" }
std_artiq = { path = "../libstd_artiq", features = ["alloc", "io_error_alloc"] } std_artiq = { path = "../libstd_artiq", features = ["alloc", "io_error_alloc"] }
logger_artiq = { path = "../liblogger_artiq" } logger_artiq = { path = "../liblogger_artiq" }
board = { path = "../libboard", features = ["uart_console"] } board = { path = "../libboard", features = ["uart_console"] }
@ -30,8 +29,14 @@ git = "https://github.com/rust-lang-nursery/compiler-builtins"
rev = "631b568" rev = "631b568"
features = ["mem"] features = ["mem"]
[dependencies.fringe]
git = "https://github.com/m-labs/libfringe"
rev = "bd23494"
default-features = false
features = ["alloc"]
[dependencies.smoltcp] [dependencies.smoltcp]
git = "https://github.com/m-labs/smoltcp" git = "https://github.com/m-labs/smoltcp"
rev = "64369d9" rev = "bf4ddef"
default-features = false default-features = false
features = ["alloc", "collections", "log"]#, "verbose"] features = ["alloc", "log"]

View File

@ -1,6 +1,5 @@
#![no_std] #![no_std]
#![feature(compiler_builtins_lib, alloc, oom, repr_simd, lang_items, const_fn, #![feature(compiler_builtins_lib, alloc, repr_simd, lang_items, const_fn, global_allocator)]
closure_to_fn_coercion)]
extern crate compiler_builtins; extern crate compiler_builtins;
extern crate alloc; extern crate alloc;
@ -11,7 +10,7 @@ extern crate byteorder;
extern crate fringe; extern crate fringe;
extern crate smoltcp; extern crate smoltcp;
extern crate alloc_artiq; extern crate alloc_list;
#[macro_use] #[macro_use]
extern crate std_artiq as std; extern crate std_artiq as std;
extern crate logger_artiq; extern crate logger_artiq;
@ -164,6 +163,10 @@ fn startup() {
} }
} }
#[global_allocator]
static mut ALLOC: alloc_list::ListAlloc = alloc_list::EMPTY;
static mut LOG_BUFFER: [u8; 1<<17] = [0; 1<<17];
#[no_mangle] #[no_mangle]
pub extern fn main() -> i32 { pub extern fn main() -> i32 {
unsafe { unsafe {
@ -171,16 +174,10 @@ pub extern fn main() -> i32 {
static mut _fheap: u8; static mut _fheap: u8;
static mut _eheap: u8; static mut _eheap: u8;
} }
alloc_artiq::seed(&mut _fheap as *mut u8, ALLOC.add_range(&mut _fheap, &mut _eheap);
&_eheap as *const u8 as usize - &_fheap as *const u8 as usize);
alloc::oom::set_oom_handler(|| {
alloc_artiq::debug_dump(&mut board::uart_console::Console).unwrap();
panic!("out of memory");
});
static mut LOG_BUFFER: [u8; 1<<17] = [0; 1<<17];
logger_artiq::BufferLogger::new(&mut LOG_BUFFER[..]).register(startup); logger_artiq::BufferLogger::new(&mut LOG_BUFFER[..]).register(startup);
0 0
} }
} }

View File

@ -13,7 +13,7 @@ path = "lib.rs"
build_artiq = { path = "../libbuild_artiq" } build_artiq = { path = "../libbuild_artiq" }
[dependencies] [dependencies]
alloc_artiq = { path = "../liballoc_artiq" } alloc_list = { path = "../liballoc_list" }
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"] }

View File

@ -20,7 +20,7 @@ requirements:
- binutils-or1k-linux >=2.27 - binutils-or1k-linux >=2.27
- llvm-or1k - llvm-or1k
- llvmlite-artiq 0.12.0.dev py35_30 - llvmlite-artiq 0.12.0.dev py35_30
- rust-core-or1k 1.18.0 15 - rust-core-or1k 1.20.0 16
- cargo 0.11.0 - cargo 0.11.0
- openocd >=0.10 - openocd >=0.10
- lit - lit

View File

@ -103,17 +103,17 @@ and the ARTIQ kernels.
* Install Rust: :: * Install Rust: ::
$ cd ~/artiq-dev $ cd ~/artiq-dev
$ git clone -b artiq-1.18.0 https://github.com/m-labs/rust $ git clone -b artiq-1.20.0 https://github.com/m-labs/rust
$ cd rust $ cd rust
$ git submodule update --init $ git submodule update --init
$ mkdir build $ mkdir build
$ cd build $ cd build
$ ../configure --prefix=/usr/local/rust-or1k --llvm-root=/usr/local/llvm-or1k --disable-manage-submodules $ ../configure --prefix=/usr/local/rust-or1k --llvm-root=/usr/local/llvm-or1k --disable-manage-submodules --disable-docs
$ sudo mkdir /usr/local/rust-or1k $ sudo mkdir /usr/local/rust-or1k
$ sudo chown $USER.$USER /usr/local/rust-or1k $ sudo chown $USER.$USER /usr/local/rust-or1k
$ make install $ make install
$ libs="libcore liballoc libstd_unicode libcollections liblibc_mini libunwind" $ libs="libcore libstd_unicode liballoc liblibc_mini libunwind"
$ rustc="/usr/local/rust-or1k/bin/rustc --target or1k-unknown-none -g -C target-feature=+mul,+div,+ffl1,+cmov,+addc -C opt-level=s -L ." $ rustc="/usr/local/rust-or1k/bin/rustc --target or1k-unknown-none -g -C target-feature=+mul,+div,+ffl1,+cmov,+addc -C opt-level=s -L ."
$ destdir="/usr/local/rust-or1k/lib/rustlib/or1k-unknown-none/lib/" $ destdir="/usr/local/rust-or1k/lib/rustlib/or1k-unknown-none/lib/"
$ mkdir ../build-or1k $ mkdir ../build-or1k
@ -121,8 +121,8 @@ and the ARTIQ kernels.
$ for lib in ${libs}; do ${rustc} ../src/${lib}/lib.rs; done $ for lib in ${libs}; do ${rustc} ../src/${lib}/lib.rs; done
$ ${rustc} -Cpanic=abort ../src/libpanic_abort/lib.rs $ ${rustc} -Cpanic=abort ../src/libpanic_abort/lib.rs
$ ${rustc} -Cpanic=unwind ../src/libpanic_unwind/lib.rs --cfg llvm_libunwind $ ${rustc} -Cpanic=unwind ../src/libpanic_unwind/lib.rs --cfg llvm_libunwind
$ sudo mkdir -p ${destdir} $ mkdir -p ${destdir}
$ sudo cp *.rlib ${destdir} $ cp *.rlib ${destdir}
.. note:: .. note::
Compilation of LLVM can take more than 30 min on some machines. Compilation of Rust can take more than two hours. Compilation of LLVM can take more than 30 min on some machines. Compilation of Rust can take more than two hours.