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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [sh/] [arch/] [v2_0/] [include/] [hal_var_sp.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_VAR_BANK_H
2
#define CYGONCE_HAL_VAR_BANK_H
3
//=============================================================================
4
//
5
//      hal_var_bank.h
6
//
7
//      Architecture abstractions for variants without banked registers
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 Red Hat, 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 version.
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
// for more details.
23
//
24
// You should have received a copy of the GNU General Public License along
25
// with eCos; if not, write to the Free Software Foundation, Inc.,
26
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
//
28
// As a special exception, if other files instantiate templates or use macros
29
// or inline functions from this file, or you compile this file and link it
30
// with other works to produce a work based on this file, this file does not
31
// by itself cause the resulting work to be covered by the GNU General Public
32
// License. However the source code for this file must still be made available
33
// in accordance with section (3) of the GNU General Public License.
34
//
35
// This exception does not invalidate any other reasons why a work based on
36
// this file might be covered by the GNU General Public License.
37
//
38
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
// at http://sources.redhat.com/ecos/ecos-license/
40
// -------------------------------------------
41
//####ECOSGPLCOPYRIGHTEND####
42
//=============================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):   jskov
46
// Contributors:jskov
47
// Date:        2002-01-11
48
// Purpose:     Architecture abstractions for variants without banked registers
49
//              
50
//####DESCRIPTIONEND####
51
//
52
//=============================================================================
53
 
54
//-----------------------------------------------------------------------------
55
// Processor saved states:
56
 
57
typedef struct
58
{
59
    // These are common to all saved states
60
    cyg_uint32   r[16];                 // Data regs
61
    cyg_uint32   macl;                  // Multiply and accumulate - low
62
    cyg_uint32   mach;                  // Multiply and accumulate - high
63
    cyg_uint32   pr;                    // Procedure Reg
64
#if 0 // FIXME: how are these accessed?
65
    cyg_uint32   mod;                   // Modulo register
66
    cyg_uint32   rs;                    // Repeat start
67
    cyg_uint32   re;                    // Repeat end
68
#endif
69
    cyg_uint32   sr;                    // Status Reg
70
    cyg_uint32   pc;                    // Program Counter
71
 
72
    // This marks the limit of state saved during a context switch and
73
    // is used to calculate necessary stack allocation for context switches.
74
    // It would probably be better to have a union instead...
75
    cyg_uint32   context_size[0];
76
 
77
    // These are only saved on interrupts
78
    cyg_uint32   vbr;                   // Vector Base Register
79
    cyg_uint32   gbr;                   // Global Base Register
80
 
81
    // These are only saved on interrupts
82
    cyg_uint32   event;                // vector number
83
} HAL_SavedRegisters;
84
 
85
//-----------------------------------------------------------------------------
86
// Context Initialization
87
// Initialize the context of a thread.
88
// Arguments:
89
// _sparg_ name of variable containing current sp, will be written with new sp
90
// _thread_ thread object address, passed as argument to entry point
91
// _entry_ entry point address.
92
// _id_ bit pattern used in initializing registers, for debugging.
93
 
94
#define HAL_THREAD_INIT_CONTEXT( _sparg_, _thread_, _entry_, _id_ )           \
95
    CYG_MACRO_START                                                           \
96
    register HAL_SavedRegisters *_regs_;                                      \
97
    int _i_;                                                                  \
98
    _regs_ = (HAL_SavedRegisters *)((_sparg_) - sizeof(HAL_SavedRegisters));  \
99
    for( _i_ = 0; _i_ < 16; _i_++ ) (_regs_)->r[_i_] = (_id_)|_i_;            \
100
    (_regs_)->r[15] = (CYG_WORD)(_regs_);      /* SP = top of stack      */   \
101
    (_regs_)->r[04] = (CYG_WORD)(_thread_);    /* R4 = arg1 = thread ptr */   \
102
    (_regs_)->mach = 0;                        /* MACH = 0               */   \
103
    (_regs_)->macl = 0;                        /* MACL = 0               */   \
104
    (_regs_)->pr = (CYG_WORD)(_entry_);        /* PR = entry point       */   \
105
    (_regs_)->sr = 0;                          /* SR = enable interrupts */   \
106
    (_regs_)->pc = (CYG_WORD)(_entry_);        /* set PC for thread dbg  */   \
107
    _sparg_ = (CYG_ADDRESS)_regs_;                                            \
108
    CYG_MACRO_END
109
 
110
//-----------------------------------------------------------------------------
111
// Thread register state manipulation for GDB support.
112
 
113
// Translate a stack pointer as saved by the thread context macros above into
114
// a pointer to a HAL_SavedRegisters structure.
115
#define HAL_THREAD_GET_SAVED_REGISTERS( _sp_, _regs_ )  \
116
        (_regs_) = (HAL_SavedRegisters *)(_sp_)
117
 
118
// Copy a set of registers from a HAL_SavedRegisters structure into a
119
// GDB ordered array.    
120
#define HAL_GET_GDB_REGISTERS( _aregval_, _regs_ )              \
121
    CYG_MACRO_START                                             \
122
    CYG_ADDRWORD *_regval_ = (CYG_ADDRWORD *)(_aregval_);       \
123
    int _i_;                                                    \
124
                                                                \
125
    for( _i_ = 0; _i_ < 16; _i_++ )                             \
126
        _regval_[_i_] = (_regs_)->r[_i_];                       \
127
                                                                \
128
    _regval_[16] = (_regs_)->pc;                                \
129
    _regval_[17] = (_regs_)->pr;                                \
130
    _regval_[18] = (_regs_)->gbr;                               \
131
    _regval_[19] = (_regs_)->vbr;                               \
132
    _regval_[20] = (_regs_)->mach;                              \
133
    _regval_[21] = (_regs_)->macl;                              \
134
    _regval_[22] = (_regs_)->sr;                                \
135
                                                                \
136
    /* 23-51 not used atm. */                                   \
137
    CYG_MACRO_END
138
 
139
// Copy a GDB ordered array into a HAL_SavedRegisters structure.
140
#define HAL_SET_GDB_REGISTERS( _regs_ , _aregval_ )             \
141
    CYG_MACRO_START                                             \
142
    CYG_ADDRWORD *_regval_ = (CYG_ADDRWORD *)(_aregval_);       \
143
    int _i_;                                                    \
144
                                                                \
145
    for( _i_ = 0; _i_ < 16; _i_++ )                             \
146
        (_regs_)->r[_i_] = _regval_[_i_];                       \
147
                                                                \
148
    (_regs_)->pc = _regval_[16];                                \
149
    (_regs_)->pr = _regval_[17];                                \
150
    (_regs_)->gbr  = _regval_[18];                              \
151
    (_regs_)->vbr  = _regval_[19];                              \
152
    (_regs_)->mach = _regval_[20];                              \
153
    (_regs_)->macl = _regval_[21];                              \
154
    (_regs_)->sr = _regval_[22];                                \
155
    CYG_MACRO_END
156
 
157
//--------------------------------------------------------------------------
158
// CPU address space translation macros
159
#define CYGARC_BUS_ADDRESS(x)       ((CYG_ADDRWORD)(x) & 0x1fffffff)
160
#define CYGARC_CACHED_ADDRESS(x)    (CYGARC_BUS_ADDRESS(x)|0x00000000)
161
#define CYGARC_UNCACHED_ADDRESS(x)  (CYGARC_BUS_ADDRESS(x)|0x20000000)
162
 
163
//-----------------------------------------------------------------------------
164
#endif // CYGONCE_HAL_VAR_BANK_H
165
// End of hal_var_bank.h

powered by: WebSVN 2.1.0

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