/*
** ppc.library emulation
** (c)1998-99 Frank Wille <frank@phoenix.owl.de>
**
** Multi Processor Semaphore
**
** V0.5d (03.04.1999) phx
**       Created.
*/

#ifndef MPSEMA_H
#define MPSEMA_H

#ifndef EXEC_SEMAPHORES_H
#include <exec/semaphores.h>
#endif

#ifndef POWERPC_SEMAPHORESPPC_H
#include <powerpc/semaphoresPPC.h>
#endif


struct CPUSemaphore {
  /* This structure has to be allocated in non-cachable memory */
  /* (Chip-RAM in our case). It will guarantee the mutual exclusion */
  /* of the two CPUs and is written by both of them. */
  UWORD cpuid;                  /* 0=M68k, 1=PPC */
  UBYTE interested[2];
};

#define MPS_CPU68K 0
#define MPS_CPUPPC 1


struct MPSemaphore {
  void *data;                           /* data-structure and length, */
  ULONG length;                         /*  which has to be protected */
  struct SignalSemaphore *m68kSS;       /* M68k task access arbitration */
  struct SignalSemaphorePPC *ppcSS;     /* PPC task access arbitration */
  struct CPUSemaphore *cpuSS;           /* CPU arbitration (68k or PPC) */
};

/* WARNING: Make sure the data to be protected is 32-bytes aligned */
/* in size and in position! */


#endif /* MPSEMA_H */
