-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtekfwtool.h
59 lines (48 loc) · 1.06 KB
/
tekfwtool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef __TEKFW_TOOL_H
#define __TEKFW_TOOL_H
#include <stdint.h>
#define TARGET_FIRMWARE_BASE 0x05010000
#ifndef BYTE_ORDER
#error Unknown endianness !
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
#define cpu_to_be16(_x) ((((uint16_t) (_x) & 0xff) << 8) | (((_x) >> 8) & 0xff))
#define be16_to_cpu cpu_to_be16
#define cpu_to_be32(_x) (cpu_to_be16(((_x) >> 16) & 0xffff) | \
(cpu_to_be16(((uint32_t) (_x) & 0xffff)) << 16))
#define be32_to_cpu cpu_to_be32
#else
#define cpu_to_be16
#define cpu_to_be32
#define be16_to_cpu
#define be32_to_cpu
#endif
#define MIN(_a, _b) ((_a) > (_b) ? (_b) : (_a))
struct cmd_hdr {
uint8_t cmd;
uint8_t csum;
uint16_t len;
};
struct memory_read_cmd {
struct cmd_hdr hdr;
uint32_t addr;
uint32_t len;
};
struct memory_write_cmd {
struct cmd_hdr hdr;
uint32_t addr;
uint32_t len;
uint8_t buf[1024];
};
struct branch_cmd {
struct cmd_hdr hdr;
uint32_t argc;
uint32_t unknown;
uint32_t function;
uint32_t arg0;
uint8_t buffer[512];
};
#define TARGET_FW_INIT 0
#define TARGET_FW_FLASH_ERASE 1
#define TARGET_FW_FLASH_PROGRAM 2
#endif