Add support for gcc v3.x compilers.
[seabios.git] / src / resume.c
index 4ff313386eb911e8e4e3577315d3d186f0dcc2da..6db6b714142f9019a347d9f1a6d6e7e12d4802e6 100644 (file)
@@ -1,8 +1,8 @@
 // Code for handling calls to "post" that are resume related.
 //
-// Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2008,2009  Kevin O'Connor <kevin@koconnor.net>
 //
-// This file may be distributed under the terms of the GNU GPLv3 license.
+// This file may be distributed under the terms of the GNU LGPLv3 license.
 
 #include "util.h" // dprintf
 #include "ioport.h" // outb
@@ -35,16 +35,18 @@ handle_resume(u8 status)
 
     switch (status) {
     case 0xfe:
-        // S3 resume request.  Jump to 32bit mode to handle the resume.
-        asm volatile(
-            "movw %%ax, %%ss\n"
-            "movl %0, %%esp\n"
-            "pushl $_code32_s3_resume\n"
-            "jmp transition32\n"
-            : : "i"(BUILD_S3RESUME_STACK_ADDR), "a"(0)
-            );
-        break;
-
+        if (CONFIG_S3_RESUME) {
+            // S3 resume request.  Jump to 32bit mode to handle the resume.
+            asm volatile(
+                "movw %w1, %%ss\n"
+                "movl %0, %%esp\n"
+                "pushl $s3_resume\n"
+                "jmp transition32\n"
+                : : "i"(BUILD_S3RESUME_STACK_ADDR), "r"(0)
+                );
+            break;
+        }
+        // NO BREAK
     case 0x00:
     case 0x09:
     case 0x0d ... 0xfd:
@@ -59,44 +61,46 @@ 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
-#define bda ((struct bios_data_area_s *)MAKE_FARPTR(SEG_BDA, 0))
         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;
     }
 
-    BX_PANIC("Unimplemented shutdown status: %02x\n", status);
+    panic("Unimplemented shutdown status: %02x\n", status);
 }
 
+#if MODE16==0
 void VISIBLE32
 s3_resume()
 {
+    if (!CONFIG_S3_RESUME)
+        panic("S3 resume support not compiled in.\n");
+
     dprintf(1, "In 32bit resume\n");
 
     smm_init();
@@ -110,8 +114,8 @@ s3_resume()
     memset(&br, 0, sizeof(br));
     if (s3_resume_vector) {
         dprintf(1, "Jump to resume vector (%x)\n", s3_resume_vector);
-        br.ip = FARPTR_TO_OFFSET(s3_resume_vector);
-        br.cs = FARPTR_TO_SEG(s3_resume_vector);
+        br.ip = FLATPTR_TO_OFFSET(s3_resume_vector);
+        br.cs = FLATPTR_TO_SEG(s3_resume_vector);
     } else {
         dprintf(1, "No resume vector set!\n");
         // Jump to the post vector to restart with a normal boot.
@@ -120,6 +124,7 @@ s3_resume()
     }
     call16big(&br);
 }
+#endif
 
 // Ughh - some older gcc compilers have a bug which causes VISIBLE32
 // functions to not be exported as global variables.