2008-05-19 23:52:27 +00:00
|
|
|
/*
|
2005-04-16 22:20:36 +00:00
|
|
|
* misc.c: Miscellaneous prom functions that don't belong
|
|
|
|
* anywhere else.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
|
|
|
|
* Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/delay.h>
|
2009-01-09 00:58:20 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/openprom.h>
|
|
|
|
#include <asm/oplib.h>
|
2007-07-12 22:55:55 +00:00
|
|
|
#include <asm/ldc.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-11-16 20:24:16 +00:00
|
|
|
static int prom_service_exists(const char *service_name)
|
2007-05-25 07:37:12 +00:00
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[5];
|
2007-05-25 07:37:12 +00:00
|
|
|
|
2010-08-24 06:10:57 +00:00
|
|
|
args[0] = (unsigned long) "test";
|
|
|
|
args[1] = 1;
|
|
|
|
args[2] = 1;
|
|
|
|
args[3] = (unsigned long) service_name;
|
|
|
|
args[4] = (unsigned long) -1;
|
|
|
|
|
|
|
|
p1275_cmd_direct(args);
|
|
|
|
|
|
|
|
if (args[4])
|
2007-05-25 07:37:12 +00:00
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void prom_sun4v_guest_soft_state(void)
|
|
|
|
{
|
|
|
|
const char *svc = "SUNW,soft-state-supported";
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[3];
|
2007-05-25 07:37:12 +00:00
|
|
|
|
|
|
|
if (!prom_service_exists(svc))
|
|
|
|
return;
|
2010-08-24 06:10:57 +00:00
|
|
|
args[0] = (unsigned long) svc;
|
|
|
|
args[1] = 0;
|
|
|
|
args[2] = 0;
|
|
|
|
p1275_cmd_direct(args);
|
2007-05-25 07:37:12 +00:00
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Reset and reboot the machine with the command 'bcommand'. */
|
[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: David S. Miller <davem@davemloft.net>
2005-09-23 03:11:33 +00:00
|
|
|
void prom_reboot(const char *bcommand)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[4];
|
|
|
|
|
2007-07-12 22:55:55 +00:00
|
|
|
#ifdef CONFIG_SUN_LDOMS
|
|
|
|
if (ldom_domaining_enabled)
|
|
|
|
ldom_reboot(bcommand);
|
|
|
|
#endif
|
2010-08-24 06:10:57 +00:00
|
|
|
args[0] = (unsigned long) "boot";
|
|
|
|
args[1] = 1;
|
|
|
|
args[2] = 0;
|
|
|
|
args[3] = (unsigned long) bcommand;
|
|
|
|
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Forth evaluate the expression contained in 'fstring'. */
|
[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: David S. Miller <davem@davemloft.net>
2005-09-23 03:11:33 +00:00
|
|
|
void prom_feval(const char *fstring)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[5];
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!fstring || fstring[0] == 0)
|
|
|
|
return;
|
2010-08-24 06:10:57 +00:00
|
|
|
args[0] = (unsigned long) "interpret";
|
|
|
|
args[1] = 1;
|
|
|
|
args[2] = 1;
|
|
|
|
args[3] = (unsigned long) fstring;
|
|
|
|
args[4] = (unsigned long) -1;
|
|
|
|
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-01-09 00:58:20 +00:00
|
|
|
EXPORT_SYMBOL(prom_feval);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Drop into the prom, with the chance to continue with the 'go'
|
|
|
|
* prom command.
|
|
|
|
*/
|
|
|
|
void prom_cmdline(void)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[3];
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
smp_capture();
|
|
|
|
#endif
|
|
|
|
|
2010-08-24 06:10:57 +00:00
|
|
|
args[0] = (unsigned long) "enter";
|
|
|
|
args[1] = 0;
|
|
|
|
args[2] = 0;
|
|
|
|
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
smp_release();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Drop into the prom, but completely terminate the program.
|
|
|
|
* No chance of continuing.
|
|
|
|
*/
|
2009-09-04 10:38:54 +00:00
|
|
|
void notrace prom_halt(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[3];
|
|
|
|
|
[SPARC64]: Initial LDOM cpu hotplug support.
Only adding cpus is supports at the moment, removal
will come next.
When new cpus are configured, the machine description is
updated. When we get the configure request we pass in a
cpu mask of to-be-added cpus to the mdesc CPU node parser
so it only fetches information for those cpus. That code
also proceeds to update the SMT/multi-core scheduling bitmaps.
cpu_up() does all the work and we return the status back
over the DS channel.
CPUs via dr-cpu need to be booted straight out of the
hypervisor, and this requires:
1) A new trampoline mechanism. CPUs are booted straight
out of the hypervisor with MMU disabled and running in
physical addresses with no mappings installed in the TLB.
The new hvtramp.S code sets up the critical cpu state,
installs the locked TLB mappings for the kernel, and
turns the MMU on. It then proceeds to follow the logic
of the existing trampoline.S SMP cpu bringup code.
2) All calls into OBP have to be disallowed when domaining
is enabled. Since cpus boot straight into the kernel from
the hypervisor, OBP has no state about that cpu and therefore
cannot handle being invoked on that cpu.
Luckily it's only a handful of interfaces which can be called
after the OBP device tree is obtained. For example, rebooting,
halting, powering-off, and setting options node variables.
CPU removal support will require some infrastructure changes
here. Namely we'll have to process the requests via a true
kernel thread instead of in a workqueue. workqueues run on
a per-cpu thread, but when unconfiguring we might need to
force the thread to execute on another cpu if the current cpu
is the one being removed. Removal of a cpu also causes the kernel
to destroy that cpu's workqueue running thread.
Another issue on removal is that we may have interrupts still
pointing to the cpu-to-be-removed. So new code will be needed
to walk the active INO list and retarget those cpus as-needed.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-07-13 23:03:42 +00:00
|
|
|
#ifdef CONFIG_SUN_LDOMS
|
|
|
|
if (ldom_domaining_enabled)
|
|
|
|
ldom_power_off();
|
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
again:
|
2010-08-24 06:10:57 +00:00
|
|
|
args[0] = (unsigned long) "exit";
|
|
|
|
args[1] = 0;
|
|
|
|
args[2] = 0;
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
goto again; /* PROM is out to get me -DaveM */
|
|
|
|
}
|
|
|
|
|
|
|
|
void prom_halt_power_off(void)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[3];
|
|
|
|
|
[SPARC64]: Initial LDOM cpu hotplug support.
Only adding cpus is supports at the moment, removal
will come next.
When new cpus are configured, the machine description is
updated. When we get the configure request we pass in a
cpu mask of to-be-added cpus to the mdesc CPU node parser
so it only fetches information for those cpus. That code
also proceeds to update the SMT/multi-core scheduling bitmaps.
cpu_up() does all the work and we return the status back
over the DS channel.
CPUs via dr-cpu need to be booted straight out of the
hypervisor, and this requires:
1) A new trampoline mechanism. CPUs are booted straight
out of the hypervisor with MMU disabled and running in
physical addresses with no mappings installed in the TLB.
The new hvtramp.S code sets up the critical cpu state,
installs the locked TLB mappings for the kernel, and
turns the MMU on. It then proceeds to follow the logic
of the existing trampoline.S SMP cpu bringup code.
2) All calls into OBP have to be disallowed when domaining
is enabled. Since cpus boot straight into the kernel from
the hypervisor, OBP has no state about that cpu and therefore
cannot handle being invoked on that cpu.
Luckily it's only a handful of interfaces which can be called
after the OBP device tree is obtained. For example, rebooting,
halting, powering-off, and setting options node variables.
CPU removal support will require some infrastructure changes
here. Namely we'll have to process the requests via a true
kernel thread instead of in a workqueue. workqueues run on
a per-cpu thread, but when unconfiguring we might need to
force the thread to execute on another cpu if the current cpu
is the one being removed. Removal of a cpu also causes the kernel
to destroy that cpu's workqueue running thread.
Another issue on removal is that we may have interrupts still
pointing to the cpu-to-be-removed. So new code will be needed
to walk the active INO list and retarget those cpus as-needed.
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-07-13 23:03:42 +00:00
|
|
|
#ifdef CONFIG_SUN_LDOMS
|
|
|
|
if (ldom_domaining_enabled)
|
|
|
|
ldom_power_off();
|
|
|
|
#endif
|
2010-08-24 06:10:57 +00:00
|
|
|
args[0] = (unsigned long) "SUNW,power-off";
|
|
|
|
args[1] = 0;
|
|
|
|
args[2] = 0;
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* if nothing else helps, we just halt */
|
|
|
|
prom_halt();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the idprom and stuff it into buffer 'idbuf'. Returns the
|
|
|
|
* format type. 'num_bytes' is the number of bytes that your idbuf
|
|
|
|
* has space for. Returns 0xff on error.
|
|
|
|
*/
|
|
|
|
unsigned char prom_get_idprom(char *idbuf, int num_bytes)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = prom_getproplen(prom_root_node, "idprom");
|
|
|
|
if ((len >num_bytes) || (len == -1))
|
|
|
|
return 0xff;
|
|
|
|
if (!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
|
|
|
|
return idbuf[0];
|
|
|
|
|
|
|
|
return 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
int prom_get_mmu_ihandle(void)
|
|
|
|
{
|
2010-10-08 21:18:11 +00:00
|
|
|
phandle node;
|
|
|
|
int ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
[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: David S. Miller <davem@davemloft.net>
2005-09-23 03:11:33 +00:00
|
|
|
if (prom_mmu_ihandle_cache != 0)
|
|
|
|
return prom_mmu_ihandle_cache;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
[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: David S. Miller <davem@davemloft.net>
2005-09-23 03:11:33 +00:00
|
|
|
node = prom_finddevice(prom_chosen_path);
|
|
|
|
ret = prom_getint(node, prom_mmu_name);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret == -1 || ret == 0)
|
[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: David S. Miller <davem@davemloft.net>
2005-09-23 03:11:33 +00:00
|
|
|
prom_mmu_ihandle_cache = -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
[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: David S. Miller <davem@davemloft.net>
2005-09-23 03:11:33 +00:00
|
|
|
prom_mmu_ihandle_cache = ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int prom_get_memory_ihandle(void)
|
|
|
|
{
|
|
|
|
static int memory_ihandle_cache;
|
2010-10-08 21:18:11 +00:00
|
|
|
phandle node;
|
|
|
|
int ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (memory_ihandle_cache != 0)
|
|
|
|
return memory_ihandle_cache;
|
|
|
|
|
|
|
|
node = prom_finddevice("/chosen");
|
|
|
|
ret = prom_getint(node, "memory");
|
|
|
|
if (ret == -1 || ret == 0)
|
|
|
|
memory_ihandle_cache = -1;
|
|
|
|
else
|
|
|
|
memory_ihandle_cache = ret;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Load explicit I/D TLB entries. */
|
2010-08-24 06:10:57 +00:00
|
|
|
static long tlb_load(const char *type, unsigned long index,
|
|
|
|
unsigned long tte_data, unsigned long vaddr)
|
|
|
|
{
|
|
|
|
unsigned long args[9];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) prom_callmethod_name;
|
|
|
|
args[1] = 5;
|
|
|
|
args[2] = 1;
|
|
|
|
args[3] = (unsigned long) type;
|
|
|
|
args[4] = (unsigned int) prom_get_mmu_ihandle();
|
|
|
|
args[5] = vaddr;
|
|
|
|
args[6] = tte_data;
|
|
|
|
args[7] = index;
|
|
|
|
args[8] = (unsigned long) -1;
|
|
|
|
|
|
|
|
p1275_cmd_direct(args);
|
|
|
|
|
|
|
|
return (long) args[8];
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
long prom_itlb_load(unsigned long index,
|
|
|
|
unsigned long tte_data,
|
|
|
|
unsigned long vaddr)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
return tlb_load("SUNW,itlb-load", index, tte_data, vaddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
long prom_dtlb_load(unsigned long index,
|
|
|
|
unsigned long tte_data,
|
|
|
|
unsigned long vaddr)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
return tlb_load("SUNW,dtlb-load", index, tte_data, vaddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int prom_map(int mode, unsigned long size,
|
|
|
|
unsigned long vaddr, unsigned long paddr)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[11];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
args[0] = (unsigned long) prom_callmethod_name;
|
|
|
|
args[1] = 7;
|
|
|
|
args[2] = 1;
|
|
|
|
args[3] = (unsigned long) prom_map_name;
|
|
|
|
args[4] = (unsigned int) prom_get_mmu_ihandle();
|
|
|
|
args[5] = (unsigned int) mode;
|
|
|
|
args[6] = size;
|
|
|
|
args[7] = vaddr;
|
|
|
|
args[8] = 0;
|
|
|
|
args[9] = paddr;
|
|
|
|
args[10] = (unsigned long) -1;
|
|
|
|
|
|
|
|
p1275_cmd_direct(args);
|
|
|
|
|
|
|
|
ret = (int) args[10];
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret == 0)
|
|
|
|
ret = -1;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void prom_unmap(unsigned long size, unsigned long vaddr)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[7];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) prom_callmethod_name;
|
|
|
|
args[1] = 4;
|
|
|
|
args[2] = 0;
|
|
|
|
args[3] = (unsigned long) prom_unmap_name;
|
|
|
|
args[4] = (unsigned int) prom_get_mmu_ihandle();
|
|
|
|
args[5] = size;
|
|
|
|
args[6] = vaddr;
|
|
|
|
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set aside physical memory which is not touched or modified
|
|
|
|
* across soft resets.
|
|
|
|
*/
|
2010-08-24 06:10:57 +00:00
|
|
|
int prom_retain(const char *name, unsigned long size,
|
|
|
|
unsigned long align, unsigned long *paddr)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[11];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) prom_callmethod_name;
|
|
|
|
args[1] = 5;
|
|
|
|
args[2] = 3;
|
|
|
|
args[3] = (unsigned long) "SUNW,retain";
|
|
|
|
args[4] = (unsigned int) prom_get_memory_ihandle();
|
|
|
|
args[5] = align;
|
|
|
|
args[6] = size;
|
|
|
|
args[7] = (unsigned long) name;
|
|
|
|
args[8] = (unsigned long) -1;
|
|
|
|
args[9] = (unsigned long) -1;
|
|
|
|
args[10] = (unsigned long) -1;
|
|
|
|
|
|
|
|
p1275_cmd_direct(args);
|
|
|
|
|
|
|
|
if (args[8])
|
|
|
|
return (int) args[8];
|
|
|
|
|
|
|
|
/* Next we get "phys_high" then "phys_low". On 64-bit
|
|
|
|
* the phys_high cell is don't care since the phys_low
|
|
|
|
* cell has the full value.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2010-08-24 06:10:57 +00:00
|
|
|
*paddr = args[10];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-08-24 06:10:57 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get "Unumber" string for the SIMM at the given
|
|
|
|
* memory address. Usually this will be of the form
|
|
|
|
* "Uxxxx" where xxxx is a decimal number which is
|
|
|
|
* etched into the motherboard next to the SIMM slot
|
|
|
|
* in question.
|
|
|
|
*/
|
|
|
|
int prom_getunumber(int syndrome_code,
|
|
|
|
unsigned long phys_addr,
|
|
|
|
char *buf, int buflen)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[12];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) prom_callmethod_name;
|
|
|
|
args[1] = 7;
|
|
|
|
args[2] = 2;
|
|
|
|
args[3] = (unsigned long) "SUNW,get-unumber";
|
|
|
|
args[4] = (unsigned int) prom_get_memory_ihandle();
|
|
|
|
args[5] = buflen;
|
|
|
|
args[6] = (unsigned long) buf;
|
|
|
|
args[7] = 0;
|
|
|
|
args[8] = phys_addr;
|
|
|
|
args[9] = (unsigned int) syndrome_code;
|
|
|
|
args[10] = (unsigned long) -1;
|
|
|
|
args[11] = (unsigned long) -1;
|
|
|
|
|
|
|
|
p1275_cmd_direct(args);
|
|
|
|
|
|
|
|
return (int) args[10];
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Power management extensions. */
|
|
|
|
void prom_sleepself(void)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[3];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) "SUNW,sleep-self";
|
|
|
|
args[1] = 0;
|
|
|
|
args[2] = 0;
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int prom_sleepsystem(void)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[4];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) "SUNW,sleep-system";
|
|
|
|
args[1] = 0;
|
|
|
|
args[2] = 1;
|
|
|
|
args[3] = (unsigned long) -1;
|
|
|
|
p1275_cmd_direct(args);
|
|
|
|
|
|
|
|
return (int) args[3];
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int prom_wakeupsystem(void)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[4];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) "SUNW,wakeup-system";
|
|
|
|
args[1] = 0;
|
|
|
|
args[2] = 1;
|
|
|
|
args[3] = (unsigned long) -1;
|
|
|
|
p1275_cmd_direct(args);
|
|
|
|
|
|
|
|
return (int) args[3];
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
2006-02-15 10:26:54 +00:00
|
|
|
void prom_startcpu(int cpunode, unsigned long pc, unsigned long arg)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[6];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) "SUNW,start-cpu";
|
|
|
|
args[1] = 3;
|
|
|
|
args[2] = 0;
|
|
|
|
args[3] = (unsigned int) cpunode;
|
|
|
|
args[4] = pc;
|
|
|
|
args[5] = arg;
|
|
|
|
p1275_cmd_direct(args);
|
2006-02-15 10:26:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void prom_startcpu_cpuid(int cpuid, unsigned long pc, unsigned long arg)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[6];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) "SUNW,start-cpu-by-cpuid";
|
|
|
|
args[1] = 3;
|
|
|
|
args[2] = 0;
|
|
|
|
args[3] = (unsigned int) cpuid;
|
|
|
|
args[4] = pc;
|
|
|
|
args[5] = arg;
|
|
|
|
p1275_cmd_direct(args);
|
2006-02-15 10:26:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void prom_stopcpu_cpuid(int cpuid)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[4];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) "SUNW,stop-cpu-by-cpuid";
|
|
|
|
args[1] = 1;
|
|
|
|
args[2] = 0;
|
|
|
|
args[3] = (unsigned int) cpuid;
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void prom_stopself(void)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[3];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) "SUNW,stop-self";
|
|
|
|
args[1] = 0;
|
|
|
|
args[2] = 0;
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void prom_idleself(void)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[3];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) "SUNW,idle-self";
|
|
|
|
args[1] = 0;
|
|
|
|
args[2] = 0;
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void prom_resumecpu(int cpunode)
|
|
|
|
{
|
2010-08-24 06:10:57 +00:00
|
|
|
unsigned long args[4];
|
|
|
|
|
|
|
|
args[0] = (unsigned long) "SUNW,resume-cpu";
|
|
|
|
args[1] = 1;
|
|
|
|
args[2] = 0;
|
|
|
|
args[3] = (unsigned int) cpunode;
|
|
|
|
p1275_cmd_direct(args);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
#endif
|