#include <sys/queue.h>
#include "interface.h"
+#include "thor.h"
struct tfm_interface_context {
struct tfm_interface *connected;
return NULL;
}
+ fprintf(stdout, "interface %s is ready.\n", intf->name);
+
+ /*
+ * Each interface can handshake at the same time, but only one
+ * interface is used for flash to prevent data corruption.
+ */
+ ret = thor_handshake(intf);
+ if (ret < 0) {
+ fprintf(stderr, "failed to handshake: %s\n", intf->name);
+ intf->ops->disconnect(intf);
+ return NULL;
+ }
+
pthread_mutex_lock(&ictx->mutex);
if (ictx->connected) {
pthread_mutex_unlock(&ictx->mutex);
return ret;
}
-static int thor_handshake(struct tfm_interface *intf)
+int thor_handshake(struct tfm_interface *intf)
{
char buf[5];
ssize_t n;
return 0;
}
-
-int thor_setup(struct tfm_interface *intf)
-{
- if (!intf) {
- fprintf(stderr, "Invalid connection\n");
- return -EINVAL;
- }
-
- return thor_handshake(intf);
-}
#include "dfu.h"
#include "interface.h"
-int thor_setup(struct tfm_interface *intf);
+int thor_handshake(struct tfm_interface *intf);
int thor_process(struct tfm_interface *intf, struct dfu_context *dfu);
#endif