Rev 1022 | Rev 1068 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
913 | decky | 1 | # |
2 | # Copyright (C) 2006 Martin Decky |
||
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 | |||
1058 | decky | 29 | #include "asm.h" |
913 | decky | 30 | #include "regname.h" |
31 | |||
914 | decky | 32 | .data |
33 | |||
34 | flush_buffer: |
||
933 | decky | 35 | .space (L1_CACHE_LINES * L1_CACHE_BYTES) |
914 | decky | 36 | |
913 | decky | 37 | .text |
38 | |||
1058 | decky | 39 | .global halt |
913 | decky | 40 | .global jump_to_kernel |
41 | |||
1058 | decky | 42 | halt: |
43 | b halt |
||
913 | decky | 44 | |
45 | jump_to_kernel: |
||
1022 | decky | 46 | |
1058 | decky | 47 | # r3 = memmap (pa) |
48 | # r4 = trans (pa) |
||
49 | # r5 = number of kernel pages |
||
50 | # r6 = real_mode (pa) |
||
1022 | decky | 51 | |
1058 | decky | 52 | mtspr srr0, r6 |
1022 | decky | 53 | |
54 | # jumps to real_mode |
||
55 | |||
1058 | decky | 56 | mfmsr r31 |
57 | lis r30, ~0@h |
||
58 | ori r30, r30, ~(msr_ir | msr_dr)@l |
||
59 | and r31, r31, r30 |
||
60 | mtspr srr1, r31 |
||
1022 | decky | 61 | rfi |
62 | |||
63 | .section REALMODE |
||
1058 | decky | 64 | .align PAGE_WIDTH |
1022 | decky | 65 | .global real_mode |
66 | |||
67 | real_mode: |
||
1058 | decky | 68 | |
69 | # copy kernel to proper location |
||
70 | # |
||
71 | # r4 = trans (pa) |
||
72 | # r5 = number of kernel pages |
||
73 | |||
74 | li r31, PAGE_SIZE >> 3 |
||
75 | li r30, 0 |
||
76 | |||
77 | page_copy: |
||
78 | |||
79 | cmpwi r5, 0 |
||
80 | beq copy_end |
||
81 | |||
82 | # copy single page |
||
83 | |||
84 | mtctr r31 |
||
85 | lwz r29, 0(r4) |
||
86 | |||
87 | copy_loop: |
||
88 | |||
89 | lwz r28, 0(r29) |
||
90 | stw r28, 0(r30) |
||
91 | |||
92 | addi r29, r29, 4 |
||
93 | addi r30, r30, 4 |
||
94 | |||
95 | bdnz copy_loop |
||
96 | |||
97 | subi r5, r5, 1 |
||
98 | addi r4, r4, 4 |
||
99 | b page_copy |
||
100 | |||
101 | copy_end: |
||
102 | |||
1022 | decky | 103 | # fill segment registers |
104 | |||
1058 | decky | 105 | li r31, 16 |
106 | mtctr r31 |
||
107 | li r31, 0 |
||
108 | li r30, 0x2000 |
||
1022 | decky | 109 | |
110 | seg_fill: |
||
111 | |||
1058 | decky | 112 | mtsrin r30, r31 |
1022 | decky | 113 | |
1058 | decky | 114 | addis r31, r31, 0x1000 # add 256 MB |
115 | addi r30, r30, 0x111 # move to next SR |
||
116 | |||
1022 | decky | 117 | bdnz seg_fill |
118 | |||
1058 | decky | 119 | # create identity mapping |
120 | |||
121 | tlbia |
||
122 | |||
123 | # start the kernel |
||
1022 | decky | 124 | # |
1058 | decky | 125 | # r3 = memmap (pa) |
1022 | decky | 126 | |
1058 | decky | 127 | lis r31, KERNEL_START_ADDR@ha |
128 | addi r31, r31, KERNEL_START_ADDR@l |
||
1022 | decky | 129 | |
1058 | decky | 130 | mtspr srr0, r31 |
1022 | decky | 131 | |
1058 | decky | 132 | mfmsr r31 |
133 | ori r31, r31, (msr_ir | msr_dr)@l |
||
134 | mtspr srr1, r31 |
||
135 | |||
1022 | decky | 136 | rfi |
1058 | decky | 137 | |
138 | .align PAGE_WIDTH |
||
139 | .global trans |
||
140 | trans: |
||
141 | .space (TRANS_SIZE * TRANS_ITEM_SIZE) |