aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-ppc64/abs_addr.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-ppc64/abs_addr.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-ppc64/abs_addr.h')
-rw-r--r--include/asm-ppc64/abs_addr.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/include/asm-ppc64/abs_addr.h b/include/asm-ppc64/abs_addr.h
new file mode 100644
index 000000000000..6d4e8e787058
--- /dev/null
+++ b/include/asm-ppc64/abs_addr.h
@@ -0,0 +1,108 @@
1#ifndef _ABS_ADDR_H
2#define _ABS_ADDR_H
3
4#include <linux/config.h>
5
6/*
7 * c 2001 PPC 64 Team, IBM Corp
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#include <asm/types.h>
16#include <asm/page.h>
17#include <asm/prom.h>
18#include <asm/lmb.h>
19
20typedef u32 msChunks_entry;
21struct msChunks {
22 unsigned long num_chunks;
23 unsigned long chunk_size;
24 unsigned long chunk_shift;
25 unsigned long chunk_mask;
26 msChunks_entry *abs;
27};
28
29extern struct msChunks msChunks;
30
31extern unsigned long msChunks_alloc(unsigned long, unsigned long, unsigned long);
32extern unsigned long reloc_offset(void);
33
34#ifdef CONFIG_MSCHUNKS
35
36static inline unsigned long
37chunk_to_addr(unsigned long chunk)
38{
39 unsigned long offset = reloc_offset();
40 struct msChunks *_msChunks = PTRRELOC(&msChunks);
41
42 return chunk << _msChunks->chunk_shift;
43}
44
45static inline unsigned long
46addr_to_chunk(unsigned long addr)
47{
48 unsigned long offset = reloc_offset();
49 struct msChunks *_msChunks = PTRRELOC(&msChunks);
50
51 return addr >> _msChunks->chunk_shift;
52}
53
54static inline unsigned long
55chunk_offset(unsigned long addr)
56{
57 unsigned long offset = reloc_offset();
58 struct msChunks *_msChunks = PTRRELOC(&msChunks);
59
60 return addr & _msChunks->chunk_mask;
61}
62
63static inline unsigned long
64abs_chunk(unsigned long pchunk)
65{
66 unsigned long offset = reloc_offset();
67 struct msChunks *_msChunks = PTRRELOC(&msChunks);
68 if ( pchunk >= _msChunks->num_chunks ) {
69 return pchunk;
70 }
71 return PTRRELOC(_msChunks->abs)[pchunk];
72}
73
74/* A macro so it can take pointers or unsigned long. */
75#define phys_to_abs(pa) \
76 ({ unsigned long _pa = (unsigned long)(pa); \
77 chunk_to_addr(abs_chunk(addr_to_chunk(_pa))) + chunk_offset(_pa); \
78 })
79
80static inline unsigned long
81physRpn_to_absRpn(unsigned long rpn)
82{
83 unsigned long pa = rpn << PAGE_SHIFT;
84 unsigned long aa = phys_to_abs(pa);
85 return (aa >> PAGE_SHIFT);
86}
87
88/* A macro so it can take pointers or unsigned long. */
89#define abs_to_phys(aa) lmb_abs_to_phys((unsigned long)(aa))
90
91#else /* !CONFIG_MSCHUNKS */
92
93#define chunk_to_addr(chunk) ((unsigned long)(chunk))
94#define addr_to_chunk(addr) (addr)
95#define chunk_offset(addr) (0)
96#define abs_chunk(pchunk) (pchunk)
97
98#define phys_to_abs(pa) (pa)
99#define physRpn_to_absRpn(rpn) (rpn)
100#define abs_to_phys(aa) (aa)
101
102#endif /* !CONFIG_MSCHUNKS */
103
104/* Convenience macros */
105#define virt_to_abs(va) phys_to_abs(__pa(va))
106#define abs_to_virt(aa) __va(abs_to_phys(aa))
107
108#endif /* _ABS_ADDR_H */