00001 //========================================================================== 00002 // 00003 // plf_misc.c 00004 // 00005 // HAL platform miscellaneous functions 00006 // 00007 //========================================================================== 00008 //####ECOSGPLCOPYRIGHTBEGIN#### 00009 // ------------------------------------------- 00010 // This file is part of eCos, the Embedded Configurable Operating System. 00011 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. 00012 // 00013 // eCos is free software; you can redistribute it and/or modify it under 00014 // the terms of the GNU General Public License as published by the Free 00015 // Software Foundation; either version 2 or (at your option) any later version. 00016 // 00017 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY 00018 // WARRANTY; without even the implied warranty of MERCHANTABILITY or 00019 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00020 // for more details. 00021 // 00022 // You should have received a copy of the GNU General Public License along 00023 // with eCos; if not, write to the Free Software Foundation, Inc., 00024 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00025 // 00026 // As a special exception, if other files instantiate templates or use macros 00027 // or inline functions from this file, or you compile this file and link it 00028 // with other works to produce a work based on this file, this file does not 00029 // by itself cause the resulting work to be covered by the GNU General Public 00030 // License. However the source code for this file must still be made available 00031 // in accordance with section (3) of the GNU General Public License. 00032 // 00033 // This exception does not invalidate any other reasons why a work based on 00034 // this file might be covered by the GNU General Public License. 00035 // 00036 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. 00037 // at http://sources.redhat.com/ecos/ecos-license/ 00038 // ------------------------------------------- 00039 //####ECOSGPLCOPYRIGHTEND#### 00040 //========================================================================== 00041 //#####DESCRIPTIONBEGIN#### 00042 // 00043 // Author(s): Uwe Kindler 00044 // Contributors: Uwe Kindler, yoshinori sato 00045 // Date: 2003-12-06 00046 // Purpose: HAL miscellaneous functions 00047 // Description: This file contains miscellaneous functions provided by the 00048 // HAL. 00049 // 00050 //####DESCRIPTIONEND#### 00051 // 00052 //========================================================================== 00053 00054 00055 //============================================================================= 00056 // DOXYGEN FILE HEADER 00063 // HAL. 00064 //============================================================================= 00065 00066 00067 //========================================================================== 00068 // INCLUDES 00069 //========================================================================== 00070 #include <pkgconf/hal.h> 00071 #include <cyg/infra/diag.h> 00072 00073 #include <cyg/infra/cyg_type.h> // Base types 00074 00075 #include <cyg/hal/hal_arch.h> // architectural definitions 00076 #include <cyg/hal/hal_io.h> 00077 #include <cyg/hal/hal_if.h> 00078 #include <cyg/hal/plf_intr.h> 00079 #include <cyg/hal/var_arch.h> 00080 #include <cyg/hal/hal_intr.h> // required for VSR initialisation 00081 00082 #ifdef CYGPKG_REDBOOT 00083 #include <redboot.h> 00084 #endif 00085 00086 00087 //========================================================================== 00088 // CROSS REFERNCES 00089 //========================================================================== 00093 externC volatile CYG_ADDRESS hal_vsr_table[CYGNUM_HAL_VSR_COUNT]; 00096 externC void __default_interrupt_vsr(void); 00097 00098 00099 //========================================================================== 00100 // PLATFORM INIT 00111 //========================================================================== 00112 void hal_platform_init(void) 00113 { 00114 // 00115 // intialize virtual vector calling interface 00116 // 00117 hal_if_init(); 00118 } 00119 00120 00121 //========================================================================== 00122 // INITIALIZE RT CLOCK 00138 //========================================================================== 00139 void hal_clock_initialize(cyg_uint32 period) 00140 { 00141 cyg_uint8 tmp; 00142 00143 // 00144 // start 16 bit timer module in MSTPCRH register 00145 // 00146 HAL_READ_UINT8(CYGARC_MSTPCRH, tmp); 00147 tmp &= ~CYGARC_MSTPCRH_TPU; 00148 HAL_WRITE_UINT8(CYGARC_MSTPCRH, tmp); 00149 // 00150 // initialize 16 bit timer - first we select timer counter clock and 00151 // counter clearing source TGR 00152 // Clock prescaler is 16 (clock/16) and TCNT is clear at compare match A 00153 // 00154 HAL_WRITE_UINT8(CYGARC_TCR5, CYGARC_TCR_CLR_CMA | 00155 CYGARC_TCR_TPSC_16); 00156 // 00157 // Select output compare register - Designate the TGRA as an output compare 00158 // register by means of TIOR. 00159 // 00160 HAL_WRITE_UINT8(CYGARC_TIOR5, 0x00); // output compare - output disabled 00161 HAL_WRITE_UINT16(CYGARC_TGRA5, period); // set compare match value to period 00162 HAL_WRITE_UINT16(CYGARC_TCNT5, 0x00); // reset up counter 00163 // 00164 // Now start the counter 5 - intterrupts will be enabled from HAL later 00165 // 00166 HAL_WRITE_UINT8(CYGARC_TSTR, CYGARC_TSTR_CST5); 00167 } 00168 00169 00170 //========================================================================== 00171 // READ CLOCK VALUE 00182 //========================================================================== 00183 void hal_clock_read(cyg_uint32 *pvalue) 00184 { 00185 cyg_uint16 val; 00186 HAL_READ_UINT16(CYGARC_TCNT5, val); 00187 *pvalue = val; 00188 } 00189 00190 00191 #ifdef CYGPKG_REDBOOT 00192 //========================================================================== 00193 // MEMORY MAP SUPPORT FOR REDBOOT 00203 //========================================================================== 00204 void 00205 cyg_plf_memory_segment(int seg, unsigned char **start, unsigned char **end) 00206 { 00207 cyg_uint32 mem_start; 00208 00209 // 00210 // we have one additional memory segment - the H8S/2674 internal ram 00211 // 00212 if (seg == 1) 00213 { 00214 // 00215 // the internal ram contains VSR table, virtual vector table and 00216 // shadow vector table. these areas are reserved and not available 00217 // so we end at start of CYGHWR_HAL_VSR_TABLE an not at ffc000 00218 // 00219 mem_start = 0xff4000; 00220 *start = (unsigned char *)(mem_start); 00221 *end = (unsigned char *)(CYGHWR_HAL_VSR_TABLE); 00222 } 00223 else 00224 { 00225 diag_printf("** Invalid memory segment #%d - ignored\n", seg); 00226 *start = NO_MEMORY; 00227 *end = NO_MEMORY; 00228 } 00229 } 00230 #endif 00231 00232 //-------------------------------------------------------------------------- 00233 // End of plf_misc.c
1.3.5