core: cleaner way to call kaboom from 32-bit code
authorH. Peter Anvin <hpa@zytor.com>
Thu, 13 Aug 2009 04:51:54 +0000 (21:51 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Thu, 13 Aug 2009 04:51:54 +0000 (21:51 -0700)
Make kaboom() a noreturn function directly callable from 32-bit code.
Do a special macro hack to keep it from interfering with the symbol
kaboom in 16-bit code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
core/call16.c
core/fs/pxe/pxe.c
core/include/core.h

index 1e369e2..86d7046 100644 (file)
@@ -19,6 +19,8 @@
 #include <stddef.h>
 #include "core.h"
 
+const com32sys_t zero_regs;    /* Common all-zero register set */
+
 void call16(void (*func)(void), const com32sys_t *ireg, com32sys_t *oreg)
 {
     core_farcall((size_t)func, ireg, oreg);
index ceb1210..d03847d 100644 (file)
@@ -324,7 +324,7 @@ static int pxe_get_cached_info(int type)
     err = pxe_call(PXENV_GET_CACHED_INFO, &bq_pkt);
     if (err) {
         printf("%s %04x\n", err_pxefailed, err);
-        call16(kaboom, NULL, NULL);
+       kaboom();
     }
     
     return bq_pkt.buffersize;
@@ -404,9 +404,8 @@ static void get_packet_gpxe(struct open_file_t *file)
         if (!err)  /* successed */
             break;
 
-        if (fr.status == PXENV_STATUS_TFTP_OPEN)
-            continue;
-        call16(kaboom, NULL, NULL);
+        if (fr.status != PXENV_STATUS_TFTP_OPEN)
+           kaboom();
     }
 
     file->tftp_bytesleft = fr.buffersize;
@@ -603,7 +602,7 @@ static void fill_buffer(struct open_file_t *file)
 
     /* time runs out */
     if (timeout == 0)
-        call16(kaboom, NULL, NULL);
+       kaboom();
     
     last_pkt = file->tftp_lastpkt;
     last_pkt = ntohs(last_pkt);       /* Host byte order */
@@ -996,7 +995,7 @@ err_reply:
     uw_pkt.buffersize = 24;
     pxe_call(PXENV_UDP_WRITE, &uw_pkt);
     printf("TFTP server sent an incomprehesible reply\n");
-    call16(kaboom, NULL, NULL);
+    kaboom();
         
 failure:
     timeout_ptr++;
@@ -1146,7 +1145,7 @@ static void pxe_load_config(com32sys_t *regs)
         return;
 
     printf("Unable to locate configuration file\n");
-    call16(kaboom, NULL, NULL); 
+    kaboom();
 }
    
   
@@ -1382,7 +1381,7 @@ static void pxe_init(void)
 
     /* Found nothing at all !! */
     printf("%s\n", err_nopxe);
-    call16(kaboom, NULL, NULL);
+    kaboom();
     
  have_pxenv:
     APIVer = pxenv->version;
@@ -1445,7 +1444,7 @@ static void udp_init(void)
     if (err || uo_pkt.status) {
         printf("%s", err_udpinit);
         printf("%d\n", uo_pkt.status);
-        call16(kaboom, NULL, NULL);
+       kaboom();
     }
 }
   
index f7a6928..ad00492 100644 (file)
@@ -25,6 +25,7 @@ void __cdecl core_intcall(uint8_t, const com32sys_t *, com32sys_t *);
 void __cdecl core_farcall(uint32_t, const com32sys_t *, com32sys_t *);
 int __cdecl core_cfarcall(uint32_t, const void *, uint32_t);
 
+extern const com32sys_t zero_regs;
 void call16(void (*)(void), const com32sys_t *, com32sys_t *);
 
 /*
@@ -34,9 +35,15 @@ void call16(void (*)(void), const com32sys_t *, com32sys_t *);
 #define __bss16  __attribute((nocommon,section(".bss16")))
 
 /*
+ * Death!  The macro trick is to avoid symbol conflict with
+ * the real-mode symbol kaboom.
+ */
+__noreturn _kaboom(void);
+#define kaboom() _kaboom()
+
+/*
  * externs for pxelinux
  */
-extern void kaboom(void);
 extern void dns_mangle(void);
 
 extern uint32_t ServerIP;