1 From 71409a190a0c8e3597cae7d46321742e29d8994b Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 21 May 2013 15:50:31 +0200
4 Subject: [PATCH 07/33] MIPS: ralink: adds a bootrom dumper module
6 This patch adds a trivial driver that allows userland to extract the bootrom of
9 Signed-off-by: John Crispin <blogic@openwrt.org>
11 arch/mips/ralink/Makefile | 2 ++
12 arch/mips/ralink/bootrom.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
13 2 files changed, 50 insertions(+)
14 create mode 100644 arch/mips/ralink/bootrom.c
16 --- a/arch/mips/ralink/Makefile
17 +++ b/arch/mips/ralink/Makefile
18 @@ -15,4 +15,6 @@ obj-$(CONFIG_SOC_MT7620) += mt7620.o
20 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
22 +obj-$(CONFIG_DEBUG_FS) += bootrom.o
26 +++ b/arch/mips/ralink/bootrom.c
29 + * This program is free software; you can redistribute it and/or modify it
30 + * under the terms of the GNU General Public License version 2 as published
31 + * by the Free Software Foundation.
33 + * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
36 +#include <linux/debugfs.h>
37 +#include <linux/seq_file.h>
39 +#define BOOTROM_OFFSET 0x10118000
40 +#define BOOTROM_SIZE 0x8000
42 +static void __iomem *membase = (void __iomem*) KSEG1ADDR(BOOTROM_OFFSET);
44 +static int bootrom_show(struct seq_file *s, void *unused)
46 + seq_write(s, membase, BOOTROM_SIZE);
51 +static int bootrom_open(struct inode *inode, struct file *file)
53 + return single_open(file, bootrom_show, NULL);
56 +static const struct file_operations bootrom_file_ops = {
57 + .open = bootrom_open,
59 + .llseek = seq_lseek,
60 + .release = single_release,
63 +static int bootrom_setup(void)
65 + if (!debugfs_create_file("bootrom", 0444,
66 + NULL, NULL, &bootrom_file_ops)) {
67 + pr_err("Failed to create bootrom debugfs file\n");
75 +postcore_initcall(bootrom_setup);