Rev 2110 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
35 | jermar | 1 | # |
2071 | jermar | 2 | # Copyright (c) 2005 Jakub Jermar |
35 | jermar | 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 | |||
473 | jermar | 29 | #include <arch/register.h> |
869 | vana | 30 | #include <arch/mm/page.h> |
31 | #include <arch/mm/asid.h> |
||
32 | #include <mm/asid.h> |
||
473 | jermar | 33 | |
869 | vana | 34 | #define RR_MASK (0xFFFFFFFF00000002) |
35 | #define RID_SHIFT 8 |
||
36 | #define PS_SHIFT 2 |
||
37 | |||
38 | #define KERNEL_TRANSLATION_I 0x0010000000000661 |
||
39 | #define KERNEL_TRANSLATION_D 0x0010000000000661 |
||
40 | |||
923 | vana | 41 | .section K_TEXT_START, "ax" |
60 | jermar | 42 | |
35 | jermar | 43 | .global kernel_image_start |
44 | |||
37 | jermar | 45 | stack0: |
35 | jermar | 46 | kernel_image_start: |
81 | jermar | 47 | .auto |
412 | jermar | 48 | |
893 | jermar | 49 | # Fill TR.i and TR.d using Region Register #VRN_KERNEL |
869 | vana | 50 | |
2110 | jermar | 51 | movl r8 = (VRN_KERNEL << VRN_SHIFT) |
52 | mov r9 = rr[r8] |
||
53 | movl r10 = (RR_MASK) |
||
54 | and r9 = r10, r9 |
||
55 | movl r10 = ((RID_KERNEL << RID_SHIFT) | (KERNEL_PAGE_WIDTH << PS_SHIFT)) |
||
56 | or r9 = r10, r9 |
||
57 | mov rr[r8] = r9 |
||
869 | vana | 58 | |
2110 | jermar | 59 | movl r8 = (VRN_KERNEL << VRN_SHIFT) |
60 | mov cr.ifa = r8 |
||
61 | movl r10 = (KERNEL_PAGE_WIDTH << PS_SHIFT) |
||
62 | mov cr.itir = r10 |
||
63 | movl r10 = (KERNEL_TRANSLATION_I) |
||
64 | itr.i itr[r0] = r10 |
||
65 | movl r10 = (KERNEL_TRANSLATION_D) |
||
66 | itr.d dtr[r0] = r10 |
||
869 | vana | 67 | |
81 | jermar | 68 | # initialize PSR |
412 | jermar | 69 | mov psr.l = r0 |
70 | srlz.i |
||
71 | srlz.d |
||
2110 | jermar | 72 | movl r10 = (PSR_DT_MASK | PSR_RT_MASK | PSR_IT_MASK | PSR_IC_MASK) /* Enable paging */ |
73 | mov r9 = psr |
||
74 | or r10 = r10, r9 |
||
75 | mov cr.ipsr = r10 |
||
76 | mov cr.ifs = r0 |
||
77 | movl r8 = paging_start |
||
78 | mov cr.iip = r8 |
||
473 | jermar | 79 | srlz.d |
869 | vana | 80 | srlz.i |
879 | vana | 81 | |
893 | jermar | 82 | .explicit |
83 | /* |
||
84 | * Return From Interupt is the only the way to fill upper half word of PSR. |
||
85 | */ |
||
86 | rfi;; |
||
879 | vana | 87 | |
88 | .global paging_start |
||
89 | paging_start: |
||
893 | jermar | 90 | |
91 | /* |
||
92 | * Now we are paging. |
||
93 | */ |
||
94 | |||
473 | jermar | 95 | # switch to register bank 1 |
96 | bsw.1 |
||
97 | |||
74 | jermar | 98 | # initialize register stack |
81 | jermar | 99 | mov ar.rsc = r0 |
2110 | jermar | 100 | movl r8 = (VRN_KERNEL << VRN_SHIFT) ;; |
869 | vana | 101 | mov ar.bspstore = r8 |
81 | jermar | 102 | loadrs |
36 | jermar | 103 | |
74 | jermar | 104 | # initialize memory stack to some sane value |
2110 | jermar | 105 | movl r12 = stack0 ;; |
869 | vana | 106 | |
2110 | jermar | 107 | add r12 = -16, r12 /* allocate a scratch area on the stack */ |
60 | jermar | 108 | |
74 | jermar | 109 | # initialize gp (Global Pointer) register |
919 | jermar | 110 | movl r1 = _hardcoded_load_address |
869 | vana | 111 | |
893 | jermar | 112 | /* |
113 | * Initialize hardcoded_* variables. |
||
114 | */ |
||
106 | jermar | 115 | movl r14 = _hardcoded_ktext_size |
116 | movl r15 = _hardcoded_kdata_size |
||
919 | jermar | 117 | movl r16 = _hardcoded_load_address ;; |
106 | jermar | 118 | addl r17 = @gprel(hardcoded_ktext_size), gp |
119 | addl r18 = @gprel(hardcoded_kdata_size), gp |
||
120 | addl r19 = @gprel(hardcoded_load_address), gp |
||
121 | ;; |
||
870 | vana | 122 | st8 [r17] = r14 |
123 | st8 [r18] = r15 |
||
106 | jermar | 124 | st8 [r19] = r16 |
869 | vana | 125 | |
2110 | jermar | 126 | ssm (1 << 19) ;; /* Disable f32 - f127 */ |
127 | srlz.i |
||
128 | srlz.d ;; |
||
1053 | vana | 129 | |
1223 | jermar | 130 | br.call.sptk.many b0 = arch_pre_main |
1053 | vana | 131 | |
2110 | jermar | 132 | movl r18 = main_bsp ;; |
133 | mov b1 = r18 ;; |
||
134 | br.call.sptk.many b0 = b1 |
||
51 | jermar | 135 | |
1053 | vana | 136 | |
36 | jermar | 137 | 0: |
39 | jermar | 138 | br 0b |