diff options
Diffstat (limited to 'arch/i386/kernel/apm.c')
-rw-r--r-- | arch/i386/kernel/apm.c | 97 |
1 files changed, 36 insertions, 61 deletions
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index 1e60acbed3c1..2d793d4aef1a 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c | |||
@@ -303,17 +303,6 @@ extern int (*console_blank_hook)(int); | |||
303 | #include "apm.h" | 303 | #include "apm.h" |
304 | 304 | ||
305 | /* | 305 | /* |
306 | * Define to make all _set_limit calls use 64k limits. The APM 1.1 BIOS is | ||
307 | * supposed to provide limit information that it recognizes. Many machines | ||
308 | * do this correctly, but many others do not restrict themselves to their | ||
309 | * claimed limit. When this happens, they will cause a segmentation | ||
310 | * violation in the kernel at boot time. Most BIOS's, however, will | ||
311 | * respect a 64k limit, so we use that. If you want to be pedantic and | ||
312 | * hold your BIOS to its claims, then undefine this. | ||
313 | */ | ||
314 | #define APM_RELAX_SEGMENTS | ||
315 | |||
316 | /* | ||
317 | * Define to re-initialize the interrupt 0 timer to 100 Hz after a suspend. | 306 | * Define to re-initialize the interrupt 0 timer to 100 Hz after a suspend. |
318 | * This patched by Chad Miller <cmiller@surfsouth.com>, original code by | 307 | * This patched by Chad Miller <cmiller@surfsouth.com>, original code by |
319 | * David Chen <chen@ctpa04.mit.edu> | 308 | * David Chen <chen@ctpa04.mit.edu> |
@@ -1075,22 +1064,23 @@ static int apm_engage_power_management(u_short device, int enable) | |||
1075 | 1064 | ||
1076 | static int apm_console_blank(int blank) | 1065 | static int apm_console_blank(int blank) |
1077 | { | 1066 | { |
1078 | int error; | 1067 | int error, i; |
1079 | u_short state; | 1068 | u_short state; |
1069 | static const u_short dev[3] = { 0x100, 0x1FF, 0x101 }; | ||
1080 | 1070 | ||
1081 | state = blank ? APM_STATE_STANDBY : APM_STATE_READY; | 1071 | state = blank ? APM_STATE_STANDBY : APM_STATE_READY; |
1082 | /* Blank the first display device */ | 1072 | |
1083 | error = set_power_state(0x100, state); | 1073 | for (i = 0; i < ARRAY_SIZE(dev); i++) { |
1084 | if ((error != APM_SUCCESS) && (error != APM_NO_ERROR)) { | 1074 | error = set_power_state(dev[i], state); |
1085 | /* try to blank them all instead */ | 1075 | |
1086 | error = set_power_state(0x1ff, state); | 1076 | if ((error == APM_SUCCESS) || (error == APM_NO_ERROR)) |
1087 | if ((error != APM_SUCCESS) && (error != APM_NO_ERROR)) | 1077 | return 1; |
1088 | /* try to blank device one instead */ | 1078 | |
1089 | error = set_power_state(0x101, state); | 1079 | if (error == APM_NOT_ENGAGED) |
1080 | break; | ||
1090 | } | 1081 | } |
1091 | if ((error == APM_SUCCESS) || (error == APM_NO_ERROR)) | 1082 | |
1092 | return 1; | 1083 | if (error == APM_NOT_ENGAGED && state != APM_STATE_READY) { |
1093 | if (error == APM_NOT_ENGAGED) { | ||
1094 | static int tried; | 1084 | static int tried; |
1095 | int eng_error; | 1085 | int eng_error; |
1096 | if (tried++ == 0) { | 1086 | if (tried++ == 0) { |
@@ -2233,8 +2223,8 @@ static struct dmi_system_id __initdata apm_dmi_table[] = { | |||
2233 | static int __init apm_init(void) | 2223 | static int __init apm_init(void) |
2234 | { | 2224 | { |
2235 | struct proc_dir_entry *apm_proc; | 2225 | struct proc_dir_entry *apm_proc; |
2226 | struct desc_struct *gdt; | ||
2236 | int ret; | 2227 | int ret; |
2237 | int i; | ||
2238 | 2228 | ||
2239 | dmi_check_system(apm_dmi_table); | 2229 | dmi_check_system(apm_dmi_table); |
2240 | 2230 | ||
@@ -2312,45 +2302,30 @@ static int __init apm_init(void) | |||
2312 | set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); | 2302 | set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); |
2313 | _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); | 2303 | _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); |
2314 | 2304 | ||
2305 | /* | ||
2306 | * Set up the long jump entry point to the APM BIOS, which is called | ||
2307 | * from inline assembly. | ||
2308 | */ | ||
2315 | apm_bios_entry.offset = apm_info.bios.offset; | 2309 | apm_bios_entry.offset = apm_info.bios.offset; |
2316 | apm_bios_entry.segment = APM_CS; | 2310 | apm_bios_entry.segment = APM_CS; |
2317 | 2311 | ||
2318 | for (i = 0; i < NR_CPUS; i++) { | 2312 | /* |
2319 | struct desc_struct *gdt = get_cpu_gdt_table(i); | 2313 | * The APM 1.1 BIOS is supposed to provide limit information that it |
2320 | set_base(gdt[APM_CS >> 3], | 2314 | * recognizes. Many machines do this correctly, but many others do |
2321 | __va((unsigned long)apm_info.bios.cseg << 4)); | 2315 | * not restrict themselves to their claimed limit. When this happens, |
2322 | set_base(gdt[APM_CS_16 >> 3], | 2316 | * they will cause a segmentation violation in the kernel at boot time. |
2323 | __va((unsigned long)apm_info.bios.cseg_16 << 4)); | 2317 | * Most BIOS's, however, will respect a 64k limit, so we use that. |
2324 | set_base(gdt[APM_DS >> 3], | 2318 | * |
2325 | __va((unsigned long)apm_info.bios.dseg << 4)); | 2319 | * Note we only set APM segments on CPU zero, since we pin the APM |
2326 | #ifndef APM_RELAX_SEGMENTS | 2320 | * code to that CPU. |
2327 | if (apm_info.bios.version == 0x100) { | 2321 | */ |
2328 | #endif | 2322 | gdt = get_cpu_gdt_table(0); |
2329 | /* For ASUS motherboard, Award BIOS rev 110 (and others?) */ | 2323 | set_base(gdt[APM_CS >> 3], |
2330 | _set_limit((char *)&gdt[APM_CS >> 3], 64 * 1024 - 1); | 2324 | __va((unsigned long)apm_info.bios.cseg << 4)); |
2331 | /* For some unknown machine. */ | 2325 | set_base(gdt[APM_CS_16 >> 3], |
2332 | _set_limit((char *)&gdt[APM_CS_16 >> 3], 64 * 1024 - 1); | 2326 | __va((unsigned long)apm_info.bios.cseg_16 << 4)); |
2333 | /* For the DEC Hinote Ultra CT475 (and others?) */ | 2327 | set_base(gdt[APM_DS >> 3], |
2334 | _set_limit((char *)&gdt[APM_DS >> 3], 64 * 1024 - 1); | 2328 | __va((unsigned long)apm_info.bios.dseg << 4)); |
2335 | #ifndef APM_RELAX_SEGMENTS | ||
2336 | } else { | ||
2337 | _set_limit((char *)&gdt[APM_CS >> 3], | ||
2338 | (apm_info.bios.cseg_len - 1) & 0xffff); | ||
2339 | _set_limit((char *)&gdt[APM_CS_16 >> 3], | ||
2340 | (apm_info.bios.cseg_16_len - 1) & 0xffff); | ||
2341 | _set_limit((char *)&gdt[APM_DS >> 3], | ||
2342 | (apm_info.bios.dseg_len - 1) & 0xffff); | ||
2343 | /* workaround for broken BIOSes */ | ||
2344 | if (apm_info.bios.cseg_len <= apm_info.bios.offset) | ||
2345 | _set_limit((char *)&gdt[APM_CS >> 3], 64 * 1024 -1); | ||
2346 | if (apm_info.bios.dseg_len <= 0x40) { /* 0x40 * 4kB == 64kB */ | ||
2347 | /* for the BIOS that assumes granularity = 1 */ | ||
2348 | gdt[APM_DS >> 3].b |= 0x800000; | ||
2349 | printk(KERN_NOTICE "apm: we set the granularity of dseg.\n"); | ||
2350 | } | ||
2351 | } | ||
2352 | #endif | ||
2353 | } | ||
2354 | 2329 | ||
2355 | apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info); | 2330 | apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info); |
2356 | if (apm_proc) | 2331 | if (apm_proc) |