OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [powerpc/] [arch/] [current/] [include/] [arch.inc] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef _CYGONCE_HAL_POWERPC_ARCH_INC_
2
#define _CYGONCE_HAL_POWERPC_ARCH_INC_
3
##=============================================================================
4
##
5
##      arch.inc
6
##
7
##      PowerPC architecture assembler header file
8
##
9
##=============================================================================
10
## ####ECOSGPLCOPYRIGHTBEGIN####
11
## -------------------------------------------
12
## This file is part of eCos, the Embedded Configurable Operating System.
13
## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007 Free Software Foundation, Inc.
14
##
15
## eCos is free software; you can redistribute it and/or modify it under
16
## the terms of the GNU General Public License as published by the Free
17
## Software Foundation; either version 2 or (at your option) any later
18
## version.
19
##
20
## eCos is distributed in the hope that it will be useful, but WITHOUT
21
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
## for more details.
24
##
25
## You should have received a copy of the GNU General Public License
26
## along with eCos; if not, write to the Free Software Foundation, Inc.,
27
## 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
28
##
29
## As a special exception, if other files instantiate templates or use
30
## macros or inline functions from this file, or you compile this file
31
## and link it with other works to produce a work based on this file,
32
## this file does not by itself cause the resulting work to be covered by
33
## the GNU General Public License. However the source code for this file
34
## must still be made available in accordance with section (3) of the GNU
35
## General Public License v2.
36
##
37
## This exception does not invalidate any other reasons why a work based
38
## on this file might be covered by the GNU General Public License.
39
## -------------------------------------------
40
## ####ECOSGPLCOPYRIGHTEND####
41
##=============================================================================
42
#######DESCRIPTIONBEGIN####
43
##
44
## Author(s):   nickg
45
## Contributors:nickg
46
## Date:        1997-10-16
47
## Purpose:     PowerPC definitions.
48
## Description: This file contains various definitions and macros that are
49
##              useful for writing assembly code for the PowerPC
50
##              It also includes the variant assembly header file.
51
## Usage:
52
##              #include 
53
##              ...
54
##
55
##
56
######DESCRIPTIONEND####
57
##
58
##=============================================================================
59
 
60
#include 
61
#include 
62
#include 
63
 
64
#------------------------------------------------------------------------------
65
# Easier to read names for the registers
66
 
67
        .equ    r0, 0
68
        .equ    r1, 1
69
        .equ    r2, 2
70
        .equ    r3, 3
71
        .equ    r4, 4
72
        .equ    r5, 5
73
        .equ    r6, 6
74
        .equ    r7, 7
75
        .equ    r8, 8
76
        .equ    r9, 9
77
        .equ    r10, 10
78
        .equ    r11, 11
79
        .equ    r12, 12
80
        .equ    r13, 13
81
        .equ    r14, 14
82
        .equ    r15, 15
83
        .equ    r16, 16
84
        .equ    r17, 17
85
        .equ    r18, 18
86
        .equ    r19, 19
87
        .equ    r20, 20
88
        .equ    r21, 21
89
        .equ    r22, 22
90
        .equ    r23, 23
91
        .equ    r24, 24
92
        .equ    r25, 25
93
        .equ    r26, 26
94
        .equ    r27, 27
95
        .equ    r28, 28
96
        .equ    r29, 29
97
        .equ    r30, 30
98
        .equ    r31, 31
99
 
100
        .equ    sp, r1
101
 
102
#ifdef CYGHWR_HAL_POWERPC_FPU
103
        .equ    f0, 0
104
        .equ    f1, 1
105
        .equ    f2, 2
106
        .equ    f3, 3
107
        .equ    f4, 4
108
        .equ    f5, 5
109
        .equ    f6, 6
110
        .equ    f7, 7
111
        .equ    f8, 8
112
        .equ    f9, 9
113
        .equ    f10, 10
114
        .equ    f11, 11
115
        .equ    f12, 12
116
        .equ    f13, 13
117
        .equ    f14, 14
118
        .equ    f15, 15
119
        .equ    f16, 16
120
        .equ    f17, 17
121
        .equ    f18, 18
122
        .equ    f19, 19
123
        .equ    f20, 20
124
        .equ    f21, 21
125
        .equ    f22, 22
126
        .equ    f23, 23
127
        .equ    f24, 24
128
        .equ    f25, 25
129
        .equ    f26, 26
130
        .equ    f27, 27
131
        .equ    f28, 28
132
        .equ    f29, 29
133
        .equ    f30, 30
134
        .equ    f31, 31
135
#endif
136
 
137
 
138
#------------------------------------------------------------------------------
139
# Some useful coding macros
140
 
141
        # Load immediate word, has to be done with 2 instructions
142
        .macro  lwi     reg,val
143
        lis     \reg,\val@H
144
        ori     \reg,\reg,\val@L
145
        .endm
146
 
147
#ifdef CYGPKG_HAL_POWERPC_PPC603
148
        # Move from HID0 hw control register
149
        .macro  mfhid0 reg
150
        mfspr   \reg,HID0
151
        .endm
152
#endif
153
 
154
#define FUNC_START(name)        \
155
        .type name,@function;   \
156
        .globl name;            \
157
name:
158
 
159
#define FUNC_END(name)          \
160
        /* nothing for now */
161
 
162
##-----------------------------------------------------------------------------
163
## PowerPC FPU state handling
164
## The PowerPC ABI defines f14-f31 as callee saved. There is thus no need to
165
## save them when calling C functions
166
 
167
#ifdef CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT
168
# define MAX_SAVE_FREG    13
169
#else
170
# define MAX_SAVE_FREG    31
171
#endif
172
 
173
        .macro  hal_fpu_save regs
174
#ifdef CYGHWR_HAL_POWERPC_FPU
175
        .set _freg, 0
176
        .rept MAX_SAVE_FREG+1
177
        stfd _freg,(CYGARC_PPCREG_FREGS+_freg*8)(\regs)
178
        .set _freg, _freg+1
179
        .endr
180
#endif
181
        .endm
182
 
183
        .macro  hal_fpu_load regs
184
#ifdef CYGHWR_HAL_POWERPC_FPU
185
        .set _freg, 0
186
        .rept MAX_SAVE_FREG+1
187
        lfd _freg,(CYGARC_PPCREG_FREGS+_freg*8)(\regs)
188
        .set _freg, _freg+1
189
        .endr
190
#endif
191
        .endm
192
 
193
##-----------------------------------------------------------------------------
194
## CPU specific macros. These provide a common assembler interface to
195
## operations that may have CPU specific implementations on different
196
## variants of the architecture.
197
 
198
#if !defined(CYGHWR_HAL_POWERPC_BOOK_E)
199
#define CYGARC_REG_MSR_INTBITS     CYGARC_REG_MSR_EE
200
#else
201
#define CYGARC_REG_MSR_INTBITS     (CYGARC_REG_MSR_EE|CYGARC_REG_MSR_CE)
202
#endif
203
 
204
        # Enable interrupts
205
        .macro hal_cpu_int_enable
206
        mfmsr   r0
207
        lwi      r3,CYGARC_REG_MSR_INTBITS
208
        or       r0,r0,r3
209
        sync
210
        mtmsr   r0
211
        sync
212
        .endm
213
 
214
        # Disable interrupts
215
        .macro hal_cpu_int_disable
216
        mfmsr   r0
217
        lwi      r3,~CYGARC_REG_MSR_INTBITS
218
        and      r0,r0,r3
219
        sync
220
        mtmsr   r0
221
        sync
222
        .endm
223
 
224
        # Merge the interrupt enable state of the status register in
225
        # \sr with the current sr.
226
        .macro  hal_cpu_int_merge sr,wr
227
        mfmsr   r0
228
        lwi      \wr,CYGARC_REG_MSR_INTBITS
229
        and      \wr,\wr,\sr
230
        or       r0,r0,\wr
231
        sync
232
        mtmsr   r0
233
        sync
234
        .endm
235
 
236
#------------------------------------------------------------------------------
237
# Book E variations
238
#
239
# These macros implement things that vary between the AIM architecture and
240
# Book E.
241
 
242
#if !defined(CYGHWR_HAL_POWERPC_BOOK_E)
243
 
244
#ifdef CYGSEM_HAL_POWERPC_COPY_VECTORS
245
 
246
        .macro  hal_vectors_init
247
        lwi     r3,rom_vectors-4
248
        lwi     r4,((CYGHWR_HAL_POWERPC_VECTOR_BASE)-4)
249
        lwi     r5,rom_vectors_end-4
250
        sub     r5,r5,r3                # compute number of words to copy
251
        srwi    r5,r5,2
252
        mtctr   r5
253
0:      lwzu    r0,4(r3)
254
        stwu    r0,4(r4)
255
        bdnz    0b
256
        .endm
257
 
258
#define HAL_VECTORS_INIT_DEFINED
259
 
260
#endif
261
 
262
#else // !defined(CYGHWR_HAL_POWERPC_BOOK_E)
263
 
264
#if defined(CYGSEM_HAL_POWERPC_COPY_VECTORS)
265
 
266
 
267
#if defined(CYGHWR_HAL_POWERPC_BOOK_E_FIXED_VECTORS)
268
        .macro  hal_ivor_init   ivor,handler
269
        .endm
270
#else
271
        .macro  hal_ivor_init   ivor,handler
272
        lwi     r3,__exception_\handler
273
        and     r3,r3,r4
274
        mtspr   \ivor,r3
275
        .endm
276
#endif
277
 
278
        .macro  hal_vectors_init
279
 
280
#if defined(CYGHWR_HAL_POWERPC_BOOK_E_FIXED_VECTORS)
281
        lwi     r3,hal_fixed_vectors_base
282
        lwi     r4,0xFFFFF000
283
#else
284
        lwi     r3,rom_vectors
285
        lwi     r4,0xFFFF0000
286
#endif
287
        and     r3,r3,r4
288
        mtspr   63,r3
289
#if defined(CYGHWR_HAL_POWERPC_NEED_VECTORS)
290
        lwi     r4,0x0000FFF0
291
        hal_ivor_init   400,critical_input
292
        hal_ivor_init   401,machine_check
293
        hal_ivor_init   402,data_storage
294
        hal_ivor_init   403,instruction_storage
295
        hal_ivor_init   404,external
296
        hal_ivor_init   405,alignment
297
        hal_ivor_init   406,program
298
        hal_ivor_init   407,floatingpoint_unavailable
299
        hal_ivor_init   408,system_call
300
        hal_ivor_init   409,ap_unavailable
301
        hal_ivor_init   410,decrementer
302
        hal_ivor_init   411,interval_timer
303
        hal_ivor_init   412,watchdog
304
        hal_ivor_init   413,data_tlb_miss
305
        hal_ivor_init   414,instruction_tlb_miss
306
        hal_ivor_init   415,debug
307
#endif
308
        .endm
309
 
310
#define HAL_VECTORS_INIT_DEFINED
311
 
312
#endif
313
 
314
#if defined(CYGHWR_HAL_POWERPC_BOOK_E_FIXED_VECTORS)
315
 
316
        .macro  exception_vector_fixed name
317
        .p2align 4
318
        .globl   exception_vector_fixed\name
319
exception_vector_fixed\name:
320
        b        __exception_\name
321
        .endm
322
 
323
        .macro  hal_fixed_vectors
324
hal_fixed_vectors_base:
325
        exception_vector_fixed          critical_input
326
        exception_vector_fixed          machine_check
327
        exception_vector_fixed          data_storage
328
        exception_vector_fixed          instruction_storage
329
        exception_vector_fixed          external
330
        exception_vector_fixed          alignment
331
        exception_vector_fixed          program
332
        exception_vector_fixed          floatingpoint_unavailable
333
        exception_vector_fixed          system_call
334
        exception_vector_fixed          ap_unavailable
335
        exception_vector_fixed          decrementer
336
        exception_vector_fixed          interval_timer
337
        exception_vector_fixed          watchdog
338
        exception_vector_fixed          data_tlb_miss
339
        exception_vector_fixed          instruction_tlb_miss
340
        exception_vector_fixed          debug
341
        .endm
342
 
343
#define HAL_FIXED_VECTORS_DEFINED
344
 
345
#endif
346
 
347
 
348
#endif // !defined(CYGHWR_HAL_POWERPC_BOOK_E)
349
 
350
 
351
#if !defined(HAL_VECTORS_INIT_DEFINED)
352
 
353
        .macro  hal_vectors_init
354
        .endm
355
 
356
#endif
357
 
358
#ifndef HAL_FIXED_VECTORS_DEFINED
359
 
360
        .macro   hal_fixed_vectors
361
        .endm
362
 
363
#endif
364
 
365
#------------------------------------------------------------------------------
366
# end of arch.inc
367
 
368
#endif // _CYGONCE_HAL_POWERPC_ARCH_INC_

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.