Author: mcayland Date: Mon Aug 19 09:40:22 2013 New Revision: 1212 URL: http://tracker.coreboot.org/trac/openbios/changeset/1212
Log: sbus/tcx: implement probe_self() wrapper
Implement a C wrapper around the Forth probe-self word and test it by moving TCX package properties to tcx.fs.
Note that the probe-self-sbus word is currently hard-coded to invoke the TCX driver FCode - this is only temporary and will be replaced when we have a working cpeek implementation.
Also remove the creation of the SUNW,tcx package from tree.fs since this is now done as part of probe-self-sbus.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/arch/sparc32/tree.fs trunk/openbios-devel/drivers/sbus.c trunk/openbios-devel/drivers/sbus.fs trunk/openbios-devel/drivers/tcx.fs
Modified: trunk/openbios-devel/arch/sparc32/tree.fs ============================================================================== --- trunk/openbios-devel/arch/sparc32/tree.fs Mon Aug 19 09:40:18 2013 (r1211) +++ trunk/openbios-devel/arch/sparc32/tree.fs Mon Aug 19 09:40:22 2013 (r1212) @@ -70,25 +70,6 @@
" /iommu/sbus" find-device new-device - " SUNW,tcx" device-name - " display" device-type - h# 1d encode-int " vbporch" property - h# a0 encode-int " hbporch" property - h# 06 encode-int " vsync" property - h# 88 encode-int " hsync" property - h# 03 encode-int " vfporch" property - h# 18 encode-int " hfporch" property - h# 03dfd240 encode-int " pixfreq" property - h# 3c encode-int " vfreq" property - h# 300 encode-int " height" property - h# 400 encode-int " width" property - h# 400 encode-int " linebytes" property - 5 encode-int 0 encode-int encode+ " intr" property - 5 encode-int " interrupts" property -finish-device - -" /iommu/sbus" find-device -new-device " espdma" device-name external : encode-unit encode-unit-sbus ;
Modified: trunk/openbios-devel/drivers/sbus.c ============================================================================== --- trunk/openbios-devel/drivers/sbus.c Mon Aug 19 09:40:18 2013 (r1211) +++ trunk/openbios-devel/drivers/sbus.c Mon Aug 19 09:40:22 2013 (r1212) @@ -141,7 +141,7 @@ static void ob_tcx_init(unsigned int slot, const char *path) { - phandle_t chosen, aliases; + phandle_t chosen;
push_str(path); fword("find-device"); @@ -342,18 +342,6 @@ }
bind_func("hw-set-color", tcx_hw_set_color); - - /* Currently we don't have an SBus probe routine, so execute FCode - directly */ - feval("['] tcx-driver-fcode 2 cells + 1 byte-load"); - - chosen = find_dev("/chosen"); - push_str(path); - fword("open-dev"); - set_int_property(chosen, "screen", POP()); - - aliases = find_dev("/aliases"); - set_property(aliases, "screen", path, strlen(path) + 1); }
static void @@ -445,11 +433,36 @@ }
static void +sbus_probe_self(unsigned int slot, unsigned long offset) +{ + /* Wrapper for calling probe-self in Forth. This is mainly because some + drivers don't handle properties correctly when the sbus node is set + as the current instance during probe. */ + char buf[6]; + + /* Make the sbus node the current instance and active package for probing */ + feval("active-package my-self"); + push_str("/iommu/sbus"); + feval("open-dev to my-self"); + + PUSH(0); + PUSH(0); + snprintf(buf, 6, "%d,%ld", slot, offset); + push_str(buf); + fword("2dup"); + fword("probe-self-sbus"); + + /* Restore */ + feval("to my-self active-package!"); +} + +static void sbus_probe_slot_ss5(unsigned int slot, uint64_t base) { // OpenBIOS and QEMU don't know how to do Sbus probing switch(slot) { case 3: // SUNW,tcx + sbus_probe_self(slot, 0); ob_tcx_init(slot, "/iommu/sbus/SUNW,tcx"); break; case 4: @@ -472,6 +485,7 @@ // OpenBIOS and QEMU don't know how to do Sbus probing 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 @@ -490,6 +504,7 @@ // OpenBIOS and QEMU don't know how to do Sbus probing 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 09:40:18 2013 (r1211) +++ trunk/openbios-devel/drivers/sbus.fs Mon Aug 19 09:40:22 2013 (r1212) @@ -58,3 +58,21 @@ : map-out-sbus ( virt ) " map-out" $call-parent ; + +\ ------------------------------------------------------------------------- +\ SBus probe +\ ------------------------------------------------------------------------- + +: 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 +;
Modified: trunk/openbios-devel/drivers/tcx.fs ============================================================================== --- trunk/openbios-devel/drivers/tcx.fs Mon Aug 19 09:40:18 2013 (r1211) +++ trunk/openbios-devel/drivers/tcx.fs Mon Aug 19 09:40:22 2013 (r1212) @@ -4,6 +4,8 @@ \ This is the Forth source for an Fcode payload to initialise \ the QEMU TCX graphics card. \ +\ (C) Copyright 2013 Mark Cave-Ayland +\
fcode-version3
@@ -30,6 +32,13 @@ then ;
+\ +\ Installation +\ + +" SUNW,tcx" device-name +" display" device-type + : qemu-tcx-driver-install ( -- ) openbios-video-addr to frame-buffer-adr default-font set-font @@ -38,6 +47,22 @@ ;
: qemu-tcx-driver-init + + h# 1d encode-int " vbporch" property + h# a0 encode-int " hbporch" property + h# 06 encode-int " vsync" property + h# 88 encode-int " hsync" property + h# 03 encode-int " vfporch" property + h# 18 encode-int " hfporch" property + h# 03dfd240 encode-int " pixfreq" property + h# 3c encode-int " vfreq" property + h# 300 encode-int " height" property + h# 400 encode-int " width" property + h# 400 encode-int " linebytes" property + + 5 encode-int 0 encode-int encode+ " intr" property + 5 encode-int " interrupts" property + ['] qemu-tcx-driver-install is-install ;