blob: 6b6959fd8604d9f28d219de691928980b316eef7 [file] [log] [blame]
Kumar Gala4ed65522008-02-27 21:51:47 -06001#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 Denk1a459662013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
Kumar Gala4ed65522008-02-27 21:51:47 -060012 */
13
14#define MAX_LMB_REGIONS 8
15
16struct lmb_property {
Becky Bruce391fd932008-06-09 20:37:18 -050017 phys_addr_t base;
18 phys_size_t size;
Kumar Gala4ed65522008-02-27 21:51:47 -060019};
20
21struct lmb_region {
22 unsigned long cnt;
Becky Bruce391fd932008-06-09 20:37:18 -050023 phys_size_t size;
Kumar Gala4ed65522008-02-27 21:51:47 -060024 struct lmb_property region[MAX_LMB_REGIONS+1];
25};
26
27struct lmb {
28 struct lmb_region memory;
29 struct lmb_region reserved;
30};
31
32extern struct lmb lmb;
33
34extern void lmb_init(struct lmb *lmb);
Becky Bruce391fd932008-06-09 20:37:18 -050035extern long lmb_add(struct lmb *lmb, phys_addr_t base, phys_size_t size);
36extern long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size);
37extern phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align);
38extern phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
39 phys_addr_t max_addr);
40extern phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
41 phys_addr_t max_addr);
42extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr);
Andy Fleming98874ff2008-07-07 14:24:39 -050043extern long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size);
Kumar Gala4ed65522008-02-27 21:51:47 -060044
45extern void lmb_dump_all(struct lmb *lmb);
46
Becky Bruce391fd932008-06-09 20:37:18 -050047static inline phys_size_t
Kumar Gala4ed65522008-02-27 21:51:47 -060048lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
49{
50 return type->region[region_nr].size;
51}
Mike Frysingera16028d2009-11-03 11:35:59 -050052
53void board_lmb_reserve(struct lmb *lmb);
54void arch_lmb_reserve(struct lmb *lmb);
55
Kumar Gala4ed65522008-02-27 21:51:47 -060056#endif /* __KERNEL__ */
57
58#endif /* _LINUX_LMB_H */