Function esp_idf_svc::hal::sys::vTaskAllocateMPURegions
source ยท pub unsafe extern "C" fn vTaskAllocateMPURegions(
xTask: *mut tskTaskControlBlock,
pxRegions: *const xMEMORY_REGION,
)
Expand description
Memory regions are assigned to a restricted task when the task is created by a call to xTaskCreateRestricted(). These regions can be redefined using vTaskAllocateMPURegions().
@param xTask The handle of the task being updated.
@param pxRegions A pointer to a MemoryRegion_t structure that contains the new memory region definitions.
Example usage: @code{c} // Define an array of MemoryRegion_t structures that configures an MPU region // allowing read/write access for 1024 bytes starting at the beginning of the // ucOneKByte array. The other two of the maximum 3 definable regions are // unused so set to zero. static const MemoryRegion_t xAltRegions portNUM_CONFIGURABLE_REGIONS = { // Base address Length Parameters { ucOneKByte, 1024, portMPU_REGION_READ_WRITE }, { 0, 0, 0 }, { 0, 0, 0 } };
void vATask( void *pvParameters ) { // This task was created such that it has access to certain regions of // memory as defined by the MPU configuration. At some point it is // desired that these MPU regions are replaced with that defined in the // xAltRegions const struct above. Use a call to vTaskAllocateMPURegions() // for this purpose. NULL is used as the task handle to indicate that this // function should modify the MPU regions of the calling task. vTaskAllocateMPURegions( NULL, xAltRegions );
// Now the task can continue its function, but from this point on can only // access its stack and the ucOneKByte array (unless any other statically // defined or shared regions have been declared elsewhere). } @endcode \ingroup Tasks