Deleted Added
sdiff udiff text old ( 5891:73084c6bb183 ) new ( 5894:8091ac99341a )
full compact
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 90 unchanged lines hidden (view full) ---

99void
100TimingSimpleCPU::CpuPort::TickEvent::schedule(PacketPtr _pkt, Tick t)
101{
102 pkt = _pkt;
103 cpu->schedule(this, t);
104}
105
106TimingSimpleCPU::TimingSimpleCPU(TimingSimpleCPUParams *p)
107 : BaseSimpleCPU(p), icachePort(this, p->clock), dcachePort(this, p->clock), fetchEvent(this)
108{
109 _status = Idle;
110
111 icachePort.snoopRangeSent = false;
112 dcachePort.snoopRangeSent = false;
113
114 ifetch_pkt = dcache_pkt = NULL;
115 drainEvent = NULL;

--- 141 unchanged lines hidden (view full) ---

257 } else {
258 _status = DcacheWaitResponse;
259 // memory system takes ownership of packet
260 dcache_pkt = NULL;
261 }
262 return dcache_pkt == NULL;
263}
264
265Fault
266TimingSimpleCPU::buildSplitPacket(PacketPtr &pkt1, PacketPtr &pkt2,
267 RequestPtr &req, Addr split_addr, uint8_t *data, bool read)
268{
269 Fault fault;
270 RequestPtr req1, req2;
271 assert(!req->isLocked() && !req->isSwap());
272 req->splitOnVaddr(split_addr, req1, req2);
273
274 pkt1 = pkt2 = NULL;
275 if ((fault = buildPacket(pkt1, req1, read)) != NoFault ||
276 (fault = buildPacket(pkt2, req2, read)) != NoFault) {
277 delete req;
278 delete req1;
279 delete pkt1;
280 req = NULL;
281 pkt1 = NULL;
282 return fault;
283 }
284
285 assert(!req1->isMmapedIpr() && !req2->isMmapedIpr());
286
287 req->setPhys(req1->getPaddr(), req->getSize(), req1->getFlags());
288 PacketPtr pkt = new Packet(req, pkt1->cmd.responseCommand(),
289 Packet::Broadcast);
290 if (req->getFlags().isSet(Request::NO_ACCESS)) {
291 delete req1;
292 delete pkt1;
293 delete req2;
294 delete pkt2;
295 pkt1 = pkt;
296 pkt2 = NULL;
297 return NoFault;
298 }
299
300 pkt->dataDynamic<uint8_t>(data);
301 pkt1->dataStatic<uint8_t>(data);
302 pkt2->dataStatic<uint8_t>(data + req1->getSize());
303
304 SplitMainSenderState * main_send_state = new SplitMainSenderState;
305 pkt->senderState = main_send_state;
306 main_send_state->fragments[0] = pkt1;
307 main_send_state->fragments[1] = pkt2;
308 main_send_state->outstanding = 2;
309 pkt1->senderState = new SplitFragmentSenderState(pkt, 0);
310 pkt2->senderState = new SplitFragmentSenderState(pkt, 1);
311 return fault;
312}
313
314Fault
315TimingSimpleCPU::buildPacket(PacketPtr &pkt, RequestPtr &req, bool read)
316{
317 Fault fault = thread->dtb->translateAtomic(req, tc, !read);
318 MemCmd cmd;
319 if (fault != NoFault) {
320 delete req;
321 req = NULL;
322 pkt = NULL;
323 return fault;
324 } else if (read) {
325 cmd = MemCmd::ReadReq;
326 if (req->isLocked())
327 cmd = MemCmd::LoadLockedReq;
328 } else {
329 cmd = MemCmd::WriteReq;
330 if (req->isLocked()) {
331 cmd = MemCmd::StoreCondReq;
332 } else if (req->isSwap()) {
333 cmd = MemCmd::SwapReq;
334 }
335 }
336 pkt = new Packet(req, cmd, Packet::Broadcast);
337 return NoFault;
338}
339
340template <class T>
341Fault
342TimingSimpleCPU::read(Addr addr, T &data, unsigned flags)
343{
344 Fault fault;
345 const int asid = 0;
346 const int thread_id = 0;
347 const Addr pc = thread->readPC();
348 int block_size = dcachePort.peerBlockSize();
349 int data_size = sizeof(T);
350
351 PacketPtr pkt;
352 RequestPtr req = new Request(asid, addr, data_size,
353 flags, pc, _cpuId, thread_id);
354
355 Addr split_addr = roundDown(addr + data_size - 1, block_size);
356 assert(split_addr <= addr || split_addr - addr < block_size);
357
358 if (split_addr > addr) {
359 PacketPtr pkt1, pkt2;
360 Fault fault = this->buildSplitPacket(pkt1, pkt2, req,
361 split_addr, (uint8_t *)(new T), true);
362 if (fault != NoFault)
363 return fault;
364 if (req->getFlags().isSet(Request::NO_ACCESS)) {
365 dcache_pkt = pkt1;
366 } else if (handleReadPacket(pkt1)) {
367 SplitFragmentSenderState * send_state =
368 dynamic_cast<SplitFragmentSenderState *>(pkt1->senderState);
369 send_state->clearFromParent();
370 if (handleReadPacket(pkt2)) {
371 send_state =
372 dynamic_cast<SplitFragmentSenderState *>(pkt1->senderState);
373 send_state->clearFromParent();
374 }
375 }
376 } else {
377 Fault fault = buildPacket(pkt, req, true);
378 if (fault != NoFault) {
379 return fault;
380 }
381 if (req->getFlags().isSet(Request::NO_ACCESS)) {
382 dcache_pkt = pkt;
383 } else {
384 pkt->dataDynamic<T>(new T);
385 handleReadPacket(pkt);
386 }
387 }
388
389 if (traceData) {
390 traceData->setData(data);
391 traceData->setAddr(addr);
392 }
393
394 // This will need a new way to tell if it has a dcache attached.

--- 84 unchanged lines hidden (view full) ---

479 int data_size = sizeof(T);
480
481 RequestPtr req = new Request(asid, addr, data_size,
482 flags, pc, _cpuId, thread_id);
483
484 Addr split_addr = roundDown(addr + data_size - 1, block_size);
485 assert(split_addr <= addr || split_addr - addr < block_size);
486
487 if (split_addr > addr) {
488 PacketPtr pkt1, pkt2;
489 T *dataP = new T;
490 *dataP = data;
491 Fault fault = this->buildSplitPacket(pkt1, pkt2, req, split_addr,
492 (uint8_t *)dataP, false);
493 if (fault != NoFault)
494 return fault;
495 dcache_pkt = pkt1;
496 if (!req->getFlags().isSet(Request::NO_ACCESS)) {
497 if (handleWritePacket()) {
498 SplitFragmentSenderState * send_state =
499 dynamic_cast<SplitFragmentSenderState *>(
500 pkt1->senderState);
501 send_state->clearFromParent();
502 dcache_pkt = pkt2;
503 if (handleReadPacket(pkt2)) {
504 send_state =
505 dynamic_cast<SplitFragmentSenderState *>(
506 pkt1->senderState);
507 send_state->clearFromParent();
508 }
509 }
510 }
511 } else {
512 bool do_access = true; // flag to suppress cache access
513
514 Fault fault = buildPacket(dcache_pkt, req, false);
515 if (fault != NoFault)
516 return fault;
517
518 if (!req->getFlags().isSet(Request::NO_ACCESS)) {
519 if (req->isLocked()) {
520 do_access = TheISA::handleLockedWrite(thread, req);
521 } else if (req->isCondSwap()) {
522 assert(res);
523 req->setExtraData(*res);
524 }
525
526 dcache_pkt->allocate();
527 if (req->isMmapedIpr())
528 dcache_pkt->set(htog(data));
529 else
530 dcache_pkt->set(data);
531
532 if (do_access)
533 handleWritePacket();
534 }
535 }
536
537 if (traceData) {
538 traceData->setAddr(req->getVaddr());
539 traceData->setData(data);
540 }
541
542 // This will need a new way to tell if it's hooked up to a cache or not.

--- 72 unchanged lines hidden (view full) ---

615
616 checkPcEventQueue();
617
618 bool fromRom = isRomMicroPC(thread->readMicroPC());
619
620 if (!fromRom) {
621 Request *ifetch_req = new Request();
622 ifetch_req->setThreadContext(_cpuId, /* thread ID */ 0);
623 Fault fault = setupFetchRequest(ifetch_req);
624
625 ifetch_pkt = new Packet(ifetch_req, MemCmd::ReadReq, Packet::Broadcast);
626 ifetch_pkt->dataStatic(&inst);
627
628 if (fault == NoFault) {
629 if (!icachePort.sendTiming(ifetch_pkt)) {
630 // Need to wait for retry
631 _status = IcacheRetry;
632 } else {
633 // Need to wait for cache to respond
634 _status = IcacheWaitResponse;
635 // ownership of packet transferred to memory system
636 ifetch_pkt = NULL;
637 }
638 } else {
639 delete ifetch_req;
640 delete ifetch_pkt;
641 // fetch fault: advance directly to next instruction (fault handler)
642 advanceInst(fault);
643 }
644 } else {
645 _status = IcacheWaitResponse;
646 completeIfetch(NULL);
647 }
648
649 numCycles += tickToCycles(curTick - previousTick);
650 previousTick = curTick;
651}
652
653
654void

--- 39 unchanged lines hidden (view full) ---

694
695 preExecute();
696 if (curStaticInst &&
697 curStaticInst->isMemRef() && !curStaticInst->isDataPrefetch()) {
698 // load or store: just send to dcache
699 Fault fault = curStaticInst->initiateAcc(this, traceData);
700 if (_status != Running) {
701 // instruction will complete in dcache response callback
702 assert(_status == DcacheWaitResponse || _status == DcacheRetry);
703 assert(fault == NoFault);
704 } else {
705 if (fault == NoFault) {
706 // Note that ARM can have NULL packets if the instruction gets
707 // squashed due to predication
708 // early fail on store conditional: complete now
709 assert(dcache_pkt != NULL || THE_ISA == ARM_ISA);
710
711 fault = curStaticInst->completeAcc(dcache_pkt, this,
712 traceData);
713 if (dcache_pkt != NULL)
714 {
715 delete dcache_pkt->req;
716 delete dcache_pkt;
717 dcache_pkt = NULL;
718 }
719
720 // keep an instruction count
721 if (fault == NoFault)
722 countInst();
723 } else if (traceData) {
724 // If there was a fault, we shouldn't trace this instruction.
725 delete traceData;
726 traceData = NULL;
727 }
728
729 postExecute();
730 // @todo remove me after debugging with legion done
731 if (curStaticInst && (!curStaticInst->isMicroop() ||

--- 106 unchanged lines hidden (view full) ---

838 return;
839 } else {
840 delete main_send_state;
841 big_pkt->senderState = NULL;
842 pkt = big_pkt;
843 }
844 }
845
846 assert(_status == DcacheWaitResponse);
847 _status = Running;
848
849 Fault fault = curStaticInst->completeAcc(pkt, this, traceData);
850
851 // keep an instruction count
852 if (fault == NoFault)
853 countInst();
854 else if (traceData) {

--- 165 unchanged lines hidden ---