aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/platform/mikrotik/routerboot.h
diff options
context:
space:
mode:
authorThibaut VARÈNE <hacks@slashdirt.org>2020-03-22 21:46:42 +0100
committerKoen Vandeputte <koen.vandeputte@ncentric.com>2020-05-08 15:17:17 +0200
commit5ecf7d96540ffa7c7446fa75adfa9e118f211c16 (patch)
treea8253300f346580bb9a92269c870bc7cc627ce7f /target/linux/generic/files/drivers/platform/mikrotik/routerboot.h
parent21869e8f80c0af3977bb5bffece6986a556cb389 (diff)
downloadupstream-5ecf7d96540ffa7c7446fa75adfa9e118f211c16.tar.gz
upstream-5ecf7d96540ffa7c7446fa75adfa9e118f211c16.tar.bz2
upstream-5ecf7d96540ffa7c7446fa75adfa9e118f211c16.zip
generic: routerboot sysfs platform driver
This driver exposes the data encoded in the "hard_config" flash segment of MikroTik RouterBOARDs devices. It presents the data in a sysfs folder named "hard_config". The WLAN calibration data is available on demand via the 'wlan_data' sysfs file in that folder. This driver permanently allocates a chunk of RAM as large as the "hard_config" MTD partition (typically 4KB), although it is technically possible to operate entirely from the MTD device without using a local buffer (except when requesting WLAN calibration data), at the cost of a performance penalty. This driver does not reuse any of the existing code previously found in routerboot.c. This driver has been successfully tested on BE (ath79) and LE (ipq40xx and ramips) hardware. Tested-by: Roger Pueyo Centelles <roger.pueyo@guifi.net> Tested-by: Baptiste Jonglez <git@bitsofnetworks.org> Tested-by: Tobias Schramm <t.schramm@manjaro.org> Tested-by: Christopher Hill <ch6574@gmail.com> Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
Diffstat (limited to 'target/linux/generic/files/drivers/platform/mikrotik/routerboot.h')
-rw-r--r--target/linux/generic/files/drivers/platform/mikrotik/routerboot.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.h b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.h
new file mode 100644
index 0000000000..d2ca41fb1b
--- /dev/null
+++ b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.h
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Common definitions for MikroTik RouterBoot data.
+ *
+ * Copyright (C) 2020 Thibaut VARÈNE <hacks+kernel@slashdirt.org>
+ */
+
+
+#ifndef _ROUTERBOOT_H_
+#define _ROUTERBOOT_H_
+
+#include <linux/types.h>
+
+// these magic values are stored in cpu-endianness on flash
+#define RB_MAGIC_HARD (('H') | ('a' << 8) | ('r' << 16) | ('d' << 24))
+#define RB_MAGIC_SOFT (('S') | ('o' << 8) | ('f' << 16) | ('t' << 24))
+#define RB_MAGIC_LZOR (('L') | ('Z' << 8) | ('O' << 16) | ('R' << 24))
+#define RB_MAGIC_ERD (('E' << 16) | ('R' << 8) | ('D'))
+
+#define RB_ART_SIZE 0x10000
+
+#define RB_MTD_HARD_CONFIG "hard_config"
+#define RB_MTD_SOFT_CONFIG "soft_config"
+
+int routerboot_tag_find(const u8 *bufhead, const size_t buflen, const u16 tag_id, u16 *pld_ofs, u16 *pld_len);
+int routerboot_rle_decode(const u8 *in, size_t inlen, u8 *out, size_t *outlen);
+
+int __init rb_hardconfig_init(struct kobject *rb_kobj);
+void __exit rb_hardconfig_exit(void);
+
+#endif /* _ROUTERBOOT_H_ */