summaryrefslogtreecommitdiffstats
path: root/utils/hwstub/lib
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-09-08 11:12:54 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-09-08 11:12:54 +0200
commit847106cdb20a0297dc9a10f212f0e3c8e6f3d58c (patch)
treea7ed541f10c7469c6f30790140cc848e12fb119c /utils/hwstub/lib
parentd815c26e8fad1562e7c4d175bc4dec2567f0fe88 (diff)
downloadrockbox-847106cdb20a0297dc9a10f212f0e3c8e6f3d58c.tar.gz
rockbox-847106cdb20a0297dc9a10f212f0e3c8e6f3d58c.tar.bz2
rockbox-847106cdb20a0297dc9a10f212f0e3c8e6f3d58c.zip
hwstub: add support for jump/call in library
Change-Id: Ia57ca613609a5e89e41ff927d7fc137c6841046a
Diffstat (limited to 'utils/hwstub/lib')
-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);