[OpenBIOS] [PATCH 12/15] pci: 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:19 CEST 2018
This enables disk drivers to call the dma-* words as required by the
specification, and in particular fixes the failing dma-alloc warnings
emitted by NetBSD PPC on boot.
Note that we also add these methods to any partition/file packages via a
new is-call-parent helper word to ensure that the dma-* words are
available at all levels of interposition.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
drivers/ide.c | 40 ++++++++++++++++++++++++++++++++++++++++
drivers/macio.c | 35 +++++++++++++++++++++++++++++++++++
drivers/pci.c | 40 ++++++++++++++++++++++++++++++++++++++++
forth/util/util.fs | 9 +++++++++
packages/disk-label.fs | 39 +++++++++++++++++++++++++++++++++++++++
5 files changed, 163 insertions(+)
diff --git a/drivers/ide.c b/drivers/ide.c
index a3535d8..274236f 100644
--- a/drivers/ide.c
+++ b/drivers/ide.c
@@ -1287,6 +1287,36 @@ ob_ide_close(struct ide_drive *drive)
selfword("close-deblocker");
}
+static void
+ob_ide_dma_alloc(int *idx)
+{
+ call_parent_method("dma-alloc");
+}
+
+static void
+ob_ide_dma_free(int *idx)
+{
+ call_parent_method("dma-free");
+}
+
+static void
+ob_ide_dma_map_in(int *idx)
+{
+ call_parent_method("dma-map-in");
+}
+
+static void
+ob_ide_dma_map_out(int *idx)
+{
+ call_parent_method("dma-map-out");
+}
+
+static void
+ob_ide_dma_sync(int *idx)
+{
+ call_parent_method("dma-sync");
+}
+
NODE_METHODS(ob_ide) = {
{ NULL, ob_ide_initialize },
{ "open", ob_ide_open },
@@ -1294,6 +1324,11 @@ NODE_METHODS(ob_ide) = {
{ "read-blocks", ob_ide_read_blocks },
{ "block-size", ob_ide_block_size },
{ "max-transfer", ob_ide_max_transfer },
+ { "dma-alloc", ob_ide_dma_alloc },
+ { "dma-free", ob_ide_dma_free },
+ { "dma-map-in", ob_ide_dma_map_in },
+ { "dma-map-out", ob_ide_dma_map_out },
+ { "dma-sync", ob_ide_dma_sync },
};
static void
@@ -1318,6 +1353,11 @@ ob_ide_ctrl_decodeunit(int *idx)
NODE_METHODS(ob_ide_ctrl) = {
{ NULL, ob_ide_ctrl_initialize },
{ "decode-unit", ob_ide_ctrl_decodeunit },
+ { "dma-alloc", ob_ide_dma_alloc },
+ { "dma-free", ob_ide_dma_free },
+ { "dma-map-in", ob_ide_dma_map_in },
+ { "dma-map-out", ob_ide_dma_map_out },
+ { "dma-sync", ob_ide_dma_sync },
};
static void set_cd_alias(const char *path)
diff --git a/drivers/macio.c b/drivers/macio.c
index 94ca90f..8ca20d8 100644
--- a/drivers/macio.c
+++ b/drivers/macio.c
@@ -220,9 +220,44 @@ ob_macio_encode_unit(void *private)
push_str(buf);
}
+static void
+ob_macio_dma_alloc(int *idx)
+{
+ call_parent_method("dma-alloc");
+}
+
+static void
+ob_macio_dma_free(int *idx)
+{
+ call_parent_method("dma-free");
+}
+
+static void
+ob_macio_dma_map_in(int *idx)
+{
+ call_parent_method("dma-map-in");
+}
+
+static void
+ob_macio_dma_map_out(int *idx)
+{
+ call_parent_method("dma-map-out");
+}
+
+static void
+ob_macio_dma_sync(int *idx)
+{
+ call_parent_method("dma-sync");
+}
+
NODE_METHODS(ob_macio) = {
{ "decode-unit", ob_macio_decode_unit },
{ "encode-unit", ob_macio_encode_unit },
+ { "dma-alloc", ob_macio_dma_alloc },
+ { "dma-free", ob_macio_dma_free },
+ { "dma-map-in", ob_macio_dma_map_in },
+ { "dma-map-out", ob_macio_dma_map_out },
+ { "dma-sync", ob_macio_dma_sync },
};
static void
diff --git a/drivers/pci.c b/drivers/pci.c
index 295be7e..dbdd40e 100644
--- a/drivers/pci.c
+++ b/drivers/pci.c
@@ -428,6 +428,36 @@ ob_pci_bus_map_in(int *idx)
PUSH(virt);
}
+static void
+ob_pci_dma_alloc(int *idx)
+{
+ call_parent_method("dma-alloc");
+}
+
+static void
+ob_pci_dma_free(int *idx)
+{
+ call_parent_method("dma-free");
+}
+
+static void
+ob_pci_dma_map_in(int *idx)
+{
+ call_parent_method("dma-map-in");
+}
+
+static void
+ob_pci_dma_map_out(int *idx)
+{
+ call_parent_method("dma-map-out");
+}
+
+static void
+ob_pci_dma_sync(int *idx)
+{
+ call_parent_method("dma-sync");
+}
+
NODE_METHODS(ob_pci_bus_node) = {
{ NULL, ob_pci_initialize },
{ "open", ob_pci_open },
@@ -435,6 +465,11 @@ NODE_METHODS(ob_pci_bus_node) = {
{ "decode-unit", ob_pci_decode_unit },
{ "encode-unit", ob_pci_encode_unit },
{ "pci-map-in", ob_pci_bus_map_in },
+ { "dma-alloc", ob_pci_dma_alloc },
+ { "dma-free", ob_pci_dma_free },
+ { "dma-map-in", ob_pci_dma_map_in },
+ { "dma-map-out", ob_pci_dma_map_out },
+ { "dma-sync", ob_pci_dma_sync },
};
/* ( pci-addr.lo pci-addr.mid pci-addr.hi size -- virt ) */
@@ -453,6 +488,11 @@ NODE_METHODS(ob_pci_bridge_node) = {
{ "decode-unit", ob_pci_decode_unit },
{ "encode-unit", ob_pci_encode_unit },
{ "pci-map-in", ob_pci_bridge_map_in },
+ { "dma-alloc", ob_pci_dma_alloc },
+ { "dma-free", ob_pci_dma_free },
+ { "dma-map-in", ob_pci_dma_map_in },
+ { "dma-map-out", ob_pci_dma_map_out },
+ { "dma-sync", ob_pci_dma_sync },
};
NODE_METHODS(ob_pci_simple_node) = {
diff --git a/forth/util/util.fs b/forth/util/util.fs
index 6f549bf..8247c7d 100644
--- a/forth/util/util.fs
+++ b/forth/util/util.fs
@@ -60,6 +60,15 @@
is-func-end
;
+\ is-call-parent installs a function that calls a function with
+\ the same name but on the parent node
+: is-call-parent ( str len )
+ 2dup is-func-begin
+ ['] (") , dup , ", null-align
+ ['] $call-parent ,
+ is-func-end
+;
+
\ -------------------------------------------------------------------------
\ install deblocker bindings
\ -------------------------------------------------------------------------
diff --git a/packages/disk-label.fs b/packages/disk-label.fs
index 8354f87..0021ade 100644
--- a/packages/disk-label.fs
+++ b/packages/disk-label.fs
@@ -75,6 +75,26 @@ new-device
( phandle probe-xt )
fs-handlers list-add , ,
;
+
+ : 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
\ ---------------------------------------------------------------------------
@@ -82,9 +102,27 @@ finish-device
\ ---------------------------------------------------------------------------
device-end
+
+: initialise-partition-package ( -- )
+ " dma-alloc" is-call-parent
+ " dma-free" is-call-parent
+ " dma-map-in" is-call-parent
+ " dma-map-out" is-call-parent
+ " dma-sync" is-call-parent
+;
+
+: initialise-fs-package ( -- )
+ " dma-alloc" is-call-parent
+ " dma-free" is-call-parent
+ " dma-map-in" is-call-parent
+ " dma-map-out" is-call-parent
+ " dma-sync" is-call-parent
+;
+
: register-partition-package ( -- )
" register-part-handler" " disk-label" $find-package-method ?dup if
active-package swap execute
+ initialise-partition-package
else
." [disk-label] internal error" cr
then
@@ -93,6 +131,7 @@ device-end
: register-fs-package ( -- )
" register-fs-handler" " disk-label" $find-package-method ?dup if
active-package swap execute
+ initialise-fs-package
else
." [misc-files] internal error" cr
then
--
2.11.0
More information about the OpenBIOS
mailing list