home *** CD-ROM | disk | FTP | other *** search
- #include <ata.h>
- #include <string.h>
- #include "CDControl.h"
-
- static bool gActiveQ = false;
- static bool gDoneQ = false;
- static ataPB gPB;
- static ATAPICmdPacket gPacket;
-
- OSErr SetupATAPI(UInt32 nDeviceID)
- {
- OSErr theResult = noErr;
-
- if(not gActiveQ){
- gActiveQ = true;
-
- memset(&gPB,0,sizeof(gPB));
- memset(&gPacket,0,sizeof(gPacket));
-
- gPB.ataIOParamBlock.ataPBVers = 3;
- gPB.ataIOParamBlock.ataPBFunctionCode = 1;
- gPB.ataIOParamBlock.ataPBIOSpeed = 4;
- gPB.ataIOParamBlock.ataPBFlags = 0x0020;
- gPB.ataIOParamBlock.ataPBDeviceID = nDeviceID;
- gPB.ataIOParamBlock.ataPBTimeOut = 0x2710;
-
- gPB.ataIOParamBlock.ataPBStatusRegister = 0x50;
- gPB.ataIOParamBlock.ataPBLogicalBlockSize = 0x200;
-
- gPB.ataIOParamBlock.ataPBActualTxCount = 0x12;
-
- gPB.ataIOParamBlock.ataPBTaskFile.ataTFSDH = 0xA0;
- gPB.ataIOParamBlock.ataPBTaskFile.ataTFCommand = 0xA0;
- gPB.ataIOParamBlock.ataPBPacketPtr = &gPacket;
-
- gPacket.atapiPacketSize = 12;
- gPacket.atapiCommandByte[0] = 0x1b00;
- gPacket.atapiCommandByte[2] = 0x0200;
-
- }
- return theResult;
- }
-
- void StopIt()
- {
- gActiveQ = false;
- }
-
- OSErr xJect(bool bOpen)
- {
-
- OSErr theResult;
-
- if(gActiveQ)
- {
- if(!bOpen)
- {
- gPacket.atapiCommandByte[2] = 0x0300; // 0x0300 INject Command
- }
- else
- {
- gPacket.atapiCommandByte[2] = 0x0200; // 0x0200 Eject Command
- }
- gDoneQ = false;
- theResult = ataManager(&gPB);
- }
- return theResult;
- }
-
-