excite_procfs.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2004, 2005 by Basler Vision Technologies AG
  3. * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
  4. *
  5. * Procfs support for Basler eXcite
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/config.h>
  22. #include <linux/proc_fs.h>
  23. #include <linux/stat.h>
  24. #include <asm/page.h>
  25. #include <asm/io.h>
  26. #include <asm/system.h>
  27. #include <asm/rm9k-ocd.h>
  28. #include <excite.h>
  29. static int excite_get_unit_id(char *buf, char **addr, off_t offs, int size)
  30. {
  31. const int len = snprintf(buf, PAGE_SIZE, "%06x", unit_id);
  32. const int w = len - offs;
  33. *addr = buf + offs;
  34. return w < size ? w : size;
  35. }
  36. static int
  37. excite_bootrom_read(char *page, char **start, off_t off, int count,
  38. int *eof, void *data)
  39. {
  40. void __iomem * src;
  41. if (off >= EXCITE_SIZE_BOOTROM) {
  42. *eof = 1;
  43. return 0;
  44. }
  45. if ((off + count) > EXCITE_SIZE_BOOTROM)
  46. count = EXCITE_SIZE_BOOTROM - off;
  47. src = ioremap(EXCITE_PHYS_BOOTROM + off, count);
  48. if (src) {
  49. memcpy_fromio(page, src, count);
  50. iounmap(src);
  51. *start = page;
  52. } else {
  53. count = -ENOMEM;
  54. }
  55. return count;
  56. }
  57. void excite_procfs_init(void)
  58. {
  59. /* Create & populate /proc/excite */
  60. struct proc_dir_entry * const pdir = proc_mkdir("excite", &proc_root);
  61. if (pdir) {
  62. struct proc_dir_entry * e;
  63. e = create_proc_info_entry("unit_id", S_IRUGO, pdir,
  64. excite_get_unit_id);
  65. if (e) e->size = 6;
  66. e = create_proc_read_entry("bootrom", S_IRUGO, pdir,
  67. excite_bootrom_read, NULL);
  68. if (e) e->size = EXCITE_SIZE_BOOTROM;
  69. }
  70. }