summaryrefslogtreecommitdiffstats
path: root/pci.h
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-02-18 23:51:35 +0100
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-02-18 23:51:35 +0100
commitc428e3496a3c5f8046a7f1778b5bdcb551993e7b (patch)
tree03d56325bc6926f4842bd776cbe45c9e56357fdd /pci.h
parentf08ec5dd017eecb20b69e664d9b80184969d08d9 (diff)
downloadipecamera-c428e3496a3c5f8046a7f1778b5bdcb551993e7b.tar.gz
ipecamera-c428e3496a3c5f8046a7f1778b5bdcb551993e7b.tar.bz2
ipecamera-c428e3496a3c5f8046a7f1778b5bdcb551993e7b.tar.xz
ipecamera-c428e3496a3c5f8046a7f1778b5bdcb551993e7b.zip
Initial support for registers, infrastructure only
Diffstat (limited to 'pci.h')
-rw-r--r--pci.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/pci.h b/pci.h
new file mode 100644
index 0000000..306892f
--- /dev/null
+++ b/pci.h
@@ -0,0 +1,81 @@
+#ifndef _PCITOOL_PCI_H
+#define _PCITOOL_PCI_H
+
+#define PCILIB_MAX_BANKS 6
+
+#include <stdint.h>
+
+#include "driver/pciDriver.h"
+#include "kernel.h"
+
+#define pcilib_memcpy memcpy32
+
+typedef enum {
+ PCILIB_MODEL_PCI,
+ PCILIB_MODEL_IPECAMERA
+} pcilib_model_t;
+
+
+typedef enum {
+ PCILIB_REGISTER_R = 1,
+ PCILIB_REGISTER_W = 2,
+ PCILIB_REGISTER_RW = 3
+} pcilib_register_mode_t;
+
+typedef enum {
+ IPECAMERA_REGISTER_PROTOCOL
+} pcilib_register_protocol_t;
+
+typedef struct {
+ uint8_t id;
+ uint8_t size;
+ uint32_t defvalue;
+ pcilib_register_mode_t mode;
+
+ const char *name;
+
+ pcilib_register_protocol_t protocol;
+ uint64_t read_addr;
+ uint64_t write_addr;
+
+ const char *description;
+} pcilib_register_t;
+
+typedef struct {
+ uint32_t start;
+ uint32_t end;
+} pcilib_register_range_t;
+
+#include "ipecamera.h"
+
+typedef struct {
+ pcilib_register_t *registers;
+ pcilib_register_range_t *ranges;
+} pcilib_model_description_t;
+
+#ifdef _PCILIB_PCI_C
+pcilib_model_description_t pcilib_model_description[2] = {
+ { NULL, NULL },
+ { ipecamera_registers, ipecamera_register_range }
+};
+#else
+extern pcilib_model_description_t pcilib_model_description[];
+#endif /* _PCILIB_PCI_C */
+
+
+int pcilib_open(const char *device);
+void pcilib_close(int handle);
+
+int pcilib_set_error_handler(void (*err)(const char *msg, ...));
+
+const pci_board_info *pcilib_get_board_info(int handle);
+pcilib_model_t pcilib_detect_model(int handle);
+void *pcilib_map_bar(int handle, int bar);
+void pcilib_unmap_bar(int handle, int bar, void *data);
+
+int pcilib_read(void *buf, int handle, int bar, unsigned long addr, int size);
+int pcilib_write(void *buf, int handle, int bar, unsigned long addr, int size);
+
+int pcilib_find_register(pcilib_model_t model, const char *reg);
+
+#endif /* _PCITOOL_PCI_H */