^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * /proc/bus/pnp interface for Plug and Play devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Written by David Hinds, dahinds@users.sourceforge.net
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Modified by Thomas Hood
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * The .../devices and .../<node> and .../boot/<node> files are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * utilized by the lspnp and setpnp utilities, supplied with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * pcmcia-cs package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * http://pcmcia-cs.sourceforge.net
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * The .../escd file is utilized by the lsescd utility written by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Gunther Mayer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * The .../legacy_device_resources file is not used yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * The other files are human-readable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/pnp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include "pnpbios.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static struct proc_dir_entry *proc_pnp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static struct proc_dir_entry *proc_pnp_boot = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static int pnpconfig_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct pnp_isa_config_struc pnps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (pnp_bios_isapnp_config(&pnps))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) seq_printf(m, "structure_revision %d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) "number_of_CSNs %d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) "ISA_read_data_port 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) pnps.revision, pnps.no_csns, pnps.isa_rd_data_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static int escd_info_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct escd_info_struc escd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) if (pnp_bios_escd_info(&escd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) seq_printf(m, "min_ESCD_write_size %d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) "ESCD_size %d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) "NVRAM_base 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) escd.min_escd_write_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) escd.escd_size, escd.nv_storage_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define MAX_SANE_ESCD_SIZE (32*1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static int escd_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct escd_info_struc escd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) char *tmpbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int escd_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (pnp_bios_escd_info(&escd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) if (escd.escd_size > MAX_SANE_ESCD_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) "PnPBIOS: %s: ESCD size reported by BIOS escd_info call is too great\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) return -EFBIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if (!tmpbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) kfree(tmpbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) escd_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) (unsigned char)(tmpbuf[0]) + (unsigned char)(tmpbuf[1]) * 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) /* sanity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (escd_size > MAX_SANE_ESCD_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) printk(KERN_ERR "PnPBIOS: %s: ESCD size reported by"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) " BIOS read_escd call is too great\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) kfree(tmpbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return -EFBIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) seq_write(m, tmpbuf, escd_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) kfree(tmpbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static int pnp_legacyres_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) void *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) buf = kmalloc(65536, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (pnp_bios_get_stat_res(buf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) seq_write(m, buf, 65536);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static int pnp_devices_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct pnp_bios_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) u8 nodenum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) node = kzalloc(node_info.max_node_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (!node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) for (nodenum = 0; nodenum < 0xff;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) u8 thisnodenum = nodenum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (pnp_bios_get_dev_node(&nodenum, PNPMODE_DYNAMIC, node))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) seq_printf(m, "%02x\t%08x\t%3phC\t%04x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) node->handle, node->eisa_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) node->type_code, node->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (nodenum <= thisnodenum) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) printk(KERN_ERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) "PnPBIOS: proc_read_devices:",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) (unsigned int)nodenum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) (unsigned int)thisnodenum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) kfree(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static int pnpbios_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) void *data = m->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct pnp_bios_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) int boot = (long)data >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) u8 nodenum = (long)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) node = kzalloc(node_info.max_node_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (!node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) kfree(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) len = node->size - sizeof(struct pnp_bios_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) seq_write(m, node->data, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) kfree(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) static int pnpbios_proc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) return single_open(file, pnpbios_proc_show, PDE_DATA(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) size_t count, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) void *data = PDE_DATA(file_inode(file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) struct pnp_bios_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int boot = (long)data >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) u8 nodenum = (long)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) int ret = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) node = kzalloc(node_info.max_node_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) if (!node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (count != node->size - sizeof(struct pnp_bios_node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (copy_from_user(node->data, buf, count)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ret = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (pnp_bios_set_dev_node(node->handle, boot, node) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) ret = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) kfree(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static const struct proc_ops pnpbios_proc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) .proc_open = pnpbios_proc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) .proc_read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) .proc_lseek = seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) .proc_release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) .proc_write = pnpbios_proc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) int pnpbios_interface_attach_device(struct pnp_bios_node *node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) char name[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) sprintf(name, "%02x", node->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) if (!proc_pnp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (!pnpbios_dont_use_current_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) proc_create_data(name, 0644, proc_pnp, &pnpbios_proc_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) (void *)(long)(node->handle));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (!proc_pnp_boot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if (proc_create_data(name, 0644, proc_pnp_boot, &pnpbios_proc_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) (void *)(long)(node->handle + 0x100)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * When this is called, pnpbios functions are assumed to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * work and the pnpbios_dont_use_current_config flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * should already have been set to the appropriate value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) int __init pnpbios_proc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) proc_pnp = proc_mkdir("bus/pnp", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) if (!proc_pnp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) proc_pnp_boot = proc_mkdir("boot", proc_pnp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) if (!proc_pnp_boot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) proc_create_single("devices", 0, proc_pnp, pnp_devices_proc_show);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) proc_create_single("configuration_info", 0, proc_pnp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) pnpconfig_proc_show);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) proc_create_single("escd_info", 0, proc_pnp, escd_info_proc_show);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) proc_create_single("escd", S_IRUSR, proc_pnp, escd_proc_show);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) proc_create_single("legacy_device_resources", 0, proc_pnp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) pnp_legacyres_proc_show);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) void __exit pnpbios_proc_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) char name[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (!proc_pnp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) for (i = 0; i < 0xff; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) sprintf(name, "%02x", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (!pnpbios_dont_use_current_config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) remove_proc_entry(name, proc_pnp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) remove_proc_entry(name, proc_pnp_boot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) remove_proc_entry("legacy_device_resources", proc_pnp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) remove_proc_entry("escd", proc_pnp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) remove_proc_entry("escd_info", proc_pnp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) remove_proc_entry("configuration_info", proc_pnp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) remove_proc_entry("devices", proc_pnp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) remove_proc_entry("boot", proc_pnp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) remove_proc_entry("bus/pnp", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }