[OpenBIOS] [PATCH 13/15] sbus: add dma-* call-parent chain to all PCI devices and bridges

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


This enables disk drivers to call the dma-* words as required by the
specification.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 arch/sparc32/tree.fs | 20 ++++++++++++++++++++
 drivers/esp.c        | 45 ++++++++++++++++++++++++++++++++++++++++++---
 drivers/iommu.c      | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/arch/sparc32/tree.fs b/arch/sparc32/tree.fs
index fc95636..e9d0333 100644
--- a/arch/sparc32/tree.fs
+++ b/arch/sparc32/tree.fs
@@ -93,6 +93,11 @@ new-device
   : decode-unit decode-unit-sbus ;
   : map-in map-in-sbus ;
   : map-out map-out-sbus ;
+  : dma-alloc " dma-alloc" $call-parent ;
+  : dma-free " dma-free" $call-parent ;
+  : dma-map-in " dma-map-in" $call-parent ;
+  : dma-map-out " dma-map-out" $call-parent ;
+  : dma-sync " dma-sync" $call-parent ;
 finish-device
 
 [IFDEF] CONFIG_BPP
@@ -110,6 +115,11 @@ new-device
   external
   : encode-unit encode-unit-sbus ;
   : decode-unit decode-unit-sbus ;
+  : dma-alloc " dma-alloc" $call-parent ;
+  : dma-free " dma-free" $call-parent ;
+  : dma-map-in " dma-map-in" $call-parent ;
+  : dma-map-out " dma-map-out" $call-parent ;
+  : dma-sync " dma-sync" $call-parent ;
 finish-device
 
 " /iommu/sbus" find-device
@@ -119,6 +129,11 @@ new-device
   external
   : encode-unit encode-unit-sbus ;
   : decode-unit decode-unit-sbus ;
+  : dma-alloc " dma-alloc" $call-parent ;
+  : dma-free " dma-free" $call-parent ;
+  : dma-map-in " dma-map-in" $call-parent ;
+  : dma-map-out " dma-map-out" $call-parent ;
+  : dma-sync " dma-sync" $call-parent ;
 finish-device
 
 " /iommu/sbus/ledma" find-device
@@ -127,6 +142,11 @@ new-device
   " network" device-type
   h# 7 encode-int " busmaster-regval" property
   h# 26 encode-int 0 encode-int encode+ " intr" property
+  : dma-alloc " dma-alloc" $call-parent ;
+  : dma-free " dma-free" $call-parent ;
+  : dma-map-in " dma-map-in" $call-parent ;
+  : dma-map-out " dma-map-out" $call-parent ;
+  : dma-sync " dma-sync" $call-parent ;
 finish-device
 
 \ obio (on-board IO)
diff --git a/drivers/esp.c b/drivers/esp.c
index 44b2096..0454d5c 100644
--- a/drivers/esp.c
+++ b/drivers/esp.c
@@ -248,6 +248,35 @@ inquiry(esp_private_t *esp, sd_private_t *sd)
     return 1;
 }
 
+static void
+ob_esp_dma_alloc(__attribute__((unused)) esp_private_t **esp)
+{
+    call_parent_method("dma-alloc");
+}
+
+static void
+ob_esp_dma_free(__attribute__((unused)) esp_private_t **esp)
+{
+    call_parent_method("dma-free");
+}
+
+static void
+ob_esp_dma_map_in(__attribute__((unused)) esp_private_t **esp)
+{
+    call_parent_method("dma-map-in");
+}
+
+static void
+ob_esp_dma_map_out(__attribute__((unused)) esp_private_t **esp)
+{
+    call_parent_method("dma-map-out");
+}
+
+static void
+ob_esp_dma_sync(__attribute__((unused)) esp_private_t **esp)
+{
+    call_parent_method("dma-sync");
+}
 
 static void
 ob_sd_read_blocks(sd_private_t **sd)
@@ -333,6 +362,11 @@ NODE_METHODS(ob_sd) = {
     { "close",          ob_sd_close },
     { "read-blocks",    ob_sd_read_blocks },
     { "block-size",     ob_sd_block_size },
+    { "dma-alloc",      ob_esp_dma_alloc   },
+    { "dma-free",       ob_esp_dma_free    },
+    { "dma-map-in",     ob_esp_dma_map_in  },
+    { "dma-map-out",    ob_esp_dma_map_out },
+    { "dma-sync",       ob_esp_dma_sync    },
 };
 
 
@@ -443,9 +477,14 @@ 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 },
+    { NULL,             ob_esp_initialize  },
+    { "decode-unit",    ob_esp_decodeunit  },
+    { "encode-unit",    ob_esp_encodeunit  },
+    { "dma-alloc",      ob_esp_dma_alloc   },
+    { "dma-free",       ob_esp_dma_free    },
+    { "dma-map-in",     ob_esp_dma_map_in  },
+    { "dma-map-out",    ob_esp_dma_map_out },
+    { "dma-sync",       ob_esp_dma_sync    },
 };
 
 static void
diff --git a/drivers/iommu.c b/drivers/iommu.c
index c414894..a6c02b8 100644
--- a/drivers/iommu.c
+++ b/drivers/iommu.c
@@ -207,6 +207,36 @@ ob_iommu_map_out(void)
     ofmem_release_io(virt, size);
 }
 
+static void
+ob_iommu_dma_alloc(void)
+{
+    call_parent_method("dma-alloc");
+}
+
+static void
+ob_iommu_dma_free(void)
+{
+    call_parent_method("dma-free");
+}
+
+static void
+ob_iommu_dma_map_in(void)
+{
+    call_parent_method("dma-map-in");
+}
+
+static void
+ob_iommu_dma_map_out(void)
+{
+    call_parent_method("dma-map-out");
+}
+
+static void
+ob_iommu_dma_sync(void)
+{
+    call_parent_method("dma-sync");
+}
+
 void
 ob_init_iommu(uint64_t base)
 {
@@ -234,4 +264,9 @@ ob_init_iommu(uint64_t base)
 
     bind_func("map-in", ob_iommu_map_in);
     bind_func("map-out", ob_iommu_map_out);
+    bind_func("dma-alloc", ob_iommu_dma_alloc);
+    bind_func("dma-free", ob_iommu_dma_free);
+    bind_func("dma-map-in", ob_iommu_dma_map_in);
+    bind_func("dma-map-out", ob_iommu_dma_map_out);
+    bind_func("dma-sync", ob_iommu_dma_sync);
 }
-- 
2.11.0




More information about the OpenBIOS mailing list