Fix apparent bug in 16bit resume code.
authorKevin O'Connor <kevin@koconnor.net>
Mon, 19 Jan 2009 17:53:54 +0000 (12:53 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 19 Jan 2009 17:53:54 +0000 (12:53 -0500)
The BDA offsets were adding in 0x400 twice.
Also, use lss insn instead of manually setting %ss and %sp.
Also, don't force segment value into %eax.

src/resume.c

index 86c0555a8715bfa5cae6ea1f7ba4e53e87f1b9d4..f141ea3f164a99629216d241ffe3e80ce8824836 100644 (file)
@@ -33,17 +33,16 @@ handle_resume(u8 status)
     debug_serial_setup();
     dprintf(1, "In resume (status=%d)\n", status);
 
-    struct bios_data_area_s *bda = MAKE_FARPTR(SEG_BDA, 0);
     switch (status) {
     case 0xfe:
         if (CONFIG_S3_RESUME) {
             // S3 resume request.  Jump to 32bit mode to handle the resume.
             asm volatile(
-                "movw %%ax, %%ss\n"
+                "movw %w1, %%ss\n"
                 "movl %0, %%esp\n"
                 "pushl $_code32_s3_resume\n"
                 "jmp transition32\n"
-                : : "i"(BUILD_S3RESUME_STACK_ADDR), "a"(0)
+                : : "i"(BUILD_S3RESUME_STACK_ADDR), "r"(0)
                 );
             break;
         }
@@ -62,33 +61,32 @@ handle_resume(u8 status)
         eoi_pic2();
         // NO BREAK
     case 0x0a:
+#define BDA_JUMP_IP (((struct bios_data_area_s *)0)->jump_ip)
         // resume execution by jump via 40h:0067h
         asm volatile(
-            "movw %%ax, %%ds\n"
+            "movw %w1, %%ds\n"
             "ljmpw *%0\n"
-            : : "m"(bda->jump_ip), "a"(SEG_BDA)
+            : : "m"(BDA_JUMP_IP), "r"(SEG_BDA)
             );
         break;
 
     case 0x0b:
         // resume execution via IRET via 40h:0067h
         asm volatile(
-            "movw %%ax, %%ds\n"
-            "movw %0, %%sp\n"
-            "movw %1, %%ss\n"
+            "movw %w1, %%ds\n"
+            "lssw %0, %%sp\n"
             "iretw\n"
-            : : "m"(bda->jump_ip), "m"(bda->jump_cs), "a"(SEG_BDA)
+            : : "m"(BDA_JUMP_IP), "r"(SEG_BDA)
             );
         break;
 
     case 0x0c:
         // resume execution via RETF via 40h:0067h
         asm volatile(
-            "movw %%ax, %%ds\n"
-            "movw %0, %%sp\n"
-            "movw %1, %%ss\n"
+            "movw %w1, %%ds\n"
+            "lssw %0, %%sp\n"
             "lretw\n"
-            : : "m"(bda->jump_ip), "m"(bda->jump_cs), "a"(SEG_BDA)
+            : : "m"(BDA_JUMP_IP), "r"(SEG_BDA)
             );
         break;
     }