15#ifndef ZEPHYR_INCLUDE_SYS_DEVICE_MMIO_H
16#define ZEPHYR_INCLUDE_SYS_DEVICE_MMIO_H
36#if defined(CONFIG_MMU) || defined(CONFIG_PCIE)
37#define DEVICE_MMIO_IS_IN_RAM
46#ifdef DEVICE_MMIO_IS_IN_RAM
51struct z_device_mmio_rom {
59#define Z_DEVICE_MMIO_ROM_INITIALIZER(node_id) \
61 .phys_addr = DT_REG_ADDR(node_id), \
62 .size = DT_REG_SIZE(node_id) \
93 z_phys_map((
uint8_t **)virt_addr, phys_addr, size,
99 *virt_addr = phys_addr;
106struct z_device_mmio_rom {
111#define Z_DEVICE_MMIO_ROM_INITIALIZER(node_id) \
113 .addr = DT_REG_ADDR(node_id) \
156#ifdef DEVICE_MMIO_IS_IN_RAM
157#define DEVICE_MMIO_RAM mm_reg_t _mmio
159#define DEVICE_MMIO_RAM
162#ifdef DEVICE_MMIO_IS_IN_RAM
175#define DEVICE_MMIO_RAM_PTR(device) (mm_reg_t *)((device)->data)
206#define DEVICE_MMIO_ROM struct z_device_mmio_rom _mmio
219#define DEVICE_MMIO_ROM_PTR(dev) \
220 ((struct z_device_mmio_rom *)((dev)->config))
242#define DEVICE_MMIO_ROM_INIT(node_id) \
243 ._mmio = Z_DEVICE_MMIO_ROM_INITIALIZER(node_id)
261#ifdef DEVICE_MMIO_IS_IN_RAM
262#define DEVICE_MMIO_MAP(dev, flags) \
263 device_map(DEVICE_MMIO_RAM_PTR(dev), \
264 DEVICE_MMIO_ROM_PTR(dev)->phys_addr, \
265 DEVICE_MMIO_ROM_PTR(dev)->size, \
268#define DEVICE_MMIO_MAP(dev, flags) do { } while (0)
290#ifdef DEVICE_MMIO_IS_IN_RAM
291#define DEVICE_MMIO_GET(dev) (*DEVICE_MMIO_RAM_PTR(dev))
293#define DEVICE_MMIO_GET(dev) (DEVICE_MMIO_ROM_PTR(dev)->addr)
337#ifdef DEVICE_MMIO_IS_IN_RAM
338#define DEVICE_MMIO_NAMED_RAM(name) mm_reg_t name
340#define DEVICE_MMIO_NAMED_RAM(name)
343#ifdef DEVICE_MMIO_IS_IN_RAM
356#define DEVICE_MMIO_NAMED_RAM_PTR(dev, name) \
357 (&(DEV_DATA(dev)->name))
393#define DEVICE_MMIO_NAMED_ROM(name) struct z_device_mmio_rom name
409#define DEVICE_MMIO_NAMED_ROM_PTR(dev, name) (&(DEV_CFG(dev)->name))
435#define DEVICE_MMIO_NAMED_ROM_INIT(name, node_id) \
436 .name = Z_DEVICE_MMIO_ROM_INITIALIZER(node_id)
466#ifdef DEVICE_MMIO_IS_IN_RAM
467#define DEVICE_MMIO_NAMED_MAP(dev, name, flags) \
468 device_map(DEVICE_MMIO_NAMED_RAM_PTR((dev), name), \
469 (DEVICE_MMIO_NAMED_ROM_PTR((dev), name)->phys_addr), \
470 (DEVICE_MMIO_NAMED_ROM_PTR((dev), name)->size), \
473#define DEVICE_MMIO_NAMED_MAP(dev, name, flags) do { } while (0)
497#ifdef DEVICE_MMIO_IS_IN_RAM
498#define DEVICE_MMIO_NAMED_GET(dev, name) \
499 (*DEVICE_MMIO_NAMED_RAM_PTR((dev), name))
501#define DEVICE_MMIO_NAMED_GET(dev, name) \
502 ((DEVICE_MMIO_NAMED_ROM_PTR((dev), name))->addr)
524 #define Z_TOPLEVEL_ROM_NAME(name) _CONCAT(z_mmio_rom__, name)
525 #define Z_TOPLEVEL_RAM_NAME(name) _CONCAT(z_mmio_ram__, name)
542#ifdef DEVICE_MMIO_IS_IN_RAM
543#define DEVICE_MMIO_TOPLEVEL(name, node_id) \
545 mm_reg_t Z_TOPLEVEL_RAM_NAME(name); \
547 const struct z_device_mmio_rom Z_TOPLEVEL_ROM_NAME(name) = \
548 Z_DEVICE_MMIO_ROM_INITIALIZER(node_id)
550#define DEVICE_MMIO_TOPLEVEL(name, node_id) \
552 const struct z_device_mmio_rom Z_TOPLEVEL_ROM_NAME(name) = \
553 Z_DEVICE_MMIO_ROM_INITIALIZER(node_id)
570#ifdef DEVICE_MMIO_IS_IN_RAM
571#define DEVICE_MMIO_TOPLEVEL_DECLARE(name) \
572 extern mm_reg_t Z_TOPLEVEL_RAM_NAME(name); \
573 extern const struct z_device_mmio_rom Z_TOPLEVEL_ROM_NAME(name)
575#define DEVICE_MMIO_TOPLEVEL_DECLARE(name) \
576 extern const struct z_device_mmio_rom Z_TOPLEVEL_ROM_NAME(name)
593#ifdef DEVICE_MMIO_IS_IN_RAM
594#define DEVICE_MMIO_TOPLEVEL_STATIC(name, node_id) \
596 static mm_reg_t Z_TOPLEVEL_RAM_NAME(name); \
598 static const struct z_device_mmio_rom Z_TOPLEVEL_ROM_NAME(name) = \
599 Z_DEVICE_MMIO_ROM_INITIALIZER(node_id)
601#define DEVICE_MMIO_TOPLEVEL_STATIC(name, node_id) \
603 static const struct z_device_mmio_rom Z_TOPLEVEL_ROM_NAME(name) = \
604 Z_DEVICE_MMIO_ROM_INITIALIZER(node_id)
607#ifdef DEVICE_MMIO_IS_IN_RAM
617#define DEVICE_MMIO_TOPLEVEL_RAM_PTR(name) &Z_TOPLEVEL_RAM_NAME(name)
628#define DEVICE_MMIO_TOPLEVEL_ROM_PTR(name) &Z_TOPLEVEL_ROM_NAME(name)
651#ifdef DEVICE_MMIO_IS_IN_RAM
652#define DEVICE_MMIO_TOPLEVEL_MAP(name, flags) \
653 device_map(&Z_TOPLEVEL_RAM_NAME(name), \
654 Z_TOPLEVEL_ROM_NAME(name).phys_addr, \
655 Z_TOPLEVEL_ROM_NAME(name).size, flags)
657#define DEVICE_MMIO_TOPLEVEL_MAP(name, flags) do { } while (0)
670#ifdef DEVICE_MMIO_IS_IN_RAM
671#define DEVICE_MMIO_TOPLEVEL_GET(name) \
672 ((mm_reg_t)Z_TOPLEVEL_RAM_NAME(name))
674#define DEVICE_MMIO_TOPLEVEL_GET(name) \
675 ((mm_reg_t)Z_TOPLEVEL_ROM_NAME(name).addr)
Common toolchain abstraction.
static __boot_func void device_map(mm_reg_t *virt_addr, uintptr_t phys_addr, size_t size, uint32_t flags)
Definition: device_mmio.h:86
flags
Definition: http_parser.h:131
#define K_MEM_PERM_RW
Definition: mem_manage.h:34
Definitions of various linker Sections.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:75
uintptr_t mm_reg_t
Definition: sys_io.h:20