Esempio n. 1
0
// **************************************************************************
// **************************************************************************
// vma <a>
int P4_vmaccess(int argc, char* argv[])
{
	unsigned short int adr, rpt, upt;

	adr = INTEGER(argv[1]);
	printf(" = %04x", getMemAdr(adr, 1)-&MEMWORD(0));
	printf("\nRPTI:%d(0x%x) UPTI:%d(0x%x) OFFSET:%d(0x%x)", RPTI(adr)/2, RPTI(adr), UPTI(adr)/2, UPTI(adr), FRAMEOFFSET(adr), FRAMEOFFSET(adr));

	for (rpt = 0; rpt < 64; rpt+=2)
	{
		if (MEMWORD(rpt+TASK_RPT) || MEMWORD(rpt+TASK_RPT+1))
		{
			outPTE("  RPT  =", rpt+TASK_RPT);
			for(upt = 0; upt < 64; upt+=2)
			{
				if (DEFINED(MEMWORD(rpt+TASK_RPT)) &&
					(DEFINED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt))
					|| PAGED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt+1))))
				{
					outPTE("    UPT=", (FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt);
				}
			}
		}
	}
	printf("\nPages = %d", nextPage);
	return 0;
} // end P4_vmaccess
Esempio n. 2
0
void swapOutFrame(int entry1Index)
{
    // clear the definition bit in entry 1 probably just set entry 1 to 0
    int entry1, entry2;

    entry1 = memory[entry1Index];
    entry2 = memory[entry1Index + 1];

    // if dirty bit is not set and swap exists we are done
    if (DIRTY(entry1) && PAGED(entry2)) {
        DEBUG_STATEMENT(DEBUG_MMU,"\nDirty copy of swap write to old page");
        // if swap exits swap access page with old write
        accessPage(SWAPPAGE(entry2), FRAME(entry1), PAGE_OLD_WRITE);
    } else if (!PAGED(entry2)) {
        DEBUG_STATEMENT(DEBUG_MMU,"\nNo copy in swap write to new swap");
        // if swap doesn't exist then we need to write out to an new write
        memory[entry1Index + 1] = entry2 = SET_PAGED(nextPage);
        accessPage(nextPage, FRAME(entry1), PAGE_NEW_WRITE);
    }

    if (DEBUG_MMU) { outPTE("\nSwapped Entry - (Pre-clear) ", entry1Index); }
    memory[entry1Index] = 0;
    if (DEBUG_MMU) { outPTE("Swapped Entry - ", entry1Index); }

    return;
}
Esempio n. 3
0
// **************************************************************************
// **************************************************************************
// vma <a>
int P4_vmaccess(int argc, char* argv[])
{
	unsigned short int adr, rpt, upt;

	printf("\nValidate arguments...");	// ?? validate arguments
	adr = INTEGER(argv[1]);

	printf(" = %04x", getMemAdr(adr, 1)-&MEMWORD(0));
	for (rpt = 0; rpt < 64; rpt+=2)
	{
		if (MEMWORD(rpt+TASK_RPT) || MEMWORD(rpt+TASK_RPT+1))
		{
			outPTE("  RPT  =", rpt+TASK_RPT);
			for(upt = 0; upt < 64; upt+=2)
			{
				if (DEFINED(MEMWORD(rpt+TASK_RPT)) &&
						(DEFINED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt))
								|| PAGED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt+1))))
				{
					outPTE("    UPT=", (FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt);
				}
			}
		}
	}
	printf("\nPages = %d", nextPage);
	return 0;
} // end P4_vmaccess
Esempio n. 4
0
void dump_rpt_and_upt()
{
  int rpt, upt;
  for (rpt = 0; rpt < 64; rpt+=2)
  {
    if (MEMWORD(rpt+TASK_RPT) || MEMWORD(rpt+TASK_RPT+1))
    {
      outPTE("  RPT  =", rpt+TASK_RPT);
      for(upt = 0; upt < 64; upt+=2)
      {
        if (DEFINED(MEMWORD(rpt+TASK_RPT)) &&(DEFINED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt))
                          || PAGED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt+1))))
        {
          outPTE("    UPT=", (FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt);
        }
      }
    }
  }
}
Esempio n. 5
0
// **************************************************************************
// **************************************************************************
// display page table entries
void displayPT(int pta, int badr, int inc)
{
	int i;
	char buf[32];

	for (i=0; i<32; i++)
	{
      sprintf(buf, "(x%04x-x%04x) ", badr+ i*inc, badr + ((i+1)*inc)-1);
		outPTE("", (pta + i*2));
	}

   return;
} // end displayPT
Esempio n. 6
0
int getClockFrame(int notme)
{
    int frame;

    // iterate through rpts (0x2400 - LC3_RPT_END)
    int maxWrap = 20;
    for (;maxWrap; cBigHand += 2, cLittleHand = 0) {
        int i;
        int rpte1;
        int upta, upte1;

        if (cBigHand >= LC3_RPT_END) {
            DEBUG_STATEMENT(DEBUG_MMU,"\nClock is wrapping");
            cBigHand = LC3_RPT;
            maxWrap--;
        }

        rpte1 = memory[cBigHand];

        if (DEFINED(rpte1) && REFERENCED(rpte1)) {
            // clear reference
            DEBUG_STATEMENT(DEBUG_MMU,"\nclearing ref for rpte");
            memory[cBigHand] = rpte1 = CLEAR_REF(rpte1);
        } else if (DEFINED(rpte1)) { // if one is non-referenced go to the user page table
            // scout out the upt!! note that this has not been referenced
            if (DEBUG_MMU) { outPTE("\nRPT entry being checked - ", cBigHand); }
            upta = (FRAME(rpte1)<<6);

            for (i = cLittleHand % 64; i < 64;i += 2, cLittleHand = i % 64) { // - iterate over userpage table
                upte1 = memory[upta + (i)];
                if (PINNED(upte1) || FRAME(upte1) == notme) {
                    DEBUG_STATEMENT(DEBUG_MMU,"\nupte1 frame was the notme frame (%x = %x) or pinned", FRAME(upte1), notme);
                    if (DEBUG_MMU) { outPTE("UPT entry being checked - ", upta + i); }

                    continue;
                }

                if (DEFINED(upte1) && REFERENCED(upte1)) { // - if entry is referenced un-reference and move on
                    // clear reference
                    DEBUG_STATEMENT(DEBUG_MMU,"\nclearing ref for upte %d", cLittleHand);
                    memory[cBigHand] = rpte1 = SET_PINNED(rpte1);
                    memory[upta + (i)] = upte1 = CLEAR_REF(upte1);
                } else if (DEFINED(upte1)) { // - otherwise prep it for being put into swap
                    // we can use the frame referenced by upte1
                    if (DEBUG_MMU) { outPTE("UPT entry being checked - ", upta + 1); }
                    DEBUG_STATEMENT(DEBUG_MMU,"\nUpte1 %x, Upte2 %x", upte1, memory[upta + (i + 1)]);
                    memory[cBigHand] = rpte1 = SET_DIRTY(rpte1);
                    frame = FRAME(upte1);
                    swapOutFrame(upta + i);
                    cLittleHand += 2;
                    DEBUG_STATEMENT(DEBUG_MMU,"\nFound a data frame that can be used! (%d, %x)", frame, frame);

                    return frame;
                }
            }

            cLittleHand = 0;
            if (!REFERENCED(rpte1) && !PINNED(rpte1) && FRAME(rpte1) != notme) { // if we only replaced or did nothing to upte entries
                // we can use the frame referenced by rpte1
                frame = FRAME(rpte1);

                DEBUG_STATEMENT(DEBUG_MMU,"\nFound a upt frame that can be used! (%d, %x)", frame, frame);
                swapOutFrame(cBigHand);
                cBigHand += 2;
                return frame;
            } else { // otherwise remove the pin flag
                memory[cBigHand] = rpte1 = CLEAR_PINNED(rpte1);
            }

        }
    } // when you get the bottom start at the top again

    DEBUG_STATEMENT(DEBUG_MMU,"\n No valid frame found notme = %d", notme);
    if (DEBUG_MMU) {  displayTableHierarchy(); }

    return -1;
}