From cf33ba748d225961b13c8806a29814e0dc28d803 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 14 May 2018 18:27:17 +0000 Subject: [PATCH] firmware: eliminate non-io uses of std_artiq from runtime. Just replace these with references to alloc. --- artiq/firmware/runtime/cache.rs | 4 +--- artiq/firmware/runtime/moninj.rs | 4 ++-- artiq/firmware/runtime/rtio_dma.rs | 7 +++---- artiq/firmware/runtime/sched.rs | 4 ++-- artiq/firmware/runtime/session.rs | 12 ++++++------ artiq/firmware/runtime/urc.rs | 6 +++--- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/artiq/firmware/runtime/cache.rs b/artiq/firmware/runtime/cache.rs index 082dda287..2f1948924 100644 --- a/artiq/firmware/runtime/cache.rs +++ b/artiq/firmware/runtime/cache.rs @@ -1,6 +1,4 @@ -use std::vec::Vec; -use std::string::String; -use std::btree_map::BTreeMap; +use alloc::{Vec, String, BTreeMap}; #[derive(Debug)] struct Entry { diff --git a/artiq/firmware/runtime/moninj.rs b/artiq/firmware/runtime/moninj.rs index dc8cccf0b..ecb862b38 100644 --- a/artiq/firmware/runtime/moninj.rs +++ b/artiq/firmware/runtime/moninj.rs @@ -1,6 +1,6 @@ -use std::io::{self, Read}; -use std::btree_map::BTreeMap; +use alloc::btree_map::BTreeMap; +use std::io::{self, Read}; use sched::Io; use sched::{TcpListener, TcpStream}; use board_misoc::{clock, csr}; diff --git a/artiq/firmware/runtime/rtio_dma.rs b/artiq/firmware/runtime/rtio_dma.rs index 4a024e929..b0f964d86 100644 --- a/artiq/firmware/runtime/rtio_dma.rs +++ b/artiq/firmware/runtime/rtio_dma.rs @@ -1,7 +1,6 @@ -use std::mem; -use std::vec::Vec; -use std::string::String; -use std::btree_map::BTreeMap; +use core::mem; +use alloc::{Vec, String, BTreeMap}; + use std::io::Write; const ALIGNMENT: usize = 64; diff --git a/artiq/firmware/runtime/sched.rs b/artiq/firmware/runtime/sched.rs index 8622b56e8..e9ca34cc3 100644 --- a/artiq/firmware/runtime/sched.rs +++ b/artiq/firmware/runtime/sched.rs @@ -3,14 +3,14 @@ use core::mem; use core::result; use core::cell::{Cell, RefCell}; +use alloc::Vec; use fringe::OwnedStack; use fringe::generator::{Generator, Yielder, State as GeneratorState}; use smoltcp::wire::IpEndpoint; use smoltcp::socket::{SocketHandle, SocketRef}; -use std::vec::Vec; -use std::io::{Read, Write, Result, Error, ErrorKind}; use board_misoc::clock; +use std::io::{Read, Write, Result, Error, ErrorKind}; use urc::Urc; type SocketSet = ::smoltcp::socket::SocketSet<'static, 'static, 'static>; diff --git a/artiq/firmware/runtime/session.rs b/artiq/firmware/runtime/session.rs index 5579cde5a..82cf8c89c 100644 --- a/artiq/firmware/runtime/session.rs +++ b/artiq/firmware/runtime/session.rs @@ -1,11 +1,9 @@ -use std::prelude::v1::*; -use std::{mem, str}; -use std::cell::{Cell, RefCell}; -use std::io::{self, Read, Write}; -use std::error::Error; +use core::{mem, str, cell::{Cell, RefCell}, fmt::Write as FmtWrite}; +use alloc::{Vec, String}; use byteorder::{ByteOrder, NetworkEndian}; use board_misoc::{ident, cache, config}; +use std::io::{self, Read, Write}; use {mailbox, rpc_queue, kernel}; use urc::Urc; use sched::{ThreadHandle, Io}; @@ -289,7 +287,9 @@ fn process_host_message(io: &Io, match unsafe { kern_load(io, session, &kernel) } { Ok(()) => host_write(stream, host::Reply::LoadCompleted), Err(error) => { - host_write(stream, host::Reply::LoadFailed(error.description()))?; + let mut description = String::new(); + write!(&mut description, "{}", error).unwrap(); + host_write(stream, host::Reply::LoadFailed(&description))?; kern_acknowledge() } }, diff --git a/artiq/firmware/runtime/urc.rs b/artiq/firmware/runtime/urc.rs index cec7751ea..1117269b6 100644 --- a/artiq/firmware/runtime/urc.rs +++ b/artiq/firmware/runtime/urc.rs @@ -1,6 +1,6 @@ -use std::rc::Rc; -use std::ops::Deref; -use std::fmt; +use core::ops::Deref; +use core::fmt; +use alloc::rc::Rc; pub struct Urc(Rc);