Lines Matching +full:align +full:- +full:size
1 // SPDX-License-Identifier: GPL-2.0
18 unsigned long size, in get_entry_num_slots() argument
22 unsigned long align = 1UL << align_shift; in get_entry_num_slots() local
25 if (md->type != EFI_CONVENTIONAL_MEMORY) in get_entry_num_slots()
28 if (md->attribute & EFI_MEMORY_HOT_PLUGGABLE) in get_entry_num_slots()
32 (md->attribute & EFI_MEMORY_SP)) in get_entry_num_slots()
35 region_end = min(md->phys_addr + md->num_pages * EFI_PAGE_SIZE - 1, in get_entry_num_slots()
37 if (region_end < size) in get_entry_num_slots()
40 first_slot = round_up(max(md->phys_addr, alloc_min), align); in get_entry_num_slots()
41 last_slot = round_down(region_end - size + 1, align); in get_entry_num_slots()
46 return ((unsigned long)(last_slot - first_slot) >> align_shift) + 1; in get_entry_num_slots()
55 #define MD_NUM_SLOTS(md) ((md)->virt_addr)
57 efi_status_t efi_random_alloc(unsigned long size, in efi_random_alloc() argument
58 unsigned long align, in efi_random_alloc() argument
75 if (align < EFI_ALLOC_ALIGN) in efi_random_alloc()
76 align = EFI_ALLOC_ALIGN; in efi_random_alloc()
80 alloc_min = align; in efi_random_alloc()
82 size = round_up(size, EFI_ALLOC_ALIGN); in efi_random_alloc()
85 for (map_offset = 0; map_offset < map->map_size; map_offset += map->desc_size) { in efi_random_alloc()
86 efi_memory_desc_t *md = (void *)map->map + map_offset; in efi_random_alloc()
89 slots = get_entry_num_slots(md, size, ilog2(align), alloc_min, in efi_random_alloc()
93 if (md->attribute & EFI_MEMORY_MORE_RELIABLE) in efi_random_alloc()
116 for (map_offset = 0; map_offset < map->map_size; map_offset += map->desc_size) { in efi_random_alloc()
117 efi_memory_desc_t *md = (void *)map->map + map_offset; in efi_random_alloc()
122 !(md->attribute & EFI_MEMORY_MORE_RELIABLE)) in efi_random_alloc()
126 target_slot -= MD_NUM_SLOTS(md); in efi_random_alloc()
130 target = round_up(max_t(u64, md->phys_addr, alloc_min), align) + target_slot * align; in efi_random_alloc()
131 pages = size / EFI_PAGE_SIZE; in efi_random_alloc()