home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / library / hwck.c < prev    next >
C/C++ Source or Header  |  1996-12-11  |  4KB  |  133 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1994  Rafael W. Luebbert
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  $Id: hwck.c,v 1.3 1994/10/18 09:12:51 rluebbert Exp $
  20.  *
  21.  *  $Log: hwck.c,v $
  22.  * Revision 1.3  1994/10/18  09:12:51  rluebbert
  23.  * Check for math emulation code (881 || 882) in 040s.  Assume no FPU otherwise.
  24.  * No 040 FPU instruction support yet.
  25.  *
  26.  * Revision 1.2  1994/06/22  14:56:04  rluebbert
  27.  * added struct ExecBase **4
  28.  *
  29.  * Revision 1.1  1994/06/19  15:11:39  rluebbert
  30.  * Initial revision
  31.  *
  32.  */
  33.  
  34. #define _KERNEL
  35. #include <ixemul.h>
  36. #include <stdarg.h>
  37. #include <proto/intuition.h>
  38.  
  39. static int show_msg(const char *msg, va_list ap, char *gadgetformat)
  40. {
  41.   struct IntuitionBase *IntuitionBase;
  42.   u_char old_flags;
  43.   struct Task *me = SysBase->ThisTask;
  44.   int ret = 0;
  45.  
  46.   /*
  47.    * This function may be called with our signals enabled. So we have to make
  48.    * sure that no signals are processed while in here.
  49.    * Since this function may be called at random points in initialization,
  50.    * it is not safe to call sigsetmask() here, so I have to resort to the
  51.    * more drastic solution of temporarily turning off TF_LAUNCH
  52.    */
  53.   old_flags = me->tc_Flags;
  54.   me->tc_Flags &= ~TF_LAUNCH;
  55.  
  56.   if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0)))
  57.     {
  58.       struct EasyStruct panic = {
  59.         sizeof(struct EasyStruct),
  60.         0,
  61.         "ixemul.library message",
  62.         (char *)msg,
  63.         gadgetformat
  64.       };
  65.         
  66.       ret = EasyRequestArgs(NULL, &panic, NULL, ap);
  67.  
  68.       CloseLibrary ((struct Library *) IntuitionBase);
  69.    }
  70.  
  71.   if (ixemulbase && (ix.ix_flags & ix_create_enforcer_hit) && betterthan68010())
  72.     {
  73.       asm ("movel #0,d0
  74.             move.l d0,0xdeaddead
  75.             nop
  76.             add.l #2,sp
  77.             move.l d0,0xdeaddead
  78.             nop
  79.             sub.l #2,sp" : /* no output */ : );
  80.     }
  81.   me->tc_Flags = old_flags;
  82.   return ret;
  83. }
  84.  
  85. void ix_panic(const char *msg, ...)
  86. {
  87.   va_list ap;
  88.         
  89.   va_start(ap, msg);
  90.   show_msg(msg, ap, "Abort");
  91.   va_end(ap);
  92. }
  93.  
  94. void ix_warning(const char *msg, ...)
  95. {
  96.   va_list ap;
  97.         
  98.   va_start(ap, msg);
  99.   if (!show_msg(msg, ap, "Continue|Abort"))
  100.     exit(20);
  101.   va_end(ap);
  102. }
  103.  
  104. struct ixemul_base *ix_init_glue(struct ixemul_base *ixbase)
  105. {
  106.   /* First set SysBase, because it is used by the 'u' macro. The Enforcer
  107.      manual recommends caching ExecBase because low-memory accesses are slower
  108.      when using Enforcer, besides the extra penalty of being in CHIP memory.
  109.      Also, lots of accesses to address 4 can hurt interrupt performance. */
  110.  
  111.   SysBase = *(struct ExecBase **)4;
  112.  
  113. #if defined (mc68020) || defined (mc68030) || defined (mc68040) || defined (mc68060)
  114.   if (!betterthan68010())
  115.     {
  116.       ix_panic("This ixemul version requires a 68020/30/40/60.");
  117.       return NULL;
  118.     }
  119. #endif
  120. #ifdef __HAVE_68881__
  121.   if (!gotanfpu())
  122.     {
  123.       if (SysBase->AttnFlags & AFF_68040)
  124.     ix_panic("68040 math emulation code not found.");
  125.       else
  126.     ix_panic("This ixemul version requires an FPU.");
  127.       return NULL;
  128.     }
  129. #endif
  130.   return ix_init(ixbase);
  131. }
  132.  
  133.