Mercurial > nand-ecoscentric
comparison packages/hal/arm/cma230/current/src/cma230_misc.c @ 46:797268ecc331 ecos-sw-1999-10-19
Merge from eCos master repository on 1999-10-19-18:55:31-BST
| author | jlarmour |
|---|---|
| date | Tue, 19 Oct 1999 19:19:52 +0000 |
| parents | |
| children | c38311975d4f |
comparison
equal
deleted
inserted
replaced
| 45:91d213c0da48 | 46:797268ecc331 |
|---|---|
| 1 //========================================================================== | |
| 2 // | |
| 3 // cma230_misc.c | |
| 4 // | |
| 5 // HAL misc board support code for ARM CMA230-1 | |
| 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): gthomas | |
| 33 // Contributors: gthomas | |
| 34 // Date: 1999-02-20 | |
| 35 // Purpose: HAL board support | |
| 36 // Description: Implementations of HAL board interfaces | |
| 37 // | |
| 38 //####DESCRIPTIONEND#### | |
| 39 // | |
| 40 //========================================================================*/ | |
| 41 | |
| 42 #include <pkgconf/hal.h> | |
| 43 | |
| 44 #include <cyg/infra/cyg_type.h> // base types | |
| 45 #include <cyg/infra/cyg_trac.h> // tracing macros | |
| 46 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 47 | |
| 48 #include <cyg/hal/hal_io.h> // IO macros | |
| 49 #include <cyg/hal/hal_arch.h> // Register state info | |
| 50 #include <cyg/hal/hal_diag.h> | |
| 51 #include <cyg/hal/hal_intr.h> // Interrupt names | |
| 52 #include <cyg/hal/hal_cache.h> | |
| 53 #include <cyg/hal/hal_cma230.h> // Hardware definitions | |
| 54 | |
| 55 static cyg_uint32 _period; | |
| 56 | |
| 57 // Use Timer/Counter #2 for system clock | |
| 58 | |
| 59 void hal_clock_initialize(cyg_uint32 period) | |
| 60 { | |
| 61 // Initialize counter | |
| 62 *(volatile cyg_uint16 *)CMA230_TC_ENABLE = 0; // Disable timer | |
| 63 *(volatile cyg_uint16 *)CMA230_TC_CLEAR = 0; // Resets counter | |
| 64 *(volatile cyg_uint16 *)CMA230_TC_PRELOAD = period; | |
| 65 *(volatile cyg_uint16 *)CMA230_TC_ENABLE = 1; // Starts timer | |
| 66 _period = period; | |
| 67 } | |
| 68 | |
| 69 // This routine is called during a clock interrupt. | |
| 70 | |
| 71 void hal_clock_reset(cyg_uint32 vector, cyg_uint32 period) | |
| 72 { | |
| 73 if (period != _period) { | |
| 74 *(volatile cyg_uint16 *)CMA230_TC_PRELOAD = period; | |
| 75 _period = period; | |
| 76 } | |
| 77 } | |
| 78 | |
| 79 // Read the current value of the clock, returning the number of hardware "ticks" | |
| 80 // that have occurred (i.e. how far away the current value is from the start) | |
| 81 | |
| 82 void hal_clock_read(cyg_uint32 *pvalue) | |
| 83 { | |
| 84 volatile cyg_int16 *tcct = (volatile cyg_int16 *)CMA230_TC_COUNT; | |
| 85 static cyg_int32 clock_val; | |
| 86 clock_val = *tcct; // Register has only 16 bits | |
| 87 *pvalue = (cyg_uint32)(_period - clock_val); // 'clock_val' counts down and wraps | |
| 88 } | |
| 89 | |
| 90 // | |
| 91 // Early stage hardware initialization | |
| 92 // Some initialization has already been done before we get here. For now | |
| 93 // just set up the interrupt environment. | |
| 94 | |
| 95 // Note: The hardware interrupt mask (read) doesn't seem to give reliable results. | |
| 96 static cyg_uint8 _imrr; | |
| 97 #undef CMA230_IMRr | |
| 98 #define CMA230_IMRr (&_imrr) | |
| 99 | |
| 100 void hal_hardware_init(void) | |
| 101 { | |
| 102 #if 0 | |
| 103 // Clear and initialize instruction cache | |
| 104 HAL_ICACHE_INVALIDATE_ALL(); | |
| 105 HAL_ICACHE_ENABLE(); | |
| 106 #endif | |
| 107 // Any hardware/platform initialization that needs to be done. | |
| 108 // Reset all interrupt masks (disable all interrupt sources) | |
| 109 *(volatile cyg_uint8 *)CMA230_IMRw = 0; | |
| 110 *(volatile cyg_uint8 *)CMA230_CLR = 0xFF; // Clear all current interrupts | |
| 111 } | |
| 112 | |
| 113 // | |
| 114 // This routine is called to respond to a hardware interrupt (IRQ). It | |
| 115 // should interrogate the hardware and return the IRQ vector number. | |
| 116 | |
| 117 // TEMP | |
| 118 int tot_ints; | |
| 119 cyg_uint32 int_PC[2048]; | |
| 120 // TEMP | |
| 121 | |
| 122 #if 0 | |
| 123 int hal_IRQ_handler(void) | |
| 124 #else | |
| 125 int hal_IRQ_handler(HAL_SavedRegisters *regs) | |
| 126 #endif | |
| 127 { | |
| 128 volatile cyg_uint8 isr = *(volatile cyg_uint8 *)CMA230_ISR; | |
| 129 volatile cyg_uint8 *imrr = (volatile cyg_uint8 *)CMA230_IMRr; | |
| 130 int vector; | |
| 131 isr &= *imrr; // The Interrupt Source Register shows _all_ current | |
| 132 // interrupt sources, not just the enabled ones | |
| 133 // TEMP | |
| 134 int_PC[tot_ints++] = 0xFFFFFFFF; | |
| 135 int_PC[tot_ints++] = isr; | |
| 136 int_PC[tot_ints++] = regs->cpsr; | |
| 137 int_PC[tot_ints++] = regs->pc; | |
| 138 if (tot_ints == 2048) tot_ints = 0; | |
| 139 // TEMP | |
| 140 for (vector = 0; vector < 8; vector++) { | |
| 141 if (isr & (1<<vector)) { | |
| 142 return (vector+1); | |
| 143 } | |
| 144 } | |
| 145 return CYGNUM_HAL_INTERRUPT_unused; // This shouldn't happen! | |
| 146 } | |
| 147 | |
| 148 // | |
| 149 // Interrupt control | |
| 150 // | |
| 151 | |
| 152 // Disable (mask) an interrupt | |
| 153 void hal_interrupt_mask(int vector) | |
| 154 { | |
| 155 volatile cyg_uint8 *imrr = (volatile cyg_uint8 *)CMA230_IMRr; | |
| 156 volatile cyg_uint8 *imrw = (volatile cyg_uint8 *)CMA230_IMRw; | |
| 157 cyg_uint8 new_mask = *imrr & ~(1<<(vector-1)); | |
| 158 *imrw = new_mask; | |
| 159 // TEMP | |
| 160 *imrr = new_mask; | |
| 161 // TEMP | |
| 162 // diag_printf("Mask interrupt #%d - mask: %x\n", vector, *imrr); | |
| 163 } | |
| 164 | |
| 165 // Enable (unmask) an interrupt | |
| 166 void hal_interrupt_unmask(int vector) | |
| 167 { | |
| 168 volatile cyg_uint8 *imrr = (volatile cyg_uint8 *)CMA230_IMRr; | |
| 169 volatile cyg_uint8 *imrw = (volatile cyg_uint8 *)CMA230_IMRw; | |
| 170 cyg_uint8 new_mask = *imrr | (1<<(vector-1)); | |
| 171 *imrw = new_mask; | |
| 172 // TEMP | |
| 173 *imrr = new_mask; | |
| 174 // TEMP | |
| 175 // diag_printf("Unmask interrupt #%d - mask: %x\n", vector, *imrr); | |
| 176 } | |
| 177 | |
| 178 void hal_interrupt_acknowledge(int vector) | |
| 179 { | |
| 180 // These two vectors are "sticky" and must be reset | |
| 181 if ((vector == CYGNUM_HAL_INTERRUPT_TIMER) || | |
| 182 (vector == CYGNUM_HAL_INTERRUPT_ABORT)) { | |
| 183 *(volatile cyg_uint8 *)CMA230_CLR = (1<<(vector-1)); | |
| 184 } | |
| 185 } | |
| 186 | |
| 187 void hal_interrupt_configure(int vector, int level, int up) | |
| 188 { | |
| 189 // No interrupts are configurable on this hardware | |
| 190 } | |
| 191 | |
| 192 void hal_interrupt_set_level(int vector, int level) | |
| 193 { | |
| 194 // No interrupts are configurable on this hardware | |
| 195 } | |
| 196 | |
| 197 /*------------------------------------------------------------------------*/ | |
| 198 // EOF hal_misc.c |
