blob: 67d89808d566bccb8c2afe3bd87e03cc83fbea39 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Common definitions for MikroTik RouterBoot data.
4 *
5 * Copyright (C) 2020 Thibaut VARĂˆNE <hacks+kernel@slashdirt.org>
6 */
7
8
9#ifndef _ROUTERBOOT_H_
10#define _ROUTERBOOT_H_
11
12#include <linux/types.h>
13
14// these magic values are stored in cpu-endianness on flash
15#define RB_MAGIC_HARD (('H') | ('a' << 8) | ('r' << 16) | ('d' << 24))
16#define RB_MAGIC_SOFT (('S') | ('o' << 8) | ('f' << 16) | ('t' << 24))
17#define RB_MAGIC_LZOR (('L') | ('Z' << 8) | ('O' << 16) | ('R' << 24))
18#define RB_MAGIC_ERD (('E' << 16) | ('R' << 8) | ('D'))
19
20#define RB_ART_SIZE 0x10000
21
22#define RB_MTD_HARD_CONFIG "hard_config"
23#define RB_MTD_SOFT_CONFIG "soft_config"
24
25int routerboot_tag_find(const u8 *bufhead, const size_t buflen, const u16 tag_id, u16 *pld_ofs, u16 *pld_len);
26int routerboot_rle_decode(const u8 *in, size_t inlen, u8 *out, size_t *outlen);
27
28int __init rb_hardconfig_init(struct kobject *rb_kobj);
29void __exit rb_hardconfig_exit(void);
30
31int __init rb_softconfig_init(struct kobject *rb_kobj);
32void __exit rb_softconfig_exit(void);
33
34ssize_t routerboot_tag_show_string(const u8 *pld, u16 pld_len, char *buf);
35ssize_t routerboot_tag_show_u32s(const u8 *pld, u16 pld_len, char *buf);
36
37#endif /* _ROUTERBOOT_H_ */