1 #ifndef POWERUP_PPCLIB_TASKS_H 2 #define POWERUP_PPCLIB_TASKS_H 3 4 /************************************************** 5 * 6 * 7 * PPCCreateTask() Tags 8 * 9 * 10 **************************************************/ 11 12 #define PPCTASKTAG_DUMMY (TAG_USER + 0x20000) 13 14 /* ElfObject which discribes the PPC program 15 * Needed to start one. 16 */ 17 #define PPCTASKTAG_ELFOBJECT (PPCTASKTAG_DUMMY + 0x1) 18 19 /* Name of the new Task. */ 20 #define PPCTASKTAG_NAME (PPCTASKTAG_DUMMY + 0x2) 21 22 /* First Argument..gpr3 */ 23 #define PPCTASKTAG_ARG1 (PPCTASKTAG_DUMMY + 0x3) 24 25 /* First Argument..gpr4 */ 26 #define PPCTASKTAG_ARG2 (PPCTASKTAG_DUMMY + 0x4) 27 28 /* First Argument..gpr5 */ 29 #define PPCTASKTAG_ARG3 (PPCTASKTAG_DUMMY + 0x5) 30 31 /* First Argument..gpr6 */ 32 #define PPCTASKTAG_ARG4 (PPCTASKTAG_DUMMY + 0x6) 33 34 /* First Argument..gpr7 */ 35 #define PPCTASKTAG_ARG5 (PPCTASKTAG_DUMMY + 0x7) 36 37 /* First Argument..gpr8 */ 38 #define PPCTASKTAG_ARG6 (PPCTASKTAG_DUMMY + 0x8) 39 40 /* First Argument..gpr9 */ 41 #define PPCTASKTAG_ARG7 (PPCTASKTAG_DUMMY + 0x9) 42 43 /* First Argument..gpr10 */ 44 #define PPCTASKTAG_ARG8 (PPCTASKTAG_DUMMY + 0xa) 45 46 /* Default=TRUE means that the cacheflush is handled automaticly 47 * You need cacheflushs when you use OS functions to share data. 48 * If you know it better than the stupid cacheflush routine you 49 * can handle that yourself and optimize your routines. 50 */ 51 52 #define PPCTASKTAG_CACHEFLUSH (PPCTASKTAG_DUMMY + 0xb) 53 54 /* Ptr to an ULONG Errorfield where a better error description 55 * can be stored. 56 */ 57 58 #define PPCTASKTAG_ERROR (PPCTASKTAG_DUMMY + 0xc) 59 60 /* PPC Stacksize...Default 8192 61 * Supported by PowerUP's PPCGetTaskAttr() (V45) 62 */ 63 #define PPCTASKTAG_STACKSIZE (PPCTASKTAG_DUMMY + 0xd) 64 65 /* Task Priority..Default 0 */ 66 #define PPCTASKTAG_PRIORITY (PPCTASKTAG_DUMMY + 0xe) 67 68 /* Input Handle..Default Open("Nil:") 69 * The handle is closed when the PPC task completes 70 */ 71 #define PPCTASKTAG_INPUTHANDLE (PPCTASKTAG_DUMMY + 0xf) 72 73 /* Output Handle..Default Open("Nil:") 74 * The handle is closed when the PPC task completes 75 */ 76 #define PPCTASKTAG_OUTPUTHANDLE (PPCTASKTAG_DUMMY + 0x10) 77 78 /* Error Handle..Default Open("Nil:") 79 * The handle is closed when the PPC task completes 80 */ 81 #define PPCTASKTAG_ERRORHANDLE (PPCTASKTAG_DUMMY + 0x11) 82 83 /* 84 * When you set this Tag the Task is stopped 85 * before the first instruction is executed 86 * Only useful for debuggers 87 */ 88 #define PPCTASKTAG_STOPTASK (PPCTASKTAG_DUMMY + 0x12) 89 90 /* ExceptionHook 91 * The M68k Hook is called when a PPC TaskObject gets an 92 * exception which can be processor or software(Kernel Msg) 93 * related. 94 * That`s the way the ppc.library calls the Hook: 95 * 96 * BOOL CallHookPkt(hook,TaskObject,ExceptionMsg); 97 * 98 * The Hook Function is NOT allowed to call PPCLibBase 99 * functions to avoid deadlocks. 100 * And after the Hook function returns the ExceptionMsg 101 * contents IS NOT valid anymore. 102 * So you should copy the ExceptionMsg contents to a private 103 * buffer and then signal your debugger control task about 104 * the event. 105 * The Hook return BOOL should tell the ppc.library if all 106 * worked fine. 107 */ 108 109 #define PPCTASKTAG_EXCEPTIONHOOK (PPCTASKTAG_DUMMY + 0x13) 110 111 112 /* If you want that the PPCTask gets a MsgPort you can tell 113 * PPCCreateTask by a TRUE that you want one. 114 * I made this optional because it may cause an initial speed 115 * loss if you only need a ppc task for a quick run job where 116 * the init latency may be a serious issue. 117 * Supported by PowerUP's PPCGetTaskAttr() 118 */ 119 #define PPCTASKTAG_MSGPORT (PPCTASKTAG_DUMMY + 0x14) 120 121 /* If you wanna provide the ppc a startup msg. This msg will 122 * be replied by the ppc.library after the PPC Task ends so 123 * you can use this to know that the PPCTask is gone so a 124 * PPCUnloadObject() is save now. 125 * Supported by PowerUP's PPCGetTaskAttr() 126 */ 127 #define PPCTASKTAG_STARTUP_MSG (PPCTASKTAG_DUMMY + 0x15) 128 129 /* The Data field for the PPCMessage 130 * Supported by PowerUP's PPCGetTaskAttr() 131 */ 132 #define PPCTASKTAG_STARTUP_MSGDATA (PPCTASKTAG_DUMMY + 0x16) 133 /* The Length field for the PPCMessage 134 * Supported by PowerUP's PPCGetTaskAttr() 135 */ 136 #define PPCTASKTAG_STARTUP_MSGLENGTH (PPCTASKTAG_DUMMY + 0x17) 137 /* The MsgID field for the PPCMessage 138 * Supported by PowerUP's PPCGetTaskAttr() 139 */ 140 #define PPCTASKTAG_STARTUP_MSGID (PPCTASKTAG_DUMMY + 0x18) 141 /* The flag to activate the CTRL-C;D;E;F gateway to 142 * the PPC Task by PPCSignalTask(); 143 */ 144 #define PPCTASKTAG_BREAKSIGNAL (PPCTASKTAG_DUMMY + 0x19) 145 146 147 /* The CPU number the task should start on. 148 * This is only a hint and no gurantee. 149 */ 150 #define PPCTASKTAG_CPUHINT (PPCTASKTAG_DUMMY + 0x1a) 151 152 /* Ptr to ixemul UserData 153 * ONLY supported by PowerUP's PPCGetTaskAttr(),PPCSetTaskAttr() 154 */ 155 #define PPCTASKTAG_EXTUSERDATA (PPCTASKTAG_DUMMY + 0x1b) 156 157 158 159 /* Run Task Synchron Flag which means that the PPCCreateTask 160 * doesn`t return until the task completes and the return 161 * value is not the TaskObject but the Task`s return value. 162 * To check if the task runned correctly check out the 163 * PPCTASKTAG_ERROR fieldptr. 164 * With this Tag you can do the same what the old RunTaskObject 165 * does which interface is a bit limited(compatibility to the 166 * first ppc.library version) 167 */ 168 169 #define PPCTASKTAG_WAITFINISH (PPCTASKTAG_DUMMY + 0x31) 170 171 /* 172 * PPCTASKTAG_ERROR types 173 */ 174 175 #define ERROR_OK 0 176 #define ERROR_MEMORY 1 177 #define ERROR_NOPC 2 178 #define ERROR_CREATEMSGINTASK 3 179 #define ERROR_INPUTHANDLE 4 180 #define ERROR_OUTPUTHANDLE 5 181 #define ERROR_ERRORHANDLE 6 182 183 184 185 186 /************************************************** 187 * 188 * 189 * PPCGetTaskAttrs(), PPCSetTaskAttrs() Tags 190 * 191 * 192 **************************************************/ 193 194 /* 195 * V45 adds the ti_Data data Set/Get passing if it`s possible 196 */ 197 198 199 #define PPCTASKINFOTAG_DUMMY (TAG_USER + 0x21000) 200 /* (Get) */ 201 #define PPCTASKINFOTAG_NAME (PPCTASKINFOTAG_DUMMY + 0x1) 202 /* (Get/Set) */ 203 #define PPCTASKINFOTAG_PRIORITY (PPCTASKINFOTAG_DUMMY + 0x2) 204 /* (Get/Set) */ 205 #define PPCTASKINFOTAG_CACHEFLUSH (PPCTASKINFOTAG_DUMMY + 0x3) 206 /* (Get) */ 207 #define PPCTASKINFOTAG_STACKSIZE (PPCTASKINFOTAG_DUMMY + 0x4) 208 /* (Get) */ 209 #define PPCTASKINFOTAG_STATE (PPCTASKINFOTAG_DUMMY + 0x5) 210 /* (Get/Set) */ 211 #define PPCTASKINFOTAG_TASK (PPCTASKINFOTAG_DUMMY + 0x6) 212 213 /* This means the HOOK function is called for every Task */ 214 #define PPCTASKINFOTAG_ALLTASK (PPCTASKINFOTAG_DUMMY + 0x7) 215 216 /* Hook function which is called for a task so you can ask special fields 217 * you may want to use. 218 * Msg Parameter is NULL for now. 219 * Object Parameter is the TaskObject 220 * 221 * HookFunc(Hook, TaskObject, NULL) 222 */ 223 #define PPCTASKINFOTAG_HOOK (PPCTASKINFOTAG_DUMMY + 0x8) 224 225 /* (Get) */ 226 #define PPCTASKINFOTAG_SIGALLOC (PPCTASKINFOTAG_DUMMY + 0x9) 227 /* (Get) */ 228 #define PPCTASKINFOTAG_SIGWAIT (PPCTASKINFOTAG_DUMMY + 0xa) 229 /* (Get) */ 230 #define PPCTASKINFOTAG_SIGRECVD (PPCTASKINFOTAG_DUMMY + 0xb) 231 /* (Get) */ 232 #define PPCTASKINFOTAG_USEDSTACKSIZE (PPCTASKINFOTAG_DUMMY + 0xc) 233 /* (Get/Set) */ 234 #define PPCTASKINFOTAG_INPUTHANDLE (PPCTASKINFOTAG_DUMMY + 0xd) 235 /* (Get/Set) */ 236 #define PPCTASKINFOTAG_OUTPUTHANDLE (PPCTASKINFOTAG_DUMMY + 0xe) 237 /* (Get/Set) */ 238 #define PPCTASKINFOTAG_ERRORHANDLE (PPCTASKINFOTAG_DUMMY + 0xf) 239 240 /* Return the ElfObject of a Task 241 * (Get) 242 * (V45) 243 */ 244 245 #define PPCTASKINFOTAG_ELFOBJECT (PPCTASKINFOTAG_DUMMY + 0x10) 246 247 /* See equal PPCTASKTAG_EXCEPTIONHOOK 248 * (V45) 249 * (Set) 250 */ 251 252 #define PPCTASKINFOTAG_EXCEPTIONHOOK (PPCTASKINFOTAG_DUMMY + 0x11) 253 254 /* Tell the task to stop at the first instruction. 255 * Only allowed to be used when you get a TaskHookMsg 256 * with the MethodID PPCTASKHOOKMETHOD_CREATE. 257 * It must not be called while a PPC Task runs. 258 * (V45) 259 * (Set) 260 */ 261 #define PPCTASKINFOTAG_STOPTASK (PPCTASKINFOTAG_DUMMY + 0x12) 262 263 264 /* See equal PPCTASKTAG_MSGPORT 265 * (V45) 266 */ 267 #define PPCTASKINFOTAG_MSGPORT (PPCTASKINFOTAG_DUMMY + 0x13) 268 269 /* See equal PPCTASKTAG_STARTUP_MSG 270 * (V45) 271 */ 272 #define PPCTASKINFOTAG_STARTUP_MSG (PPCTASKINFOTAG_DUMMY + 0x14) 273 274 /* See equal PPCTASKTAG_STARTUP_MSGDATA 275 * (V45) 276 */ 277 #define PPCTASKINFOTAG_STARTUP_MSGDATA (PPCTASKINFOTAG_DUMMY + 0x15) 278 279 /* See equal PPCTASKTAG_STARTUP_MSGLENGTH 280 * (V45) 281 */ 282 #define PPCTASKINFOTAG_STARTUP_MSGLENGTH (PPCTASKINFOTAG_DUMMY + 0x16) 283 284 /* See equal PPCTASKTAG_STARTUP_MSGID 285 * (V45) 286 */ 287 #define PPCTASKINFOTAG_STARTUP_MSGID (PPCTASKINFOTAG_DUMMY + 0x17) 288 289 290 /* 291 * All Register Tags only accept Ptrs at ti_Data so I don`t have to 292 * change the API when there`s a 64Bit PPC some time. 293 */ 294 295 /* SRR0=PC 296 * Get/Set through ti_Data or PPCTASKINFOTAG_VALUEPTR 297 * (Get/Set) 298 */ 299 #define PPCTASKINFOTAG_PC (PPCTASKINFOTAG_DUMMY + 0x20) 300 301 /* SRR1=MSR 302 * Get/Set through ti_Data or PPCTASKINFOTAG_VALUEPTR 303 * (Get/Set) 304 */ 305 #define PPCTASKINFOTAG_MSR (PPCTASKINFOTAG_DUMMY + 0x21) 306 307 /* 32bit value in function Result 308 * Get/Set through ti_Data 309 * (Get/Set) 310 */ 311 #define PPCTASKINFOTAG_CR (PPCTASKINFOTAG_DUMMY + 0x22) 312 313 /* 32bit value in function Result 314 * Get/Set through ti_Data 315 * (Get/Set) 316 */ 317 #define PPCTASKINFOTAG_XER (PPCTASKINFOTAG_DUMMY + 0x23) 318 319 /* Result by PPCTASKINFOTAG_VALUEPTR 320 * Get/Set through ti_Data or PPCTASKINFOTAG_VALUEPTR 321 * (Get/Set) 322 */ 323 #define PPCTASKINFOTAG_LR (PPCTASKINFOTAG_DUMMY + 0x24) 324 325 /* Result by PPCTASKINFOTAG_VALUEPTR 326 * Get/Set through ti_Data or PPCTASKINFOTAG_VALUEPTR 327 * (Get/Set) 328 */ 329 #define PPCTASKINFOTAG_CTR (PPCTASKINFOTAG_DUMMY + 0x25) 330 331 /* Result by PPCTASKINFOTAG_VALUEPTR 332 * Get/Set through ti_Data or PPCTASKINFOTAG_VALUEPTR 333 * (Get/Set) 334 */ 335 #define PPCTASKINFOTAG_FPSCR (PPCTASKINFOTAG_DUMMY + 0x26) 336 337 /* ti_Data=Register Number 338 * Get/Set through PPCTASKINFOTAG_VALUEPTR 339 * (Get/Set) 340 */ 341 #define PPCTASKINFOTAG_GPR (PPCTASKINFOTAG_DUMMY + 0x30) 342 343 /* ti_Data=Register Number 344 * Get/Set through PPCTASKINFOTAG_VALUEPTR 345 * (Get/Set) 346 */ 347 #define PPCTASKINFOTAG_FPR (PPCTASKINFOTAG_DUMMY + 0x31) 348 349 /* Address where to read/write the register value from. 350 * I use a ptr to be size indepent with the registers 351 * (Get/Set) 352 */ 353 #define PPCTASKINFOTAG_VALUEPTR (PPCTASKINFOTAG_DUMMY + 0x32) 354 355 356 /* With PPCTASKINFOTAG_WAITFINISHTASK 357 * it returns the parent process in which you created 358 * a synchron PPC Task. Synchron PPC Task`s are created 359 * with the PPCTASKTAG_WAITINFISH,TRUE or outdated a 360 * PPCRunObject. 361 * The reason for this function is to find the shell 362 * task easily and check for a CTRL-C for example. 363 * (Get) 364 * (V45) 365 */ 366 #define PPCTASKINFOTAG_WAITFINISHTASK (PPCTASKTAG_DUMMY + 0x33) 367 368 369 370 /************************************************** 371 * 372 * 373 * TaskObject ExceptionHook 374 * 375 * 376 **************************************************/ 377 378 379 struct ExceptionMsg 380 { 381 ULONG Version; 382 ULONG Type; 383 ULONG GPR[32]; 384 DOUBLE FPR[32]; 385 ULONG SR[16]; 386 ULONG CR; 387 DOUBLE FPSCR; 388 ULONG XER; 389 ULONG LR; 390 ULONG CTR; 391 ULONG PVR; 392 ULONG IBAT0U; 393 ULONG IBAT0L; 394 ULONG IBAT1U; 395 ULONG IBAT1L; 396 ULONG IBAT2U; 397 ULONG IBAT2L; 398 ULONG IBAT3U; 399 ULONG IBAT3L; 400 401 ULONG DBAT0U; 402 ULONG DBAT0L; 403 ULONG DBAT1U; 404 ULONG DBAT1L; 405 ULONG DBAT2U; 406 ULONG DBAT2L; 407 ULONG DBAT3U; 408 ULONG DBAT3L; 409 410 ULONG SDR1; 411 ULONG ASR; 412 413 ULONG DAR; 414 ULONG DSISR; 415 ULONG SRR0; 416 ULONG SRR1; 417 418 ULONG SPRG0; 419 ULONG SPRG1; 420 ULONG SPRG2; 421 ULONG SPRG3; 422 423 ULONG TBL; 424 ULONG TBU; 425 ULONG DEC; 426 ULONG DABR; 427 428 /* 603 special registers */ 429 430 ULONG DMISS; 431 ULONG DCMP; 432 ULONG HASH1; 433 ULONG HASH2; 434 ULONG IMISS; 435 ULONG ICMP; 436 ULONG RPA; 437 438 /* 604e special registers */ 439 440 /* Version 0 ends here */ 441 442 ULONG MSR; 443 444 /* Version 1 ends here */ 445 446 /* Size depends on Version */ 447 }; 448 449 /* Current supported Version 450 */ 451 452 #define EXCEPTIONMSG_VERSION 1 453 454 /* 455 * Current supported Types 456 */ 457 458 /* 459 * These are the processor exceptions 460 */ 461 462 #define EXCEPTION_UNKNOWN 0 /* Won`t happen */ 463 #define EXCEPTION_RESET 1 /* Won`t happen */ 464 #define EXCEPTION_MACHINECHECK 2 /* Won`t happen */ 465 #define EXCEPTION_DATAACCESS 3 466 #define EXCEPTION_INSTRUCTIONACCESS 4 467 #define EXCEPTION_EXTERNALINTERRUPT 5 /* Won`t happen */ 468 #define EXCEPTION_ALIGNMENT 6 469 #define EXCEPTION_PROGRAM 7 470 #define EXCEPTION_FPUUNAVAILABLE 8 471 #define EXCEPTION_DECREMENTER 9 472 #define EXCEPTION_INTERFACEERROR 10 473 #define EXCEPTION_RESERVED_B 11 474 #define EXCEPTION_SYSTEMCALL 12 475 #define EXCEPTION_TRACE 13 476 #define EXCEPTION_FPUASSIST 14 477 #define EXCEPTION_RESERVED_F 15 478 #define EXCEPTION_IMISS 16 479 #define EXCEPTION_DLOADMISS 17 480 #define EXCEPTION_DSTOREMISS 18 481 #define EXCEPTION_IADDRESSBREAK 19 482 #define EXCEPTION_SYSTEMMANAGEMENTINT 20 483 484 485 /* 486 * These are the kernel exceptions 487 * to signal certain events 488 */ 489 490 #define EXCEPTION_MSG 0x80000000 491 492 /* 493 * You receive this exception type 494 * when the Kernel could stop a Task 495 * successfully after a Stop or Trace 496 * operation. 497 * Look at PPCTASKTAG_STOPTASK for example 498 */ 499 500 #define EXCEPTION_STOPTASK (EXCEPTION_MSG + 0x0) 501 502 /* 503 * You receive this exception type 504 * when the task completes. 505 * In this case the ONLY valid fields in the 506 * ExceptionMsg are the Version field and the 507 * the Message type. 508 */ 509 510 #define EXCEPTION_FINISHTASK (EXCEPTION_MSG + 0x1) 511 512 513 /************************************************** 514 * 515 * 516 * PPCStartTask() Tags 517 * 518 * 519 **************************************************/ 520 521 #define PPCTASKSTARTTAG_DUMMY (TAG_USER + 0x22000) 522 523 /* Just run a Task again 524 * ti_Data=BOOL 525 */ 526 #define PPCTASKSTARTTAG_RUN (PPCTASKSTARTTAG_DUMMY + 0x0) 527 528 /* Single Step the next instruction 529 * ti_Data=BOOL 530 */ 531 #define PPCTASKSTARTTAG_TRACE (PPCTASKSTARTTAG_DUMMY + 0x1) 532 533 /* Branch until a Trace instruction 534 * Processor dependent 535 * ti_Data=BOOL 536 * NOT SUPPORTED YET 537 */ 538 #define PPCTASKSTARTTAG_BRANCHTRACE (PPCTASKSTARTTAG_DUMMY + 0x2) 539 540 /* Run until Instruction hit 541 * the Breakpoint Address 542 * Processor dependent 543 * ti_Data=BOOL 544 * NOT SUPPORTED YET 545 */ 546 #define PPCTASKSTARTTAG_IBREAK (PPCTASKSTARTTAG_DUMMY + 0x3) 547 548 /* Run until DataAccess hit 549 * the Breakpoint Address 550 * Processor dependent 551 * ti_Data=BOOL 552 * NOT SUPPORTED YET 553 */ 554 #define PPCTASKSTARTTAG_DBREAK (PPCTASKSTARTTAG_DUMMY + 0x4) 555 556 #endif