diff options
Diffstat (limited to 'rbutil/jztool/src')
-rw-r--r-- | rbutil/jztool/src/x1000.c | 30 |
1 files changed, 23 insertions, 7 deletions
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 | ||