summaryrefslogtreecommitdiffstats
path: root/pcilib
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-06-19 17:51:56 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-06-19 17:51:56 +0200
commit954583ac2ee8ec522a0283e6e3b249345c71a3e7 (patch)
treecdcef21dc7635ae04f17f4d48355583015267692 /pcilib
parent36385f1e83c7f6dd45954033b91d1871e62005c4 (diff)
parent907559d880de032deb31aa5e648c11029bbf9cce (diff)
downloadpcitool-954583ac2ee8ec522a0283e6e3b249345c71a3e7.tar.gz
pcitool-954583ac2ee8ec522a0283e6e3b249345c71a3e7.tar.bz2
pcitool-954583ac2ee8ec522a0283e6e3b249345c71a3e7.tar.xz
pcitool-954583ac2ee8ec522a0283e6e3b249345c71a3e7.zip
Integration of software registers
Diffstat (limited to 'pcilib')
-rw-r--r--pcilib/bank.c2
-rw-r--r--pcilib/bank.h5
-rw-r--r--pcilib/bar.c3
-rw-r--r--pcilib/export.c3
-rw-r--r--pcilib/kmem.h3
-rw-r--r--pcilib/pcilib.h1
6 files changed, 13 insertions, 4 deletions
diff --git a/pcilib/bank.c b/pcilib/bank.c
index dbbb427..3d53db2 100644
--- a/pcilib/bank.c
+++ b/pcilib/bank.c
@@ -65,7 +65,7 @@ void pcilib_free_register_banks(pcilib_t *ctx) {
if (ctx->bank_ctx[i]) {
if (bapi->free)
- bapi->free(ctx->bank_ctx[i]);
+ bapi->free(ctx, ctx->bank_ctx[i]);
else
free(ctx->bank_ctx[i]);
diff --git a/pcilib/bank.h b/pcilib/bank.h
index 943c389..8b461af 100644
--- a/pcilib/bank.h
+++ b/pcilib/bank.h
@@ -9,10 +9,12 @@
#define PCILIB_REGISTER_BANK2 2
#define PCILIB_REGISTER_BANK3 3
#define PCILIB_REGISTER_BANK_DMA 64 /**< First BANK address to be used by DMA engines */
+#define PCILIB_REGISTER_BANK_DMACONF 65 /**< DMA configuration in the software registers */
#define PCILIB_REGISTER_BANK_DYNAMIC 128 /**< First BANK address to map dynamic XML configuration */
#define PCILIB_REGISTER_PROTOCOL_INVALID ((pcilib_register_protocol_t)-1)
#define PCILIB_REGISTER_PROTOCOL0 0 /**< First PROTOCOL address to be used in the event engine */
#define PCILIB_REGISTER_PROTOCOL_DEFAULT 64 /**< Default memmap based protocol */
+#define PCILIB_REGISTER_PROTOCOL_SOFTWARE 65 /**< Software registers */
#define PCILIB_REGISTER_PROTOCOL_DMA 96 /**< First PROTOCOL address to be used by DMA engines */
#define PCILIB_REGISTER_PROTOCOL_DYNAMIC 128 /**< First PROTOCOL address to be used by plugins */
@@ -28,7 +30,7 @@ typedef struct {
pcilib_version_t version;
pcilib_register_bank_context_t *(*init)(pcilib_t *ctx, pcilib_register_bank_t bank, const char *model, const void *args); /**< Optional API call to initialize bank context */
- void (*free)(pcilib_register_bank_context_t *ctx); /**< Optional API call to cleanup bank context */
+ void (*free)(pcilib_t *pcilib, pcilib_register_bank_context_t *ctx); /**< Optional API call to cleanup bank context */
int (*read)(pcilib_t *pcilib, pcilib_register_bank_context_t *ctx, pcilib_register_addr_t addr, pcilib_register_value_t *value); /**< Read from register, mandatory for RO/RW registers */
int (*write)(pcilib_t *pcilib, pcilib_register_bank_context_t *ctx, pcilib_register_addr_t addr, pcilib_register_value_t value); /**< Write to register, mandatory for WO/RW registers */
} pcilib_register_protocol_api_description_t;
@@ -84,7 +86,6 @@ struct pcilib_register_bank_context_s {
const pcilib_register_protocol_api_description_t *api; /**< API functions */
};
-
// we don't copy strings, they should be statically allocated
int pcilib_init_register_banks(pcilib_t *ctx);
void pcilib_free_register_banks(pcilib_t *ctx);
diff --git a/pcilib/bar.c b/pcilib/bar.c
index a2670c0..ce04f6d 100644
--- a/pcilib/bar.c
+++ b/pcilib/bar.c
@@ -131,6 +131,9 @@ int pcilib_map_register_space(pcilib_t *ctx) {
// uint32_t buf[2];
void *reg_space;
pcilib_bar_t bar = banks[i].bar;
+
+ if (bar == PCILIB_BAR_NOBAR)
+ continue;
if (bar == PCILIB_BAR_DETECT) {
uintptr_t addr = banks[0].read_addr;
diff --git a/pcilib/export.c b/pcilib/export.c
index e442fc7..7b78e32 100644
--- a/pcilib/export.c
+++ b/pcilib/export.c
@@ -5,10 +5,11 @@
#include "export.h"
#include "protocols/default.h"
-
+#include "protocols/software.h"
const pcilib_register_protocol_description_t pcilib_protocols[] = {
{ PCILIB_REGISTER_PROTOCOL_DEFAULT, &pcilib_default_protocol_api, NULL, NULL, "default", "" },
+ { PCILIB_REGISTER_PROTOCOL_SOFTWARE, &pcilib_register_software_protocol_api, NULL, NULL, "software_registers", "" },
{ 0 }
};
diff --git a/pcilib/kmem.h b/pcilib/kmem.h
index 8302b6a..ae690fe 100644
--- a/pcilib/kmem.h
+++ b/pcilib/kmem.h
@@ -4,6 +4,8 @@
typedef struct pcilib_s pcilib_t;
typedef struct pcilib_kmem_list_s pcilib_kmem_list_t;
+#define PCILIB_KMEM_PAGE_SIZE 0x1000
+
typedef enum {
PCILIB_TRISTATE_NO = 0,
PCILIB_TRISTATE_PARTIAL = 1,
@@ -27,6 +29,7 @@ typedef enum {
PCILIB_KMEM_USE_STANDARD = 0,
PCILIB_KMEM_USE_DMA_RING = 1,
PCILIB_KMEM_USE_DMA_PAGES = 2,
+ PCILIB_KMEM_USE_SOFTWARE_REGISTERS = 3,
PCILIB_KMEM_USE_USER = 0x10
} pcilib_kmem_use_t;
diff --git a/pcilib/pcilib.h b/pcilib/pcilib.h
index 6d241c6..9710642 100644
--- a/pcilib/pcilib.h
+++ b/pcilib/pcilib.h
@@ -85,6 +85,7 @@ typedef struct {
#define PCILIB_BAR_DETECT ((pcilib_bar_t)-1)
#define PCILIB_BAR_INVALID ((pcilib_bar_t)-1)
+#define PCILIB_BAR_NOBAR ((pcilib_bar_t)-2)
#define PCILIB_BAR0 0
#define PCILIB_BAR1 1
#define PCILIB_DMA_ENGINE_INVALID ((pcilib_dma_engine_t)-1)