summaryrefslogtreecommitdiffstats
path: root/src/occBootLoader/bootInit.S
blob: d7fe632767801aba7c0177fed4563caecfdf2feb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/occBootLoader/bootInit.S $
#
# OpenPOWER OnChipController Project
#
# Contributors Listed Below - COPYRIGHT 2011,2014
# [+] Google Inc.
# [+] International Business Machines Corp.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG

#*****************************************************************************/
# Includes
#*****************************************************************************/
#include "bootMain.h"
#include "ppc32_asm.h"
#include "ppc405_spr.h"

#*****************************************************************************/
# Functions
#*****************************************************************************/

# Function Specification ******************************************************
#
#  Name: boot_low_level_init
#
#  Description: Low level boot initialization
#
# End Function Specification **************************************************
.global_function __boot_low_level_init

__boot_low_level_init:

# enable machine check exception
# initialize exception vector prefix to zero
# enable machine check (19th bit)
li      %r3, 0
mtevpr  %r3
_liwa   %r4, MACHINE_CHECK_ENABLE
mtmsr   %r4

# Check if TSR[WSR] indicates that reset was due to watchdog,
# then initialize external debug event and trap(halt). Otherwise
# continue normally. Setting up external debug event will set FIR bits on halt
mftsr   %r3
_liwa   %r4, (TSR_WRS_CHIP | TSR_WRS_CORE | TSR_WRS_SYSTEM)
AND     %r5, %r3, %r4
li      %r4, 0
cmp     0, 0, %r4, %r5
beq     skip_wd_reset_trap

# Initialize external debug event before doing trap
_liwa   %r3, (DBCR0_EDM | DBCR0_TDE | DBCR0_FT)
mtdbcr0 %r3
tw 31,0,0

skip_wd_reset_trap:
# enable write back data cache and instruction cache
li       %r3, 0
mtdcwr   %r3
_liw     %r3, DATA_CACHE_BLOCK_ENABLE
mtdccr   %r3
mticcr   %r3

dcache_invalidate:
# We loop through addresses 0 ... (DCACHE_SIZE / DCACHE_WAYS) - 1
# invalidating the D-Cache.  The dccci instruction on the 405
# invalidates both ways.
li    %r3, 0
_liwa    %r4, (DATA_CACHE_LINES / 2)
mtctr    %r4

1:
dccci    %r0, %r3
addi    %r3, %r3, CACHE_LINE_SIZE
bdnz    1b
sync

# fill in 16K with zero for the data cache
# set counter to loop for number of data cache lines
_liw    %r3, 0
_liwa   %r5, DATA_CACHE_BLOCK_ADDR
_liwa   %r4, DATA_CACHE_LINES
mtctr   %r4

dcbz_loop:
dcbz    %r5, %r3
addi    %r3, %r3, CACHE_LINE_SIZE
bdnz    dcbz_loop

# write in initialized writeable data if length is non-zero
_liw    %r5, (__START_ADDR__ - 4)
_liw    %r4, __READ_ONLY_DATA_LEN__
add     %r3, %r5, %r4
_liw    %r4, __WRITEABLE_DATA_LEN__
_liw    %r5, (__WRITEABLE_DATA_ADDR__ - 4)
_liw    %r6, 2
srw     %r4, %r4, %r6
_liw    %r6, 0
cmp     0, 0, %r4, %r6
beq     skip_loop
mtctr   %r4

copy_loop:
lwzu    %r4, 4(%r3)
stwu    %r4, 4(%r5)
bdnz    copy_loop

skip_loop:
# set up EABI constant registers r2, r13
_liw    %r2, _SDA2_BASE_
_liw    %r13, _SDA_BASE_

# set up stack pointer register r1
_liwa   %r1, STACK_POINTER_ADDR

# jump to main
b main
.epilogue  __boot_low_level_init

# vector section, put traps on sections after 0000
.section .vectors_0000, "a", @progbits
.global __vectors_0000

__vectors_0000:
.section .vectors_0100, "ax", @progbits
.global __vectors_0100

__vectors_0100:
tw 31,0,0
.section .vectors_0200, "ax", @progbits
.global __vectors_0200

__vectors_0200:
tw 31,0,0
.section .vectors_0300, "ax", @progbits
.global __vectors_0300

__vectors_0300:
tw 31,0,0
.section .vectors_0400, "ax", @progbits
.global __vectors_0400

__vectors_0400:
tw 31,0,0
.section .vectors_0500, "ax", @progbits
.global __vectors_0500

__vectors_0500:
tw 31,0,0
.section .vectors_0600, "ax", @progbits
.global __vectors_0600

__vectors_0600:
tw 31,0,0
.section .vectors_0700, "ax", @progbits
.global __vectors_0700

__vectors_0700:
tw 31,0,0
OpenPOWER on IntegriCloud