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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [h8300/] [h8s/] [current/] [include/] [variant.inc] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_VARIANT_INC
2
#define CYGONCE_HAL_VARIANT_INC
3
##=============================================================================
4
##
5
##      variant.inc
6
##
7
##      H8S 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 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):   ysato
45
## Contributors:        ysato
46
## Date:        2003-01-01
47
## Purpose:     H8S definitions.
48
## Description: This file contains various definitions and macros that are
49
##              useful for writing assembly code for the H8/300H CPU variant.
50
## Usage:
51
##              #include 
52
##              ...
53
##
54
##
55
######DESCRIPTIONEND####
56
##
57
##=============================================================================
58
 
59
#include 
60
 
61
#include 
62
#include 
63
 
64
 
65
#------------------------------------------------------------------------------
66
# Register definitions
67
 
68
#define INTCR 0xffff31
69
 
70
#------------------------------------------------------------------------------
71
# CPU state save and restore macros
72
 
73
        .macro  hal_cpu_save_all
74
        subs    #2,sp                           ; reserve space
75
        subs    #4,sp
76
        mov.l   sp,@-sp
77
        stm     er0-er3,@-sp
78
        stm     er4-er6,@-sp
79
        sub.w   e0,e0
80
        mov.w   e0,@(4*9:16,sp)                 ; clear exr high word
81
        mov.w   @(4*10:16,sp),r0
82
        sub.l   er1,er1
83
        mov.b   r0h,r1l
84
        mov.l   er1,@(4*8:16,sp)                ; copy ccr
85
        mov.l   @(4*6:16,sp),er0
86
        mov.l   @(4*5:16,sp),er1
87
        .endm
88
 
89
        .macro  hal_cpu_load_all
90
        mov.w   @(4*8+2:16,sp),r1               ; load ccr
91
        mov.w   @(4*10:16,sp),r0                ; load pc+ccr high word
92
        mov.b   r1l,r0h                         ; replace ccr byte
93
        mov.w   r0,@(4*10:16,sp)                ; restore pc+ccr high word
94
        mov.w   @(4*9+2:16,sp),r0
95
        mov.b   r0l,r0h
96
        mov.w   r0,@(4*9+2:16,sp)               ; extend exr
97
        ldm     @sp+,er4-er6
98
        ldm     @sp+,er0-er3
99
        add.l   #10,sp
100
        .endm
101
 
102
        .macro hal_cpu_save_context
103
        stc     exr,r2l
104
        mov.b   r2l,r2h
105
        mov.w   r2,@-sp
106
        hal_cpu_save_all
107
        .endm
108
 
109
        .macro  h8300_var_interrupt_entry
110
        mov.l   @CYG_LABEL_DEFN(_intvector),er0
111
        shll.l  #2,er0
112
        mov.l   @(CYG_LABEL_DEFN(hal_vsr_table),er0),er0
113
        .endm
114
 
115
        .macro  h8300_var_call_pending_DSR
116
        mov.l   er5,@-sp                        ; save some work regs
117
        mov.l   er6,@-sp
118
        mov.l   sp,er6                          ; save current SP
119
        mov.l   #__interrupt_stack,sp           ; interrupt stack pointer
120
        stc     exr,r5l                         ; save PSW
121
        hal_cpu_int_enable                      ; enable interrupts
122
 
123
        ; Call kernel code to invoke DSRs.
124
        jsr     @CYG_LABEL_DEFN(cyg_interrupt_call_pending_DSRs)
125
 
126
        ; On return the old SP in a2 and the old PSW in d2 will
127
        ; have been preserved by the calling conventions.
128
 
129
        hal_cpu_int_merge r5l                   ; Restore previous PSW
130
        mov.l   er6,sp                          ; restore old SP
131
        mov.l   @sp+,er6                        ; Retrieve old work regs
132
        mov.l   @sp+,er5
133
        rts                                     ; and return
134
        .endm
135
 
136
# Location of PC in saved register context (HAL_SavedRegisters)
137
#define SAVED_CONTEXT_PC_OFFSET (4*10)
138
 
139
        # Enable interrupts
140
        .macro hal_cpu_int_enable
141
        andc    #0xf8,exr
142
        .endm
143
 
144
        # Disable interrupts
145
        .macro hal_cpu_int_disable
146
        orc     #0x07,exr
147
        .endm
148
 
149
        # Merge the interrupt enable state of the status register in
150
        # \sr with the current sr.
151
        .macro  hal_cpu_int_merge sr wk=r0l
152
        and.b   #0x07,\sr
153
        stc     exr,\wk
154
        and.b   #0xf8,\wk
155
        or.b    \sr,\wk
156
        ldc     \wk,exr
157
        .endm
158
 
159
        .macro  hal_cpu_set_int_level
160
        ldc     exr,r0h
161
        and.b   #0xf8,r0h
162
        or.b    r0l,r0h
163
        mov.b   r0h,exr
164
        .endm
165
 
166
        .macro  h8300_trap_adjust_pc
167
        mov.l   @(40:16,sp),er0
168
        subs    #2,er0
169
        mov.l   er0,@(40:16,sp)
170
        .endm
171
 
172
##-----------------------------------------------------------------------------
173
# Default interrupt decoding macros.
174
 
175
#ifndef CYGPKG_HAL_H8300_INTC_DEFINED
176
 
177
#define CYG_ISR_TABLE_SIZE       128
178
 
179
        .macro  hal_intc_init
180
        mov.b   @INTCR,r0l
181
        bclr    #4,r0l
182
        bset    #5,r0l
183
        mov.b   r0l,@INTCR              ; interrupt mode 2
184
        .endm
185
 
186
#define CYGPKG_HAL_H8300_INTC_DEFINED
187
 
188
#endif
189
 
190
 
191
 
192
#ifndef CYGPKG_HAL_H8300_MON_DEFINED
193
 
194
        .macro  hal_mon_init
195
        .endm
196
 
197
#if !(defined(CYG_HAL_STARTUP_ROM)              || \
198
        defined(CYGPKG_HAL_H8300_H8300H_SIM)    || \
199
        !defined(CYGSEM_HAL_USE_ROM_MONITOR))
200
 
201
#define CYG_HAL_H8300_VSR_TABLE_DEFINED
202
 
203
#endif
204
 
205
 
206
 
207
#define CYGPKG_HAL_H8300_MON_DEFINED
208
 
209
#endif
210
 
211
#ifndef CYGPKG_HAL_H8300_CPU_INIT_DEFINED
212
#define CYGPKG_HAL_H8300_CPU_INIT_DEFINED
213
        # Initialize CPU
214
        .macro  hal_cpu_init
215
        # Set up the PSW
216
        ldc     #0x80,ccr
217
        ldc     #0x07,exr
218
        .endm
219
#endif
220
 
221
#------------------------------------------------------------------------------
222
#endif // ifndef CYGONCE_HAL_VARIANT_INC
223
# end of variant.inc

powered by: WebSVN 2.1.0

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