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@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 ( -- ) ;