Deleted Added
sdiff udiff text old ( 3832:49c95a73e29c ) new ( 3833:b5faabcf350e )
full compact
1/*
2 * Copyright (c) 2001-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;

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

343 TLB::writeTagAccess(tc, MISCREG_MMU_DTLB_TAG_ACCESS, va, context);
344}
345
346
347
348Fault
349ITB::translate(RequestPtr &req, ThreadContext *tc)
350{
351 uint64_t hpstate = tc->readMiscReg(MISCREG_HPSTATE);
352 uint64_t pstate = tc->readMiscReg(MISCREG_PSTATE);
353 bool lsuIm = tc->readMiscReg(MISCREG_MMU_LSU_CTRL) >> 2 & 0x1;
354 uint64_t tl = tc->readMiscReg(MISCREG_TL);
355 uint64_t part_id = tc->readMiscReg(MISCREG_MMU_PART_ID);
356 bool addr_mask = pstate >> 3 & 0x1;
357 bool priv = pstate >> 2 & 0x1;
358 Addr vaddr = req->getVaddr();
359 int context;
360 ContextType ct;
361 int asi;
362 bool real = false;
363 TlbEntry *e;
364
365 DPRINTF(TLB, "TLB: ITB Request to translate va=%#x size=%d\n",
366 vaddr, req->getSize());
367 DPRINTF(TLB, "TLB: pstate: %#X hpstate: %#X lsudm: %#X part_id: %#X\n",
368 pstate, hpstate, lsuIm, part_id);
369
370 assert(req->getAsi() == ASI_IMPLICIT);
371
372 if (tl > 0) {
373 asi = ASI_N;
374 ct = Nucleus;
375 context = 0;
376 } else {
377 asi = ASI_P;
378 ct = Primary;
379 context = tc->readMiscReg(MISCREG_MMU_P_CONTEXT);
380 }
381
382 if ( hpstate >> 2 & 0x1 || hpstate >> 5 & 0x1 ) {
383 req->setPaddr(req->getVaddr() & PAddrImplMask);
384 return NoFault;
385 }
386
387 // If the asi is unaligned trap
388 if (vaddr & req->getSize()-1) {
389 writeSfsr(tc, false, ct, false, OtherFault, asi);
390 return new MemAddressNotAligned;
391 }
392
393 if (addr_mask)
394 vaddr = vaddr & VAddrAMask;
395
396 if (!validVirtualAddress(vaddr, addr_mask)) {
397 writeSfsr(tc, false, ct, false, VaOutOfRange, asi);
398 return new InstructionAccessException;
399 }
400
401 if (!lsuIm) {
402 e = lookup(req->getVaddr(), part_id, true);
403 real = true;
404 context = 0;
405 } else {
406 e = lookup(vaddr, part_id, false, context);
407 }
408
409 if (e == NULL || !e->valid) {

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

428}
429
430
431
432Fault
433DTB::translate(RequestPtr &req, ThreadContext *tc, bool write)
434{
435 /* @todo this could really use some profiling and fixing to make it faster! */
436 uint64_t hpstate = tc->readMiscReg(MISCREG_HPSTATE);
437 uint64_t pstate = tc->readMiscReg(MISCREG_PSTATE);
438 bool lsuDm = tc->readMiscReg(MISCREG_MMU_LSU_CTRL) >> 3 & 0x1;
439 uint64_t tl = tc->readMiscReg(MISCREG_TL);
440 uint64_t part_id = tc->readMiscReg(MISCREG_MMU_PART_ID);
441 bool hpriv = hpstate >> 2 & 0x1;
442 bool red = hpstate >> 5 >> 0x1;
443 bool addr_mask = pstate >> 3 & 0x1;
444 bool priv = pstate >> 2 & 0x1;
445 bool implicit = false;
446 bool real = false;
447 Addr vaddr = req->getVaddr();
448 Addr size = req->getSize();
449 ContextType ct = Primary;
450 int context = 0;
451 ASI asi;
452
453 TlbEntry *e;
454
455 asi = (ASI)req->getAsi();
456 DPRINTF(TLB, "TLB: DTB Request to translate va=%#x size=%d asi=%#x\n",
457 vaddr, size, asi);
458 DPRINTF(TLB, "TLB: pstate: %#X hpstate: %#X lsudm: %#X part_id: %#X\n",
459 pstate, hpstate, lsuDm, part_id);
460 if (asi == ASI_IMPLICIT)
461 implicit = true;
462
463 if (implicit) {
464 if (tl > 0) {
465 asi = ASI_N;
466 ct = Nucleus;
467 context = 0;
468 } else {
469 asi = ASI_P;
470 ct = Primary;
471 context = tc->readMiscReg(MISCREG_MMU_P_CONTEXT);
472 }
473 } else if (!hpriv && !red) {
474 if (tl > 0 || AsiIsNucleus(asi)) {
475 ct = Nucleus;
476 context = 0;
477 } else if (AsiIsSecondary(asi)) {
478 ct = Secondary;
479 context = tc->readMiscReg(MISCREG_MMU_S_CONTEXT);
480 } else {
481 context = tc->readMiscReg(MISCREG_MMU_P_CONTEXT);
482 ct = Primary; //???
483 }
484
485 // We need to check for priv level/asi priv
486 if (!priv && !AsiIsUnPriv(asi)) {
487 // It appears that context should be Nucleus in these cases?
488 writeSfr(tc, vaddr, write, Nucleus, false, IllegalAsi, asi);
489 return new PrivilegedAction;
490 }
491 if (priv && AsiIsHPriv(asi)) {
492 writeSfr(tc, vaddr, write, Nucleus, false, IllegalAsi, asi);
493 return new DataAccessException;
494 }
495
496 } else if (hpriv) {
497 if (asi == ASI_P) {
498 ct = Primary;
499 context = tc->readMiscReg(MISCREG_MMU_P_CONTEXT);
500 goto continueDtbFlow;
501 }
502 }
503
504 if (!implicit) {
505 if (AsiIsLittle(asi))
506 panic("Little Endian ASIs not supported\n");
507 if (AsiIsBlock(asi))

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

542 vaddr = vaddr & VAddrAMask;
543
544 if (!validVirtualAddress(vaddr, addr_mask)) {
545 writeSfr(tc, vaddr, false, ct, true, VaOutOfRange, asi);
546 return new DataAccessException;
547 }
548
549
550 if ((!lsuDm && !hpriv) || AsiIsReal(asi)) {
551 real = true;
552 context = 0;
553 };
554
555 if (hpriv && (implicit || (!AsiIsAsIfUser(asi) && !AsiIsReal(asi)))) {
556 req->setPaddr(req->getVaddr() & PAddrImplMask);
557 return NoFault;
558 }

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

635 return NoFault;
636};
637
638Tick
639DTB::doMmuRegRead(ThreadContext *tc, Packet *pkt)
640{
641 Addr va = pkt->getAddr();
642 ASI asi = (ASI)pkt->req->getAsi();
643
644 DPRINTF(IPR, "Memory Mapped IPR Read: asi=%#X a=%#x\n",
645 (uint32_t)pkt->req->getAsi(), pkt->getAddr());
646
647 switch (asi) {
648 case ASI_LSU_CONTROL_REG:
649 assert(va == 0);
650 pkt->set(tc->readMiscRegWithEffect(MISCREG_MMU_LSU_CTRL));

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

718 pkt->set(0);
719 break;
720 case ASI_HYP_SCRATCHPAD:
721 case ASI_SCRATCHPAD:
722 pkt->set(tc->readMiscRegWithEffect(MISCREG_SCRATCHPAD_R0 + (va >> 3)));
723 break;
724 case ASI_IMMU:
725 switch (va) {
726 case 0x30:
727 pkt->set(tc->readMiscRegWithEffect(MISCREG_MMU_ITLB_TAG_ACCESS));
728 break;
729 default:
730 goto doMmuReadError;
731 }
732 break;
733 case ASI_DMMU:
734 switch (va) {
735 case 0x30:
736 pkt->set(tc->readMiscRegWithEffect(MISCREG_MMU_DTLB_TAG_ACCESS));
737 break;
738 case 0x80:
739 pkt->set(tc->readMiscRegWithEffect(MISCREG_MMU_PART_ID));
740 break;
741 default:
742 goto doMmuReadError;
743 }
744 break;
745 default:
746doMmuReadError:
747 panic("need to impl DTB::doMmuRegRead() got asi=%#x, va=%#x\n",
748 (uint32_t)asi, va);
749 }
750 pkt->result = Packet::Success;
751 return tc->getCpuPtr()->cycles(1);
752}

--- 209 unchanged lines hidden ---