blob: 43082a393fded52ec71f4bca686cffef0e1aedf8 [file] [log] [blame]
Kumar Gala6d7bfa82008-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 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16
17#define MAX_LMB_REGIONS 8
18
19struct lmb_property {
Becky Bruced26d67c2008-06-09 20:37:18 -050020 phys_addr_t base;
21 phys_size_t size;
Kumar Gala6d7bfa82008-02-27 21:51:47 -060022};
23
24struct lmb_region {
25 unsigned long cnt;
Becky Bruced26d67c2008-06-09 20:37:18 -050026 phys_size_t size;
Kumar Gala6d7bfa82008-02-27 21:51:47 -060027 struct lmb_property region[MAX_LMB_REGIONS+1];
28};
29
30struct lmb {
31 struct lmb_region memory;
32 struct lmb_region reserved;
33};
34
35extern struct lmb lmb;
36
37extern void lmb_init(struct lmb *lmb);
Becky Bruced26d67c2008-06-09 20:37:18 -050038extern long lmb_add(struct lmb *lmb, phys_addr_t base, phys_size_t size);
39extern long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size);
40extern phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align);
41extern phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
42 phys_addr_t max_addr);
43extern phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align,
44 phys_addr_t max_addr);
45extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr);
Andy Fleming09d2a712008-07-07 14:24:39 -050046extern long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size);
Kumar Gala6d7bfa82008-02-27 21:51:47 -060047
48extern void lmb_dump_all(struct lmb *lmb);
49
Becky Bruced26d67c2008-06-09 20:37:18 -050050static inline phys_size_t
Kumar Gala6d7bfa82008-02-27 21:51:47 -060051lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
52{
53 return type->region[region_nr].size;
54}
Mike Frysingera0dadf82009-11-03 11:35:59 -050055
56void board_lmb_reserve(struct lmb *lmb);
57void arch_lmb_reserve(struct lmb *lmb);
58
Kumar Gala6d7bfa82008-02-27 21:51:47 -060059#endif /* __KERNEL__ */
60
61#endif /* _LINUX_LMB_H */