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 --- openbios-devel/arch/sparc32/tree.fs | 19 ---------------- openbios-devel/drivers/iommu.c | 12 ++-------- openbios-devel/drivers/sbus.c | 41 ++++++++++++++++++++++++----------- openbios-devel/drivers/sbus.fs | 18 +++++++++++++++ openbios-devel/drivers/tcx.fs | 23 ++++++++++++++++++++ 5 files changed, 71 insertions(+), 42 deletions(-)
diff --git a/openbios-devel/arch/sparc32/tree.fs b/openbios-devel/arch/sparc32/tree.fs index 58e8339..c82bb17 100644 --- a/openbios-devel/arch/sparc32/tree.fs +++ b/openbios-devel/arch/sparc32/tree.fs @@ -70,25 +70,6 @@ finish-device
" /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 ; diff --git a/openbios-devel/drivers/iommu.c b/openbios-devel/drivers/iommu.c index 0fd5018..7314bdd 100644 --- a/openbios-devel/drivers/iommu.c +++ b/openbios-devel/drivers/iommu.c @@ -155,21 +155,13 @@ static void ob_iommu_map_in(void) { phys_addr_t phys; - ucell size, virt, align; + ucell size, virt;
size = POP(); POP(); phys = POP();
- /* Make sure we are page-aligned at a minimum */ - align = size; - if (align < PAGE_SIZE) { - align = PAGE_SIZE; - } - - ofmem_claim_phys(phys, size, 0); - virt = ofmem_claim_virt(-1, size, align); - ofmem_map(phys, virt, size, ofmem_arch_default_translation_mode(phys)); + virt = ofmem_map_io(phys, size);
PUSH(virt); } diff --git a/openbios-devel/drivers/sbus.c b/openbios-devel/drivers/sbus.c index 5f2592f..3257142 100644 --- a/openbios-devel/drivers/sbus.c +++ b/openbios-devel/drivers/sbus.c @@ -141,7 +141,7 @@ uint16_t graphic_depth; 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 @@ ob_tcx_init(unsigned int slot, const char *path) }
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 @@ ob_macio_init(unsigned int slot, uint64_t base, unsigned long offset) }
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 @@ sbus_probe_slot_ss10(unsigned int slot, uint64_t base) // 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 @@ sbus_probe_slot_ss600mp(unsigned int slot, uint64_t base) // 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 diff --git a/openbios-devel/drivers/sbus.fs b/openbios-devel/drivers/sbus.fs index 11a2365..20a8132 100644 --- a/openbios-devel/drivers/sbus.fs +++ b/openbios-devel/drivers/sbus.fs @@ -58,3 +58,21 @@ : map-out-sbus ( virt ) " map-in" $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 +; diff --git a/openbios-devel/drivers/tcx.fs b/openbios-devel/drivers/tcx.fs index 19fa555..8b16858 100644 --- a/openbios-devel/drivers/tcx.fs +++ b/openbios-devel/drivers/tcx.fs @@ -30,6 +30,13 @@ fcode-version3 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 +45,22 @@ fcode-version3 ;
: 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 ;