[30ef8ce] | 1 | #
|
---|
[df4ed85] | 2 | # Copyright (c) 2005 Jakub Jermar
|
---|
[30ef8ce] | 3 | # All rights reserved.
|
---|
| 4 | #
|
---|
| 5 | # Redistribution and use in source and binary forms, with or without
|
---|
| 6 | # modification, are permitted provided that the following conditions
|
---|
| 7 | # are met:
|
---|
| 8 | #
|
---|
| 9 | # - Redistributions of source code must retain the above copyright
|
---|
| 10 | # notice, this list of conditions and the following disclaimer.
|
---|
| 11 | # - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | # notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | # documentation and/or other materials provided with the distribution.
|
---|
| 14 | # - The name of the author may not be used to endorse or promote products
|
---|
| 15 | # derived from this software without specific prior written permission.
|
---|
| 16 | #
|
---|
| 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | #
|
---|
| 28 |
|
---|
[802bb95] | 29 | #include <arch/register.h>
|
---|
[5ac2e61] | 30 | #include <arch/mm/page.h>
|
---|
| 31 | #include <arch/mm/asid.h>
|
---|
| 32 | #include <mm/asid.h>
|
---|
| 33 |
|
---|
[5bda2f3e] | 34 | #define RR_MASK (0xFFFFFFFF00000002)
|
---|
| 35 | #define RID_SHIFT 8
|
---|
| 36 | #define PS_SHIFT 2
|
---|
[7208b6c] | 37 |
|
---|
[5bda2f3e] | 38 | #define KERNEL_TRANSLATION_I 0x0010000000000661
|
---|
| 39 | #define KERNEL_TRANSLATION_D 0x0010000000000661
|
---|
[5ac2e61] | 40 |
|
---|
[9faddb3] | 41 | .section K_TEXT_START, "ax"
|
---|
[00a44bc] | 42 |
|
---|
[30ef8ce] | 43 | .global kernel_image_start
|
---|
| 44 |
|
---|
[2217ac3] | 45 | stack0:
|
---|
[fe7abd0] | 46 |
|
---|
| 47 | #
|
---|
| 48 | # Kernel entry point.
|
---|
| 49 | #
|
---|
| 50 | # This is where we are passed control from the boot code.
|
---|
| 51 | # Register contents:
|
---|
| 52 | #
|
---|
| 53 | # r2 Address of the boot code's bootinfo structure.
|
---|
| 54 | #
|
---|
[30ef8ce] | 55 | kernel_image_start:
|
---|
[7f1bfce] | 56 | .auto
|
---|
[5bda2f3e] | 57 |
|
---|
[7208b6c] | 58 | mov psr.l = r0
|
---|
| 59 | srlz.i
|
---|
| 60 | srlz.d
|
---|
[5bda2f3e] | 61 |
|
---|
[481c520] | 62 | # Fill TR.i and TR.d using Region Register #VRN_KERNEL
|
---|
[5bda2f3e] | 63 |
|
---|
[15819e37] | 64 | movl r8 = (VRN_KERNEL << VRN_SHIFT)
|
---|
| 65 | mov r9 = rr[r8]
|
---|
[5bda2f3e] | 66 |
|
---|
[15819e37] | 67 | movl r10 = (RR_MASK)
|
---|
| 68 | and r9 = r10, r9
|
---|
[d9ee2ea] | 69 | movl r10 = (((RID_KERNEL7) << RID_SHIFT) | (KERNEL_PAGE_WIDTH << PS_SHIFT))
|
---|
[5bda2f3e] | 70 | or r9 = r10, r9
|
---|
| 71 |
|
---|
[15819e37] | 72 | mov rr[r8] = r9
|
---|
[5bda2f3e] | 73 |
|
---|
[15819e37] | 74 | movl r8 = (VRN_KERNEL << VRN_SHIFT)
|
---|
| 75 | mov cr.ifa = r8
|
---|
[5bda2f3e] | 76 |
|
---|
[acee917] | 77 | mov r11 = cr.itir
|
---|
| 78 | movl r10 = (KERNEL_PAGE_WIDTH << PS_SHIFT)
|
---|
| 79 | or r10 = r10, r11
|
---|
| 80 | mov cr.itir = r10
|
---|
[5bda2f3e] | 81 |
|
---|
[15819e37] | 82 | movl r10 = (KERNEL_TRANSLATION_I)
|
---|
| 83 | itr.i itr[r0] = r10
|
---|
| 84 | movl r10 = (KERNEL_TRANSLATION_D)
|
---|
| 85 | itr.d dtr[r0] = r10
|
---|
[5bda2f3e] | 86 |
|
---|
[22f0561] | 87 | # Initialize DCR
|
---|
[93d66ef] | 88 |
|
---|
| 89 | movl r10 = (DCR_DP_MASK | DCR_DK_MASK | DCR_DX_MASK | DCR_DR_MASK | DCR_DA_MASK | DCR_DD_MASK | DCR_LC_MASK)
|
---|
| 90 | mov r9 = cr.dcr
|
---|
| 91 | or r10 = r10, r9
|
---|
| 92 | mov cr.dcr = r10
|
---|
| 93 |
|
---|
[666773c] | 94 | # Initialize PSR
|
---|
[5bda2f3e] | 95 |
|
---|
[15819e37] | 96 | movl r10 = (PSR_DT_MASK | PSR_RT_MASK | PSR_IT_MASK | PSR_IC_MASK) /* Enable paging */
|
---|
| 97 | mov r9 = psr
|
---|
[5bda2f3e] | 98 |
|
---|
[15819e37] | 99 | or r10 = r10, r9
|
---|
| 100 | mov cr.ipsr = r10
|
---|
| 101 | mov cr.ifs = r0
|
---|
| 102 | movl r8 = paging_start
|
---|
| 103 | mov cr.iip = r8
|
---|
[802bb95] | 104 | srlz.d
|
---|
[5ac2e61] | 105 | srlz.i
|
---|
[5bda2f3e] | 106 |
|
---|
[481c520] | 107 | .explicit
|
---|
[5bda2f3e] | 108 |
|
---|
[481c520] | 109 | /*
|
---|
[0e56eb1a] | 110 | * Return From Interrupt is the only way to
|
---|
| 111 | * fill the upper half word of PSR.
|
---|
[481c520] | 112 | */
|
---|
[acee917] | 113 | rfi ;;
|
---|
[085434a] | 114 |
|
---|
| 115 | .global paging_start
|
---|
| 116 | paging_start:
|
---|
[5bda2f3e] | 117 |
|
---|
[481c520] | 118 | /*
|
---|
| 119 | * Now we are paging.
|
---|
| 120 | */
|
---|
[d75628da] | 121 |
|
---|
| 122 | #
|
---|
| 123 | # Set Interruption Vector Address
|
---|
| 124 | # (i.e. location of interruption vector table)
|
---|
| 125 | #
|
---|
| 126 | movl r8 = ivt ;;
|
---|
| 127 | mov cr.iva = r8
|
---|
| 128 | srlz.d ;;
|
---|
| 129 |
|
---|
[5bda2f3e] | 130 |
|
---|
[666773c] | 131 | # Switch to register bank 1
|
---|
[802bb95] | 132 | bsw.1
|
---|
[5bda2f3e] | 133 |
|
---|
[666773c] | 134 | # Initialize register stack
|
---|
[7f1bfce] | 135 | mov ar.rsc = r0
|
---|
[15819e37] | 136 | movl r8 = (VRN_KERNEL << VRN_SHIFT) ;;
|
---|
[5ac2e61] | 137 | mov ar.bspstore = r8
|
---|
[7f1bfce] | 138 | loadrs
|
---|
[972c60ce] | 139 |
|
---|
[7f0e7b6] | 140 | #
|
---|
[d75628da] | 141 | # Initialize memory stack to some sane value and allocate a scratch area
|
---|
[7f0e7b6] | 142 | # on it.
|
---|
| 143 | #
|
---|
| 144 | movl sp = stack0 ;;
|
---|
| 145 | add sp = -16, sp
|
---|
[5bda2f3e] | 146 |
|
---|
[666773c] | 147 | # Initialize gp (Global Pointer) register
|
---|
[18ba2e4f] | 148 | movl gp = __gp
|
---|
[7a9364c] | 149 |
|
---|
[18ba2e4f] | 150 | #
|
---|
[fe7abd0] | 151 | # Initialize bootinfo on BSP.
|
---|
| 152 | #
|
---|
| 153 | movl r20 = (VRN_KERNEL << VRN_SHIFT) ;;
|
---|
| 154 | or r20 = r20, r2 ;;
|
---|
[e5c1186] | 155 | addl r21 = @gprel(bootinfo), gp ;;
|
---|
| 156 | st8 [r21] = r20
|
---|
[5bda2f3e] | 157 |
|
---|
[15819e37] | 158 | ssm (1 << 19) ;; /* Disable f32 - f127 */
|
---|
| 159 | srlz.i
|
---|
| 160 | srlz.d ;;
|
---|
[972c60ce] | 161 |
|
---|
[6ecc8bce] | 162 | br.call.sptk.many b0 = arch_pre_main
|
---|
[fae1647] | 163 | 0:
|
---|
| 164 | br.call.sptk.many b0 = main_bsp
|
---|
[2a0047fc] | 165 | 0:
|
---|
[47d78c6] | 166 | br 0b
|
---|