kernel: mm: rename Z_FREE_VM_START to K_MEM_VM_FREE_START
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:
parent
b2784c9145
commit
a459cdf51e
5 changed files with 29 additions and 13 deletions
|
|
@ -81,7 +81,7 @@ below.
|
|||
| image |
|
||||
| |
|
||||
| |
|
||||
+--------------+ <- Z_FREE_VM_START
|
||||
+--------------+ <- K_MEM_VM_FREE_START
|
||||
| |
|
||||
| Unused, |
|
||||
| Available VM |
|
||||
|
|
@ -115,7 +115,7 @@ below.
|
|||
* ``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.
|
||||
|
||||
* ``Z_FREE_VM_START`` is the beginning of the virtual address space where addresses
|
||||
* ``K_MEM_VM_FREE_START`` is the beginning of the virtual address space where addresses
|
||||
can be allocated for memory mapping. This depends on whether
|
||||
:kconfig:option:`CONFIG_ARCH_MAPS_ALL_RAM` is enabled.
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ below.
|
|||
memory address space, and it is the same as
|
||||
(:kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` + :kconfig:option:`CONFIG_SRAM_SIZE`).
|
||||
|
||||
* If it is disabled, ``Z_FREE_VM_START`` is the same ``K_MEM_KERNEL_VIRT_END`` which
|
||||
* If it is disabled, ``K_MEM_VM_FREE_START`` is the same ``K_MEM_KERNEL_VIRT_END`` which
|
||||
is the end of the kernel image.
|
||||
|
||||
* ``Z_VM_RESERVED`` is an area reserved to support kernel functions. For example,
|
||||
|
|
@ -176,7 +176,7 @@ mappings must be aligned on page size and have finer access control.
|
|||
* The requested size must be multiple of page size.
|
||||
|
||||
* The address returned is inside the virtual address space between
|
||||
``Z_FREE_VM_START`` and ``K_MEM_VIRT_RAM_END``.
|
||||
``K_MEM_VM_FREE_START`` and ``K_MEM_VIRT_RAM_END``.
|
||||
|
||||
* The mapped region is not guaranteed to be physically contiguous in memory.
|
||||
|
||||
|
|
|
|||
|
|
@ -90,10 +90,26 @@
|
|||
*/
|
||||
#define K_MEM_BOOT_PHYS_TO_VIRT(phys) ((uint8_t *)(((uintptr_t)(phys)) + K_MEM_VM_OFFSET))
|
||||
|
||||
/**
|
||||
* @def K_MEM_VM_FREE_START
|
||||
* @brief Start address of unused, available virtual addresses.
|
||||
*
|
||||
* This is the start address of the virtual memory region where
|
||||
* addresses can be allocated for memory mapping. This depends on whether
|
||||
* CONFIG_ARCH_MAPS_ALL_RAM is enabled:
|
||||
*
|
||||
* - If it is enabled, which means all physical memory are mapped in virtual
|
||||
* memory address space, and it is the same as
|
||||
* (CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE).
|
||||
*
|
||||
* - If it is disabled, K_MEM_VM_FREE_START is the same K_MEM_KERNEL_VIRT_END which
|
||||
* is the end of the kernel image.
|
||||
*
|
||||
*/
|
||||
#ifdef CONFIG_ARCH_MAPS_ALL_RAM
|
||||
#define Z_FREE_VM_START K_MEM_BOOT_PHYS_TO_VIRT(K_MEM_PHYS_RAM_END)
|
||||
#define K_MEM_VM_FREE_START K_MEM_BOOT_PHYS_TO_VIRT(K_MEM_PHYS_RAM_END)
|
||||
#else
|
||||
#define Z_FREE_VM_START K_MEM_KERNEL_VIRT_END
|
||||
#define K_MEM_VM_FREE_START K_MEM_KERNEL_VIRT_END
|
||||
#endif /* CONFIG_ARCH_MAPS_ALL_RAM */
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ void z_page_frames_dump(void)
|
|||
* | image |
|
||||
* | |
|
||||
* | |
|
||||
* +--------------+ <- Z_FREE_VM_START
|
||||
* +--------------+ <- K_MEM_VM_FREE_START
|
||||
* | |
|
||||
* | Unused, |
|
||||
* | Available VM |
|
||||
|
|
@ -195,7 +195,7 @@ SYS_BITARRAY_DEFINE_STATIC(virt_region_bitmap,
|
|||
|
||||
static bool virt_region_inited;
|
||||
|
||||
#define Z_VIRT_REGION_START_ADDR Z_FREE_VM_START
|
||||
#define Z_VIRT_REGION_START_ADDR K_MEM_VM_FREE_START
|
||||
#define Z_VIRT_REGION_END_ADDR (K_MEM_VIRT_RAM_END - Z_VM_RESERVED)
|
||||
|
||||
static inline uintptr_t virt_from_bitmap_offset(size_t offset, size_t size)
|
||||
|
|
@ -227,7 +227,7 @@ static void virt_region_init(void)
|
|||
}
|
||||
|
||||
/* Mark all bits up to Z_FREE_VM_START as allocated */
|
||||
num_bits = POINTER_TO_UINT(Z_FREE_VM_START)
|
||||
num_bits = POINTER_TO_UINT(K_MEM_VM_FREE_START)
|
||||
- POINTER_TO_UINT(K_MEM_VIRT_RAM_START);
|
||||
offset = virt_to_bitmap_offset(K_MEM_VIRT_RAM_START, num_bits);
|
||||
num_bits /= CONFIG_MMU_PAGE_SIZE;
|
||||
|
|
@ -327,7 +327,7 @@ static void *virt_region_alloc(size_t size, size_t align)
|
|||
* | image |
|
||||
* | |
|
||||
* | |
|
||||
* +--------------+ <- Z_FREE_VM_START
|
||||
* +--------------+ <- K_MEM_VM_FREE_START
|
||||
* | ... |
|
||||
* +==============+ <- dest_addr
|
||||
* | Unused |
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ ZTEST(mem_map_api, test_k_mem_map_exhaustion)
|
|||
* virtual address (plus itself and guard page)
|
||||
* to obtain the end address.
|
||||
* 2. Calculate how big this region is from
|
||||
* Z_FREE_VM_START to end address.
|
||||
* K_MEM_VM_FREE_START to end address.
|
||||
* 3. Calculate how many times we can call k_mem_map().
|
||||
* Remember there are two guard pages for every
|
||||
* mapping call (hence 1 + 2 == 3).
|
||||
|
|
@ -417,7 +417,7 @@ ZTEST(mem_map_api, test_k_mem_map_exhaustion)
|
|||
k_mem_unmap(addr, CONFIG_MMU_PAGE_SIZE);
|
||||
|
||||
cnt = POINTER_TO_UINT(addr) + CONFIG_MMU_PAGE_SIZE * 2;
|
||||
cnt -= POINTER_TO_UINT(Z_FREE_VM_START);
|
||||
cnt -= POINTER_TO_UINT(K_MEM_VM_FREE_START);
|
||||
cnt /= CONFIG_MMU_PAGE_SIZE * 3;
|
||||
|
||||
/* If we are limited by virtual address space... */
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#define FAULTY_ADDRESS 0xBFFFFFFF
|
||||
#elif CONFIG_MMU
|
||||
/* Just past the zephyr image mapping should be a non-present page */
|
||||
#define FAULTY_ADDRESS Z_FREE_VM_START
|
||||
#define FAULTY_ADDRESS K_MEM_VM_FREE_START
|
||||
#else
|
||||
#define FAULTY_ADDRESS 0xFFFFFFF0
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue