refactor: remove/clarify some todo!
This commit is contained in:
parent
32677721f9
commit
67cf3673ca
@ -520,9 +520,12 @@ impl CurrentThread {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn handle_single_step<F: TaskFrame>(&self, frame: &mut F) {
|
||||
pub fn handle_single_step<F: TaskFrame>(&self, frame: &mut F) -> bool {
|
||||
{
|
||||
let mut debug = self.debug.lock();
|
||||
if debug.debugger.is_none() {
|
||||
return false;
|
||||
}
|
||||
let space = self.address_space();
|
||||
|
||||
if let Some(original) = debug.restore_breakpoint.take() {
|
||||
@ -540,7 +543,7 @@ impl CurrentThread {
|
||||
if !debug.single_step {
|
||||
log::debug!("Clear single step ({} {:?})", self.id, self.name);
|
||||
frame.set_single_step(false);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -552,7 +555,7 @@ impl CurrentThread {
|
||||
}
|
||||
|
||||
match self.suspend() {
|
||||
Ok(_) | Err(Error::Interrupted) => (),
|
||||
Ok(_) | Err(Error::Interrupted) => true,
|
||||
Err(err) => panic!("TODO: handle error in debug suspend: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ use crate::{
|
||||
unsafe fn pre_init_mmu() {
|
||||
if ID_AA64MMFR0_EL1.matches_all(ID_AA64MMFR0_EL1::TGran4::NotSupported) {
|
||||
// TODO early panic
|
||||
todo!();
|
||||
loop {}
|
||||
}
|
||||
|
||||
MAIR_EL1.write(
|
||||
|
@ -127,12 +127,12 @@ extern "C" fn __aa64_el0_irq_handler(frame: *mut ExceptionFrame) {
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn __aa64_el0_fiq_handler() {
|
||||
todo!();
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn __aa64_el0_serror_handler() {
|
||||
todo!();
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
// EL1
|
||||
@ -159,19 +159,20 @@ extern "C" fn __aa64_el1_irq_handler(_frame: *mut ExceptionFrame) {
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn __aa64_el1_fiq_handler() {
|
||||
todo!();
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn __aa64_el1_serror_handler() {
|
||||
todo!();
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn el0_sync_inner(frame: &mut ExceptionFrame) {
|
||||
let esr_el1 = ESR_EL1.get();
|
||||
let ec = (esr_el1 >> 26) & 0x3F;
|
||||
let iss = esr_el1 & 0x1FFFFFF;
|
||||
|
||||
match ec {
|
||||
let dump = match ec {
|
||||
// SVC in AArch64
|
||||
0b010101 => {
|
||||
let func = frame.r[8];
|
||||
@ -185,25 +186,30 @@ fn el0_sync_inner(frame: &mut ExceptionFrame) {
|
||||
let args = &frame.r[0..6];
|
||||
let result = raw_syscall_handler(func, args) as _;
|
||||
frame.r[0] = result;
|
||||
false
|
||||
}
|
||||
// Software Step from lower Exception Level
|
||||
0b110010 => {
|
||||
let thread = Thread::current();
|
||||
|
||||
thread.handle_single_step(frame);
|
||||
|
||||
// Make the PE actually step the instruction
|
||||
frame.spsr_el1 |= 1 << 21;
|
||||
if thread.handle_single_step(frame) {
|
||||
// Make the PE actually step the instruction
|
||||
frame.spsr_el1 |= 1 << 21;
|
||||
false
|
||||
} else {
|
||||
thread.raise_signal(Signal::Aborted);
|
||||
true
|
||||
}
|
||||
}
|
||||
// BRK in AArch64
|
||||
0b111100 => {
|
||||
let thread = Thread::current();
|
||||
warnln!("Thread {} {:?} hit a breakpoint", thread.id, thread.name);
|
||||
thread.raise_signal(Signal::Aborted);
|
||||
true
|
||||
}
|
||||
_ => {
|
||||
let thread = Thread::current();
|
||||
let iss = esr_el1 & 0x1FFFFFF;
|
||||
if ec == 0b100100 {
|
||||
// Data abort from lower level
|
||||
let thread = Thread::current();
|
||||
@ -215,10 +221,14 @@ fn el0_sync_inner(frame: &mut ExceptionFrame) {
|
||||
FAR_EL1.get()
|
||||
);
|
||||
}
|
||||
dump_irrecoverable_exception(frame, ec, iss);
|
||||
|
||||
thread.raise_signal(Signal::MemoryAccessViolation);
|
||||
true
|
||||
}
|
||||
};
|
||||
|
||||
if dump {
|
||||
dump_irrecoverable_exception(frame, ec, iss);
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,20 +236,4 @@ fn irq_common() {
|
||||
external_interrupt_controller().handle_pending_irqs();
|
||||
}
|
||||
|
||||
// unsafe fn handle_signal_exit(frame: &mut ExceptionFrame) {
|
||||
// let saved_data: &SignalEntryData = match syscall::arg::ref_const(frame.r[0] as _) {
|
||||
// Ok(r) => r,
|
||||
// Err(err) => {
|
||||
// todo!("Invalid SignalEntryData pointer: {:?}", err)
|
||||
// }
|
||||
// };
|
||||
// debugln!(
|
||||
// "Handling signal exit to pc={:#x}, sp={:#x}",
|
||||
// saved_data.frame.elr_el1,
|
||||
// saved_data.frame.sp_el0
|
||||
// );
|
||||
//
|
||||
// frame.restore(&saved_data.frame);
|
||||
// }
|
||||
|
||||
global_asm!(include_str!("vectors.S"));
|
||||
|
@ -127,7 +127,7 @@ impl Gicd {
|
||||
match reg {
|
||||
// Private IRQs
|
||||
0..=1 => {
|
||||
todo!();
|
||||
unimplemented!()
|
||||
}
|
||||
// Shared IRQs
|
||||
_ => {
|
||||
|
@ -149,7 +149,7 @@ impl ExternalInterruptController for Gic {
|
||||
|
||||
impl MessageInterruptController for Gic {
|
||||
fn handle_msi(&self, _vector: usize) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn register_msi_range(
|
||||
@ -157,7 +157,7 @@ impl MessageInterruptController for Gic {
|
||||
_range: &mut [MsiInfo],
|
||||
_handler: &'static dyn InterruptHandler,
|
||||
) -> Result<(), Error> {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ impl LocalInterruptController for Gic {
|
||||
let mask = match target {
|
||||
IpiDeliveryTarget::OtherCpus => usize::MAX & !(1 << local),
|
||||
IpiDeliveryTarget::Specific(mask) => mask,
|
||||
IpiDeliveryTarget::ThisCpu => todo!(),
|
||||
IpiDeliveryTarget::ThisCpu => 1 << local,
|
||||
};
|
||||
|
||||
for i in 0..CPU_COUNT.load(Ordering::Acquire) {
|
||||
|
@ -144,7 +144,7 @@ impl AArch64 {
|
||||
) -> Result<(), Error> {
|
||||
let end_l1i = memory_end.page_align_up::<L1>().page_index::<L1>();
|
||||
if end_l1i > RAM_MAPPING_L1_COUNT {
|
||||
todo!()
|
||||
panic!("TODO: partial physical memory mapping");
|
||||
}
|
||||
|
||||
// Map 1GiB chunks
|
||||
|
@ -17,11 +17,6 @@ static AP_TRAMPOLINE_STACK: BootStack<BOOT_STACK_SIZE> = BootStack::zeroed();
|
||||
#[derive(Debug)]
|
||||
enum CpuEnableMethod {
|
||||
Psci,
|
||||
// Not currently supported
|
||||
#[allow(dead_code)]
|
||||
SpinTable {
|
||||
release_addr: usize,
|
||||
},
|
||||
}
|
||||
|
||||
struct CpuInfo<'a> {
|
||||
@ -39,7 +34,14 @@ fn enumerate_cpus<'a>(dt: &'a DeviceTree) -> impl Iterator<Item = CpuInfo<'a>> {
|
||||
let enable_method_str: &str = cpu_node.prop("enable-method")?;
|
||||
let enable_method = match enable_method_str {
|
||||
"psci" => CpuEnableMethod::Psci,
|
||||
_ => todo!(),
|
||||
_ => {
|
||||
log::warn!(
|
||||
"Cannot enable cpu #{}: enable-method={:?} unsupported",
|
||||
id,
|
||||
enable_method_str
|
||||
);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
Some(CpuInfo {
|
||||
@ -64,7 +66,6 @@ impl CpuEnableMethod {
|
||||
|
||||
psci.start_cpu(id, ip, sp)
|
||||
}
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,13 +194,17 @@ fn user_exception_inner(kind: ExceptionKind, frame: &mut ExceptionFrame) {
|
||||
true
|
||||
}
|
||||
ExceptionKind::Debug => {
|
||||
// TODO check if the thread was really in single-step mode or has debugging related to
|
||||
// the address in exception description
|
||||
thread.handle_single_step(frame);
|
||||
false
|
||||
if thread.handle_single_step(frame) {
|
||||
false
|
||||
} else {
|
||||
thread.raise_signal(Signal::Aborted);
|
||||
true
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
todo!()
|
||||
log::warn!("No handler for exception: {:?}", kind);
|
||||
thread.raise_signal(Signal::Aborted);
|
||||
true
|
||||
}
|
||||
};
|
||||
|
||||
@ -234,7 +238,7 @@ extern "C" fn __i686_syscall_handler(frame: *mut SyscallFrame) {
|
||||
}
|
||||
}
|
||||
if frame.eax == usize::from(SyscallFunction::Fork) {
|
||||
todo!()
|
||||
todo!("Implement fork()")
|
||||
// unsafe {
|
||||
// Process::raw_fork(frame);
|
||||
// return;
|
||||
|
@ -96,7 +96,7 @@ impl Platform for I686 {
|
||||
}
|
||||
|
||||
fn register_reset_device(&self, _reset: &'static dyn ResetDevice) -> Result<(), Error> {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ impl Device for IoApic {
|
||||
}
|
||||
|
||||
unsafe fn init(&'static self) -> Result<(), Error> {
|
||||
todo!()
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,13 +292,13 @@ impl LocalInterruptController for LocalApic {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
IpiDeliveryTarget::ThisCpu => todo!(),
|
||||
IpiDeliveryTarget::Specific(_) => todo!(),
|
||||
IpiDeliveryTarget::ThisCpu => unimplemented!(),
|
||||
IpiDeliveryTarget::Specific(_) => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn init_ap(&self) -> Result<(), Error> {
|
||||
todo!()
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ pub fn setup_vectors(idt: &mut [exception::Entry]) {
|
||||
|
||||
unsafe extern "C" fn irq_handler(vector: usize, frame: *mut IrqFrame) {
|
||||
if vector >= POPULATED_EXTERNAL_VECTORS as _ {
|
||||
todo!("Got a weird IRQ with vector {}", vector);
|
||||
unreachable!("Got a weird IRQ with vector {}", vector);
|
||||
}
|
||||
|
||||
let cpu = Cpu::local();
|
||||
@ -76,7 +76,7 @@ unsafe extern "C" fn irq_handler(vector: usize, frame: *mut IrqFrame) {
|
||||
|
||||
unsafe extern "C" fn msi_handler(vector: usize, frame: *mut IrqFrame) {
|
||||
if vector >= MAX_MSI_VECTORS as _ {
|
||||
todo!("Got a weird MSI with vector {}", vector);
|
||||
unreachable!("Got a weird MSI with vector {}", vector);
|
||||
}
|
||||
|
||||
let cpu = Cpu::local();
|
||||
@ -106,7 +106,7 @@ unsafe extern "C" fn local_timer_irq_handler(frame: *mut IrqFrame) {
|
||||
}
|
||||
|
||||
unsafe extern "C" fn dummy_irq_handler() {
|
||||
todo!()
|
||||
unreachable!("dummy_irq_handler entered")
|
||||
}
|
||||
|
||||
unsafe extern "C" fn ipi_handler() {
|
||||
|
@ -129,10 +129,12 @@ fn user_exception_inner(kind: ExceptionKind, frame: &mut ExceptionFrame) {
|
||||
|
||||
let dump = match kind {
|
||||
ExceptionKind::Debug => {
|
||||
// TODO check if the thread was really in single-step mode or has debugging related to
|
||||
// the address in exception description
|
||||
thread.handle_single_step(frame);
|
||||
false
|
||||
if thread.handle_single_step(frame) {
|
||||
false
|
||||
} else {
|
||||
thread.raise_signal(Signal::Aborted);
|
||||
true
|
||||
}
|
||||
}
|
||||
ExceptionKind::PageFault => {
|
||||
thread.raise_signal(Signal::MemoryAccessViolation);
|
||||
@ -147,7 +149,8 @@ fn user_exception_inner(kind: ExceptionKind, frame: &mut ExceptionFrame) {
|
||||
}
|
||||
}
|
||||
ExceptionKind::FpuException => {
|
||||
todo!()
|
||||
thread.raise_signal(Signal::Aborted);
|
||||
true
|
||||
}
|
||||
ExceptionKind::InvalidOpcode => {
|
||||
// TODO handle ud2 as breakpoint? (it's 2 bytes)
|
||||
@ -155,13 +158,18 @@ fn user_exception_inner(kind: ExceptionKind, frame: &mut ExceptionFrame) {
|
||||
true
|
||||
}
|
||||
ExceptionKind::Breakpoint => {
|
||||
todo!()
|
||||
thread.raise_signal(Signal::Aborted);
|
||||
true
|
||||
}
|
||||
ExceptionKind::SimdFpuException => {
|
||||
thread.raise_signal(Signal::MemoryAccessViolation);
|
||||
true
|
||||
}
|
||||
_ => todo!("No handler for exception: {:?}", kind),
|
||||
_ => {
|
||||
log::warn!("No handler for exception: {:?}", kind);
|
||||
thread.raise_signal(Signal::Aborted);
|
||||
true
|
||||
}
|
||||
};
|
||||
|
||||
if dump {
|
||||
|
@ -45,6 +45,7 @@ use crate::{
|
||||
display::{console, fb_console::FramebufferConsole, linear_fb::LinearFramebuffer},
|
||||
},
|
||||
fs::{Initrd, INITRD_DATA},
|
||||
panic::panic_secondary,
|
||||
};
|
||||
|
||||
use self::{
|
||||
@ -99,9 +100,11 @@ impl Platform for X86_64 {
|
||||
}
|
||||
|
||||
impl X86_64 {
|
||||
unsafe fn handle_ipi(&self, _msg: IpiMessage) {
|
||||
warnln!("Received an IPI");
|
||||
todo!();
|
||||
unsafe fn handle_ipi(&self, msg: IpiMessage) {
|
||||
match msg {
|
||||
IpiMessage::Panic => panic_secondary(),
|
||||
IpiMessage::Shutdown => unimplemented!("TODO: ACPI shutdown"),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_boot_data(&self, data: BootData) {
|
||||
@ -146,7 +149,7 @@ impl X86_64 {
|
||||
.page_index::<L1>();
|
||||
|
||||
if end_l1i > 512 {
|
||||
todo!(
|
||||
panic!(
|
||||
"Cannot handle {}GiB of RAM",
|
||||
end_l1i * L1::SIZE / (1024 * 1024 * 1024)
|
||||
);
|
||||
|
@ -66,7 +66,7 @@ pub(crate) fn load_module(path: &str) -> Result<(), Error> {
|
||||
let file = run_with_io(&process, |mut io| {
|
||||
let path: &Path = path.as_ref();
|
||||
if !path.is_absolute() {
|
||||
todo!();
|
||||
return Err(Error::InvalidArgument);
|
||||
}
|
||||
io.ioctx_mut().open_executable(path)
|
||||
})?;
|
||||
|
@ -31,6 +31,9 @@ pub(crate) fn debug_control(pid: ProcessId, op: &mut DebugOperation) -> Result<(
|
||||
target_thread.read_memory(*address, buffer)
|
||||
}
|
||||
DebugOperation::WriteMemory { .. } => todo!(),
|
||||
_ => todo!(),
|
||||
_ => {
|
||||
log::warn!("Unsupported debug operation: {:?}", op);
|
||||
Err(Error::InvalidOperation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user