home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / library / rcs / ix_resident.c,v < prev    next >
Encoding:
Text File  |  1992-09-14  |  3.1 KB  |  155 lines

  1. head    1.2;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @ *  @;
  7.  
  8.  
  9. 1.2
  10. date    92.09.14.01.42.52;    author mwild;    state Exp;
  11. branches;
  12. next    1.1;
  13.  
  14. 1.1
  15. date    92.05.14.19.55.40;    author mwild;    state Exp;
  16. branches;
  17. next    ;
  18.  
  19.  
  20. desc
  21. @support for management of baserelative code (relocation of dataseg)
  22. @
  23.  
  24.  
  25. 1.2
  26. log
  27. @if out of memory, exit. There's no reason to continue, the programs would
  28. just plain crash...
  29. @
  30. text
  31. @/*
  32.  *  This file is part of ixemul.library for the Amiga.
  33.  *  Copyright (C) 1991, 1992  Markus M. Wild
  34.  *
  35.  *  This library is free software; you can redistribute it and/or
  36.  *  modify it under the terms of the GNU Library General Public
  37.  *  License as published by the Free Software Foundation; either
  38.  *  version 2 of the License, or (at your option) any later version.
  39.  *
  40.  *  This library is distributed in the hope that it will be useful,
  41.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  42.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  43.  *  Library General Public License for more details.
  44.  *
  45.  *  You should have received a copy of the GNU Library General Public
  46.  *  License along with this library; if not, write to the Free
  47.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  48.  *
  49.  *  $Id: ix_resident.c,v 1.1 1992/05/14 19:55:40 mwild Exp $
  50.  *
  51.  *  $Log: ix_resident.c,v $
  52.  *  Revision 1.1  1992/05/14  19:55:40  mwild
  53.  *  Initial revision
  54.  *
  55.  */
  56.  
  57. #define KERNEL
  58. #include "ixemul.h"
  59. #include <sys/exec.h>
  60.  
  61. #undef DEBUG
  62. #ifdef DEBUG
  63. #define DP(a) kprintf a
  64. #else
  65. #define DP(a)
  66. #endif
  67.  
  68.  
  69. void
  70. ix_resident (int numpar, int a4, int databss_size, long *relocs)
  71. {
  72.   /* for now, only a4 management is supported. relocation is for later, 
  73.      and isn't defined yet */
  74.  
  75.   if ((numpar == 3 || numpar == 4) && databss_size)
  76.     {
  77.       int mem = syscall (SYS_malloc, databss_size);
  78.       if (! mem)
  79.         {
  80.       ix_panic ("Out of memory, not purified.");
  81.       _exit (20);
  82.     }
  83.       else
  84.     {
  85.       int origmem = a4 - 0x7ffe;
  86.  
  87.       bcopy (origmem, mem, databss_size);
  88.  
  89. DP(("Relocating area $%lx -> $%lx ($%lx)\n", origmem, mem, databss_size));
  90.       
  91.       if (numpar == 4 && relocs[0] > 0)
  92.         {
  93.           int i, num_rel = relocs[0];
  94.           
  95.           for (i = 0, relocs++; i < num_rel; i++, relocs++)
  96.         {
  97. DP(("  [%lx] $%lx -> ", *relocs, *(long *)(mem + *relocs)));
  98.               *(long *)(mem + *relocs) -= origmem - mem;
  99. DP(("$%lx\n", *(long *)(mem + *relocs)));
  100.             }
  101.         }
  102.  
  103.       a4 = mem + 0x7ffe;
  104.     }
  105.     }
  106.  
  107.   
  108.   if (numpar >= 2 && numpar <= 4)
  109.     {
  110.       /* need output parameter, or the asm is optimized away */
  111.       asm volatile ("movel %0, a4" : "=g" (a4) : "0" (a4));
  112.       
  113.       u.u_a4 = a4;
  114.     }
  115.   else
  116.     ix_panic ("Unsupported ix_resident call.");
  117. }
  118.  
  119. int
  120. ix_geta4 ()
  121. {
  122.   asm volatile ("movel %0, a4" : "=g" (u.u_a4) : "0" (u.u_a4));
  123. }
  124.  
  125. void
  126. ix_check_cpu (int machtype)
  127. {
  128.   if (machtype == MID_SUN020)
  129.     {
  130.       if (!((*(struct ExecBase **)4)->AttnFlags & AFF_68020))
  131.     {
  132.       ix_panic ("This program requires at least a 68020 cpu.");
  133.       syscall (SYS_exit, 20);
  134.     }
  135.     }
  136. }
  137. @
  138.  
  139.  
  140. 1.1
  141. log
  142. @Initial revision
  143. @
  144. text
  145. @d19 1
  146. a19 1
  147.  *  $Id$
  148. d21 4
  149. a24 1
  150.  *  $Log$
  151. d49 4
  152. a52 1
  153.     ix_panic ("Out of memory, not purified.");
  154. @
  155.