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

📄 apm_32.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
}#ifndef MODULEstatic int __init apm_setup(char *str){	int	invert;	while ((str != NULL) && (*str != '\0')) {		if (strncmp(str, "off", 3) == 0)			apm_disabled = 1;		if (strncmp(str, "on", 2) == 0)			apm_disabled = 0;		if ((strncmp(str, "bounce-interval=", 16) == 0) ||		    (strncmp(str, "bounce_interval=", 16) == 0))			bounce_interval = simple_strtol(str + 16, NULL, 0);		if ((strncmp(str, "idle-threshold=", 15) == 0) ||		    (strncmp(str, "idle_threshold=", 15) == 0))			idle_threshold = simple_strtol(str + 15, NULL, 0);		if ((strncmp(str, "idle-period=", 12) == 0) ||		    (strncmp(str, "idle_period=", 12) == 0))			idle_period = simple_strtol(str + 12, NULL, 0);		invert = (strncmp(str, "no-", 3) == 0) ||			(strncmp(str, "no_", 3) == 0);		if (invert)			str += 3;		if (strncmp(str, "debug", 5) == 0)			debug = !invert;		if ((strncmp(str, "power-off", 9) == 0) ||		    (strncmp(str, "power_off", 9) == 0))			power_off = !invert;		if (strncmp(str, "smp", 3) == 0)		{			smp = !invert;			idle_threshold = 100;		}		if ((strncmp(str, "allow-ints", 10) == 0) ||		    (strncmp(str, "allow_ints", 10) == 0)) 			apm_info.allow_ints = !invert;		if ((strncmp(str, "broken-psr", 10) == 0) ||		    (strncmp(str, "broken_psr", 10) == 0))			apm_info.get_power_status_broken = !invert;		if ((strncmp(str, "realmode-power-off", 18) == 0) ||		    (strncmp(str, "realmode_power_off", 18) == 0))			apm_info.realmode_power_off = !invert;		str = strchr(str, ',');		if (str != NULL)			str += strspn(str, ", \t");	}	return 1;}__setup("apm=", apm_setup);#endifstatic const struct file_operations apm_bios_fops = {	.owner		= THIS_MODULE,	.read		= do_read,	.poll		= do_poll,	.ioctl		= do_ioctl,	.open		= do_open,	.release	= do_release,};static struct miscdevice apm_device = {	APM_MINOR_DEV,	"apm_bios",	&apm_bios_fops};/* Simple "print if true" callback */static int __init print_if_true(const struct dmi_system_id *d){	printk("%s\n", d->ident);	return 0;}/* * Some Bioses enable the PS/2 mouse (touchpad) at resume, even if it was * disabled before the suspend. Linux used to get terribly confused by that. */static int __init broken_ps2_resume(const struct dmi_system_id *d){	printk(KERN_INFO "%s machine detected. Mousepad Resume Bug workaround hopefully not needed.\n", d->ident);	return 0;}/* Some bioses have a broken protected mode poweroff and need to use realmode */static int __init set_realmode_power_off(const struct dmi_system_id *d){	if (apm_info.realmode_power_off == 0) {		apm_info.realmode_power_off = 1;		printk(KERN_INFO "%s bios detected. Using realmode poweroff only.\n", d->ident);	}	return 0;}/* Some laptops require interrupts to be enabled during APM calls */static int __init set_apm_ints(const struct dmi_system_id *d){	if (apm_info.allow_ints == 0) {		apm_info.allow_ints = 1;		printk(KERN_INFO "%s machine detected. Enabling interrupts during APM calls.\n", d->ident);	}	return 0;}/* Some APM bioses corrupt memory or just plain do not work */static int __init apm_is_horked(const struct dmi_system_id *d){	if (apm_info.disabled == 0) {		apm_info.disabled = 1;		printk(KERN_INFO "%s machine detected. Disabling APM.\n", d->ident);	}	return 0;}static int __init apm_is_horked_d850md(const struct dmi_system_id *d){	if (apm_info.disabled == 0) {		apm_info.disabled = 1;		printk(KERN_INFO "%s machine detected. Disabling APM.\n", d->ident);		printk(KERN_INFO "This bug is fixed in bios P15 which is available for \n");		printk(KERN_INFO "download from support.intel.com \n");	}	return 0;}/* Some APM bioses hang on APM idle calls */static int __init apm_likes_to_melt(const struct dmi_system_id *d){	if (apm_info.forbid_idle == 0) {		apm_info.forbid_idle = 1;		printk(KERN_INFO "%s machine detected. Disabling APM idle calls.\n", d->ident);	}	return 0;}/* *  Check for clue free BIOS implementations who use *  the following QA technique * *      [ Write BIOS Code ]<------ *               |                ^ *      < Does it Compile >----N-- *               |Y               ^ *	< Does it Boot Win98 >-N-- *               |Y *           [Ship It] * *	Phoenix A04  08/24/2000 is known bad (Dell Inspiron 5000e) *	Phoenix A07  09/29/2000 is known good (Dell Inspiron 5000) */static int __init broken_apm_power(const struct dmi_system_id *d){	apm_info.get_power_status_broken = 1;	printk(KERN_WARNING "BIOS strings suggest APM bugs, disabling power status reporting.\n");	return 0;}/* * This bios swaps the APM minute reporting bytes over (Many sony laptops * have this problem). */static int __init swab_apm_power_in_minutes(const struct dmi_system_id *d){	apm_info.get_power_status_swabinminutes = 1;	printk(KERN_WARNING "BIOS strings suggest APM reports battery life in minutes and wrong byte order.\n");	return 0;}static struct dmi_system_id __initdata apm_dmi_table[] = {	{		print_if_true,		KERN_WARNING "IBM T23 - BIOS 1.03b+ and controller firmware 1.02+ may be needed for Linux APM.",		{	DMI_MATCH(DMI_SYS_VENDOR, "IBM"),			DMI_MATCH(DMI_BIOS_VERSION, "1AET38WW (1.01b)"), },	},	{	/* Handle problems with APM on the C600 */		broken_ps2_resume, "Dell Latitude C600",		{	DMI_MATCH(DMI_SYS_VENDOR, "Dell"),			DMI_MATCH(DMI_PRODUCT_NAME, "Latitude C600"), },	},	{	/* Allow interrupts during suspend on Dell Latitude laptops*/		set_apm_ints, "Dell Latitude",		{	DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),			DMI_MATCH(DMI_PRODUCT_NAME, "Latitude C510"), }	},	{	/* APM crashes */		apm_is_horked, "Dell Inspiron 2500",		{	DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),			DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 2500"),			DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION,"A11"), },	},	{	/* Allow interrupts during suspend on Dell Inspiron laptops*/		set_apm_ints, "Dell Inspiron", {			DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),			DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 4000"), },	},	{	/* Handle problems with APM on Inspiron 5000e */		broken_apm_power, "Dell Inspiron 5000e",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "A04"),			DMI_MATCH(DMI_BIOS_DATE, "08/24/2000"), },	},	{	/* Handle problems with APM on Inspiron 2500 */		broken_apm_power, "Dell Inspiron 2500",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "A12"),			DMI_MATCH(DMI_BIOS_DATE, "02/04/2002"), },	},	{	/* APM crashes */		apm_is_horked, "Dell Dimension 4100",		{	DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),			DMI_MATCH(DMI_PRODUCT_NAME, "XPS-Z"),			DMI_MATCH(DMI_BIOS_VENDOR,"Intel Corp."),			DMI_MATCH(DMI_BIOS_VERSION,"A11"), },	},	{	/* Allow interrupts during suspend on Compaq Laptops*/		set_apm_ints, "Compaq 12XL125",		{	DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),			DMI_MATCH(DMI_PRODUCT_NAME, "Compaq PC"),			DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION,"4.06"), },	},	{	/* Allow interrupts during APM or the clock goes slow */		set_apm_ints, "ASUSTeK",		{	DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),			DMI_MATCH(DMI_PRODUCT_NAME, "L8400K series Notebook PC"), },	},	{	/* APM blows on shutdown */		apm_is_horked, "ABIT KX7-333[R]",		{	DMI_MATCH(DMI_BOARD_VENDOR, "ABIT"),			DMI_MATCH(DMI_BOARD_NAME, "VT8367-8233A (KX7-333[R])"), },	},	{	/* APM crashes */		apm_is_horked, "Trigem Delhi3",		{	DMI_MATCH(DMI_SYS_VENDOR, "TriGem Computer, Inc"),			DMI_MATCH(DMI_PRODUCT_NAME, "Delhi3"), },	},	{	/* APM crashes */		apm_is_horked, "Fujitsu-Siemens",		{	DMI_MATCH(DMI_BIOS_VENDOR, "hoenix/FUJITSU SIEMENS"),			DMI_MATCH(DMI_BIOS_VERSION, "Version1.01"), },	},	{	/* APM crashes */		apm_is_horked_d850md, "Intel D850MD",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Intel Corp."),			DMI_MATCH(DMI_BIOS_VERSION, "MV85010A.86A.0016.P07.0201251536"), },	},	{	/* APM crashes */		apm_is_horked, "Intel D810EMO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Intel Corp."),			DMI_MATCH(DMI_BIOS_VERSION, "MO81010A.86A.0008.P04.0004170800"), },	},	{	/* APM crashes */		apm_is_horked, "Dell XPS-Z",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Intel Corp."),			DMI_MATCH(DMI_BIOS_VERSION, "A11"),			DMI_MATCH(DMI_PRODUCT_NAME, "XPS-Z"), },	},	{	/* APM crashes */		apm_is_horked, "Sharp PC-PJ/AX",		{	DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),			DMI_MATCH(DMI_PRODUCT_NAME, "PC-PJ/AX"),			DMI_MATCH(DMI_BIOS_VENDOR,"SystemSoft"),			DMI_MATCH(DMI_BIOS_VERSION,"Version R2.08"), },	},	{	/* APM crashes */		apm_is_horked, "Dell Inspiron 2500",		{	DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),			DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 2500"),			DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION,"A11"), },	},	{	/* APM idle hangs */		apm_likes_to_melt, "Jabil AMD",		{	DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),			DMI_MATCH(DMI_BIOS_VERSION, "0AASNP06"), },	},	{	/* APM idle hangs */		apm_likes_to_melt, "AMI Bios",		{	DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),			DMI_MATCH(DMI_BIOS_VERSION, "0AASNP05"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-N505X(DE) */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "R0206H"),			DMI_MATCH(DMI_BIOS_DATE, "08/23/99"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-N505VX */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "W2K06H0"),			DMI_MATCH(DMI_BIOS_DATE, "02/03/00"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-XG29 */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "R0117A0"),			DMI_MATCH(DMI_BIOS_DATE, "04/25/00"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-Z600NE */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "R0121Z1"),			DMI_MATCH(DMI_BIOS_DATE, "05/11/00"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-Z600NE */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "WME01Z1"),			DMI_MATCH(DMI_BIOS_DATE, "08/11/00"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-Z600LEK(DE) */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "R0206Z3"),			DMI_MATCH(DMI_BIOS_DATE, "12/25/00"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-Z505LS */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "R0203D0"),			DMI_MATCH(DMI_BIOS_DATE, "05/12/00"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-Z505LS */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "R0203Z3"),			DMI_MATCH(DMI_BIOS_DATE, "08/25/00"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-Z505LS (with updated BIOS) */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "R0209Z3"),			DMI_MATCH(DMI_BIOS_DATE, "05/12/01"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-F104K */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "R0204K2"),			DMI_MATCH(DMI_BIOS_DATE, "08/28/00"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-C1VN/C1VE */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "R0208P1"),			DMI_MATCH(DMI_BIOS_DATE, "11/09/00"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-C1VE */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "R0204P1"),			DMI_MATCH(DMI_BIOS_DATE, "09/12/00"), },	},	{	/* Handle problems with APM on Sony Vaio PCG-C1VE */		swab_apm_power_in_minutes, "Sony VAIO",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),			DMI_MATCH(DMI_BIOS_VERSION, "WXPO1Z3"),			DMI_MATCH(DMI_BIOS_DATE, "10/26/01"), },	},	{	/* broken PM poweroff bios */		set_realmode_power_off, "Award Software v4.60 PGMA",		{	DMI_MATCH(DMI_BIOS_VENDOR, "Award Software International, Inc."),			DMI_MATCH(DMI_BIOS_VERSION, "4.60 PGMA"),			DMI_MATCH(DMI_BIOS_DATE, "134526184"), },	},	/* Generic per vendor APM settings  */	{	/* Allow interrupts during suspend on IBM laptops */		set_apm_ints, "IBM",		{	DMI_MATCH(DMI_SYS_VENDOR, "IBM"), },	},	{ }};/* * Just start the APM thread. We do NOT want to do APM BIOS * calls from anything but the APM thread, if for no other reason * than the fact that we don't trust the APM BIOS. This way, * most common APM BIOS problems that lead to protection errors * etc will have at least some level of being contained... * * In short, if something bad happens, at least we have a choice * of just killing the apm thread.. */static int __init apm_init(void){	struct proc_dir_entry *apm_proc;	struct desc_struct *gdt;	int err;	dmi_check_system(apm_dmi_table);	if (apm_info.bios.version == 0 || paravirt_enabled()) {		printk(KERN_INFO "apm: BIOS not found.\n");		return -ENODEV;	}	printk(KERN_INFO		"apm: BIOS version %d.%d Flags 0x%02x (Driver version %s)\n",		((apm_info.bios.version >> 8) & 0xff),		(apm_info.bios.version & 0xff),		apm_info.bios.flags,		driver_version);	if ((apm_info.bios.flags & APM_32_BIT_SUPPORT) == 0) {		printk(KERN_INFO "apm: no 32 bit BIOS support\n");		return -ENODEV;	}	if (allow_ints)		apm_info.allow_ints = 1;	if (broken_psr)		apm_info.get_power_status_broken = 1;	if (realmode_power_off)		apm_info.realmode_power_off = 1;	/* User can override, but default is to trust DMI */	if (apm_disabled != -1)		apm_info.disabled = apm_disabled;	/*	 * Fix for the Compaq Contura 3/25c which reports BIOS version 0.1	 * but is reportedly a 1.0 BIOS.	 */	if (apm_info.bios.version == 0x001)		apm_info.bios.version = 0x100;	/* BIOS < 1.2 doesn't set cseg_16_len */	if (apm_info.bios.version < 0x102)		apm_info.bios.cseg_16_len = 0; /* 64k */	if (debug) {		printk(KERN_INFO "apm: entry %x:%x cseg16 %x dseg %x",			apm_info.bios.cseg, apm_info.bios.offset,			apm_info.bios.cseg_16, apm_info.bios.dseg);		if (apm_info.bios.version > 0x100)			printk(" cseg len %x, dseg len %x",				apm_info.bios.cseg_len,				apm_info.bios.dseg_len);		if (apm_info.bios.version > 0x101)			printk(" cseg16 len %x", apm

⌨️ 快捷键说明

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