blob: f04d058093785615d7e93e76f0a188defda537db [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Kumar Gala4ed65522008-02-27 21:51:47 -06002#ifndef _LINUX_LMB_H
3#define _LINUX_LMB_H
4#ifdef __KERNEL__
5
6#include <asm/types.h>
7/*
8 * Logical memory blocks.
9 *
10 * Copyright (C) 2001 Peter Bergner, IBM Corp.
Kumar Gala4ed65522008-02-27 21:51:47 -060011 */
12
13#define MAX_LMB_REGIONS 8
14
15struct lmb_property {
Becky Bruce391fd932008-06-09 20:37:18 -050016 phys_addr_t base;
17 phys_size_t size;
Kumar Gala4ed65522008-02-27 21:51:47 -060018};
19
20struct lmb_region {
21 unsigned long cnt;
Becky Bruce391fd932008-06-09 20:37:18 -050022 phys_size_t size;
Kumar Gala4ed65522008-02-27 21:51:47 -060023 struct lmb_property region[MAX_LMB_REGIONS+1];
24};
25
26struct lmb {
27 struct lmb_region memory;
28 struct lmb_region reserved;
29};
30
31extern struct lmb lmb;
32
33extern void lmb_init(struct lmb *lmb);
Becky Bruce391fd932008-06-09 20:37:18 -050034extern long lmb_add(struct lmb *lmb, phys_addr_t base, phys_size_t size);
35extern long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size);
36extern phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align);
37extern phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
38 phys_addr_t max_addr);
39extern phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
40 phys_addr_t max_addr);
41extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr);
Andy Fleming98874ff2008-07-07 14:24:39 -050042extern long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size);
Kumar Gala4ed65522008-02-27 21:51:47 -060043
44extern void lmb_dump_all(struct lmb *lmb);
45
Becky Bruce391fd932008-06-09 20:37:18 -050046static inline phys_size_t
Kumar Gala4ed65522008-02-27 21:51:47 -060047lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
48{
49 return type->region[region_nr].size;
50}
Mike Frysingera16028d2009-11-03 11:35:59 -050051
52void board_lmb_reserve(struct lmb *lmb);
53void arch_lmb_reserve(struct lmb *lmb);
54
Kumar Gala4ed65522008-02-27 21:51:47 -060055#endif /* __KERNEL__ */
56
57#endif /* _LINUX_LMB_H */