_set_limit((char *)&per_cpu(cpu_gdt_table, i)[APM_DS >> 3], 64 * 1024 - 1); 
_set_limit((char *)&gdt[APM_DS >> 3], 64 * 1024 - 1); 
static int __init apm_init(void){	struct proc_dir_entry *apm_proc;	int ret;	int i;	dmi_check_system(apm_dmi_table);	if (apm_info.bios.version == 0) {		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:%lx 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_info.bios.cseg_16_len);		printk("\n");	}	if (apm_info.disabled) {		printk(KERN_NOTICE "apm: disabled on user request.\n");		return -ENODEV;	}	if ((num_online_cpus() > 1) && !power_off && !smp) {		printk(KERN_NOTICE "apm: disabled - APM is not SMP safe.\n");		apm_info.disabled = 1;		return -ENODEV;	}	if (PM_IS_ACTIVE()) {		printk(KERN_NOTICE "apm: overridden by ACPI.\n");		apm_info.disabled = 1;		return -ENODEV;	}	pm_active = 1;	/*	 * Set up a segment that references the real mode segment 0x40	 * that extends up to the end of page zero (that we have reserved).	 * This is for buggy BIOS's that refer to (real mode) segment 0x40	 * even though they are called in protected mode.	 */	set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));	_set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));	apm_bios_entry.offset = apm_info.bios.offset;	apm_bios_entry.segment = APM_CS;	for (i = 0; i < NR_CPUS; i++) {		set_base(per_cpu(cpu_gdt_table, i)[APM_CS >> 3],			 __va((unsigned long)apm_info.bios.cseg << 4));		set_base(per_cpu(cpu_gdt_table, i)[APM_CS_16 >> 3],			 __va((unsigned long)apm_info.bios.cseg_16 << 4));		set_base(per_cpu(cpu_gdt_table, i)[APM_DS >> 3],			 __va((unsigned long)apm_info.bios.dseg << 4));#ifndef APM_RELAX_SEGMENTS		if (apm_info.bios.version == 0x100) {#endif			/* For ASUS motherboard, Award BIOS rev 110 (and others?) */			_set_limit((char *)&per_cpu(cpu_gdt_table, i)[APM_CS >> 3], 64 * 1024 - 1);			/* For some unknown machine. */			_set_limit((char *)&per_cpu(cpu_gdt_table, i)[APM_CS_16 >> 3], 64 * 1024 - 1);			/* For the DEC Hinote Ultra CT475 (and others?) */			_set_limit((char *)&per_cpu(cpu_gdt_table, i)[APM_DS >> 3], 64 * 1024 - 1);#ifndef APM_RELAX_SEGMENTS		} else {			_set_limit((char *)&per_cpu(cpu_gdt_table, i)[APM_CS >> 3],				(apm_info.bios.cseg_len - 1) & 0xffff);			_set_limit((char *)&per_cpu(cpu_gdt_table, i)[APM_CS_16 >> 3],				(apm_info.bios.cseg_16_len - 1) & 0xffff);			_set_limit((char *)&per_cpu(cpu_gdt_table, i)[APM_DS >> 3],				(apm_info.bios.dseg_len - 1) & 0xffff);		      /* workaround for broken BIOSes */	                if (apm_info.bios.cseg_len <= apm_info.bios.offset)        	                _set_limit((char *)&per_cpu(cpu_gdt_table, i)[APM_CS >> 3], 64 * 1024 -1);                       if (apm_info.bios.dseg_len <= 0x40) { /* 0x40 * 4kB == 64kB */                        	/* for the BIOS that assumes granularity = 1 */                        	per_cpu(cpu_gdt_table, i)[APM_DS >> 3].b |= 0x800000;                        	printk(KERN_NOTICE "apm: we set the granularity of dseg.\n");        	        }		}#endif	}	apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info);	if (apm_proc)		apm_proc->owner = THIS_MODULE;	ret = kernel_thread(apm, NULL, CLONE_KERNEL | SIGCHLD);	if (ret < 0) {		printk(KERN_ERR "apm: disabled - Unable to start kernel thread.\n");		return -ENOMEM;	}	if (num_online_cpus() > 1 && !smp ) {		printk(KERN_NOTICE		   "apm: disabled - APM is not SMP safe (power off active).\n");		return 0;	}	misc_register(&apm_device);	if (HZ != 100)		idle_period = (idle_period * HZ) / 100;	if (idle_threshold < 100) {		original_pm_idle = pm_idle;		pm_idle  = apm_cpu_idle;		set_pm_idle = 1;	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/251e6912df43df54570ed68aade703b329c6cd5b/apm.c/buggy/arch/i386/kernel/apm.c