qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] sun4m: Add FCode ROM for TCX framebuffer
@ 2013-08-20 22:25 Mark Cave-Ayland
  2013-08-20 22:41 ` Peter Maydell
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Cave-Ayland @ 2013-08-20 22:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Bob Breuer, Mark Cave-Ayland, Artyom Tarasenko

Upstream OpenBIOS now implements SBus probing in order to determine the
contents of a physical bus slot, which is required to allow OpenBIOS to
identify the framebuffer without help from the fw_cfg interface.

SBus probing works by detecting the presence of an FCode program
(effectively tokenised Forth) at the base address of each slot, and if
present executes it so that it creates its own device node in the
OpenBIOS device tree.

The FCode ROM is generated as part of the OpenBIOS build and should
generally be updated at the same time.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
CC: Blue Swirl <blauwirbel@gmail.com>
CC: Bob Breuer <breuerr@mc.net>
CC: Artyom Tarasenko <atar4qemu@gmail.com>
---
 hw/display/tcx.c     |    7 +++++++
 hw/sparc/sun4m.c     |   32 +++++++++++++++++++++++++-------
 pc-bios/QEMU,tcx.bin |  Bin 0 -> 1242 bytes
 3 files changed, 32 insertions(+), 7 deletions(-)
 create mode 100644 pc-bios/QEMU,tcx.bin

diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index 24876d3..7a18d3e 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -43,6 +43,7 @@ typedef struct TCXState {
     QemuConsole *con;
     uint8_t *vram;
     uint32_t *vram24, *cplane;
+    MemoryRegion rom;
     MemoryRegion vram_mem;
     MemoryRegion vram_8bit;
     MemoryRegion vram_24bit;
@@ -537,6 +538,12 @@ static int tcx_init1(SysBusDevice *dev)
     vmstate_register_ram_global(&s->vram_mem);
     vram_base = memory_region_get_ram_ptr(&s->vram_mem);
 
+    /* FCode ROM */
+    memory_region_init_ram(&s->rom, NULL, "tcx.prom", 0x10000);
+    vmstate_register_ram_global(&s->rom);
+    memory_region_set_readonly(&s->rom, true);
+    sysbus_init_mmio(dev, &s->rom);
+
     /* 8-bit plane */
     s->vram = vram_base;
     size = s->vram_size;
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 942ca37..9d7814b 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -75,6 +75,8 @@
 
 #define ESCC_CLOCK 4915200
 
+#define FCODE_MAX_ROM_SIZE 0x10000
+
 struct sun4m_hwdef {
     hwaddr iommu_base, iommu_pad_base, iommu_pad_len, slavio_base;
     hwaddr intctl_base, counter_base, nvram_base, ms_kb_base;
@@ -526,11 +528,15 @@ static void apc_init(hwaddr power_base, qemu_irq cpu_halt)
     sysbus_connect_irq(s, 0, cpu_halt);
 }
 
+#define TCX_ROM_FILE  "QEMU,tcx.bin"
+
 static void tcx_init(hwaddr addr, int vram_size, int width,
                      int height, int depth)
 {
     DeviceState *dev;
     SysBusDevice *s;
+    char *fcode_filename = NULL;
+    int ret = -1;
 
     dev = qdev_create(NULL, "SUNW,tcx");
     qdev_prop_set_uint32(dev, "vram_size", vram_size);
@@ -539,22 +545,34 @@ static void tcx_init(hwaddr addr, int vram_size, int width,
     qdev_prop_set_uint16(dev, "depth", depth);
     qdev_init_nofail(dev);
     s = SYS_BUS_DEVICE(dev);
+    /* FCode ROM */
+    sysbus_mmio_map(s, 0, addr);
     /* 8-bit plane */
-    sysbus_mmio_map(s, 0, addr + 0x00800000ULL);
+    sysbus_mmio_map(s, 1, addr + 0x00800000ULL);
     /* DAC */
-    sysbus_mmio_map(s, 1, addr + 0x00200000ULL);
+    sysbus_mmio_map(s, 2, addr + 0x00200000ULL);
     /* TEC (dummy) */
-    sysbus_mmio_map(s, 2, addr + 0x00700000ULL);
+    sysbus_mmio_map(s, 3, addr + 0x00700000ULL);
     /* THC 24 bit: NetBSD writes here even with 8-bit display: dummy */
-    sysbus_mmio_map(s, 3, addr + 0x00301000ULL);
+    sysbus_mmio_map(s, 4, addr + 0x00301000ULL);
     if (depth == 24) {
         /* 24-bit plane */
-        sysbus_mmio_map(s, 4, addr + 0x02000000ULL);
+        sysbus_mmio_map(s, 5, addr + 0x02000000ULL);
         /* Control plane */
-        sysbus_mmio_map(s, 5, addr + 0x0a000000ULL);
+        sysbus_mmio_map(s, 6, addr + 0x0a000000ULL);
     } else {
         /* THC 8 bit (dummy) */
-        sysbus_mmio_map(s, 4, addr + 0x00300000ULL);
+        sysbus_mmio_map(s, 5, addr + 0x00300000ULL);
+    }
+
+    fcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, TCX_ROM_FILE);
+    if (fcode_filename) {
+        ret = load_image_targphys(fcode_filename, addr, FCODE_MAX_ROM_SIZE);
+    }
+
+    if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) {
+        fprintf(stderr, "qemu: could not load prom '%s'\n", TCX_ROM_FILE);
+        exit(1);
     }
 }
 
diff --git a/pc-bios/QEMU,tcx.bin b/pc-bios/QEMU,tcx.bin
new file mode 100644
index 0000000000000000000000000000000000000000..a8ddd70ef35355c30d7cffd2e1b57f877572a3ca
GIT binary patch
literal 1242
zcmZ8hxl-Fu6xFkZeQXTK&j!qn**AgB64rt)Bt;q~lNw`zm4NNY!htH3naNM2fFJOT
zMvP0-C0(jantVh4Aoo6xa1s^oY*+VceZQe4G)@2MLG!<*wdh7l>uTIJS~6X!TIGUW
zshM@VXjRM)cF`?Cvpk3g+5cZyvh4GctJ2Vej2Eq{TQUo_TT@n;tP8trnS~qIYFqk)
zhb|xDvgIM-Bg7c>5oUxB{jz0fba;q04NWkK6PaYvO+-5+l3=3g9(st(aMT+_eL-Xp
zS>Pzi&MgtCBH<xLBxjJ5X2Lc79I-RN1fw1XiBvht1kn(YTXu$tP?d*~rV&z?I!ewV
zJ7Zj|(TMS;p{r;jh$e$5+cY97nj+_x&zf!;aplYe#j`>2T+^VJL^bn4@j?(SHjQ2t
zEd|kX5Un&ln11eFgno#yNaaORNP4`hK87&@6QdZ1DI_M4RXBxdg)^8_IFChzOIT5u
z!H~jk^eF7dpu!m93VUHFOd`c7!;W<>44SysnK-5@CNQb6GjUewc`PVg!m`57#Dvmm
z3@GeO>{B`k$=I2g^K&Acmyyeps%e))F}jGnFQY6gS1##059<%KZ1A#4ALEvvdw%>e
zkM;3d>ucn+a#3-zc;??@>%~icn>x1s1!}qNqZ=E@Jz|~I4&9}}KNB09WbFFb#!gG(
z`1PwdEAHuaNXTf>u2nBiZp5&MJs<0L2Wf2?yV!gb1@TtAqctg`C&i*;)oQ{(7a~XE
zGJ7O0vf^`tn(q6E@`Zp-oWd%49<d>H*SWGpTE=LIxx+u6Fj88kfi)y3SM>-x)J=C9
ztj2gsy-=+<rzK&q^M#$#-%f;_u6pgJeA=$~#JbecVb$a8uO1oI<H-sC`hLhx)xJJ+
ztoQ9M2i&FJ*5DD5_TItw%8}Y;NPt9)Hx0FCw9lo2d;W-}ZkJu>$&+!Cmg8JiU3z3m
K?1|A9_O(BcTLJ$7

literal 0
HcmV?d00001

-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-08-26 21:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20 22:25 [Qemu-devel] [PATCH] sun4m: Add FCode ROM for TCX framebuffer Mark Cave-Ayland
2013-08-20 22:41 ` Peter Maydell
2013-08-21 14:44   ` Mark Cave-Ayland
2013-08-21 15:34     ` Peter Maydell
2013-08-21 16:29       ` Mark Cave-Ayland
2013-08-21 17:06         ` Peter Maydell
2013-08-24 13:05           ` Mark Cave-Ayland
2013-08-21 17:54   ` Andreas Färber
2013-08-21 18:52     ` Mark Cave-Ayland
2013-08-24 17:46       ` Andreas Färber
2013-08-26 21:35         ` Mark Cave-Ayland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).