1 #ifndef __BSP_COMMON_BSP_IF_H__
2 #define __BSP_COMMON_BSP_IF_H__
3 //==========================================================================
7 // BSP interface definitions.
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.
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.
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
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.
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.
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.
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####
46 // Contributors: gthomas
48 // Purpose: BSP interface definitions.
52 //####DESCRIPTIONEND####
54 //=========================================================================
60 * Maximum number of interrupt controllers supported by
63 #define BSP_MAX_IRQ_CONTROLLERS 8
69 * Interrupt controller abstraction.
70 * Each interrupt controller on a given board should be described using
71 * this data structure.
73 struct bsp_irq_controller {
75 * First and last irqs handled by this controller.
81 * pointer to array of bsp_vec struct pointers. These are
82 * the heads of the linked list of ISRs for each irq handled
88 * Pointer to initialization routine which is run once at boot time.
90 void (*init)(const struct bsp_irq_controller *__ic);
93 * Pointer to routines used to disable and enable interrupts handled
96 int (*disable)(const struct bsp_irq_controller *__ic,
98 void (*enable)(const struct bsp_irq_controller *__ic,
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.
109 struct bsp_comm_procs {
111 * Implementation dependent data pointer passed to the following procs.
116 * Write a buffer of the given length. All of buffer is sent before
117 * the write call returns.
119 void (*__write)(void *ch_data, const char *buf, int len);
122 * Fill a buffer with up to the given length. Returns the actual number
123 * of characters read.
125 int (*__read)(void *ch_data, char *buf, int len);
128 * Send a single character.
130 void (*__putc)(void *ch_data, char ch);
133 * Read a single character. If no character is immediately available, will
134 * block until one becomes available.
136 int (*__getc)(void *ch_data);
139 * Catchall comm port control.
141 int (*__control)(void *ch_data, int func, ...);
144 * For serial ports, the control function may be used to set and get the
145 * current baud rate. Usage:
147 * err = (*__control)(COMMCTL_SETBAUD, int bits_per_second);
148 * err => Zero if successful, -1 if error.
150 * baud = (*__control)(COMMCTL_GETBAUD);
151 * baud => -1 if error, current baud otherwise.
153 #define COMMCTL_SETBAUD 0
154 #define COMMCTL_GETBAUD 1
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.
161 #define COMMCTL_INSTALL_DBG_ISR 2
162 #define COMMCTL_REMOVE_DBG_ISR 3
165 * Disable comm port interrupt. Returns TRUE if interrupt was enabled,
168 #define COMMCTL_IRQ_DISABLE 4
170 * Enable comm port interrupt.
172 #define COMMCTL_IRQ_ENABLE 5
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.
181 struct bsp_comm_channel {
182 struct bsp_comm_info info;
183 struct bsp_comm_procs procs;
188 * Number to place in the version field. If structure is changed
189 * in a way which is not backwards compatible, this number should
192 #define BSP_SHARED_DATA_VERSION 2
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.
202 int version; /* version number for future expansion */
205 * Pointer to the array of pointers to interrupt controller descriptors.
207 const struct bsp_irq_controller **__ictrl_table;
210 * Pointer to the array of exception vectors.
212 bsp_vec_t **__exc_table;
215 * Pointer to debug handler vector.
217 bsp_handler_t *__dbg_vector;
220 * User hook to catch debugger 'kill' command.
222 bsp_handler_t __kill_vector;
225 * Vectored functions for console and debug i/o.
227 struct bsp_comm_procs *__console_procs;
228 struct bsp_comm_procs *__debug_procs;
231 * Vectored cache control functions.
233 void (*__flush_dcache)(void *__p, int __nbytes);
234 void (*__flush_icache)(void *__p, int __nbytes);
237 * Generic data pointers
243 * General BSP information access.
244 * See bsp.h for details.
246 int (*__sysinfo)(enum bsp_info_id __id, va_list __ap);
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
254 int (*__set_debug_comm)(int __comm_id);
255 int (*__set_console_comm)(int __comm_id);
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.
262 int (*__set_serial_baud)(int __comm_id, int baud);
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
276 void (*__reset)(void);
279 * TRUE if console interrupt detected during program output.
281 int __console_interrupt_flag;
286 extern bsp_shared_t *bsp_shared_data;
289 * Platform info which may be overriden/modified by arch/board specific code.
291 extern struct bsp_platform_info _bsp_platform_info;
294 * Cache info which may be overriden/modified by arch/board specific code.
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;
301 * Array of comm channel descriptors which must be provided by board specific
304 extern struct bsp_comm_channel _bsp_comm_list[];
307 * Number of comm channel descriptors which must be provided by board specific
310 extern int _bsp_num_comms;
314 * Array of memory region descriptors which must be provided by board specific
317 extern struct bsp_mem_info _bsp_memory_list[];
320 * Number of memory region descriptors which must be provided by board specific
323 extern int _bsp_num_mem_regions;
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.
337 extern void *_bsp_ram_info_ptr;
340 * Generic bsp initialization. Called by low level startup code
342 extern void _bsp_init(void);
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().
349 extern void _bsp_init_board_comm(void);
352 * Make generic BSP aware of CPU/MCU specific interrupt controllers.
354 extern void _bsp_install_cpu_irq_controllers(void);
357 * Make generic BSP aware of board specific interrupt controllers.
359 extern void _bsp_install_board_irq_controllers(void);
362 * Callback used by above two routines to install a single
363 * interrupt controller.
365 extern void _bsp_install_irq_controller(const struct bsp_irq_controller *__ic);
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.
374 extern int _bsp_exc_dispatch(int __exc_number, void *__regs);
378 * Architecture specific routine to dump register values.
380 extern void _bsp_dump_regs(void *__regs);
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
389 extern int _bsp_do_syscall(int __func,
390 long __arg1, long __arg2, long __arg3, long __arg4,
394 extern void _bsp_cpu_init(void);
395 extern void _bsp_board_init(void);
399 * General interface for getting certain BSP parameters.
400 * See bsp.h for details.
402 extern int _bsp_sysinfo(enum bsp_info_id __id, va_list __ap);
405 * Called from comm channel when a connection to host is closed.
407 extern void _bsp_dbg_connect_abort(void);
411 * Pointer to a network channel. NULL if no network channel
414 extern struct bsp_comm_channel *_bsp_net_channel;
418 * Formatted output primitive.
420 extern void __vprintf(void (*putc_func)(char c), const char *fmt0, va_list ap);
424 #endif /* !__ASSEMBLER__ */
427 * SYSCALL number to use to get pointer to above bsp_shared_t structure.
429 #define BSP_GET_SHARED 0xbaad
431 #endif // __BSP_COMMON_BSP_IF_H__