1 |
27 |
unneback |
#ifndef __BSP_COMMON_BSP_IF_H__
|
2 |
|
|
#define __BSP_COMMON_BSP_IF_H__
|
3 |
|
|
//==========================================================================
|
4 |
|
|
//
|
5 |
|
|
// bsp_if.h
|
6 |
|
|
//
|
7 |
|
|
// BSP interface definitions.
|
8 |
|
|
//
|
9 |
|
|
//==========================================================================
|
10 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
18 |
|
|
//
|
19 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
20 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
21 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
22 |
|
|
// for more details.
|
23 |
|
|
//
|
24 |
|
|
// You should have received a copy of the GNU General Public License along
|
25 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
26 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
27 |
|
|
//
|
28 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
29 |
|
|
// or inline functions from this file, or you compile this file and link it
|
30 |
|
|
// with other works to produce a work based on this file, this file does not
|
31 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
32 |
|
|
// License. However the source code for this file must still be made available
|
33 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
36 |
|
|
// this file might be covered by the GNU General Public License.
|
37 |
|
|
//
|
38 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
39 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//==========================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s):
|
46 |
|
|
// Contributors: gthomas
|
47 |
|
|
// Date: 1999-10-20
|
48 |
|
|
// Purpose: BSP interface definitions.
|
49 |
|
|
// Description:
|
50 |
|
|
//
|
51 |
|
|
//
|
52 |
|
|
//####DESCRIPTIONEND####
|
53 |
|
|
//
|
54 |
|
|
//=========================================================================
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
#include <bsp/bsp.h>
|
58 |
|
|
|
59 |
|
|
/*
|
60 |
|
|
* Maximum number of interrupt controllers supported by
|
61 |
|
|
* this bsp.
|
62 |
|
|
*/
|
63 |
|
|
#define BSP_MAX_IRQ_CONTROLLERS 8
|
64 |
|
|
|
65 |
|
|
#ifndef __ASSEMBLER__
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
/*
|
69 |
|
|
* Interrupt controller abstraction.
|
70 |
|
|
* Each interrupt controller on a given board should be described using
|
71 |
|
|
* this data structure.
|
72 |
|
|
*/
|
73 |
|
|
struct bsp_irq_controller {
|
74 |
|
|
/*
|
75 |
|
|
* First and last irqs handled by this controller.
|
76 |
|
|
*/
|
77 |
|
|
short first;
|
78 |
|
|
short last;
|
79 |
|
|
|
80 |
|
|
/*
|
81 |
|
|
* pointer to array of bsp_vec struct pointers. These are
|
82 |
|
|
* the heads of the linked list of ISRs for each irq handled
|
83 |
|
|
* by this controller.
|
84 |
|
|
*/
|
85 |
|
|
bsp_vec_t **vec_list;
|
86 |
|
|
|
87 |
|
|
/*
|
88 |
|
|
* Pointer to initialization routine which is run once at boot time.
|
89 |
|
|
*/
|
90 |
|
|
void (*init)(const struct bsp_irq_controller *__ic);
|
91 |
|
|
|
92 |
|
|
/*
|
93 |
|
|
* Pointer to routines used to disable and enable interrupts handled
|
94 |
|
|
* by this controller.
|
95 |
|
|
*/
|
96 |
|
|
int (*disable)(const struct bsp_irq_controller *__ic,
|
97 |
|
|
int __irq_nr);
|
98 |
|
|
void (*enable)(const struct bsp_irq_controller *__ic,
|
99 |
|
|
int __irq_nr);
|
100 |
|
|
};
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
/*
|
104 |
|
|
* Board specific code needs to provide at least one communication channel
|
105 |
|
|
* for use as the debug and console (stdio) channel. For each channel,
|
106 |
|
|
* there must be a set of function vectors for the common BSP code to
|
107 |
|
|
* control the channel.
|
108 |
|
|
*/
|
109 |
|
|
struct bsp_comm_procs {
|
110 |
|
|
/*
|
111 |
|
|
* Implementation dependent data pointer passed to the following procs.
|
112 |
|
|
*/
|
113 |
|
|
void *ch_data;
|
114 |
|
|
|
115 |
|
|
/*
|
116 |
|
|
* Write a buffer of the given length. All of buffer is sent before
|
117 |
|
|
* the write call returns.
|
118 |
|
|
*/
|
119 |
|
|
void (*__write)(void *ch_data, const char *buf, int len);
|
120 |
|
|
|
121 |
|
|
/*
|
122 |
|
|
* Fill a buffer with up to the given length. Returns the actual number
|
123 |
|
|
* of characters read.
|
124 |
|
|
*/
|
125 |
|
|
int (*__read)(void *ch_data, char *buf, int len);
|
126 |
|
|
|
127 |
|
|
/*
|
128 |
|
|
* Send a single character.
|
129 |
|
|
*/
|
130 |
|
|
void (*__putc)(void *ch_data, char ch);
|
131 |
|
|
|
132 |
|
|
/*
|
133 |
|
|
* Read a single character. If no character is immediately available, will
|
134 |
|
|
* block until one becomes available.
|
135 |
|
|
*/
|
136 |
|
|
int (*__getc)(void *ch_data);
|
137 |
|
|
|
138 |
|
|
/*
|
139 |
|
|
* Catchall comm port control.
|
140 |
|
|
*/
|
141 |
|
|
int (*__control)(void *ch_data, int func, ...);
|
142 |
|
|
|
143 |
|
|
/*
|
144 |
|
|
* For serial ports, the control function may be used to set and get the
|
145 |
|
|
* current baud rate. Usage:
|
146 |
|
|
*
|
147 |
|
|
* err = (*__control)(COMMCTL_SETBAUD, int bits_per_second);
|
148 |
|
|
* err => Zero if successful, -1 if error.
|
149 |
|
|
*
|
150 |
|
|
* baud = (*__control)(COMMCTL_GETBAUD);
|
151 |
|
|
* baud => -1 if error, current baud otherwise.
|
152 |
|
|
*/
|
153 |
|
|
#define COMMCTL_SETBAUD 0
|
154 |
|
|
#define COMMCTL_GETBAUD 1
|
155 |
|
|
|
156 |
|
|
/*
|
157 |
|
|
* Install and remove debugger interrupt handlers. These are the receiver
|
158 |
|
|
* interrupt routines which are used to change control from a running
|
159 |
|
|
* program to the debugger stub.
|
160 |
|
|
*/
|
161 |
|
|
#define COMMCTL_INSTALL_DBG_ISR 2
|
162 |
|
|
#define COMMCTL_REMOVE_DBG_ISR 3
|
163 |
|
|
|
164 |
|
|
/*
|
165 |
|
|
* Disable comm port interrupt. Returns TRUE if interrupt was enabled,
|
166 |
|
|
* FALSE otherwise.
|
167 |
|
|
*/
|
168 |
|
|
#define COMMCTL_IRQ_DISABLE 4
|
169 |
|
|
/*
|
170 |
|
|
* Enable comm port interrupt.
|
171 |
|
|
*/
|
172 |
|
|
#define COMMCTL_IRQ_ENABLE 5
|
173 |
|
|
};
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
/*
|
177 |
|
|
* The board specific code uses this data structure to provide information
|
178 |
|
|
* about and procedure vectors for each supported communication channel.
|
179 |
|
|
* See _bsp_comm_list below.
|
180 |
|
|
*/
|
181 |
|
|
struct bsp_comm_channel {
|
182 |
|
|
struct bsp_comm_info info;
|
183 |
|
|
struct bsp_comm_procs procs;
|
184 |
|
|
};
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
/*
|
188 |
|
|
* Number to place in the version field. If structure is changed
|
189 |
|
|
* in a way which is not backwards compatible, this number should
|
190 |
|
|
* be incremented.
|
191 |
|
|
*/
|
192 |
|
|
#define BSP_SHARED_DATA_VERSION 2
|
193 |
|
|
|
194 |
|
|
/*
|
195 |
|
|
* Clients of this BSP will need to have access to BSP functions and
|
196 |
|
|
* data structures. Because, the client and the BSP may not be linked
|
197 |
|
|
* together, a structure of vectors is used to gain this access. A
|
198 |
|
|
* pointer to this structure can be gotten via a syscall. This syscall
|
199 |
|
|
* is made automatically from within the crt0.o file.
|
200 |
|
|
*/
|
201 |
|
|
typedef struct {
|
202 |
|
|
int version; /* version number for future expansion */
|
203 |
|
|
|
204 |
|
|
/*
|
205 |
|
|
* Pointer to the array of pointers to interrupt controller descriptors.
|
206 |
|
|
*/
|
207 |
|
|
const struct bsp_irq_controller **__ictrl_table;
|
208 |
|
|
|
209 |
|
|
/*
|
210 |
|
|
* Pointer to the array of exception vectors.
|
211 |
|
|
*/
|
212 |
|
|
bsp_vec_t **__exc_table;
|
213 |
|
|
|
214 |
|
|
/*
|
215 |
|
|
* Pointer to debug handler vector.
|
216 |
|
|
*/
|
217 |
|
|
bsp_handler_t *__dbg_vector;
|
218 |
|
|
|
219 |
|
|
/*
|
220 |
|
|
* User hook to catch debugger 'kill' command.
|
221 |
|
|
*/
|
222 |
|
|
bsp_handler_t __kill_vector;
|
223 |
|
|
|
224 |
|
|
/*
|
225 |
|
|
* Vectored functions for console and debug i/o.
|
226 |
|
|
*/
|
227 |
|
|
struct bsp_comm_procs *__console_procs;
|
228 |
|
|
struct bsp_comm_procs *__debug_procs;
|
229 |
|
|
|
230 |
|
|
/*
|
231 |
|
|
* Vectored cache control functions.
|
232 |
|
|
*/
|
233 |
|
|
void (*__flush_dcache)(void *__p, int __nbytes);
|
234 |
|
|
void (*__flush_icache)(void *__p, int __nbytes);
|
235 |
|
|
|
236 |
|
|
/*
|
237 |
|
|
* Generic data pointers
|
238 |
|
|
*/
|
239 |
|
|
void *__cpu_data;
|
240 |
|
|
void *__board_data;
|
241 |
|
|
|
242 |
|
|
/*
|
243 |
|
|
* General BSP information access.
|
244 |
|
|
* See bsp.h for details.
|
245 |
|
|
*/
|
246 |
|
|
int (*__sysinfo)(enum bsp_info_id __id, va_list __ap);
|
247 |
|
|
|
248 |
|
|
/*
|
249 |
|
|
* Set or get active debug and console channels.
|
250 |
|
|
* Returns -1 if unsucessful.
|
251 |
|
|
* If the passed in __comm_id is -1, then the id of the current channel
|
252 |
|
|
* is returned.
|
253 |
|
|
*/
|
254 |
|
|
int (*__set_debug_comm)(int __comm_id);
|
255 |
|
|
int (*__set_console_comm)(int __comm_id);
|
256 |
|
|
|
257 |
|
|
/*
|
258 |
|
|
* Set or get the current baud rate of a serial comm channel.
|
259 |
|
|
* Returns -1 on if unsuccessful.
|
260 |
|
|
* If the given baud is -1, then the current baudrate is returned.
|
261 |
|
|
*/
|
262 |
|
|
int (*__set_serial_baud)(int __comm_id, int baud);
|
263 |
|
|
|
264 |
|
|
/*
|
265 |
|
|
* Debug agent data.
|
266 |
|
|
*/
|
267 |
|
|
void *__dbg_data;
|
268 |
|
|
|
269 |
|
|
/*
|
270 |
|
|
* Reset function
|
271 |
|
|
* We want to avoid calling this with a trap since
|
272 |
|
|
* we may be calling it from SWI mode (in cygmon).
|
273 |
|
|
* That is problematic, as nested SWI's are not
|
274 |
|
|
* very good.
|
275 |
|
|
*/
|
276 |
|
|
void (*__reset)(void);
|
277 |
|
|
|
278 |
|
|
/*
|
279 |
|
|
* TRUE if console interrupt detected during program output.
|
280 |
|
|
*/
|
281 |
|
|
int __console_interrupt_flag;
|
282 |
|
|
|
283 |
|
|
} bsp_shared_t;
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
extern bsp_shared_t *bsp_shared_data;
|
287 |
|
|
|
288 |
|
|
/*
|
289 |
|
|
* Platform info which may be overriden/modified by arch/board specific code.
|
290 |
|
|
*/
|
291 |
|
|
extern struct bsp_platform_info _bsp_platform_info;
|
292 |
|
|
|
293 |
|
|
/*
|
294 |
|
|
* Cache info which may be overriden/modified by arch/board specific code.
|
295 |
|
|
*/
|
296 |
|
|
extern struct bsp_cachesize_info _bsp_dcache_info;
|
297 |
|
|
extern struct bsp_cachesize_info _bsp_icache_info;
|
298 |
|
|
extern struct bsp_cachesize_info _bsp_scache_info;
|
299 |
|
|
|
300 |
|
|
/*
|
301 |
|
|
* Array of comm channel descriptors which must be provided by board specific
|
302 |
|
|
* code.
|
303 |
|
|
*/
|
304 |
|
|
extern struct bsp_comm_channel _bsp_comm_list[];
|
305 |
|
|
|
306 |
|
|
/*
|
307 |
|
|
* Number of comm channel descriptors which must be provided by board specific
|
308 |
|
|
* code.
|
309 |
|
|
*/
|
310 |
|
|
extern int _bsp_num_comms;
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
/*
|
314 |
|
|
* Array of memory region descriptors which must be provided by board specific
|
315 |
|
|
* code.
|
316 |
|
|
*/
|
317 |
|
|
extern struct bsp_mem_info _bsp_memory_list[];
|
318 |
|
|
|
319 |
|
|
/*
|
320 |
|
|
* Number of memory region descriptors which must be provided by board specific
|
321 |
|
|
* code.
|
322 |
|
|
*/
|
323 |
|
|
extern int _bsp_num_mem_regions;
|
324 |
|
|
|
325 |
|
|
/*
|
326 |
|
|
* In order to construct the above _bsp_memory_list, some board specific
|
327 |
|
|
* code may have to size RAM regions. To do this easily and reliably,
|
328 |
|
|
* the code needs to run from ROM before .bss and .data sections are
|
329 |
|
|
* initialized. This leads to the problem of where to store the results
|
330 |
|
|
* of the memory sizing tests. In this case, the _bsp_init_stack routine
|
331 |
|
|
* which sizes memory and sets up the stack will place the board-specific
|
332 |
|
|
* information on the stack and return with the stack pointer pointing to
|
333 |
|
|
* a pointer to the information. That is, addr_of_info = *(void **)sp.
|
334 |
|
|
* The architecture specific code will then copy that pointer to the
|
335 |
|
|
* _bsp_ram_info_ptr variable after initializing the .data and .bss sections.
|
336 |
|
|
*/
|
337 |
|
|
extern void *_bsp_ram_info_ptr;
|
338 |
|
|
|
339 |
|
|
/*
|
340 |
|
|
* Generic bsp initialization. Called by low level startup code
|
341 |
|
|
*/
|
342 |
|
|
extern void _bsp_init(void);
|
343 |
|
|
|
344 |
|
|
/*
|
345 |
|
|
* Initialize board communication in polling mode. This enables
|
346 |
|
|
* debugging printf for later initializations. Interrupts for
|
347 |
|
|
* comm channels may be set up later in _bsp_board_init().
|
348 |
|
|
*/
|
349 |
|
|
extern void _bsp_init_board_comm(void);
|
350 |
|
|
|
351 |
|
|
/*
|
352 |
|
|
* Make generic BSP aware of CPU/MCU specific interrupt controllers.
|
353 |
|
|
*/
|
354 |
|
|
extern void _bsp_install_cpu_irq_controllers(void);
|
355 |
|
|
|
356 |
|
|
/*
|
357 |
|
|
* Make generic BSP aware of board specific interrupt controllers.
|
358 |
|
|
*/
|
359 |
|
|
extern void _bsp_install_board_irq_controllers(void);
|
360 |
|
|
|
361 |
|
|
/*
|
362 |
|
|
* Callback used by above two routines to install a single
|
363 |
|
|
* interrupt controller.
|
364 |
|
|
*/
|
365 |
|
|
extern void _bsp_install_irq_controller(const struct bsp_irq_controller *__ic);
|
366 |
|
|
|
367 |
|
|
/*
|
368 |
|
|
* Generic exception dispatch routine. Usually called from asm-level
|
369 |
|
|
* exception handler to call vectors in vector chain for the given
|
370 |
|
|
* exception number. Stops traversing vector chain when a called
|
371 |
|
|
* vector returns a non-zero value. If no vector returns non-zero,
|
372 |
|
|
* a default error message and register dump is printed.
|
373 |
|
|
*/
|
374 |
|
|
extern int _bsp_exc_dispatch(int __exc_number, void *__regs);
|
375 |
|
|
|
376 |
|
|
|
377 |
|
|
/*
|
378 |
|
|
* Architecture specific routine to dump register values.
|
379 |
|
|
*/
|
380 |
|
|
extern void _bsp_dump_regs(void *__regs);
|
381 |
|
|
|
382 |
|
|
|
383 |
|
|
/*
|
384 |
|
|
* Generic syscall handler called by architecture specific handler.
|
385 |
|
|
* Returns non-zero if given 'func' number was handled by the generic
|
386 |
|
|
* code, zero otherwise. If handled, the syscall error is returned
|
387 |
|
|
* via the err_ptr.
|
388 |
|
|
*/
|
389 |
|
|
extern int _bsp_do_syscall(int __func,
|
390 |
|
|
long __arg1, long __arg2, long __arg3, long __arg4,
|
391 |
|
|
int *__err_ptr);
|
392 |
|
|
|
393 |
|
|
|
394 |
|
|
extern void _bsp_cpu_init(void);
|
395 |
|
|
extern void _bsp_board_init(void);
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
/*
|
399 |
|
|
* General interface for getting certain BSP parameters.
|
400 |
|
|
* See bsp.h for details.
|
401 |
|
|
*/
|
402 |
|
|
extern int _bsp_sysinfo(enum bsp_info_id __id, va_list __ap);
|
403 |
|
|
|
404 |
|
|
/*
|
405 |
|
|
* Called from comm channel when a connection to host is closed.
|
406 |
|
|
*/
|
407 |
|
|
extern void _bsp_dbg_connect_abort(void);
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
/*
|
411 |
|
|
* Pointer to a network channel. NULL if no network channel
|
412 |
|
|
* exists.
|
413 |
|
|
*/
|
414 |
|
|
extern struct bsp_comm_channel *_bsp_net_channel;
|
415 |
|
|
|
416 |
|
|
|
417 |
|
|
/*
|
418 |
|
|
* Formatted output primitive.
|
419 |
|
|
*/
|
420 |
|
|
extern void __vprintf(void (*putc_func)(char c), const char *fmt0, va_list ap);
|
421 |
|
|
|
422 |
|
|
|
423 |
|
|
|
424 |
|
|
#endif /* !__ASSEMBLER__ */
|
425 |
|
|
|
426 |
|
|
/*
|
427 |
|
|
* SYSCALL number to use to get pointer to above bsp_shared_t structure.
|
428 |
|
|
*/
|
429 |
|
|
#define BSP_GET_SHARED 0xbaad
|
430 |
|
|
|
431 |
|
|
#endif // __BSP_COMMON_BSP_IF_H__
|
432 |
|
|
|
433 |
|
|
|