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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [sparclite/] [sleb/] [current/] [include/] [hal_clock.h] - Blame information for rev 817

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_CLOCK_H
2
#define CYGONCE_HAL_CLOCK_H
3
 
4
//=============================================================================
5
//
6
//      hal_clock.h
7
//
8
//      HAL clock support
9
//
10
//=============================================================================
11
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
12
// -------------------------------------------                              
13
// This file is part of eCos, the Embedded Configurable Operating System.   
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under    
17
// the terms of the GNU General Public License as published by the Free     
18
// Software Foundation; either version 2 or (at your option) any later      
19
// version.                                                                 
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT      
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
24
// for more details.                                                        
25
//
26
// You should have received a copy of the GNU General Public License        
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
29
//
30
// As a special exception, if other files instantiate templates or use      
31
// macros or inline functions from this file, or you compile this file      
32
// and link it with other works to produce a work based on this file,       
33
// this file does not by itself cause the resulting work to be covered by   
34
// the GNU General Public License. However the source code for this file    
35
// must still be made available in accordance with section (3) of the GNU   
36
// General Public License v2.                                               
37
//
38
// This exception does not invalidate any other reasons why a work based    
39
// on this file might be covered by the GNU General Public License.         
40
// -------------------------------------------                              
41
// ####ECOSGPLCOPYRIGHTEND####                                              
42
//=============================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):   nickg, gthomas, hmt
46
// Contributors:        nickg, gthomas, hmt
47
// Date:        1999-01-28
48
// Purpose:     Define clock support
49
// Description: The macros defined here provide the HAL APIs for handling
50
//              the clock.
51
//              
52
// Usage:
53
//              #include <cyg/hal/hal_intr.h> // which includes this file
54
//              ...
55
//              
56
//
57
//####DESCRIPTIONEND####
58
//
59
//=============================================================================
60
 
61
// #include <cyg/hal/hal_io.h>
62
 
63
#include <cyg/hal/hal_hwio.h> // HAL_SPARC_86940_READ/WRITE
64
 
65
//-----------------------------------------------------------------------------
66
// Clock control
67
 
68
 
69
// The vector used by the Real time clock is defined in hal_xpic.h
70
 
71
extern cyg_int32 cyg_hal_sparclite_clock_period;
72
 
73
//-----------------------------------------------------------------------------
74
 
75
#define HAL_SPARC_86940_REG_TIMER1_PRESCALER ( 0x14 * 4 )
76
#define HAL_SPARC_86940_REG_TIMER1_CONTROL   ( 0x15 * 4 )
77
#define HAL_SPARC_86940_REG_TIMER1_RELOAD    ( 0x16 * 4 )
78
#define HAL_SPARC_86940_REG_TIMER1_COUNT     ( 0x17 * 4 )
79
 
80
 
81
 
82
#define HAL_SPARC_86940_TIMER1_PRESCALER_WRITE( v ) \
83
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_TIMER1_PRESCALER, v )
84
 
85
#define HAL_SPARC_86940_TIMER1_PRESCALER_READ( r ) \
86
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TIMER1_PRESCALER, r )
87
 
88
#define HAL_SPARC_86940_TIMER1_CONTROL_WRITE( v ) \
89
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_TIMER1_CONTROL, v )
90
 
91
#define HAL_SPARC_86940_TIMER1_CONTROL_READ( r ) \
92
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TIMER1_CONTROL, r )
93
 
94
#define HAL_SPARC_86940_TIMER1_RELOAD_WRITE( v ) \
95
            HAL_SPARC_86940_WRITE( HAL_SPARC_86940_REG_TIMER1_RELOAD, v )
96
 
97
#define HAL_SPARC_86940_TIMER1_RELOAD_READ( r ) \
98
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TIMER1_RELOAD, r )
99
 
100
#define HAL_SPARC_86940_TIMER1_COUNT_READ( r ) \
101
            HAL_SPARC_86940_READ( HAL_SPARC_86940_REG_TIMER1_COUNT, r )
102
 
103
//-----------------------------------------------------------------------------
104
 
105
// Initialize the clock to 1MHz whatever the system clock speed.  This
106
// requires calculation...
107
 
108
externC void hal_clock_initialize( cyg_uint32 p );
109
#define HAL_CLOCK_INITIALIZE( _period_ ) hal_clock_initialize( _period_ )
110
 
111
// This is the easiest way to clear the interrupt.
112
#define HAL_CLOCK_RESET( _vector_, _period_ ) CYG_MACRO_START            \
113
  cyg_uint32 _scratch_;                                                  \
114
  HAL_SPARC_86940_TIMER1_COUNT_READ( _scratch_ );                        \
115
CYG_MACRO_END
116
 
117
#define HAL_CLOCK_READ( _pvalue_ ) CYG_MACRO_START                       \
118
  cyg_uint32 _read_;                                                     \
119
  HAL_SPARC_86940_TIMER1_COUNT_READ( _read_ );                           \
120
  *((cyg_uint32 *)(_pvalue_)) = cyg_hal_sparclite_clock_period - _read_; \
121
CYG_MACRO_END
122
 
123
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY
124
#define HAL_CLOCK_LATENCY( _pvalue_ )         HAL_CLOCK_READ( _pvalue_ )
125
#endif
126
 
127
//-----------------------------------------------------------------------------
128
 
129
#endif // ifndef CYGONCE_HAL_CLOCK_H
130
// End of hal_clock.h

powered by: WebSVN 2.1.0

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