1 #ifndef CYGONCE_HAL_HAL_IF_H
2 #define CYGONCE_HAL_HAL_IF_H
4 //=============================================================================
8 // HAL header for ROM/RAM calling interface.
10 //=============================================================================
11 //####ECOSGPLCOPYRIGHTBEGIN####
12 // -------------------------------------------
13 // This file is part of eCos, the Embedded Configurable Operating System.
14 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
15 // Copyright (C) 2002, 2003, 2004 Gary Thomas
17 // eCos is free software; you can redistribute it and/or modify it under
18 // the terms of the GNU General Public License as published by the Free
19 // Software Foundation; either version 2 or (at your option) any later version.
21 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
22 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
23 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 // You should have received a copy of the GNU General Public License along
27 // with eCos; if not, write to the Free Software Foundation, Inc.,
28 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
30 // As a special exception, if other files instantiate templates or use macros
31 // or inline functions from this file, or you compile this file and link it
32 // with other works to produce a work based on this file, this file does not
33 // by itself cause the resulting work to be covered by the GNU General Public
34 // License. However the source code for this file must still be made available
35 // in accordance with section (3) of the GNU General Public License.
37 // This exception does not invalidate any other reasons why a work based on
38 // this file might be covered by the GNU General Public License.
40 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
41 // at http://sources.redhat.com/ecos/ecos-license/
42 // -------------------------------------------
43 //####ECOSGPLCOPYRIGHTEND####
44 //=============================================================================
45 //#####DESCRIPTIONBEGIN####
48 // Contributors:jskov, woehler
50 // Purpose: HAL RAM/ROM calling interface
51 // Description: ROM/RAM calling interface table definitions. The layout is a
52 // combination of libbsp and vectors already in use by some
54 // Usage: #include <cyg/hal/hal_if.h>
56 //####DESCRIPTIONEND####
58 //=============================================================================
60 #include <cyg/infra/cyg_type.h> // types & externC
61 #include <cyg/hal/dbg-threads-api.h>
62 #include <cyg/hal/dbg-thread-syscall.h>
66 #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
68 // Architecture/var/platform may override the accessor macros.
69 #include <cyg/hal/hal_arch.h>
71 // Special monitor locking procedures. These are necessary when the monitor
72 // and eCos share facilities, e.g. the network hardware.
73 #if defined (CYGPKG_NET) || defined (CYGPKG_NET_LWIP)
74 #include <cyg/hal/hal_intr.h>
75 #include <cyg/hal/drv_api.h> // cyg_drv_dsr_lock(), etc
76 #define _ENTER_MONITOR() \
78 HAL_DISABLE_INTERRUPTS(ints); \
81 #define _EXIT_MONITOR() \
82 cyg_drv_dsr_unlock(); \
83 HAL_RESTORE_INTERRUPTS(ints)
84 #else // !CYGPKG_NET && !CYGPKG_NET_LWIP
85 #define _ENTER_MONITOR() CYG_EMPTY_STATEMENT
86 #define _EXIT_MONITOR() CYG_EMPTY_STATEMENT
89 //--------------------------------------------------------------------------
90 #ifndef _BSP_HANDLER_T_DEFINED
91 #define _BSP_HANDLER_T_DEFINED
92 typedef int (*bsp_handler_t)(int __irq_nr, void *__regs);
93 #endif // _BSP_HANDLER_T_DEFINED
95 //--------------------------------------------------------------------------
96 // Communication interface table. CYGNUM_CALL_IF_CONSOLE_PROCS and
97 // CYGNUM_CALL_IF_DEBUG_PROCS point to instances (possibly the same)
102 * For serial ports, the control function may be used to set and get the
103 * current baud rate. Usage:
105 * err = (*__control)(COMMCTL_SETBAUD, int bits_per_second);
106 * err => Zero if successful, -1 if error.
108 * baud = (*__control)(COMMCTL_GETBAUD);
109 * baud => -1 if error, current baud otherwise.
115 * Install and remove debugger interrupt handlers. These are the receiver
116 * interrupt routines which are used to change control from a running
117 * program to the debugger stub.
119 __COMMCTL_INSTALL_DBG_ISR,
120 __COMMCTL_REMOVE_DBG_ISR,
123 * Disable comm port interrupt. Returns TRUE if interrupt was enabled,
126 __COMMCTL_IRQ_DISABLE,
129 * Enable comm port interrupt.
131 __COMMCTL_IRQ_ENABLE,
134 * Returns the number of the interrupt vector used by the debug
137 __COMMCTL_DBG_ISR_VECTOR,
140 * Returns the current timeout value and sets a new timeout.
141 * Timeout resolution is in milliseconds.
142 * old_timeout = (*__control)(__COMMCTL_SET_TIMEOUT,
143 * cyg_int32 new_timeout);
145 __COMMCTL_SET_TIMEOUT,
148 * Forces driver to send all characters which may be buffered in
149 * the driver. This only flushes the driver buffers, not necessarily
150 * any hardware FIFO, etc.
152 __COMMCTL_FLUSH_OUTPUT,
155 * Forces driver to enable or disable flushes when a newline is
156 * seen in the output stream. Flushing at line boundaries occurs
157 * in the driver, not necessarily any hardware FIFO, etc. Line
158 * buffering is optional and may only be available in some drivers.
160 __COMMCTL_ENABLE_LINE_FLUSH,
161 __COMMCTL_DISABLE_LINE_FLUSH,
163 } __comm_control_cmd_t;
166 #define CYGNUM_COMM_IF_CH_DATA 0
167 #define CYGNUM_COMM_IF_WRITE 1
168 #define CYGNUM_COMM_IF_READ 2
169 #define CYGNUM_COMM_IF_PUTC 3
170 #define CYGNUM_COMM_IF_GETC 4
171 #define CYGNUM_COMM_IF_CONTROL 5
172 #define CYGNUM_COMM_IF_DBG_ISR 6
173 #define CYGNUM_COMM_IF_GETC_TIMEOUT 7
175 #define CYGNUM_COMM_IF_TABLE_SIZE 8
177 typedef volatile CYG_ADDRWORD hal_virtual_comm_table_t[CYGNUM_COMM_IF_TABLE_SIZE];
179 // The below is a (messy) attempt at adding some type safety to the
180 // above array. At the same time, the accessors allow the
181 // implementation to be easily changed in the future (both tag->data
182 // table and structure implementations have been suggested).
184 typedef void* __comm_if_ch_data_t;
185 typedef void (*__comm_if_write_t)(void* __ch_data, const cyg_uint8* __buf,
187 typedef int (*__comm_if_read_t)(void* __ch_data, cyg_uint8* __buf,
189 typedef void (*__comm_if_putc_t)(void* __ch_data, cyg_uint8 __ch);
190 typedef cyg_uint8 (*__comm_if_getc_t)(void* __ch_data);
191 typedef int (*__comm_if_control_t)(void *__ch_data,
192 __comm_control_cmd_t __func, ...);
193 typedef int (*__comm_if_dbg_isr_t)(void *__ch_data,
194 int* __ctrlc, CYG_ADDRWORD __vec,
195 CYG_ADDRWORD __data);
196 typedef cyg_bool (*__comm_if_getc_timeout_t)(void *__ch_data, void *__ch);
198 #define __call_COMM0(_n_,_rt_,_t_) \
199 static __inline__ _rt_ \
200 __call_COMM_##_n_(hal_virtual_comm_table_t t) \
203 void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
205 res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp); \
210 #define __call_voidCOMM(_n_,_rt_,_t_) \
211 static __inline__ _rt_ \
212 __call_COMM_##_n_(hal_virtual_comm_table_t t) \
214 void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
216 ((_t_)(t[CYGNUM_COMM_##_n_]))(dp); \
220 #define __call_COMM1(_n_,_rt_,_t_,_t1_) \
221 static __inline__ _rt_ \
222 __call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_) \
225 void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
227 res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_); \
232 #define __call_voidCOMM1(_n_,_rt_,_t_,_t1_) \
233 static __inline__ _rt_ \
234 __call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_) \
236 void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
238 ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_); \
242 #define __call_COMM2(_n_,_rt_,_t_,_t1_,_t2_) \
243 static __inline__ _rt_ \
244 __call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_) \
247 void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
249 res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_); \
254 #define __call_voidCOMM2(_n_,_rt_,_t_,_t1_,_t2_) \
255 static __inline__ _rt_ \
256 __call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_) \
258 void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
260 ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_); \
264 #define __call_COMM3(_n_,_rt_,_t_,_t1_,_t2_,_t3_) \
265 static __inline__ _rt_ \
266 __call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
269 void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
271 res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_, _p3_); \
276 #define __call_voidCOMM3(_n_,_rt_,_t_,_t1_,_t2_,_t3_) \
277 static __inline__ _rt_ \
278 __call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
280 void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA]; \
282 ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_, _p3_); \
286 #ifndef CYGACC_COMM_IF_DEFINED
288 #define CYGACC_COMM_IF_CH_DATA(_t_) \
289 ((__comm_if_ch_data_t)((_t_)[CYGNUM_COMM_IF_CH_DATA]))
290 #define CYGACC_COMM_IF_CH_DATA_SET(_t_, _x_) \
291 (_t_)[CYGNUM_COMM_IF_CH_DATA]=(CYG_ADDRWORD)(_x_)
293 __call_voidCOMM2(IF_WRITE, void, __comm_if_write_t, const cyg_uint8 *, cyg_uint32)
294 #define CYGACC_COMM_IF_WRITE(_t_, _b_, _l_) \
295 __call_COMM_IF_WRITE(_t_, _b_, _l_)
296 #define CYGACC_COMM_IF_WRITE_SET(_t_, _x_) \
297 (_t_)[CYGNUM_COMM_IF_WRITE]=(CYG_ADDRWORD)(_x_)
299 __call_voidCOMM2(IF_READ, void, __comm_if_read_t, cyg_uint8 *, cyg_uint32)
300 #define CYGACC_COMM_IF_READ(_t_, _b_, _l_) \
301 __call_COMM_IF_READ(_t_, _b_, _l_)
302 #define CYGACC_COMM_IF_READ_SET(_t_, _x_) \
303 (_t_)[CYGNUM_COMM_IF_READ]=(CYG_ADDRWORD)(_x_)
305 __call_voidCOMM1(IF_PUTC, void, __comm_if_putc_t, cyg_uint8)
306 #define CYGACC_COMM_IF_PUTC(_t_, _c_) \
307 __call_COMM_IF_PUTC(_t_,_c_)
308 #define CYGACC_COMM_IF_PUTC_SET(_t_, _x_) \
309 (_t_)[CYGNUM_COMM_IF_PUTC]=(CYG_ADDRWORD)(_x_)
311 __call_COMM0(IF_GETC, cyg_uint8, __comm_if_getc_t)
312 #define CYGACC_COMM_IF_GETC(_t_) \
313 __call_COMM_IF_GETC(_t_)
314 #define CYGACC_COMM_IF_GETC_SET(_t_, _x_) \
315 (_t_)[CYGNUM_COMM_IF_GETC]=(CYG_ADDRWORD)(_x_)
317 // This macro has not been changed to use inline functions like the
318 // others, simply because it uses variable arguments, and the change
319 // would break binary compatibility.
320 #define CYGACC_COMM_IF_CONTROL(_t_, args...) \
323 res = ((__comm_if_control_t)((_t_)[CYGNUM_COMM_IF_CONTROL]))(CYGACC_COMM_IF_CH_DATA(_t_), args); \
326 #define CYGACC_COMM_IF_CONTROL_SET(_t_, _x_) \
327 (_t_)[CYGNUM_COMM_IF_CONTROL]=(CYG_ADDRWORD)(_x_)
329 __call_COMM3(IF_DBG_ISR, int, __comm_if_dbg_isr_t, int *, CYG_ADDRWORD, CYG_ADDRWORD)
330 #define CYGACC_COMM_IF_DBG_ISR(_t_, _c_, _v_, _d_) \
331 __call_COMM_IF_DBG_ISR(_t_, _c_, _v_, _d_)
332 #define CYGACC_COMM_IF_DBG_ISR_SET(_t_, _x_) \
333 (_t_)[CYGNUM_COMM_IF_DBG_ISR]=(CYG_ADDRWORD)(_x_)
335 __call_COMM1(IF_GETC_TIMEOUT, cyg_bool, __comm_if_getc_timeout_t, void *)
336 #define CYGACC_COMM_IF_GETC_TIMEOUT(_t_, _c_) \
337 __call_COMM_IF_GETC_TIMEOUT(_t_, _c_)
338 #define CYGACC_COMM_IF_GETC_TIMEOUT_SET(_t_, _x_) \
339 (_t_)[CYGNUM_COMM_IF_GETC_TIMEOUT]=(CYG_ADDRWORD)(_x_)
341 #endif // CYGACC_COMM_IF_DEFINED
343 //--------------------------------------------------------------------------
344 // Main calling interface table. Will be assigned a location by the
345 // linker script. Both ROM and RAM startup applications will know about
347 #define CYGNUM_CALL_IF_VERSION 0
348 #define CYGNUM_CALL_IF_available_1 1
349 #define CYGNUM_CALL_IF_available_2 2
350 #define CYGNUM_CALL_IF_available_3 3
351 #define CYGNUM_CALL_IF_KILL_VECTOR 4
352 #define CYGNUM_CALL_IF_CONSOLE_PROCS 5
353 #define CYGNUM_CALL_IF_DEBUG_PROCS 6
354 #define CYGNUM_CALL_IF_FLUSH_DCACHE 7
355 #define CYGNUM_CALL_IF_FLUSH_ICACHE 8
356 #define CYGNUM_CALL_IF_available_9 9
357 #define CYGNUM_CALL_IF_available_10 10
358 #define CYGNUM_CALL_IF_available_11 11
359 #define CYGNUM_CALL_IF_SET_DEBUG_COMM 12
360 #define CYGNUM_CALL_IF_SET_CONSOLE_COMM 13
361 #define CYGNUM_CALL_IF_MONITOR_VERSION 14
362 #define CYGNUM_CALL_IF_DBG_SYSCALL 15
363 #define CYGNUM_CALL_IF_RESET 16
364 #define CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG 17
365 #define CYGNUM_CALL_IF_DELAY_US 18
366 #define CYGNUM_CALL_IF_DBG_DATA 19
367 #define CYGNUM_CALL_IF_FLASH_CFG_OP 20
368 #define CYGNUM_CALL_IF_MONITOR_RETURN 21
369 #define CYGNUM_CALL_IF_FLASH_FIS_OP 22
370 #define CYGNUM_CALL_IF_FLASH_FIS_OP2 23
372 #define CYGNUM_CALL_IF_LAST_ENTRY CYGNUM_CALL_IF_FLASH_FIS_OP2
374 #define CYGNUM_CALL_IF_INSTALL_BPT_FN 35
376 #define CYGNUM_CALL_IF_TABLE_SIZE 64
378 externC volatile CYG_ADDRWORD hal_virtual_vector_table[CYGNUM_CALL_IF_TABLE_SIZE];
380 // Table version contains version information for both the CALL table
381 // itself (the number of the last active entry in the table), and the
382 // COMM table (the size of the table).
383 #define CYGNUM_CALL_IF_TABLE_VERSION_CALL CYGNUM_CALL_IF_LAST_ENTRY
384 #define CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK (CYGNUM_CALL_IF_TABLE_SIZE+1)
385 #define CYGNUM_CALL_IF_TABLE_VERSION_CALL_MAX CYGNUM_CALL_IF_TABLE_SIZE
386 #define CYGNUM_CALL_IF_TABLE_VERSION_COMM CYGNUM_COMM_IF_TABLE_SIZE
387 #define CYGNUM_CALL_IF_TABLE_VERSION_CALL_MASK 0x0000ffff
388 #define CYGNUM_CALL_IF_TABLE_VERSION_COMM_MASK 0xffff0000
389 #define CYGNUM_CALL_IF_TABLE_VERSION_COMM_shift 16
392 // These are special debug/console procs IDs
393 // QUERY_CURRENT will cause the ID of the currently selected proc ID to be
395 // EMPTY this is the ID used for an empty procs table (i.e, NULL
397 // MANGLER selects the procs space reserved for the console mangler
398 // allowing the application to temporarily disable mangling
399 // or temporarily switch in different console procs.
400 #define CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT -1
401 #define CYGNUM_CALL_IF_SET_COMM_ID_EMPTY -2
402 #define CYGNUM_CALL_IF_SET_COMM_ID_MANGLER -3
404 // The below is a (messy) attempt at adding some type safety to the
405 // above array. At the same time, the accessors allow the
406 // implementation to be easily changed in the future (both tag->data
407 // table and structure implementations have been suggested).
409 typedef int __call_if_version_t;
410 typedef void* __call_if_ictrl_table_t;
411 typedef void* __call_if_exc_table_t;
412 typedef bsp_handler_t *__call_if_dbg_vector_t;
413 typedef bsp_handler_t __call_if_kill_vector_t;
414 typedef hal_virtual_comm_table_t *__call_if_console_procs_t;
415 typedef hal_virtual_comm_table_t *__call_if_debug_procs_t;
416 typedef void (__call_if_flush_dcache_t)(void *__p, int __nbytes);
417 typedef void (__call_if_flush_icache_t)(void *__p, int __nbytes);
418 typedef int (__call_if_set_debug_comm_t)(int __comm_id);
419 typedef int (__call_if_set_console_comm_t)(int __comm_id);
420 typedef void* __call_if_dbg_data_t;
421 typedef int (__call_if_dbg_syscall_t) (enum dbg_syscall_ids id,
422 union dbg_thread_syscall_parms *p);
423 typedef void (__call_if_reset_t)(void);
424 typedef int __call_if_console_interrupt_flag_t;
425 typedef void (__call_if_delay_us_t)(cyg_int32 usecs);
426 typedef void (__call_if_install_bpt_fn_t)(void *__epc);
427 typedef char *__call_if_monitor_version_t;
428 typedef void (__call_if_monitor_return_t)(int status);
429 typedef cyg_bool (__call_if_flash_fis_op_fn_t)(int __oper, char *__name, void *__val);
432 // This structure is used to pass parameters to/from the fis routines
434 struct fis_table_entry {
435 unsigned char name[16];
436 CYG_ADDRESS flash_base;
437 CYG_ADDRESS mem_base;
439 CYG_ADDRESS entry_point;
440 unsigned long data_length;
441 unsigned long desc_cksum;
442 unsigned long file_cksum;
445 typedef int (__call_if_flash_fis_op2_fn_t)(int __oper, unsigned int index, struct fis_table_entry *__fis_entry);
447 // This structure is used to pass parameters to/from the fconfig routines.
448 // This allows a single virtual vector interface, with widely varying functionality
451 char *key; // Datum 'key'
452 int keylen; // Length of key
453 void *val; // Pointer to data
454 int type; // Type of datum
455 int offset; // Offset within data (used by _NEXT)
457 typedef cyg_bool (__call_if_flash_cfg_op_fn_t)(int __oper, struct cyg_fconfig *__data);
459 #ifndef CYGACC_CALL_IF_DEFINED
461 #define __data_VV(_n_,_tt_) \
462 static __inline__ _tt_ \
463 __call_vv_##_n_(void) \
465 return ((_tt_)hal_virtual_vector_table[_n_]); \
468 #define __call_VV0(_n_,_tt_,_rt_) \
469 static __inline__ _rt_ \
470 __call_vv_##_n_(void) \
474 res = ((_tt_ *)hal_virtual_vector_table[_n_])(); \
479 #define __call_voidVV0(_n_,_tt_,_rt_) \
480 static __inline__ _rt_ \
481 __call_vv_##_n_(void) \
484 ((_tt_ *)hal_virtual_vector_table[_n_])(); \
488 #define __call_VV1(_n_,_tt_,_rt_,_t1_) \
489 static __inline__ _rt_ \
490 __call_vv_##_n_(_t1_ _p1_) \
494 res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_); \
499 #define __call_voidVV1(_n_,_tt_,_rt_,_t1_) \
500 static __inline__ _rt_ \
501 __call_vv_##_n_(_t1_ _p1_) \
504 ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_); \
508 #define __call_VV2(_n_,_tt_,_rt_,_t1_,_t2_) \
509 static __inline__ _rt_ \
510 __call_vv_##_n_(_t1_ _p1_, _t2_ _p2_) \
514 res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_); \
519 #define __call_voidVV2(_n_,_tt_,_rt_,_t1_,_t2_) \
520 static __inline__ _rt_ \
521 __call_vv_##_n_(_t1_ _p1_, _t2_ _p2_) \
524 ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_); \
528 #define __call_VV3(_n_,_tt_,_rt_,_t1_,_t2_,_t3_) \
529 static __inline__ _rt_ \
530 __call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
534 res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_); \
539 #define __call_voidVV3(_n_,_tt_,_rt_,_t1_,_t2_,_t3_) \
540 static __inline__ _rt_ \
541 __call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_) \
544 ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_); \
548 #define __call_VV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_) \
549 static __inline__ _rt_ \
550 __call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_) \
554 res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_,_p4_); \
559 #define __call_voidVV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_) \
560 static __inline__ _rt_ \
561 __call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_) \
564 ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_,_p4_); \
569 #define CYGACC_DATA_VV(t,e) __call_vv_##e()
570 #define CYGACC_CALL_VV0(t,e) __call_vv_##e
571 #define CYGACC_CALL_VV1(t,e,p1) __call_vv_##e((p1))
572 #define CYGACC_CALL_VV2(t,e,p1,p2) __call_vv_##e((p1),(p2))
573 #define CYGACC_CALL_VV3(t,e,p1,p2,p3) __call_vv_##e((p1),(p2),(p3))
574 #define CYGACC_CALL_VV4(t,e,p1,p2,p3,p4) __call_vv_##e((p1),(p2),(p3),(p4))
576 #define CYGACC_CALL_IF_VERSION() \
577 CYGACC_DATA_VV(__call_if_version_t, CYGNUM_CALL_IF_VERSION)
578 __data_VV(CYGNUM_CALL_IF_VERSION, __call_if_version_t)
579 #define CYGACC_CALL_IF_VERSION_SET(_x_) \
580 hal_virtual_vector_table[CYGNUM_CALL_IF_VERSION]=(CYG_ADDRWORD)(_x_)
582 #define CYGACC_CALL_IF_KILL_VECTOR() \
583 CYGACC_DATA_VV(__call_if_kill_vector_t, CYGNUM_CALL_IF_KILL_VECTOR)
584 __data_VV(CYGNUM_CALL_IF_KILL_VECTOR, __call_if_kill_vector_t)
585 #define CYGACC_CALL_IF_KILL_VECTOR_SET(_x_) \
586 hal_virtual_vector_table[CYGNUM_CALL_IF_KILL_VECTOR]=(CYG_ADDRWORD)(_x_)
588 #define CYGACC_CALL_IF_CONSOLE_PROCS() \
589 CYGACC_DATA_VV(__call_if_console_procs_t, CYGNUM_CALL_IF_CONSOLE_PROCS)
590 __data_VV(CYGNUM_CALL_IF_CONSOLE_PROCS, __call_if_console_procs_t)
591 #define CYGACC_CALL_IF_CONSOLE_PROCS_SET(_x_) \
592 hal_virtual_vector_table[CYGNUM_CALL_IF_CONSOLE_PROCS]=(CYG_ADDRWORD)(_x_)
594 #define CYGACC_CALL_IF_FLUSH_DCACHE(_p_, _n_) \
595 ((__call_if_flush_dcache_t*)hal_virtual_vector_table[CYGNUM_CALL_IF_FLUSH_DCACHE])((_p_), (_n_))
596 #define CYGACC_CALL_IF_FLUSH_DCACHE_SET(_x_) \
597 hal_virtual_vector_table[CYGNUM_CALL_IF_FLUSH_DCACHE]=(CYG_ADDRWORD)(_x_)
599 #define CYGACC_CALL_IF_FLUSH_ICACHE(_p_, _n_) \
600 ((__call_if_flush_icache_t*)hal_virtual_vector_table[CYGNUM_CALL_IF_FLUSH_ICACHE])((_p_), (_n_))
601 #define CYGACC_CALL_IF_FLUSH_ICACHE_SET(_x_) \
602 hal_virtual_vector_table[CYGNUM_CALL_IF_FLUSH_ICACHE]=(CYG_ADDRWORD)(_x_)
604 #define CYGACC_CALL_IF_DEBUG_PROCS() \
605 CYGACC_DATA_VV(__call_if_debug_procs_t, CYGNUM_CALL_IF_DEBUG_PROCS)
606 __data_VV(CYGNUM_CALL_IF_DEBUG_PROCS, __call_if_debug_procs_t)
607 #define CYGACC_CALL_IF_DEBUG_PROCS_SET(_x_) \
608 hal_virtual_vector_table[CYGNUM_CALL_IF_DEBUG_PROCS]=(CYG_ADDRWORD)(_x_)
610 #define CYGACC_CALL_IF_SET_DEBUG_COMM(_i_) \
611 CYGACC_CALL_VV1(__call_if_set_debug_comm_t*, CYGNUM_CALL_IF_SET_DEBUG_COMM, (_i_))
612 __call_VV1(CYGNUM_CALL_IF_SET_DEBUG_COMM, __call_if_set_debug_comm_t, int, int)
613 #define CYGACC_CALL_IF_SET_DEBUG_COMM_SET(_x_) \
614 hal_virtual_vector_table[CYGNUM_CALL_IF_SET_DEBUG_COMM]=(CYG_ADDRWORD)(_x_)
616 #define CYGACC_CALL_IF_SET_CONSOLE_COMM(_i_) \
617 CYGACC_CALL_VV1(__call_if_set_console_comm_t*, CYGNUM_CALL_IF_SET_CONSOLE_COMM, (_i_))
618 __call_VV1(CYGNUM_CALL_IF_SET_CONSOLE_COMM, __call_if_set_console_comm_t, int, int)
619 #define CYGACC_CALL_IF_SET_CONSOLE_COMM_SET(_x_) \
620 hal_virtual_vector_table[CYGNUM_CALL_IF_SET_CONSOLE_COMM]=(CYG_ADDRWORD)(_x_)
622 #define CYGACC_CALL_IF_DBG_DATA() \
623 CYGACC_DATA_VV(__call_if_dbg_data_t, CYGNUM_CALL_IF_DBG_DATA)
624 __data_VV(CYGNUM_CALL_IF_DBG_DATA, __call_if_dbg_data_t)
625 #define CYGACC_CALL_IF_DBG_DATA_SET(_x_) \
626 hal_virtual_vector_table[CYGNUM_CALL_IF_DBG_DATA]=(CYG_ADDRWORD)(_x_)
628 #define CYGACC_CALL_IF_DBG_SYSCALL(_id_,_p_) \
629 CYGACC_CALL_VV2(__call_if_dbg_syscall_t, CYGNUM_CALL_IF_DBG_SYSCALL, _id_, _p_)
630 __call_VV2(CYGNUM_CALL_IF_DBG_SYSCALL, __call_if_dbg_syscall_t, int, enum dbg_syscall_ids , union dbg_thread_syscall_parms *)
631 #define CYGACC_CALL_IF_DBG_SYSCALL_SET(_x_) \
632 hal_virtual_vector_table[CYGNUM_CALL_IF_DBG_SYSCALL]=(CYG_ADDRWORD)(_x_)
634 #define CYGACC_CALL_IF_RESET() \
635 CYGACC_CALL_VV0(__call_if_reset_t*, CYGNUM_CALL_IF_RESET)()
636 __call_voidVV0(CYGNUM_CALL_IF_RESET, __call_if_reset_t, void)
637 #define CYGACC_CALL_IF_RESET_SET(_x_) \
638 hal_virtual_vector_table[CYGNUM_CALL_IF_RESET]=(CYG_ADDRWORD)(_x_)
639 #define CYGACC_CALL_IF_RESET_GET() \
640 ((__call_if_reset_t*)hal_virtual_vector_table[CYGNUM_CALL_IF_RESET])
642 #define CYGACC_CALL_IF_MONITOR_VERSION() \
643 CYGACC_DATA_VV(__call_if_monitor_version_t, CYGNUM_CALL_IF_MONITOR_VERSION)
644 __data_VV(CYGNUM_CALL_IF_MONITOR_VERSION, __call_if_monitor_version_t)
645 #define CYGACC_CALL_IF_MONITOR_VERSION_SET(_x_) \
646 hal_virtual_vector_table[CYGNUM_CALL_IF_MONITOR_VERSION]=(CYG_ADDRWORD)(_x_)
648 #define CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG() \
649 CYGACC_DATA_VV(__call_if_console_interrupt_flag_t, CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG)
650 __data_VV(CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG, __call_if_console_interrupt_flag_t)
651 #define CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(_x_) \
652 hal_virtual_vector_table[CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG]=(CYG_ADDRWORD)(_x_)
654 #define CYGACC_CALL_IF_DELAY_US(_u_) \
655 CYGACC_CALL_VV1(__call_if_delay_us_t*, CYGNUM_CALL_IF_DELAY_US, (_u_))
656 __call_voidVV1(CYGNUM_CALL_IF_DELAY_US, __call_if_delay_us_t, void, cyg_int32)
657 #define CYGACC_CALL_IF_DELAY_US_SET(_x_) \
658 hal_virtual_vector_table[CYGNUM_CALL_IF_DELAY_US]=(CYG_ADDRWORD)(_x_)
660 #define CYGACC_CALL_IF_INSTALL_BPT_FN(_e_) \
661 CYGACC_CALL_VV1(__call_if_install_bpt_fn_t*, CYGNUM_CALL_IF_INSTALL_BPT_FN, (_e_))
662 __call_voidVV1(CYGNUM_CALL_IF_INSTALL_BPT_FN, __call_if_install_bpt_fn_t, void, void *)
663 #define CYGACC_CALL_IF_INSTALL_BPT_FN_SET(_x_) \
664 hal_virtual_vector_table[CYGNUM_CALL_IF_INSTALL_BPT_FN]=(CYG_ADDRWORD)(_x_)
667 // Access persistent data store - kept in FLASH or EEPROM by RedBoot
669 #define CYGNUM_CALL_IF_FLASH_CFG_GET 0 // Get a particular fconfig key
670 #define CYGNUM_CALL_IF_FLASH_CFG_NEXT 1 // Enumerate keys (get the next one)
671 #define CYGNUM_CALL_IF_FLASH_CFG_SET 2 // Update particular fconfig key
672 #define CYGACC_CALL_IF_FLASH_CFG_OP2(_o_,_d_) \
673 CYGACC_CALL_VV2(__call_if_flash_cfg_op_fn_t*, CYGNUM_CALL_IF_FLASH_CFG_OP, (_o_),(_d_))
674 __call_VV2(CYGNUM_CALL_IF_FLASH_CFG_OP, __call_if_flash_cfg_op_fn_t, cyg_bool, int, struct cyg_fconfig *)
676 static __inline__ cyg_bool
677 __call_if_flash_cfg_op(int op, char *key, void *data, int type)
679 struct cyg_fconfig info;
684 return CYGACC_CALL_IF_FLASH_CFG_OP2(op, &info);
686 #define CYGACC_CALL_IF_FLASH_CFG_OP(_o_,_k_,_d_,_t_) \
687 __call_if_flash_cfg_op(_o_,_k_,_d_,_t_)
688 #define CYGACC_CALL_IF_FLASH_CFG_OP_SET(_x_) \
689 hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_CFG_OP]=(CYG_ADDRWORD)(_x_)
691 #define CYGACC_CALL_IF_MONITOR_RETURN(_u_) \
692 CYGACC_CALL_VV1(__call_if_monitor_return_t*, CYGNUM_CALL_IF_MONITOR_RETURN, (_u_))
693 __call_voidVV1(CYGNUM_CALL_IF_MONITOR_RETURN, __call_if_monitor_return_t, void, int)
694 #define CYGACC_CALL_IF_MONITOR_RETURN_SET(_x_) \
695 hal_virtual_vector_table[CYGNUM_CALL_IF_MONITOR_RETURN]=(CYG_ADDRWORD)(_x_)
697 #define CYGACC_CALL_IF_FLASH_FIS_OP(_o_,_k_,_d_) \
698 CYGACC_CALL_VV3(__call_if_flash_fis_op_fn_t*, CYGNUM_CALL_IF_FLASH_FIS_OP, (_o_),(_k_),(_d_))
699 __call_VV3(CYGNUM_CALL_IF_FLASH_FIS_OP, __call_if_flash_fis_op_fn_t, cyg_bool, int, char *, void *)
700 #define CYGACC_CALL_IF_FLASH_FIS_OP_SET(_x_) \
701 hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_FIS_OP]=(CYG_ADDRWORD)(_x_)
702 #define CYGNUM_CALL_IF_FLASH_FIS_GET_FLASH_BASE 0
703 #define CYGNUM_CALL_IF_FLASH_FIS_GET_SIZE 1
704 #define CYGNUM_CALL_IF_FLASH_FIS_GET_MEM_BASE 2
705 #define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY_POINT 3
706 #define CYGNUM_CALL_IF_FLASH_FIS_GET_DATA_LENGTH 4
707 #define CYGNUM_CALL_IF_FLASH_FIS_GET_DESC_CKSUM 5
708 #define CYGNUM_CALL_IF_FLASH_FIS_GET_FILE_CKSUM 6
710 #define CYGACC_CALL_IF_FLASH_FIS_OP2(_o_,_k_,_d_) \
711 CYGACC_CALL_VV3(__call_if_flash_fis_op2_fn_t*, CYGNUM_CALL_IF_FLASH_FIS_OP2, (_o_),(_k_),(_d_))
712 __call_VV3(CYGNUM_CALL_IF_FLASH_FIS_OP2, __call_if_flash_fis_op2_fn_t, int, int, unsigned int, struct fis_table_entry *)
713 #define CYGACC_CALL_IF_FLASH_FIS_OP2_SET(_x_) \
714 hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_FIS_OP2]=(CYG_ADDRWORD)(_x_)
715 #define CYGNUM_CALL_IF_FLASH_FIS_GET_VERSION 0
716 #define CYGNUM_CALL_IF_FLASH_FIS_INIT 1
717 #define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY_COUNT 2
718 #define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY 3
719 #define CYGNUM_CALL_IF_FLASH_FIS_START_UPDATE 4
720 #define CYGNUM_CALL_IF_FLASH_FIS_FINISH_UPDATE 5
721 #define CYGNUM_CALL_IF_FLASH_FIS_MODIFY_ENTRY 6
724 // These need to be kept uptodate with the (unadorned) masters
725 // in RedBoot's flash_config.h:
726 #define CYGNUM_FLASH_CFG_TYPE_CONFIG_EMPTY 0
727 #define CYGNUM_FLASH_CFG_TYPE_CONFIG_BOOL 1
728 #define CYGNUM_FLASH_CFG_TYPE_CONFIG_INT 2
729 #define CYGNUM_FLASH_CFG_TYPE_CONFIG_STRING 3
730 #define CYGNUM_FLASH_CFG_TYPE_CONFIG_SCRIPT 4
731 #define CYGNUM_FLASH_CFG_TYPE_CONFIG_IP 5
732 #define CYGNUM_FLASH_CFG_TYPE_CONFIG_ESA 6
734 #endif // CYGACC_CALL_IF_DEFINED
736 //--------------------------------------------------------------------------
738 externC void hal_if_diag_init(void);
739 externC void hal_if_diag_write_char(char c);
740 externC void hal_if_diag_read_char(char *c);
742 //--------------------------------------------------------------------------
744 externC cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
745 externC cyg_bool hal_ctrlc_check(CYG_ADDRWORD vector, CYG_ADDRWORD data);
747 #define HAL_CTRLC_ISR hal_ctrlc_isr
748 #define HAL_CTRLC_CHECK hal_ctrlc_check
752 #if defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT) \
753 || defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
754 // Then other code might invoke this macro
755 #define HAL_CTRLC_CHECK(a1,a2) 0 // Nothing, no CTRLC here
758 #endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
760 //--------------------------------------------------------------------------
761 // Functions provided by the HAL interface.
762 externC void hal_if_init(void);
763 #if 0 != CYGINT_HAL_PLF_IF_INIT
764 externC void plf_if_init(void);
767 //-----------------------------------------------------------------------------
768 #endif // CYGONCE_HAL_HAL_IF_H