0004-MIPS-ralink-adds-a-bootrom-dumper-module.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From af03898c74172ab16d610f3eeaa65f66401eb7db 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 04/57] MIPS: ralink: adds a bootrom dumper module
  5. This patch adds a trivial driver that allows userland to extract the bootrom of
  6. a SoC via debugfs.
  7. Signed-off-by: John Crispin <blogic@openwrt.org>
  8. ---
  9. arch/mips/ralink/Makefile | 2 ++
  10. arch/mips/ralink/bootrom.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
  11. 2 files changed, 50 insertions(+)
  12. create mode 100644 arch/mips/ralink/bootrom.c
  13. --- a/arch/mips/ralink/Makefile
  14. +++ b/arch/mips/ralink/Makefile
  15. @@ -16,3 +16,5 @@ obj-$(CONFIG_SOC_RT3883) += rt3883.o
  16. obj-$(CONFIG_SOC_MT7620) += mt7620.o
  17. obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
  18. +
  19. +obj-$(CONFIG_DEBUG_FS) += bootrom.o
  20. --- /dev/null
  21. +++ b/arch/mips/ralink/bootrom.c
  22. @@ -0,0 +1,48 @@
  23. +/*
  24. + * This program is free software; you can redistribute it and/or modify it
  25. + * under the terms of the GNU General Public License version 2 as published
  26. + * by the Free Software Foundation.
  27. + *
  28. + * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
  29. + */
  30. +
  31. +#include <linux/debugfs.h>
  32. +#include <linux/seq_file.h>
  33. +
  34. +#define BOOTROM_OFFSET 0x10118000
  35. +#define BOOTROM_SIZE 0x8000
  36. +
  37. +static void __iomem *membase = (void __iomem*) KSEG1ADDR(BOOTROM_OFFSET);
  38. +
  39. +static int bootrom_show(struct seq_file *s, void *unused)
  40. +{
  41. + seq_write(s, membase, BOOTROM_SIZE);
  42. +
  43. + return 0;
  44. +}
  45. +
  46. +static int bootrom_open(struct inode *inode, struct file *file)
  47. +{
  48. + return single_open(file, bootrom_show, NULL);
  49. +}
  50. +
  51. +static const struct file_operations bootrom_file_ops = {
  52. + .open = bootrom_open,
  53. + .read = seq_read,
  54. + .llseek = seq_lseek,
  55. + .release = single_release,
  56. +};
  57. +
  58. +static int bootrom_setup(void)
  59. +{
  60. + if (!debugfs_create_file("bootrom", 0444,
  61. + NULL, NULL, &bootrom_file_ops)) {
  62. + pr_err("Failed to create bootrom debugfs file\n");
  63. +
  64. + return -EINVAL;
  65. + }
  66. +
  67. + return 0;
  68. +}
  69. +
  70. +postcore_initcall(bootrom_setup);