[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>
This commit is contained in:
Michael Ellerman 2005-08-03 20:21:23 +10:00 committed by Paul Mackerras
parent 38e85dc180
commit 34c8f6961f
3 changed files with 27 additions and 26 deletions

View File

@ -225,21 +225,3 @@ struct ItVpdAreas itVpdAreas = {
0,0 0,0
} }
}; };
struct msChunks msChunks;
EXPORT_SYMBOL(msChunks);
unsigned long
msChunks_alloc(unsigned long mem, unsigned long num_chunks, unsigned long chunk_size)
{
_msChunks->num_chunks = num_chunks;
_msChunks->chunk_size = chunk_size;
_msChunks->chunk_shift = __ilog2(chunk_size);
_msChunks->chunk_mask = (1UL<<_msChunks->chunk_shift)-1;
mem = _ALIGN(mem, sizeof(msChunks_entry));
_msChunks->abs = (msChunks_entry *)mem;
mem += num_chunks * sizeof(msChunks_entry);
return mem;
}

View File

@ -415,6 +415,22 @@ static void __init iSeries_init_early(void)
DBG(" <- iSeries_init_early()\n"); DBG(" <- iSeries_init_early()\n");
} }
struct msChunks msChunks = {
/* XXX We don't use these, but Piranha might need them. */
.chunk_size = MSCHUNKS_CHUNK_SIZE,
.chunk_shift = MSCHUNKS_CHUNK_SHIFT,
.chunk_mask = MSCHUNKS_OFFSET_MASK,
};
EXPORT_SYMBOL(msChunks);
void msChunks_alloc(unsigned long num_chunks)
{
klimit = _ALIGN(klimit, sizeof(u32));
msChunks.abs = (u32 *)klimit;
klimit += num_chunks * sizeof(u32);
msChunks.num_chunks = num_chunks;
}
/* /*
* The iSeries may have very large memories ( > 128 GB ) and a partition * The iSeries may have very large memories ( > 128 GB ) and a partition
* may get memory in "chunks" that may be anywhere in the 2**52 real * 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)
/* Chunk size on iSeries is 256K bytes */ /* Chunk size on iSeries is 256K bytes */
totalChunks = (u32)HvLpConfig_getMsChunks(); totalChunks = (u32)HvLpConfig_getMsChunks();
klimit = msChunks_alloc(klimit, totalChunks, 1UL << 18); msChunks_alloc(totalChunks);
/* /*
* Get absolute address of our load area * Get absolute address of our load area
@ -498,7 +514,7 @@ static void __init build_iSeries_Memory_Map(void)
*/ */
hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress()); hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress());
hptSizePages = (u32)HvCallHpt_getHptPages(); hptSizePages = (u32)HvCallHpt_getHptPages();
hptSizeChunks = hptSizePages >> (msChunks.chunk_shift - PAGE_SHIFT); hptSizeChunks = hptSizePages >> (MSCHUNKS_CHUNK_SHIFT - PAGE_SHIFT);
hptLastChunk = hptFirstChunk + hptSizeChunks - 1; hptLastChunk = hptFirstChunk + hptSizeChunks - 1;
printk("HPT absolute addr = %016lx, size = %dK\n", printk("HPT absolute addr = %016lx, size = %dK\n",

View File

@ -17,34 +17,37 @@
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/lmb.h> #include <asm/lmb.h>
typedef u32 msChunks_entry;
struct msChunks { struct msChunks {
unsigned long num_chunks; unsigned long num_chunks;
unsigned long chunk_size; unsigned long chunk_size;
unsigned long chunk_shift; unsigned long chunk_shift;
unsigned long chunk_mask; unsigned long chunk_mask;
msChunks_entry *abs; u32 *abs;
}; };
extern struct msChunks msChunks; extern struct msChunks msChunks;
extern unsigned long msChunks_alloc(unsigned long, unsigned long, unsigned long);
#ifdef CONFIG_MSCHUNKS #ifdef CONFIG_MSCHUNKS
/* Chunks are 256 KB */
#define MSCHUNKS_CHUNK_SHIFT (18)
#define MSCHUNKS_CHUNK_SIZE (1UL << MSCHUNKS_CHUNK_SHIFT)
#define MSCHUNKS_OFFSET_MASK (MSCHUNKS_CHUNK_SIZE - 1)
static inline unsigned long chunk_to_addr(unsigned long chunk) static inline unsigned long chunk_to_addr(unsigned long chunk)
{ {
return chunk << msChunks.chunk_shift; return chunk << MSCHUNKS_CHUNK_SHIFT;
} }
static inline unsigned long addr_to_chunk(unsigned long addr) static inline unsigned long addr_to_chunk(unsigned long addr)
{ {
return addr >> msChunks.chunk_shift; return addr >> MSCHUNKS_CHUNK_SHIFT;
} }
static inline unsigned long chunk_offset(unsigned long addr) static inline unsigned long chunk_offset(unsigned long addr)
{ {
return addr & msChunks.chunk_mask; return addr & MSCHUNKS_OFFSET_MASK;
} }
static inline unsigned long abs_chunk(unsigned long pchunk) static inline unsigned long abs_chunk(unsigned long pchunk)