diff options
author | Thomas Huth <thuth@linux.vnet.ibm.com> | 2011-08-05 09:31:12 +0200 |
---|---|---|
committer | Thomas Huth <thuth@linux.vnet.ibm.com> | 2011-10-12 16:24:55 +0200 |
commit | 4f0a051873ec1d1c026dab8a76fce2ceb955475e (patch) | |
tree | c24100782f146f2a067ef4b460b41ce65654d42e /clients | |
parent | 904abb4a8f424f7962f09d4aa53fb321403fc087 (diff) | |
download | SLOF-4f0a051873ec1d1c026dab8a76fce2ceb955475e.zip SLOF-4f0a051873ec1d1c026dab8a76fce2ceb955475e.tar.gz SLOF-4f0a051873ec1d1c026dab8a76fce2ceb955475e.tar.bz2 |
Added PCI DMA functions
DMA transfers can only happen within a dedicated DMA window, so we need
special functions for allocating buffers and for mapping these buffers in and
out again.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Diffstat (limited to 'clients')
-rw-r--r-- | clients/net-snk/include/netdriver_int.h | 5 | ||||
-rw-r--r-- | clients/net-snk/oflib/of.c | 41 |
2 files changed, 45 insertions, 1 deletions
diff --git a/clients/net-snk/include/netdriver_int.h b/clients/net-snk/include/netdriver_int.h index 2f286ad..99aa358 100644 --- a/clients/net-snk/include/netdriver_int.h +++ b/clients/net-snk/include/netdriver_int.h @@ -102,6 +102,9 @@ typedef int (*k_ioctl_t) (int, int, void *); typedef void (*modules_remove_t) (int); typedef snk_module_t *(*modules_load_t) (int); +typedef long (*dma_map_in_t)(void *address, long size, int cachable); +typedef void (*dma_map_out_t)(void *address, long devaddr, long size); + typedef struct { int version; print_t print; @@ -129,6 +132,8 @@ typedef struct { k_ioctl_t k_ioctl; modules_remove_t modules_remove; modules_load_t modules_load; + dma_map_in_t dma_map_in; + dma_map_out_t dma_map_out; } snk_kernel_t; /* Entry of module */ diff --git a/clients/net-snk/oflib/of.c b/clients/net-snk/oflib/of.c index 0685127..31aa7f0 100644 --- a/clients/net-snk/oflib/of.c +++ b/clients/net-snk/oflib/of.c @@ -221,6 +221,12 @@ of_4_1(const char *serv, int arg0, int arg1, int arg2, int arg3) } int +of_test(const char *name) +{ + return (int) of_1_1("test", p32cast name); +} + +int of_interpret_1(void *s, void *ret) { return of_1_2("interpret", p32cast s, ret); @@ -373,6 +379,7 @@ bootmsg_error(short id, const char *str) (void) of_2_0("bootmsg-error", id, p32cast str); } +/* void bootmsg_debugcp(short id, const char *str, short lvl) { @@ -384,7 +391,7 @@ bootmsg_cp(short id) { (void) of_1_0("bootmsg-cp", id); } - +*/ static long of_fileio_read(snk_fileio_t *fileio, char *buf, long len) @@ -413,6 +420,34 @@ of_fileio_close(snk_fileio_t *fileio) return 0; } +static long +dma_map_in(void *address, long size, int cachable) +{ + unsigned int ret; + + /* Is dma-map-in available? */ + if (of_test("dma-map-in") != 0) { + /* No dma-map-in available ==> Assume we can use 1:1 addresses */ + return (long)address; + } + + ret = of_3_1("dma-map-in", p32cast address, (int)size, cachable); + + return ret; +} + +static void +dma_map_out(void *address, long devaddr, long size) +{ + /* Is dma-map-out available? */ + if (of_test("dma-map-out") != 0) { + /* No dma-map-out available */ + return; + } + + of_3_0("dma-map-out", p32cast address, (int)devaddr, (int)size); +} + #define CONFIG_SPACE 0 #define IO_SPACE 1 @@ -791,6 +826,7 @@ get_timebase(unsigned int *timebase) of_getprop(cpu, "timebase-frequency", timebase, 4); } + int glue_init(snk_kernel_t * snk_kernel_interface, unsigned int * timebase, size_t _client_start, size_t _client_size) @@ -834,6 +870,9 @@ glue_init(snk_kernel_t * snk_kernel_interface, unsigned int * timebase, snk_kernel_interface->translate_addr = translate_address; snk_kernel_interface->pci_config_read = rtas_pci_config_read; snk_kernel_interface->pci_config_write = rtas_pci_config_write; + snk_kernel_interface->dma_map_in = dma_map_in; + snk_kernel_interface->dma_map_out = dma_map_out; + claim_rc=(int)(long)of_claim(client_start, client_size, 0); return 0; |