excite_procfs.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/module.h>
  22. #include <linux/proc_fs.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/stat.h>
  25. #include <asm/page.h>
  26. #include <asm/io.h>
  27. #include <asm/system.h>
  28. #include <asm/rm9k-ocd.h>
  29. #include <excite.h>
  30. static int excite_unit_id_proc_show(struct seq_file *m, void *v)
  31. {
  32. seq_printf(m, "%06x", unit_id);
  33. return 0;
  34. }
  35. static int excite_unit_id_proc_open(struct inode *inode, struct file *file)
  36. {
  37. return single_open(file, excite_unit_id_proc_show, NULL);
  38. }
  39. static const struct file_operations excite_unit_id_proc_fops = {
  40. .owner = THIS_MODULE,
  41. .open = excite_unit_id_proc_open,
  42. .read = seq_read,
  43. .llseek = seq_lseek,
  44. .release = single_release,
  45. };
  46. static int
  47. excite_bootrom_read(char *page, char **start, off_t off, int count,
  48. int *eof, void *data)
  49. {
  50. void __iomem * src;
  51. if (off >= EXCITE_SIZE_BOOTROM) {
  52. *eof = 1;
  53. return 0;
  54. }
  55. if ((off + count) > EXCITE_SIZE_BOOTROM)
  56. count = EXCITE_SIZE_BOOTROM - off;
  57. src = ioremap(EXCITE_PHYS_BOOTROM + off, count);
  58. if (src) {
  59. memcpy_fromio(page, src, count);
  60. iounmap(src);
  61. *start = page;
  62. } else {
  63. count = -ENOMEM;
  64. }
  65. return count;
  66. }
  67. void excite_procfs_init(void)
  68. {
  69. /* Create & populate /proc/excite */
  70. struct proc_dir_entry * const pdir = proc_mkdir("excite", NULL);
  71. if (pdir) {
  72. struct proc_dir_entry * e;
  73. e = proc_create("unit_id", S_IRUGO, pdir,
  74. &excite_unit_id_proc_fops);
  75. if (e) e->size = 6;
  76. e = create_proc_read_entry("bootrom", S_IRUGO, pdir,
  77. excite_bootrom_read, NULL);
  78. if (e) e->size = EXCITE_SIZE_BOOTROM;
  79. }
  80. }