diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-04-29 20:31:20 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-04-29 20:31:32 +0100 |
commit | 48b77898dce686f77b86adb977ba49400f5a3f7d (patch) | |
tree | 0255604d58a80d3869e9d6ae39102a1c25f84aee /rbutil | |
parent | 16a1993cadfb3da9df25d5436ebf355ed31cc5b1 (diff) | |
download | rockbox-48b77898dce686f77b86adb977ba49400f5a3f7d.tar.gz rockbox-48b77898dce686f77b86adb977ba49400f5a3f7d.zip |
jztool: portability fixes for Mac
Change-Id: Id01ee4ff0222ebcd56764c90c9a211792aa0f69f
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/jztool/Makefile | 4 | ||||
-rw-r--r-- | rbutil/jztool/src/x1000.c | 30 |
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) | |||
26 | # TODO: support Windows | 26 | # TODO: support Windows |
27 | else | 27 | else |
28 | ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE) | 28 | ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE) |
29 | # TODO: support OSX | 29 | # OSX -- /opt location is cheesy attempt to support ARM macs |
30 | CFLAGS += -I/usr/local/include -I/opt/homebrew/include | ||
31 | LDOPTS += -L/usr/local/lib -L/opt/homebrew/lib -lusb-1.0 | ||
30 | else | 32 | else |
31 | # Linux | 33 | # Linux |
32 | CFLAGS += `pkg-config --cflags libusb-1.0` | 34 | 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 @@ | |||
22 | #include "jztool_private.h" | 22 | #include "jztool_private.h" |
23 | #include "../../../firmware/target/mips/ingenic_x1000/spl-x1000-defs.h" | 23 | #include "../../../firmware/target/mips/ingenic_x1000/spl-x1000-defs.h" |
24 | #include "../../../firmware/target/mips/ingenic_x1000/nand-x1000-err.h" | 24 | #include "../../../firmware/target/mips/ingenic_x1000/nand-x1000-err.h" |
25 | #include <endian.h> // TODO: portability | ||
26 | #include <string.h> | 25 | #include <string.h> |
27 | 26 | ||
27 | static uint32_t to_le32(uint32_t x) | ||
28 | { | ||
29 | union { uint32_t u; uint8_t p[4]; } f; | ||
30 | f.p[0] = x & 0xff; | ||
31 | f.p[1] = (x >> 8) & 0xff; | ||
32 | f.p[2] = (x >> 16) & 0xff; | ||
33 | f.p[3] = (x >> 24) & 0xff; | ||
34 | return f.u; | ||
35 | } | ||
36 | |||
37 | static uint32_t from_le32(uint32_t x) | ||
38 | { | ||
39 | union { uint32_t u; uint8_t p[4]; } f; | ||
40 | f.u = x; | ||
41 | return f.p[0] | (f.p[1] << 8) | (f.p[2] << 16) | (f.p[3] << 24); | ||
42 | } | ||
43 | |||
28 | static const char* jz_x1000_nand_strerror(int rc) | 44 | static const char* jz_x1000_nand_strerror(int rc) |
29 | { | 45 | { |
30 | switch(rc) { | 46 | switch(rc) { |
@@ -54,10 +70,10 @@ static const char* jz_x1000_nand_strerror(int rc) | |||
54 | 70 | ||
55 | static int jz_x1000_send_args(jz_usbdev* dev, struct x1000_spl_arguments* args) | 71 | static int jz_x1000_send_args(jz_usbdev* dev, struct x1000_spl_arguments* args) |
56 | { | 72 | { |
57 | args->command = htole32(args->command); | 73 | args->command = to_le32(args->command); |
58 | args->param1 = htole32(args->param1); | 74 | args->param1 = to_le32(args->param1); |
59 | args->param2 = htole32(args->param2); | 75 | args->param2 = to_le32(args->param2); |
60 | args->flags = htole32(args->flags); | 76 | args->flags = to_le32(args->flags); |
61 | return jz_usb_send(dev, SPL_ARGUMENTS_ADDRESS, sizeof(*args), args); | 77 | return jz_usb_send(dev, SPL_ARGUMENTS_ADDRESS, sizeof(*args), args); |
62 | } | 78 | } |
63 | 79 | ||
@@ -67,8 +83,8 @@ static int jz_x1000_recv_status(jz_usbdev* dev, struct x1000_spl_status* status) | |||
67 | if(rc < 0) | 83 | if(rc < 0) |
68 | return rc; | 84 | return rc; |
69 | 85 | ||
70 | status->err_code = le32toh(status->err_code); | 86 | status->err_code = from_le32(status->err_code); |
71 | status->reserved = le32toh(status->reserved); | 87 | status->reserved = from_le32(status->reserved); |
72 | return JZ_SUCCESS; | 88 | return JZ_SUCCESS; |
73 | } | 89 | } |
74 | 90 | ||