2 * OpenBIOS - free your system!
3 * ( firmware/flash device driver for Linux )
5 * procfs.c - proc filesystem handling for flash device listing.
7 * This program is part of a free implementation of the IEEE 1275-1994
8 * Standard for Boot (Initialization Configuration) Firmware.
10 * Copyright (C) 1998-2004 Stefan Reinauer, <stepan@openbios.org>
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.
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.
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
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>
32 #include <linux/proc_fs.h>
37 #include "flashchips.h"
38 #include "programming.h"
40 struct proc_dir_entry *proc_bios;
42 #define PRINT_PROC(fmt,args...) \
46 len += sprintf( buffer+len, fmt, ##args ); \
47 if (begin + len > offset + size) \
49 else if (begin + len < offset) { \
56 * ******************************************
60 * ******************************************
63 #define CFLASH flashdevices[i]
64 #define FLASH flashchips[CFLASH.flashnum]
65 #define MANUF manufacturers[CFLASH.manufnum]
67 int bios_read_proc(char *buffer, char **start, off_t offset, int size, int *eof, void *data)
72 for (i=0;i<flashcount;i++) {
74 printk(KERN_DEBUG "BIOS: processing proc info for "
75 "flashchip %d\n",i+1);
77 if (i) /* empty line is seperator between flash chips */
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 : ");
90 /* Flash chip completely unknown -> output ID and proceed */
92 PRINT_PROC("unknown %s device (id 0x%04x)\n",
93 MANUF.name, CFLASH.id);
94 PRINT_PROC("Supported : no\n");
98 PRINT_PROC("%s %s (%dV)\n", MANUF.name,
99 FLASH.name, FLASH.voltage);
101 PRINT_PROC("Supported : %s\n",
102 FLASH.supported ? "yes": "no");
104 PRINT_PROC("Pagetable : %d Byte\n", FLASH.pagesize );
106 PRINT_PROC("Erase first : %s\n",
107 FLASH.flags & f_needs_erase ? "yes": "no");
109 PRINT_PROC("Intel compliant : %s\n",
110 FLASH.flags & f_intel_compl ? "yes": "no");
112 PRINT_PROC("FWH compliant : %s\n",
113 FLASH.flags & f_fwh_compl ? "yes": "no");
115 if (CFLASH.sectors > 1)
116 PRINT_PROC("Sectors : %d\n", CFLASH.sectors);
120 printk(KERN_DEBUG "BIOS: read_proc done.\n");
122 /* set to 1 if we're done */
125 if (offset >= begin + len)
128 *start = buffer + (begin - offset);
130 return (size < begin + len - offset ? size : begin + len - offset);
136 #ifdef PROC_WRITEABLE
137 int bios_write_proc(struct file *file, const char *buffer, unsigned long count, void *data)
139 printk (KERN_INFO "%s\n",buffer);
144 int bios_proc_register(void)
146 if ((proc_bios = create_proc_entry("bios", 0, 0))) {
147 proc_bios->read_proc = bios_read_proc;
149 proc_bios->write_proc = bios_write_proc;
156 int bios_proc_unregister(void)
159 remove_proc_entry("bios", 0);