OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * mkdlinkfw |
||
3 | * |
||
4 | * Copyright (C) 2018 Paweł Dembicki <paweldembicki@gmail.com> |
||
5 | * |
||
6 | * This tool is based on mktplinkfw. |
||
7 | * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org> |
||
8 | * Copyright (C) 2008,2009 Wang Jian <lark@linux.net.cn> |
||
9 | * |
||
10 | * This program is free software; you can redistribute it and/or modify it |
||
11 | * under the terms of the GNU General Public License as published by the Free |
||
12 | * Software Foundation; either version 2 of the License, or (at your option) |
||
13 | * any later version. |
||
14 | */ |
||
15 | |||
16 | #ifndef mkdlinkfw_lib_h |
||
17 | #define mkdlinkfw_lib_h |
||
18 | |||
19 | #define AUH_MAGIC "DLK" |
||
20 | #define AUH_SIZE 80 |
||
21 | #define AUH_LVPS 0x01 |
||
22 | #define AUH_HDR_ID 0x4842 |
||
23 | #define AUH_HDR_VER 0x02 |
||
24 | #define AUH_SEC_ID 0x04 |
||
25 | #define AUH_INFO_TYPE 0x04 |
||
26 | |||
27 | #define STAG_SIZE 16 |
||
28 | #define STAG_ID 0x04 |
||
29 | #define STAG_MAGIC 0x2B24 |
||
30 | #define STAG_CMARK_FACTORY 0xFF |
||
31 | |||
32 | #define SCH2_SIZE 40 |
||
33 | #define SCH2_MAGIC 0x2124 |
||
34 | #define SCH2_VER 0x02 |
||
35 | |||
36 | /* |
||
37 | * compression type values in the header |
||
38 | * so far onlysupport for LZMA is added |
||
39 | */ |
||
40 | #define FLAT 0 |
||
41 | #define JZ 1 |
||
42 | #define GZIP 2 |
||
43 | #define LZMA 3 |
||
44 | |||
45 | #define RAM_ENTRY_ADDR 0x80000000 |
||
46 | #define RAM_LOAD_ADDR 0x80000000 |
||
47 | #define JBOOT_SIZE 0x10000 |
||
48 | |||
49 | #define ALL_HEADERS_SIZE (AUH_SIZE + STAG_SIZE + SCH2_SIZE) |
||
50 | #define MAX_HEADER_COUNTER 10 |
||
51 | #define TIMESTAMP_MAGIC 0x35016f00L |
||
52 | |||
53 | #define FACTORY 0 |
||
54 | #define SYSUPGRADE 1 |
||
55 | |||
56 | #define ERR(fmt, ...) do { \ |
||
57 | fflush(0); \ |
||
58 | fprintf(stderr, "[%s] *** error: " fmt "\n", \ |
||
59 | progname, ## __VA_ARGS__); \ |
||
60 | } while (0) |
||
61 | |||
62 | #define ERRS(fmt, ...) do { \ |
||
63 | int save = errno; \ |
||
64 | fflush(0); \ |
||
65 | fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \ |
||
66 | progname, ## __VA_ARGS__, strerror(save)); \ |
||
67 | } while (0) |
||
68 | |||
69 | #define DBG(fmt, ...) do { \ |
||
70 | fprintf(stderr, "[%s] " fmt "\n", progname, ## __VA_ARGS__); \ |
||
71 | } while (0) |
||
72 | |||
73 | struct file_info { |
||
74 | char *file_name; /* name of the file */ |
||
75 | uint32_t file_size; /* length of the file */ |
||
76 | }; |
||
77 | |||
78 | uint32_t jboot_timestamp(void); |
||
79 | uint16_t jboot_checksum(uint16_t start_val, uint16_t *data, int size); |
||
80 | int get_file_stat(struct file_info *fdata); |
||
81 | int read_to_buf(const struct file_info *fdata, char *buf); |
||
82 | int write_fw(const char *ofname, const char *data, int len); |
||
83 | |||
84 | #endif /* mkdlinkfw_lib_h */ |