2 * OpenBIOS - free your system!
3 * ( firmware/flash device driver for Linux )
5 * bios_core.c - core skeleton
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)
32 #include <linux/modversions.h>
35 #include <linux/module.h>
37 #include <linux/pci.h>
38 #include <linux/errno.h>
39 #include <linux/vmalloc.h>
40 #include <linux/init.h>
46 #include "flashchips.h"
47 #include "programming.h"
49 extern struct file_operations bios_fops;
50 int bios_proc_register(void);
51 int bios_proc_unregister(void);
55 spinlock_t bios_lock = SPIN_LOCK_UNLOCKED;
58 * ******************************************
62 * ******************************************
65 static void free_iomaps(void)
67 unsigned long lastmapped=0;
70 /* We remember the last mapped area to be sure that we only iounmap
71 * every mapped area once. If two flash devices are in the same
72 * area but do not occur sequentially during probing you have a
73 * seriously strange hardware
75 for (i=0; i<flashcount; i++) {
76 if (lastmapped==flashdevices[i].mapped)
78 iounmap((void *)flashdevices[i].mapped);
79 lastmapped=flashdevices[i].mapped;
84 * ******************************************
88 * ******************************************
91 void probe_system(void)
96 /* This function checks all flash media attached to
97 * PCI devices in the system. This means NON-PCI systems
98 * don't work. This causes machine checks on my LX164 test
99 * machine, so leave it away until it's fixed. This is
100 * needed for Ruffians, so we check the machine type
101 * in probe_alphafw() and call probe_pcibus from there.
102 * This could use some cleanup
109 static __init int bios_init(void)
111 printk(KERN_INFO "BIOS driver v" BIOS_VERSION " (writing %s) for "
112 UTS_RELEASE "\n", write?"enabled":"disabled");
114 #if !defined(UTC_BIOS) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
115 if (!pci_present()) {
116 printk(KERN_WARNING "BIOS: No PCI system.");
121 /* Probe for flash devices */
125 printk(KERN_WARNING "BIOS: No flash devices found.\n");
129 if (register_chrdev(BIOS_MAJOR, "bios", &bios_fops) == -EBUSY) {
130 printk(KERN_WARNING "BIOS: Could not register bios device.\n");
135 #ifdef CONFIG_PROC_FS
136 bios_proc_register();
142 * ******************************************
146 * ******************************************
150 MODULE_PARM(write,"i");
151 MODULE_AUTHOR("Stefan Reinauer <stepan@openbios.org>");
152 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,10)
153 MODULE_LICENSE("GPL");
156 static __exit void cleanup_bios_module (void)
158 #ifdef CONFIG_PROC_FS
159 bios_proc_unregister();
163 unregister_chrdev(BIOS_MAJOR, "bios");
164 printk(KERN_INFO "BIOS driver removed.\n");
167 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
168 int init_module(void)
173 void cleanup_module(void)
175 cleanup_bios_module();
179 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,74)
180 module_init(bios_init);
181 module_exit(cleanup_bios_module);
186 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
193 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)