Commit bff06d55 authored by David S. Miller's avatar David S. Miller

[SPARC64]: Rewrite bootup sequence.

Instead of all of this cpu-specific code to remap the kernel
to the correct location, use portable firmware calls to do
this instead.

What we do now is the following in position independant
assembler:

	chosen_node = prom_finddevice("/chosen");
	prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu");
	vaddr = 4MB_ALIGN(current_text_addr());
	prom_translate(vaddr, &paddr_high, &paddr_low, &mode);
	prom_boot_mapping_mode = mode;
	prom_boot_mapping_phys_high = paddr_high;
	prom_boot_mapping_phys_low = paddr_low;
	prom_map(-1, 8 * 1024 * 1024, KERNBASE, paddr_low);

and that replaces the massive amount of by-hand TLB probing and
programming we used to do here.

The new code should also handle properly the case where the kernel
is mapped at the correct address already (think: future kexec
support).

Consequently, the bulk of remap_kernel() dies as does the entirety
of arch/sparc64/prom/map.S

We try to share some strings in the PROM library with the ones used
at bootup, and while we're here mark input strings to oplib.h routines
with "const" when appropriate.

There are many more simplifications now possible.  For one thing, we
can consolidate the two copies we now have of a lot of cpu setup code
sitting in head.S and trampoline.S.

This is a significant step towards CONFIG_DEBUG_PAGEALLOC support.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 40fd3533
This diff is collapsed.
...@@ -536,20 +536,7 @@ void __init setup_arch(char **cmdline_p) ...@@ -536,20 +536,7 @@ void __init setup_arch(char **cmdline_p)
} }
pfn_base = phys_base >> PAGE_SHIFT; pfn_base = phys_base >> PAGE_SHIFT;
switch (tlb_type) { kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL;
default:
case spitfire:
kern_base = spitfire_get_itlb_data(sparc64_highest_locked_tlbent());
kern_base &= _PAGE_PADDR_SF;
break;
case cheetah:
case cheetah_plus:
kern_base = cheetah_get_litlb_data(sparc64_highest_locked_tlbent());
kern_base &= _PAGE_PADDR;
break;
};
kern_size = (unsigned long)&_end - (unsigned long)KERNBASE; kern_size = (unsigned long)&_end - (unsigned long)KERNBASE;
if (!root_flags) if (!root_flags)
......
...@@ -119,8 +119,8 @@ startup_continue: ...@@ -119,8 +119,8 @@ startup_continue:
sethi %hi(itlb_load), %g2 sethi %hi(itlb_load), %g2
or %g2, %lo(itlb_load), %g2 or %g2, %lo(itlb_load), %g2
stx %g2, [%sp + 2047 + 128 + 0x18] stx %g2, [%sp + 2047 + 128 + 0x18]
sethi %hi(mmu_ihandle_cache), %g2 sethi %hi(prom_mmu_ihandle_cache), %g2
lduw [%g2 + %lo(mmu_ihandle_cache)], %g2 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
stx %g2, [%sp + 2047 + 128 + 0x20] stx %g2, [%sp + 2047 + 128 + 0x20]
sethi %hi(KERNBASE), %g2 sethi %hi(KERNBASE), %g2
stx %g2, [%sp + 2047 + 128 + 0x28] stx %g2, [%sp + 2047 + 128 + 0x28]
...@@ -156,8 +156,8 @@ startup_continue: ...@@ -156,8 +156,8 @@ startup_continue:
sethi %hi(itlb_load), %g2 sethi %hi(itlb_load), %g2
or %g2, %lo(itlb_load), %g2 or %g2, %lo(itlb_load), %g2
stx %g2, [%sp + 2047 + 128 + 0x18] stx %g2, [%sp + 2047 + 128 + 0x18]
sethi %hi(mmu_ihandle_cache), %g2 sethi %hi(prom_mmu_ihandle_cache), %g2
lduw [%g2 + %lo(mmu_ihandle_cache)], %g2 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
stx %g2, [%sp + 2047 + 128 + 0x20] stx %g2, [%sp + 2047 + 128 + 0x20]
sethi %hi(KERNBASE + 0x400000), %g2 sethi %hi(KERNBASE + 0x400000), %g2
stx %g2, [%sp + 2047 + 128 + 0x28] stx %g2, [%sp + 2047 + 128 + 0x28]
...@@ -190,8 +190,8 @@ do_dtlb: ...@@ -190,8 +190,8 @@ do_dtlb:
sethi %hi(dtlb_load), %g2 sethi %hi(dtlb_load), %g2
or %g2, %lo(dtlb_load), %g2 or %g2, %lo(dtlb_load), %g2
stx %g2, [%sp + 2047 + 128 + 0x18] stx %g2, [%sp + 2047 + 128 + 0x18]
sethi %hi(mmu_ihandle_cache), %g2 sethi %hi(prom_mmu_ihandle_cache), %g2
lduw [%g2 + %lo(mmu_ihandle_cache)], %g2 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
stx %g2, [%sp + 2047 + 128 + 0x20] stx %g2, [%sp + 2047 + 128 + 0x20]
sethi %hi(KERNBASE), %g2 sethi %hi(KERNBASE), %g2
stx %g2, [%sp + 2047 + 128 + 0x28] stx %g2, [%sp + 2047 + 128 + 0x28]
...@@ -228,8 +228,8 @@ do_dtlb: ...@@ -228,8 +228,8 @@ do_dtlb:
sethi %hi(dtlb_load), %g2 sethi %hi(dtlb_load), %g2
or %g2, %lo(dtlb_load), %g2 or %g2, %lo(dtlb_load), %g2
stx %g2, [%sp + 2047 + 128 + 0x18] stx %g2, [%sp + 2047 + 128 + 0x18]
sethi %hi(mmu_ihandle_cache), %g2 sethi %hi(prom_mmu_ihandle_cache), %g2
lduw [%g2 + %lo(mmu_ihandle_cache)], %g2 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
stx %g2, [%sp + 2047 + 128 + 0x20] stx %g2, [%sp + 2047 + 128 + 0x20]
sethi %hi(KERNBASE + 0x400000), %g2 sethi %hi(KERNBASE + 0x400000), %g2
stx %g2, [%sp + 2047 + 128 + 0x28] stx %g2, [%sp + 2047 + 128 + 0x28]
......
...@@ -505,108 +505,20 @@ static int read_obp_translations(void) ...@@ -505,108 +505,20 @@ static int read_obp_translations(void)
return n; return n;
} }
static inline void early_spitfire_errata32(void)
{
/* Spitfire Errata #32 workaround */
/* NOTE: Using plain zero for the context value is
* correct here, we are not using the Linux trap
* tables yet so we should not use the special
* UltraSPARC-III+ page size encodings yet.
*/
__asm__ __volatile__("stxa %0, [%1] %2\n\t"
"flush %%g6"
: /* No outputs */
: "r" (0), "r" (PRIMARY_CONTEXT),
"i" (ASI_DMMU));
}
static void lock_remap_func_page(unsigned long phys_page)
{
unsigned long tte_data = (phys_page | pgprot_val(PAGE_KERNEL));
if (tlb_type == spitfire) {
/* Lock this into i/d tlb entry 59 */
__asm__ __volatile__(
"stxa %%g0, [%2] %3\n\t"
"stxa %0, [%1] %4\n\t"
"membar #Sync\n\t"
"flush %%g6\n\t"
"stxa %%g0, [%2] %5\n\t"
"stxa %0, [%1] %6\n\t"
"membar #Sync\n\t"
"flush %%g6"
: /* no outputs */
: "r" (tte_data), "r" (59 << 3), "r" (TLB_TAG_ACCESS),
"i" (ASI_DMMU), "i" (ASI_DTLB_DATA_ACCESS),
"i" (ASI_IMMU), "i" (ASI_ITLB_DATA_ACCESS)
: "memory");
} else {
/* Lock this into i/d tlb-0 entry 11 */
__asm__ __volatile__(
"stxa %%g0, [%2] %3\n\t"
"stxa %0, [%1] %4\n\t"
"membar #Sync\n\t"
"flush %%g6\n\t"
"stxa %%g0, [%2] %5\n\t"
"stxa %0, [%1] %6\n\t"
"membar #Sync\n\t"
"flush %%g6"
: /* no outputs */
: "r" (tte_data), "r" ((0 << 16) | (11 << 3)),
"r" (TLB_TAG_ACCESS), "i" (ASI_DMMU),
"i" (ASI_DTLB_DATA_ACCESS), "i" (ASI_IMMU),
"i" (ASI_ITLB_DATA_ACCESS)
: "memory");
}
}
static void remap_kernel(void) static void remap_kernel(void)
{ {
unsigned long phys_page, tte_vaddr, tte_data; unsigned long phys_page, tte_vaddr, tte_data;
void (*remap_func)(unsigned long, unsigned long, int);
int tlb_ent = sparc64_highest_locked_tlbent(); int tlb_ent = sparc64_highest_locked_tlbent();
early_spitfire_errata32();
if (tlb_type == spitfire)
phys_page = spitfire_get_dtlb_data(tlb_ent);
else
phys_page = cheetah_get_ldtlb_data(tlb_ent);
phys_page &= _PAGE_PADDR;
phys_page += ((unsigned long)&prom_boot_page -
(unsigned long)KERNBASE);
lock_remap_func_page(phys_page);
tte_vaddr = (unsigned long) KERNBASE; tte_vaddr = (unsigned long) KERNBASE;
phys_page = (prom_boot_mapping_phys_low >> 22UL) << 22UL;
early_spitfire_errata32(); tte_data = (phys_page | (_PAGE_VALID | _PAGE_SZ4MB |
_PAGE_CP | _PAGE_CV | _PAGE_P |
if (tlb_type == spitfire) _PAGE_L | _PAGE_W));
tte_data = spitfire_get_dtlb_data(tlb_ent);
else
tte_data = cheetah_get_ldtlb_data(tlb_ent);
kern_locked_tte_data = tte_data; kern_locked_tte_data = tte_data;
remap_func = (void *) ((unsigned long) &prom_remap - /* Now lock us into the TLBs via OBP. */
(unsigned long) &prom_boot_page);
early_spitfire_errata32();
phys_page = tte_data & _PAGE_PADDR;
remap_func(phys_page, KERNBASE, prom_get_mmu_ihandle());
if (bigkernel)
remap_func(phys_page + 0x400000,
KERNBASE + 0x400000,
prom_get_mmu_ihandle());
/* Flush out that temporary mapping. */
spitfire_flush_dtlb_nucleus_page(0x0);
spitfire_flush_itlb_nucleus_page(0x0);
/* Now lock us back into the TLBs via OBP. */
prom_dtlb_load(tlb_ent, tte_data, tte_vaddr); prom_dtlb_load(tlb_ent, tte_data, tte_vaddr);
prom_itlb_load(tlb_ent, tte_data, tte_vaddr); prom_itlb_load(tlb_ent, tte_data, tte_vaddr);
if (bigkernel) { if (bigkernel) {
......
...@@ -7,4 +7,4 @@ EXTRA_AFLAGS := -ansi ...@@ -7,4 +7,4 @@ EXTRA_AFLAGS := -ansi
EXTRA_CFLAGS := -Werror EXTRA_CFLAGS := -Werror
lib-y := bootstr.o devops.o init.o memory.o misc.o \ lib-y := bootstr.o devops.o init.o memory.o misc.o \
tree.o console.o printf.o p1275.o map.o cif.o tree.o console.o printf.o p1275.o cif.o
...@@ -67,7 +67,7 @@ prom_putchar(char c) ...@@ -67,7 +67,7 @@ prom_putchar(char c)
} }
void void
prom_puts(char *s, int len) prom_puts(const char *s, int len)
{ {
p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)| p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)|
P1275_INOUT(3,1), P1275_INOUT(3,1),
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* Returns 0 on failure. * Returns 0 on failure.
*/ */
int int
prom_devopen(char *dstr) prom_devopen(const char *dstr)
{ {
return p1275_cmd ("open", P1275_ARG(0,P1275_ARG_IN_STRING)| return p1275_cmd ("open", P1275_ARG(0,P1275_ARG_IN_STRING)|
P1275_INOUT(1,1), P1275_INOUT(1,1),
......
...@@ -46,7 +46,7 @@ void __init prom_init(void *cif_handler, void *cif_stack) ...@@ -46,7 +46,7 @@ void __init prom_init(void *cif_handler, void *cif_stack)
if((prom_root_node == 0) || (prom_root_node == -1)) if((prom_root_node == 0) || (prom_root_node == -1))
prom_halt(); prom_halt();
prom_chosen_node = prom_finddevice("/chosen"); prom_chosen_node = prom_finddevice(prom_chosen_path);
if (!prom_chosen_node || prom_chosen_node == -1) if (!prom_chosen_node || prom_chosen_node == -1)
prom_halt(); prom_halt();
......
/* $Id: map.S,v 1.2 1999/11/19 05:53:02 davem Exp $
* map.S: Tricky coding required to fixup the kernel OBP maps
* properly.
*
* Copyright (C) 1999 David S. Miller (davem@redhat.com)
*/
.text
.align 8192
.globl prom_boot_page
prom_boot_page:
call_method:
.asciz "call-method"
.align 8
map:
.asciz "map"
.align 8
/* When we are invoked, our caller has remapped us to
* page zero, therefore we must use PC relative addressing
* for everything after we begin performing the unmap/map
* calls.
*/
.globl prom_remap
prom_remap: /* %o0 = physpage, %o1 = virtpage, %o2 = mmu_ihandle */
rd %pc, %g1
srl %o2, 0, %o2 ! kill sign extension
sethi %hi(p1275buf), %g2
or %g2, %lo(p1275buf), %g2
ldx [%g2 + 0x10], %g3 ! prom_cif_stack
save %g3, -(192 + 128), %sp
ldx [%g2 + 0x08], %l0 ! prom_cif_handler
mov %g6, %i3
mov %g4, %i4
mov %g5, %i5
flushw
sethi %hi(prom_remap - call_method), %g7
or %g7, %lo(prom_remap - call_method), %g7
sub %g1, %g7, %l2 ! call-method string
sethi %hi(prom_remap - map), %g7
or %g7, %lo(prom_remap - map), %g7
sub %g1, %g7, %l4 ! map string
/* OK, map the 4MB region we really live at. */
stx %l2, [%sp + 2047 + 128 + 0x00] ! call-method
mov 7, %l5
stx %l5, [%sp + 2047 + 128 + 0x08] ! num_args
mov 1, %l5
stx %l5, [%sp + 2047 + 128 + 0x10] ! num_rets
stx %l4, [%sp + 2047 + 128 + 0x18] ! map
stx %i2, [%sp + 2047 + 128 + 0x20] ! mmu_ihandle
mov -1, %l5
stx %l5, [%sp + 2047 + 128 + 0x28] ! mode == default
sethi %hi(4 * 1024 * 1024), %l5
stx %l5, [%sp + 2047 + 128 + 0x30] ! size
stx %i1, [%sp + 2047 + 128 + 0x38] ! vaddr
stx %g0, [%sp + 2047 + 128 + 0x40] ! filler
stx %i0, [%sp + 2047 + 128 + 0x48] ! paddr
call %l0
add %sp, (2047 + 128), %o0 ! argument array
/* Restore hard-coded globals. */
mov %i3, %g6
mov %i4, %g4
mov %i5, %g5
/* Wheee.... we are done. */
ret
restore
.align 8192
...@@ -17,14 +17,14 @@ ...@@ -17,14 +17,14 @@
#include <asm/system.h> #include <asm/system.h>
/* Reset and reboot the machine with the command 'bcommand'. */ /* Reset and reboot the machine with the command 'bcommand'. */
void prom_reboot(char *bcommand) void prom_reboot(const char *bcommand)
{ {
p1275_cmd("boot", P1275_ARG(0, P1275_ARG_IN_STRING) | p1275_cmd("boot", P1275_ARG(0, P1275_ARG_IN_STRING) |
P1275_INOUT(1, 0), bcommand); P1275_INOUT(1, 0), bcommand);
} }
/* Forth evaluate the expression contained in 'fstring'. */ /* Forth evaluate the expression contained in 'fstring'. */
void prom_feval(char *fstring) void prom_feval(const char *fstring)
{ {
if (!fstring || fstring[0] == 0) if (!fstring || fstring[0] == 0)
return; return;
...@@ -148,21 +148,19 @@ void prom_set_trap_table(unsigned long tba) ...@@ -148,21 +148,19 @@ void prom_set_trap_table(unsigned long tba)
p1275_cmd("SUNW,set-trap-table", P1275_INOUT(1, 0), tba); p1275_cmd("SUNW,set-trap-table", P1275_INOUT(1, 0), tba);
} }
int mmu_ihandle_cache = 0;
int prom_get_mmu_ihandle(void) int prom_get_mmu_ihandle(void)
{ {
int node, ret; int node, ret;
if (mmu_ihandle_cache != 0) if (prom_mmu_ihandle_cache != 0)
return mmu_ihandle_cache; return prom_mmu_ihandle_cache;
node = prom_finddevice("/chosen"); node = prom_finddevice(prom_chosen_path);
ret = prom_getint(node, "mmu"); ret = prom_getint(node, prom_mmu_name);
if (ret == -1 || ret == 0) if (ret == -1 || ret == 0)
mmu_ihandle_cache = -1; prom_mmu_ihandle_cache = -1;
else else
mmu_ihandle_cache = ret; prom_mmu_ihandle_cache = ret;
return ret; return ret;
} }
...@@ -190,7 +188,7 @@ long prom_itlb_load(unsigned long index, ...@@ -190,7 +188,7 @@ long prom_itlb_load(unsigned long index,
unsigned long tte_data, unsigned long tte_data,
unsigned long vaddr) unsigned long vaddr)
{ {
return p1275_cmd("call-method", return p1275_cmd(prom_callmethod_name,
(P1275_ARG(0, P1275_ARG_IN_STRING) | (P1275_ARG(0, P1275_ARG_IN_STRING) |
P1275_ARG(2, P1275_ARG_IN_64B) | P1275_ARG(2, P1275_ARG_IN_64B) |
P1275_ARG(3, P1275_ARG_IN_64B) | P1275_ARG(3, P1275_ARG_IN_64B) |
...@@ -207,7 +205,7 @@ long prom_dtlb_load(unsigned long index, ...@@ -207,7 +205,7 @@ long prom_dtlb_load(unsigned long index,
unsigned long tte_data, unsigned long tte_data,
unsigned long vaddr) unsigned long vaddr)
{ {
return p1275_cmd("call-method", return p1275_cmd(prom_callmethod_name,
(P1275_ARG(0, P1275_ARG_IN_STRING) | (P1275_ARG(0, P1275_ARG_IN_STRING) |
P1275_ARG(2, P1275_ARG_IN_64B) | P1275_ARG(2, P1275_ARG_IN_64B) |
P1275_ARG(3, P1275_ARG_IN_64B) | P1275_ARG(3, P1275_ARG_IN_64B) |
...@@ -223,13 +221,13 @@ long prom_dtlb_load(unsigned long index, ...@@ -223,13 +221,13 @@ long prom_dtlb_load(unsigned long index,
int prom_map(int mode, unsigned long size, int prom_map(int mode, unsigned long size,
unsigned long vaddr, unsigned long paddr) unsigned long vaddr, unsigned long paddr)
{ {
int ret = p1275_cmd("call-method", int ret = p1275_cmd(prom_callmethod_name,
(P1275_ARG(0, P1275_ARG_IN_STRING) | (P1275_ARG(0, P1275_ARG_IN_STRING) |
P1275_ARG(3, P1275_ARG_IN_64B) | P1275_ARG(3, P1275_ARG_IN_64B) |
P1275_ARG(4, P1275_ARG_IN_64B) | P1275_ARG(4, P1275_ARG_IN_64B) |
P1275_ARG(6, P1275_ARG_IN_64B) | P1275_ARG(6, P1275_ARG_IN_64B) |
P1275_INOUT(7, 1)), P1275_INOUT(7, 1)),
"map", prom_map_name,
prom_get_mmu_ihandle(), prom_get_mmu_ihandle(),
mode, mode,
size, size,
...@@ -244,12 +242,12 @@ int prom_map(int mode, unsigned long size, ...@@ -244,12 +242,12 @@ int prom_map(int mode, unsigned long size,
void prom_unmap(unsigned long size, unsigned long vaddr) void prom_unmap(unsigned long size, unsigned long vaddr)
{ {
p1275_cmd("call-method", p1275_cmd(prom_callmethod_name,
(P1275_ARG(0, P1275_ARG_IN_STRING) | (P1275_ARG(0, P1275_ARG_IN_STRING) |
P1275_ARG(2, P1275_ARG_IN_64B) | P1275_ARG(2, P1275_ARG_IN_64B) |
P1275_ARG(3, P1275_ARG_IN_64B) | P1275_ARG(3, P1275_ARG_IN_64B) |
P1275_INOUT(4, 0)), P1275_INOUT(4, 0)),
"unmap", prom_unmap_name,
prom_get_mmu_ihandle(), prom_get_mmu_ihandle(),
size, size,
vaddr); vaddr);
...@@ -258,7 +256,7 @@ void prom_unmap(unsigned long size, unsigned long vaddr) ...@@ -258,7 +256,7 @@ void prom_unmap(unsigned long size, unsigned long vaddr)
/* Set aside physical memory which is not touched or modified /* Set aside physical memory which is not touched or modified
* across soft resets. * across soft resets.
*/ */
unsigned long prom_retain(char *name, unsigned long prom_retain(const char *name,
unsigned long pa_low, unsigned long pa_high, unsigned long pa_low, unsigned long pa_high,
long size, long align) long size, long align)
{ {
...@@ -290,7 +288,7 @@ int prom_getunumber(int syndrome_code, ...@@ -290,7 +288,7 @@ int prom_getunumber(int syndrome_code,
unsigned long phys_addr, unsigned long phys_addr,
char *buf, int buflen) char *buf, int buflen)
{ {
return p1275_cmd("call-method", return p1275_cmd(prom_callmethod_name,
(P1275_ARG(0, P1275_ARG_IN_STRING) | (P1275_ARG(0, P1275_ARG_IN_STRING) |
P1275_ARG(3, P1275_ARG_OUT_BUF) | P1275_ARG(3, P1275_ARG_OUT_BUF) |
P1275_ARG(6, P1275_ARG_IN_64B) | P1275_ARG(6, P1275_ARG_IN_64B) |
......
...@@ -46,7 +46,7 @@ static inline unsigned long spitfire_get_primary_context(void) ...@@ -46,7 +46,7 @@ static inline unsigned long spitfire_get_primary_context(void)
*/ */
DEFINE_SPINLOCK(prom_entry_lock); DEFINE_SPINLOCK(prom_entry_lock);
long p1275_cmd (char *service, long fmt, ...) long p1275_cmd(const char *service, long fmt, ...)
{ {
char *p, *q; char *p, *q;
unsigned long flags; unsigned long flags;
......
...@@ -34,7 +34,7 @@ prom_write(const char *buf, unsigned int n) ...@@ -34,7 +34,7 @@ prom_write(const char *buf, unsigned int n)
} }
void void
prom_printf(char *fmt, ...) prom_printf(const char *fmt, ...)
{ {
va_list args; va_list args;
int i; int i;
......
...@@ -69,7 +69,7 @@ prom_getsibling(int node) ...@@ -69,7 +69,7 @@ prom_getsibling(int node)
* Return -1 on error. * Return -1 on error.
*/ */
__inline__ int __inline__ int
prom_getproplen(int node, char *prop) prom_getproplen(int node, const char *prop)
{ {
if((!node) || (!prop)) return -1; if((!node) || (!prop)) return -1;
return p1275_cmd ("getproplen", return p1275_cmd ("getproplen",
...@@ -83,20 +83,20 @@ prom_getproplen(int node, char *prop) ...@@ -83,20 +83,20 @@ prom_getproplen(int node, char *prop)
* was successful the length will be returned, else -1 is returned. * was successful the length will be returned, else -1 is returned.
*/ */
__inline__ int __inline__ int
prom_getproperty(int node, char *prop, char *buffer, int bufsize) prom_getproperty(int node, const char *prop, char *buffer, int bufsize)
{ {
int plen; int plen;
plen = prom_getproplen(node, prop); plen = prom_getproplen(node, prop);
if((plen > bufsize) || (plen == 0) || (plen == -1)) if ((plen > bufsize) || (plen == 0) || (plen == -1)) {
return -1; return -1;
else { } else {
/* Ok, things seem all right. */ /* Ok, things seem all right. */
return p1275_cmd ("getprop", return p1275_cmd(prom_getprop_name,
P1275_ARG(1,P1275_ARG_IN_STRING)| P1275_ARG(1,P1275_ARG_IN_STRING)|
P1275_ARG(2,P1275_ARG_OUT_BUF)| P1275_ARG(2,P1275_ARG_OUT_BUF)|
P1275_INOUT(4, 1), P1275_INOUT(4, 1),
node, prop, buffer, P1275_SIZE(plen)); node, prop, buffer, P1275_SIZE(plen));
} }
} }
...@@ -104,7 +104,7 @@ prom_getproperty(int node, char *prop, char *buffer, int bufsize) ...@@ -104,7 +104,7 @@ prom_getproperty(int node, char *prop, char *buffer, int bufsize)
* on failure. * on failure.
*/ */
__inline__ int __inline__ int
prom_getint(int node, char *prop) prom_getint(int node, const char *prop)
{ {
int intprop; int intprop;
...@@ -119,7 +119,7 @@ prom_getint(int node, char *prop) ...@@ -119,7 +119,7 @@ prom_getint(int node, char *prop)
*/ */
int int
prom_getintdefault(int node, char *property, int deflt) prom_getintdefault(int node, const char *property, int deflt)
{ {
int retval; int retval;
...@@ -131,7 +131,7 @@ prom_getintdefault(int node, char *property, int deflt) ...@@ -131,7 +131,7 @@ prom_getintdefault(int node, char *property, int deflt)
/* Acquire a boolean property, 1=TRUE 0=FALSE. */ /* Acquire a boolean property, 1=TRUE 0=FALSE. */
int int
prom_getbool(int node, char *prop) prom_getbool(int node, const char *prop)
{ {
int retval; int retval;
...@@ -145,7 +145,7 @@ prom_getbool(int node, char *prop) ...@@ -145,7 +145,7 @@ prom_getbool(int node, char *prop)
* buffer. * buffer.
*/ */
void void
prom_getstring(int node, char *prop, char *user_buf, int ubuf_size) prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size)
{ {
int len; int len;
...@@ -160,7 +160,7 @@ prom_getstring(int node, char *prop, char *user_buf, int ubuf_size) ...@@ -160,7 +160,7 @@ prom_getstring(int node, char *prop, char *user_buf, int ubuf_size)
* YES = 1 NO = 0 * YES = 1 NO = 0
*/ */
int int
prom_nodematch(int node, char *name) prom_nodematch(int node, const char *name)
{ {
char namebuf[128]; char namebuf[128];
prom_getproperty(node, "name", namebuf, sizeof(namebuf)); prom_getproperty(node, "name", namebuf, sizeof(namebuf));
...@@ -172,7 +172,7 @@ prom_nodematch(int node, char *name) ...@@ -172,7 +172,7 @@ prom_nodematch(int node, char *name)
* 'nodename'. Return node if successful, zero if not. * 'nodename'. Return node if successful, zero if not.
*/ */
int int
prom_searchsiblings(int node_start, char *nodename) prom_searchsiblings(int node_start, const char *nodename)
{ {
int thisnode, error; int thisnode, error;
...@@ -294,7 +294,7 @@ prom_firstprop(int node, char *buffer) ...@@ -294,7 +294,7 @@ prom_firstprop(int node, char *buffer)
* property types for this node. * property types for this node.
*/ */
__inline__ char * __inline__ char *
prom_nextprop(int node, char *oprop, char *buffer) prom_nextprop(int node, const char *oprop, char *buffer)
{ {
char buf[32]; char buf[32];
...@@ -314,15 +314,17 @@ prom_nextprop(int node, char *oprop, char *buffer) ...@@ -314,15 +314,17 @@ prom_nextprop(int node, char *oprop, char *buffer)
} }
int int
prom_finddevice(char *name) prom_finddevice(const char *name)
{ {
if(!name) return 0; if (!name)
return p1275_cmd ("finddevice", P1275_ARG(0,P1275_ARG_IN_STRING)| return 0;
P1275_INOUT(1, 1), return p1275_cmd(prom_finddev_name,
name); P1275_ARG(0,P1275_ARG_IN_STRING)|
P1275_INOUT(1, 1),
name);
} }
int prom_node_has_property(int node, char *prop) int prom_node_has_property(int node, const char *prop)
{ {
char buf [32]; char buf [32];
...@@ -339,7 +341,7 @@ int prom_node_has_property(int node, char *prop) ...@@ -339,7 +341,7 @@ int prom_node_has_property(int node, char *prop)
* of 'size' bytes. Return the number of bytes the prom accepted. * of 'size' bytes. Return the number of bytes the prom accepted.
*/ */
int int
prom_setprop(int node, char *pname, char *value, int size) prom_setprop(int node, const char *pname, char *value, int size)
{ {
if(size == 0) return 0; if(size == 0) return 0;
if((pname == 0) || (value == 0)) return 0; if((pname == 0) || (value == 0)) return 0;
...@@ -364,7 +366,7 @@ prom_inst2pkg(int inst) ...@@ -364,7 +366,7 @@ prom_inst2pkg(int inst)
* FIXME: Should work for v0 as well * FIXME: Should work for v0 as well
*/ */
int int
prom_pathtoinode(char *path) prom_pathtoinode(const char *path)
{ {
int node, inst; int node, inst;
......
...@@ -38,6 +38,20 @@ extern int prom_stdin, prom_stdout; ...@@ -38,6 +38,20 @@ extern int prom_stdin, prom_stdout;
*/ */
extern int prom_chosen_node; extern int prom_chosen_node;
/* Helper values and strings in arch/sparc64/kernel/head.S */
extern const char prom_finddev_name[];
extern const char prom_chosen_path[];
extern const char prom_getprop_name[];
extern const char prom_mmu_name[];
extern const char prom_callmethod_name[];
extern const char prom_translate_name[];
extern const char prom_map_name[];
extern const char prom_unmap_name[];
extern int prom_mmu_ihandle_cache;
extern unsigned int prom_boot_mapped_pc;
extern unsigned int prom_boot_mapping_mode;
extern unsigned long prom_boot_mapping_phys_high, prom_boot_mapping_phys_low;
struct linux_mlist_p1275 { struct linux_mlist_p1275 {
struct linux_mlist_p1275 *theres_more; struct linux_mlist_p1275 *theres_more;
unsigned long start_adr; unsigned long start_adr;
...@@ -68,7 +82,7 @@ extern char *prom_getbootargs(void); ...@@ -68,7 +82,7 @@ extern char *prom_getbootargs(void);
* of the string is different on V0 vs. V2->higher proms. The caller must * of the string is different on V0 vs. V2->higher proms. The caller must
* know what he/she is doing! Returns the device descriptor, an int. * know what he/she is doing! Returns the device descriptor, an int.
*/ */
extern int prom_devopen(char *device_string); extern int prom_devopen(const char *device_string);
/* Close a previously opened device described by the passed integer /* Close a previously opened device described by the passed integer
* descriptor. * descriptor.
...@@ -98,10 +112,10 @@ extern struct linux_mem_p1275 *prom_meminfo(void); ...@@ -98,10 +112,10 @@ extern struct linux_mem_p1275 *prom_meminfo(void);
/* Miscellaneous routines, don't really fit in any category per se. */ /* Miscellaneous routines, don't really fit in any category per se. */
/* Reboot the machine with the command line passed. */ /* Reboot the machine with the command line passed. */
extern void prom_reboot(char *boot_command); extern void prom_reboot(const char *boot_command);
/* Evaluate the forth string passed. */ /* Evaluate the forth string passed. */
extern void prom_feval(char *forth_string); extern void prom_feval(const char *forth_string);
/* Enter the prom, with possibility of continuation with the 'go' /* Enter the prom, with possibility of continuation with the 'go'
* command in newer proms. * command in newer proms.
...@@ -154,7 +168,7 @@ extern char prom_getchar(void); ...@@ -154,7 +168,7 @@ extern char prom_getchar(void);
extern void prom_putchar(char character); extern void prom_putchar(char character);
/* Prom's internal routines, don't use in kernel/boot code. */ /* Prom's internal routines, don't use in kernel/boot code. */
extern void prom_printf(char *fmt, ...); extern void prom_printf(const char *fmt, ...);
extern void prom_write(const char *buf, unsigned int len); extern void prom_write(const char *buf, unsigned int len);
/* Query for input device type */ /* Query for input device type */
...@@ -215,7 +229,7 @@ extern int prom_getunumber(int syndrome_code, ...@@ -215,7 +229,7 @@ extern int prom_getunumber(int syndrome_code,
char *buf, int buflen); char *buf, int buflen);
/* Retain physical memory to the caller across soft resets. */ /* Retain physical memory to the caller across soft resets. */
extern unsigned long prom_retain(char *name, extern unsigned long prom_retain(const char *name,
unsigned long pa_low, unsigned long pa_high, unsigned long pa_low, unsigned long pa_high,
long size, long align); long size, long align);
...@@ -269,28 +283,28 @@ extern int prom_getsibling(int node); ...@@ -269,28 +283,28 @@ extern int prom_getsibling(int node);
/* Get the length, at the passed node, of the given property type. /* Get the length, at the passed node, of the given property type.
* Returns -1 on error (ie. no such property at this node). * Returns -1 on error (ie. no such property at this node).
*/ */
extern int prom_getproplen(int thisnode, char *property); extern int prom_getproplen(int thisnode, const char *property);
/* Fetch the requested property using the given buffer. Returns /* Fetch the requested property using the given buffer. Returns
* the number of bytes the prom put into your buffer or -1 on error. * the number of bytes the prom put into your buffer or -1 on error.
*/ */
extern int prom_getproperty(int thisnode, char *property, extern int prom_getproperty(int thisnode, const char *property,
char *prop_buffer, int propbuf_size); char *prop_buffer, int propbuf_size);
/* Acquire an integer property. */ /* Acquire an integer property. */
extern int prom_getint(int node, char *property); extern int prom_getint(int node, const char *property);
/* Acquire an integer property, with a default value. */ /* Acquire an integer property, with a default value. */
extern int prom_getintdefault(int node, char *property, int defval); extern int prom_getintdefault(int node, const char *property, int defval);
/* Acquire a boolean property, 0=FALSE 1=TRUE. */ /* Acquire a boolean property, 0=FALSE 1=TRUE. */
extern int prom_getbool(int node, char *prop); extern int prom_getbool(int node, const char *prop);
/* Acquire a string property, null string on error. */ /* Acquire a string property, null string on error. */
extern void prom_getstring(int node, char *prop, char *buf, int bufsize); extern void prom_getstring(int node, const char *prop, char *buf, int bufsize);
/* Does the passed node have the given "name"? YES=1 NO=0 */ /* Does the passed node have the given "name"? YES=1 NO=0 */
extern int prom_nodematch(int thisnode, char *name); extern int prom_nodematch(int thisnode, const char *name);
/* Puts in buffer a prom name in the form name@x,y or name (x for which_io /* Puts in buffer a prom name in the form name@x,y or name (x for which_io
* and y for first regs phys address * and y for first regs phys address
...@@ -300,7 +314,7 @@ extern int prom_getname(int node, char *buf, int buflen); ...@@ -300,7 +314,7 @@ extern int prom_getname(int node, char *buf, int buflen);
/* Search all siblings starting at the passed node for "name" matching /* Search all siblings starting at the passed node for "name" matching
* the given string. Returns the node on success, zero on failure. * the given string. Returns the node on success, zero on failure.
*/ */
extern int prom_searchsiblings(int node_start, char *name); extern int prom_searchsiblings(int node_start, const char *name);
/* Return the first property type, as a string, for the given node. /* Return the first property type, as a string, for the given node.
* Returns a null string on error. Buffer should be at least 32B long. * Returns a null string on error. Buffer should be at least 32B long.
...@@ -310,21 +324,21 @@ extern char *prom_firstprop(int node, char *buffer); ...@@ -310,21 +324,21 @@ extern char *prom_firstprop(int node, char *buffer);
/* Returns the next property after the passed property for the given /* Returns the next property after the passed property for the given
* node. Returns null string on failure. Buffer should be at least 32B long. * node. Returns null string on failure. Buffer should be at least 32B long.
*/ */
extern char *prom_nextprop(int node, char *prev_property, char *buffer); extern char *prom_nextprop(int node, const char *prev_property, char *buffer);
/* Returns 1 if the specified node has given property. */ /* Returns 1 if the specified node has given property. */
extern int prom_node_has_property(int node, char *property); extern int prom_node_has_property(int node, const char *property);
/* Returns phandle of the path specified */ /* Returns phandle of the path specified */
extern int prom_finddevice(char *name); extern int prom_finddevice(const char *name);
/* Set the indicated property at the given node with the passed value. /* Set the indicated property at the given node with the passed value.
* Returns the number of bytes of your value that the prom took. * Returns the number of bytes of your value that the prom took.
*/ */
extern int prom_setprop(int node, char *prop_name, char *prop_value, extern int prom_setprop(int node, const char *prop_name, char *prop_value,
int value_size); int value_size);
extern int prom_pathtoinode(char *path); extern int prom_pathtoinode(const char *path);
extern int prom_inst2pkg(int); extern int prom_inst2pkg(int);
/* CPU probing helpers. */ /* CPU probing helpers. */
...@@ -334,7 +348,7 @@ int cpu_find_by_mid(int mid, int *prom_node); ...@@ -334,7 +348,7 @@ int cpu_find_by_mid(int mid, int *prom_node);
/* Client interface level routines. */ /* Client interface level routines. */
extern void prom_set_trap_table(unsigned long tba); extern void prom_set_trap_table(unsigned long tba);
extern long p1275_cmd (char *, long, ...); extern long p1275_cmd(const char *, long, ...);
#if 0 #if 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment