Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 1 | #ifndef _LINUX_LMB_H |
| 2 | #define _LINUX_LMB_H |
| 3 | #ifdef __KERNEL__ |
| 4 | |
| 5 | #include <asm/types.h> |
| 6 | /* |
| 7 | * Logical memory blocks. |
| 8 | * |
| 9 | * Copyright (C) 2001 Peter Bergner, IBM Corp. |
| 10 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #define MAX_LMB_REGIONS 8 |
| 15 | |
| 16 | struct lmb_property { |
Becky Bruce | 391fd93 | 2008-06-09 20:37:18 -0500 | [diff] [blame] | 17 | phys_addr_t base; |
| 18 | phys_size_t size; |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | struct lmb_region { |
| 22 | unsigned long cnt; |
Becky Bruce | 391fd93 | 2008-06-09 20:37:18 -0500 | [diff] [blame] | 23 | phys_size_t size; |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 24 | struct lmb_property region[MAX_LMB_REGIONS+1]; |
| 25 | }; |
| 26 | |
| 27 | struct lmb { |
| 28 | struct lmb_region memory; |
| 29 | struct lmb_region reserved; |
| 30 | }; |
| 31 | |
| 32 | extern struct lmb lmb; |
| 33 | |
| 34 | extern void lmb_init(struct lmb *lmb); |
Becky Bruce | 391fd93 | 2008-06-09 20:37:18 -0500 | [diff] [blame] | 35 | extern long lmb_add(struct lmb *lmb, phys_addr_t base, phys_size_t size); |
| 36 | extern long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size); |
| 37 | extern phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align); |
| 38 | extern phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, |
| 39 | phys_addr_t max_addr); |
| 40 | extern phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, |
| 41 | phys_addr_t max_addr); |
| 42 | extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr); |
Andy Fleming | 98874ff | 2008-07-07 14:24:39 -0500 | [diff] [blame] | 43 | extern long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size); |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 44 | |
| 45 | extern void lmb_dump_all(struct lmb *lmb); |
| 46 | |
Becky Bruce | 391fd93 | 2008-06-09 20:37:18 -0500 | [diff] [blame] | 47 | static inline phys_size_t |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 48 | lmb_size_bytes(struct lmb_region *type, unsigned long region_nr) |
| 49 | { |
| 50 | return type->region[region_nr].size; |
| 51 | } |
Mike Frysinger | a16028d | 2009-11-03 11:35:59 -0500 | [diff] [blame] | 52 | |
| 53 | void board_lmb_reserve(struct lmb *lmb); |
| 54 | void arch_lmb_reserve(struct lmb *lmb); |
| 55 | |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 56 | #endif /* __KERNEL__ */ |
| 57 | |
| 58 | #endif /* _LINUX_LMB_H */ |