#[no_mangle]
pub extern "C" fn xila_memory_flush_instruction_cache(
_address: *mut c_void,
_size: usize,
)
Expand description
Flushes the instruction cache for a specific memory region.
This function invalidates the instruction cache for the specified memory region. This is necessary after modifying executable code to ensure the processor sees the updated instructions.
§Safety
- The address must point to valid memory
- The memory region must not be accessed for execution during the flush operation
- The size should not exceed the actual allocated memory size
§Parameters
Address
- Starting address of the memory region to flushSize
- Size of the memory region in bytes
§Examples
// After writing machine code to executable memory
void* code_ptr = xila_memory_allocate(NULL, 4096, 4096, XILA_MEMORY_CAPABILITIES_EXECUTE);
memcpy(code_ptr, machine_code, code_size);
xila_memory_flush_instruction_cache(code_ptr, code_size);
// Now safe to execute the code
((void(*)())code_ptr)();