Zephyr API Documentation  3.7.0-rc3
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Device memory-mapped IO management

Definitions and helper macros for managing driver memory-mapped input/output (MMIO) regions appropriately in either RAM or ROM. More...

Modules

 Named MMIO region macros
 For drivers which need to manage multiple MMIO regions, which will be referenced by name.
 
 Single MMIO region macros
 For drivers which need to manage just one MMIO region, the most common case.
 
 Top-level MMIO region macros
 For drivers which do not use Zephyr's driver model and do not associate struct device with a driver instance.
 

Macros

#define DEVICE_MMIO_IS_IN_RAM
 

Functions

static __boot_func void device_map (mm_reg_t *virt_addr, uintptr_t phys_addr, size_t size, uint32_t flags)
 Set linear address for device MMIO access.
 

Detailed Description

Definitions and helper macros for managing driver memory-mapped input/output (MMIO) regions appropriately in either RAM or ROM.

In most cases drivers will just want to include device.h, but including this separately may be needed for arch-level driver code which uses the DEVICE_MMIO_TOPLEVEL variants and including the main device.h would introduce header dependency loops due to that header's reliance on kernel.h.

Macro Definition Documentation

◆ DEVICE_MMIO_IS_IN_RAM

#define DEVICE_MMIO_IS_IN_RAM

Function Documentation

◆ device_map()

static __boot_func void device_map ( mm_reg_t virt_addr,
uintptr_t  phys_addr,
size_t  size,
uint32_t  flags 
)
inlinestatic

#include <zephyr/sys/device_mmio.h>

Set linear address for device MMIO access.

This function sets the virt_addr parameter to the correct linear address for the MMIO region.

If the MMU is enabled, mappings may be created in the page tables.

Normally, only a caching mode needs to be set for the 'flags' parameter. The mapped linear address will have read-write access to supervisor mode.

See also
k_map()
Parameters
[out]virt_addrOutput linear address storage location, most users will want some DEVICE_MMIO_RAM_PTR() value
[in]phys_addrPhysical address base of the MMIO region
[in]sizeSize of the MMIO region
[in]flagsCaching mode and access flags, see K_MEM_CACHE_* and K_MEM_PERM_* macros