diff options
Diffstat (limited to 'include/linux/memblock.h')
| -rw-r--r-- | include/linux/memblock.h | 76 |
1 files changed, 56 insertions, 20 deletions
diff --git a/include/linux/memblock.h b/include/linux/memblock.h index ca59883c8364..516920549378 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h | |||
| @@ -20,31 +20,60 @@ | |||
| 20 | #define INIT_MEMBLOCK_REGIONS 128 | 20 | #define INIT_MEMBLOCK_REGIONS 128 |
| 21 | #define INIT_PHYSMEM_REGIONS 4 | 21 | #define INIT_PHYSMEM_REGIONS 4 |
| 22 | 22 | ||
| 23 | /* Definition of memblock flags. */ | 23 | /** |
| 24 | enum { | 24 | * enum memblock_flags - definition of memory region attributes |
| 25 | * @MEMBLOCK_NONE: no special request | ||
| 26 | * @MEMBLOCK_HOTPLUG: hotpluggable region | ||
| 27 | * @MEMBLOCK_MIRROR: mirrored region | ||
| 28 | * @MEMBLOCK_NOMAP: don't add to kernel direct mapping | ||
| 29 | */ | ||
| 30 | enum memblock_flags { | ||
| 25 | MEMBLOCK_NONE = 0x0, /* No special request */ | 31 | MEMBLOCK_NONE = 0x0, /* No special request */ |
| 26 | MEMBLOCK_HOTPLUG = 0x1, /* hotpluggable region */ | 32 | MEMBLOCK_HOTPLUG = 0x1, /* hotpluggable region */ |
| 27 | MEMBLOCK_MIRROR = 0x2, /* mirrored region */ | 33 | MEMBLOCK_MIRROR = 0x2, /* mirrored region */ |
| 28 | MEMBLOCK_NOMAP = 0x4, /* don't add to kernel direct mapping */ | 34 | MEMBLOCK_NOMAP = 0x4, /* don't add to kernel direct mapping */ |
| 29 | }; | 35 | }; |
| 30 | 36 | ||
| 37 | /** | ||
| 38 | * struct memblock_region - represents a memory region | ||
| 39 | * @base: physical address of the region | ||
| 40 | * @size: size of the region | ||
| 41 | * @flags: memory region attributes | ||
| 42 | * @nid: NUMA node id | ||
| 43 | */ | ||
| 31 | struct memblock_region { | 44 | struct memblock_region { |
| 32 | phys_addr_t base; | 45 | phys_addr_t base; |
| 33 | phys_addr_t size; | 46 | phys_addr_t size; |
| 34 | unsigned long flags; | 47 | enum memblock_flags flags; |
| 35 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP | 48 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP |
| 36 | int nid; | 49 | int nid; |
| 37 | #endif | 50 | #endif |
| 38 | }; | 51 | }; |
| 39 | 52 | ||
| 53 | /** | ||
| 54 | * struct memblock_type - collection of memory regions of certain type | ||
| 55 | * @cnt: number of regions | ||
| 56 | * @max: size of the allocated array | ||
| 57 | * @total_size: size of all regions | ||
| 58 | * @regions: array of regions | ||
| 59 | * @name: the memory type symbolic name | ||
| 60 | */ | ||
| 40 | struct memblock_type { | 61 | struct memblock_type { |
| 41 | unsigned long cnt; /* number of regions */ | 62 | unsigned long cnt; |
| 42 | unsigned long max; /* size of the allocated array */ | 63 | unsigned long max; |
| 43 | phys_addr_t total_size; /* size of all regions */ | 64 | phys_addr_t total_size; |
| 44 | struct memblock_region *regions; | 65 | struct memblock_region *regions; |
| 45 | char *name; | 66 | char *name; |
| 46 | }; | 67 | }; |
| 47 | 68 | ||
| 69 | /** | ||
| 70 | * struct memblock - memblock allocator metadata | ||
| 71 | * @bottom_up: is bottom up direction? | ||
| 72 | * @current_limit: physical address of the current allocation limit | ||
| 73 | * @memory: usabe memory regions | ||
| 74 | * @reserved: reserved memory regions | ||
| 75 | * @physmem: all physical memory | ||
| 76 | */ | ||
| 48 | struct memblock { | 77 | struct memblock { |
| 49 | bool bottom_up; /* is bottom up direction? */ | 78 | bool bottom_up; /* is bottom up direction? */ |
| 50 | phys_addr_t current_limit; | 79 | phys_addr_t current_limit; |
| @@ -72,7 +101,7 @@ void memblock_discard(void); | |||
| 72 | 101 | ||
| 73 | phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align, | 102 | phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align, |
| 74 | phys_addr_t start, phys_addr_t end, | 103 | phys_addr_t start, phys_addr_t end, |
| 75 | int nid, ulong flags); | 104 | int nid, enum memblock_flags flags); |
| 76 | phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, | 105 | phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, |
| 77 | phys_addr_t size, phys_addr_t align); | 106 | phys_addr_t size, phys_addr_t align); |
| 78 | void memblock_allow_resize(void); | 107 | void memblock_allow_resize(void); |
| @@ -89,19 +118,19 @@ int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size); | |||
| 89 | int memblock_mark_mirror(phys_addr_t base, phys_addr_t size); | 118 | int memblock_mark_mirror(phys_addr_t base, phys_addr_t size); |
| 90 | int memblock_mark_nomap(phys_addr_t base, phys_addr_t size); | 119 | int memblock_mark_nomap(phys_addr_t base, phys_addr_t size); |
| 91 | int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); | 120 | int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); |
| 92 | ulong choose_memblock_flags(void); | 121 | enum memblock_flags choose_memblock_flags(void); |
| 93 | 122 | ||
| 94 | /* Low level functions */ | 123 | /* Low level functions */ |
| 95 | int memblock_add_range(struct memblock_type *type, | 124 | int memblock_add_range(struct memblock_type *type, |
| 96 | phys_addr_t base, phys_addr_t size, | 125 | phys_addr_t base, phys_addr_t size, |
| 97 | int nid, unsigned long flags); | 126 | int nid, enum memblock_flags flags); |
| 98 | 127 | ||
| 99 | void __next_mem_range(u64 *idx, int nid, ulong flags, | 128 | void __next_mem_range(u64 *idx, int nid, enum memblock_flags flags, |
| 100 | struct memblock_type *type_a, | 129 | struct memblock_type *type_a, |
| 101 | struct memblock_type *type_b, phys_addr_t *out_start, | 130 | struct memblock_type *type_b, phys_addr_t *out_start, |
| 102 | phys_addr_t *out_end, int *out_nid); | 131 | phys_addr_t *out_end, int *out_nid); |
| 103 | 132 | ||
| 104 | void __next_mem_range_rev(u64 *idx, int nid, ulong flags, | 133 | void __next_mem_range_rev(u64 *idx, int nid, enum memblock_flags flags, |
| 105 | struct memblock_type *type_a, | 134 | struct memblock_type *type_a, |
| 106 | struct memblock_type *type_b, phys_addr_t *out_start, | 135 | struct memblock_type *type_b, phys_addr_t *out_start, |
| 107 | phys_addr_t *out_end, int *out_nid); | 136 | phys_addr_t *out_end, int *out_nid); |
| @@ -239,7 +268,6 @@ void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, | |||
| 239 | /** | 268 | /** |
| 240 | * for_each_resv_unavail_range - iterate through reserved and unavailable memory | 269 | * for_each_resv_unavail_range - iterate through reserved and unavailable memory |
| 241 | * @i: u64 used as loop variable | 270 | * @i: u64 used as loop variable |
| 242 | * @flags: pick from blocks based on memory attributes | ||
| 243 | * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL | 271 | * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL |
| 244 | * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL | 272 | * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL |
| 245 | * | 273 | * |
| @@ -253,13 +281,13 @@ void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, | |||
| 253 | NUMA_NO_NODE, MEMBLOCK_NONE, p_start, p_end, NULL) | 281 | NUMA_NO_NODE, MEMBLOCK_NONE, p_start, p_end, NULL) |
| 254 | 282 | ||
| 255 | static inline void memblock_set_region_flags(struct memblock_region *r, | 283 | static inline void memblock_set_region_flags(struct memblock_region *r, |
| 256 | unsigned long flags) | 284 | enum memblock_flags flags) |
| 257 | { | 285 | { |
| 258 | r->flags |= flags; | 286 | r->flags |= flags; |
| 259 | } | 287 | } |
| 260 | 288 | ||
| 261 | static inline void memblock_clear_region_flags(struct memblock_region *r, | 289 | static inline void memblock_clear_region_flags(struct memblock_region *r, |
| 262 | unsigned long flags) | 290 | enum memblock_flags flags) |
| 263 | { | 291 | { |
| 264 | r->flags &= ~flags; | 292 | r->flags &= ~flags; |
| 265 | } | 293 | } |
| @@ -317,10 +345,10 @@ static inline bool memblock_bottom_up(void) | |||
| 317 | 345 | ||
| 318 | phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align, | 346 | phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align, |
| 319 | phys_addr_t start, phys_addr_t end, | 347 | phys_addr_t start, phys_addr_t end, |
| 320 | ulong flags); | 348 | enum memblock_flags flags); |
| 321 | phys_addr_t memblock_alloc_base_nid(phys_addr_t size, | 349 | phys_addr_t memblock_alloc_base_nid(phys_addr_t size, |
| 322 | phys_addr_t align, phys_addr_t max_addr, | 350 | phys_addr_t align, phys_addr_t max_addr, |
| 323 | int nid, ulong flags); | 351 | int nid, enum memblock_flags flags); |
| 324 | phys_addr_t memblock_alloc_base(phys_addr_t size, phys_addr_t align, | 352 | phys_addr_t memblock_alloc_base(phys_addr_t size, phys_addr_t align, |
| 325 | phys_addr_t max_addr); | 353 | phys_addr_t max_addr); |
| 326 | phys_addr_t __memblock_alloc_base(phys_addr_t size, phys_addr_t align, | 354 | phys_addr_t __memblock_alloc_base(phys_addr_t size, phys_addr_t align, |
| @@ -367,8 +395,10 @@ phys_addr_t memblock_get_current_limit(void); | |||
| 367 | */ | 395 | */ |
| 368 | 396 | ||
| 369 | /** | 397 | /** |
| 370 | * memblock_region_memory_base_pfn - Return the lowest pfn intersecting with the memory region | 398 | * memblock_region_memory_base_pfn - get the lowest pfn of the memory region |
| 371 | * @reg: memblock_region structure | 399 | * @reg: memblock_region structure |
| 400 | * | ||
| 401 | * Return: the lowest pfn intersecting with the memory region | ||
| 372 | */ | 402 | */ |
| 373 | static inline unsigned long memblock_region_memory_base_pfn(const struct memblock_region *reg) | 403 | static inline unsigned long memblock_region_memory_base_pfn(const struct memblock_region *reg) |
| 374 | { | 404 | { |
| @@ -376,8 +406,10 @@ static inline unsigned long memblock_region_memory_base_pfn(const struct membloc | |||
| 376 | } | 406 | } |
| 377 | 407 | ||
| 378 | /** | 408 | /** |
| 379 | * memblock_region_memory_end_pfn - Return the end_pfn this region | 409 | * memblock_region_memory_end_pfn - get the end pfn of the memory region |
| 380 | * @reg: memblock_region structure | 410 | * @reg: memblock_region structure |
| 411 | * | ||
| 412 | * Return: the end_pfn of the reserved region | ||
| 381 | */ | 413 | */ |
| 382 | static inline unsigned long memblock_region_memory_end_pfn(const struct memblock_region *reg) | 414 | static inline unsigned long memblock_region_memory_end_pfn(const struct memblock_region *reg) |
| 383 | { | 415 | { |
| @@ -385,8 +417,10 @@ static inline unsigned long memblock_region_memory_end_pfn(const struct memblock | |||
| 385 | } | 417 | } |
| 386 | 418 | ||
| 387 | /** | 419 | /** |
| 388 | * memblock_region_reserved_base_pfn - Return the lowest pfn intersecting with the reserved region | 420 | * memblock_region_reserved_base_pfn - get the lowest pfn of the reserved region |
| 389 | * @reg: memblock_region structure | 421 | * @reg: memblock_region structure |
| 422 | * | ||
| 423 | * Return: the lowest pfn intersecting with the reserved region | ||
| 390 | */ | 424 | */ |
| 391 | static inline unsigned long memblock_region_reserved_base_pfn(const struct memblock_region *reg) | 425 | static inline unsigned long memblock_region_reserved_base_pfn(const struct memblock_region *reg) |
| 392 | { | 426 | { |
| @@ -394,8 +428,10 @@ static inline unsigned long memblock_region_reserved_base_pfn(const struct membl | |||
| 394 | } | 428 | } |
| 395 | 429 | ||
| 396 | /** | 430 | /** |
| 397 | * memblock_region_reserved_end_pfn - Return the end_pfn this region | 431 | * memblock_region_reserved_end_pfn - get the end pfn of the reserved region |
| 398 | * @reg: memblock_region structure | 432 | * @reg: memblock_region structure |
| 433 | * | ||
| 434 | * Return: the end_pfn of the reserved region | ||
| 399 | */ | 435 | */ |
| 400 | static inline unsigned long memblock_region_reserved_end_pfn(const struct memblock_region *reg) | 436 | static inline unsigned long memblock_region_reserved_end_pfn(const struct memblock_region *reg) |
| 401 | { | 437 | { |
