2006-05-10 23:00:34 +00:00
|
|
|
/*
|
|
|
|
|
* PROM interface support
|
|
|
|
|
* Copyright 1996 The Australian National University.
|
|
|
|
|
* Copyright 1996 Fujitsu Laboratories Limited
|
|
|
|
|
* Copyright 1999 Pete A. Zaitcev
|
|
|
|
|
* This software may be distributed under the terms of the Gnu
|
|
|
|
|
* Public License version 2 or later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "openprom.h"
|
|
|
|
|
#include "asm/io.h"
|
|
|
|
|
#include "asm/types.h"
|
|
|
|
|
#include "libc/vsprintf.h"
|
|
|
|
|
#include "openbios/config.h"
|
|
|
|
|
#include "openbios/bindings.h"
|
2008-07-07 18:35:51 +00:00
|
|
|
#include "openbios/drivers.h"
|
2006-05-10 23:00:34 +00:00
|
|
|
#include "openbios/kernel.h"
|
|
|
|
|
#include "openbios/sysinclude.h"
|
2008-07-07 18:35:51 +00:00
|
|
|
#include "sys_info.h"
|
|
|
|
|
#include "boot.h"
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2006-05-15 08:17:51 +00:00
|
|
|
#ifdef CONFIG_DEBUG_OBP
|
2006-05-10 23:00:34 +00:00
|
|
|
#define DPRINTF(fmt, args...) \
|
|
|
|
|
do { printk(fmt , ##args); } while (0)
|
|
|
|
|
#else
|
|
|
|
|
#define DPRINTF(fmt, args...)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define PAGE_SIZE 4096
|
|
|
|
|
|
|
|
|
|
static struct linux_mlist_v0 totphys[1];
|
|
|
|
|
static struct linux_mlist_v0 totmap[1];
|
|
|
|
|
static struct linux_mlist_v0 totavail[1];
|
|
|
|
|
|
|
|
|
|
static struct linux_mlist_v0 *ptphys;
|
|
|
|
|
static struct linux_mlist_v0 *ptmap;
|
|
|
|
|
static struct linux_mlist_v0 *ptavail;
|
2006-07-23 14:29:29 +00:00
|
|
|
char obp_stdin, obp_stdout;
|
2006-05-10 23:00:34 +00:00
|
|
|
static int obp_fd_stdin, obp_fd_stdout;
|
2006-07-23 14:29:29 +00:00
|
|
|
const char *obp_stdin_path, *obp_stdout_path;
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
static int obp_nextnode(int node);
|
|
|
|
|
static int obp_child(int node);
|
|
|
|
|
static int obp_proplen(int node, char *name);
|
|
|
|
|
static int obp_getprop(int node, char *name, char *val);
|
|
|
|
|
static int obp_setprop(int node, char *name, char *val, int len);
|
|
|
|
|
static const char *obp_nextprop(int node, char *name);
|
2006-05-16 17:36:09 +00:00
|
|
|
static int obp_devread(int dev_desc, char *buf, int nbytes);
|
|
|
|
|
static int obp_devseek(int dev_desc, int hi, int lo);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2006-07-23 14:29:29 +00:00
|
|
|
struct linux_arguments_v0 obp_arg;
|
2008-11-02 19:25:05 +00:00
|
|
|
static const char *bootpath;
|
2006-05-10 23:00:34 +00:00
|
|
|
static const struct linux_arguments_v0 * const obp_argp = &obp_arg;
|
|
|
|
|
|
2006-06-05 19:49:53 +00:00
|
|
|
static void (*sync_hook)(void);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
static struct linux_romvec romvec0;
|
|
|
|
|
|
2006-05-22 10:33:31 +00:00
|
|
|
static void doublewalk(__attribute__((unused)) unsigned int ptab1,
|
|
|
|
|
__attribute__((unused)) unsigned int va)
|
2006-05-10 23:00:34 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_nextnode(int node)
|
|
|
|
|
{
|
|
|
|
|
int peer;
|
|
|
|
|
|
|
|
|
|
PUSH(node);
|
|
|
|
|
fword("peer");
|
|
|
|
|
peer = POP();
|
2006-05-18 21:57:08 +00:00
|
|
|
DPRINTF("obp_nextnode(0x%x) = 0x%x\n", node, peer);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
return peer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_child(int node)
|
|
|
|
|
{
|
|
|
|
|
int child;
|
|
|
|
|
|
|
|
|
|
PUSH(node);
|
|
|
|
|
fword("child");
|
|
|
|
|
child = POP();
|
2006-05-18 21:57:08 +00:00
|
|
|
DPRINTF("obp_child(0x%x) = 0x%x\n", node, child);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_proplen(int node, char *name)
|
|
|
|
|
{
|
|
|
|
|
int notfound;
|
|
|
|
|
|
2007-08-11 07:45:33 +00:00
|
|
|
if (!node) {
|
|
|
|
|
DPRINTF("obp_proplen(0x0, %s) = -1\n", name);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-10 23:00:34 +00:00
|
|
|
push_str(name);
|
|
|
|
|
PUSH(node);
|
|
|
|
|
fword("get-package-property");
|
|
|
|
|
notfound = POP();
|
|
|
|
|
|
|
|
|
|
if (notfound) {
|
2006-05-18 21:57:08 +00:00
|
|
|
DPRINTF("obp_proplen(0x%x, %s) (not found)\n", node, name);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
} else {
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
len = POP();
|
|
|
|
|
(void) POP();
|
2006-05-18 21:57:08 +00:00
|
|
|
DPRINTF("obp_proplen(0x%x, %s) = %d\n", node, name, len);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-24 20:00:02 +00:00
|
|
|
#ifdef CONFIG_DEBUG_OBP
|
Patch for SunOS compatibility from pjcreath+openbios@gmail.com:
I've been trying to get old versions of SunOS to load under qemu. In
doing so, I've encountered a number of bugs in OBP. I'm not always
certain of the best fix, but I can at least provide a quick hack that
will get people farther along.
1) Error message: "kmem_alloc failed, nbytes 680"
Bug: obp_dumb_memalloc is a bit too dumb. It needs to pick an address
if passed a null address. (According to the comment in the allocator
in OpenSolaris prom_alloc.c (see
<http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/psm/promif/ieee1275/sun4/prom_alloc.c>),
"If virthint is zero, a suitable virt is chosen.")
Quick fix: If passed a null address, start doling out addresses at
10MB and increment by size.
Shortcomings: The quick fix ignores the issue of free() and doesn't
remove memory from the virtual-memory/available node.
After the quick fix, the boot gets farther, leading us to:
2) Error message: "Unhandled Exception 0x00000080"
Bug: Trap 0 (entry 0x80 in the table, i.e. syscall_trap_4x) is
undefined. This is because the SunOS bootloader installs the trap by
writing code in the trap table, but the trap table is in the .text
section of OpenBIOS. Thus the trap 0 handler simply jumps to "bug".
Quick fix: Move the trap table to the .data section. Insert a "b
entry; nop; nop; nop;" before "bug:".
Shortcomings: Requires the extra "b entry" code. Allows the only VM
copy of the trap table to be permanently changed. OpenBIOS should
copy the read-only trap table to read-write memory (and update %tbr)
upon reset/entry.
3) #2 above actually exposes another bug. The write to the read-only
trap table does not cause an access violation -- instead, it silently
fails. The "std" instruction at 0x403e6c in the bootloader has no
effect.
Bug: Uncertain. It could be a systemic bug in qemu, but it appears
that the VM's MMU believes that the page is writable. That means that
the VM's MMU is not having the access protection flags set for pages
mapped to ROM. It thinks everything is rwx.
Fix?: The VM's MMU should have the access protection flags properly
set for each ROM section. This should probably be done within
OpenBIOS. E.g., .text should be r-x, .data should probably be rwx,
etc.
This is the one fix I'm really not sure how to implement. Any
suggestions? This may be a problem that only affects this bootloader,
so fixing #2 above may be all that's strictly necessary. But I'm not
positive that this bug doesn't have other ill effects I haven't found
yet.
At any rate, fixing #2 gets us still further, to:
4) Error messages:
"obp_devopen(sd(0,0,0):d) = 0xffd8e270
obp_inst2pkg(fd 0xffd8e270) = 0xffd57f44
obp_getprop(0xffd57f44, device_type) (not found)"
Bug: The OpenBIOS "interpose" implementation is not transparent to
non-interposition-aware code (in violation of the interposition spec).
The inst2pkg call in this sequence returns the phandle for
/packages/misc-files, instead of the proper phandle.
Quick fix: Comment out the "interpose disk-label" lines in ob_sd_open.
Shortcomings: It disables disk-label. The correct fix is to fix the
underlying problem with interposition, but I'm not sure exactly what
it is. Could someone help?
Fixing #4 gets us quite a bit further, until:
5) Error message:
"Unhandled Exception 0x00000009
PC = 0xf0138b20 NPC = 0xf0138b24
Stopping execution"
Bug: The instruction is trying to read from 0xfd020000+4, which is an
invalid address. This address isn't mapped by OBP by default on Sun
hardware, so the bootloader must be trying to (a) map this address and
failing silently or (b) skipping the mapping for some reason. The
instruction is hard-coded to look at this absolute address.
Fix: Unknown. This may be another instance of writes silently
failing, hence my interest in #3 above. It could also be a
side-effect of the quick fix for #4.
6) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008f0c addr=feff8008 mmu_fsr=3a6 rw=2
MMU sfsr=3a6: Invalid Address on supv data store at level 3
regs at fd008f0c:
psr=4400fc7 pc=f00053f4 npc=f00053f8
..."
Bug: Real sun4m hardware registers 4 CPU-specific interrupts followed
by a system-wide interrupt, regardless of the number of CPUs
installed. The same is true of counters. SunOS looks at the 5th
interrupt for the system-wide interrupt. OBP, since there's only one
CPU, just sets up one CPU-specific interrupt followed by the
system-wide interrupt, so there is no 5th interrupt. See the comment
on "NCPU" at
<http://stuff.mit.edu/afs/athena/astaff/project/opssrc/sys.sunos/sun4m/devaddr.h>.
Fix: in obp_interrupt_init() and obp_counter_init() register 4
CPU-specific interrupts before allocating the system-wide interrupt.
The kernel will then map the 5th interrupt to the system-wide
interrupt.
7) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d8c addr=7ff000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d8c:
psr=4000cc4 pc=f01339a4 npc=f01339a8
..."
Bug: The command-line arguments passed to the kernel are fixed at
address 0x7FF000 (CMDLINE_ADDR, passed from qemu via nv_info.cmdline),
which is no longer mapped by the time the kernel looks at the boot
arguments. A regular Sun boot ROM will copy this into mapped memory.
Fix: Copy the string in nv_info.cmdline to a OpenBIOS global (since
OpenBIOS continues to be mapped) in ob_nvram_init().
8) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008dec addr=1019000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008dec:
psr=4400cc5 pc=f0131680 npc=f0131684
..."
Bug: The dumb memory allocator from bug #1 was allocating a range that
the SunOS 4 kernel doesn't like.
Fix: Mimic the Sun boot ROM allocator: the top of the heap should be
a 0xFFEDA000 and allocations should return descending addresses. So,
for example, if asking for 0x1000 bytes, the first returned pointer
should be 0xFFED9000.
9) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d2c addr=b1b91000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d2c:
psr=4900cc3 pc=f0142c04 npc=f0142c08
..."
Bug: The precise underlying cause isn't clear. The bug appears due to
a variation between OBP's behavior and stock Sun behavior.
Fix: Add the "cache-physical?" property to the CPU node in
ob_nvram_init() and bump the "mmu-nctx" property up to 4096 (from
256).
git-svn-id: svn://coreboot.org/openbios/openbios-devel@114 f158a5a8-5612-0410-a976-696ce0be7e32
2007-03-09 00:59:05 +00:00
|
|
|
static int looks_like_string(char *str, int len)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int ret = (str[len-1] == '\0');
|
|
|
|
|
for (i = 0; i < len-1 && ret; i++)
|
|
|
|
|
{
|
|
|
|
|
int ch = str[i] & 0xFF;
|
|
|
|
|
if (ch < 0x20 || ch > 0x7F)
|
|
|
|
|
ret = 0;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-05-10 23:00:34 +00:00
|
|
|
static int obp_getprop(int node, char *name, char *value)
|
|
|
|
|
{
|
2006-05-26 10:37:37 +00:00
|
|
|
int notfound, found;
|
|
|
|
|
int len;
|
|
|
|
|
char *str;
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2007-08-11 07:45:33 +00:00
|
|
|
if (!node) {
|
|
|
|
|
DPRINTF("obp_getprop(0x0, %s) = -1\n", name);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-10 23:00:34 +00:00
|
|
|
if (!name) {
|
|
|
|
|
// NULL name means get first property
|
|
|
|
|
push_str("");
|
|
|
|
|
PUSH(node);
|
|
|
|
|
fword("next-property");
|
2006-05-26 10:37:37 +00:00
|
|
|
found = POP();
|
|
|
|
|
if (found) {
|
|
|
|
|
len = POP();
|
|
|
|
|
str = (char *) POP();
|
|
|
|
|
DPRINTF("obp_getprop(0x%x, NULL) = %s\n", node, str);
|
|
|
|
|
|
|
|
|
|
return (int)str;
|
|
|
|
|
}
|
|
|
|
|
DPRINTF("obp_getprop(0x%x, NULL) (not found)\n", node);
|
|
|
|
|
|
|
|
|
|
return -1;
|
2006-05-10 23:00:34 +00:00
|
|
|
} else {
|
|
|
|
|
push_str(name);
|
|
|
|
|
PUSH(node);
|
|
|
|
|
fword("get-package-property");
|
|
|
|
|
notfound = POP();
|
|
|
|
|
}
|
|
|
|
|
if (notfound) {
|
2006-05-18 21:57:08 +00:00
|
|
|
DPRINTF("obp_getprop(0x%x, %s) (not found)\n", node, name);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
} else {
|
|
|
|
|
len = POP();
|
|
|
|
|
str = (char *) POP();
|
2006-05-26 10:37:37 +00:00
|
|
|
if (len > 0)
|
|
|
|
|
memcpy(value, str, len);
|
|
|
|
|
else
|
|
|
|
|
str = "NULL";
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2007-04-24 20:00:02 +00:00
|
|
|
#ifdef CONFIG_DEBUG_OBP
|
Patch for SunOS compatibility from pjcreath+openbios@gmail.com:
I've been trying to get old versions of SunOS to load under qemu. In
doing so, I've encountered a number of bugs in OBP. I'm not always
certain of the best fix, but I can at least provide a quick hack that
will get people farther along.
1) Error message: "kmem_alloc failed, nbytes 680"
Bug: obp_dumb_memalloc is a bit too dumb. It needs to pick an address
if passed a null address. (According to the comment in the allocator
in OpenSolaris prom_alloc.c (see
<http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/psm/promif/ieee1275/sun4/prom_alloc.c>),
"If virthint is zero, a suitable virt is chosen.")
Quick fix: If passed a null address, start doling out addresses at
10MB and increment by size.
Shortcomings: The quick fix ignores the issue of free() and doesn't
remove memory from the virtual-memory/available node.
After the quick fix, the boot gets farther, leading us to:
2) Error message: "Unhandled Exception 0x00000080"
Bug: Trap 0 (entry 0x80 in the table, i.e. syscall_trap_4x) is
undefined. This is because the SunOS bootloader installs the trap by
writing code in the trap table, but the trap table is in the .text
section of OpenBIOS. Thus the trap 0 handler simply jumps to "bug".
Quick fix: Move the trap table to the .data section. Insert a "b
entry; nop; nop; nop;" before "bug:".
Shortcomings: Requires the extra "b entry" code. Allows the only VM
copy of the trap table to be permanently changed. OpenBIOS should
copy the read-only trap table to read-write memory (and update %tbr)
upon reset/entry.
3) #2 above actually exposes another bug. The write to the read-only
trap table does not cause an access violation -- instead, it silently
fails. The "std" instruction at 0x403e6c in the bootloader has no
effect.
Bug: Uncertain. It could be a systemic bug in qemu, but it appears
that the VM's MMU believes that the page is writable. That means that
the VM's MMU is not having the access protection flags set for pages
mapped to ROM. It thinks everything is rwx.
Fix?: The VM's MMU should have the access protection flags properly
set for each ROM section. This should probably be done within
OpenBIOS. E.g., .text should be r-x, .data should probably be rwx,
etc.
This is the one fix I'm really not sure how to implement. Any
suggestions? This may be a problem that only affects this bootloader,
so fixing #2 above may be all that's strictly necessary. But I'm not
positive that this bug doesn't have other ill effects I haven't found
yet.
At any rate, fixing #2 gets us still further, to:
4) Error messages:
"obp_devopen(sd(0,0,0):d) = 0xffd8e270
obp_inst2pkg(fd 0xffd8e270) = 0xffd57f44
obp_getprop(0xffd57f44, device_type) (not found)"
Bug: The OpenBIOS "interpose" implementation is not transparent to
non-interposition-aware code (in violation of the interposition spec).
The inst2pkg call in this sequence returns the phandle for
/packages/misc-files, instead of the proper phandle.
Quick fix: Comment out the "interpose disk-label" lines in ob_sd_open.
Shortcomings: It disables disk-label. The correct fix is to fix the
underlying problem with interposition, but I'm not sure exactly what
it is. Could someone help?
Fixing #4 gets us quite a bit further, until:
5) Error message:
"Unhandled Exception 0x00000009
PC = 0xf0138b20 NPC = 0xf0138b24
Stopping execution"
Bug: The instruction is trying to read from 0xfd020000+4, which is an
invalid address. This address isn't mapped by OBP by default on Sun
hardware, so the bootloader must be trying to (a) map this address and
failing silently or (b) skipping the mapping for some reason. The
instruction is hard-coded to look at this absolute address.
Fix: Unknown. This may be another instance of writes silently
failing, hence my interest in #3 above. It could also be a
side-effect of the quick fix for #4.
6) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008f0c addr=feff8008 mmu_fsr=3a6 rw=2
MMU sfsr=3a6: Invalid Address on supv data store at level 3
regs at fd008f0c:
psr=4400fc7 pc=f00053f4 npc=f00053f8
..."
Bug: Real sun4m hardware registers 4 CPU-specific interrupts followed
by a system-wide interrupt, regardless of the number of CPUs
installed. The same is true of counters. SunOS looks at the 5th
interrupt for the system-wide interrupt. OBP, since there's only one
CPU, just sets up one CPU-specific interrupt followed by the
system-wide interrupt, so there is no 5th interrupt. See the comment
on "NCPU" at
<http://stuff.mit.edu/afs/athena/astaff/project/opssrc/sys.sunos/sun4m/devaddr.h>.
Fix: in obp_interrupt_init() and obp_counter_init() register 4
CPU-specific interrupts before allocating the system-wide interrupt.
The kernel will then map the 5th interrupt to the system-wide
interrupt.
7) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d8c addr=7ff000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d8c:
psr=4000cc4 pc=f01339a4 npc=f01339a8
..."
Bug: The command-line arguments passed to the kernel are fixed at
address 0x7FF000 (CMDLINE_ADDR, passed from qemu via nv_info.cmdline),
which is no longer mapped by the time the kernel looks at the boot
arguments. A regular Sun boot ROM will copy this into mapped memory.
Fix: Copy the string in nv_info.cmdline to a OpenBIOS global (since
OpenBIOS continues to be mapped) in ob_nvram_init().
8) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008dec addr=1019000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008dec:
psr=4400cc5 pc=f0131680 npc=f0131684
..."
Bug: The dumb memory allocator from bug #1 was allocating a range that
the SunOS 4 kernel doesn't like.
Fix: Mimic the Sun boot ROM allocator: the top of the heap should be
a 0xFFEDA000 and allocations should return descending addresses. So,
for example, if asking for 0x1000 bytes, the first returned pointer
should be 0xFFED9000.
9) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d2c addr=b1b91000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d2c:
psr=4900cc3 pc=f0142c04 npc=f0142c08
..."
Bug: The precise underlying cause isn't clear. The bug appears due to
a variation between OBP's behavior and stock Sun behavior.
Fix: Add the "cache-physical?" property to the CPU node in
ob_nvram_init() and bump the "mmu-nctx" property up to 4096 (from
256).
git-svn-id: svn://coreboot.org/openbios/openbios-devel@114 f158a5a8-5612-0410-a976-696ce0be7e32
2007-03-09 00:59:05 +00:00
|
|
|
if (looks_like_string(str, len)) {
|
|
|
|
|
DPRINTF("obp_getprop(0x%x, %s) = %s\n", node, name, str);
|
|
|
|
|
} else {
|
|
|
|
|
int i;
|
|
|
|
|
DPRINTF("obp_getprop(0x%x, %s) = ", node, name);
|
|
|
|
|
for (i = 0; i < len; i++) {
|
2008-07-07 18:35:51 +00:00
|
|
|
DPRINTF("%02x%s", str[i] & 0xFF,
|
Patch for SunOS compatibility from pjcreath+openbios@gmail.com:
I've been trying to get old versions of SunOS to load under qemu. In
doing so, I've encountered a number of bugs in OBP. I'm not always
certain of the best fix, but I can at least provide a quick hack that
will get people farther along.
1) Error message: "kmem_alloc failed, nbytes 680"
Bug: obp_dumb_memalloc is a bit too dumb. It needs to pick an address
if passed a null address. (According to the comment in the allocator
in OpenSolaris prom_alloc.c (see
<http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/psm/promif/ieee1275/sun4/prom_alloc.c>),
"If virthint is zero, a suitable virt is chosen.")
Quick fix: If passed a null address, start doling out addresses at
10MB and increment by size.
Shortcomings: The quick fix ignores the issue of free() and doesn't
remove memory from the virtual-memory/available node.
After the quick fix, the boot gets farther, leading us to:
2) Error message: "Unhandled Exception 0x00000080"
Bug: Trap 0 (entry 0x80 in the table, i.e. syscall_trap_4x) is
undefined. This is because the SunOS bootloader installs the trap by
writing code in the trap table, but the trap table is in the .text
section of OpenBIOS. Thus the trap 0 handler simply jumps to "bug".
Quick fix: Move the trap table to the .data section. Insert a "b
entry; nop; nop; nop;" before "bug:".
Shortcomings: Requires the extra "b entry" code. Allows the only VM
copy of the trap table to be permanently changed. OpenBIOS should
copy the read-only trap table to read-write memory (and update %tbr)
upon reset/entry.
3) #2 above actually exposes another bug. The write to the read-only
trap table does not cause an access violation -- instead, it silently
fails. The "std" instruction at 0x403e6c in the bootloader has no
effect.
Bug: Uncertain. It could be a systemic bug in qemu, but it appears
that the VM's MMU believes that the page is writable. That means that
the VM's MMU is not having the access protection flags set for pages
mapped to ROM. It thinks everything is rwx.
Fix?: The VM's MMU should have the access protection flags properly
set for each ROM section. This should probably be done within
OpenBIOS. E.g., .text should be r-x, .data should probably be rwx,
etc.
This is the one fix I'm really not sure how to implement. Any
suggestions? This may be a problem that only affects this bootloader,
so fixing #2 above may be all that's strictly necessary. But I'm not
positive that this bug doesn't have other ill effects I haven't found
yet.
At any rate, fixing #2 gets us still further, to:
4) Error messages:
"obp_devopen(sd(0,0,0):d) = 0xffd8e270
obp_inst2pkg(fd 0xffd8e270) = 0xffd57f44
obp_getprop(0xffd57f44, device_type) (not found)"
Bug: The OpenBIOS "interpose" implementation is not transparent to
non-interposition-aware code (in violation of the interposition spec).
The inst2pkg call in this sequence returns the phandle for
/packages/misc-files, instead of the proper phandle.
Quick fix: Comment out the "interpose disk-label" lines in ob_sd_open.
Shortcomings: It disables disk-label. The correct fix is to fix the
underlying problem with interposition, but I'm not sure exactly what
it is. Could someone help?
Fixing #4 gets us quite a bit further, until:
5) Error message:
"Unhandled Exception 0x00000009
PC = 0xf0138b20 NPC = 0xf0138b24
Stopping execution"
Bug: The instruction is trying to read from 0xfd020000+4, which is an
invalid address. This address isn't mapped by OBP by default on Sun
hardware, so the bootloader must be trying to (a) map this address and
failing silently or (b) skipping the mapping for some reason. The
instruction is hard-coded to look at this absolute address.
Fix: Unknown. This may be another instance of writes silently
failing, hence my interest in #3 above. It could also be a
side-effect of the quick fix for #4.
6) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008f0c addr=feff8008 mmu_fsr=3a6 rw=2
MMU sfsr=3a6: Invalid Address on supv data store at level 3
regs at fd008f0c:
psr=4400fc7 pc=f00053f4 npc=f00053f8
..."
Bug: Real sun4m hardware registers 4 CPU-specific interrupts followed
by a system-wide interrupt, regardless of the number of CPUs
installed. The same is true of counters. SunOS looks at the 5th
interrupt for the system-wide interrupt. OBP, since there's only one
CPU, just sets up one CPU-specific interrupt followed by the
system-wide interrupt, so there is no 5th interrupt. See the comment
on "NCPU" at
<http://stuff.mit.edu/afs/athena/astaff/project/opssrc/sys.sunos/sun4m/devaddr.h>.
Fix: in obp_interrupt_init() and obp_counter_init() register 4
CPU-specific interrupts before allocating the system-wide interrupt.
The kernel will then map the 5th interrupt to the system-wide
interrupt.
7) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d8c addr=7ff000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d8c:
psr=4000cc4 pc=f01339a4 npc=f01339a8
..."
Bug: The command-line arguments passed to the kernel are fixed at
address 0x7FF000 (CMDLINE_ADDR, passed from qemu via nv_info.cmdline),
which is no longer mapped by the time the kernel looks at the boot
arguments. A regular Sun boot ROM will copy this into mapped memory.
Fix: Copy the string in nv_info.cmdline to a OpenBIOS global (since
OpenBIOS continues to be mapped) in ob_nvram_init().
8) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008dec addr=1019000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008dec:
psr=4400cc5 pc=f0131680 npc=f0131684
..."
Bug: The dumb memory allocator from bug #1 was allocating a range that
the SunOS 4 kernel doesn't like.
Fix: Mimic the Sun boot ROM allocator: the top of the heap should be
a 0xFFEDA000 and allocations should return descending addresses. So,
for example, if asking for 0x1000 bytes, the first returned pointer
should be 0xFFED9000.
9) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d2c addr=b1b91000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d2c:
psr=4900cc3 pc=f0142c04 npc=f0142c08
..."
Bug: The precise underlying cause isn't clear. The bug appears due to
a variation between OBP's behavior and stock Sun behavior.
Fix: Add the "cache-physical?" property to the CPU node in
ob_nvram_init() and bump the "mmu-nctx" property up to 4096 (from
256).
git-svn-id: svn://coreboot.org/openbios/openbios-devel@114 f158a5a8-5612-0410-a976-696ce0be7e32
2007-03-09 00:59:05 +00:00
|
|
|
(len == 4 || i == len-1) ? "" : " ");
|
|
|
|
|
}
|
|
|
|
|
DPRINTF("\n");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char *obp_nextprop(int node, char *name)
|
|
|
|
|
{
|
2006-05-16 17:36:09 +00:00
|
|
|
int found;
|
|
|
|
|
|
2006-05-10 23:00:34 +00:00
|
|
|
if (!name || *name == '\0') {
|
|
|
|
|
// NULL name means get first property
|
2006-05-16 17:36:09 +00:00
|
|
|
push_str("");
|
|
|
|
|
name = "NULL";
|
|
|
|
|
} else {
|
|
|
|
|
push_str(name);
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
2006-05-16 17:36:09 +00:00
|
|
|
PUSH(node);
|
|
|
|
|
fword("next-property");
|
|
|
|
|
found = POP();
|
|
|
|
|
if (!found) {
|
2006-05-18 21:57:08 +00:00
|
|
|
DPRINTF("obp_nextprop(0x%x, %s) (not found)\n", node, name);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2006-05-18 21:57:08 +00:00
|
|
|
return "";
|
2006-05-16 17:36:09 +00:00
|
|
|
} else {
|
|
|
|
|
int len;
|
|
|
|
|
char *str;
|
2008-07-07 18:35:51 +00:00
|
|
|
|
2006-05-16 17:36:09 +00:00
|
|
|
len = POP();
|
|
|
|
|
str = (char *) POP();
|
|
|
|
|
|
2006-05-18 21:57:08 +00:00
|
|
|
DPRINTF("obp_nextprop(0x%x, %s) = %s\n", node, name, str);
|
2006-05-16 17:36:09 +00:00
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
2006-05-26 10:37:37 +00:00
|
|
|
|
|
|
|
|
static int obp_setprop(__attribute__((unused)) int node,
|
|
|
|
|
__attribute__((unused)) char *name,
|
|
|
|
|
__attribute__((unused)) char *value,
|
|
|
|
|
__attribute__((unused)) int len)
|
|
|
|
|
{
|
|
|
|
|
DPRINTF("obp_setprop(0x%x, %s) = %s (%d)\n", node, name, value, len);
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct linux_nodeops nodeops0 = {
|
|
|
|
|
obp_nextnode, /* int (*no_nextnode)(int node); */
|
|
|
|
|
obp_child, /* int (*no_child)(int node); */
|
|
|
|
|
obp_proplen, /* int (*no_proplen)(int node, char *name); */
|
|
|
|
|
obp_getprop, /* int (*no_getprop)(int node,char *name,char *val); */
|
|
|
|
|
obp_setprop, /* int (*no_setprop)(int node, char *name,
|
|
|
|
|
char *val, int len); */
|
|
|
|
|
obp_nextprop /* char * (*no_nextprop)(int node, char *name); */
|
|
|
|
|
};
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
static int obp_nbgetchar(void)
|
|
|
|
|
{
|
2006-05-15 08:17:51 +00:00
|
|
|
return getchar();
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_nbputchar(int ch)
|
|
|
|
|
{
|
|
|
|
|
putchar(ch);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void obp_reboot(char *str)
|
|
|
|
|
{
|
2008-07-05 16:57:17 +00:00
|
|
|
extern volatile unsigned int *reset_reg;
|
2007-05-27 19:49:35 +00:00
|
|
|
|
2006-05-10 23:00:34 +00:00
|
|
|
printk("rebooting (%s)\n", str);
|
2007-05-27 19:49:35 +00:00
|
|
|
*reset_reg = 1;
|
|
|
|
|
printk("reboot failed\n");
|
2006-05-10 23:00:34 +00:00
|
|
|
for (;;) {}
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-29 19:31:28 +00:00
|
|
|
extern volatile unsigned char *power_reg;
|
2006-05-22 10:33:31 +00:00
|
|
|
static void obp_abort(void)
|
2006-05-10 23:00:34 +00:00
|
|
|
{
|
2007-05-27 19:49:35 +00:00
|
|
|
|
2006-05-10 23:00:34 +00:00
|
|
|
printk("abort, power off\n");
|
2007-05-27 19:49:35 +00:00
|
|
|
*power_reg = 1;
|
|
|
|
|
printk("power off failed\n");
|
2006-05-10 23:00:34 +00:00
|
|
|
for (;;) {}
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-22 10:33:31 +00:00
|
|
|
static void obp_halt(void)
|
2006-05-10 23:00:34 +00:00
|
|
|
{
|
|
|
|
|
printk("halt, power off\n");
|
2007-05-27 19:49:35 +00:00
|
|
|
*power_reg = 1;
|
|
|
|
|
printk("power off failed\n");
|
2006-05-10 23:00:34 +00:00
|
|
|
for (;;) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_devopen(char *str)
|
|
|
|
|
{
|
2006-05-15 08:17:51 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
push_str(str);
|
|
|
|
|
fword("open-dev");
|
|
|
|
|
ret = POP();
|
2006-05-16 17:36:09 +00:00
|
|
|
DPRINTF("obp_devopen(%s) = 0x%x\n", str, ret);
|
2006-05-15 08:17:51 +00:00
|
|
|
|
|
|
|
|
return ret;
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-16 17:36:09 +00:00
|
|
|
static int obp_devclose(int dev_desc)
|
2006-05-10 23:00:34 +00:00
|
|
|
{
|
2006-05-16 17:36:09 +00:00
|
|
|
int ret;
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2006-05-16 17:36:09 +00:00
|
|
|
PUSH(dev_desc);
|
|
|
|
|
fword("close-dev");
|
|
|
|
|
ret = POP();
|
|
|
|
|
|
|
|
|
|
DPRINTF("obp_devclose(0x%x) = %d\n", dev_desc, ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_rdblkdev(int dev_desc, int num_blks, int offset, char *buf)
|
|
|
|
|
{
|
2006-05-16 17:36:09 +00:00
|
|
|
int ret, hi, lo, bs;
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2006-05-28 18:48:47 +00:00
|
|
|
bs = 512;
|
2006-05-16 17:36:09 +00:00
|
|
|
hi = ((uint64_t)offset * bs) >> 32;
|
|
|
|
|
lo = ((uint64_t)offset * bs) & 0xffffffff;
|
2006-05-15 08:17:51 +00:00
|
|
|
|
2006-05-16 17:36:09 +00:00
|
|
|
ret = obp_devseek(dev_desc, hi, lo);
|
|
|
|
|
|
|
|
|
|
ret = obp_devread(dev_desc, buf, num_blks * bs) / bs;
|
|
|
|
|
|
2006-05-18 21:57:08 +00:00
|
|
|
DPRINTF("obp_rdblkdev(fd 0x%x, num_blks %d, offset %d (hi %d lo %d), buf 0x%x) = %d\n", dev_desc, num_blks, offset, hi, lo, (int)buf, ret);
|
2006-05-15 08:17:51 +00:00
|
|
|
|
|
|
|
|
return ret;
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-10 15:56:42 +00:00
|
|
|
static char *obp_dumb_mmap(char *va, int which_io, unsigned int pa,
|
|
|
|
|
unsigned int size)
|
2006-05-10 23:00:34 +00:00
|
|
|
{
|
|
|
|
|
unsigned int npages;
|
|
|
|
|
unsigned int off;
|
|
|
|
|
unsigned int mva;
|
2007-05-19 12:55:01 +00:00
|
|
|
uint64_t mpa = ((uint64_t)which_io << 32) | (uint64_t)pa;
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2007-05-19 12:55:01 +00:00
|
|
|
DPRINTF("obp_dumb_mmap: virta 0x%x, paddr 0x%llx, sz %d\n",
|
|
|
|
|
(unsigned int)va, mpa, size);
|
2006-06-07 10:18:24 +00:00
|
|
|
|
2006-05-10 23:00:34 +00:00
|
|
|
off = pa & (PAGE_SIZE-1);
|
2007-05-19 12:55:01 +00:00
|
|
|
npages = (off + (size - 1) + (PAGE_SIZE-1)) / PAGE_SIZE;
|
|
|
|
|
mpa &= ~(uint64_t)(PAGE_SIZE - 1);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
mva = (unsigned int) va;
|
|
|
|
|
while (npages-- != 0) {
|
2007-05-19 12:55:01 +00:00
|
|
|
map_page(mva, mpa, 1);
|
2006-05-10 23:00:34 +00:00
|
|
|
mva += PAGE_SIZE;
|
2007-05-19 12:55:01 +00:00
|
|
|
mpa += (uint64_t)PAGE_SIZE;
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return va;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void obp_dumb_munmap(__attribute__((unused)) char *va,
|
|
|
|
|
__attribute__((unused)) unsigned int size)
|
|
|
|
|
{
|
2006-05-22 10:33:31 +00:00
|
|
|
DPRINTF("obp_dumb_munmap: virta 0x%x, sz %d\n", (unsigned int)va, size);
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_devread(int dev_desc, char *buf, int nbytes)
|
|
|
|
|
{
|
2006-05-16 17:36:09 +00:00
|
|
|
int ret;
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2006-05-16 17:36:09 +00:00
|
|
|
PUSH((int)buf);
|
|
|
|
|
PUSH(nbytes);
|
|
|
|
|
push_str("read");
|
|
|
|
|
PUSH(dev_desc);
|
|
|
|
|
fword("$call-method");
|
|
|
|
|
ret = POP();
|
|
|
|
|
|
|
|
|
|
DPRINTF("obp_devread(fd 0x%x, buf 0x%x, nbytes %d) = %d\n", dev_desc, (int)buf, nbytes, ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_devwrite(int dev_desc, char *buf, int nbytes)
|
|
|
|
|
{
|
2006-05-16 17:36:09 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
PUSH((int)buf);
|
|
|
|
|
PUSH(nbytes);
|
|
|
|
|
push_str("write");
|
|
|
|
|
PUSH(dev_desc);
|
|
|
|
|
fword("$call-method");
|
|
|
|
|
ret = POP();
|
|
|
|
|
|
2006-06-05 19:49:53 +00:00
|
|
|
//DPRINTF("obp_devwrite(fd 0x%x, buf %s, nbytes %d) = %d\n", dev_desc, buf, nbytes, ret);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
return nbytes;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-16 17:36:09 +00:00
|
|
|
static int obp_devseek(int dev_desc, int hi, int lo)
|
2006-05-10 23:00:34 +00:00
|
|
|
{
|
2006-05-16 17:36:09 +00:00
|
|
|
int ret;
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2006-05-16 17:36:09 +00:00
|
|
|
PUSH(lo);
|
|
|
|
|
PUSH(hi);
|
|
|
|
|
push_str("seek");
|
|
|
|
|
PUSH(dev_desc);
|
|
|
|
|
fword("$call-method");
|
|
|
|
|
ret = POP();
|
|
|
|
|
|
|
|
|
|
DPRINTF("obp_devseek(fd 0x%x, hi %d, lo %d) = %d\n", dev_desc, hi, lo, ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_inst2pkg(int dev_desc)
|
|
|
|
|
{
|
2006-05-16 17:36:09 +00:00
|
|
|
int ret;
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2006-05-16 17:36:09 +00:00
|
|
|
PUSH(dev_desc);
|
2007-04-24 19:19:58 +00:00
|
|
|
fword("ihandle>non-interposed-phandle");
|
2006-05-16 17:36:09 +00:00
|
|
|
ret = POP();
|
|
|
|
|
|
|
|
|
|
DPRINTF("obp_inst2pkg(fd 0x%x) = 0x%x\n", dev_desc, ret);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
2006-06-10 02:04:54 +00:00
|
|
|
static void obp_dumb_memfree(__attribute__((unused))char *va,
|
|
|
|
|
__attribute__((unused))unsigned sz)
|
2006-06-07 07:44:40 +00:00
|
|
|
{
|
2006-06-07 10:18:24 +00:00
|
|
|
DPRINTF("obp_dumb_memfree 0x%x(%d)\n", va, sz);
|
2006-06-07 07:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-06-10 02:04:54 +00:00
|
|
|
static char * obp_dumb_memalloc(char *va, unsigned int size)
|
2006-06-07 07:44:40 +00:00
|
|
|
{
|
Patch for SunOS compatibility from pjcreath+openbios@gmail.com:
I've been trying to get old versions of SunOS to load under qemu. In
doing so, I've encountered a number of bugs in OBP. I'm not always
certain of the best fix, but I can at least provide a quick hack that
will get people farther along.
1) Error message: "kmem_alloc failed, nbytes 680"
Bug: obp_dumb_memalloc is a bit too dumb. It needs to pick an address
if passed a null address. (According to the comment in the allocator
in OpenSolaris prom_alloc.c (see
<http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/psm/promif/ieee1275/sun4/prom_alloc.c>),
"If virthint is zero, a suitable virt is chosen.")
Quick fix: If passed a null address, start doling out addresses at
10MB and increment by size.
Shortcomings: The quick fix ignores the issue of free() and doesn't
remove memory from the virtual-memory/available node.
After the quick fix, the boot gets farther, leading us to:
2) Error message: "Unhandled Exception 0x00000080"
Bug: Trap 0 (entry 0x80 in the table, i.e. syscall_trap_4x) is
undefined. This is because the SunOS bootloader installs the trap by
writing code in the trap table, but the trap table is in the .text
section of OpenBIOS. Thus the trap 0 handler simply jumps to "bug".
Quick fix: Move the trap table to the .data section. Insert a "b
entry; nop; nop; nop;" before "bug:".
Shortcomings: Requires the extra "b entry" code. Allows the only VM
copy of the trap table to be permanently changed. OpenBIOS should
copy the read-only trap table to read-write memory (and update %tbr)
upon reset/entry.
3) #2 above actually exposes another bug. The write to the read-only
trap table does not cause an access violation -- instead, it silently
fails. The "std" instruction at 0x403e6c in the bootloader has no
effect.
Bug: Uncertain. It could be a systemic bug in qemu, but it appears
that the VM's MMU believes that the page is writable. That means that
the VM's MMU is not having the access protection flags set for pages
mapped to ROM. It thinks everything is rwx.
Fix?: The VM's MMU should have the access protection flags properly
set for each ROM section. This should probably be done within
OpenBIOS. E.g., .text should be r-x, .data should probably be rwx,
etc.
This is the one fix I'm really not sure how to implement. Any
suggestions? This may be a problem that only affects this bootloader,
so fixing #2 above may be all that's strictly necessary. But I'm not
positive that this bug doesn't have other ill effects I haven't found
yet.
At any rate, fixing #2 gets us still further, to:
4) Error messages:
"obp_devopen(sd(0,0,0):d) = 0xffd8e270
obp_inst2pkg(fd 0xffd8e270) = 0xffd57f44
obp_getprop(0xffd57f44, device_type) (not found)"
Bug: The OpenBIOS "interpose" implementation is not transparent to
non-interposition-aware code (in violation of the interposition spec).
The inst2pkg call in this sequence returns the phandle for
/packages/misc-files, instead of the proper phandle.
Quick fix: Comment out the "interpose disk-label" lines in ob_sd_open.
Shortcomings: It disables disk-label. The correct fix is to fix the
underlying problem with interposition, but I'm not sure exactly what
it is. Could someone help?
Fixing #4 gets us quite a bit further, until:
5) Error message:
"Unhandled Exception 0x00000009
PC = 0xf0138b20 NPC = 0xf0138b24
Stopping execution"
Bug: The instruction is trying to read from 0xfd020000+4, which is an
invalid address. This address isn't mapped by OBP by default on Sun
hardware, so the bootloader must be trying to (a) map this address and
failing silently or (b) skipping the mapping for some reason. The
instruction is hard-coded to look at this absolute address.
Fix: Unknown. This may be another instance of writes silently
failing, hence my interest in #3 above. It could also be a
side-effect of the quick fix for #4.
6) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008f0c addr=feff8008 mmu_fsr=3a6 rw=2
MMU sfsr=3a6: Invalid Address on supv data store at level 3
regs at fd008f0c:
psr=4400fc7 pc=f00053f4 npc=f00053f8
..."
Bug: Real sun4m hardware registers 4 CPU-specific interrupts followed
by a system-wide interrupt, regardless of the number of CPUs
installed. The same is true of counters. SunOS looks at the 5th
interrupt for the system-wide interrupt. OBP, since there's only one
CPU, just sets up one CPU-specific interrupt followed by the
system-wide interrupt, so there is no 5th interrupt. See the comment
on "NCPU" at
<http://stuff.mit.edu/afs/athena/astaff/project/opssrc/sys.sunos/sun4m/devaddr.h>.
Fix: in obp_interrupt_init() and obp_counter_init() register 4
CPU-specific interrupts before allocating the system-wide interrupt.
The kernel will then map the 5th interrupt to the system-wide
interrupt.
7) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d8c addr=7ff000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d8c:
psr=4000cc4 pc=f01339a4 npc=f01339a8
..."
Bug: The command-line arguments passed to the kernel are fixed at
address 0x7FF000 (CMDLINE_ADDR, passed from qemu via nv_info.cmdline),
which is no longer mapped by the time the kernel looks at the boot
arguments. A regular Sun boot ROM will copy this into mapped memory.
Fix: Copy the string in nv_info.cmdline to a OpenBIOS global (since
OpenBIOS continues to be mapped) in ob_nvram_init().
8) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008dec addr=1019000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008dec:
psr=4400cc5 pc=f0131680 npc=f0131684
..."
Bug: The dumb memory allocator from bug #1 was allocating a range that
the SunOS 4 kernel doesn't like.
Fix: Mimic the Sun boot ROM allocator: the top of the heap should be
a 0xFFEDA000 and allocations should return descending addresses. So,
for example, if asking for 0x1000 bytes, the first returned pointer
should be 0xFFED9000.
9) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d2c addr=b1b91000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d2c:
psr=4900cc3 pc=f0142c04 npc=f0142c08
..."
Bug: The precise underlying cause isn't clear. The bug appears due to
a variation between OBP's behavior and stock Sun behavior.
Fix: Add the "cache-physical?" property to the CPU node in
ob_nvram_init() and bump the "mmu-nctx" property up to 4096 (from
256).
git-svn-id: svn://coreboot.org/openbios/openbios-devel@114 f158a5a8-5612-0410-a976-696ce0be7e32
2007-03-09 00:59:05 +00:00
|
|
|
static unsigned int next_free_address = 0xFFEDA000;
|
|
|
|
|
|
2007-07-29 20:20:46 +00:00
|
|
|
size = (size + 7) & ~7;
|
2007-06-27 20:11:08 +00:00
|
|
|
totmap[0].num_bytes -= size;
|
|
|
|
|
DPRINTF("obp_dumb_memalloc req 0x%x of %d at 0x%x\n", va, size,
|
|
|
|
|
totmap[0].num_bytes);
|
Patch for SunOS compatibility from pjcreath+openbios@gmail.com:
I've been trying to get old versions of SunOS to load under qemu. In
doing so, I've encountered a number of bugs in OBP. I'm not always
certain of the best fix, but I can at least provide a quick hack that
will get people farther along.
1) Error message: "kmem_alloc failed, nbytes 680"
Bug: obp_dumb_memalloc is a bit too dumb. It needs to pick an address
if passed a null address. (According to the comment in the allocator
in OpenSolaris prom_alloc.c (see
<http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/psm/promif/ieee1275/sun4/prom_alloc.c>),
"If virthint is zero, a suitable virt is chosen.")
Quick fix: If passed a null address, start doling out addresses at
10MB and increment by size.
Shortcomings: The quick fix ignores the issue of free() and doesn't
remove memory from the virtual-memory/available node.
After the quick fix, the boot gets farther, leading us to:
2) Error message: "Unhandled Exception 0x00000080"
Bug: Trap 0 (entry 0x80 in the table, i.e. syscall_trap_4x) is
undefined. This is because the SunOS bootloader installs the trap by
writing code in the trap table, but the trap table is in the .text
section of OpenBIOS. Thus the trap 0 handler simply jumps to "bug".
Quick fix: Move the trap table to the .data section. Insert a "b
entry; nop; nop; nop;" before "bug:".
Shortcomings: Requires the extra "b entry" code. Allows the only VM
copy of the trap table to be permanently changed. OpenBIOS should
copy the read-only trap table to read-write memory (and update %tbr)
upon reset/entry.
3) #2 above actually exposes another bug. The write to the read-only
trap table does not cause an access violation -- instead, it silently
fails. The "std" instruction at 0x403e6c in the bootloader has no
effect.
Bug: Uncertain. It could be a systemic bug in qemu, but it appears
that the VM's MMU believes that the page is writable. That means that
the VM's MMU is not having the access protection flags set for pages
mapped to ROM. It thinks everything is rwx.
Fix?: The VM's MMU should have the access protection flags properly
set for each ROM section. This should probably be done within
OpenBIOS. E.g., .text should be r-x, .data should probably be rwx,
etc.
This is the one fix I'm really not sure how to implement. Any
suggestions? This may be a problem that only affects this bootloader,
so fixing #2 above may be all that's strictly necessary. But I'm not
positive that this bug doesn't have other ill effects I haven't found
yet.
At any rate, fixing #2 gets us still further, to:
4) Error messages:
"obp_devopen(sd(0,0,0):d) = 0xffd8e270
obp_inst2pkg(fd 0xffd8e270) = 0xffd57f44
obp_getprop(0xffd57f44, device_type) (not found)"
Bug: The OpenBIOS "interpose" implementation is not transparent to
non-interposition-aware code (in violation of the interposition spec).
The inst2pkg call in this sequence returns the phandle for
/packages/misc-files, instead of the proper phandle.
Quick fix: Comment out the "interpose disk-label" lines in ob_sd_open.
Shortcomings: It disables disk-label. The correct fix is to fix the
underlying problem with interposition, but I'm not sure exactly what
it is. Could someone help?
Fixing #4 gets us quite a bit further, until:
5) Error message:
"Unhandled Exception 0x00000009
PC = 0xf0138b20 NPC = 0xf0138b24
Stopping execution"
Bug: The instruction is trying to read from 0xfd020000+4, which is an
invalid address. This address isn't mapped by OBP by default on Sun
hardware, so the bootloader must be trying to (a) map this address and
failing silently or (b) skipping the mapping for some reason. The
instruction is hard-coded to look at this absolute address.
Fix: Unknown. This may be another instance of writes silently
failing, hence my interest in #3 above. It could also be a
side-effect of the quick fix for #4.
6) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008f0c addr=feff8008 mmu_fsr=3a6 rw=2
MMU sfsr=3a6: Invalid Address on supv data store at level 3
regs at fd008f0c:
psr=4400fc7 pc=f00053f4 npc=f00053f8
..."
Bug: Real sun4m hardware registers 4 CPU-specific interrupts followed
by a system-wide interrupt, regardless of the number of CPUs
installed. The same is true of counters. SunOS looks at the 5th
interrupt for the system-wide interrupt. OBP, since there's only one
CPU, just sets up one CPU-specific interrupt followed by the
system-wide interrupt, so there is no 5th interrupt. See the comment
on "NCPU" at
<http://stuff.mit.edu/afs/athena/astaff/project/opssrc/sys.sunos/sun4m/devaddr.h>.
Fix: in obp_interrupt_init() and obp_counter_init() register 4
CPU-specific interrupts before allocating the system-wide interrupt.
The kernel will then map the 5th interrupt to the system-wide
interrupt.
7) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d8c addr=7ff000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d8c:
psr=4000cc4 pc=f01339a4 npc=f01339a8
..."
Bug: The command-line arguments passed to the kernel are fixed at
address 0x7FF000 (CMDLINE_ADDR, passed from qemu via nv_info.cmdline),
which is no longer mapped by the time the kernel looks at the boot
arguments. A regular Sun boot ROM will copy this into mapped memory.
Fix: Copy the string in nv_info.cmdline to a OpenBIOS global (since
OpenBIOS continues to be mapped) in ob_nvram_init().
8) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008dec addr=1019000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008dec:
psr=4400cc5 pc=f0131680 npc=f0131684
..."
Bug: The dumb memory allocator from bug #1 was allocating a range that
the SunOS 4 kernel doesn't like.
Fix: Mimic the Sun boot ROM allocator: the top of the heap should be
a 0xFFEDA000 and allocations should return descending addresses. So,
for example, if asking for 0x1000 bytes, the first returned pointer
should be 0xFFED9000.
9) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d2c addr=b1b91000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d2c:
psr=4900cc3 pc=f0142c04 npc=f0142c08
..."
Bug: The precise underlying cause isn't clear. The bug appears due to
a variation between OBP's behavior and stock Sun behavior.
Fix: Add the "cache-physical?" property to the CPU node in
ob_nvram_init() and bump the "mmu-nctx" property up to 4096 (from
256).
git-svn-id: svn://coreboot.org/openbios/openbios-devel@114 f158a5a8-5612-0410-a976-696ce0be7e32
2007-03-09 00:59:05 +00:00
|
|
|
|
|
|
|
|
// If va is null, the allocator is supposed to pick a "suitable" address.
|
|
|
|
|
// (See OpenSolaric prom_alloc.c) There's not any real guidance as
|
|
|
|
|
// to what might be "suitable". So we mimic the behavior of a Sun boot
|
|
|
|
|
// ROM.
|
|
|
|
|
|
|
|
|
|
if (va == NULL) {
|
2008-07-07 18:35:51 +00:00
|
|
|
va = (char *)(next_free_address - size);
|
Patch for SunOS compatibility from pjcreath+openbios@gmail.com:
I've been trying to get old versions of SunOS to load under qemu. In
doing so, I've encountered a number of bugs in OBP. I'm not always
certain of the best fix, but I can at least provide a quick hack that
will get people farther along.
1) Error message: "kmem_alloc failed, nbytes 680"
Bug: obp_dumb_memalloc is a bit too dumb. It needs to pick an address
if passed a null address. (According to the comment in the allocator
in OpenSolaris prom_alloc.c (see
<http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/psm/promif/ieee1275/sun4/prom_alloc.c>),
"If virthint is zero, a suitable virt is chosen.")
Quick fix: If passed a null address, start doling out addresses at
10MB and increment by size.
Shortcomings: The quick fix ignores the issue of free() and doesn't
remove memory from the virtual-memory/available node.
After the quick fix, the boot gets farther, leading us to:
2) Error message: "Unhandled Exception 0x00000080"
Bug: Trap 0 (entry 0x80 in the table, i.e. syscall_trap_4x) is
undefined. This is because the SunOS bootloader installs the trap by
writing code in the trap table, but the trap table is in the .text
section of OpenBIOS. Thus the trap 0 handler simply jumps to "bug".
Quick fix: Move the trap table to the .data section. Insert a "b
entry; nop; nop; nop;" before "bug:".
Shortcomings: Requires the extra "b entry" code. Allows the only VM
copy of the trap table to be permanently changed. OpenBIOS should
copy the read-only trap table to read-write memory (and update %tbr)
upon reset/entry.
3) #2 above actually exposes another bug. The write to the read-only
trap table does not cause an access violation -- instead, it silently
fails. The "std" instruction at 0x403e6c in the bootloader has no
effect.
Bug: Uncertain. It could be a systemic bug in qemu, but it appears
that the VM's MMU believes that the page is writable. That means that
the VM's MMU is not having the access protection flags set for pages
mapped to ROM. It thinks everything is rwx.
Fix?: The VM's MMU should have the access protection flags properly
set for each ROM section. This should probably be done within
OpenBIOS. E.g., .text should be r-x, .data should probably be rwx,
etc.
This is the one fix I'm really not sure how to implement. Any
suggestions? This may be a problem that only affects this bootloader,
so fixing #2 above may be all that's strictly necessary. But I'm not
positive that this bug doesn't have other ill effects I haven't found
yet.
At any rate, fixing #2 gets us still further, to:
4) Error messages:
"obp_devopen(sd(0,0,0):d) = 0xffd8e270
obp_inst2pkg(fd 0xffd8e270) = 0xffd57f44
obp_getprop(0xffd57f44, device_type) (not found)"
Bug: The OpenBIOS "interpose" implementation is not transparent to
non-interposition-aware code (in violation of the interposition spec).
The inst2pkg call in this sequence returns the phandle for
/packages/misc-files, instead of the proper phandle.
Quick fix: Comment out the "interpose disk-label" lines in ob_sd_open.
Shortcomings: It disables disk-label. The correct fix is to fix the
underlying problem with interposition, but I'm not sure exactly what
it is. Could someone help?
Fixing #4 gets us quite a bit further, until:
5) Error message:
"Unhandled Exception 0x00000009
PC = 0xf0138b20 NPC = 0xf0138b24
Stopping execution"
Bug: The instruction is trying to read from 0xfd020000+4, which is an
invalid address. This address isn't mapped by OBP by default on Sun
hardware, so the bootloader must be trying to (a) map this address and
failing silently or (b) skipping the mapping for some reason. The
instruction is hard-coded to look at this absolute address.
Fix: Unknown. This may be another instance of writes silently
failing, hence my interest in #3 above. It could also be a
side-effect of the quick fix for #4.
6) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008f0c addr=feff8008 mmu_fsr=3a6 rw=2
MMU sfsr=3a6: Invalid Address on supv data store at level 3
regs at fd008f0c:
psr=4400fc7 pc=f00053f4 npc=f00053f8
..."
Bug: Real sun4m hardware registers 4 CPU-specific interrupts followed
by a system-wide interrupt, regardless of the number of CPUs
installed. The same is true of counters. SunOS looks at the 5th
interrupt for the system-wide interrupt. OBP, since there's only one
CPU, just sets up one CPU-specific interrupt followed by the
system-wide interrupt, so there is no 5th interrupt. See the comment
on "NCPU" at
<http://stuff.mit.edu/afs/athena/astaff/project/opssrc/sys.sunos/sun4m/devaddr.h>.
Fix: in obp_interrupt_init() and obp_counter_init() register 4
CPU-specific interrupts before allocating the system-wide interrupt.
The kernel will then map the 5th interrupt to the system-wide
interrupt.
7) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d8c addr=7ff000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d8c:
psr=4000cc4 pc=f01339a4 npc=f01339a8
..."
Bug: The command-line arguments passed to the kernel are fixed at
address 0x7FF000 (CMDLINE_ADDR, passed from qemu via nv_info.cmdline),
which is no longer mapped by the time the kernel looks at the boot
arguments. A regular Sun boot ROM will copy this into mapped memory.
Fix: Copy the string in nv_info.cmdline to a OpenBIOS global (since
OpenBIOS continues to be mapped) in ob_nvram_init().
8) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008dec addr=1019000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008dec:
psr=4400cc5 pc=f0131680 npc=f0131684
..."
Bug: The dumb memory allocator from bug #1 was allocating a range that
the SunOS 4 kernel doesn't like.
Fix: Mimic the Sun boot ROM allocator: the top of the heap should be
a 0xFFEDA000 and allocations should return descending addresses. So,
for example, if asking for 0x1000 bytes, the first returned pointer
should be 0xFFED9000.
9) Error message:
"BAD TRAP: cpu=0 type=9 rp=fd008d2c addr=b1b91000 mmu_fsr=126 rw=1
MMU sfsr=126: Invalid Address on supv data fetch at level 1
regs at fd008d2c:
psr=4900cc3 pc=f0142c04 npc=f0142c08
..."
Bug: The precise underlying cause isn't clear. The bug appears due to
a variation between OBP's behavior and stock Sun behavior.
Fix: Add the "cache-physical?" property to the CPU node in
ob_nvram_init() and bump the "mmu-nctx" property up to 4096 (from
256).
git-svn-id: svn://coreboot.org/openbios/openbios-devel@114 f158a5a8-5612-0410-a976-696ce0be7e32
2007-03-09 00:59:05 +00:00
|
|
|
next_free_address -= size;
|
|
|
|
|
DPRINTF("obp_dumb_memalloc req null -> 0x%x\n", va);
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-27 20:11:08 +00:00
|
|
|
obp_dumb_mmap(va, 0, totmap[0].num_bytes, size);
|
2006-06-07 07:44:40 +00:00
|
|
|
|
|
|
|
|
return va;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-22 10:33:31 +00:00
|
|
|
static int obp_cpustart(__attribute__((unused))unsigned int whichcpu,
|
|
|
|
|
__attribute__((unused))int ctxtbl_ptr,
|
|
|
|
|
__attribute__((unused))int thiscontext,
|
|
|
|
|
__attribute__((unused))char *prog_counter)
|
2006-05-10 23:00:34 +00:00
|
|
|
{
|
2006-06-06 22:23:04 +00:00
|
|
|
int cpu, found;
|
2006-05-10 23:00:34 +00:00
|
|
|
struct linux_prom_registers *smp_ctable = (void *)ctxtbl_ptr;
|
|
|
|
|
|
2006-05-18 21:57:08 +00:00
|
|
|
DPRINTF("obp_cpustart: cpu %d, ctxptr 0x%x, ctx %d, pc 0x%x\n", whichcpu,
|
2006-05-22 10:33:31 +00:00
|
|
|
smp_ctable->phys_addr, thiscontext, (unsigned int)prog_counter);
|
2006-06-06 22:23:04 +00:00
|
|
|
|
2006-05-10 23:00:34 +00:00
|
|
|
found = obp_getprop(whichcpu, "mid", (char *)&cpu);
|
|
|
|
|
if (found == -1)
|
|
|
|
|
return -1;
|
2006-06-06 22:23:04 +00:00
|
|
|
DPRINTF("cpu found, id %d -> cpu %d\n", whichcpu, cpu);
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2006-06-06 22:23:04 +00:00
|
|
|
return start_cpu((unsigned int)prog_counter, ((unsigned int)smp_ctable->phys_addr) >> 4,
|
|
|
|
|
thiscontext, cpu);
|
2006-05-10 23:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_cpustop(__attribute__((unused)) unsigned int whichcpu)
|
|
|
|
|
{
|
|
|
|
|
DPRINTF("obp_cpustop: cpu %d\n", whichcpu);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_cpuidle(__attribute__((unused)) unsigned int whichcpu)
|
|
|
|
|
{
|
|
|
|
|
DPRINTF("obp_cpuidle: cpu %d\n", whichcpu);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int obp_cpuresume(__attribute__((unused)) unsigned int whichcpu)
|
|
|
|
|
{
|
|
|
|
|
DPRINTF("obp_cpuresume: cpu %d\n", whichcpu);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-05 20:34:53 +00:00
|
|
|
static void obp_fortheval_v2(char *str)
|
2006-06-05 19:49:53 +00:00
|
|
|
{
|
|
|
|
|
// for now, move something to the stack so we
|
|
|
|
|
// don't get a stack underrun.
|
|
|
|
|
//
|
|
|
|
|
// FIXME: find out why solaris doesnt put its stuff on the stack
|
2008-07-07 18:35:51 +00:00
|
|
|
//
|
2006-06-05 19:49:53 +00:00
|
|
|
fword("0");
|
|
|
|
|
fword("0");
|
2006-06-05 20:34:53 +00:00
|
|
|
|
|
|
|
|
DPRINTF("obp_fortheval_v2(%s)\n", str);
|
|
|
|
|
push_str(str);
|
|
|
|
|
fword("eval");
|
2006-06-05 19:49:53 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-10 23:00:34 +00:00
|
|
|
void *
|
2008-11-02 19:25:05 +00:00
|
|
|
init_openprom(unsigned long memsize, const char *path)
|
2006-05-10 23:00:34 +00:00
|
|
|
{
|
|
|
|
|
ptphys = totphys;
|
|
|
|
|
ptmap = totmap;
|
|
|
|
|
ptavail = totavail;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Form memory descriptors.
|
|
|
|
|
*/
|
2006-05-22 22:16:20 +00:00
|
|
|
totphys[0].theres_more = NULL;
|
2006-05-10 23:00:34 +00:00
|
|
|
totphys[0].start_adr = (char *) 0;
|
|
|
|
|
totphys[0].num_bytes = memsize;
|
|
|
|
|
|
2006-05-22 22:16:20 +00:00
|
|
|
totavail[0].theres_more = NULL;
|
|
|
|
|
totavail[0].start_adr = (char *) 0;
|
2007-06-27 20:11:08 +00:00
|
|
|
totavail[0].num_bytes = va2pa((int)&_start) - PAGE_SIZE;
|
2006-05-10 23:00:34 +00:00
|
|
|
|
2006-05-22 22:16:20 +00:00
|
|
|
totmap[0].theres_more = NULL;
|
2006-05-10 23:00:34 +00:00
|
|
|
totmap[0].start_adr = &_start;
|
2006-05-28 18:48:47 +00:00
|
|
|
totmap[0].num_bytes = (unsigned long) &_iomem - (unsigned long) &_start + PAGE_SIZE;
|
2006-05-26 10:37:37 +00:00
|
|
|
|
2006-05-10 23:00:34 +00:00
|
|
|
// Linux wants a R/W romvec table
|
|
|
|
|
romvec0.pv_magic_cookie = LINUX_OPPROM_MAGIC;
|
2006-05-28 18:48:47 +00:00
|
|
|
romvec0.pv_romvers = 3;
|
2006-06-05 19:49:53 +00:00
|
|
|
romvec0.pv_plugin_revision = 2;
|
|
|
|
|
romvec0.pv_printrev = 0x20019;
|
2006-05-10 23:00:34 +00:00
|
|
|
romvec0.pv_v0mem.v0_totphys = &ptphys;
|
|
|
|
|
romvec0.pv_v0mem.v0_prommap = &ptmap;
|
|
|
|
|
romvec0.pv_v0mem.v0_available = &ptavail;
|
|
|
|
|
romvec0.pv_nodeops = &nodeops0;
|
|
|
|
|
romvec0.pv_bootstr = (void *)doublewalk;
|
|
|
|
|
romvec0.pv_v0devops.v0_devopen = &obp_devopen;
|
|
|
|
|
romvec0.pv_v0devops.v0_devclose = &obp_devclose;
|
|
|
|
|
romvec0.pv_v0devops.v0_rdblkdev = &obp_rdblkdev;
|
|
|
|
|
romvec0.pv_stdin = &obp_stdin;
|
|
|
|
|
romvec0.pv_stdout = &obp_stdout;
|
|
|
|
|
romvec0.pv_getchar = obp_nbgetchar;
|
|
|
|
|
romvec0.pv_putchar = (void (*)(int))obp_nbputchar;
|
|
|
|
|
romvec0.pv_nbgetchar = obp_nbgetchar;
|
|
|
|
|
romvec0.pv_nbputchar = obp_nbputchar;
|
|
|
|
|
romvec0.pv_reboot = obp_reboot;
|
|
|
|
|
romvec0.pv_printf = (void (*)(const char *fmt, ...))printk;
|
|
|
|
|
romvec0.pv_abort = obp_abort;
|
|
|
|
|
romvec0.pv_halt = obp_halt;
|
2006-06-05 19:49:53 +00:00
|
|
|
romvec0.pv_synchook = &sync_hook;
|
2006-05-10 23:00:34 +00:00
|
|
|
romvec0.pv_v0bootargs = &obp_argp;
|
2006-06-05 20:34:53 +00:00
|
|
|
romvec0.pv_fortheval.v2_eval = obp_fortheval_v2;
|
2006-05-10 23:00:34 +00:00
|
|
|
romvec0.pv_v2devops.v2_inst2pkg = obp_inst2pkg;
|
2006-06-07 07:44:40 +00:00
|
|
|
romvec0.pv_v2devops.v2_dumb_mem_alloc = obp_dumb_memalloc;
|
|
|
|
|
romvec0.pv_v2devops.v2_dumb_mem_free = obp_dumb_memfree;
|
2006-05-10 23:00:34 +00:00
|
|
|
romvec0.pv_v2devops.v2_dumb_mmap = obp_dumb_mmap;
|
|
|
|
|
romvec0.pv_v2devops.v2_dumb_munmap = obp_dumb_munmap;
|
|
|
|
|
romvec0.pv_v2devops.v2_dev_open = obp_devopen;
|
|
|
|
|
romvec0.pv_v2devops.v2_dev_close = (void (*)(int))obp_devclose;
|
|
|
|
|
romvec0.pv_v2devops.v2_dev_read = obp_devread;
|
|
|
|
|
romvec0.pv_v2devops.v2_dev_write = obp_devwrite;
|
|
|
|
|
romvec0.pv_v2devops.v2_dev_seek = obp_devseek;
|
2008-11-02 19:25:05 +00:00
|
|
|
|
|
|
|
|
push_str(path);
|
|
|
|
|
fword("pathres-resolve-aliases");
|
|
|
|
|
bootpath = pop_fstr_copy();
|
|
|
|
|
romvec0.pv_v2bootargs.bootpath = &bootpath;
|
|
|
|
|
|
2006-05-22 22:16:20 +00:00
|
|
|
romvec0.pv_v2bootargs.bootargs = &obp_arg.argv[1];
|
2006-05-10 23:00:34 +00:00
|
|
|
romvec0.pv_v2bootargs.fd_stdin = &obp_fd_stdin;
|
|
|
|
|
romvec0.pv_v2bootargs.fd_stdout = &obp_fd_stdout;
|
2006-05-18 21:57:08 +00:00
|
|
|
|
2006-07-23 14:29:29 +00:00
|
|
|
push_str(obp_stdin_path);
|
2006-05-18 21:57:08 +00:00
|
|
|
fword("open-dev");
|
|
|
|
|
obp_fd_stdin = POP();
|
2006-07-23 14:29:29 +00:00
|
|
|
push_str(obp_stdout_path);
|
2006-05-18 21:57:08 +00:00
|
|
|
fword("open-dev");
|
|
|
|
|
obp_fd_stdout = POP();
|
2006-05-10 23:00:34 +00:00
|
|
|
|
|
|
|
|
romvec0.v3_cpustart = obp_cpustart;
|
|
|
|
|
romvec0.v3_cpustop = obp_cpustop;
|
|
|
|
|
romvec0.v3_cpuidle = obp_cpuidle;
|
|
|
|
|
romvec0.v3_cpuresume = obp_cpuresume;
|
|
|
|
|
|
|
|
|
|
return &romvec0;
|
|
|
|
|
}
|