summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/hwstub/lib/hwstub.c35
-rw-r--r--utils/hwstub/lib/hwstub.h1
2 files changed, 16 insertions, 20 deletions
diff --git a/utils/hwstub/lib/hwstub.c b/utils/hwstub/lib/hwstub.c
index a2af2f26d4..6ae0400a66 100644
--- a/utils/hwstub/lib/hwstub.c
+++ b/utils/hwstub/lib/hwstub.c
@@ -207,30 +207,25 @@ int hwstub_rw_mem(struct hwstub_device_t *dev, int read, uint32_t addr, void *bu
return read ? hwstub_read(dev, addr, buf, sz) : hwstub_write(dev, addr, buf, sz);
}
+int hwstub_exec(struct hwstub_device_t *dev, uint32_t addr, uint16_t flags)
+{
+ struct hwstub_exec_req_t exec;
+ exec.dAddress = addr;
+ exec.bmFlags = flags;
+ int size = libusb_control_transfer(dev->handle,
+ LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE | LIBUSB_ENDPOINT_OUT,
+ HWSTUB_EXEC, dev->id, dev->intf, (void *)&exec, sizeof(exec), 1000);
+ if(size != (int)sizeof(exec))
+ return -1;
+ return 0;
+}
+
int hwstub_call(struct hwstub_device_t *dev, uint32_t addr)
{
-#if 0
- return libusb_control_transfer(dev->handle,
- LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_DEVICE |
- LIBUSB_ENDPOINT_OUT, HWSTUB_CALL, addr & 0xffff, addr >> 16, NULL, 0,
- 1000);
-#else
- (void) dev;
- (void) addr;
- return -1;
-#endif
+ return hwstub_exec(dev, addr, HWSTUB_EXEC_CALL);
}
int hwstub_jump(struct hwstub_device_t *dev, uint32_t addr)
{
-#if 0
- return libusb_control_transfer(dev->handle,
- LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_DEVICE |
- LIBUSB_ENDPOINT_OUT, HWSTUB_JUMP, addr & 0xffff, addr >> 16, NULL, 0,
- 1000);
-#else
- (void) dev;
- (void) addr;
- return -1;
-#endif
+ return hwstub_exec(dev, addr, HWSTUB_EXEC_JUMP);
}
diff --git a/utils/hwstub/lib/hwstub.h b/utils/hwstub/lib/hwstub.h
index 8fb98fe669..d7d6ceb8ef 100644
--- a/utils/hwstub/lib/hwstub.h
+++ b/utils/hwstub/lib/hwstub.h
@@ -56,6 +56,7 @@ int hwstub_read(struct hwstub_device_t *dev, uint32_t addr, void *buf, size_t sz
int hwstub_write(struct hwstub_device_t *dev, uint32_t addr, void *buf, size_t sz);
int hwstub_rw_mem(struct hwstub_device_t *dev, int read, uint32_t addr, void *buf, size_t sz);
/* Returns <0 on error */
+int hwstub_exec(struct hwstub_device_t *dev, uint32_t addr, uint16_t flags);
int hwstub_call(struct hwstub_device_t *dev, uint32_t addr);
int hwstub_jump(struct hwstub_device_t *dev, uint32_t addr);