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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [common/] [v2_0/] [include/] [hal_if.h] - Blame information for rev 27

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

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_HAL_IF_H
2
#define CYGONCE_HAL_HAL_IF_H
3
 
4
//=============================================================================
5
//
6
//      hal_if.h
7
//
8
//      HAL header for ROM/RAM calling interface.
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, 2003 Red Hat, Inc.
15
// Copyright (C) 2002 Gary Thomas
16
//
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.
20
//
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
24
// for more details.
25
//
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.
29
//
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.
36
//
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.
39
//
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####
46
//
47
// Author(s):   jskov
48
// Contributors:jskov
49
// Date:        2000-06-07
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
53
//              eCos platforms.
54
// Usage:       #include <cyg/hal/hal_if.h>
55
//                           
56
//####DESCRIPTIONEND####
57
//
58
//=============================================================================
59
 
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>
63
 
64
#include <stdarg.h>
65
 
66
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
67
 
68
// Architecture/var/platform may override the accessor macros.
69
#include <cyg/hal/hal_arch.h>
70
 
71
// Special monitor locking procedures.  These are necessary when the monitor
72
// and eCos share facilities, e.g. the network hardware.
73
#ifdef CYGPKG_NET
74
#include <cyg/hal/hal_intr.h>
75
#include <cyg/hal/drv_api.h>            // cyg_drv_dsr_lock(), etc
76
#define _ENTER_MONITOR()                        \
77
    cyg_uint32 ints;                            \
78
    HAL_DISABLE_INTERRUPTS(ints);               \
79
    cyg_drv_dsr_lock()
80
 
81
#define _EXIT_MONITOR()                         \
82
    cyg_drv_dsr_unlock();                       \
83
    HAL_RESTORE_INTERRUPTS(ints)
84
#else // !CYGPKG_NET
85
#define _ENTER_MONITOR() CYG_EMPTY_STATEMENT
86
#define _EXIT_MONITOR()  CYG_EMPTY_STATEMENT
87
#endif
88
 
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
94
 
95
//--------------------------------------------------------------------------
96
// Communication interface table. CYGNUM_CALL_IF_CONSOLE_PROCS and
97
// CYGNUM_CALL_IF_DEBUG_PROCS point to instances (possibly the same)
98
// of this table.
99
 
100
typedef enum {
101
    /*
102
     * For serial ports, the control function may be used to set and get the
103
     * current baud rate. Usage:
104
     *
105
     *   err = (*__control)(COMMCTL_SETBAUD, int bits_per_second);
106
     *     err => Zero if successful, -1 if error.
107
     *
108
     *   baud = (*__control)(COMMCTL_GETBAUD);
109
     *     baud => -1 if error, current baud otherwise.
110
     */
111
    __COMMCTL_SETBAUD=0,
112
    __COMMCTL_GETBAUD,
113
 
114
    /*
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.
118
     */
119
    __COMMCTL_INSTALL_DBG_ISR,
120
    __COMMCTL_REMOVE_DBG_ISR,
121
 
122
    /*
123
     * Disable comm port interrupt. Returns TRUE if interrupt was enabled,
124
     * FALSE otherwise.
125
     */
126
    __COMMCTL_IRQ_DISABLE,
127
 
128
    /*
129
     * Enable comm port interrupt.
130
     */
131
    __COMMCTL_IRQ_ENABLE,
132
 
133
    /*
134
     * Returns the number of the interrupt vector used by the debug
135
     * interrupt handler.
136
     */
137
    __COMMCTL_DBG_ISR_VECTOR,
138
 
139
    /*
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);
144
     */
145
    __COMMCTL_SET_TIMEOUT,
146
 
147
    /*
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.
151
     */
152
    __COMMCTL_FLUSH_OUTPUT,
153
 
154
    /*
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.
159
     */
160
    __COMMCTL_ENABLE_LINE_FLUSH,
161
    __COMMCTL_DISABLE_LINE_FLUSH,
162
 
163
} __comm_control_cmd_t;
164
 
165
 
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
174
 
175
#define CYGNUM_COMM_IF_TABLE_SIZE                 8
176
 
177
typedef volatile CYG_ADDRWORD hal_virtual_comm_table_t[CYGNUM_COMM_IF_TABLE_SIZE];
178
 
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).
183
 
184
typedef void* __comm_if_ch_data_t;
185
typedef void (*__comm_if_write_t)(void* __ch_data, const cyg_uint8* __buf,
186
                                  cyg_uint32 __len);
187
typedef int (*__comm_if_read_t)(void* __ch_data, cyg_uint8* __buf,
188
                                cyg_uint32 __len);
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 __vector,
195
                               CYG_ADDRWORD __data);
196
typedef cyg_bool (*__comm_if_getc_timeout_t)(void* __ch_data, cyg_uint8* __ch);
197
 
198
#define __call_COMM0(_n_,_rt_,_t_)                              \
199
static __inline__ _rt_                                          \
200
__call_COMM_##_n_(hal_virtual_comm_table_t t)                   \
201
{                                                               \
202
    _rt_ res;                                                   \
203
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
204
    _ENTER_MONITOR();                                           \
205
    res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp);                    \
206
    _EXIT_MONITOR();                                            \
207
    return res;                                                 \
208
}
209
 
210
#define __call_voidCOMM(_n_,_rt_,_t_)                           \
211
static __inline__ _rt_                                          \
212
__call_COMM_##_n_(hal_virtual_comm_table_t t)                   \
213
{                                                               \
214
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
215
    _ENTER_MONITOR();                                           \
216
    ((_t_)(t[CYGNUM_COMM_##_n_]))(dp);                          \
217
    _EXIT_MONITOR();                                            \
218
}
219
 
220
#define __call_COMM1(_n_,_rt_,_t_,_t1_)                         \
221
static __inline__ _rt_                                          \
222
__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_)        \
223
{                                                               \
224
    _rt_ res;                                                   \
225
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
226
    _ENTER_MONITOR();                                           \
227
    res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_);              \
228
    _EXIT_MONITOR();                                            \
229
    return res;                                                 \
230
}
231
 
232
#define __call_voidCOMM1(_n_,_rt_,_t_,_t1_)                     \
233
static __inline__ _rt_                                          \
234
__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_)        \
235
{                                                               \
236
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
237
    _ENTER_MONITOR();                                           \
238
    ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_);                    \
239
    _EXIT_MONITOR();                                            \
240
}
241
 
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_)        \
245
{                                                               \
246
    _rt_ res;                                                   \
247
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
248
    _ENTER_MONITOR();                                           \
249
    res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_);        \
250
    _EXIT_MONITOR();                                            \
251
    return res;                                                 \
252
}
253
 
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_)        \
257
{                                                               \
258
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
259
    _ENTER_MONITOR();                                           \
260
    ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_);              \
261
    _EXIT_MONITOR();                                            \
262
}
263
 
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_)        \
267
{                                                               \
268
    _rt_ res;                                                   \
269
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
270
    _ENTER_MONITOR();                                           \
271
    res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_, _p3_);              \
272
    _EXIT_MONITOR();                                            \
273
    return res;                                                 \
274
}
275
 
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_)        \
279
{                                                               \
280
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
281
    _ENTER_MONITOR();                                           \
282
    ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_, _p3_);        \
283
    _EXIT_MONITOR();                                            \
284
}
285
 
286
#ifndef CYGACC_COMM_IF_DEFINED
287
 
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_)
292
 
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_)
298
 
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_)
304
 
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_)
310
 
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_)
316
 
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...)                                                            \
321
 ({ int res;                                                                                            \
322
    _ENTER_MONITOR();                                                                                   \
323
    res = ((__comm_if_control_t)((_t_)[CYGNUM_COMM_IF_CONTROL]))(CYGACC_COMM_IF_CH_DATA(_t_), args);    \
324
    _EXIT_MONITOR();                                                                                    \
325
    res;})
326
#define CYGACC_COMM_IF_CONTROL_SET(_t_, _x_) \
327
 (_t_)[CYGNUM_COMM_IF_CONTROL]=(CYG_ADDRWORD)(_x_)
328
 
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_)
334
 
335
__call_COMM1(IF_GETC_TIMEOUT, cyg_bool, __comm_if_getc_timeout_t, cyg_uint8 *)
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_)
340
 
341
#endif // CYGACC_COMM_IF_DEFINED
342
 
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
346
// the location.
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
 
370
#define CYGNUM_CALL_IF_LAST_ENTRY                 CYGNUM_CALL_IF_MONITOR_RETURN
371
 
372
#define CYGNUM_CALL_IF_INSTALL_BPT_FN             35
373
 
374
#define CYGNUM_CALL_IF_TABLE_SIZE                 64
375
 
376
externC volatile CYG_ADDRWORD hal_virtual_vector_table[CYGNUM_CALL_IF_TABLE_SIZE];
377
 
378
// Table version contains version information for both the CALL table
379
// itself (the number of the last active entry in the table), and the
380
// COMM table (the size of the table).
381
#define CYGNUM_CALL_IF_TABLE_VERSION_CALL         CYGNUM_CALL_IF_LAST_ENTRY
382
#define CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK    (CYGNUM_CALL_IF_TABLE_SIZE+1)
383
#define CYGNUM_CALL_IF_TABLE_VERSION_CALL_MAX     CYGNUM_CALL_IF_TABLE_SIZE
384
#define CYGNUM_CALL_IF_TABLE_VERSION_COMM         CYGNUM_COMM_IF_TABLE_SIZE
385
#define CYGNUM_CALL_IF_TABLE_VERSION_CALL_MASK    0x0000ffff
386
#define CYGNUM_CALL_IF_TABLE_VERSION_COMM_MASK    0xffff0000
387
#define CYGNUM_CALL_IF_TABLE_VERSION_COMM_shift   16
388
 
389
 
390
// These are special debug/console procs IDs
391
// QUERY_CURRENT will cause the ID of the currently selected proc ID to be
392
//               returned.
393
// EMPTY         this is the ID used for an empty procs table (i.e, NULL
394
//               pointer)
395
// MANGLER       selects the procs space reserved for the console mangler
396
//               allowing the application to temporarily disable mangling
397
//               or temporarily switch in different console procs.
398
#define CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT -1
399
#define CYGNUM_CALL_IF_SET_COMM_ID_EMPTY         -2
400
#define CYGNUM_CALL_IF_SET_COMM_ID_MANGLER       -3
401
 
402
// The below is a (messy) attempt at adding some type safety to the
403
// above array. At the same time, the accessors allow the
404
// implementation to be easily changed in the future (both tag->data
405
// table and structure implementations have been suggested).
406
 
407
typedef int __call_if_version_t;
408
typedef void* __call_if_ictrl_table_t;
409
typedef void* __call_if_exc_table_t;
410
typedef bsp_handler_t *__call_if_dbg_vector_t;
411
typedef bsp_handler_t __call_if_kill_vector_t;
412
typedef hal_virtual_comm_table_t *__call_if_console_procs_t;
413
typedef hal_virtual_comm_table_t *__call_if_debug_procs_t;
414
typedef void (__call_if_flush_dcache_t)(void *__p, int __nbytes);
415
typedef void (__call_if_flush_icache_t)(void *__p, int __nbytes);
416
typedef int (__call_if_set_debug_comm_t)(int __comm_id);
417
typedef int (__call_if_set_console_comm_t)(int __comm_id);
418
typedef void* __call_if_dbg_data_t;
419
typedef int (__call_if_dbg_syscall_t) (enum dbg_syscall_ids id,
420
                                        union dbg_thread_syscall_parms  *p );
421
typedef void (__call_if_reset_t)(void);
422
typedef int __call_if_console_interrupt_flag_t;
423
typedef void (__call_if_delay_us_t)(cyg_int32 usecs);
424
typedef void (__call_if_install_bpt_fn_t)(void *__epc);
425
typedef cyg_bool (__call_if_flash_cfg_op_fn_t)(int __oper, char *__key,
426
                                               void *__val, int __type);
427
typedef char *__call_if_monitor_version_t;
428
typedef void (__call_if_monitor_return_t)(int status);
429
 
430
#ifndef CYGACC_CALL_IF_DEFINED
431
 
432
#define __data_VV(_n_,_tt_)                             \
433
static __inline__ _tt_                                  \
434
__call_vv_##_n_(void)                                   \
435
{                                                       \
436
    return ((_tt_)hal_virtual_vector_table[_n_]);       \
437
}
438
 
439
#define __call_VV0(_n_,_tt_,_rt_)                                       \
440
static __inline__ _rt_                                                  \
441
__call_vv_##_n_(void)                                                   \
442
{                                                                       \
443
    _rt_ res;                                                           \
444
    _ENTER_MONITOR();                                                   \
445
    res = ((_tt_ *)hal_virtual_vector_table[_n_])();                    \
446
    _EXIT_MONITOR();                                                    \
447
    return res;                                                         \
448
}
449
 
450
#define __call_voidVV0(_n_,_tt_,_rt_)                                   \
451
static __inline__ _rt_                                                  \
452
__call_vv_##_n_(void)                                                   \
453
{                                                                       \
454
    _ENTER_MONITOR();                                                   \
455
    ((_tt_ *)hal_virtual_vector_table[_n_])();                          \
456
    _EXIT_MONITOR();                                                    \
457
}
458
 
459
#define __call_VV1(_n_,_tt_,_rt_,_t1_)                                  \
460
static __inline__ _rt_                                                  \
461
__call_vv_##_n_(_t1_ _p1_)                                              \
462
{                                                                       \
463
    _rt_ res;                                                           \
464
    _ENTER_MONITOR();                                                   \
465
    res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_);                \
466
    _EXIT_MONITOR();                                                    \
467
    return res;                                                         \
468
}
469
 
470
#define __call_voidVV1(_n_,_tt_,_rt_,_t1_)                              \
471
static __inline__ _rt_                                                  \
472
__call_vv_##_n_(_t1_ _p1_)                                              \
473
{                                                                       \
474
    _ENTER_MONITOR();                                                   \
475
    ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_);                      \
476
    _EXIT_MONITOR();                                                    \
477
}
478
 
479
#define __call_VV2(_n_,_tt_,_rt_,_t1_,_t2_)                             \
480
static __inline__ _rt_                                                  \
481
__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_)                                   \
482
{                                                                       \
483
    _rt_ res;                                                           \
484
    _ENTER_MONITOR();                                                   \
485
    res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_);           \
486
    _EXIT_MONITOR();                                                    \
487
    return res;                                                         \
488
}
489
 
490
#define __call_voidVV2(_n_,_tt_,_rt_,_t1_,_t2_)                         \
491
static __inline__ _rt_                                                  \
492
__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_)                                   \
493
{                                                                       \
494
    _ENTER_MONITOR();                                                   \
495
    ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_);                 \
496
    _EXIT_MONITOR();                                                    \
497
}
498
 
499
#define __call_VV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_)                   \
500
static __inline__ _rt_                                                  \
501
__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_)             \
502
{                                                                       \
503
    _rt_ res;                                                           \
504
    _ENTER_MONITOR();                                                   \
505
    res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_,_p4_); \
506
    _EXIT_MONITOR();                                                    \
507
    return res;                                                         \
508
}
509
 
510
#define __call_voidVV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_)               \
511
static __inline__ _rt_                                                  \
512
__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_)             \
513
{                                                                       \
514
    _ENTER_MONITOR();                                                   \
515
    ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_,_p4_);       \
516
    _EXIT_MONITOR();                                                    \
517
}
518
 
519
 
520
#define CYGACC_DATA_VV(t,e)              __call_vv_##e()
521
#define CYGACC_CALL_VV0(t,e)             __call_vv_##e
522
#define CYGACC_CALL_VV1(t,e,p1)          __call_vv_##e((p1))
523
#define CYGACC_CALL_VV2(t,e,p1,p2)       __call_vv_##e((p1),(p2))
524
#define CYGACC_CALL_VV3(t,e,p1,p2,p3)    __call_vv_##e((p1),(p2),(p3))
525
#define CYGACC_CALL_VV4(t,e,p1,p2,p3,p4) __call_vv_##e((p1),(p2),(p3),(p4))
526
 
527
#define CYGACC_CALL_IF_VERSION() \
528
 CYGACC_DATA_VV(__call_if_version_t, CYGNUM_CALL_IF_VERSION)
529
__data_VV(CYGNUM_CALL_IF_VERSION, __call_if_version_t)
530
#define CYGACC_CALL_IF_VERSION_SET(_x_) \
531
 hal_virtual_vector_table[CYGNUM_CALL_IF_VERSION]=(CYG_ADDRWORD)(_x_)
532
 
533
#define CYGACC_CALL_IF_KILL_VECTOR() \
534
 CYGACC_DATA_VV(__call_if_kill_vector_t, CYGNUM_CALL_IF_KILL_VECTOR)
535
__data_VV(CYGNUM_CALL_IF_KILL_VECTOR, __call_if_kill_vector_t)
536
#define CYGACC_CALL_IF_KILL_VECTOR_SET(_x_) \
537
 hal_virtual_vector_table[CYGNUM_CALL_IF_KILL_VECTOR]=(CYG_ADDRWORD)(_x_)
538
 
539
#define CYGACC_CALL_IF_CONSOLE_PROCS() \
540
 CYGACC_DATA_VV(__call_if_console_procs_t, CYGNUM_CALL_IF_CONSOLE_PROCS)
541
__data_VV(CYGNUM_CALL_IF_CONSOLE_PROCS, __call_if_console_procs_t)
542
#define CYGACC_CALL_IF_CONSOLE_PROCS_SET(_x_) \
543
 hal_virtual_vector_table[CYGNUM_CALL_IF_CONSOLE_PROCS]=(CYG_ADDRWORD)(_x_)
544
 
545
#define CYGACC_CALL_IF_FLUSH_DCACHE(_p_, _n_) \
546
 ((__call_if_flush_dcache_t*)hal_virtual_vector_table[CYGNUM_CALL_IF_FLUSH_DCACHE])((_p_), (_n_))
547
#define CYGACC_CALL_IF_FLUSH_DCACHE_SET(_x_) \
548
 hal_virtual_vector_table[CYGNUM_CALL_IF_FLUSH_DCACHE]=(CYG_ADDRWORD)(_x_)
549
 
550
#define CYGACC_CALL_IF_FLUSH_ICACHE(_p_, _n_) \
551
 ((__call_if_flush_icache_t*)hal_virtual_vector_table[CYGNUM_CALL_IF_FLUSH_ICACHE])((_p_), (_n_))
552
#define CYGACC_CALL_IF_FLUSH_ICACHE_SET(_x_) \
553
 hal_virtual_vector_table[CYGNUM_CALL_IF_FLUSH_ICACHE]=(CYG_ADDRWORD)(_x_)
554
 
555
#define CYGACC_CALL_IF_DEBUG_PROCS() \
556
 CYGACC_DATA_VV(__call_if_debug_procs_t, CYGNUM_CALL_IF_DEBUG_PROCS)
557
__data_VV(CYGNUM_CALL_IF_DEBUG_PROCS, __call_if_debug_procs_t)
558
#define CYGACC_CALL_IF_DEBUG_PROCS_SET(_x_) \
559
 hal_virtual_vector_table[CYGNUM_CALL_IF_DEBUG_PROCS]=(CYG_ADDRWORD)(_x_)
560
 
561
#define CYGACC_CALL_IF_SET_DEBUG_COMM(_i_) \
562
 CYGACC_CALL_VV1(__call_if_set_debug_comm_t*, CYGNUM_CALL_IF_SET_DEBUG_COMM, (_i_))
563
__call_VV1(CYGNUM_CALL_IF_SET_DEBUG_COMM, __call_if_set_debug_comm_t, int, int)
564
#define CYGACC_CALL_IF_SET_DEBUG_COMM_SET(_x_) \
565
 hal_virtual_vector_table[CYGNUM_CALL_IF_SET_DEBUG_COMM]=(CYG_ADDRWORD)(_x_)
566
 
567
#define CYGACC_CALL_IF_SET_CONSOLE_COMM(_i_) \
568
 CYGACC_CALL_VV1(__call_if_set_console_comm_t*, CYGNUM_CALL_IF_SET_CONSOLE_COMM, (_i_))
569
__call_VV1(CYGNUM_CALL_IF_SET_CONSOLE_COMM, __call_if_set_console_comm_t, int, int)
570
#define CYGACC_CALL_IF_SET_CONSOLE_COMM_SET(_x_) \
571
 hal_virtual_vector_table[CYGNUM_CALL_IF_SET_CONSOLE_COMM]=(CYG_ADDRWORD)(_x_)
572
 
573
#define CYGACC_CALL_IF_DBG_DATA() \
574
 CYGACC_DATA_VV(__call_if_dbg_data_t, CYGNUM_CALL_IF_DBG_DATA)
575
__data_VV(CYGNUM_CALL_IF_DBG_DATA, __call_if_dbg_data_t)
576
#define CYGACC_CALL_IF_DBG_DATA_SET(_x_) \
577
 hal_virtual_vector_table[CYGNUM_CALL_IF_DBG_DATA]=(CYG_ADDRWORD)(_x_)
578
 
579
#define CYGACC_CALL_IF_DBG_SYSCALL(_id_,_p_) \
580
 CYGACC_CALL_VV2(__call_if_dbg_syscall_t, CYGNUM_CALL_IF_DBG_SYSCALL, _id_, _p_)
581
__call_VV2(CYGNUM_CALL_IF_DBG_SYSCALL, __call_if_dbg_syscall_t, int, enum dbg_syscall_ids ,  union dbg_thread_syscall_parms  *)
582
#define CYGACC_CALL_IF_DBG_SYSCALL_SET(_x_) \
583
 hal_virtual_vector_table[CYGNUM_CALL_IF_DBG_SYSCALL]=(CYG_ADDRWORD)(_x_)
584
 
585
#define CYGACC_CALL_IF_RESET() \
586
 CYGACC_CALL_VV0(__call_if_reset_t*, CYGNUM_CALL_IF_RESET)()
587
__call_voidVV0(CYGNUM_CALL_IF_RESET, __call_if_reset_t, void)
588
#define CYGACC_CALL_IF_RESET_SET(_x_) \
589
 hal_virtual_vector_table[CYGNUM_CALL_IF_RESET]=(CYG_ADDRWORD)(_x_)
590
#define CYGACC_CALL_IF_RESET_GET() \
591
 ((__call_if_reset_t*)hal_virtual_vector_table[CYGNUM_CALL_IF_RESET])
592
 
593
#define CYGACC_CALL_IF_MONITOR_VERSION() \
594
 CYGACC_DATA_VV(__call_if_monitor_version_t, CYGNUM_CALL_IF_MONITOR_VERSION)
595
__data_VV(CYGNUM_CALL_IF_MONITOR_VERSION, __call_if_monitor_version_t)
596
#define CYGACC_CALL_IF_MONITOR_VERSION_SET(_x_) \
597
 hal_virtual_vector_table[CYGNUM_CALL_IF_MONITOR_VERSION]=(CYG_ADDRWORD)(_x_)
598
 
599
#define CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG() \
600
 CYGACC_DATA_VV(__call_if_console_interrupt_flag_t, CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG)
601
__data_VV(CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG, __call_if_console_interrupt_flag_t)
602
#define CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(_x_) \
603
 hal_virtual_vector_table[CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG]=(CYG_ADDRWORD)(_x_)
604
 
605
#define CYGACC_CALL_IF_DELAY_US(_u_) \
606
 CYGACC_CALL_VV1(__call_if_delay_us_t*, CYGNUM_CALL_IF_DELAY_US, (_u_))
607
__call_voidVV1(CYGNUM_CALL_IF_DELAY_US, __call_if_delay_us_t, void, cyg_int32)
608
#define CYGACC_CALL_IF_DELAY_US_SET(_x_) \
609
 hal_virtual_vector_table[CYGNUM_CALL_IF_DELAY_US]=(CYG_ADDRWORD)(_x_)
610
 
611
#define CYGACC_CALL_IF_INSTALL_BPT_FN(_e_) \
612
 CYGACC_CALL_VV1(__call_if_install_bpt_fn_t*, CYGNUM_CALL_IF_INSTALL_BPT_FN, (_e_))
613
__call_voidVV1(CYGNUM_CALL_IF_INSTALL_BPT_FN, __call_if_install_bpt_fn_t, void, void *)
614
#define CYGACC_CALL_IF_INSTALL_BPT_FN_SET(_x_) \
615
 hal_virtual_vector_table[CYGNUM_CALL_IF_INSTALL_BPT_FN]=(CYG_ADDRWORD)(_x_)
616
 
617
#define CYGACC_CALL_IF_FLASH_CFG_OP(_o_,_k_,_d_,_t_) \
618
 CYGACC_CALL_VV4(__call_if_flash_cfg_op_fn_t*, CYGNUM_CALL_IF_FLASH_CFG_OP, (_o_),(_k_),(_d_),(_t_))
619
__call_VV4(CYGNUM_CALL_IF_FLASH_CFG_OP, __call_if_flash_cfg_op_fn_t, cyg_bool, int, char *, void *, int)
620
#define CYGACC_CALL_IF_FLASH_CFG_OP_SET(_x_) \
621
 hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_CFG_OP]=(CYG_ADDRWORD)(_x_)
622
#define CYGNUM_CALL_IF_FLASH_CFG_GET (0)
623
 
624
#define CYGACC_CALL_IF_MONITOR_RETURN(_u_) \
625
 CYGACC_CALL_VV1(__call_if_monitor_return_t*, CYGNUM_CALL_IF_MONITOR_RETURN, (_u_))
626
__call_voidVV1(CYGNUM_CALL_IF_MONITOR_RETURN, __call_if_monitor_return_t, void, int)
627
#define CYGACC_CALL_IF_MONITOR_RETURN_SET(_x_) \
628
 hal_virtual_vector_table[CYGNUM_CALL_IF_MONITOR_RETURN]=(CYG_ADDRWORD)(_x_)
629
 
630
// These need to be kept uptodate with the (unadorned) masters
631
// in RedBoot's flash_config.h:
632
#define CYGNUM_FLASH_CFG_OP_CONFIG_EMPTY   0
633
#define CYGNUM_FLASH_CFG_OP_CONFIG_BOOL    1
634
#define CYGNUM_FLASH_CFG_OP_CONFIG_INT     2
635
#define CYGNUM_FLASH_CFG_OP_CONFIG_STRING  3
636
#define CYGNUM_FLASH_CFG_OP_CONFIG_SCRIPT  4
637
#define CYGNUM_FLASH_CFG_OP_CONFIG_IP      5
638
#define CYGNUM_FLASH_CFG_OP_CONFIG_ESA     6
639
 
640
#endif // CYGACC_CALL_IF_DEFINED
641
 
642
//--------------------------------------------------------------------------
643
// Diag wrappers.
644
externC void hal_if_diag_init(void);
645
externC void hal_if_diag_write_char(char c);
646
externC void hal_if_diag_read_char(char *c);
647
 
648
//--------------------------------------------------------------------------
649
// Ctrl-c support.
650
externC cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
651
externC cyg_bool   hal_ctrlc_check(CYG_ADDRWORD vector, CYG_ADDRWORD data);
652
 
653
#define HAL_CTRLC_ISR hal_ctrlc_isr
654
#define HAL_CTRLC_CHECK hal_ctrlc_check
655
 
656
#else
657
 
658
#if defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT) \
659
    || defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
660
// Then other code might invoke this macro
661
#define HAL_CTRLC_CHECK(a1,a2) (0) // Nothing, no CTRLC here
662
#endif
663
 
664
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
665
 
666
//--------------------------------------------------------------------------
667
// Functions provided by the HAL interface.
668
externC void hal_if_init(void);
669
#if 0 != CYGINT_HAL_PLF_IF_INIT
670
externC void plf_if_init(void);
671
#endif
672
 
673
//-----------------------------------------------------------------------------
674
#endif // CYGONCE_HAL_HAL_IF_H
675
// End of hal_if.h

powered by: WebSVN 2.1.0

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