summaryrefslogtreecommitdiffstats
path: root/pci.h
diff options
context:
space:
mode:
Diffstat (limited to 'pci.h')
-rw-r--r--pci.h85
1 files changed, 20 insertions, 65 deletions
diff --git a/pci.h b/pci.h
index 306892f..74699cd 100644
--- a/pci.h
+++ b/pci.h
@@ -1,81 +1,36 @@
#ifndef _PCITOOL_PCI_H
#define _PCITOOL_PCI_H
-#define PCILIB_MAX_BANKS 6
-
-#include <stdint.h>
+#define PCILIB_REGISTER_TIMEOUT 10000 /**< us */
#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;
+#include "pcilib.h"
-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 pci_board_info *pcilib_get_board_info(pcilib_t *ctx);
- const char *description;
-} pcilib_register_t;
-
-typedef struct {
- uint32_t start;
- uint32_t end;
-} pcilib_register_range_t;
-
-#include "ipecamera.h"
+#ifdef _PCILIB_PCI_C
+# include "ipecamera.h"
+# include "default.h"
-typedef struct {
- pcilib_register_t *registers;
- pcilib_register_range_t *ranges;
-} pcilib_model_description_t;
+pcilib_model_description_t pcilib_model[3] = {
+ { NULL, NULL, NULL },
+ { NULL, NULL, NULL },
+ { ipecamera_registers, ipecamera_register_banks, ipecamera_register_ranges }
+};
-#ifdef _PCILIB_PCI_C
-pcilib_model_description_t pcilib_model_description[2] = {
- { NULL, NULL },
- { ipecamera_registers, ipecamera_register_range }
+pcilib_protocol_description_t pcilib_protocol[3] = {
+ { pcilib_default_read, pcilib_default_write },
+ { ipecamera_read, ipecamera_write },
+ { NULL, NULL }
};
#else
-extern pcilib_model_description_t pcilib_model_description[];
-#endif /* _PCILIB_PCI_C */
-
-
-int pcilib_open(const char *device);
-void pcilib_close(int handle);
+extern void (*pcilib_error)(const char *msg, ...);
+extern void (*pcilib_warning)(const char *msg, ...);
-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);
+extern pcilib_model_description_t pcilib_model[];
+extern pcilib_protocol_description_t pcilib_protocol[];
+#endif /* _PCILIB_PCI_C */
#endif /* _PCITOOL_PCI_H */