home *** CD-ROM | disk | FTP | other *** search
- /*
- File: VBL.c
-
- Contains: A dcmd which displays onboard and slot-based VBL tasks.
-
- Written by: JM3 = Jim Murphy
- DAL = Dave Lyons
- sad = Scott Douglas
-
- Copyright: ⌐ 1988, 1993-1994, 1996 by Apple Computer, Inc., All Rights Reserved.
-
- Change History (most recent first):
-
- <4> 25-Jan-96 JM3 Updated the sample build commands to be current.
- <3> 11-Dec-94 JM3 Updated for new version 3 dcmd requirements. Removed the remnants of Dave's
- old wiggy brace style. Luckily, that habit has long since been broken. :-)
- <2> 9/9/93 DAL now displays all nonempty SlotVBL queues as well as the regular
- VBL queue; cleaned up the output
-
- Modification history:
- 2Dec88 sad written from VCB.
-
- The following MPW commands will build the dcmd and copy it to the "Debugger Prefs" file
- in the System folder. The dcmd's name in MacsBug will be the name of the file built by
- the Linker.
-
- C VBL.c
- Link -o VBL -sg Main=STDCLIB,STDIO,SANELIB dcmdGlue.a.o" Put.c.o" VBL.c.o" ╢
- "{Libraries}Runtime.o"
- BuildDcmd VBL 197 -format3
- Echo 'include "VBL";' | Rez -a -o "{SystemFolder}Debugger Prefs"
-
- TO DO
- -----
- identify the task's owner in some way
- */
-
- #include <Memory.h>
- #include <OSUtils.h>
- #include <Retrace.h>
- #include <Types.h>
-
- #include "dcmd.h"
- #include "put.h"
-
- #define VBLQueue ((QHdrPtr)0x160)
-
-
- static void DrawVBL(VBLTask* vblp)
- {
-
- PutUHexZTo((unsigned long)vblp,8,8);
- PutSpacesTo(10);
- PutUHexWord(vblp->vblCount);
- PutSpacesTo(17);
- PutUHexWord(vblp->vblPhase);
- PutSpacesTo(24);
- PutUHexZTo((unsigned long)vblp->vblAddr,8,27);
- PutLine();
-
- }
-
-
- void DumpOneVBLQueue(QHdrPtr theQueue, short slotNum, dcmdBlock* paramPtr)
- {
-
- VBLTask* vblp;
- int numvbls = 0;
-
- PutLine();
- PutPStr("\pVBL tasks");
- if(slotNum != -1)
- {
- PutPStr("\p for slot ");
- PutUDec(slotNum);
- }
-
- if (theQueue->qFlags & 0x4000)
- PutPStr("\p (queue executing)");
- else
- PutPStr("\p (queue not executing)");
- PutLine();
-
- vblp = (VBLTask*)(theQueue->qHead);
-
- // 1 2 3 4 5 6 7
- // 1234567890123456789012345678901234567890123456789012345678901234567890
- dcmdDrawLine("\p VBLTask Count Phase Code");
- dcmdDrawLine("\p ------- ----- ----- ----");
-
- while (vblp)
- {
- DrawVBL(vblp);
- numvbls++;
- if (paramPtr->aborted) break;
- if (vblp->qLink == 0)
- if (vblp != (VBLTask*)(theQueue->qTail))
- dcmdDrawLine("\pVBL queue does not end at VBLQueue.qTail");
- vblp = (VBLTask*)vblp->qLink;
- }
-
- PutUDec(numvbls);
- if(numvbls==1)
- PutPStr("\p VBL task");
- else
- PutPStr("\p VBL tasks");
- PutLine();
-
- }
-
-
- short GetQueueSize(QHdrPtr theQueue)
- {
-
- VBLTask* vblp;
- int count = 0;
-
- vblp = (VBLTask*)(theQueue->qHead);
-
- while (vblp)
- {
- count++;
- if(count>1000)
- return count; // avoid infinite loop if queue is hosed
- vblp = (VBLTask*)vblp->qLink;
- }
-
- return count;
-
- }
-
-
- pascal void CommandEntry(dcmdBlock* paramPtr)
- {
-
- static const char usageStr[] = "\p";
-
- switch (paramPtr->request)
- {
- case dcmdInit:
- break;
-
- case dcmdHelp:
- dcmdDrawLine("\pLists tasks in the regular and slot VBL queues.");
- break;
-
- case dcmdGetInfo:
- * (long *) &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->dcmdVersion = 0x03008000; // version 3.0 final
- BlockMoveData(&usageStr, &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->usageStr, usageStr[0]+1);
- break;
-
- case dcmdDoIt:
- {
- short slotNum;
- QHdrPtr *slotQueueArray = *(QHdrPtr **)0x0D04;
-
- dcmdSwapWorlds();
-
- DumpOneVBLQueue(VBLQueue,-1,paramPtr);
- for(slotNum=0; slotNum<=14; slotNum++)
- {
- if(GetQueueSize(slotQueueArray[slotNum]))
- DumpOneVBLQueue(slotQueueArray[slotNum], slotNum, paramPtr);
- }
-
- dcmdSwapWorlds();
- }
- break;
-
- // Version 3 and newer dcmds must quietly ignore requests we don't recognize.
-
- default:
- break;
- }
-
- }
-