| 1 | /* |
| 2 | * ========== Copyright Header Begin ========================================== |
| 3 | * |
| 4 | * OpenSPARC T2 Processor File: mmu_ptr_calc.s |
| 5 | * Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved |
| 6 | * 4150 Network Circle, Santa Clara, California 95054, U.S.A. |
| 7 | * |
| 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; version 2 of the License. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
| 23 | * For the avoidance of doubt, and except that if any non-GPL license |
| 24 | * choice is available it will apply instead, Sun elects to use only |
| 25 | * the General Public License version 2 (GPLv2) at this time for any |
| 26 | * software where a choice of GPL license versions is made |
| 27 | * available with the language indicating that GPLv2 or any later version |
| 28 | * may be used, or where a choice of which version of the GPL is applied is |
| 29 | * otherwise unspecified. |
| 30 | * |
| 31 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 32 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 33 | * have any questions. |
| 34 | * |
| 35 | * |
| 36 | * ========== Copyright Header End ============================================ |
| 37 | */ |
| 38 | sllx %g6, 51, %g5 |
| 39 | brnz,a %g5, 1f |
| 40 | add %g7, 0x20, %g7 ! this executes only if branch taken |
| 41 | |
| 42 | 1: |
| 43 | !%g1 = ldxa tsb_config |
| 44 | ldxa [%g7] ASI_MMU_ZERO_CONTEXT_TSB_CONFIG, %g1 |
| 45 | |
| 46 | !%g2 = tsbsz = %g1 & 0xf |
| 47 | and %g1, 0xf, %g2 |
| 48 | |
| 49 | !%g3 = pgsz = %g1 & 0x70 >> 4 |
| 50 | and %g1, 0x70, %g3 |
| 51 | srlx %g3, 4, %g3 |
| 52 | |
| 53 | !tsb64[63:40] = 0 |
| 54 | !tsb64[39:13+tsbsz] = tsb_base[39:13+tsbsz] |
| 55 | !tsb64[12+tsbsz:0] = 0 |
| 56 | ! |
| 57 | !tsb64 = ({24'b0,27'b1,13'b0} << (tsbsz)) & tsb_base |
| 58 | ! = (0xffffffff000 << (tsbsz)) & tsb_base |
| 59 | ! ((~0xfff) << (tsbsz)) & tsb_base |
| 60 | |
| 61 | !%g4 = 0x000000ffffffe000 |
| 62 | not %g0, %g4 |
| 63 | srlx %g4, 36, %g4 |
| 64 | sllx %g4, 13, %g4 |
| 65 | |
| 66 | !%g4 = sllx %g2 |
| 67 | sllx %g4, %g2, %g4 |
| 68 | |
| 69 | !%g4 = and %g1 %g4 |
| 70 | and %g1, %g4, %g4 |
| 71 | |
| 72 | !va_mask = {(8+tsbsz)'b1,4'b0} |
| 73 | ! = (0xffffff >> (15-tsbsz) |
| 74 | |
| 75 | !%g5 = 0xffffff |
| 76 | set 0xffffff, %g5 |
| 77 | |
| 78 | !%g1 = 15 |
| 79 | mov 15, %g1 |
| 80 | |
| 81 | !%g1 = sub %g1 %g2 |
| 82 | sub %g1, %g2, %g1 |
| 83 | |
| 84 | !%g5 = srax %g5 %g1 |
| 85 | srax %g5, %g1, %g1 |
| 86 | |
| 87 | !va_1 = va >> (13+3*pgsz) |
| 88 | |
| 89 | !%g5 = mulx %g3 |
| 90 | mulx %g3, 3, %g5 |
| 91 | |
| 92 | !%g5 = add %g5 13 |
| 93 | add %g5, 13, %g5 |
| 94 | |
| 95 | !%g1 = srax %g6 %g5 |
| 96 | srax %g6, %g5, %g5 |
| 97 | |
| 98 | !va64 = va_1 & va_mask |
| 99 | |
| 100 | !%g1 = and %g1 %g5 |
| 101 | and %g1, %g5, %g1 |
| 102 | |
| 103 | ! va64 << 4 |
| 104 | !%g1 = sllx 4, %g1 |
| 105 | sllx %g1, 4, %g1 |
| 106 | |
| 107 | !tsb_pointer = (tsb64 | VA64) |
| 108 | |
| 109 | !%g1 = or %g1 %g4 |
| 110 | or %g1, %g4, %g1 |