Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 368
memory: Add virtual memory regions gathering and structs#6931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* SPDX-License-Identifier: BSD-3-Clause */ | ||
| /* | ||
| * Copyright(c) 2022 Intel Corporation. All rights reserved. | ||
| * | ||
| * Author: Jakub Dabek <jakub.dabek@intel.com> | ||
| */ | ||
| #ifndef ZEPHYR_LIB_REGIONS_MM_H_ | ||
| #define ZEPHYR_LIB_REGIONS_MM_H_ | ||
| #include <adsp_memory.h> | ||
| #include <adsp_memory_regions.h> | ||
| #include <zephyr/drivers/mm/system_mm.h> | ||
| #include <zephyr/sys/mem_blocks.h> | ||
| #include <zephyr/init.h> | ||
| #include <ipc/topology.h> | ||
| /* | ||
| * Struct containing information on virtual memory heap. | ||
| * Information about allocated physical blocks is stored in | ||
| * physical_blocks_allocators variable and uses zephyr memblocks api. | ||
| */ | ||
| struct virtual_memory_heap { | ||
| /* zephyr provided virtual region */ | ||
| struct sys_mm_drv_region *virtual_region; | ||
| /* physical pages allocators represented in memblocks */ | ||
| struct sys_multi_mem_blocks physical_blocks_allocators; | ||
| /* SOF memory capability */ | ||
| uint32_t memory_caps; | ||
| }; | ||
| /* Available externaly array containing all information on virtual heaps | ||
| * Used to control physical allocations and overall virtual to physicall | ||
| * mapping on sof side (zephyr handles the actual assigning physical memory | ||
| * sof only requests it). | ||
| */ | ||
| extern struct virtual_memory_heap | ||
| vm_heaps[CONFIG_MP_MAX_NUM_CPUS + VIRTUAL_REGION_COUNT]; | ||
| #endif /* ZEPHYR_LIB_REGIONS_MM_H_ */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| /* | ||
| * Copyright(c) 2022 Intel Corporation. All rights reserved. | ||
| * | ||
| * Author: Jakub Dabek <jakub.dabek@intel.com> | ||
| */ | ||
| #include <sof/lib/regions_mm.h> | ||
| struct virtual_memory_heap | ||
| vm_heaps[CONFIG_MP_MAX_NUM_CPUS + VIRTUAL_REGION_COUNT]; | ||
| /** | ||
| * @brief Fill vm_heaps array with information from zephyr. | ||
| * | ||
| * Virtual memory regions calculated in zephyr are translated here | ||
| * to a struct that will keep all information on current allocations | ||
| * and virtual to physical mappings that are related to heaps. | ||
| * System heap is not a part of this information. It only refers to | ||
| * virtual first heaps. | ||
| * Has to be initialized after calculations for regions is done in zephyr. | ||
| */ | ||
| static int virtual_heaps_init(const struct device *unused) | ||
| { | ||
| ARG_UNUSED(unused); | ||
| struct sys_mm_drv_region *virtual_memory_regions = | ||
| (struct sys_mm_drv_region *)sys_mm_drv_query_memory_regions(); | ||
| for (size_t i = 0; | ||
| i < CONFIG_MP_MAX_NUM_CPUS + VIRTUAL_REGION_COUNT; | ||
| i++) { | ||
| vm_heaps[i].virtual_region = &virtual_memory_regions[i]; | ||
| switch (virtual_memory_regions[i].attr) { | ||
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, so it's not just a bit set in the attribute, the attribute is actually equal to one of those bits. I thought you'd need to do something like but if you don't - all the better | ||
| case MEM_REG_ATTR_CORE_HEAP: | ||
| vm_heaps[i].memory_caps = | ||
| SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_HP | SOF_MEM_CAPS_CACHE; | ||
| break; | ||
| case MEM_REG_ATTR_SHARED_HEAP: | ||
| vm_heaps[i].memory_caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_HP; | ||
| break; | ||
| case MEM_REG_ATTR_OPPORTUNISTIC_MEMORY: | ||
| vm_heaps[i].memory_caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_HP; | ||
| break; | ||
| default: | ||
| return -EINVAL; | ||
| } | ||
| } | ||
| return 0; | ||
| } | ||
| SYS_INIT(virtual_heaps_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); | ||
Uh oh!
There was an error while loading. Please reload this page.