OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_61/] [or1ksim/] [mmu/] [immu.c] - Diff between revs 74 and 102

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 74 Rev 102
Line 49... Line 49...
/* Number of usage states (2, 3, 4 etc., max is 4). */
/* Number of usage states (2, 3, 4 etc., max is 4). */
#define ITLB_USTATES 2
#define ITLB_USTATES 2
 
 
void itlb_info()
void itlb_info()
{
{
 
        if (!getsprbits(SPR_UPR, SPR_UPR_IMP)) {
 
                printf("IMMU not implemented. Set UPR[IMP].\n");
 
                return;
 
        }
 
 
        printf("Insn MMU %dKB: ", ITLB_SETS * ITLB_ENTRY_SIZE * ITLB_WAYS / 1024);
        printf("Insn MMU %dKB: ", ITLB_SETS * ITLB_ENTRY_SIZE * ITLB_WAYS / 1024);
        printf("%d ways, %d sets, entry size %d bytes\n", ITLB_WAYS, ITLB_SETS, ITLB_ENTRY_SIZE);
        printf("%d ways, %d sets, entry size %d bytes\n", ITLB_WAYS, ITLB_SETS, ITLB_ENTRY_SIZE);
}
}
 
 
/* First check if virtual address is covered by ITLB and if it is:
/* First check if virtual address is covered by ITLB and if it is:
Line 66... Line 71...
    - find lru way and entry and invoke ITLB miss exception handler
    - find lru way and entry and invoke ITLB miss exception handler
    - set 'lru' with ITLB_USTATES - 1 and decrement 'lru' of other
    - set 'lru' with ITLB_USTATES - 1 and decrement 'lru' of other
      ways unless they have reached 0
      ways unless they have reached 0
*/
*/
 
 
unsigned long itlb_status(int start_set)
void itlb_status(int start_set)
{
{
        int set;
        int set;
        int way;
        int way;
        int end_set = ITLB_SETS;
        int end_set = ITLB_SETS;
 
 
 
        if (!getsprbits(SPR_UPR, SPR_UPR_IMP)) {
 
                printf("IMMU not implemented. Set UPR[IMP].\n");
 
                return;
 
        }
 
 
        if ((start_set >= 0) && (start_set < end_set))
        if ((start_set >= 0) && (start_set < end_set))
                end_set = start_set + 1;
                end_set = start_set + 1;
        else
        else
                start_set = 0;
                start_set = 0;
 
 
Line 107... Line 117...
        int set, way = -1;
        int set, way = -1;
        int i;
        int i;
        unsigned long tagaddr;
        unsigned long tagaddr;
        unsigned long vpn;
        unsigned long vpn;
 
 
        if (! (mfspr(SPR_SR) & SPR_SR_IME))
        if (!(mfspr(SPR_SR) & SPR_SR_IME) || !(getsprbits(SPR_UPR, SPR_UPR_IMP)))
                return virtaddr;
                return virtaddr;
 
 
        /* Which set to check out? */
        /* Which set to check out? */
        set = (virtaddr / PAGE_SIZE) % ITLB_SETS;
        set = (virtaddr / PAGE_SIZE) % ITLB_SETS;
        tagaddr = (virtaddr / PAGE_SIZE) / ITLB_SETS;
        tagaddr = (virtaddr / PAGE_SIZE) / ITLB_SETS;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.