#if 0 cd [file dirname [info script]] source makefile.tcl return #endif #include "ohci.h" #include "uart.h" const U32 selfIdBufSize=2*1024; const U32 bufSize=256; U8 * const selfIdBuf=(U8 *)0x00100000; OhciDescriptor::OutputLastImmediate * const oli=(OhciDescriptor::OutputLastImmediate *)(selfIdBuf+selfIdBufSize); OhciDescriptor::InputMore * const im=(OhciDescriptor::InputMore *)(oli+1); U8 * const buf= (U8*)(im+1); int waitQuadletInit(Ohci *ohci) { bClear(selfIdBuf,selfIdBufSize); ohci->selfIdPointer->all=(U32)selfIdBuf; ohci->linkControl->set->all=ohci->linkControl->set->cycleTimerEnable.mask(); im->init(); im->reqCount=bufSize; im->resCount=bufSize; im->dataAddress=(U32)buf; im->branchAddress=0; bClear(buf,bufSize); asm("wbinvd"); ohci->arRequestProgram->dmaContext->all=(U32)im; ohci->arRequestProgram->dmaContext->z=1; ohci->arRequestProgram->contextControl->set->all=ohci->arRequestProgram->contextControl->set->run.mask(); ohci->asynchronousRequestFilterHi->set->all=ohci->asynchronousRequestFilterHi->set->asynReqResourceAll.mask(); return 0; }; U32 quadletWriteRequestReceive(Ohci *ohci,Ieee1394::QuadletWriteRequestReceive *qwrr) { com1<<"writeQuadlet "<< qwrr->data <<"\r\n"; return 0; } U32 blockWriteRequestReceive(Ohci *ohci,Ieee1394::BlockWriteRequestReceive *bwrr) { com1<<"writeBlock\r\n"; com1.dump((U8*)bwrr->datas,bwrr->dataLength); return 0; } U32 quadletReadRequestReceive(Ohci *ohci,Ieee1394::QuadletReadRequestReceive *qrrr) { Ieee1394::QuadletReadResponseTransmit *qrrt; Ieee1394::PacketReceiveTail* prt; qrrt=(Ieee1394::QuadletReadResponseTransmit *)(U32*)oli->quadlets; prt=(Ieee1394::PacketReceiveTail*)(qrrr+1); ohci->atResponseProgram->contextControl->clear->all=ohci->atResponseProgram->contextControl->set->run.mask(); com1<<"readQuadlet "<<(U32)qrrr->tLabel<<"\r\n"; oli->init(); oli->reqCount=16; oli->branchAddress=0; //oli->timeStamp=(1<<13)+(U32)prt->timeStamp; oli->timeStamp=(1<<13)+(U32)ohci->isochronousCycleTimer->timeStamp; qrrt->speed=2; qrrt->tLabel=(U32)qrrr->tLabel; qrrt->rt=1; qrrt->tCode=6; qrrt->rCode=0; qrrt->srcBusId=0; qrrt->dstBusId=(U32)qrrr->srcBusId; //qrrt->dstBusId=(U32)0xffc1; qrrt->data=0xdeadbeaf; asm("wbinvd"); ohci->atResponseProgram->dmaContext->all=(U32)oli; ohci->atResponseProgram->dmaContext->z=2; ohci->atResponseProgram->contextControl->set->all=ohci->atResponseProgram->contextControl->set->run.mask(); return 0; } U32 blockReadRequestReceive(Ohci *ohci,Ieee1394::BlockReadRequestReceive *) { com1<<"readBlock\r\n"; return 0; } U32 otherRequestReceive(Ohci *ohci,Ieee1394::PacketReceiveRequest *) { com1<<"other\r\n"; return 0; } typedef U32 (*RequestReceive)(Ohci *ohci,Ieee1394::PacketReceiveRequest * prr); //typedef U32 (*RequestReceive)(Ohci *ohci,void* prr); RequestReceive const tCodes[]= { (RequestReceive)quadletWriteRequestReceive, (RequestReceive)blockWriteRequestReceive, otherRequestReceive, otherRequestReceive, (RequestReceive)quadletReadRequestReceive, (RequestReceive)blockReadRequestReceive, otherRequestReceive, otherRequestReceive, otherRequestReceive, otherRequestReceive, otherRequestReceive, otherRequestReceive, otherRequestReceive, otherRequestReceive, otherRequestReceive, otherRequestReceive }; int waitQuadletPoll(Ohci *ohci) { U32 got; com1<< "wait ... "; while(1) { asm("invd"); got=im->reqCount-im->resCount; if(!got) continue; Ieee1394::PacketReceiveRequest *prr; prr=(Ieee1394::PacketReceiveRequest *)(U32)im->dataAddress; com1<srcBusId<<" dst :"<<(U32)prr->dstBusId << "\r\n"; com1<<"address : "<< (U32)prr->dstOffsetHi << ' ' << (U32)prr->dstOffsetLo << "\r\n"; tCodes[prr->tCode](ohci,prr); im->dataAddress+=got; im->reqCount-=got; } return 0; };