Skip to contentSkip to conversation

APM work around for bad bios.

PATCH Hiroshi Miura 2 participants 2 messages Oct 17, 2002 – Oct 26, 2002

lore
Share & tools
lore
#0 lore raw

Hello,

I use CASIO CASSIOPEIA FIVA 101 and 103. (http://www.da-cha.org/fiva/fiva.html)
this use Cyrix MediaGX and Award BIOS.
This APM BIOS report broken value for dseg_len.
it asumes granularity is 1.

I made a work around for this situation.

* if (cseg_len < bios.offset) BIOS report BAD len value. -- segment length must be always larger than code offset

* if (dseg_len <= 0x40 ) BIOS asumes granularity =1.

     -- 0x40 * 4kB = 64kB, my pc reports 0x40.
arch/i386/kernel/apm.c +8 -0
diff -urB -x .config -x '*.[oasS]' -x '*.in' -x '*.rej' -x '*.orig' linux-2.5.43-orig/arch/i386/kernel/apm.c linux-2.5.43/arch/i386/kernel/apm.c
@@ -1980,6 +2141,14 @@
 				(apm_info.bios.cseg_16_len - 1) & 0xffff);
 			_set_limit((char *)&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 *)&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 */
+                        	cpu_gdt_table[i][APM_DS >> 3].b |= 0x800000;
+                        	printk(KERN_NOTICE "apm: we set the granularity of dseg.\n");
+        	        }
 		}
 #endif
 	}
Signature · 4 lines
Hiroshi Miura  --- http://www.da-cha.org/ 
NTTDATA Corp. Marketing & Business Strategy Planning Dept. --- [email protected] 
Key fingerprint = 9117 9407 5684 FBF1 4063  15B4 401D D077 04AB 8617
-- My hacking life is happy as the day is long
#1 lore raw

Hi!

Quoted 18 lines

I use CASIO CASSIOPEIA FIVA 101 and 103. (http://www.da-cha.org/fiva/fiva.html)
this use Cyrix MediaGX and Award BIOS.
This APM BIOS report broken value for dseg_len.
it asumes granularity is 1.

I made a work around for this situation.

* if (cseg_len < bios.offset) BIOS report BAD len value. -- segment length must be always larger than code offset

* if (dseg_len <= 0x40 ) BIOS asumes granularity =1.

     -- 0x40 * 4kB = 64kB, my pc reports 0x40.

diff -urB -x .config -x '*.[oasS]' -x '*.in' -x '*.rej' -x '*.orig' linux-2.5.43-orig/arch/i386/kernel/apm.c linux-2.5.43/arch/i386/kernel/apm.c

arch/i386/kernel/apm.c line 2146

Quoted 6 lines
arch/i386/kernel/apm.c +3 -0
@@ -1980,6 +2141,14 @@
 				(apm_info.bios.cseg_16_len - 1) & 0xffff);
 			_set_limit((char *)&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 *)&cpu_gdt_table[i][APM_CS >> 3], 64 * 1024 -1);

Maybe add printk KERN_WARNING "apm: broken bios -- code segment too short, assuming 64k"

arch/i386/kernel/apm.c

Quoted 5 lines
arch/i386/kernel/apm.c +4 -0
+                       if (apm_info.bios.dseg_len <= 0x40) { /* 0x40 * 4kB == 64kB */
+                        	/* for the BIOS that assumes granularity = 1 */
+                        	cpu_gdt_table[i][APM_DS >> 3].b |= 0x800000;
+                        	printk(KERN_NOTICE "apm: we set the
 granularity of dseg.\n");

Maybe better KERN_WARNING "apm: broken bios -- assuming granularity 1 on dseg"
Pavel

Signature · 2 lines
Worst form of spam? Adding advertisment signatures ala sourceforge.net.
What goes next? Inserting advertisment *into* email?