xref: /openbmc/u-boot/include/lmb.h (revision dcfe8638)
1 #ifndef _LINUX_LMB_H
2 #define _LINUX_LMB_H
3 #ifdef __KERNEL__
4 #ifdef CONFIG_LMB
5 
6 #include <asm/types.h>
7 /*
8  * Logical memory blocks.
9  *
10  * Copyright (C) 2001 Peter Bergner, IBM Corp.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version
15  * 2 of the License, or (at your option) any later version.
16  */
17 
18 #define MAX_LMB_REGIONS 8
19 
20 struct lmb_property {
21 	phys_addr_t base;
22 	phys_size_t size;
23 };
24 
25 struct lmb_region {
26 	unsigned long cnt;
27 	phys_size_t size;
28 	struct lmb_property region[MAX_LMB_REGIONS+1];
29 };
30 
31 struct lmb {
32 	struct lmb_region memory;
33 	struct lmb_region reserved;
34 };
35 
36 extern struct lmb lmb;
37 
38 extern void lmb_init(struct lmb *lmb);
39 extern long lmb_add(struct lmb *lmb, phys_addr_t base, phys_size_t size);
40 extern long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size);
41 extern phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align);
42 extern phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
43 			    phys_addr_t max_addr);
44 extern phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
45 			      phys_addr_t max_addr);
46 extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr);
47 extern long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size);
48 
49 extern void lmb_dump_all(struct lmb *lmb);
50 
51 static inline phys_size_t
52 lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
53 {
54 	return type->region[region_nr].size;
55 }
56 
57 void board_lmb_reserve(struct lmb *lmb);
58 void arch_lmb_reserve(struct lmb *lmb);
59 
60 #endif /* CONFIG_LMB */
61 #endif /* __KERNEL__ */
62 
63 #endif /* _LINUX_LMB_H */
64