Mercurial > ecos-v2_0-branch
annotate packages/hal/sparclite/sleb/current/src/hal_priv.c @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children | e0c0827131d1 |
| rev | line source |
|---|---|
| 2 | 1 //============================================================================= |
| 2 // | |
| 3 // hal_priv.c | |
| 4 // | |
| 5 // SPARClite Architecture sim-specific private variables | |
| 6 // | |
| 7 //============================================================================= | |
| 8 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
9 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
10 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
11 // The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
12 // Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
14 // http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
15 // |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
18 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
19 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // |
| 2 | 30 //####COPYRIGHTEND#### |
| 31 //============================================================================= | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 34 // Author(s): hmt | |
| 35 // Contributors:hmt | |
| 36 // Date: 1998-12-10 | |
| 37 // Purpose: private vars for SPARClite sim. | |
| 38 // | |
| 39 //####DESCRIPTIONEND#### | |
| 40 // | |
| 41 //============================================================================= | |
| 42 | |
| 43 | |
| 44 #include <pkgconf/system.h> | |
| 45 #include <pkgconf/hal.h> | |
| 46 #include <pkgconf/hal_sparclite.h> | |
| 47 #include <pkgconf/hal_sparclite_sleb.h> | |
| 48 | |
| 49 #include <cyg/infra/cyg_type.h> | |
| 50 #include <cyg/hal/hal_intr.h> | |
| 51 #include <cyg/hal/hal_arch.h> | |
| 52 | |
| 53 #ifdef CYGPKG_KERNEL | |
| 54 #include <pkgconf/kernel.h> // CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT | |
| 55 #endif | |
| 56 | |
| 57 #include <cyg/hal/hal_clock.h> | |
| 58 | |
| 59 // ------------------------------------------------------------------------ | |
| 60 // Clock static to keep period recorded. | |
| 61 cyg_int32 cyg_hal_sparclite_clock_period = 0; | |
| 62 | |
| 63 /* Address of clock switch */ | |
| 64 #define CLKSW_ADDR 0x01000003 | |
| 65 | |
| 66 #define HAL_SPARC_86940_TIMER1_CONTROL_INIT ( \ | |
| 67 0 | \ | |
| 68 HAL_SPARC_86940_TCR_CLKPRS | \ | |
| 69 HAL_SPARC_86940_TCR_OUTLOW ) | |
| 70 // Disable, CLKSEL=prescale(2), periodic interrupts, gate 0 | |
| 71 // and lower the output: OUTCTL = 2 | |
| 72 | |
| 73 #define HAL_SPARC_86940_TIMER1_CONTROL_ENABLE ( \ | |
| 74 HAL_SPARC_86940_TCR_CE | \ | |
| 75 HAL_SPARC_86940_TCR_CLKPRS | \ | |
| 76 HAL_SPARC_86940_TCR_OUTSAME ) | |
| 77 // Enable + .... and no change to the output: OUTCTL = 0 | |
| 78 | |
| 79 void hal_clock_initialize( cyg_uint32 p ) | |
| 80 { | |
| 81 cyg_uint32 ints; | |
| 82 cyg_uint32 clk; | |
| 83 HAL_DISABLE_INTERRUPTS( ints ); | |
| 84 | |
| 85 HAL_SPARC_86940_TIMER1_CONTROL_WRITE( | |
| 86 HAL_SPARC_86940_TIMER1_CONTROL_INIT ); // Make sure it's disabled | |
| 87 | |
| 88 // Clear any pending interrupts: | |
| 89 HAL_INTERRUPT_ACKNOWLEDGE( CYGNUM_HAL_INTERRUPT_RTC ); | |
| 90 | |
| 91 clk = *(unsigned char *)CLKSW_ADDR; | |
| 92 if (clk & 0x80) | |
| 93 clk = 10; | |
| 94 | |
| 95 /* could be 10 - 62 MHz */ | |
| 96 clk = (clk & 0x3f); /* in MHz */ | |
| 97 // BUT the 86940 is internally clocked at half that speed (page 20 RHS) | |
| 98 clk >>= 1; | |
| 99 // so the clock is now the number of system ticks we want per counter | |
| 100 // tick... | |
| 101 HAL_SPARC_86940_TIMER1_PRESCALER_WRITE( | |
| 102 0 /* internal clock */ | | |
| 103 HAL_SPARC_86940_PRS_ODIV1 | | |
| 104 clk ); | |
| 105 // should give 1MHz on the externally visible counter... | |
| 106 HAL_SPARC_86940_TIMER1_CONTROL_WRITE( | |
| 107 HAL_SPARC_86940_TIMER1_CONTROL_INIT ); | |
| 108 HAL_SPARC_86940_TIMER1_RELOAD_WRITE( p ); | |
| 109 HAL_SPARC_86940_TIMER1_CONTROL_WRITE( | |
| 110 HAL_SPARC_86940_TIMER1_CONTROL_ENABLE ); | |
| 111 HAL_SPARC_86940_TIMER1_RELOAD_WRITE( p ); | |
| 112 cyg_hal_sparclite_clock_period = p; | |
| 113 HAL_RESTORE_INTERRUPTS( ints ); | |
| 114 } | |
| 115 | |
| 116 // ------------------------------------------------------------------------ | |
| 117 | |
| 118 #ifdef CYG_HAL_USE_ROM_MONITOR_CYGMON | |
| 119 #include <cyg/hal/hal_cygm.h> // CygMon vector table & layout | |
| 120 | |
| 121 static struct { int eCosV, CygMonV; } setup[] = { | |
| 122 { CYGNUM_HAL_VECTOR_OTHERS , BSP_EXC_TRAP }, | |
| 123 { CYGNUM_HAL_VECTOR_FETCH_ABORT , BSP_EXC_IACCESS }, | |
| 124 { CYGNUM_HAL_VECTOR_ILLEGAL_OP , BSP_EXC_ILL }, | |
| 125 { CYGNUM_HAL_VECTOR_PRIV_OP , BSP_EXC_IPRIV }, | |
| 126 { CYGNUM_HAL_VECTOR_UNALIGNED , BSP_EXC_ALIGN }, | |
| 127 { CYGNUM_HAL_VECTOR_DATA_ABORT , BSP_EXC_DACCESS }, | |
| 128 }; | |
| 129 | |
| 130 #endif // CYG_HAL_USE_ROM_MONITOR_CYGMON | |
| 131 | |
| 132 // ------------------------------------------------------------------------ | |
| 133 // Board specific startups. | |
| 134 | |
| 135 extern void hal_board_prestart( void ); | |
| 136 extern void hal_board_poststart( void ); | |
| 137 | |
| 138 #define SLEB_LED (*(volatile char *)(0x02000003)) | |
| 139 | |
| 140 #define LED( _x_ ) SLEB_LED = (char)(0xff & ~(_x_)) | |
| 141 | |
| 142 void hal_board_prestart( void ) | |
| 143 { | |
| 144 | |
| 145 LED( 0xc0 ); | |
| 146 | |
| 147 // Disable default clocks &c | |
| 148 HAL_SPARC_86940_TIMER1_PRESCALER_WRITE( 1 ); // as if at reset | |
| 149 HAL_SPARC_86940_TIMER1_CONTROL_WRITE( 0 ); // as if at reset | |
| 150 | |
| 151 #ifdef CYG_HAL_USE_ROM_MONITOR_CYGMON | |
| 152 // then initialize our vectors to point to (or bounce to) | |
| 153 // CygMon's equivalent functionality. | |
| 154 { | |
| 155 extern void hal_user_trap_to_cygmon_vsr( void ); | |
| 156 extern void hal_nofpcp_trap_to_cygmon_vsr( void ); | |
| 157 extern void hal_nmi_handler( void ); | |
| 158 int i; | |
| 159 | |
| 160 HAL_VSR_SET( CYGNUM_HAL_VECTOR_USER_TRAP, | |
| 161 (CYG_ADDRESS)hal_user_trap_to_cygmon_vsr, NULL ); | |
| 162 | |
| 163 HAL_VSR_SET( CYGNUM_HAL_VECTOR_NOFPCP, | |
| 164 (CYG_ADDRESS)hal_nofpcp_trap_to_cygmon_vsr, NULL ); | |
| 165 | |
| 166 for ( i = 0; i < sizeof(setup)/sizeof(setup[0]); i++ ) | |
| 167 HAL_VSR_SET( setup[i].eCosV, | |
| 168 CYGMON_VECTOR_TABLE[ setup[i].CygMonV ], NULL ); | |
| 169 | |
| 170 // Just point this one straight though, and unmask it. | |
| 171 // That way CygMon looks after ^Cs itself. | |
| 172 HAL_VSR_SET( CYGNUM_HAL_VECTOR_INTERRUPT_10, | |
| 173 CYGMON_VECTOR_TABLE[ BSP_EXC_INT10 ], NULL ); | |
| 174 HAL_INTERRUPT_UNMASK( CYGNUM_HAL_VECTOR_INTERRUPT_10 ); | |
| 175 | |
| 176 // Just point this one straight though, and unmask it. | |
| 177 // That way CygMon looks after the Ethernet itself. | |
| 178 HAL_VSR_SET( CYGNUM_HAL_VECTOR_INTERRUPT_14, | |
| 179 CYGMON_VECTOR_TABLE[ BSP_EXC_INT14 ], NULL ); | |
| 180 HAL_INTERRUPT_UNMASK( CYGNUM_HAL_VECTOR_INTERRUPT_14 ); | |
| 181 | |
| 182 // Install handler for the NMI button on the board | |
| 183 HAL_VSR_SET( CYGNUM_HAL_VECTOR_INTERRUPT_15, | |
| 184 (CYG_ADDRESS)hal_nmi_handler, NULL ); | |
| 185 HAL_INTERRUPT_UNMASK( CYGNUM_HAL_VECTOR_INTERRUPT_15 ); | |
| 186 | |
| 187 LED( 0xc4 ); | |
| 188 | |
| 189 #ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT | |
| 190 { | |
| 191 extern void patch_dbg_syscalls(void * vector); | |
| 192 patch_dbg_syscalls( (void *)CYGMON_VECTOR_TABLE ); | |
| 193 } | |
| 194 #endif // CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT | |
| 195 | |
| 196 } | |
| 197 #endif // CYG_HAL_USE_ROM_MONITOR_CYGMON | |
| 198 | |
| 199 LED( 0xc8 ); | |
| 200 } | |
| 201 | |
| 202 void hal_board_poststart( void ) | |
| 203 { | |
| 204 LED( 0xe0 ); | |
| 205 HAL_ENABLE_INTERRUPTS(); | |
| 206 LED( 0xf0 ); | |
| 207 } | |
| 208 | |
| 209 | |
| 210 // EOF hal_priv.c |
