kernel: mm: rename Z_KERNEL_VIRT_* to K_MEM_KERNEL_VIRT_*

Renames:
  Z_KERNEL_VIRT_START to K_MEM_KERNEL_VIRT_START
  Z_KERNEL_VIRT_SIZE to K_MEM_KERNEL_VIRT_SIZE
  Z_KERNEL_VIRT_END to K_MEM_KERNEL_VIRT_END

This is part of a series to move memory management related
stuff from Z_ namespace into its own namespace.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2024-06-07 09:48:08 -07:00 committed by Anas Nashif
commit b2784c9145
4 changed files with 20 additions and 16 deletions

View file

@ -75,7 +75,7 @@ below.
+--------------+ <- K_MEM_VIRT_RAM_START +--------------+ <- K_MEM_VIRT_RAM_START
| Undefined VM | <- architecture specific reserved area | Undefined VM | <- architecture specific reserved area
+--------------+ <- Z_KERNEL_VIRT_START +--------------+ <- K_MEM_KERNEL_VIRT_START
| Mapping for | | Mapping for |
| main kernel | | main kernel |
| image | | image |
@ -108,11 +108,11 @@ below.
* ``K_MEM_VIRT_RAM_END`` is simply (``K_MEM_VIRT_RAM_START`` + ``K_MEM_VIRT_RAM_SIZE``). * ``K_MEM_VIRT_RAM_END`` is simply (``K_MEM_VIRT_RAM_START`` + ``K_MEM_VIRT_RAM_SIZE``).
* ``Z_KERNEL_VIRT_START`` is the same as ``z_mapped_start`` specified in the linker * ``K_MEM_KERNEL_VIRT_START`` is the same as ``z_mapped_start`` specified in the linker
script. This is the virtual address of the beginning of the kernel image at script. This is the virtual address of the beginning of the kernel image at
boot time. boot time.
* ``Z_KERNEL_VIRT_END`` is the same as ``z_mapped_end`` specified in the linker * ``K_MEM_KERNEL_VIRT_END`` is the same as ``z_mapped_end`` specified in the linker
script. This is the virtual address of the end of the kernel image at boot time. script. This is the virtual address of the end of the kernel image at boot time.
* ``Z_FREE_VM_START`` is the beginning of the virtual address space where addresses * ``Z_FREE_VM_START`` is the beginning of the virtual address space where addresses
@ -123,7 +123,7 @@ below.
memory address space, and it is the same as memory address space, and it is the same as
(:kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` + :kconfig:option:`CONFIG_SRAM_SIZE`). (:kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` + :kconfig:option:`CONFIG_SRAM_SIZE`).
* If it is disabled, ``Z_FREE_VM_START`` is the same ``Z_KERNEL_VIRT_END`` which * If it is disabled, ``Z_FREE_VM_START`` is the same ``K_MEM_KERNEL_VIRT_END`` which
is the end of the kernel image. is the end of the kernel image.
* ``Z_VM_RESERVED`` is an area reserved to support kernel functions. For example, * ``Z_VM_RESERVED`` is an area reserved to support kernel functions. For example,

View file

@ -46,10 +46,14 @@
/** End address (exclusive) of virtual memory. */ /** End address (exclusive) of virtual memory. */
#define K_MEM_VIRT_RAM_END (K_MEM_VIRT_RAM_START + K_MEM_VIRT_RAM_SIZE) #define K_MEM_VIRT_RAM_END (K_MEM_VIRT_RAM_START + K_MEM_VIRT_RAM_SIZE)
/* Boot-time virtual location of the kernel image. */ /** Boot-time virtual start address of the kernel image. */
#define Z_KERNEL_VIRT_START ((uint8_t *)&z_mapped_start[0]) #define K_MEM_KERNEL_VIRT_START ((uint8_t *)&z_mapped_start[0])
#define Z_KERNEL_VIRT_END ((uint8_t *)&z_mapped_end[0])
#define Z_KERNEL_VIRT_SIZE (Z_KERNEL_VIRT_END - Z_KERNEL_VIRT_START) /** Boot-time virtual end address of the kernel image. */
#define K_MEM_KERNEL_VIRT_END ((uint8_t *)&z_mapped_end[0])
/** Boot-time virtual address space size of the kernel image. */
#define K_MEM_KERNEL_VIRT_SIZE (K_MEM_KERNEL_VIRT_END - K_MEM_KERNEL_VIRT_START)
/** /**
* @brief Offset for translating between static physical and virtual addresses. * @brief Offset for translating between static physical and virtual addresses.
@ -89,7 +93,7 @@
#ifdef CONFIG_ARCH_MAPS_ALL_RAM #ifdef CONFIG_ARCH_MAPS_ALL_RAM
#define Z_FREE_VM_START K_MEM_BOOT_PHYS_TO_VIRT(K_MEM_PHYS_RAM_END) #define Z_FREE_VM_START K_MEM_BOOT_PHYS_TO_VIRT(K_MEM_PHYS_RAM_END)
#else #else
#define Z_FREE_VM_START Z_KERNEL_VIRT_END #define Z_FREE_VM_START K_MEM_KERNEL_VIRT_END
#endif /* CONFIG_ARCH_MAPS_ALL_RAM */ #endif /* CONFIG_ARCH_MAPS_ALL_RAM */
/* /*

View file

@ -147,8 +147,8 @@ void z_page_frames_dump(void)
* Call all of these functions with z_mm_lock held. * Call all of these functions with z_mm_lock held.
* *
* Overall virtual memory map: When the kernel starts, it resides in * Overall virtual memory map: When the kernel starts, it resides in
* virtual memory in the region Z_KERNEL_VIRT_START to * virtual memory in the region K_MEM_KERNEL_VIRT_START to
* Z_KERNEL_VIRT_END. Unused virtual memory past this, up to the limit * K_MEM_KERNEL_VIRT_END. Unused virtual memory past this, up to the limit
* noted by CONFIG_KERNEL_VM_SIZE may be used for runtime memory mappings. * noted by CONFIG_KERNEL_VM_SIZE may be used for runtime memory mappings.
* *
* If CONFIG_ARCH_MAPS_ALL_RAM is set, we do not just map the kernel image, * If CONFIG_ARCH_MAPS_ALL_RAM is set, we do not just map the kernel image,
@ -159,7 +159,7 @@ void z_page_frames_dump(void)
* *
* +--------------+ <- K_MEM_VIRT_RAM_START * +--------------+ <- K_MEM_VIRT_RAM_START
* | Undefined VM | <- May contain ancillary regions like x86_64's locore * | Undefined VM | <- May contain ancillary regions like x86_64's locore
* +--------------+ <- Z_KERNEL_VIRT_START (often == K_MEM_VIRT_RAM_START) * +--------------+ <- K_MEM_KERNEL_VIRT_START (often == K_MEM_VIRT_RAM_START)
* | Mapping for | * | Mapping for |
* | main kernel | * | main kernel |
* | image | * | image |
@ -321,7 +321,7 @@ static void *virt_region_alloc(size_t size, size_t align)
* *
* +--------------+ <- K_MEM_VIRT_RAM_START * +--------------+ <- K_MEM_VIRT_RAM_START
* | Undefined VM | * | Undefined VM |
* +--------------+ <- Z_KERNEL_VIRT_START (often == K_MEM_VIRT_RAM_START) * +--------------+ <- K_MEM_KERNEL_VIRT_START (often == K_MEM_VIRT_RAM_START)
* | Mapping for | * | Mapping for |
* | main kernel | * | main kernel |
* | image | * | image |
@ -970,7 +970,7 @@ void z_mem_manage_init(void)
/* All pages composing the Zephyr image are mapped at boot in a /* All pages composing the Zephyr image are mapped at boot in a
* predictable way. This can change at runtime. * predictable way. This can change at runtime.
*/ */
VIRT_FOREACH(Z_KERNEL_VIRT_START, Z_KERNEL_VIRT_SIZE, addr) VIRT_FOREACH(K_MEM_KERNEL_VIRT_START, K_MEM_KERNEL_VIRT_SIZE, addr)
{ {
pf = z_phys_to_page_frame(K_MEM_BOOT_VIRT_TO_PHYS(addr)); pf = z_phys_to_page_frame(K_MEM_BOOT_VIRT_TO_PHYS(addr));
frame_mapped_set(pf, addr); frame_mapped_set(pf, addr);

View file

@ -87,12 +87,12 @@ ZTEST(x86_pagetables, test_ram_perms)
pentry_t entry, flags, expected; pentry_t entry, flags, expected;
#ifdef CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT #ifdef CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT
const uint8_t *mem_range_end = Z_KERNEL_VIRT_END; const uint8_t *mem_range_end = K_MEM_KERNEL_VIRT_END;
#else #else
const uint8_t *mem_range_end = (uint8_t *)lnkr_pinned_end; const uint8_t *mem_range_end = (uint8_t *)lnkr_pinned_end;
#endif /* CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT */ #endif /* CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT */
for (pos = Z_KERNEL_VIRT_START; pos < mem_range_end; for (pos = K_MEM_KERNEL_VIRT_START; pos < mem_range_end;
pos += CONFIG_MMU_PAGE_SIZE) { pos += CONFIG_MMU_PAGE_SIZE) {
if (pos == NULL) { if (pos == NULL) {
/* We have another test specifically for NULL page */ /* We have another test specifically for NULL page */