home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / exec / initresident.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  2.5 KB  |  105 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: initresident.c,v 1.5 1996/10/24 15:50:51 aros Exp $
  4.     $Log: initresident.c,v $
  5.     Revision 1.5  1996/10/24 15:50:51  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.4  1996/08/13 13:56:03  digulla
  9.     Replaced AROS_LA by AROS_LHA
  10.     Replaced some AROS_LH*I by AROS_LH*
  11.     Sorted and added includes
  12.  
  13.     Revision 1.3  1996/08/01 17:41:12  digulla
  14.     Added standard header for all files
  15.  
  16.     Desc:
  17.     Lang:
  18. */
  19. #include <dos/dos.h>
  20. #include <aros/asmcall.h>
  21. #include "exec_intern.h"
  22.  
  23. /*****************************************************************************
  24.  
  25.     NAME */
  26.     #include <exec/resident.h>
  27.     #include <clib/exec_protos.h>
  28.  
  29. AROS_LH2(APTR, InitResident,
  30.  
  31. /*  SYNOPSIS */
  32.     AROS_LHA(struct Resident *, resident, A1),
  33.     AROS_LHA(BPTR,              segList,  D1),
  34.  
  35. /* LOCATION */
  36.     struct ExecBase *, SysBase, 17, Exec)
  37.  
  38. /*  FUNCTION
  39.     Test the resident structure and build the library or device
  40.     with the information given therein. The Init() vector is
  41.     called and the base address returned.
  42.  
  43.     INPUTS
  44.     resident - Pointer to resident structure.
  45.     segList  - Pointer to loaded module, 0 for resident modules.
  46.  
  47.     RESULT
  48.     A pointer to the library or device ready to add to the exec lists.
  49.  
  50.     NOTES
  51.  
  52.     EXAMPLE
  53.  
  54.     BUGS
  55.  
  56.     SEE ALSO
  57.  
  58.     INTERNALS
  59.  
  60.     HISTORY
  61.  
  62. ******************************************************************************/
  63. {
  64.     AROS_LIBFUNC_INIT
  65.  
  66.     /* Check for validity */
  67.     if(resident->rt_MatchWord!=RTC_MATCHWORD||
  68.        resident->rt_MatchTag!=resident)
  69.     return NULL;
  70.  
  71.     /* Depending on the autoinit flag... */
  72.     if(resident->rt_Flags&RTF_AUTOINIT)
  73.     {
  74.     /* ...initialize automatically... */
  75.     struct init
  76.     {
  77.         ULONG dSize;
  78.         APTR vectors;
  79.         APTR structure;
  80.         ULONG_FUNC init;
  81.     };
  82.     struct init *init=(struct init *)resident->rt_Init;
  83.     struct Library *library;
  84.     library=MakeLibrary(init->vectors,init->structure,
  85.                 init->init,init->dSize,segList);
  86.     if(library!=NULL)
  87.     {
  88.         library->lib_Node.ln_Type=resident->rt_Type;
  89.         library->lib_Node.ln_Name=resident->rt_Name;
  90.         library->lib_Version     =resident->rt_Version;
  91.         library->lib_IdString    =resident->rt_IdString;
  92.     }
  93.     return library;
  94.     }
  95.     else
  96.     /* ...or let the library do it. */
  97.     return AROS_UFC3(struct Library *,resident->rt_Init,
  98.         AROS_UFCA(ULONG,0L,D0),
  99.         AROS_UFCA(BPTR,segList,A0),
  100.         AROS_UFCA(struct ExecBase *,SysBase,A6)
  101.     );
  102.  
  103.     AROS_LIBFUNC_EXIT
  104. } /* InitResident */
  105.