blob: 5d1f4b624a2695b06e478dd7fcf205508d1a5cc1 [file] [log] [blame]
Kumar Gala4ed65522008-02-27 21:51:47 -06001#ifndef _LINUX_LMB_H
2#define _LINUX_LMB_H
3#ifdef __KERNEL__
Mike Frysinger95952602012-02-15 20:02:47 +00004#ifdef CONFIG_LMB
Kumar Gala4ed65522008-02-27 21:51:47 -06005
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
20struct lmb_property {
Becky Bruce391fd932008-06-09 20:37:18 -050021 phys_addr_t base;
22 phys_size_t size;
Kumar Gala4ed65522008-02-27 21:51:47 -060023};
24
25struct lmb_region {
26 unsigned long cnt;
Becky Bruce391fd932008-06-09 20:37:18 -050027 phys_size_t size;
Kumar Gala4ed65522008-02-27 21:51:47 -060028 struct lmb_property region[MAX_LMB_REGIONS+1];
29};
30
31struct lmb {
32 struct lmb_region memory;
33 struct lmb_region reserved;
34};
35
36extern struct lmb lmb;
37
38extern void lmb_init(struct lmb *lmb);
Becky Bruce391fd932008-06-09 20:37:18 -050039extern long lmb_add(struct lmb *lmb, phys_addr_t base, phys_size_t size);
40extern long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size);
41extern phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align);
42extern phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
43 phys_addr_t max_addr);
44extern phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
45 phys_addr_t max_addr);
46extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr);
Andy Fleming98874ff2008-07-07 14:24:39 -050047extern long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size);
Kumar Gala4ed65522008-02-27 21:51:47 -060048
49extern void lmb_dump_all(struct lmb *lmb);
50
Becky Bruce391fd932008-06-09 20:37:18 -050051static inline phys_size_t
Kumar Gala4ed65522008-02-27 21:51:47 -060052lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
53{
54 return type->region[region_nr].size;
55}
Mike Frysingera16028d2009-11-03 11:35:59 -050056
57void board_lmb_reserve(struct lmb *lmb);
58void arch_lmb_reserve(struct lmb *lmb);
59
Mike Frysinger95952602012-02-15 20:02:47 +000060#endif /* CONFIG_LMB */
Kumar Gala4ed65522008-02-27 21:51:47 -060061#endif /* __KERNEL__ */
62
63#endif /* _LINUX_LMB_H */