astlpc: abstract hardware interactions to allow a non-fileio-based implementation

Currently, the astlpc binding assumes a particular method of access to
the KCS and LPC interfaces, using reads and writes to a pair of Linux
devices.

We want to be able to use the astlpc binding in different environments,
possibly not backed by file IO. This change adds an interface to provide
custom operations to read and write the KCS and LPC state.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Change-Id: I3e403a025760657a7264098f5486f046e3ac436b
diff --git a/libmctp-astlpc.h b/libmctp-astlpc.h
index 4bffd93..81f3b1b 100644
--- a/libmctp-astlpc.h
+++ b/libmctp-astlpc.h
@@ -7,16 +7,36 @@
 extern "C" {
 #endif
 
+#include <unistd.h>
 #include <libmctp.h>
 
 struct mctp_binding_astlpc;
 
-struct mctp_binding_astlpc *mctp_astlpc_init(void);
-int mctp_astlpc_get_fd(struct mctp_binding_astlpc *astlpc);
+enum mctp_binding_astlpc_kcs_reg {
+	MCTP_ASTLPC_KCS_REG_DATA = 0,
+	MCTP_ASTLPC_KCS_REG_STATUS = 1,
+};
+
+struct mctp_binding_astlpc_ops {
+	int	(*kcs_read)(void *data, enum mctp_binding_astlpc_kcs_reg reg,
+			uint8_t *val);
+	int	(*kcs_write)(void *data, enum mctp_binding_astlpc_kcs_reg reg,
+			uint8_t val);
+	int	(*lpc_read)(void *data, void *buf, off_t offset, size_t len);
+	int	(*lpc_write)(void *data, void *buf, off_t offset, size_t len);
+};
+
+struct mctp_binding_astlpc *mctp_astlpc_init_ops(
+		struct mctp_binding_astlpc_ops *ops,
+		void *ops_data, void *lpc_map);
 void mctp_astlpc_register_bus(struct mctp_binding_astlpc *astlpc,
 		struct mctp *mctp, mctp_eid_t eid);
 int mctp_astlpc_poll(struct mctp_binding_astlpc *astlpc);
 
+/* fileio-based interface */
+struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void);
+int mctp_astlpc_get_fd(struct mctp_binding_astlpc *astlpc);
+
 #ifdef __cplusplus
 }
 #endif