Nothing to see here, move along
1use crate::cap::boot_untyped;
2use crate::proc::context::CpuContext;
3
4use super::{SyscallResult, try_syscall};
5
6pub fn sys_boot_untyped_info(ctx: &mut CpuContext) {
7 let pid = crate::arch::syscall::current_pid();
8 if pid != crate::types::Pid::INIT {
9 ctx.rax = SyscallResult::error(crate::error::KernelError::PermissionDenied).raw();
10 return;
11 }
12
13 let index = ctx.rdi;
14
15 let meta = try_syscall!(
16 ctx,
17 boot_untyped::metadata().ok_or(crate::error::KernelError::NotInitialized)
18 );
19
20 if index == u64::MAX {
21 ctx.rax = SyscallResult::success(meta.len() as u64).raw();
22 return;
23 }
24
25 let idx = try_syscall!(ctx, super::u32_from_reg(index)) as usize;
26 if idx >= meta.len() {
27 ctx.rax = SyscallResult::error(crate::error::KernelError::InvalidParameter).raw();
28 return;
29 }
30
31 let info = &meta.as_slice()[idx];
32 ctx.rax = SyscallResult::success(info.cnode_slot).raw();
33 ctx.rsi = info.phys_base;
34 ctx.rdx = (info.size_bits as u64) | ((info.is_device as u64) << 8);
35}