5 * Definitions for talking to the Open Firmware PROM on
6 * Power Macintosh computers.
8 * Copyright (C) 2001 Peter Bergner, IBM Corp.
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
16 #include <linux/config.h>
19 extern unsigned long reloc_offset(void);
21 #define MAX_LMB_REGIONS 64
23 union lmb_reg_property {
24 struct reg_property32 addr32[MAX_LMB_REGIONS];
25 struct reg_property64 addr64[MAX_LMB_REGIONS];
28 #define LMB_MEMORY_AREA 1
31 #define LMB_ALLOC_ANYWHERE 0
32 #define LMB_ALLOC_FIRST4GBYTE (1UL<<32)
36 unsigned long physbase;
45 unsigned long lcd_size; /* Least Common Denominator */
46 struct lmb_property region[MAX_LMB_REGIONS+1];
51 unsigned long rmo_size;
52 struct lmb_region memory;
53 struct lmb_region reserved;
56 extern struct lmb lmb;
58 extern void lmb_init(void);
59 extern void lmb_analyze(void);
60 extern long lmb_add(unsigned long, unsigned long);
61 #ifdef CONFIG_MSCHUNKS
62 extern long lmb_add_io(unsigned long base, unsigned long size);
63 #endif /* CONFIG_MSCHUNKS */
64 extern long lmb_reserve(unsigned long, unsigned long);
65 extern unsigned long lmb_alloc(unsigned long, unsigned long);
66 extern unsigned long lmb_alloc_base(unsigned long, unsigned long, unsigned long);
67 extern unsigned long lmb_phys_mem_size(void);
68 extern unsigned long lmb_end_of_DRAM(void);
69 extern unsigned long lmb_abs_to_phys(unsigned long);
70 extern void lmb_dump(char *);
72 static inline unsigned long
73 lmb_addrs_overlap(unsigned long base1, unsigned long size1,
74 unsigned long base2, unsigned long size2)
76 return ((base1 < (base2+size2)) && (base2 < (base1+size1)));
80 lmb_regions_overlap(struct lmb_region *rgn, unsigned long r1, unsigned long r2)
82 unsigned long base1 = rgn->region[r1].base;
83 unsigned long size1 = rgn->region[r1].size;
84 unsigned long base2 = rgn->region[r2].base;
85 unsigned long size2 = rgn->region[r2].size;
87 return lmb_addrs_overlap(base1,size1,base2,size2);
91 lmb_addrs_adjacent(unsigned long base1, unsigned long size1,
92 unsigned long base2, unsigned long size2)
94 if ( base2 == base1 + size1 ) {
96 } else if ( base1 == base2 + size2 ) {
103 lmb_regions_adjacent(struct lmb_region *rgn, unsigned long r1, unsigned long r2)
105 unsigned long base1 = rgn->region[r1].base;
106 unsigned long size1 = rgn->region[r1].size;
107 unsigned long type1 = rgn->region[r1].type;
108 unsigned long base2 = rgn->region[r2].base;
109 unsigned long size2 = rgn->region[r2].size;
110 unsigned long type2 = rgn->region[r2].type;
112 return (type1 == type2) && lmb_addrs_adjacent(base1,size1,base2,size2);
115 #endif /* _PPC64_LMB_H */