1 #ifndef__ALPHA_MMU_CONTEXT_H 2 #define__ALPHA_MMU_CONTEXT_H 3
4 /* 5 * get a new mmu context.. 6 * 7 * Copyright (C) 1996, Linus Torvalds 8 */ 9
10 #include <asm/pgtable.h>
11
12 /* 13 * The maximum ASN's the processor supports. On the EV4 this doesn't 14 * matter as the pal-code doesn't use the ASNs anyway, on the EV5 15 * EV5 this is 127. 16 */ 17 #defineMAX_ASN 127
18
19 #defineASN_VERSION_SHIFT 32
20 #defineASN_VERSION_MASK ((~0UL) << ASN_VERSION_SHIFT)
21 #defineASN_FIRST_VERSION (1UL << ASN_VERSION_SHIFT)
22
23 /* 24 * NOTE! The way this is set up, the high bits of the "asn_cache" (and 25 * the "mm->context") are the ASN _version_ code. A version of 0 is 26 * always considered invalid, so to invalidate another process you only 27 * need to do "p->mm->context = 0". 28 * 29 * If we need more ASN's than the processor has, we invalidate the old 30 * user TLB's (tbiap()) and start a new ASN version. That will automatically 31 * force a new asn for any other processes the next time they want to 32 * run. 33 */ 34 externinlinevoidget_mmu_context(structtask_struct *p)
/* */ 35 { 36 staticunsignedlongasn_cache = ASN_FIRST_VERSION;
37 structmm_struct * mm = p->mm;
38 unsignedlongasn = mm->context;
39
40 /* Check if our ASN is of an older version and thus invalid */ 41 if ((asn_cache ^ asn) & ASN_VERSION_MASK) { 42 /* get a new asn of the current version */ 43 asn = asn_cache++;
44 /* check if it's legal.. */ 45 if ((asn & ~ASN_VERSION_MASK) > MAX_ASN) { 46 /* start a new version, invalidate all old asn's */ 47 tbiap();
48 asn_cache = (asn_cache & ASN_VERSION_MASK) + ASN_FIRST_VERSION;
49 if (!asn_cache)
50 asn_cache = ASN_FIRST_VERSION;
51 asn = asn_cache++;
52 } 53 mm->context = asn; /* full version + asn */ 54 p->tss.asn = asn & ~ASN_VERSION_MASK; /* just asn */ 55 } 56 } 57
58 #endif