comparison packages/hal/mips/jmr3904/current/src/plf_misc.c @ 6:d376b777e2ce ecos-sw-1999-05-14

Merge from eCos master repository on 1999-05-14-19:27:43-BST
author jlarmour
date Fri, 14 May 1999 12:20:00 +0000
parents
children d3fbcdfa1b2f
comparison
equal deleted inserted replaced
5:4e8259f41183 6:d376b777e2ce
1 //==========================================================================
2 //
3 // plf_misc.c
4 //
5 // HAL platform miscellaneous functions
6 //
7 //==========================================================================
8 //####COPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 // The contents of this file are subject to the Cygnus eCos Public License
12 // Version 1.0 (the "License"); you may not use this file except in
13 // compliance with the License. You may obtain a copy of the License at
14 // http://sourceware.cygnus.com/ecos
15 //
16 // Software distributed under the License is distributed on an "AS IS"
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18 // License for the specific language governing rights and limitations under
19 // the License.
20 //
21 // The Original Code is eCos - Embedded Cygnus Operating System, released
22 // September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Cygnus. Portions created
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved.
26 // -------------------------------------------
27 //
28 //####COPYRIGHTEND####
29 //==========================================================================
30 //#####DESCRIPTIONBEGIN####
31 //
32 // Author(s): nickg
33 // Contributors: nickg, jlarmour
34 // Date: 1999-01-21
35 // Purpose: HAL miscellaneous functions
36 // Description: This file contains miscellaneous functions provided by the
37 // HAL.
38 //
39 //####DESCRIPTIONEND####
40 //
41 //========================================================================*/
42
43 #include <pkgconf/hal.h>
44
45 #include <cyg/infra/cyg_type.h> // Base types
46 #include <cyg/infra/cyg_trac.h> // tracing macros
47 #include <cyg/infra/cyg_ass.h> // assertion macros
48
49 #include <cyg/hal/hal_arch.h> // architectural definitions
50
51 #include <cyg/hal/hal_intr.h> // Interrupt handling
52
53 #include <cyg/hal/hal_cache.h> // Cache handling
54
55 /*------------------------------------------------------------------------*/
56
57 extern void patch_dbg_syscalls(void * vector);
58
59 /*------------------------------------------------------------------------*/
60
61 void hal_platform_init(void)
62 {
63 // On the real hardware we also enable the cache.
64 // doing this here is a temporary measure until we
65 // have a proper platform specific place to do it.
66
67 #if !defined(CYGHWR_HAL_TX39_JMR3904_ENABLE_TOE)
68
69 HAL_ICACHE_INVALIDATE_ALL();
70 HAL_ICACHE_ENABLE();
71 HAL_DCACHE_INVALIDATE_ALL();
72 HAL_DCACHE_ENABLE();
73
74 HAL_TX39_DEBUG_TOE_DISABLE();
75
76 #else
77
78 // If TOE is enabled, caches are disabled by default
79 // until spurious Bus Timeout problem is fixed.
80
81 HAL_ICACHE_INVALIDATE_ALL();
82 HAL_ICACHE_DISABLE();
83 HAL_DCACHE_INVALIDATE_ALL();
84 HAL_DCACHE_DISABLE();
85
86 HAL_TX39_DEBUG_TOE_ENABLE();
87
88 #endif
89
90 #if 0
91 #if defined(CYG_HAL_USE_ROM_MONITOR) && \
92 !defined(CYGDBG_INFRA_DIAG_USE_DEVICE) && \
93 defined(CYG_HAL_TX39_JMR3904)
94
95 {
96 static void hal_init_ctrlc_intr(void);
97 hal_init_ctrlc_intr();
98 }
99
100 #endif
101 #endif
102
103 #if defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT) && \
104 defined(CYG_HAL_USE_ROM_MONITOR) && \
105 defined(CYG_HAL_USE_ROM_MONITOR_CYGMON)
106 {
107 patch_dbg_syscalls( (void *)(&hal_vsr_table[0]) );
108 }
109 #endif
110
111 }
112
113 /*------------------------------------------------------------------------*/
114 /* Functions to support the detection and execution of a user provoked */
115 /* program break. These are usually called from interrupt routines. */
116
117 cyg_bool cyg_hal_is_break(char *buf, int size)
118 {
119 while( size )
120 if( buf[--size] == 0x03 ) return true;
121
122 return false;
123 }
124
125 void cyg_hal_user_break( CYG_ADDRWORD *regs )
126 {
127 #if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
128
129 // Ctrl-C: breakpoint.
130 extern void breakpoint(void);
131 breakpoint();
132
133 #elif defined(CYG_HAL_USE_ROM_MONITOR) && defined(CYG_HAL_USE_ROM_MONITOR_GDB_STUBS)
134
135 // Ctrl-C: breakpoint.
136 typedef void bpt_fn(void);
137 bpt_fn *bfn = ((bpt_fn **)0x80000100)[61];
138 bfn();
139
140 #elif defined(CYG_HAL_USE_ROM_MONITOR) && defined(CYG_HAL_USE_ROM_MONITOR_CYGMON)
141
142 // Ctrl-C: breakpoint.
143 typedef void install_bpt_fn(void *epc);
144 HAL_SavedRegisters *sreg = (HAL_SavedRegisters *)regs;
145 install_bpt_fn *ibp = (install_bpt_fn *)hal_vsr_table[35];
146 if( ibp != NULL ) ibp((void *)sreg->pc);
147
148 #endif
149
150 }
151
152 /*------------------------------------------------------------------------*/
153 /* This code installs an interrupt handler to capture Ctrl-C. */
154
155 #if 0
156 #if defined(CYG_HAL_USE_ROM_MONITOR) && \
157 !defined(CYGDBG_INFRA_DIAG_USE_DEVICE) && \
158 defined(CYG_HAL_TX39_JMR3904)
159
160 #define DIAG_BASE 0xfffff300
161 #define DIAG_SLCR (DIAG_BASE+0x00)
162 #define DIAG_SLSR (DIAG_BASE+0x04)
163 #define DIAG_SLDICR (DIAG_BASE+0x08)
164 #define DIAG_SLDISR (DIAG_BASE+0x0C)
165 #define DIAG_SFCR (DIAG_BASE+0x10)
166 #define DIAG_SBRG (DIAG_BASE+0x14)
167 #define DIAG_TFIFO (DIAG_BASE+0x20)
168 #define DIAG_RFIFO (DIAG_BASE+0x30)
169
170 #define BRG_T0 0x0000
171 #define BRG_T2 0x0100
172 #define BRG_T4 0x0200
173 #define BRG_T5 0x0300
174
175 static cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data, CYG_ADDRWORD regs)
176 {
177 char c;
178 CYG_WORD16 disr;
179
180 HAL_READ_UINT16( DIAG_SLDISR , disr );
181
182 if( disr & 0x0001 )
183 {
184
185 disr = disr & ~0x0001;
186
187 HAL_READ_UINT8( DIAG_RFIFO, c );
188
189 HAL_WRITE_UINT16( DIAG_SLDISR , disr );
190
191 if( cyg_hal_is_break( &c , 1 ) )
192 cyg_hal_user_break( regs );
193 }
194
195 return 0;
196 }
197
198
199 static void hal_init_ctrlc_intr(void)
200 {
201 CYG_WORD16 dicr;
202
203 HAL_INTERRUPT_ATTACH( CYGNUM_HAL_INTERRUPT_SIO_0, hal_ctrlc_isr, NULL,
204 NULL );
205
206 HAL_INTERRUPT_UNMASK( CYGNUM_HAL_INTERRUPT_SIO_0 );
207
208 HAL_READ_UINT16( DIAG_SLDICR , dicr );
209 dicr = 0x0001;
210 HAL_WRITE_UINT16( DIAG_SLDICR , dicr );
211 }
212
213 #endif
214 #endif
215
216 /*------------------------------------------------------------------------*/
217 /* End of plf_misc.c */