1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
29#include <excite.h>
30
31static int excite_get_unit_id(char *buf, char **addr, off_t offs, int size)
32{
33 const int len = snprintf(buf, PAGE_SIZE, "%06x", unit_id);
34 const int w = len - offs;
35 *addr = buf + offs;
36 return w < size ? w : size;
37}
38
39static int
40excite_bootrom_read(char *page, char **start, off_t off, int count,
41 int *eof, void *data)
42{
43 void __iomem * src;
44
45 if (off >= EXCITE_SIZE_BOOTROM) {
46 *eof = 1;
47 return 0;
48 }
49
50 if ((off + count) > EXCITE_SIZE_BOOTROM)
51 count = EXCITE_SIZE_BOOTROM - off;
52
53 src = ioremap(EXCITE_PHYS_BOOTROM + off, count);
54 if (src) {
55 memcpy_fromio(page, src, count);
56 iounmap(src);
57 *start = page;
58 } else {
59 count = -ENOMEM;
60 }
61
62 return count;
63}
64
65void excite_procfs_init(void)
66{
67
68 struct proc_dir_entry * const pdir = proc_mkdir("excite", &proc_root);
69 if (pdir) {
70 struct proc_dir_entry * e;
71
72 e = create_proc_info_entry("unit_id", S_IRUGO, pdir,
73 excite_get_unit_id);
74 if (e) e->size = 6;
75
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}
81