From 1ff42683d943b730e38462645624a84d087bc557 Mon Sep 17 00:00:00 2001
From: whitequark <whitequark@whitequark.org>
Date: Mon, 14 May 2018 17:33:25 +0000
Subject: [PATCH] firmware: merge libamp into libboard_artiq.

All gateware interfaces live in libboard_artiq, but libamp predates
libboard_artiq.
---
 artiq/firmware/Cargo.lock                             | 10 +---------
 artiq/firmware/ksupport/Cargo.toml                    |  2 +-
 artiq/firmware/ksupport/lib.rs                        | 10 +++++-----
 artiq/firmware/libamp/Cargo.toml                      | 11 -----------
 artiq/firmware/libamp/lib.rs                          |  6 ------
 artiq/firmware/libboard_artiq/lib.rs                  |  3 +++
 artiq/firmware/{libamp => libboard_artiq}/mailbox.rs  |  0
 .../firmware/{libamp => libboard_artiq}/rpc_queue.rs  |  0
 artiq/firmware/runtime/Cargo.toml                     |  1 -
 artiq/firmware/runtime/main.rs                        |  3 +--
 10 files changed, 11 insertions(+), 35 deletions(-)
 delete mode 100644 artiq/firmware/libamp/Cargo.toml
 delete mode 100644 artiq/firmware/libamp/lib.rs
 rename artiq/firmware/{libamp => libboard_artiq}/mailbox.rs (100%)
 rename artiq/firmware/{libamp => libboard_artiq}/rpc_queue.rs (100%)

diff --git a/artiq/firmware/Cargo.lock b/artiq/firmware/Cargo.lock
index d4c556ebb..9ce01cd31 100644
--- a/artiq/firmware/Cargo.lock
+++ b/artiq/firmware/Cargo.lock
@@ -2,13 +2,6 @@
 name = "alloc_list"
 version = "0.0.0"
 
-[[package]]
-name = "amp"
-version = "0.0.0"
-dependencies = [
- "board 0.0.0",
-]
-
 [[package]]
 name = "bitflags"
 version = "1.0.1"
@@ -134,8 +127,8 @@ dependencies = [
 name = "ksupport"
 version = "0.0.0"
 dependencies = [
- "amp 0.0.0",
  "board 0.0.0",
+ "board_artiq 0.0.0",
  "build_misoc 0.0.0",
  "cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "dyld 0.0.0",
@@ -204,7 +197,6 @@ name = "runtime"
 version = "0.0.0"
 dependencies = [
  "alloc_list 0.0.0",
- "amp 0.0.0",
  "board 0.0.0",
  "board_artiq 0.0.0",
  "build_artiq 0.0.0",
diff --git a/artiq/firmware/ksupport/Cargo.toml b/artiq/firmware/ksupport/Cargo.toml
index 53995f3e4..ef5513344 100644
--- a/artiq/firmware/ksupport/Cargo.toml
+++ b/artiq/firmware/ksupport/Cargo.toml
@@ -17,5 +17,5 @@ cslice = { version = "0.3" }
 io = { path = "../libio", features = ["byteorder"] }
 dyld = { path = "../libdyld" }
 board = { path = "../libboard" }
+board_artiq = { path = "../libboard_artiq" }
 proto = { path = "../libproto" }
-amp = { path = "../libamp" }
diff --git a/artiq/firmware/ksupport/lib.rs b/artiq/firmware/ksupport/lib.rs
index e46d4e244..1975ca12b 100644
--- a/artiq/firmware/ksupport/lib.rs
+++ b/artiq/firmware/ksupport/lib.rs
@@ -8,19 +8,19 @@ extern crate unwind;
 extern crate libc;
 
 extern crate io;
-extern crate board;
 extern crate dyld;
+extern crate board;
+extern crate board_artiq;
 extern crate proto;
-extern crate amp;
 
 use core::{mem, ptr, slice, str};
 use cslice::{CSlice, AsCSlice};
 use io::Cursor;
-use board::csr;
 use dyld::Library;
+use board::csr;
+use board_artiq::{mailbox, rpc_queue};
 use proto::{kernel_proto, rpc_proto};
-use proto::kernel_proto::*;
-use amp::{mailbox, rpc_queue};
+use kernel_proto::*;
 
 fn send(request: &Message) {
     unsafe { mailbox::send(request as *const _ as usize) }
diff --git a/artiq/firmware/libamp/Cargo.toml b/artiq/firmware/libamp/Cargo.toml
deleted file mode 100644
index 2607f80c2..000000000
--- a/artiq/firmware/libamp/Cargo.toml
+++ /dev/null
@@ -1,11 +0,0 @@
-[package]
-authors = ["M-Labs"]
-name = "amp"
-version = "0.0.0"
-
-[lib]
-name = "amp"
-path = "lib.rs"
-
-[dependencies]
-board = { path = "../libboard" }
diff --git a/artiq/firmware/libamp/lib.rs b/artiq/firmware/libamp/lib.rs
deleted file mode 100644
index df46ef0c0..000000000
--- a/artiq/firmware/libamp/lib.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-#![no_std]
-
-extern crate board;
-
-pub mod mailbox;
-pub mod rpc_queue;
diff --git a/artiq/firmware/libboard_artiq/lib.rs b/artiq/firmware/libboard_artiq/lib.rs
index bf4c491a2..a94c20a62 100644
--- a/artiq/firmware/libboard_artiq/lib.rs
+++ b/artiq/firmware/libboard_artiq/lib.rs
@@ -16,6 +16,9 @@ pub mod pcr;
 pub mod i2c;
 pub mod spi;
 
+pub mod mailbox;
+pub mod rpc_queue;
+
 #[cfg(has_si5324)]
 pub mod si5324;
 
diff --git a/artiq/firmware/libamp/mailbox.rs b/artiq/firmware/libboard_artiq/mailbox.rs
similarity index 100%
rename from artiq/firmware/libamp/mailbox.rs
rename to artiq/firmware/libboard_artiq/mailbox.rs
diff --git a/artiq/firmware/libamp/rpc_queue.rs b/artiq/firmware/libboard_artiq/rpc_queue.rs
similarity index 100%
rename from artiq/firmware/libamp/rpc_queue.rs
rename to artiq/firmware/libboard_artiq/rpc_queue.rs
diff --git a/artiq/firmware/runtime/Cargo.toml b/artiq/firmware/runtime/Cargo.toml
index fc8cb35ad..7eff26c33 100644
--- a/artiq/firmware/runtime/Cargo.toml
+++ b/artiq/firmware/runtime/Cargo.toml
@@ -26,7 +26,6 @@ std_artiq = { path = "../libstd_artiq", features = ["alloc", "io_error_alloc"] }
 logger_artiq = { path = "../liblogger_artiq" }
 board_artiq = { path = "../libboard_artiq" }
 proto = { path = "../libproto", features = ["log", "alloc"] }
-amp = { path = "../libamp" }
 
 [dependencies.fringe]
 git = "https://github.com/m-labs/libfringe"
diff --git a/artiq/firmware/runtime/main.rs b/artiq/firmware/runtime/main.rs
index 0aed7b4f8..2f14a4b4a 100644
--- a/artiq/firmware/runtime/main.rs
+++ b/artiq/firmware/runtime/main.rs
@@ -20,7 +20,6 @@ extern crate logger_artiq;
 extern crate board;
 extern crate board_artiq;
 extern crate proto;
-extern crate amp;
 
 use core::convert::TryFrom;
 use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr};
@@ -34,7 +33,7 @@ use board_artiq::drtioaux;
 use proto::{mgmt_proto, moninj_proto, rpc_proto, session_proto,kernel_proto};
 #[cfg(has_rtio_analyzer)]
 use proto::analyzer_proto;
-use amp::{mailbox, rpc_queue};
+use board_artiq::{mailbox, rpc_queue};
 
 #[cfg(has_rtio_core)]
 mod rtio_mgt;