Index: arch/mips32/src/mm/as.c
===================================================================
--- arch/mips32/src/mm/as.c	(revision 5d2ab231a2e6c513f459e864da1c59750cce6db7)
+++ arch/mips32/src/mm/as.c	(revision 6461d67c2af90661b2bc7782827b0e00e345afbc)
@@ -36,5 +36,5 @@
 /** Install address space.
  *
- * Install ASID and if necessary, purge TLB.
+ * Install ASID.
  *
  * @param as Address space structure.
@@ -44,9 +44,4 @@
 	entry_hi_t hi;
 	ipl_t ipl;
-
-	/*
-	 * If necessary, purge TLB.
-	 */
-	tlb_invalidate_asid(as->asid);	/* TODO: do it only if necessary */
 
 	/*
Index: arch/mips32/src/mm/asid.c
===================================================================
--- arch/mips32/src/mm/asid.c	(revision 5d2ab231a2e6c513f459e864da1c59750cce6db7)
+++ arch/mips32/src/mm/asid.c	(revision 6461d67c2af90661b2bc7782827b0e00e345afbc)
@@ -29,92 +29,4 @@
 
 #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;
-}
Index: arch/mips32/src/mm/tlb.c
===================================================================
--- arch/mips32/src/mm/tlb.c	(revision 5d2ab231a2e6c513f459e864da1c59750cce6db7)
+++ arch/mips32/src/mm/tlb.c	(revision 6461d67c2af90661b2bc7782827b0e00e345afbc)
@@ -28,5 +28,5 @@
 
 #include <arch/mm/tlb.h>
-#include <arch/mm/asid.h>
+#include <mm/asid.h>
 #include <mm/tlb.h>
 #include <mm/page.h>
@@ -495,11 +495,13 @@
 }
 
-/** 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.
- */
-void tlb_invalidate_page(asid_t asid, __address page)
-{
+ * @param page First page whose TLB entry is to be invalidated.
+ * @param cnt Number of entries to invalidate.
+ */
+void tlb_invalidate_pages(asid_t asid, __address page, count_t cnt)
+{
+	int i;
 	ipl_t ipl;
 	entry_lo_t lo0, lo1;
@@ -512,25 +514,27 @@
 	ipl = interrupts_disable();
 
-	hi.value = 0;
-	prepare_entry_hi(&hi, asid, page);
-	cp0_entry_hi_write(hi.value);
-
-	tlbp();
-	index.value = cp0_index_read();
-
-	if (!index.p) {
-		/* Entry was found, index register contains valid index. */
-		tlbr();
-
-		lo0.value = cp0_entry_lo0_read();
-		lo1.value = cp0_entry_lo1_read();
-
-		lo0.v = 0;
-		lo1.v = 0;
-
-		cp0_entry_lo0_write(lo0.value);
-		cp0_entry_lo1_write(lo1.value);
-
-		tlbwi();
+	for (i = 0; i < cnt; i++) {
+		hi.value = 0;
+		prepare_entry_hi(&hi, asid, page + i * PAGE_SIZE);
+		cp0_entry_hi_write(hi.value);
+
+		tlbp();
+		index.value = cp0_index_read();
+
+		if (!index.p) {
+			/* Entry was found, index register contains valid index. */
+			tlbr();
+
+			lo0.value = cp0_entry_lo0_read();
+			lo1.value = cp0_entry_lo1_read();
+
+			lo0.v = 0;
+			lo1.v = 0;
+
+			cp0_entry_lo0_write(lo0.value);
+			cp0_entry_lo1_write(lo1.value);
+
+			tlbwi();
+		}
 	}
 	
