Lines Matching full:entries

45  * - Each MPU region is described by TWO entries:
49 * We might run out of available entries in the MPU map because of
57 * - All enabled entries are grouped towards the end of the map.
62 * - No disabled MPU entries allowed in between.
65 * For foreground map to be valid, its entries must follow these rules:
139 * Return the pointer to the entry encompassing @a addr out of an array of MPU entries.
144 * @param[in] entries Array of MPU entries.
156 struct xtensa_mpu_entry *check_addr_in_mpu_entries(const struct xtensa_mpu_entry *entries, in check_addr_in_mpu_entries() argument
168 if (addr < xtensa_mpu_entry_start_address_get(&entries[first_enabled_idx])) { in check_addr_in_mpu_entries()
175 s_addr = xtensa_mpu_entry_start_address_get(&entries[idx]); in check_addr_in_mpu_entries()
176 e_addr = xtensa_mpu_entry_start_address_get(&entries[idx + 1]); in check_addr_in_mpu_entries()
179 ret = &entries[idx]; in check_addr_in_mpu_entries()
185 s_addr = xtensa_mpu_entry_start_address_get(&entries[idx]); in check_addr_in_mpu_entries()
188 ret = &entries[idx]; in check_addr_in_mpu_entries()
213 * @param entries Array of MPU entries with XTENSA_MPU_NUM_ENTRIES elements.
218 static inline uint8_t find_first_enabled_entry(const struct xtensa_mpu_entry *entries) in find_first_enabled_entry() argument
224 if (entries[first_enabled_idx].as.p.enable) { in find_first_enabled_entry()
233 * Compare two MPU entries.
235 * This is used by qsort to compare two MPU entries on their ordering
263 * Sort the MPU entries base on starting address.
265 * This sorts the MPU entries in ascending order of starting address.
266 * After sorting, it rewrites the segment numbers of all entries.
268 static void sort_entries(struct xtensa_mpu_entry *entries) in sort_entries() argument
270 qsort(entries, XTENSA_MPU_NUM_ENTRIES, sizeof(entries[0]), compare_entries); in sort_entries()
274 entries[idx].at.p.segment = idx; in sort_entries()
279 * Consolidate the MPU entries.
281 * This removes consecutive entries where the attributes are the same.
283 * @param entries Array of MPU entries with XTENSA_MPU_NUM_ENTRIES elements.
288 static uint8_t consolidate_entries(struct xtensa_mpu_entry *entries, in consolidate_entries() argument
296 /* For each a pair of entries... */ in consolidate_entries()
298 struct xtensa_mpu_entry *entry_0 = &entries[idx_0]; in consolidate_entries()
299 struct xtensa_mpu_entry *entry_1 = &entries[idx_1]; in consolidate_entries()
312 * If both entries have the same address, the higher index in consolidate_entries()
349 /* Go through the map from the end and copy enabled entries in place. */ in consolidate_entries()
351 struct xtensa_mpu_entry *entry_rd = &entries[read_idx]; in consolidate_entries()
357 entry_wr = &entries[write_idx]; in consolidate_entries()
370 struct xtensa_mpu_entry *e = &entries[idx_0]; in consolidate_entries()
381 /* Use default memory type for disabled entries. */ in consolidate_entries()
385 /* No need to conlidate entries. Map is same as before. */ in consolidate_entries()
396 * start and end entries. This may re-use existing entries or add new
397 * entries to the map.
419 struct xtensa_mpu_entry *entries = map->entries; in mpu_map_region_add() local
426 first_enabled_idx = find_first_enabled_entry(entries); in mpu_map_region_add()
432 * at all. This is because we group all enabled entries at in mpu_map_region_add()
435 struct xtensa_mpu_entry *last_entry = &entries[XTENSA_MPU_NUM_ENTRIES - 1]; in mpu_map_region_add()
439 /* Empty table, so populate the entries as-is. */ in mpu_map_region_add()
445 entry_slot_s = &entries[XTENSA_MPU_NUM_ENTRIES - 1]; in mpu_map_region_add()
453 * Populate the last two entries to indicate in mpu_map_region_add()
459 entry_slot_s = &entries[XTENSA_MPU_NUM_ENTRIES - 2]; in mpu_map_region_add()
460 entry_slot_e = &entries[XTENSA_MPU_NUM_ENTRIES - 1]; in mpu_map_region_add()
475 first_enabled_idx = consolidate_entries(entries, first_enabled_idx); in mpu_map_region_add()
484 check_addr_in_mpu_entries(entries, start_addr, first_enabled_idx, in mpu_map_region_add()
487 check_addr_in_mpu_entries(entries, end_addr, first_enabled_idx, in mpu_map_region_add()
502 * we can reuse those entries without adding new one. in mpu_map_region_add()
516 * we start adding entries, as we will need to apply the same in mpu_map_region_add()
532 * We will sort the entries later. in mpu_map_region_add()
536 entry_slot_s = &entries[first_enabled_idx]; in mpu_map_region_add()
551 * We will sort the entries later. in mpu_map_region_add()
555 entry_slot_e = &entries[first_enabled_idx]; in mpu_map_region_add()
566 /* Sort the entries in ascending order of starting address */ in mpu_map_region_add()
567 sort_entries(entries); in mpu_map_region_add()
570 * Need to figure out where the start and end entries are as sorting in mpu_map_region_add()
574 check_addr_in_mpu_entries(entries, start_addr, first_enabled_idx, in mpu_map_region_add()
577 check_addr_in_mpu_entries(entries, end_addr, first_enabled_idx, in mpu_map_region_add()
590 * update entries will change the attribute of last entry in mpu_map_region_add()
597 * Any existing entries between the "newly" popluated start and in mpu_map_region_add()
598 * end entries must bear the same attributes. So modify them in mpu_map_region_add()
602 xtensa_mpu_entry_attributes_set(&entries[idx], access_rights, memory_type); in mpu_map_region_add()
644 * Clear MPU entries first, then write MPU entries in reverse order. in xtensa_mpu_map_write()
647 * two consecutive entries, and that the addresses of all entries in xtensa_mpu_map_write()
649 * To ensure this, we clear out the entries first then write them in xtensa_mpu_map_write()
659 : : "a"(map->entries[entry].at), "a"(map->entries[entry].as)); in xtensa_mpu_map_write()
677 * Clear the foreground MPU map so we can populate it later with valid entries. in xtensa_mpu_init()
691 /* Use default memory type for disabled entries. */ in xtensa_mpu_init()
694 xtensa_mpu_map_fg_kernel.entries[entry] = ent; in xtensa_mpu_init()
699 * Add necessary MPU entries for the memory regions of base Zephyr image. in xtensa_mpu_init()
718 * Now for the entries for memory regions needed by SoC. in xtensa_mpu_init()
735 /* Consolidate entries so we have a compact map at boot. */ in xtensa_mpu_init()
736 consolidate_entries(xtensa_mpu_map_fg_kernel.entries, first_enabled_idx); in xtensa_mpu_init()
760 * Due to each memory region requiring 2 MPU entries to describe, in arch_mem_domain_max_partitions_get()
763 * needs 2 entries (1 if the end of region already has an entry). in arch_mem_domain_max_partitions_get()
764 * If they are all disjoint, it will need (2 * n) entries to in arch_mem_domain_max_partitions_get()
835 * a region with default attributes. If entries already in arch_mem_domain_partition_remove()
836 * exist for the region, the corresponding entries will in arch_mem_domain_partition_remove()
837 * be updated with the default attributes. Or new entries in arch_mem_domain_partition_remove()