summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-04-29 20:31:20 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-04-29 20:31:32 +0100
commit48b77898dce686f77b86adb977ba49400f5a3f7d (patch)
tree0255604d58a80d3869e9d6ae39102a1c25f84aee
parent16a1993cadfb3da9df25d5436ebf355ed31cc5b1 (diff)
downloadrockbox-48b77898dc.tar.gz
rockbox-48b77898dc.tar.bz2
rockbox-48b77898dc.zip
jztool: portability fixes for Mac
Change-Id: Id01ee4ff0222ebcd56764c90c9a211792aa0f69f
-rw-r--r--rbutil/jztool/Makefile4
-rw-r--r--rbutil/jztool/src/x1000.c30
2 files changed, 26 insertions, 8 deletions
diff --git a/rbutil/jztool/Makefile b/rbutil/jztool/Makefile
index aa434adf1f..6ab990d9d8 100644
--- a/rbutil/jztool/Makefile
+++ b/rbutil/jztool/Makefile
@@ -26,7 +26,9 @@ ifeq ($(findstring WIN32,$(CPPDEFINES)),WIN32)
# TODO: support Windows
else
ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE)
-# TODO: support OSX
+# OSX -- /opt location is cheesy attempt to support ARM macs
+CFLAGS += -I/usr/local/include -I/opt/homebrew/include
+LDOPTS += -L/usr/local/lib -L/opt/homebrew/lib -lusb-1.0
else
# Linux
CFLAGS += `pkg-config --cflags libusb-1.0`
diff --git a/rbutil/jztool/src/x1000.c b/rbutil/jztool/src/x1000.c
index 049344e5e6..1a12340316 100644
--- a/rbutil/jztool/src/x1000.c
+++ b/rbutil/jztool/src/x1000.c
@@ -22,9 +22,25 @@
#include "jztool_private.h"
#include "../../../firmware/target/mips/ingenic_x1000/spl-x1000-defs.h"
#include "../../../firmware/target/mips/ingenic_x1000/nand-x1000-err.h"
-#include <endian.h> // TODO: portability
#include <string.h>
+static uint32_t to_le32(uint32_t x)
+{
+ union { uint32_t u; uint8_t p[4]; } f;
+ f.p[0] = x & 0xff;
+ f.p[1] = (x >> 8) & 0xff;
+ f.p[2] = (x >> 16) & 0xff;
+ f.p[3] = (x >> 24) & 0xff;
+ return f.u;
+}
+
+static uint32_t from_le32(uint32_t x)
+{
+ union { uint32_t u; uint8_t p[4]; } f;
+ f.u = x;
+ return f.p[0] | (f.p[1] << 8) | (f.p[2] << 16) | (f.p[3] << 24);
+}
+
static const char* jz_x1000_nand_strerror(int rc)
{
switch(rc) {
@@ -54,10 +70,10 @@ static const char* jz_x1000_nand_strerror(int rc)
static int jz_x1000_send_args(jz_usbdev* dev, struct x1000_spl_arguments* args)
{
- args->command = htole32(args->command);
- args->param1 = htole32(args->param1);
- args->param2 = htole32(args->param2);
- args->flags = htole32(args->flags);
+ args->command = to_le32(args->command);
+ args->param1 = to_le32(args->param1);
+ args->param2 = to_le32(args->param2);
+ args->flags = to_le32(args->flags);
return jz_usb_send(dev, SPL_ARGUMENTS_ADDRESS, sizeof(*args), args);
}
@@ -67,8 +83,8 @@ static int jz_x1000_recv_status(jz_usbdev* dev, struct x1000_spl_status* status)
if(rc < 0)
return rc;
- status->err_code = le32toh(status->err_code);
- status->reserved = le32toh(status->reserved);
+ status->err_code = from_le32(status->err_code);
+ status->reserved = from_le32(status->reserved);
return JZ_SUCCESS;
}