/*
** ppc.library emulation
** (c)1998-99 Frank Wille <frank@phoenix.owl.de>
**
** Private C includes
**
** V0.6  (10.04.1999) phx
**       MPSemaphore protects the LibBase from reserved0 on.
** V0.5d (10.04.1999) phx
**       Security buffer at end of library base.
**       PortList.
**       MPSemaphore LibMPS replaces all M68k- and PPC-specific
**       semaphores. This will hopefully allow read/write access for
**       both CPUs on all data.
**       Pad-bytes for longword alignment after List structures.
** V0.5b (12.02.1999) phx
**       Moved Ext_UserData into Task.
** V0.5a (26.01.1999) phx
**       Ext_UserData, used by PPCSet/GetAttr PPCTASKTAG_EXTUSERDATA.
** V0.5  (23.01.1999) phx
**       Internal ELFLoadSegPatch. Library memory pool.
** V0.4c (20.01.1999) phx
**       ELF-library support.
**       TaskObjects contains a list of all PowerUp task, launched by
**       the 68k or the PPC. It should be modified from 68k only.
** V0.4b (05.01.1999) phx
**       TimerObject Server task. Support for TimerObjects and signals.
** V0.4  (21.11.1998) phx
**       Infos about PowerPC will be determined on startup. New fields:
**       ppc_PVR, ppc_BusClock, ppc_CPUClock.
** V0.1  (15.11.1998) phx
**       First partially working ppc.library emulation. Synchronous PPC
**       tasks, started by runelf, which only use the basic PowerUp kernel
**       functions for I/O, memory and context-switch seem to work fine.
**       Supported 68k functions:
**        PPCLoadObject,PPCUnloadObject,PPCRunObject,PPCAllocMem,PPCFreeMem,
**        PPCAllocVec,PPCFreeVec,PPCCreateTask(only synchronous),
**        PPCGetObjectAttrs,PPCLoadObjectTagList
**       Supported PowerUp kernel functions:
**        PPCAllocMem,PPCAllocPooled(dummy),PPCAllocVec,
**        PPCAllocVecPooled(dummy),PPCCallM68k,PPCCallOS,PPCClose,
**        PPCCreatePool(dummy),PPCDeletePool(dummy),PPCFreeMem,
**        PPCFreePooled(dummy),PPCFreeVec,PPCFreeVecPooled(dummy),
**        PPCOpen,PPCRead,PPCSeek,PPCWrite
**       Pooled memory functions currently use the normal Alloc/FreeVec
**       functions, because pooled memory support is still missing in WarpOS.
** V0.0  (31.10.1998) phx
**       created
*/

#ifndef PPCLIBEMU_H
#define PPCLIBEMU_H

#include <stdarg.h>
#include <exec/types.h>
#include <exec/lists.h>
#include <exec/libraries.h>
#include <exec/execbase.h>
#include <dos/dos.h>
#include <utility/tagitem.h>
#include <utility/hooks.h>
#include <powerpc/powerpc.h>
#include <powerpc/tasksPPC.h>
#include "mpsema.h"


/* The Library base structure */
struct PPCLibBase {
  struct Library libnode;
  UWORD Flags;
  BPTR SegList;
  APTR WOSLinkerDB;  /* <-- Offset 40 must not change! TOC-pointer for r2 */
  ULONG ppc_PVR;
  ULONG ppc_BusClock;
  ULONG ppc_CPUClock;
  struct ExecBase *SysBase;
  struct PPCBase *PowerPCBase;          /* Offset 60! Don't move! */
  struct Library *DOSBase;
  struct Library *UtilityBase;
  struct Library *IntuitionBase;
  void *LibPool;                        /* Memory Pool for library alloc. */
  UBYTE reserved0[32];
  struct List ElfObjects;               /* all loaded ELF objects */
  UBYTE reserved1[2];
  struct List TaskObjects;              /* all PowerUp tasks */
  UBYTE reserved2[34];
  struct MPSemaphore LibMPS;            /* LibBase CPU access arbitration */
  UBYTE reserved3[32];
  /* PowerPC-only data below! */
  struct TaskPPC *TimerObjSrv;          /* PPC TimerObject Server Task */
  struct List ElfLibraries;             /* all loaded ELF libraries */
  UBYTE reserved4[2];
  struct List PortList;                 /* global PPC MsgPorts */
  UBYTE reserved5[34];
};

#define PPCLibB_AllErrors 0             /* show requesters for all errors */
#define PPCLibF_AllErrors 1
#define PPCLibB_Debug 15                /* debugging mode (serial port) */
#define PPCLibF_Debug (1<<15)


#ifdef __PPC__
#include "inlineppc.h"
#else
#include "inline68k.h"
#endif


#endif /* PPCLIBEMU_H */
