|
|
1.1 root 1: /*
2: * OpenBIOS - free your system!
3: * ( firmware/flash device driver for Linux )
4: *
5: * procfs.c - proc filesystem handling for flash device listing.
6: *
7: * This program is part of a free implementation of the IEEE 1275-1994
8: * Standard for Boot (Initialization Configuration) Firmware.
9: *
10: * Copyright (C) 1998-2004 Stefan Reinauer, <[email protected]>
11: *
12: * This program is free software; you can redistribute it and/or modify
13: * it under the terms of the GNU General Public License as published by
14: * the Free Software Foundation; version 2 of the License.
15: *
16: * This program is distributed in the hope that it will be useful,
17: * but WITHOUT ANY WARRANTY; without even the implied warranty of
18: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19: * GNU General Public License for more details.
20: *
21: * You should have received a copy of the GNU General Public License
22: * along with this program; if not, write to the Free Software
23: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
24: *
25: */
26:
27: #include <linux/config.h>
28: #include <linux/version.h>
29: #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) && defined(MODVERSIONS)
30: #include <linux/modversions.h>
31: #endif
32: #include <linux/proc_fs.h>
33:
34: #ifdef CONFIG_PROC_FS
35: #include "bios.h"
36: #include "pcisets.h"
37: #include "flashchips.h"
38: #include "programming.h"
39:
40: struct proc_dir_entry *proc_bios;
41:
42: #define PRINT_PROC(fmt,args...) \
43: do { \
44: if (!run) \
45: break; \
46: len += sprintf( buffer+len, fmt, ##args ); \
47: if (begin + len > offset + size) \
48: run=0; \
49: else if (begin + len < offset) { \
50: begin += len; \
51: len = 0; \
52: } \
53: } while (0)
54:
55: /*
56: * ******************************************
57: *
58: * /proc/bios handling
59: *
60: * ******************************************
61: */
62:
63: #define CFLASH flashdevices[i]
64: #define FLASH flashchips[CFLASH.flashnum]
65: #define MANUF manufacturers[CFLASH.manufnum]
66:
67: int bios_read_proc(char *buffer, char **start, off_t offset, int size, int *eof, void *data)
68: {
69: int len=0, run=1, i;
70: off_t begin = 0;
71:
72: for (i=0;i<flashcount;i++) {
73: #ifdef DEBUG_PROC
74: printk(KERN_DEBUG "BIOS: processing proc info for "
75: "flashchip %d\n",i+1);
76: #endif
77: if (i) /* empty line is seperator between flash chips */
78: PRINT_PROC("\n");
79:
80: PRINT_PROC("Memory Address : 0x%08lx\n",
81: (unsigned long)CFLASH.physical);
82: PRINT_PROC("Memory Size : %d kByte\n", CFLASH.size>>10);
83: PRINT_PROC("Flash Type : ");
84:
85: if (CFLASH.id == 0) {
86: PRINT_PROC("ROM\n");
87: continue;
88: }
89:
90: /* Flash chip completely unknown -> output ID and proceed */
91: if (FLASH.id == 0) {
92: PRINT_PROC("unknown %s device (id 0x%04x)\n",
93: MANUF.name, CFLASH.id);
94: PRINT_PROC("Supported : no\n");
95: continue;
96: }
97:
98: PRINT_PROC("%s %s (%dV)\n", MANUF.name,
99: FLASH.name, FLASH.voltage);
100:
101: PRINT_PROC("Supported : %s\n",
102: FLASH.supported ? "yes": "no");
103: #ifdef DEBUG
104: PRINT_PROC("Pagetable : %d Byte\n", FLASH.pagesize );
105:
106: PRINT_PROC("Erase first : %s\n",
107: FLASH.flags & f_needs_erase ? "yes": "no");
108:
109: PRINT_PROC("Intel compliant : %s\n",
110: FLASH.flags & f_intel_compl ? "yes": "no");
111:
112: PRINT_PROC("FWH compliant : %s\n",
113: FLASH.flags & f_fwh_compl ? "yes": "no");
114:
115: if (CFLASH.sectors > 1)
116: PRINT_PROC("Sectors : %d\n", CFLASH.sectors);
117: #endif
118: }
119: #ifdef DEBUG_PROC
120: printk(KERN_DEBUG "BIOS: read_proc done.\n");
121: #endif
122: /* set to 1 if we're done */
123: *eof=run;
124:
125: if (offset >= begin + len)
126: return 0;
127:
128: *start = buffer + (begin - offset);
129:
130: return (size < begin + len - offset ? size : begin + len - offset);
131: }
132: #undef FLASH
133: #undef MANUF
134: #undef CFLASH
135:
136: #ifdef PROC_WRITEABLE
137: int bios_write_proc(struct file *file, const char *buffer, unsigned long count, void *data)
138: {
139: printk (KERN_INFO "%s\n",buffer);
140: return count;
141: }
142: #endif
143:
144: int bios_proc_register(void)
145: {
146: if ((proc_bios = create_proc_entry("bios", 0, 0))) {
147: proc_bios->read_proc = bios_read_proc;
148: #ifdef PROC_WRITABLE
149: proc_bios->write_proc = bios_write_proc;
150: #endif
151: return 0;
152: }
153: return 1;
154: }
155:
156: int bios_proc_unregister(void)
157: {
158: if (proc_bios)
159: remove_proc_entry("bios", 0);
160: return 0;
161: }
162: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.