1 #ifndef POWERUP_PPCLIB_INTERFACE_H
    2 #define POWERUP_PPCLIB_INTERFACE_H
    3 
    4 #include <exec/types.h>
    5 
    6 /*
    7  * Structure which is used on the PPC side to call
    8  * AmigaOS library functions or sub routines.
    9  *
   10  */
   11 
   12 /*****************************/
   13 /* About the CacheMode field */
   14 /*****************************/
   15 
   16 /*
   17  * For calling functions from the PPC under M68k AmigaOS or for
   18  * calling functions on the PPC Supervisor mode you have to care
   19  * for the cache issues. Please read the Cache chapter in the
   20  * docs/powerup.guide about the cache problems involved.
   21  * If you do something wrong here you can expect that you loose
   22  * data, get wrong data or simply crash the machine.
   23  *
   24  * IF_CACHEFLUSHNO:
   25  * You use this mode for the cpu if your function
   26  * touches no memory both cpus use.
   27  *
   28  * Example: Close(File)
   29  *          If you call this function by the PPC there`s no need
   30  *          to flush the cache because the PPC isn`t allowed to
   31  *          touch any memory which has to do with the File BPTR.
   32  * ATTENTION:
   33  *          The PPC MUST NOT be used to poke into AmigaOS system
   34  *          structures.
   35  *
   36  * IF_CACHEFLUSHALL:
   37  * You use this mode for the cpu if your function
   38  * touches memory both cpus use and it`s no simple memory area
   39  * which may be flushed individually. This should be used by default.
   40  *
   41  * Example: OpenWindowTagList(NewWindow,TagList)
   42  *          Here you pass a complex data structure which may use
   43  *          memory areas at several different areas.
   44  *
   45  * IF_CACHEFLUSHAREA:
   46  * You use this mode for the cpu if your function
   47  * touches memory both cpus use and it`s a memory area which isn`t
   48  * very big. It depends on the size and how many lines are dirty
   49  * if this is faster than IF_CACHEFLUSHALL.
   50  * With the Start and Length fields of each cpu you can define
   51  * the area.
   52  *
   53  * Example: Write(File,Address,Length)
   54  *          When the PPC runs this function the PPC must make sure
   55  *          that all data in the to be written memory area is in
   56  *          in the memory and not only in the cache.
   57  *
   58  * IF_CACHEINVALIDAREA: (V45)
   59  * You use this mode for the cpu if your function
   60  * touches memory both cpus use and it`s a memory area where you
   61  * don`t care for valid data anymore.
   62  * With the Start and Length fields of each cpu you can define
   63  * the area.
   64  *
   65  * Example: Read(File,Address,Length)
   66  *          When the PPC runs this function the PPC has no need
   67  *          anymore for anything which is in its cache for the
   68  *          area the Address and Length define, so you could
   69  *          invalidate this instead of doing a cacheflush which
   70  *          may write back dirty lines.
   71  *          Be VERY careful about this.
   72  *
   73  * ATTENTION! The Address must be 32Byte aligned, so you should always
   74  * use PPCAllocMem for data which is used on the M68k and PPC
   75  * You are NOT allowed to use normal pools for exchanging data between
   76  * the M68k and PPC.
   77  *
   78  * IF_ASYNC: (V45)
   79  * If you use this flag, the function is called asynchronous and
   80  * the PPC doesn`t have to wait for a result.
   81  * This flag is only checked in the M68kCacheMode field.
   82  * This also means that the result of the PPCCall#? function
   83  * is meaningless.
   84  * Normally this flag doesn`t really fit into a CacheMode flag, but
   85  * well..too bad i haven`t declared another flag field there.
   86  */
   87 
   88 struct Caos
   89 {
   90 	union
   91 	{
   92 		int	Offset;
   93 		APTR	Function;
   94 	} caos_Un;
   95 	ULONG	M68kCacheMode;
   96 	APTR	M68kStart;
   97 	ULONG	M68kLength;
   98 	ULONG	PPCCacheMode;
   99 	APTR	PPCStart;
  100 	ULONG	PPCLength;
  101 	ULONG	d0;
  102 	ULONG	d1;
  103 	ULONG	d2;
  104 	ULONG	d3;
  105 	ULONG	d4;
  106 	ULONG	d5;
  107 	ULONG	d6;
  108 	ULONG	d7;
  109 	ULONG	a0;
  110 	ULONG	a1;
  111 	ULONG	a2;
  112 	ULONG	a3;
  113 	ULONG	a4;
  114 	ULONG	a5;
  115 /*
  116  * here you have to put the LibBasePtr if you want
  117  * to call a Library.
  118  */
  119 	ULONG	a6;
  120 };
  121 
  122 #define	IF_CACHEFLUSHNO		0
  123 #define	IF_CACHEFLUSHALL	1
  124 #define	IF_CACHEFLUSHAREA	2
  125 #define	IF_CACHEINVALIDAREA	4
  126 #define	IF_ASYNC		0x10000
  127 
  128 
  129 
  130 /*
  131  * Structure which is used on the M68k side to run
  132  * a Kernel Supervisor ElfObject. During this time
  133  * the multitasking on the PPC stops
  134  * PPCRunKernelModule() ONLY !!!!!!!!!!!!!!!!!!!!!
  135  * If you set IF_CACHEASYNC in PPCCacheMode the operation
  136  * doesn`t return a valid result as it`s asynchron.
  137  */
  138 
  139 struct ModuleArgs
  140 {
  141 	ULONG	M68kCacheMode;
  142 	APTR	M68kStart;
  143 	ULONG	M68kLength;
  144 	ULONG	PPCCacheMode;
  145 	APTR	PPCStart;
  146 	ULONG	PPCLength;
  147 
  148 	ULONG	Arg1;	/* GPR3=C Integer Arg1  */
  149 	ULONG	Arg2;	/* GPR4=C Integer Arg2  */
  150 	ULONG	Arg3;	/* GPR5=C Integer Arg3  */
  151 	ULONG	Arg4;	/* GPR6=C Integer Arg4  */
  152 	ULONG	Arg5;	/* GPR7=C Integer Arg5  */
  153 	ULONG	Arg6;	/* GPR8=C Integer Arg6  */
  154 	ULONG	Arg7;	/* GPR9=C Integer Arg7  */
  155 	ULONG	Arg8;	/* GPR10=C Integer Arg8 */
  156 	DOUBLE	FArg1;	/* FPR1=C FPU Arg1 */
  157 	DOUBLE	FArg2;	/* FPR2=C FPU Arg2 */
  158 	DOUBLE	FArg3;	/* FPR3=C FPU Arg3 */
  159 	DOUBLE	FArg4;	/* FPR4=C FPU Arg4 */
  160 	DOUBLE	FArg5;	/* FPR5=C FPU Arg5 */
  161 	DOUBLE	FArg6;	/* FPR6=C FPU Arg6 */
  162 	DOUBLE	FArg7;	/* FPR7=C FPU Arg7 */
  163 	DOUBLE	FArg8;	/* FPR8=C FPU Arg8 */
  164 };
  165 
  166 #endif