source: rtems/c/src/lib/libbsp/sparc/leon3/include/bsp.h @ cd64fbf

4.115
Last change on this file since cd64fbf was cd64fbf, checked in by Daniel Hellstrom <daniel@…>, on 12/16/11 at 09:37:49

LEON: GPTIMER driver, Timer Library and System Clock for LEON3

With this patch the LEON family can access the GRLIB GPTIMER using
the Timer library (TLIB).

A System Clock driver instead of BSP/clock/ck_init.c is provided
using the TLIB. The classic clock driver is split in two parts,
clock driver and timer driver. The BSPs need only to fullfill the
timer interface instead of the clock interface. Currently only
LEON3 uses it. The LEON2 Timer is not ported to TLIB.

The GPTIMER driver is implemented using the Driver Manager, so the
System Clock Driver is at this point only suitable for LEON3 when
the driver manager is initialized during BSP startup. When the DrvMgr?
is not initialized during startup the standard BSP/clock dirver is
used.

LEON2 sometimes also needs to access GPTIMER when a off-chip GRLIB AMBA
systems is connected, for example AMBA-over-PCI.

  • Property mode set to 100644
File size: 7.4 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup sparc_leon3
5 *
6 * @brief Global BSP Definitions.
7 */
8
9/*  bsp.h
10 *
11 *  This include file contains all SPARC simulator definitions.
12 *
13 *  COPYRIGHT (c) 1989-1998.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.org/license/LICENSE.
19 *
20 *  Ported to ERC32 implementation of the SPARC by On-Line Applications
21 *  Research Corporation (OAR) under contract to the European Space
22 *  Agency (ESA).
23 *
24 *  ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995.
25 *  European Space Agency.
26 */
27
28#ifndef _BSP_H
29#define _BSP_H
30
31#include <bspopts.h>
32#include <bsp/default-initial-extension.h>
33
34#include <rtems.h>
35#include <leon.h>
36#include <rtems/clockdrv.h>
37#include <rtems/console.h>
38#include <rtems/irq-extension.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/**
45 *  @defgroup sparc_leon3 LEON3 Support
46 *
47 *  @ingroup bsp_sparc
48 *
49 *  @brief LEON3 support package
50 *
51 */
52
53/* SPARC CPU variant: LEON3 */
54#define LEON3 1
55
56/*
57 *  BSP provides its own Idle thread body
58 */
59void *bsp_idle_thread( uintptr_t ignored );
60#define BSP_IDLE_TASK_BODY bsp_idle_thread
61
62/* Maximum supported APBUARTs by BSP */
63#define BSP_NUMBER_OF_TERMIOS_PORTS 8
64
65/* Make sure maximum number of consoles fit in filesystem */
66#define BSP_MAXIMUM_DEVICES 8
67
68/*
69 * Network driver configuration
70 */
71struct rtems_bsdnet_ifconfig;
72extern int rtems_leon_open_eth_driver_attach(
73  struct rtems_bsdnet_ifconfig *config,
74  int attach
75);
76extern int rtems_smc91111_driver_attach_leon3(
77  struct rtems_bsdnet_ifconfig *config,
78  int attach
79);
80extern int rtems_leon_greth_driver_attach(
81  struct rtems_bsdnet_ifconfig *config,
82  int attach
83);
84
85#define RTEMS_BSP_NETWORK_DRIVER_NAME_OPENETH "open_eth1"
86#define RTEMS_BSP_NETWORK_DRIVER_ATTACH_OPENETH   \
87    rtems_leon_open_eth_driver_attach
88#define RTEMS_BSP_NETWORK_DRIVER_NAME_SMC91111 "smc_eth1"
89#define RTEMS_BSP_NETWORK_DRIVER_ATTACH_SMC91111 \
90    rtems_smc91111_driver_attach_leon3
91#define RTEMS_BSP_NETWORK_DRIVER_NAME_GRETH "gr_eth1"
92#define RTEMS_BSP_NETWORK_DRIVER_ATTACH_GRETH \
93    rtems_leon_greth_driver_attach
94
95#ifndef RTEMS_BSP_NETWORK_DRIVER_NAME
96#define RTEMS_BSP_NETWORK_DRIVER_NAME   RTEMS_BSP_NETWORK_DRIVER_NAME_GRETH
97#define RTEMS_BSP_NETWORK_DRIVER_ATTACH RTEMS_BSP_NETWORK_DRIVER_ATTACH_GRETH
98#endif
99
100#define HAS_SMC91111
101
102/* Configure GRETH driver */
103#define GRETH_SUPPORTED
104#define GRETH_MEM_LOAD(addr) leon_r32_no_cache(addr)
105
106extern int   CPU_SPARC_HAS_SNOOPING;
107
108/* Constants */
109
110/*
111 *  Information placed in the linkcmds file.
112 */
113
114extern int   RAM_START;
115extern int   RAM_END;
116extern int   RAM_SIZE;
117
118extern int   PROM_START;
119extern int   PROM_END;
120extern int   PROM_SIZE;
121
122extern int   CLOCK_SPEED;
123
124extern int   end;        /* last address in the program */
125
126/* miscellaneous stuff assumed to exist */
127
128rtems_isr_entry set_vector(                     /* returns old vector */
129    rtems_isr_entry     handler,                /* isr routine        */
130    rtems_vector_number vector,                 /* vector number      */
131    int                 type                    /* RTEMS or RAW intr  */
132);
133
134void BSP_fatal_exit(uint32_t error);
135
136void bsp_spurious_initialize( void );
137
138/*
139 *  Delay for the specified number of microseconds.
140 */
141void rtems_bsp_delay(int usecs);
142
143/* Allocate 8-byte aligned non-freeable pre-malloc() memory. The function
144 * can be called at any time. The work-area will shrink when called before
145 * bsp_work_area_initialize(). malloc() is called to get memory when this
146 * function is called after bsp_work_area_initialize().
147 */
148void *bsp_early_malloc(int size);
149
150/* Interrupt Service Routine (ISR) pointer */
151typedef void (*bsp_shared_isr)(void *arg);
152
153/* Initializes the Shared System Interrupt service */
154extern void BSP_shared_interrupt_init(void);
155
156/* Called directly from IRQ trap handler TRAP[0x10..0x1F] = IRQ[0..15] */
157void bsp_isr_handler(rtems_vector_number vector);
158
159/* Registers a shared IRQ handler, and enable it at IRQ controller. Multiple
160 * interrupt handlers may use the same IRQ number, all ISRs will be called
161 * when an interrupt on that line is fired.
162 *
163 * Arguments
164 *  irq       System IRQ number
165 *  info      Optional Name of IRQ source
166 *  isr       Function pointer to the ISR
167 *  arg       Second argument to function isr
168 */
169static __inline__ int BSP_shared_interrupt_register
170       (
171       int irq,
172       const char *info,
173       bsp_shared_isr isr,
174       void *arg
175       )
176{
177       return rtems_interrupt_handler_install(irq, info,
178                                       RTEMS_INTERRUPT_SHARED, isr, arg);
179}
180
181/* Unregister previously registered shared IRQ handler.
182 *
183 * Arguments
184 *  irq       System IRQ number
185 *  isr       Function pointer to the ISR
186 *  arg       Second argument to function isr
187 */
188static __inline__ int BSP_shared_interrupt_unregister
189       (
190       int irq,
191       bsp_shared_isr isr,
192       void *arg
193       )
194{
195       return rtems_interrupt_handler_remove(irq, isr, arg);
196}
197
198/* Clear interrupt pending on IRQ controller, this is typically done on a
199 * level triggered interrupt source such as PCI to avoid taking double IRQs.
200 * In such a case the interrupt source must be cleared first on LEON, before
201 * acknowledging the IRQ with this function.
202 *
203 * Arguments
204 *  irq       System IRQ number
205 */
206extern void BSP_shared_interrupt_clear(int irq);
207
208/* Enable Interrupt. This function will unmask the IRQ at the interrupt
209 * controller. This is normally done by _register(). Note that this will
210 * affect all ISRs on this IRQ.
211 *
212 * Arguments
213 *  irq       System IRQ number
214 */
215extern void BSP_shared_interrupt_unmask(int irq);
216
217/* Disable Interrupt. This function will mask one IRQ at the interrupt
218 * controller. This is normally done by _unregister().  Note that this will
219 * affect all ISRs on this IRQ.
220 *
221 * Arguments
222 *  irq         System IRQ number
223 */
224extern void BSP_shared_interrupt_mask(int irq);
225
226#if defined(RTEMS_SMP) || defined(RTEMS_MULTIPROCESSING)
227/* Irq used by the shared memory driver and for inter-processor interrupts.
228 * The variable is weakly linked. Redefine the variable in your application
229 * to override the BSP default.
230 */
231extern const unsigned char LEON3_mp_irq;
232#endif
233
234#ifdef RTEMS_SMP
235/* Weak table used to implement static interrupt CPU affinity in a SMP
236 * configuration. The array index is the interrupt to be looked up, and
237 * the array[INTERRUPT] content is the CPU number relative to boot CPU
238 * index that will be servicing the interrupts from the IRQ source. The
239 * default is to let the first CPU (the boot cpu) to handle all
240 * interrupts (all zeros).
241 */
242extern const unsigned char LEON3_irq_to_cpu[32];
243#endif
244
245/* BSP PCI Interrupt support */
246#define BSP_PCI_shared_interrupt_register    BSP_shared_interrupt_register
247#define BSP_PCI_shared_interrupt_unregister  BSP_shared_interrupt_unregister
248#define BSP_PCI_shared_interrupt_unmask      BSP_shared_interrupt_unmask
249#define BSP_PCI_shared_interrupt_mask        BSP_shared_interrupt_mask
250#define BSP_PCI_shared_interrupt_clear       BSP_shared_interrupt_clear
251
252/* Common driver build-time configurations. On small systems undefine
253 * [DRIVER]_INFO_AVAIL to avoid info routines get dragged in. It is good
254 * for debugging and printing information about the system, but makes the
255 * image bigger.
256 */
257#define AMBAPPBUS_INFO_AVAIL          /* AMBAPP Bus driver */
258#define GPTIMER_INFO_AVAIL            /* GPTIMER Timer driver */
259
260#ifdef __cplusplus
261}
262#endif
263
264#endif
Note: See TracBrowser for help on using the repository browser.