[OpenBIOS] [PATCH 14/15] esp: switch creation of esp device over to use new-device

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Mon May 21 23:33:21 CEST 2018


Instead of using a C initialize function to create the esp device, switch over
to using the Forth "new-device" word so that all of the initialisation can be
done in place in ob_esp_init().

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 drivers/esp.c | 98 ++++++++++++++++++++++++++++-------------------------------
 1 file changed, 47 insertions(+), 51 deletions(-)

diff --git a/drivers/esp.c b/drivers/esp.c
index 0454d5c..b13ff2c 100644
--- a/drivers/esp.c
+++ b/drivers/esp.c
@@ -435,35 +435,6 @@ espdma_init(unsigned int slot, uint64_t base, unsigned long offset,
 }
 
 static void
-ob_esp_initialize(__attribute__((unused)) esp_private_t **esp)
-{
-    phandle_t ph = get_cur_dev();
-
-    set_int_property(ph, "#address-cells", 2);
-    set_int_property(ph, "#size-cells", 0);
-
-    /* set device type */
-    push_str("scsi");
-    fword("device-type");
-
-    /* QEMU's ESP emulation does not support mixing DMA and FIFO messages. By
-       setting this attribute, we prevent the Solaris ESP kernel driver from
-       trying to use this feature when booting a disk image (and failing) */
-    PUSH(0x58);
-    fword("encode-int");
-    push_str("scsi-options");
-    fword("property");
-
-    PUSH(0x24);
-    fword("encode-int");
-    PUSH(0);
-    fword("encode-int");
-    fword("encode+");
-    push_str("intr");
-    fword("property");
-}
-
-static void
 ob_esp_decodeunit(__attribute__((unused)) esp_private_t **esp)
 {
     fword("decode-unit-scsi");
@@ -477,7 +448,6 @@ ob_esp_encodeunit(__attribute__((unused)) esp_private_t **esp)
 }
 
 NODE_METHODS(ob_esp) = {
-    { NULL,             ob_esp_initialize  },
     { "decode-unit",    ob_esp_decodeunit  },
     { "encode-unit",    ob_esp_encodeunit  },
     { "dma-alloc",      ob_esp_dma_alloc   },
@@ -529,6 +499,53 @@ ob_esp_init(unsigned int slot, uint64_t base, unsigned long espoffset,
         return -1;
     }
 
+    push_str("/iommu/sbus/espdma");
+    fword("find-device");
+    fword("new-device");
+
+    push_str("esp");
+    fword("device-name");
+
+    /* set device type */
+    push_str("scsi");
+    fword("device-type");
+
+    /* QEMU's ESP emulation does not support mixing DMA and FIFO messages. By
+       setting this attribute, we prevent the Solaris ESP kernel driver from
+       trying to use this feature when booting a disk image (and failing) */
+    PUSH(0x58);
+    fword("encode-int");
+    push_str("scsi-options");
+    fword("property");
+
+    PUSH(0x24);
+    fword("encode-int");
+    PUSH(0);
+    fword("encode-int");
+    fword("encode+");
+    push_str("intr");
+    fword("property");
+
+    PUSH(slot);
+    fword("encode-int");
+    PUSH(espoffset);
+    fword("encode-int");
+    fword("encode+");
+    PUSH(0x00000010);
+    fword("encode-int");
+    fword("encode+");
+    push_str("reg");
+    fword("property");
+
+    PUSH(0x02625a00);
+    fword("encode-int");
+    push_str("clock-frequency");
+    fword("property");
+
+    REGISTER_NODE_METHODS(ob_esp, "/iommu/sbus/espdma/esp");
+
+    fword("finish-device");
+
     esp->buffer = (void *)dvma_alloc(BUFSIZE);
     esp->buffer_dvma = dvma_map_in(esp->buffer);
     if (!esp->buffer || !esp->buffer_dvma) {
@@ -568,27 +585,6 @@ ob_esp_init(unsigned int slot, uint64_t base, unsigned long espoffset,
 #endif
     }
 
-    REGISTER_NAMED_NODE(ob_esp, "/iommu/sbus/espdma/esp");
-    device_end();
-    /* set reg */
-    push_str("/iommu/sbus/espdma/esp");
-    fword("find-device");
-    PUSH(slot);
-    fword("encode-int");
-    PUSH(espoffset);
-    fword("encode-int");
-    fword("encode+");
-    PUSH(0x00000010);
-    fword("encode-int");
-    fword("encode+");
-    push_str("reg");
-    fword("property");
-
-    PUSH(0x02625a00);
-    fword("encode-int");
-    push_str("clock-frequency");
-    fword("property");
-
     for (id = 0; id < 8; id++) {
         if (!esp->sd[id].present)
             continue;
-- 
2.11.0




More information about the OpenBIOS mailing list