/* * Call PnP BIOS with function 0x0a, "get statically allocated resource * information" */ static int __pnp_bios_get_stat_res(char *info) { u16 status; if (!pnp_bios_present()) return PNP_FUNCTION_NOT_SUPPORTED; status = call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, info, 65536, NULL, 0); return status; }
/* * Call PnP BIOS function 0x42, "read ESCD" * nvram_base is determined by calling escd_info */ static int __pnp_bios_read_escd(char *data, u32 nvram_base) { u16 status; if (!pnp_bios_present()) return ESCD_FUNCTION_NOT_SUPPORTED; status = call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0, data, 65536, __va(nvram_base), 65536); return status; }
/* * Call PnP BIOS with function 0x41, "get ESCD info" */ static int __pnp_bios_escd_info(struct escd_info_struc *data) { u16 status; if (!pnp_bios_present()) return ESCD_FUNCTION_NOT_SUPPORTED; status = call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4, PNP_TS1, PNP_DS, data, sizeof(struct escd_info_struc), NULL, 0); return status; }
/* * Call PnP BIOS with function 0x40, "get isa pnp configuration structure" */ static int __pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) { u16 status; if (!pnp_bios_present()) return PNP_FUNCTION_NOT_SUPPORTED; status = call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, data, sizeof(struct pnp_isa_config_struc), NULL, 0); return status; }
/* * Call PnP BIOS with function 0x05, "get docking station information" */ int pnp_bios_dock_station_info(struct pnp_docking_station_info *data) { u16 status; if (!pnp_bios_present()) return PNP_FUNCTION_NOT_SUPPORTED; status = call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, data, sizeof(struct pnp_docking_station_info), NULL, 0); return status; }
/* * Call PnP BIOS with function 0x00, "get number of system device nodes" */ static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data) { u16 status; if (!pnp_bios_present()) return PNP_FUNCTION_NOT_SUPPORTED; status = call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2, PNP_TS1, PNP_DS, 0, 0, data, sizeof(struct pnp_dev_node_info), NULL, 0); data->no_nodes &= 0xff; return status; }
/* * Call PnP BIOS with function 0x02, "set system device node" * Input: *nodenum = desired node, * boot = whether to set nonvolatile boot (!=0) * or volatile current (0) config */ static int __pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) { u16 status; if (!pnp_bios_present()) return PNP_FUNCTION_NOT_SUPPORTED; if (!boot && pnpbios_dont_use_current_config) return PNP_FUNCTION_NOT_SUPPORTED; status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1, boot ? 2 : 1, PNP_DS, 0, 0, data, 65536, NULL, 0); return status; }
/* * Call PnP BIOS with function 0x01, "get system device node" * Input: *nodenum = desired node, * boot = whether to get nonvolatile boot (!=0) * or volatile current (0) config * Output: *nodenum=next node or 0xff if no more nodes */ static int __pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) { u16 status; u16 tmp_nodenum; if (!pnp_bios_present()) return PNP_FUNCTION_NOT_SUPPORTED; if (!boot && pnpbios_dont_use_current_config) return PNP_FUNCTION_NOT_SUPPORTED; tmp_nodenum = *nodenum; status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0, &tmp_nodenum, sizeof(tmp_nodenum), data, 65536); *nodenum = tmp_nodenum; return status; }
void pnp_proc_init(void) { struct pnp_bios_node *node; struct proc_dir_entry *ent; char name[3]; u8 num; if (!pnp_bios_present()) return; if (pnp_bios_dev_node_info(&node_info) != 0) return; proc_pnp = proc_mkdir("pnp", proc_bus); if (!proc_pnp) return; proc_pnp_boot = proc_mkdir("boot", proc_pnp); if (!proc_pnp_boot) return; create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL); node = kmalloc(node_info.max_node_size, GFP_KERNEL); if (!node) return; for (num = 0; num != 0xff; ) { if (pnp_bios_get_dev_node(&num, 0, node) != 0) break; sprintf(name, "%02x", node->handle); ent = create_proc_entry(name, 0, proc_pnp); if (ent) { ent->read_proc = proc_read_node; ent->write_proc = proc_write_node; ent->data = (void *)(long)(node->handle); } ent = create_proc_entry(name, 0, proc_pnp_boot); if (ent) { ent->read_proc = proc_read_node; ent->write_proc = proc_write_node; ent->data = (void *)(long)(node->handle+0x100); } } kfree(node); }