⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pnp_bios.c

📁 pcmcia source code
💻 C
📖 第 1 页 / 共 2 页
字号:
 */#if neededint pnp_bios_send_message(u16 message){	u16 status;	if (!pnp_bios_present ())		return PNP_FUNCTION_NOT_SUPPORTED;	push_pnp_gdt();	__asm__ __volatile__          ("lcall %%cs:" SYMBOL_NAME_STR(pnp_bios_callpoint) "\n\t"           :"=a"(status)           :"a"(((u32) message << 16) | PNP_SEND_MESSAGE),            "b"(PNP_DS)           :"memory");	pop_pnp_gdt();	return status;}#endif/* * Call pnp bios with function 0x05, "get docking station information" */#if neededint pnp_bios_dock_station_info(struct pnp_docking_station_info *data){	u16 status;	if (!pnp_bios_present ())		return PNP_FUNCTION_NOT_SUPPORTED;	push_pnp_gdt();	Q2_SET_SEL(PNP_TS1, data, sizeof(struct pnp_docking_station_info));	__asm__ __volatile__          ("lcall %%cs:" SYMBOL_NAME_STR(pnp_bios_callpoint) "\n\t"           :"=a"(status)           :"a"(PNP_GET_DOCKING_STATION_INFORMATION),            "b"((PNP_TS1 << 16) | PNP_DS)           :"memory");	pop_pnp_gdt();	return status;}#endif/* * Call pnp bios with function 0x09, "set statically allocated resource * information" */#if neededint pnp_bios_set_stat_res(char *info){	u16 status;	if (!pnp_bios_present ())		return PNP_FUNCTION_NOT_SUPPORTED;	push_pnp_gdt();	Q2_SET_SEL(PNP_TS1, info, *((u16 *) info));	__asm__ __volatile__          ("lcall %%cs:" SYMBOL_NAME_STR(pnp_bios_callpoint) "\n\t"           :"=a"(status)           :"a"(PNP_SET_STATIC_ALLOCED_RES_INFO),            "b"((PNP_TS1 << 16) | PNP_DS)           :"memory");	pop_pnp_gdt();	return status;}#endif/* * Call pnp bios with function 0x0a, "get statically allocated resource * information" */#if neededint pnp_bios_get_stat_res(char *info){	u16 status;	if (!pnp_bios_present ())		return PNP_FUNCTION_NOT_SUPPORTED;	push_pnp_gdt();	Q2_SET_SEL(PNP_TS1, info, 64 * 1024);	__asm__ __volatile__          ("lcall %%cs:" SYMBOL_NAME_STR(pnp_bios_callpoint) "\n\t"           :"=a"(status)           :"a"(PNP_GET_STATIC_ALLOCED_RES_INFO),            "b"((PNP_TS1 << 16) | PNP_DS)           :"memory");	pop_pnp_gdt();	return status;}#endif/* * Call pnp bios with function 0x0b, "get APM id table" */#if neededint pnp_bios_apm_id_table(char *table, u16 *size){	u16 status;	if (!pnp_bios_present ())		return PNP_FUNCTION_NOT_SUPPORTED;	push_pnp_gdt();	Q2_SET_SEL(PNP_TS1, table, *size);	Q2_SET_SEL(PNP_TS2, size, sizeof(u16));	__asm__ __volatile__          ("lcall %%cs:" SYMBOL_NAME_STR(pnp_bios_callpoint) "\n\t"           :"=a"(status)           :"a"(PNP_GET_APM_ID_TABLE),            "b"(PNP_TS2),            "c"((PNP_DS << 16) | PNP_TS1)           :"memory");	pop_pnp_gdt();	return status;}#endif/* * Call pnp bios with function 0x40, "get isa pnp configuration structure" */#if neededint pnp_bios_isapnp_config(struct pnp_isa_config_struc *data){	u16 status;	if (!pnp_bios_present ())		return PNP_FUNCTION_NOT_SUPPORTED;	push_pnp_gdt();	Q2_SET_SEL(PNP_TS1, data, sizeof(struct pnp_isa_config_struc));	__asm__ __volatile__          ("lcall %%cs:" SYMBOL_NAME_STR(pnp_bios_callpoint) "\n\t"           :"=a"(status)           :"a"(PNP_GET_PNP_ISA_CONFIG_STRUC),            "b"((PNP_DS << 16) | PNP_TS1)           :"memory");	pop_pnp_gdt();	return status;}#endif/* * Call pnp bios with function 0x41, "get ESCD info" */#if neededint pnp_bios_escd_info(struct escd_info_struc *data){	u16 status;	if (!pnp_bios_present ())		return ESCD_FUNCTION_NOT_SUPPORTED;	push_pnp_gdt();	Q2_SET_SEL(PNP_TS1, data, sizeof(struct escd_info_struc));	__asm__ __volatile__          ("lcall %%cs:" SYMBOL_NAME_STR(pnp_bios_callpoint) "\n\t"           :"=a"(status)           :"a"(PNP_GET_ESCD_INFO),            "b"((2 << 16) | PNP_TS1),            "c"((4 << 16) | PNP_TS1),            "d"((PNP_DS << 16) | PNP_TS1)           :"memory");	pop_pnp_gdt();	return status;}#endif/* * Call pnp bios function 0x42, "read ESCD" * nvram_base is determined by calling escd_info */#if neededint pnp_bios_read_escd(char *data, u32 nvram_base){	u16 status;	if (!pnp_bios_present ())		return ESCD_FUNCTION_NOT_SUPPORTED;	push_pnp_gdt();	Q2_SET_SEL(PNP_TS1, data, 64 * 1024);	set_base(gdt[PNP_TS2 >> 3], nvram_base);	set_limit(gdt[PNP_TS2 >> 3], 64 * 1024);	__asm__ __volatile__          ("lcall %%cs:" SYMBOL_NAME_STR(pnp_bios_callpoint) "\n\t"           :"=a"(status)           :"a"(PNP_READ_ESCD),            "b"((PNP_TS2 << 16) | PNP_TS1),            "c"(PNP_DS)           :"memory");	pop_pnp_gdt();	return status;}#endif/* * Call pnp bios function 0x43, "write ESCD" */#if neededint pnp_bios_write_escd(char *data, u32 nvram_base){	u16 status;	if (!pnp_bios_present ())		return ESCD_FUNCTION_NOT_SUPPORTED;	push_pnp_gdt();	Q2_SET_SEL(PNP_TS1, data, 64 * 1024);	set_base(gdt[PNP_TS2 >> 3], nvram_base);	set_limit(gdt[PNP_TS2 >> 3], 64 * 1024);	__asm__ __volatile__          ("lcall %%cs:" SYMBOL_NAME_STR(pnp_bios_callpoint) "\n\t"           :"=a"(status)           :"a"(PNP_WRITE_ESCD),            "b"((PNP_TS2 << 16) | PNP_TS1),            "c"(PNP_DS)           :"memory");	pop_pnp_gdt();	return status;}#endifint pnp_bios_present(void){  return (pnp_bios_inst_struc != NULL);}/*  * Searches the defined area (0xf0000-0xffff0) for a valid PnP BIOS * structure and, if found one, sets up the selectors and entry points */void pnp_bios_init(void){	union pnpbios *check;	u8 sum;	int i, length;#ifdef MODULE	struct Xgt_desc_struct my_gdt_descr;	__asm__ __volatile__ ("sgdt %0" : : "m" (my_gdt_descr));	gdt = (struct desc_struct *)my_gdt_descr.address;#endif	for (check = (union pnpbios *) __va(0xf0000);	     check < (union pnpbios *) __va(0xffff0);	     ((void *) (check)) += 16) {		if (check->fields.signature != PNP_SIGNATURE)			continue;		length = check->fields.length;		if (!length)			continue;		for (sum = 0, i = 0; i < length; i++)			sum += check->chars[i];		if (sum)			continue;		if (check->fields.version < 0x10) {			printk(KERN_WARNING "PnP: unsupported version %d.%d",			       check->fields.version >> 4,			       check->fields.version & 15);			continue;		}		printk(KERN_INFO "PnP: PNP BIOS installation structure at 0x%p\n",		       check);		printk(KERN_INFO "PnP: PNP BIOS version %d.%d, entry at %x:%x, dseg at %x\n",                       check->fields.version >> 4, check->fields.version & 15,		       check->fields.pm16cseg, check->fields.pm16offset,		       check->fields.pm16dseg);		push_pnp_gdt();		Q2_SET_SEL(PNP_CS32, &pnp_bios_callfunc,			   sizeof(pnp_bios_callfunc));		Q_SET_SEL(PNP_CS16, check->fields.pm16cseg, 64 * 1024);		Q_SET_SEL(PNP_DS, check->fields.pm16dseg, 64 * 1024);		pop_pnp_gdt();		pnp_bios_callfunc[6] = check->fields.pm16offset & 0xff;		pnp_bios_callfunc[7] = check->fields.pm16offset >> 8;		pnp_bios_callpoint.offset = 0;		pnp_bios_callpoint.segment = PNP_CS32;		pnp_bios_inst_struc = check;		break;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -