aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2005-08-03 06:21:23 -0400
committerPaul Mackerras <paulus@samba.org>2005-08-28 20:53:35 -0400
commit34c8f6961fc601294a38c5bd5ca12131b2e52674 (patch)
tree98035e5581a0addfca935fa2d8afddfc7c56c631
parent38e85dc18036804ada8698951cfad4e6114fec1b (diff)
[PATCH] ppc64: msChunks cleanups
Chunks are 256KB, so use constants for the size/shift/mask, rather than getting them from the msChunks struct. The iSeries debugger (??) might still need access to the values in the msChunks struct, so we keep them around for now, but set them from the constant values. Replace msChunks_entry typedef with regular u32. Simplify msChunks_alloc() to manipulate klimit directly, rather than via a parameter. Move msChunks_alloc() and msChunks into iSeries_setup.c, as that's where they're used. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r--arch/ppc64/kernel/LparData.c18
-rw-r--r--arch/ppc64/kernel/iSeries_setup.c20
-rw-r--r--include/asm-ppc64/abs_addr.h15
3 files changed, 27 insertions, 26 deletions
diff --git a/arch/ppc64/kernel/LparData.c b/arch/ppc64/kernel/LparData.c
index 0ed77b2f7d5f..0a9c23ca2f0c 100644
--- a/arch/ppc64/kernel/LparData.c
+++ b/arch/ppc64/kernel/LparData.c
@@ -225,21 +225,3 @@ struct ItVpdAreas itVpdAreas = {
225 0,0 225 0,0
226 } 226 }
227}; 227};
228
229struct msChunks msChunks;
230EXPORT_SYMBOL(msChunks);
231
232unsigned long
233msChunks_alloc(unsigned long mem, unsigned long num_chunks, unsigned long chunk_size)
234{
235 _msChunks->num_chunks = num_chunks;
236 _msChunks->chunk_size = chunk_size;
237 _msChunks->chunk_shift = __ilog2(chunk_size);
238 _msChunks->chunk_mask = (1UL<<_msChunks->chunk_shift)-1;
239
240 mem = _ALIGN(mem, sizeof(msChunks_entry));
241 _msChunks->abs = (msChunks_entry *)mem;
242 mem += num_chunks * sizeof(msChunks_entry);
243
244 return mem;
245}
diff --git a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c
index 460e7df681a1..e47984ba7c7c 100644
--- a/arch/ppc64/kernel/iSeries_setup.c
+++ b/arch/ppc64/kernel/iSeries_setup.c
@@ -415,6 +415,22 @@ static void __init iSeries_init_early(void)
415 DBG(" <- iSeries_init_early()\n"); 415 DBG(" <- iSeries_init_early()\n");
416} 416}
417 417
418struct msChunks msChunks = {
419 /* XXX We don't use these, but Piranha might need them. */
420 .chunk_size = MSCHUNKS_CHUNK_SIZE,
421 .chunk_shift = MSCHUNKS_CHUNK_SHIFT,
422 .chunk_mask = MSCHUNKS_OFFSET_MASK,
423};
424EXPORT_SYMBOL(msChunks);
425
426void msChunks_alloc(unsigned long num_chunks)
427{
428 klimit = _ALIGN(klimit, sizeof(u32));
429 msChunks.abs = (u32 *)klimit;
430 klimit += num_chunks * sizeof(u32);
431 msChunks.num_chunks = num_chunks;
432}
433
418/* 434/*
419 * The iSeries may have very large memories ( > 128 GB ) and a partition 435 * The iSeries may have very large memories ( > 128 GB ) and a partition
420 * may get memory in "chunks" that may be anywhere in the 2**52 real 436 * may get memory in "chunks" that may be anywhere in the 2**52 real
@@ -452,7 +468,7 @@ static void __init build_iSeries_Memory_Map(void)
452 468
453 /* Chunk size on iSeries is 256K bytes */ 469 /* Chunk size on iSeries is 256K bytes */
454 totalChunks = (u32)HvLpConfig_getMsChunks(); 470 totalChunks = (u32)HvLpConfig_getMsChunks();
455 klimit = msChunks_alloc(klimit, totalChunks, 1UL << 18); 471 msChunks_alloc(totalChunks);
456 472
457 /* 473 /*
458 * Get absolute address of our load area 474 * Get absolute address of our load area
@@ -498,7 +514,7 @@ static void __init build_iSeries_Memory_Map(void)
498 */ 514 */
499 hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress()); 515 hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress());
500 hptSizePages = (u32)HvCallHpt_getHptPages(); 516 hptSizePages = (u32)HvCallHpt_getHptPages();
501 hptSizeChunks = hptSizePages >> (msChunks.chunk_shift - PAGE_SHIFT); 517 hptSizeChunks = hptSizePages >> (MSCHUNKS_CHUNK_SHIFT - PAGE_SHIFT);
502 hptLastChunk = hptFirstChunk + hptSizeChunks - 1; 518 hptLastChunk = hptFirstChunk + hptSizeChunks - 1;
503 519
504 printk("HPT absolute addr = %016lx, size = %dK\n", 520 printk("HPT absolute addr = %016lx, size = %dK\n",
diff --git a/include/asm-ppc64/abs_addr.h b/include/asm-ppc64/abs_addr.h
index 93dc63ed4f2f..2276567f133a 100644
--- a/include/asm-ppc64/abs_addr.h
+++ b/include/asm-ppc64/abs_addr.h
@@ -17,34 +17,37 @@
17#include <asm/prom.h> 17#include <asm/prom.h>
18#include <asm/lmb.h> 18#include <asm/lmb.h>
19 19
20typedef u32 msChunks_entry;
21struct msChunks { 20struct msChunks {
22 unsigned long num_chunks; 21 unsigned long num_chunks;
23 unsigned long chunk_size; 22 unsigned long chunk_size;
24 unsigned long chunk_shift; 23 unsigned long chunk_shift;
25 unsigned long chunk_mask; 24 unsigned long chunk_mask;
26 msChunks_entry *abs; 25 u32 *abs;
27}; 26};
28 27
29extern struct msChunks msChunks; 28extern struct msChunks msChunks;
30 29
31extern unsigned long msChunks_alloc(unsigned long, unsigned long, unsigned long);
32 30
33#ifdef CONFIG_MSCHUNKS 31#ifdef CONFIG_MSCHUNKS
34 32
33/* Chunks are 256 KB */
34#define MSCHUNKS_CHUNK_SHIFT (18)
35#define MSCHUNKS_CHUNK_SIZE (1UL << MSCHUNKS_CHUNK_SHIFT)
36#define MSCHUNKS_OFFSET_MASK (MSCHUNKS_CHUNK_SIZE - 1)
37
35static inline unsigned long chunk_to_addr(unsigned long chunk) 38static inline unsigned long chunk_to_addr(unsigned long chunk)
36{ 39{
37 return chunk << msChunks.chunk_shift; 40 return chunk << MSCHUNKS_CHUNK_SHIFT;
38} 41}
39 42
40static inline unsigned long addr_to_chunk(unsigned long addr) 43static inline unsigned long addr_to_chunk(unsigned long addr)
41{ 44{
42 return addr >> msChunks.chunk_shift; 45 return addr >> MSCHUNKS_CHUNK_SHIFT;
43} 46}
44 47
45static inline unsigned long chunk_offset(unsigned long addr) 48static inline unsigned long chunk_offset(unsigned long addr)
46{ 49{
47 return addr & msChunks.chunk_mask; 50 return addr & MSCHUNKS_OFFSET_MASK;
48} 51}
49 52
50static inline unsigned long abs_chunk(unsigned long pchunk) 53static inline unsigned long abs_chunk(unsigned long pchunk)