Author: mcayland
Date: Mon Aug 19 09:40:12 2013
New Revision: 1209
URL: http://tracker.coreboot.org/trac/openbios/changeset/1209
Log:
SPARC32: fix romvec stdin/stdout field initialisation
Previously the romvec stdin/stdout ihandles were configured so that they were
set to the current stdin and stdout paths at initialisation time. Unfortunately
as stdin/stdout can be changed with the input and output words, they can end
up pointing to invalid ihandles causing a crash when trying to output to the
console.
Fix this by pointing the romvec structure to the address of the stdin/stdout
variables so that they are always in sync. Similarly we also resolve the
text path stdin/stdout variables at boot time to ensure that they will never
be stale.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc32/boot.c
trunk/openbios-devel/arch/sparc32/romvec.c
Modified: trunk/openbios-devel/arch/sparc32/boot.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/boot.c Mon Aug 19 09:40:10 2013 (r1208)
+++ trunk/openbios-devel/arch/sparc32/boot.c Mon Aug 19 09:40:12 2013 (r1209)
@@ -23,7 +23,7 @@
void go(void)
{
ucell address, type, size;
- int image_retval = 0, proplen, target, device;
+ int image_retval = 0, intprop, proplen, target, device;
phandle_t chosen;
char *prop, *id, *name;
static char bootpathbuf[128], bootargsbuf[128], buf[128];
@@ -40,8 +40,19 @@
needs to be set up to pass certain parameters using a C struct. Hence this section
extracts the relevant boot information and places it in obp_arg. */
- /* Get the name of the selected boot device, along with the device and unit number */
+ /* Get the stdin and stdout paths */
chosen = find_dev("/chosen");
+ intprop = get_int_property(chosen, "stdin", &proplen);
+ PUSH(intprop);
+ fword("get-instance-path");
+ ((struct linux_romvec *)romvec)->pv_stdin = pop_fstr_copy();
+
+ intprop = get_int_property(chosen, "stdout", &proplen);
+ PUSH(intprop);
+ fword("get-instance-path");
+ ((struct linux_romvec *)romvec)->pv_stdout = pop_fstr_copy();
+
+ /* Get the name of the selected boot device, along with the device and unit number */
prop = get_property(chosen, "bootpath", &proplen);
strncpy(bootpathbuf, prop, proplen);
prop = get_property(chosen, "bootargs", &proplen);
Modified: trunk/openbios-devel/arch/sparc32/romvec.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/romvec.c Mon Aug 19 09:40:10 2013 (r1208)
+++ trunk/openbios-devel/arch/sparc32/romvec.c Mon Aug 19 09:40:12 2013 (r1209)
@@ -25,7 +25,6 @@
#endif
char obp_stdin, obp_stdout;
-static int obp_fd_stdin, obp_fd_stdout;
const char *obp_stdin_path, *obp_stdout_path;
struct linux_arguments_v0 obp_arg;
@@ -498,15 +497,12 @@
romvec0.pv_v2bootargs.bootpath = &bootpath;
romvec0.pv_v2bootargs.bootargs = &obp_arg.argv[1];
- romvec0.pv_v2bootargs.fd_stdin = &obp_fd_stdin;
- romvec0.pv_v2bootargs.fd_stdout = &obp_fd_stdout;
- push_str(obp_stdin_path);
- fword("open-dev");
- obp_fd_stdin = POP();
- push_str(obp_stdout_path);
- fword("open-dev");
- obp_fd_stdout = POP();
+ /* Point fd_stdin/fd_stdout to the Forth stdin/stdout variables */
+ fword("stdin");
+ romvec0.pv_v2bootargs.fd_stdin = cell2pointer(POP());
+ fword("stdout");
+ romvec0.pv_v2bootargs.fd_stdout = cell2pointer(POP());
romvec0.v3_memalloc = obp_memalloc_handler;
This patch corrects two long-standing bugs with PPC PCI configuration space
access. Firstly fix the calculation of PCI configuration space addresses by
the PCI_ADDR macro; this was incorrectly using arch->cfg_base which is the
mapped address and has nothing to do with the PCI configuration space
address. Instead just set bit 31 to initiate a configuration cycle as per the
PCI specification.
Secondly, fix pci_config_read32() and pci_config_write16() which were
incorrectly adding the register offset to the PCI IO dataport address causing
them to write into unknown address space for registers > 0. It appears that
this only worked purely by coincidence with QEMU due to the way in which the
configuration address was calculated for an oversized PCI configuration IO
dataport MemoryRegion.
Reported-by: Hervé Poussineau <hpoussin(a)reactos.org>
CC: Hervé Poussineau <hpoussin(a)reactos.org>
CC: Andreas Färber <afaerber(a)suse.de>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
---
openbios-devel/include/arch/ppc/pci.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/openbios-devel/include/arch/ppc/pci.h b/openbios-devel/include/arch/ppc/pci.h
index cccefb1..d96bd7e 100644
--- a/openbios-devel/include/arch/ppc/pci.h
+++ b/openbios-devel/include/arch/ppc/pci.h
@@ -12,7 +12,7 @@
/* PCI Configuration Mechanism #1 */
#define PCI_ADDR(bus, dev, fn) \
- ((pci_addr) (arch->cfg_base \
+ ((pci_addr) (0x80000000u \
| (uint32_t) (bus) << 16 \
| (uint32_t) (dev) << 11 \
| (uint32_t) (fn) << 8))
@@ -41,7 +41,7 @@ static inline uint32_t pci_config_read32(pci_addr dev, uint8_t reg)
{
uint32_t res;
out_le32((unsigned *)arch->cfg_addr, dev | reg);
- res = in_le32((unsigned *)(arch->cfg_data + reg));
+ res = in_le32((unsigned *)(arch->cfg_data));
return res;
}
@@ -60,7 +60,7 @@ static inline void pci_config_write16(pci_addr dev, uint8_t reg, uint16_t val)
static inline void pci_config_write32(pci_addr dev, uint8_t reg, uint32_t val)
{
out_le32((unsigned *)arch->cfg_addr, dev | reg);
- out_le32((unsigned *)(arch->cfg_data + reg), val);
+ out_le32((unsigned *)(arch->cfg_data), val);
}
#else /* !PCI_CONFIG_1 */
#error PCI Configuration Mechanism is not specified or implemented
--
1.7.10.4
Finally we have a working CG3 framebuffer with QEMU on SPARC32!
This patchset, minus integration of Bob's cpeek patches, should be fairly
close to the final implementation. It includes FCode source for a CG3
ROM which can be probed using a patched version of QEMU, and should be
applied on top of my previous v2 display patchset.
As a teaser, I've created the following images from my testing:
http://www.ilande.co.uk/tmp/sol8-1.pnghttp://www.ilande.co.uk/tmp/sol8-2.pnghttp://www.ilande.co.uk/tmp/sol8-3.pnghttp://www.ilande.co.uk/tmp/debian-woody.png
Some discussion points: what should be the fallback behaviour if we fail
an FCode ROM probe for the display? At the moment I attempt to execute an
internal copy of the FCode payload directly, so if people are running OpenBIOS
on systems which don't emulate SBus then there should be no difference in
behaviour.
The only minor issue at the moment is that OpenBIOS will crash if you try to
drive the display at 1152x900 rather than 1024x768. This is simply because
there isn't enough room in the 2M address space for the extra 200K or so
required for the extra screen area. We could probably fix this by trimming
out some of the extras such as grubfs (and possibly pre-aligning parts of
the memory image) but any ideas gratefully received. If you have access to
proprietary ROM images then those should work with the patched QEMU too -
please test and let me know.
Finally I've pushed my modifed QEMU source with updated OpenBIOS images to
github for testing. Simply pass -vga cg3 on the command line and you will be
switched onto the new CG3 framebuffer.
https://github.com/mcayland/qemu/tree/cg3-preview
As always thanks to everyone else for helping to make this possible - enjoy!
Mark Cave-Ayland (2):
cg3: add new FCode ROM for QEMU's Sun CG3 framebuffer
sbus: add probe for display device
openbios-devel/arch/sparc32/build.xml | 1 +
openbios-devel/drivers/build.xml | 1 +
openbios-devel/drivers/cgthree.fs | 154 +++++++++++++++++++++++++++++++++
openbios-devel/drivers/sbus.c | 30 ++++++-
openbios-devel/drivers/sbus.fs | 27 ++++--
5 files changed, 202 insertions(+), 11 deletions(-)
create mode 100644 openbios-devel/drivers/cgthree.fs
--
1.7.10.4
Implement data fault handling for cpeek and friends on SPARC32. Keeps
the existing behavior for other architectures.
This series incorporates contributions and naming suggestions from
Mark Cave-Ayland.
Bob Breuer (3):
Add peek/poke hooks
SPARC32: implement data fault handler
SPARC32: handle data faults for peek/poke
openbios-devel/arch/sparc32/init.fs | 30 ++++++++++++++++++++++++++++++
openbios-devel/arch/sparc32/lib.c | 21 +++++++++++++++++++++
openbios-devel/arch/sparc32/vectors.S | 32 ++++++++++++++++++++++++++++++--
openbios-devel/forth/device/other.fs | 22 ++++++++++++++++------
4 files changed, 97 insertions(+), 8 deletions(-)
--
1.7.10.4
Author: mcayland
Date: Mon Aug 19 14:58:12 2013
New Revision: 1223
URL: http://tracker.coreboot.org/trac/openbios/changeset/1223
Log:
sbus: add SBus slot probe functionality
Change the SBus logic so that we first probe each slot and attempt to execute any
FCode if present. Only if no FCode is found do we fall back to the internal
(hardwired) device node generation.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/drivers/sbus.c
trunk/openbios-devel/drivers/sbus.fs
trunk/openbios-devel/forth/admin/devices.fs
Modified: trunk/openbios-devel/drivers/sbus.c
==============================================================================
--- trunk/openbios-devel/drivers/sbus.c Mon Aug 19 14:58:09 2013 (r1222)
+++ trunk/openbios-devel/drivers/sbus.c Mon Aug 19 14:58:12 2013 (r1223)
@@ -141,8 +141,26 @@
static void
ob_tcx_init(unsigned int slot, const char *path)
{
- push_str(path);
- fword("find-device");
+ char buf[6];
+
+ printk("No display device located during SBus probe - falling back to internal TCX driver\n");
+
+ /* Make the sbus node the current instance and active package for probing */
+ feval("active-package my-self");
+ push_str("/iommu/sbus");
+ feval("2dup find-device open-dev to my-self");
+
+ fword("new-device");
+ PUSH(0);
+ PUSH(0);
+ snprintf(buf, 6, "%d,0", slot);
+ push_str(buf);
+ fword("set-args");
+ feval("['] tcx-driver-fcode 2 cells + 1 byte-load");
+ fword("finish-device");
+
+ /* Restore */
+ feval("to my-self active-package!");
}
static void
@@ -241,6 +259,8 @@
as the current instance during probe. */
char buf[6];
+ printk("Probing SBus slot %d offset %ld\n", slot, offset);
+
/* Make the sbus node the current instance and active package for probing */
feval("active-package my-self");
push_str("/iommu/sbus");
@@ -257,13 +277,28 @@
feval("to my-self active-package!");
}
+static int
+sbus_probe_sucess(void)
+{
+ /* Return true if the last sbus_probe_self() resulted in
+ the successful detection and execution of FCode */
+ fword("probe-fcode?");
+ return POP();
+}
+
static void
sbus_probe_slot_ss5(unsigned int slot, uint64_t base)
{
- // OpenBIOS and QEMU don't know how to do Sbus probing
+ /* Probe the slot */
+ sbus_probe_self(slot, 0);
+
+ /* If the device was successfully created by FCode then do nothing */
+ if (sbus_probe_sucess()) {
+ return;
+ }
+
switch(slot) {
case 3: // SUNW,tcx
- sbus_probe_self(slot, 0);
ob_tcx_init(slot, "/iommu/sbus/SUNW,tcx");
break;
case 4:
@@ -283,10 +318,16 @@
static void
sbus_probe_slot_ss10(unsigned int slot, uint64_t base)
{
- // OpenBIOS and QEMU don't know how to do Sbus probing
+ /* Probe the slot */
+ sbus_probe_self(slot, 0);
+
+ /* If the device was successfully created by FCode then do nothing */
+ if (sbus_probe_sucess()) {
+ return;
+ }
+
switch(slot) {
case 2: // SUNW,tcx
- sbus_probe_self(slot, 0);
ob_tcx_init(slot, "/iommu/sbus/SUNW,tcx");
break;
case 0xf: // le, esp, bpp, power-management
@@ -302,10 +343,16 @@
static void
sbus_probe_slot_ss600mp(unsigned int slot, uint64_t base)
{
- // OpenBIOS and QEMU don't know how to do Sbus probing
+ /* Probe the slot */
+ sbus_probe_self(slot, 0);
+
+ /* If the device was successfully created by FCode then do nothing */
+ if (sbus_probe_sucess()) {
+ return;
+ }
+
switch(slot) {
case 2: // SUNW,tcx
- sbus_probe_self(slot, 0);
ob_tcx_init(slot, "/iommu/sbus/SUNW,tcx");
break;
case 0xf: // le, esp, bpp, power-management
Modified: trunk/openbios-devel/drivers/sbus.fs
==============================================================================
--- trunk/openbios-devel/drivers/sbus.fs Mon Aug 19 14:58:09 2013 (r1222)
+++ trunk/openbios-devel/drivers/sbus.fs Mon Aug 19 14:58:12 2013 (r1223)
@@ -55,7 +55,7 @@
r> drop
;
-: map-out-sbus ( virt )
+: map-out-sbus ( virt size )
" map-out" $call-parent
;
@@ -64,15 +64,31 @@
\ -------------------------------------------------------------------------
: probe-self-sbus ( arg-adr arg-len reg-adr reg-len fcode-adr fcode-len -- )
- 2drop
- new-device
- set-args
-
- \ Note: this is currently hardcoded to TCX for testing as we don't have
- \ cpeek (yet). Once cpeek is in place, adapting this to probe any slot
- \ will be faily easy.
- " tcx-driver-fcode" $find drop 2 cells +
- 1 byte-load
- finish-device
+ 0 to probe-fcode?
+
+ ['] decode-unit-sbus catch if
+ 2drop 2drop 2drop 2drop
+ exit
+ then
+
+ h# 10000 map-in-sbus
+
+ dup cpeek if
+ dup h# f1 = swap h# fd = or if
+ new-device
+ >r set-args r>
+ dup 1 byte-load
+ finish-device
+
+ -1 to probe-fcode?
+ else
+ nip nip nip nip
+ ." Invalid FCode start byte" cr
+ then
+ else
+ nip nip nip nip
+ then
+
+ h# 10000 map-out-sbus
;
Modified: trunk/openbios-devel/forth/admin/devices.fs
==============================================================================
--- trunk/openbios-devel/forth/admin/devices.fs Mon Aug 19 14:58:09 2013 (r1222)
+++ trunk/openbios-devel/forth/admin/devices.fs Mon Aug 19 14:58:12 2013 (r1223)
@@ -508,5 +508,8 @@
\ 7.4.11.3 Device probing
+\ Set to true if the last probe-self was successful
+0 value probe-fcode?
+
: probe-all ( -- )
;