/kernel/trunk/arch/mips32/include/mm/asid.h |
---|
30,16 → 30,9 |
#define __mips32_ASID_H__ |
#include <arch/types.h> |
#include <typedefs.h> |
#define ASIDS 256 |
#define ASID_INVALID 0 |
#define ASID_START 1 |
#define ASID_MAX_ARCH 255 |
typedef __u8 asid_t; |
extern asid_t asid_get(void); |
extern void asid_put(asid_t asid); |
extern bool asid_has_conflicts(asid_t asid); |
#endif |
/kernel/trunk/arch/mips32/Makefile.inc |
---|
51,7 → 51,12 |
CONFIG_PAGE_PT = y |
## Compile with support for address space identifiers. |
# |
CONFIG_ASID = y |
## Accepted MACHINEs |
# |
/kernel/trunk/arch/mips32/src/mm/asid.c |
---|
28,93 → 28,5 |
*/ |
#include <arch/mm/asid.h> |
#include <synch/spinlock.h> |
#include <arch.h> |
#include <debug.h> |
#include <typedefs.h> |
SPINLOCK_INITIALIZE(asid_usage_lock); |
static count_t asid_usage[ASIDS]; /**< Usage tracking array for ASIDs */ |
/** Get ASID |
* |
* Get the least used ASID. |
* |
* @return ASID |
*/ |
asid_t asid_get(void) |
{ |
ipl_t ipl; |
int i, j; |
count_t min; |
min = (unsigned) -1; |
ipl = interrupts_disable(); |
spinlock_lock(&asid_usage_lock); |
for (i = ASID_START, j = ASID_START; i < ASIDS; i++) { |
if (asid_usage[i] < min) { |
j = i; |
min = asid_usage[i]; |
if (!min) |
break; |
} |
} |
asid_usage[j]++; |
spinlock_unlock(&asid_usage_lock); |
interrupts_restore(ipl); |
return i; |
} |
/** Release ASID |
* |
* Release ASID by decrementing its usage count. |
* |
* @param asid ASID. |
*/ |
void asid_put(asid_t asid) |
{ |
ipl_t ipl; |
ipl = interrupts_disable(); |
spinlock_lock(&asid_usage_lock); |
ASSERT(asid != ASID_INVALID); |
ASSERT(asid_usage[asid] > 0); |
asid_usage[asid]--; |
spinlock_unlock(&asid_usage_lock); |
interrupts_restore(ipl); |
} |
/** Find out whether ASID is used by more address spaces |
* |
* Find out whether ASID is used by more address spaces. |
* |
* @param asid ASID in question. |
* |
* @return True if 'asid' is used by more address spaces, false otherwise. |
*/ |
bool asid_has_conflicts(asid_t asid) |
{ |
bool has_conflicts = false; |
ipl_t ipl; |
ASSERT(asid != ASID_INVALID); |
ipl = interrupts_disable(); |
spinlock_lock(&asid_usage_lock); |
if (asid_usage[asid] > 1) |
has_conflicts = true; |
spinlock_unlock(&asid_usage_lock); |
interrupts_restore(ipl); |
return has_conflicts; |
} |
/kernel/trunk/arch/mips32/src/mm/tlb.c |
---|
27,7 → 27,7 |
*/ |
#include <arch/mm/tlb.h> |
#include <arch/mm/asid.h> |
#include <mm/asid.h> |
#include <mm/tlb.h> |
#include <mm/page.h> |
#include <mm/as.h> |
494,13 → 494,15 |
cp0_entry_hi_write(hi_save.value); |
} |
/** Invalidate TLB entry for specified page belonging to specified address space. |
/** Invalidate TLB entries for specified page range belonging to specified address space. |
* |
* @param asid Address space identifier. |
* @param page Page whose TLB entry is to be invalidated. |
* @param page First page whose TLB entry is to be invalidated. |
* @param cnt Number of entries to invalidate. |
*/ |
void tlb_invalidate_page(asid_t asid, __address page) |
void tlb_invalidate_pages(asid_t asid, __address page, count_t cnt) |
{ |
int i; |
ipl_t ipl; |
entry_lo_t lo0, lo1; |
entry_hi_t hi, hi_save; |
511,8 → 513,9 |
hi_save.value = cp0_entry_hi_read(); |
ipl = interrupts_disable(); |
for (i = 0; i < cnt; i++) { |
hi.value = 0; |
prepare_entry_hi(&hi, asid, page); |
prepare_entry_hi(&hi, asid, page + i * PAGE_SIZE); |
cp0_entry_hi_write(hi.value); |
tlbp(); |
533,6 → 536,7 |
tlbwi(); |
} |
} |
interrupts_restore(ipl); |
cp0_entry_hi_write(hi_save.value); |
/kernel/trunk/arch/mips32/src/mm/as.c |
---|
35,7 → 35,7 |
/** Install address space. |
* |
* Install ASID and if necessary, purge TLB. |
* Install ASID. |
* |
* @param as Address space structure. |
*/ |
45,11 → 45,6 |
ipl_t ipl; |
/* |
* If necessary, purge TLB. |
*/ |
tlb_invalidate_asid(as->asid); /* TODO: do it only if necessary */ |
/* |
* Install ASID. |
*/ |
hi.value = cp0_entry_hi_read(); |