mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
kernel: compatibility with riscv32imac-unknown-xous-elf
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
3c10127ed4
commit
19653e9c53
17 changed files with 219 additions and 172 deletions
|
|
@ -5,6 +5,7 @@ $crate = "xous-kernel"
|
||||||
|
|
||||||
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32imac src/asm.S -o bin/$crate.o
|
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32imac src/asm.S -o bin/$crate.o
|
||||||
riscv64-unknown-elf-ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
riscv64-unknown-elf-ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
||||||
|
riscv64-unknown-elf-ar crs bin/riscv32imac-unknown-xous-elf.a bin/$crate.o
|
||||||
riscv64-unknown-elf-ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
riscv64-unknown-elf-ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32i src/asm.S -DSKIP_MULTICORE -o bin/$crate.o
|
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32i src/asm.S -DSKIP_MULTICORE -o bin/$crate.o
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ rm -f bin/*.a
|
||||||
|
|
||||||
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32imac src/asm.S -o bin/$crate.o
|
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32imac src/asm.S -o bin/$crate.o
|
||||||
ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv32imac-unknown-none-elf.a bin/$crate.o
|
||||||
|
ar crs bin/riscv32imac-unknown-xous-elf.a bin/$crate.o
|
||||||
ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
ar crs bin/riscv32imc-unknown-none-elf.a bin/$crate.o
|
||||||
|
|
||||||
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32i src/asm.S -DSKIP_MULTICORE -o bin/$crate.o
|
riscv64-unknown-elf-gcc -ggdb3 -c -mabi=ilp32 -march=rv32i src/asm.S -DSKIP_MULTICORE -o bin/$crate.o
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
BIN
kernel/bin/riscv32imac-unknown-xous-elf.a
Normal file
BIN
kernel/bin/riscv32imac-unknown-xous-elf.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -17,7 +17,7 @@ fn main() {
|
||||||
// If we're not running on a desktop-class operating system, emit the "baremetal"
|
// If we're not running on a desktop-class operating system, emit the "baremetal"
|
||||||
// config setting. This will enable software to do tasks such as
|
// config setting. This will enable software to do tasks such as
|
||||||
// managing memory.
|
// managing memory.
|
||||||
if target_os == "none" {
|
if target_os == "none" || target_os == "xous" {
|
||||||
println!("Target {} is bare metal", target);
|
println!("Target {} is bare metal", target);
|
||||||
println!("cargo:rustc-cfg=baremetal");
|
println!("cargo:rustc-cfg=baremetal");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ SECTIONS
|
||||||
/DISCARD/ :
|
/DISCARD/ :
|
||||||
{
|
{
|
||||||
*(.eh_frame);
|
*(.eh_frame);
|
||||||
|
*(.eh_frame_hdr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,22 +85,25 @@ fn handle_connection(
|
||||||
chn: Sender<ThreadMessage>,
|
chn: Sender<ThreadMessage>,
|
||||||
should_exit: std::sync::Arc<core::sync::atomic::AtomicBool>,
|
should_exit: std::sync::Arc<core::sync::atomic::AtomicBool>,
|
||||||
) {
|
) {
|
||||||
enum ServerMessage {
|
// enum ServerMessage {
|
||||||
Exit,
|
// Exit,
|
||||||
ServerPacket([usize; 9]),
|
// ServerPacket(Box<SysCall>),
|
||||||
ServerPacketWithData([usize; 9], Vec<u8>),
|
// ServerPacketWithData([usize; 9], Vec<u8>),
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn conn_thread(mut conn: TcpStream, sender: Sender<ServerMessage>, _pid: PID) {
|
fn conn_thread(mut conn: TcpStream, sender: Sender<ThreadMessage>, pid: PID) {
|
||||||
loop {
|
loop {
|
||||||
let mut raw_data = [0u8; 9 * std::mem::size_of::<usize>()];
|
let mut raw_data = [0u8; 9 * std::mem::size_of::<usize>()];
|
||||||
|
|
||||||
|
// Read bytes from the connection. This will fail when the connection closes,
|
||||||
|
// so send a `Termination` message across the channel.
|
||||||
if let Err(_e) = conn.read_exact(&mut raw_data) {
|
if let Err(_e) = conn.read_exact(&mut raw_data) {
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"KERNEL({}): client disconnected: {} -- shutting down virtual process",
|
"KERNEL({}): client disconnected: {} -- shutting down virtual process",
|
||||||
_pid, _e
|
pid, _e
|
||||||
);
|
);
|
||||||
sender.send(ServerMessage::Exit).ok();
|
// sender.send(ServerMessage::Exit).ok();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,40 +114,68 @@ fn handle_connection(
|
||||||
{
|
{
|
||||||
*word = usize::from_le_bytes(bytes.try_into().unwrap());
|
*word = usize::from_le_bytes(bytes.try_into().unwrap());
|
||||||
}
|
}
|
||||||
|
let thread_id = packet_data[0] as TID;
|
||||||
|
let mut call = match crate::SysCall::from_args(
|
||||||
|
packet_data[1],
|
||||||
|
packet_data[2],
|
||||||
|
packet_data[3],
|
||||||
|
packet_data[4],
|
||||||
|
packet_data[5],
|
||||||
|
packet_data[6],
|
||||||
|
packet_data[7],
|
||||||
|
packet_data[8],
|
||||||
|
) {
|
||||||
|
Ok(call) => call,
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("KERNEL({}): Received invalid syscall: {:?}", pid, e);
|
||||||
|
eprintln!(
|
||||||
|
"Raw packet: {:08x} {} {} {} {} {} {} {}",
|
||||||
|
packet_data[0],
|
||||||
|
packet_data[1],
|
||||||
|
packet_data[2],
|
||||||
|
packet_data[3],
|
||||||
|
packet_data[4],
|
||||||
|
packet_data[5],
|
||||||
|
packet_data[6],
|
||||||
|
packet_data[7]
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(mem) = unsafe { call.memory_mut() } {
|
||||||
|
let mut data = vec![0u8; mem.len()];
|
||||||
|
if conn.read_exact(&mut data).is_err() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let sliced_data = data.into_boxed_slice();
|
||||||
|
assert_eq!(
|
||||||
|
sliced_data.len(),
|
||||||
|
mem.len(),
|
||||||
|
"deconstructed data {} != message buf length {}",
|
||||||
|
sliced_data.len(),
|
||||||
|
mem.len()
|
||||||
|
);
|
||||||
|
*mem = unsafe {
|
||||||
|
xous_kernel::MemoryRange::new(
|
||||||
|
Box::into_raw(sliced_data) as *mut u8 as usize,
|
||||||
|
mem.len(),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send(
|
.send(ThreadMessage::SysCall(pid, thread_id, call))
|
||||||
if (packet_data[1] == xous_kernel::syscall::SysCallNumber::SendMessage as _
|
|
||||||
|| packet_data[1]
|
|
||||||
== xous_kernel::syscall::SysCallNumber::TrySendMessage as _)
|
|
||||||
&& (packet_data[3] == 1 || packet_data[3] == 2 || packet_data[3] == 3)
|
|
||||||
{
|
|
||||||
let mut v = vec![0; packet_data[6]];
|
|
||||||
if conn.read_exact(&mut v).is_err() {
|
|
||||||
sender.send(ServerMessage::Exit).ok();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ServerMessage::ServerPacketWithData(packet_data, v)
|
|
||||||
} else if packet_data[1]
|
|
||||||
== xous_kernel::syscall::SysCallNumber::ReturnMemory as _
|
|
||||||
{
|
|
||||||
let mut v = vec![0; packet_data[4]];
|
|
||||||
if conn.read_exact(&mut v).is_err() {
|
|
||||||
sender.send(ServerMessage::Exit).ok();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ServerMessage::ServerPacketWithData(packet_data, v)
|
|
||||||
} else {
|
|
||||||
ServerMessage::ServerPacket(packet_data)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (sender, receiver) = unbounded();
|
// let (sender, receiver) = unbounded();
|
||||||
let conn_sender = sender.clone();
|
// let conn_sender = sender.clone();
|
||||||
std::thread::Builder::new()
|
let conn_sender = chn.clone();
|
||||||
|
let conn_thread = std::thread::Builder::new()
|
||||||
.name(format!("PID {}: client connection thread", pid))
|
.name(format!("PID {}: client connection thread", pid))
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
conn_thread(conn, conn_sender, pid);
|
conn_thread(conn, conn_sender, pid);
|
||||||
|
|
@ -155,122 +186,124 @@ fn handle_connection(
|
||||||
.name(format!("PID {}: client should_exit thread", pid))
|
.name(format!("PID {}: client should_exit thread", pid))
|
||||||
.spawn(move || loop {
|
.spawn(move || loop {
|
||||||
if should_exit.load(core::sync::atomic::Ordering::Relaxed) {
|
if should_exit.load(core::sync::atomic::Ordering::Relaxed) {
|
||||||
// eprintln!("KERNEL: should_exit == 1");
|
eprintln!("KERNEL: should_exit == 1");
|
||||||
sender.send(ServerMessage::Exit).ok();
|
// sender.send(ServerMessage::Exit).ok();
|
||||||
|
// WARNING: This functionality is unimplemented right now
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::thread::park_timeout(std::time::Duration::from_secs(1));
|
std::thread::park_timeout(std::time::Duration::from_secs(1));
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
for msg in receiver {
|
// for msg in receiver {
|
||||||
match msg {
|
// match msg {
|
||||||
ServerMessage::Exit => {
|
// ServerMessage::Exit => {
|
||||||
#[cfg(not(test))]
|
// #[cfg(not(test))]
|
||||||
eprintln!("KERNEL({}): Received ServerMessage::Exit", pid);
|
// eprintln!("KERNEL({}): Received ServerMessage::Exit", pid);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
ServerMessage::ServerPacket(pkt) => {
|
// ServerMessage::ServerPacket(pkt) => {
|
||||||
let thread_id = pkt[0];
|
// let thread_id = pkt[0];
|
||||||
let call = xous_kernel::SysCall::from_args(
|
// let call = xous_kernel::SysCall::from_args(
|
||||||
pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[6], pkt[7], pkt[8],
|
// pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[6], pkt[7], pkt[8],
|
||||||
);
|
// );
|
||||||
match call {
|
// match call {
|
||||||
Err(e) => {
|
// Err(e) => {
|
||||||
eprintln!("KERNEL({}): Received invalid syscall: {:?}", pid, e);
|
// eprintln!("KERNEL({}): Received invalid syscall: {:?}", pid, e);
|
||||||
eprintln!(
|
// eprintln!(
|
||||||
"Raw packet: {:08x} {} {} {} {} {} {} {}",
|
// "Raw packet: {:08x} {} {} {} {} {} {} {}",
|
||||||
pkt[0], pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[6], pkt[7]
|
// pkt[0], pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[6], pkt[7]
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
Ok(call) => chn
|
// Ok(call) => chn
|
||||||
.send(ThreadMessage::SysCall(pid, thread_id, call))
|
// .send(ThreadMessage::SysCall(pid, thread_id, call))
|
||||||
.expect("couldn't make syscall"),
|
// .expect("couldn't make syscall"),
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
ServerMessage::ServerPacketWithData(pkt, data) => {
|
// ServerMessage::ServerPacketWithData(pkt, data) => {
|
||||||
let thread_id = pkt[0];
|
// let thread_id = pkt[0];
|
||||||
let call = xous_kernel::SysCall::from_args(
|
// let call = xous_kernel::SysCall::from_args(
|
||||||
pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[6], pkt[7], pkt[8],
|
// pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[6], pkt[7], pkt[8],
|
||||||
);
|
// );
|
||||||
match call {
|
// match call {
|
||||||
Err(e) => {
|
// Err(e) => {
|
||||||
eprintln!("KERNEL({}): Received invalid syscall: {:?}", pid, e);
|
// eprintln!("KERNEL({}): Received invalid syscall: {:?}", pid, e);
|
||||||
eprintln!(
|
// eprintln!(
|
||||||
"Raw packet: {:08x} {} {} {} {} {} {} {}",
|
// "Raw packet: {:08x} {} {} {} {} {} {} {}",
|
||||||
pkt[0], pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[6], pkt[7]
|
// pkt[0], pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[6], pkt[7]
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
Ok(mut call) => {
|
// Ok(mut call) => {
|
||||||
// eprintln!(
|
// // eprintln!(
|
||||||
// "Received packet: {:08x} {} {} {} {} {} {} {}: {:?}",
|
// // "Received packet: {:08x} {} {} {} {} {} {} {}: {:?}",
|
||||||
// pkt[0], pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[6], pkt[7], call
|
// // pkt[0], pkt[1], pkt[2], pkt[3], pkt[4], pkt[5], pkt[6], pkt[7], call
|
||||||
// );
|
// // );
|
||||||
match call {
|
// match call {
|
||||||
SysCall::SendMessage(ref _cid, ref mut envelope)
|
// SysCall::SendMessage(ref _cid, ref mut envelope)
|
||||||
| SysCall::TrySendMessage(ref _cid, ref mut envelope) => {
|
// | SysCall::TrySendMessage(ref _cid, ref mut envelope) => {
|
||||||
match envelope {
|
// match envelope {
|
||||||
xous_kernel::Message::MutableBorrow(msg)
|
// xous_kernel::Message::MutableBorrow(msg)
|
||||||
| xous_kernel::Message::Borrow(msg)
|
// | xous_kernel::Message::Borrow(msg)
|
||||||
| xous_kernel::Message::Move(msg) => {
|
// | xous_kernel::Message::Move(msg) => {
|
||||||
// Update the address pointer. This will get turned back into a
|
// // Update the address pointer. This will get turned back into a
|
||||||
// usable pointer by casting it back into a &[T] on the other
|
// // usable pointer by casting it back into a &[T] on the other
|
||||||
// side. This is just a pointer to the start of data
|
// // side. This is just a pointer to the start of data
|
||||||
// as well as the index into the data it points at. The lengths
|
// // as well as the index into the data it points at. The lengths
|
||||||
// should still be equal once we reconstitute the data in the
|
// // should still be equal once we reconstitute the data in the
|
||||||
// other process.
|
// // other process.
|
||||||
// ::debug_here::debug_here!();
|
// // ::debug_here::debug_here!();
|
||||||
let sliced_data = data.into_boxed_slice();
|
// let sliced_data = data.into_boxed_slice();
|
||||||
assert_eq!(
|
// assert_eq!(
|
||||||
sliced_data.len(),
|
// sliced_data.len(),
|
||||||
msg.buf.len(),
|
// msg.buf.len(),
|
||||||
"deconstructed data {} != message buf length {}",
|
// "deconstructed data {} != message buf length {}",
|
||||||
sliced_data.len(),
|
// sliced_data.len(),
|
||||||
msg.buf.len()
|
// msg.buf.len()
|
||||||
);
|
// );
|
||||||
msg.buf = unsafe {
|
// msg.buf = unsafe {
|
||||||
xous_kernel::MemoryRange::new(
|
// xous_kernel::MemoryRange::new(
|
||||||
Box::into_raw(sliced_data) as *mut u8 as usize,
|
// Box::into_raw(sliced_data) as *mut u8 as usize,
|
||||||
msg.buf.len(),
|
// msg.buf.len(),
|
||||||
)
|
// )
|
||||||
.unwrap()
|
// .unwrap()
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
xous_kernel::Message::Scalar(_)
|
// xous_kernel::Message::Scalar(_)
|
||||||
| xous_kernel::Message::BlockingScalar(_) => (),
|
// | xous_kernel::Message::BlockingScalar(_) => (),
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
SysCall::ReturnMemory(
|
// SysCall::ReturnMemory(
|
||||||
ref _sender,
|
// ref _sender,
|
||||||
ref mut buf,
|
// ref mut buf,
|
||||||
ref _offset,
|
// ref _offset,
|
||||||
ref _valid,
|
// ref _valid,
|
||||||
) => {
|
// ) => {
|
||||||
let sliced_data = data.into_boxed_slice();
|
// let sliced_data = data.into_boxed_slice();
|
||||||
assert_eq!(
|
// assert_eq!(
|
||||||
sliced_data.len(),
|
// sliced_data.len(),
|
||||||
buf.len(),
|
// buf.len(),
|
||||||
"deconstructed data {} != message buf length {}",
|
// "deconstructed data {} != message buf length {}",
|
||||||
sliced_data.len(),
|
// sliced_data.len(),
|
||||||
buf.len()
|
// buf.len()
|
||||||
);
|
// );
|
||||||
*buf = unsafe {
|
// *buf = unsafe {
|
||||||
xous_kernel::MemoryRange::new(
|
// xous_kernel::MemoryRange::new(
|
||||||
Box::into_raw(sliced_data) as *mut u8 as usize,
|
// Box::into_raw(sliced_data) as *mut u8 as usize,
|
||||||
buf.len(),
|
// buf.len(),
|
||||||
)
|
// )
|
||||||
.unwrap()
|
// .unwrap()
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
_ => panic!("unsupported message type"),
|
// _ => panic!("unsupported message type"),
|
||||||
}
|
// }
|
||||||
chn.send(ThreadMessage::SysCall(pid, thread_id, call))
|
// chn.send(ThreadMessage::SysCall(pid, thread_id, call))
|
||||||
.expect("couldn't make syscall");
|
// .expect("couldn't make syscall");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
conn_thread.join().unwrap();
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"KERNEL({}): Finished the thread so sending TerminateProcess",
|
"KERNEL({}): Finished the thread so sending TerminateProcess",
|
||||||
|
|
@ -535,6 +568,7 @@ pub fn idle() -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ThreadMessage::SysCall(pid, thread_id, call) => {
|
ThreadMessage::SysCall(pid, thread_id, call) => {
|
||||||
|
// let measurement_start = std::time::Instant::now();
|
||||||
// println!("KERNEL({}): Received syscall {:?}", pid, call);
|
// println!("KERNEL({}): Received syscall {:?}", pid, call);
|
||||||
crate::arch::process::set_current_pid(pid);
|
crate::arch::process::set_current_pid(pid);
|
||||||
// println!("KERNEL({}): Now running as the new process", pid);
|
// println!("KERNEL({}): Now running as the new process", pid);
|
||||||
|
|
@ -607,6 +641,12 @@ pub fn idle() -> bool {
|
||||||
.ok();
|
.ok();
|
||||||
});
|
});
|
||||||
crate::arch::process::set_current_pid(existing_pid);
|
crate::arch::process::set_current_pid(existing_pid);
|
||||||
|
// println!(
|
||||||
|
// "KERNEL [{:2}:{:2}] Syscall took {:7} usec",
|
||||||
|
// pid,
|
||||||
|
// thread_id,
|
||||||
|
// measurement_start.elapsed().as_micros()
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_shutdown {
|
if is_shutdown {
|
||||||
|
|
|
||||||
|
|
@ -391,7 +391,7 @@ impl Process {
|
||||||
let process = &mut process_table.table[current_pid_idx].as_mut().unwrap();
|
let process = &mut process_table.table[current_pid_idx].as_mut().unwrap();
|
||||||
let conn = process.conn.as_mut().unwrap();
|
let conn = process.conn.as_mut().unwrap();
|
||||||
conn.write_all(bytes).unwrap();
|
conn.write_all(bytes).unwrap();
|
||||||
conn.flush().unwrap();
|
// conn.flush().unwrap();
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#[cfg(baremetal)]
|
#[cfg(baremetal)]
|
||||||
use core::fmt::{Error, Write};
|
use core::fmt::{Error, Write};
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(baremetal)]
|
||||||
use utralib::generated::*;
|
use utralib::generated::*;
|
||||||
|
|
||||||
#[cfg(baremetal)]
|
#[cfg(baremetal)]
|
||||||
|
|
@ -12,7 +12,7 @@ pub static mut DEBUG_OUTPUT: Option<&'static mut dyn Write> = None;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
not(test),
|
not(test),
|
||||||
target_os = "none",
|
baremetal,
|
||||||
any(feature = "debug-print", feature = "print-panics")
|
any(feature = "debug-print", feature = "print-panics")
|
||||||
))]
|
))]
|
||||||
pub mod debug_print_hardware {
|
pub mod debug_print_hardware {
|
||||||
|
|
@ -21,12 +21,12 @@ pub mod debug_print_hardware {
|
||||||
}
|
}
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
not(test),
|
not(test),
|
||||||
target_os = "none",
|
baremetal,
|
||||||
any(feature = "debug-print", feature = "print-panics")
|
any(feature = "debug-print", feature = "print-panics")
|
||||||
))]
|
))]
|
||||||
pub use crate::debug::debug_print_hardware::SUPERVISOR_UART_ADDR;
|
pub use crate::debug::debug_print_hardware::SUPERVISOR_UART_ADDR;
|
||||||
|
|
||||||
#[cfg(all(target_os = "none"))]
|
#[cfg(baremetal)]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! print {
|
macro_rules! print {
|
||||||
($($args:tt)+) => {{
|
($($args:tt)+) => {{
|
||||||
|
|
@ -39,7 +39,7 @@ macro_rules! print {
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(baremetal)]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! println
|
macro_rules! println
|
||||||
{
|
{
|
||||||
|
|
@ -54,15 +54,15 @@ macro_rules! println
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(baremetal)]
|
||||||
pub struct Uart {}
|
pub struct Uart {}
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(baremetal)]
|
||||||
pub static mut UART: Uart = Uart {};
|
pub static mut UART: Uart = Uart {};
|
||||||
|
|
||||||
#[cfg(all(target_os = "none", feature = "wrap-print"))]
|
#[cfg(all(target_os = "none", feature = "wrap-print"))]
|
||||||
static mut CHAR_COUNT: usize = 0;
|
static mut CHAR_COUNT: usize = 0;
|
||||||
|
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(baremetal)]
|
||||||
impl Uart {
|
impl Uart {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn init(self) {
|
pub fn init(self) {
|
||||||
|
|
@ -117,10 +117,10 @@ impl Uart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "gdbserver", target_os = "none"))]
|
#[cfg(all(feature = "gdbserver", baremetal))]
|
||||||
mod gdb_server;
|
mod gdb_server;
|
||||||
|
|
||||||
#[cfg(all(feature = "gdbserver", target_os = "none"))]
|
#[cfg(all(feature = "gdbserver", baremetal))]
|
||||||
impl gdbstub::Connection for Uart {
|
impl gdbstub::Connection for Uart {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ impl gdbstub::Connection for Uart {
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
not(test),
|
not(test),
|
||||||
target_os = "none",
|
baremetal,
|
||||||
any(feature = "debug-print", feature = "print-panics")
|
any(feature = "debug-print", feature = "print-panics")
|
||||||
))]
|
))]
|
||||||
pub fn irq(_irq_number: usize, _arg: *mut usize) {
|
pub fn irq(_irq_number: usize, _arg: *mut usize) {
|
||||||
|
|
@ -157,11 +157,11 @@ pub fn irq(_irq_number: usize, _arg: *mut usize) {
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
not(test),
|
not(test),
|
||||||
target_os = "none",
|
baremetal,
|
||||||
any(feature = "debug-print", feature = "print-panics")
|
any(feature = "debug-print", feature = "print-panics")
|
||||||
))]
|
))]
|
||||||
fn process_irq_character(b: u8) {
|
fn process_irq_character(b: u8) {
|
||||||
#[cfg(all(feature = "gdbserver", target_os = "none"))]
|
#[cfg(all(feature = "gdbserver", baremetal))]
|
||||||
if gdb_server::handle(b) {
|
if gdb_server::handle(b) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +257,7 @@ fn process_irq_character(b: u8) {
|
||||||
});
|
});
|
||||||
println!("{} k total", total_bytes / 1024);
|
println!("{} k total", total_bytes / 1024);
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "gdbserver", target_os = "none"))]
|
#[cfg(all(feature = "gdbserver", baremetal))]
|
||||||
b'g' => {
|
b'g' => {
|
||||||
println!("Starting GDB server -- attach your debugger now");
|
println!("Starting GDB server -- attach your debugger now");
|
||||||
gdb_server::setup();
|
gdb_server::setup();
|
||||||
|
|
@ -277,7 +277,7 @@ fn process_irq_character(b: u8) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(baremetal)]
|
||||||
impl Write for Uart {
|
impl Write for Uart {
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
for c in s.bytes() {
|
for c in s.bytes() {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#![cfg_attr(baremetal, no_main)]
|
#![cfg_attr(baremetal, no_main)]
|
||||||
#![cfg_attr(baremetal, no_std)]
|
#![cfg_attr(baremetal, no_std)]
|
||||||
|
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(baremetal)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
|
|
||||||
|
|
@ -28,9 +28,9 @@ mod syscall;
|
||||||
use services::SystemServices;
|
use services::SystemServices;
|
||||||
use xous_kernel::*;
|
use xous_kernel::*;
|
||||||
|
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(baremetal)]
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(baremetal)]
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn handle_panic(_arg: &PanicInfo) -> ! {
|
fn handle_panic(_arg: &PanicInfo) -> ! {
|
||||||
println!("PANIC in PID {}: {}", crate::arch::current_pid(), _arg);
|
println!("PANIC in PID {}: {}", crate::arch::current_pid(), _arg);
|
||||||
|
|
@ -150,7 +150,7 @@ pub extern "C" fn kmain() {
|
||||||
// Note that at this point, no new direct children of INIT may be created.
|
// Note that at this point, no new direct children of INIT may be created.
|
||||||
let mut pid = None;
|
let mut pid = None;
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "none", all(ci, test))))]
|
#[cfg(not(any(target_os = "none", target_os = "xous", all(ci, test))))]
|
||||||
{
|
{
|
||||||
use std::panic;
|
use std::panic;
|
||||||
panic::set_hook(Box::new(|arg| {
|
panic::set_hook(Box::new(|arg| {
|
||||||
|
|
|
||||||
|
|
@ -1914,7 +1914,7 @@ impl SystemServices {
|
||||||
/// within the current process.
|
/// within the current process.
|
||||||
pub fn sidx_from_cid(&self, cid: CID) -> Option<usize> {
|
pub fn sidx_from_cid(&self, cid: CID) -> Option<usize> {
|
||||||
// println!("KERNEL({}): Attempting to get SIDX from CID {}", crate::arch::process::current_pid(), cid);
|
// println!("KERNEL({}): Attempting to get SIDX from CID {}", crate::arch::process::current_pid(), cid);
|
||||||
if cid == 0 || cid == 1 {
|
if cid < 2 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1930,8 +1930,9 @@ impl SystemServices {
|
||||||
// println!("KERNEL({}): CID {} doesn't exist in the connection map", crate::arch::process::current_pid(), cid + 2);
|
// println!("KERNEL({}): CID {} doesn't exist in the connection map", crate::arch::process::current_pid(), cid + 2);
|
||||||
// println!("KERNEL({}): Process inner is: {:?}", crate::arch::process::current_pid(), process_inner);
|
// println!("KERNEL({}): Process inner is: {:?}", crate::arch::process::current_pid(), process_inner);
|
||||||
// }
|
// }
|
||||||
let mut server_idx = process_inner.connection_map[cid as usize]?.get() as usize;
|
let connection_value = *process_inner.connection_map.get(cid as usize)?;
|
||||||
if server_idx == 1 {
|
let mut server_idx = connection_value?.get() as usize;
|
||||||
|
if server_idx < 2 {
|
||||||
// println!("KERNEL({}): CID {} is no longer valid", crate::arch::process::current_pid(), cid + 2);
|
// println!("KERNEL({}): CID {} is no longer valid", crate::arch::process::current_pid(), cid + 2);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -600,7 +600,8 @@ fn receive_message(pid: PID, tid: TID, sid: SID, blocking: ExecutionType) -> Sys
|
||||||
pub fn handle(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult {
|
pub fn handle(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult {
|
||||||
#[cfg(feature = "debug-print")]
|
#[cfg(feature = "debug-print")]
|
||||||
print!("KERNEL({}:{}): Syscall {:x?}", pid, tid, call);
|
print!("KERNEL({}:{}): Syscall {:x?}", pid, tid, call);
|
||||||
|
// let call_string = format!("{:x?}", call);
|
||||||
|
// let start_time = std::time::Instant::now();
|
||||||
#[allow(clippy::let_and_return)]
|
#[allow(clippy::let_and_return)]
|
||||||
let result = if in_irq && !call.can_call_from_interrupt() {
|
let result = if in_irq && !call.can_call_from_interrupt() {
|
||||||
Err(xous_kernel::Error::InvalidSyscall)
|
Err(xous_kernel::Error::InvalidSyscall)
|
||||||
|
|
@ -608,6 +609,8 @@ pub fn handle(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallResult
|
||||||
handle_inner(pid, tid, in_irq, call)
|
handle_inner(pid, tid, in_irq, call)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// println!("KERNEL [{:2}:{:2}] Syscall took {:7} usec: {}", pid, tid, start_time.elapsed().as_micros(), call_string);
|
||||||
|
|
||||||
#[cfg(feature = "debug-print")]
|
#[cfg(feature = "debug-print")]
|
||||||
println!(
|
println!(
|
||||||
" -> ({}:{}) {:x?}",
|
" -> ({}:{}) {:x?}",
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
#![cfg_attr(target_os = "none", no_std)]
|
#![cfg_attr(any(target_os = "none", target_os = "xous"), no_std)]
|
||||||
pub mod generated;
|
pub mod generated;
|
||||||
pub use generated::*;
|
pub use generated::*;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue