Skip to main content

read_ptr

Function read_ptr 

Source
pub unsafe fn read_ptr(buffer: PhysicalAddress<[u8]>) -> Result<usize, SbiError>
Expand description

A convenience wrapper for debug_console_read which takes a single non-null slice instead of the manual length and address parameters. This slice MUST point into physical memory, and any pointers which are virtual pointers that overlap with the physical address space can cause undefined behavior.

This function is not appropriate to call for platforms where the amount of physical memory can exceed the pointer size.

§Safety

This function is marked unsafe as it allows arbitrary writes to physical memory which can cause undefined behavior if misused.

§Possible errors

SbiError::INVALID_PARAMETER: The memory region described by the given pointer is not accessible to supervisor mode.

SbiError::DENIED: Writing to the debug console is not allowed.

SbiError::FAILED: Writing failed due to I/O errors.