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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [common/] [current/] [include/] [hal_if.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#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, 2004 Free Software Foundation, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under    
17
// the terms of the GNU General Public License as published by the Free     
18
// Software Foundation; either version 2 or (at your option) any later      
19
// version.                                                                 
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT      
22
// ANY 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        
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
29
//
30
// As a special exception, if other files instantiate templates or use      
31
// macros or inline functions from this file, or you compile this file      
32
// and link it with other works to produce a work based on this file,       
33
// this file does not by itself cause the resulting work to be covered by   
34
// the GNU General Public License. However the source code for this file    
35
// must still be made available in accordance with section (3) of the GNU   
36
// General Public License v2.                                               
37
//
38
// This exception does not invalidate any other reasons why a work based    
39
// on this file might be covered by the GNU General Public License.         
40
// -------------------------------------------                              
41
// ####ECOSGPLCOPYRIGHTEND####                                              
42
//=============================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):   jskov
46
// Contributors:jskov, woehler
47
// Date:        2000-06-07
48
// Purpose:     HAL RAM/ROM calling interface
49
// Description: ROM/RAM calling interface table definitions. The layout is a
50
//              combination of libbsp and vectors already in use by some
51
//              eCos platforms.
52
// Usage:       #include <cyg/hal/hal_if.h>
53
//                           
54
//####DESCRIPTIONEND####
55
//
56
//=============================================================================
57
 
58
#include <cyg/infra/cyg_type.h>         // types & externC
59
#include <cyg/hal/dbg-threads-api.h>
60
#include <cyg/hal/dbg-thread-syscall.h>
61
 
62
#include <stdarg.h>
63
 
64
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
65
 
66
// Architecture/var/platform may override the accessor macros.
67
#include <cyg/hal/hal_arch.h>
68
 
69
// Special monitor locking procedures.  These are necessary when the monitor
70
// and eCos share facilities, e.g. the network hardware.
71
#if defined (CYGPKG_NET) || defined (CYGPKG_NET_LWIP)
72
#include <cyg/hal/hal_intr.h>
73
#include <cyg/hal/drv_api.h>            // cyg_drv_dsr_lock(), etc
74
#define _ENTER_MONITOR()                        \
75
    cyg_uint32 ints;                            \
76
    HAL_DISABLE_INTERRUPTS(ints);               \
77
    cyg_drv_dsr_lock()
78
 
79
#define _EXIT_MONITOR()                         \
80
    cyg_drv_dsr_unlock();                       \
81
    HAL_RESTORE_INTERRUPTS(ints)
82
#else // !CYGPKG_NET && !CYGPKG_NET_LWIP
83
#define _ENTER_MONITOR() CYG_EMPTY_STATEMENT
84
#define _EXIT_MONITOR()  CYG_EMPTY_STATEMENT
85
#endif
86
 
87
//--------------------------------------------------------------------------
88
#ifndef _BSP_HANDLER_T_DEFINED
89
#define _BSP_HANDLER_T_DEFINED
90
typedef int (*bsp_handler_t)(int __irq_nr, void *__regs);
91
#endif // _BSP_HANDLER_T_DEFINED
92
 
93
//--------------------------------------------------------------------------
94
// Communication interface table. CYGNUM_CALL_IF_CONSOLE_PROCS and
95
// CYGNUM_CALL_IF_DEBUG_PROCS point to instances (possibly the same)
96
// of this table.
97
 
98
typedef enum {
99
    /*
100
     * For serial ports, the control function may be used to set and get the
101
     * current baud rate. Usage:
102
     *
103
     *   err = (*__control)(COMMCTL_SETBAUD, int bits_per_second);
104
     *     err => Zero if successful, -1 if error.
105
     *
106
     *   baud = (*__control)(COMMCTL_GETBAUD);
107
     *     baud => -1 if error, current baud otherwise.
108
     */
109
    __COMMCTL_SETBAUD=0,
110
    __COMMCTL_GETBAUD,
111
 
112
    /*
113
     * Install and remove debugger interrupt handlers. These are the receiver
114
     * interrupt routines which are used to change control from a running
115
     * program to the debugger stub.
116
     */
117
    __COMMCTL_INSTALL_DBG_ISR,
118
    __COMMCTL_REMOVE_DBG_ISR,
119
 
120
    /*
121
     * Disable comm port interrupt. Returns TRUE if interrupt was enabled,
122
     * FALSE otherwise.
123
     */
124
    __COMMCTL_IRQ_DISABLE,
125
 
126
    /*
127
     * Enable comm port interrupt.
128
     */
129
    __COMMCTL_IRQ_ENABLE,
130
 
131
    /*
132
     * Returns the number of the interrupt vector used by the debug
133
     * interrupt handler.
134
     */
135
    __COMMCTL_DBG_ISR_VECTOR,
136
 
137
    /*
138
     * Returns the current timeout value and sets a new timeout.
139
     * Timeout resolution is in milliseconds.
140
     *   old_timeout = (*__control)(__COMMCTL_SET_TIMEOUT,
141
     *                              cyg_int32 new_timeout);
142
     */
143
    __COMMCTL_SET_TIMEOUT,
144
 
145
    /*
146
     * Forces driver to send all characters which may be buffered in
147
     * the driver. This only flushes the driver buffers, not necessarily
148
     * any hardware FIFO, etc.
149
     */
150
    __COMMCTL_FLUSH_OUTPUT,
151
 
152
    /*
153
     * Forces driver to enable or disable flushes when a newline is
154
     * seen in the output stream. Flushing at line boundaries occurs
155
     * in the driver, not necessarily any hardware FIFO, etc. Line
156
     * buffering is optional and may only be available in some drivers.
157
     */
158
    __COMMCTL_ENABLE_LINE_FLUSH,
159
    __COMMCTL_DISABLE_LINE_FLUSH,
160
 
161
} __comm_control_cmd_t;
162
 
163
 
164
#define CYGNUM_COMM_IF_CH_DATA                    0
165
#define CYGNUM_COMM_IF_WRITE                      1
166
#define CYGNUM_COMM_IF_READ                       2
167
#define CYGNUM_COMM_IF_PUTC                       3
168
#define CYGNUM_COMM_IF_GETC                       4
169
#define CYGNUM_COMM_IF_CONTROL                    5
170
#define CYGNUM_COMM_IF_DBG_ISR                    6
171
#define CYGNUM_COMM_IF_GETC_TIMEOUT               7
172
 
173
#define CYGNUM_COMM_IF_TABLE_SIZE                 8
174
 
175
typedef volatile CYG_ADDRWORD hal_virtual_comm_table_t[CYGNUM_COMM_IF_TABLE_SIZE];
176
 
177
// The below is a (messy) attempt at adding some type safety to the
178
// above array. At the same time, the accessors allow the
179
// implementation to be easily changed in the future (both tag->data
180
// table and structure implementations have been suggested).
181
 
182
typedef void* __comm_if_ch_data_t;
183
typedef void (*__comm_if_write_t)(void* __ch_data, const cyg_uint8* __buf,
184
                                  cyg_uint32 __len);
185
typedef int (*__comm_if_read_t)(void* __ch_data, cyg_uint8* __buf,
186
                                cyg_uint32 __len);
187
typedef void (*__comm_if_putc_t)(void* __ch_data, cyg_uint8 __ch);
188
typedef cyg_uint8 (*__comm_if_getc_t)(void* __ch_data);
189
typedef int (*__comm_if_control_t)(void *__ch_data,
190
                                   __comm_control_cmd_t __func, ...);
191
typedef int (*__comm_if_dbg_isr_t)(void *__ch_data,
192
                               int* __ctrlc, CYG_ADDRWORD __vec,
193
                               CYG_ADDRWORD __data);
194
typedef cyg_bool (*__comm_if_getc_timeout_t)(void* __ch_data, cyg_uint8* __ch);
195
 
196
#define __call_COMM0(_n_,_rt_,_t_)                              \
197
static __inline__ _rt_                                          \
198
__call_COMM_##_n_(hal_virtual_comm_table_t t)                   \
199
{                                                               \
200
    _rt_ res;                                                   \
201
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
202
    _ENTER_MONITOR();                                           \
203
    res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp);                    \
204
    _EXIT_MONITOR();                                            \
205
    return res;                                                 \
206
}
207
 
208
#define __call_voidCOMM(_n_,_rt_,_t_)                           \
209
static __inline__ _rt_                                          \
210
__call_COMM_##_n_(hal_virtual_comm_table_t t)                   \
211
{                                                               \
212
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
213
    _ENTER_MONITOR();                                           \
214
    ((_t_)(t[CYGNUM_COMM_##_n_]))(dp);                          \
215
    _EXIT_MONITOR();                                            \
216
}
217
 
218
#define __call_COMM1(_n_,_rt_,_t_,_t1_)                         \
219
static __inline__ _rt_                                          \
220
__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_)        \
221
{                                                               \
222
    _rt_ res;                                                   \
223
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
224
    _ENTER_MONITOR();                                           \
225
    res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_);              \
226
    _EXIT_MONITOR();                                            \
227
    return res;                                                 \
228
}
229
 
230
#define __call_voidCOMM1(_n_,_rt_,_t_,_t1_)                     \
231
static __inline__ _rt_                                          \
232
__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_)        \
233
{                                                               \
234
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
235
    _ENTER_MONITOR();                                           \
236
    ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_);                    \
237
    _EXIT_MONITOR();                                            \
238
}
239
 
240
#define __call_COMM2(_n_,_rt_,_t_,_t1_,_t2_)                    \
241
static __inline__ _rt_                                          \
242
__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_)        \
243
{                                                               \
244
    _rt_ res;                                                   \
245
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
246
    _ENTER_MONITOR();                                           \
247
    res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_);        \
248
    _EXIT_MONITOR();                                            \
249
    return res;                                                 \
250
}
251
 
252
#define __call_voidCOMM2(_n_,_rt_,_t_,_t1_,_t2_)                \
253
static __inline__ _rt_                                          \
254
__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_)        \
255
{                                                               \
256
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
257
    _ENTER_MONITOR();                                           \
258
    ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_);              \
259
    _EXIT_MONITOR();                                            \
260
}
261
 
262
#define __call_COMM3(_n_,_rt_,_t_,_t1_,_t2_,_t3_)               \
263
static __inline__ _rt_                                          \
264
__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_, _t3_ _p3_)        \
265
{                                                               \
266
    _rt_ res;                                                   \
267
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
268
    _ENTER_MONITOR();                                           \
269
    res = ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_, _p3_);              \
270
    _EXIT_MONITOR();                                            \
271
    return res;                                                 \
272
}
273
 
274
#define __call_voidCOMM3(_n_,_rt_,_t_,_t1_,_t2_,_t3_)           \
275
static __inline__ _rt_                                          \
276
__call_COMM_##_n_(hal_virtual_comm_table_t t, _t1_ _p1_, _t2_ _p2_, _t3_ _p3_)        \
277
{                                                               \
278
    void *dp = (__comm_if_ch_data_t)t[CYGNUM_COMM_IF_CH_DATA];  \
279
    _ENTER_MONITOR();                                           \
280
    ((_t_)(t[CYGNUM_COMM_##_n_]))(dp, _p1_, _p2_, _p3_);        \
281
    _EXIT_MONITOR();                                            \
282
}
283
 
284
#ifndef CYGACC_COMM_IF_DEFINED
285
 
286
#define CYGACC_COMM_IF_CH_DATA(_t_) \
287
 ((__comm_if_ch_data_t)((_t_)[CYGNUM_COMM_IF_CH_DATA]))
288
#define CYGACC_COMM_IF_CH_DATA_SET(_t_, _x_) \
289
 (_t_)[CYGNUM_COMM_IF_CH_DATA]=(CYG_ADDRWORD)(_x_)
290
 
291
__call_voidCOMM2(IF_WRITE, void, __comm_if_write_t, const cyg_uint8 *, cyg_uint32)
292
#define CYGACC_COMM_IF_WRITE(_t_, _b_, _l_) \
293
 __call_COMM_IF_WRITE(_t_, _b_, _l_)
294
#define CYGACC_COMM_IF_WRITE_SET(_t_, _x_) \
295
 (_t_)[CYGNUM_COMM_IF_WRITE]=(CYG_ADDRWORD)(_x_)
296
 
297
__call_voidCOMM2(IF_READ, void, __comm_if_read_t, cyg_uint8 *, cyg_uint32)
298
#define CYGACC_COMM_IF_READ(_t_, _b_, _l_) \
299
 __call_COMM_IF_READ(_t_, _b_, _l_)
300
#define CYGACC_COMM_IF_READ_SET(_t_, _x_) \
301
 (_t_)[CYGNUM_COMM_IF_READ]=(CYG_ADDRWORD)(_x_)
302
 
303
__call_voidCOMM1(IF_PUTC, void, __comm_if_putc_t, cyg_uint8)
304
#define CYGACC_COMM_IF_PUTC(_t_, _c_) \
305
 __call_COMM_IF_PUTC(_t_,_c_)
306
#define CYGACC_COMM_IF_PUTC_SET(_t_, _x_) \
307
 (_t_)[CYGNUM_COMM_IF_PUTC]=(CYG_ADDRWORD)(_x_)
308
 
309
__call_COMM0(IF_GETC, cyg_uint8, __comm_if_getc_t)
310
#define CYGACC_COMM_IF_GETC(_t_) \
311
 __call_COMM_IF_GETC(_t_)
312
#define CYGACC_COMM_IF_GETC_SET(_t_, _x_) \
313
 (_t_)[CYGNUM_COMM_IF_GETC]=(CYG_ADDRWORD)(_x_)
314
 
315
// This macro has not been changed to use inline functions like the
316
// others, simply because it uses variable arguments, and the change
317
// would break binary compatibility.
318
#define CYGACC_COMM_IF_CONTROL(_t_, args...)                                                            \
319
 ({ int res;                                                                                            \
320
    _ENTER_MONITOR();                                                                                   \
321
    res = ((__comm_if_control_t)((_t_)[CYGNUM_COMM_IF_CONTROL]))(CYGACC_COMM_IF_CH_DATA(_t_), args);    \
322
    _EXIT_MONITOR();                                                                                    \
323
    res;})
324
#define CYGACC_COMM_IF_CONTROL_SET(_t_, _x_) \
325
 (_t_)[CYGNUM_COMM_IF_CONTROL]=(CYG_ADDRWORD)(_x_)
326
 
327
__call_COMM3(IF_DBG_ISR, int, __comm_if_dbg_isr_t, int *, CYG_ADDRWORD, CYG_ADDRWORD)
328
#define CYGACC_COMM_IF_DBG_ISR(_t_, _c_, _v_, _d_) \
329
 __call_COMM_IF_DBG_ISR(_t_, _c_, _v_, _d_)
330
#define CYGACC_COMM_IF_DBG_ISR_SET(_t_, _x_) \
331
 (_t_)[CYGNUM_COMM_IF_DBG_ISR]=(CYG_ADDRWORD)(_x_)
332
 
333
__call_COMM1(IF_GETC_TIMEOUT, cyg_bool, __comm_if_getc_timeout_t, cyg_uint8 *)
334
#define CYGACC_COMM_IF_GETC_TIMEOUT(_t_, _c_) \
335
 __call_COMM_IF_GETC_TIMEOUT(_t_, _c_)
336
#define CYGACC_COMM_IF_GETC_TIMEOUT_SET(_t_, _x_) \
337
 (_t_)[CYGNUM_COMM_IF_GETC_TIMEOUT]=(CYG_ADDRWORD)(_x_)
338
 
339
#endif // CYGACC_COMM_IF_DEFINED
340
 
341
//--------------------------------------------------------------------------
342
// Main calling interface table. Will be assigned a location by the 
343
// linker script. Both ROM and RAM startup applications will know about
344
// the location.
345
#define CYGNUM_CALL_IF_VERSION                    0
346
#define CYGNUM_CALL_IF_available_1                1
347
#define CYGNUM_CALL_IF_available_2                2
348
#define CYGNUM_CALL_IF_available_3                3
349
#define CYGNUM_CALL_IF_KILL_VECTOR                4
350
#define CYGNUM_CALL_IF_CONSOLE_PROCS              5
351
#define CYGNUM_CALL_IF_DEBUG_PROCS                6
352
#define CYGNUM_CALL_IF_available_7                7
353
#define CYGNUM_CALL_IF_available_8                8
354
#define CYGNUM_CALL_IF_available_9                9
355
#define CYGNUM_CALL_IF_available_10               10
356
#define CYGNUM_CALL_IF_available_11               11
357
#define CYGNUM_CALL_IF_SET_DEBUG_COMM             12
358
#define CYGNUM_CALL_IF_SET_CONSOLE_COMM           13
359
#define CYGNUM_CALL_IF_MONITOR_VERSION            14
360
#define CYGNUM_CALL_IF_DBG_SYSCALL                15
361
#define CYGNUM_CALL_IF_RESET                      16
362
#define CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG     17
363
#define CYGNUM_CALL_IF_DELAY_US                   18
364
#define CYGNUM_CALL_IF_DBG_DATA                   19
365
#define CYGNUM_CALL_IF_FLASH_CFG_OP               20
366
#define CYGNUM_CALL_IF_MONITOR_RETURN             21
367
#define CYGNUM_CALL_IF_FLASH_FIS_OP               22
368
#define CYGNUM_CALL_IF_FLASH_FIS_OP2              23
369
 
370
#define CYGNUM_CALL_IF_LAST_ENTRY                 CYGNUM_CALL_IF_FLASH_FIS_OP2
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 int (__call_if_set_debug_comm_t)(int __comm_id);
415
typedef int (__call_if_set_console_comm_t)(int __comm_id);
416
typedef void* __call_if_dbg_data_t;
417
typedef int (__call_if_dbg_syscall_t) (enum dbg_syscall_ids id,
418
                                        union dbg_thread_syscall_parms  *p );
419
typedef void (__call_if_reset_t)(void);
420
typedef int __call_if_console_interrupt_flag_t;
421
typedef void (__call_if_delay_us_t)(cyg_int32 usecs);
422
typedef void (__call_if_install_bpt_fn_t)(void *__epc);
423
typedef char *__call_if_monitor_version_t;
424
typedef void (__call_if_monitor_return_t)(int status);
425
typedef cyg_bool (__call_if_flash_fis_op_fn_t)(int __oper, char *__name, void *__val);
426
 
427
//
428
// This structure is used to pass parameters to/from the fis routines
429
//
430
struct fis_table_entry {
431
   unsigned char name[16];
432
   CYG_ADDRESS   flash_base;
433
   CYG_ADDRESS   mem_base;
434
   unsigned long size;
435
   CYG_ADDRESS   entry_point;
436
   unsigned long data_length;
437
   unsigned long desc_cksum;
438
   unsigned long file_cksum;
439
};
440
 
441
typedef int (__call_if_flash_fis_op2_fn_t)(int __oper, unsigned int index, struct fis_table_entry *__fis_entry);
442
//
443
// This structure is used to pass parameters to/from the fconfig routines.
444
// This allows a single virtual vector interface, with widely varying functionality
445
//
446
struct cyg_fconfig {
447
    char *key;      // Datum 'key'
448
    int   keylen;   // Length of key
449
    void *val;      // Pointer to data
450
    int   type;     // Type of datum
451
    int   offset;   // Offset within data (used by _NEXT)
452
};
453
typedef cyg_bool (__call_if_flash_cfg_op_fn_t)(int __oper, struct cyg_fconfig *__data);
454
 
455
#ifndef CYGACC_CALL_IF_DEFINED
456
 
457
#define __data_VV(_n_,_tt_)                             \
458
static __inline__ _tt_                                  \
459
__call_vv_##_n_(void)                                   \
460
{                                                       \
461
    return ((_tt_)hal_virtual_vector_table[_n_]);       \
462
}
463
 
464
#define __call_VV0(_n_,_tt_,_rt_)                                       \
465
static __inline__ _rt_                                                  \
466
__call_vv_##_n_(void)                                                   \
467
{                                                                       \
468
    _rt_ res;                                                           \
469
    _ENTER_MONITOR();                                                   \
470
    res = ((_tt_ *)hal_virtual_vector_table[_n_])();                    \
471
    _EXIT_MONITOR();                                                    \
472
    return res;                                                         \
473
}
474
 
475
#define __call_voidVV0(_n_,_tt_,_rt_)                                   \
476
static __inline__ _rt_                                                  \
477
__call_vv_##_n_(void)                                                   \
478
{                                                                       \
479
    _ENTER_MONITOR();                                                   \
480
    ((_tt_ *)hal_virtual_vector_table[_n_])();                          \
481
    _EXIT_MONITOR();                                                    \
482
}
483
 
484
#define __call_VV1(_n_,_tt_,_rt_,_t1_)                                  \
485
static __inline__ _rt_                                                  \
486
__call_vv_##_n_(_t1_ _p1_)                                              \
487
{                                                                       \
488
    _rt_ res;                                                           \
489
    _ENTER_MONITOR();                                                   \
490
    res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_);                \
491
    _EXIT_MONITOR();                                                    \
492
    return res;                                                         \
493
}
494
 
495
#define __call_voidVV1(_n_,_tt_,_rt_,_t1_)                              \
496
static __inline__ _rt_                                                  \
497
__call_vv_##_n_(_t1_ _p1_)                                              \
498
{                                                                       \
499
    _ENTER_MONITOR();                                                   \
500
    ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_);                      \
501
    _EXIT_MONITOR();                                                    \
502
}
503
 
504
#define __call_VV2(_n_,_tt_,_rt_,_t1_,_t2_)                             \
505
static __inline__ _rt_                                                  \
506
__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_)                                   \
507
{                                                                       \
508
    _rt_ res;                                                           \
509
    _ENTER_MONITOR();                                                   \
510
    res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_);           \
511
    _EXIT_MONITOR();                                                    \
512
    return res;                                                         \
513
}
514
 
515
#define __call_voidVV2(_n_,_tt_,_rt_,_t1_,_t2_)                         \
516
static __inline__ _rt_                                                  \
517
__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_)                                   \
518
{                                                                       \
519
    _ENTER_MONITOR();                                                   \
520
    ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_);                 \
521
    _EXIT_MONITOR();                                                    \
522
}
523
 
524
#define __call_VV3(_n_,_tt_,_rt_,_t1_,_t2_,_t3_)                        \
525
static __inline__ _rt_                                                  \
526
__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_)                        \
527
{                                                                       \
528
    _rt_ res;                                                           \
529
    _ENTER_MONITOR();                                                   \
530
    res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_);      \
531
    _EXIT_MONITOR();                                                    \
532
    return res;                                                         \
533
}
534
 
535
#define __call_voidVV3(_n_,_tt_,_rt_,_t1_,_t2_,_t3_)                    \
536
static __inline__ _rt_                                                  \
537
__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_)                        \
538
{                                                                       \
539
    _ENTER_MONITOR();                                                   \
540
    ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_);            \
541
    _EXIT_MONITOR();                                                    \
542
}
543
 
544
#define __call_VV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_)                   \
545
static __inline__ _rt_                                                  \
546
__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_)             \
547
{                                                                       \
548
    _rt_ res;                                                           \
549
    _ENTER_MONITOR();                                                   \
550
    res = ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_,_p4_); \
551
    _EXIT_MONITOR();                                                    \
552
    return res;                                                         \
553
}
554
 
555
#define __call_voidVV4(_n_,_tt_,_rt_,_t1_,_t2_,_t3_,_t4_)               \
556
static __inline__ _rt_                                                  \
557
__call_vv_##_n_(_t1_ _p1_, _t2_ _p2_, _t3_ _p3_, _t4_ _p4_)             \
558
{                                                                       \
559
    _ENTER_MONITOR();                                                   \
560
    ((_tt_ *)hal_virtual_vector_table[_n_])(_p1_,_p2_,_p3_,_p4_);       \
561
    _EXIT_MONITOR();                                                    \
562
}
563
 
564
 
565
#define CYGACC_DATA_VV(t,e)              __call_vv_##e()
566
#define CYGACC_CALL_VV0(t,e)             __call_vv_##e
567
#define CYGACC_CALL_VV1(t,e,p1)          __call_vv_##e((p1))
568
#define CYGACC_CALL_VV2(t,e,p1,p2)       __call_vv_##e((p1),(p2))
569
#define CYGACC_CALL_VV3(t,e,p1,p2,p3)    __call_vv_##e((p1),(p2),(p3))
570
#define CYGACC_CALL_VV4(t,e,p1,p2,p3,p4) __call_vv_##e((p1),(p2),(p3),(p4))
571
 
572
#define CYGACC_CALL_IF_VERSION() \
573
 CYGACC_DATA_VV(__call_if_version_t, CYGNUM_CALL_IF_VERSION)
574
__data_VV(CYGNUM_CALL_IF_VERSION, __call_if_version_t)
575
#define CYGACC_CALL_IF_VERSION_SET(_x_) \
576
 hal_virtual_vector_table[CYGNUM_CALL_IF_VERSION]=(CYG_ADDRWORD)(_x_)
577
 
578
#define CYGACC_CALL_IF_KILL_VECTOR() \
579
 CYGACC_DATA_VV(__call_if_kill_vector_t, CYGNUM_CALL_IF_KILL_VECTOR)
580
__data_VV(CYGNUM_CALL_IF_KILL_VECTOR, __call_if_kill_vector_t)
581
#define CYGACC_CALL_IF_KILL_VECTOR_SET(_x_) \
582
 hal_virtual_vector_table[CYGNUM_CALL_IF_KILL_VECTOR]=(CYG_ADDRWORD)(_x_)
583
 
584
#define CYGACC_CALL_IF_CONSOLE_PROCS() \
585
 CYGACC_DATA_VV(__call_if_console_procs_t, CYGNUM_CALL_IF_CONSOLE_PROCS)
586
__data_VV(CYGNUM_CALL_IF_CONSOLE_PROCS, __call_if_console_procs_t)
587
#define CYGACC_CALL_IF_CONSOLE_PROCS_SET(_x_) \
588
 hal_virtual_vector_table[CYGNUM_CALL_IF_CONSOLE_PROCS]=(CYG_ADDRWORD)(_x_)
589
 
590
#define CYGACC_CALL_IF_DEBUG_PROCS() \
591
 CYGACC_DATA_VV(__call_if_debug_procs_t, CYGNUM_CALL_IF_DEBUG_PROCS)
592
__data_VV(CYGNUM_CALL_IF_DEBUG_PROCS, __call_if_debug_procs_t)
593
#define CYGACC_CALL_IF_DEBUG_PROCS_SET(_x_) \
594
 hal_virtual_vector_table[CYGNUM_CALL_IF_DEBUG_PROCS]=(CYG_ADDRWORD)(_x_)
595
 
596
#define CYGACC_CALL_IF_SET_DEBUG_COMM(_i_) \
597
 CYGACC_CALL_VV1(__call_if_set_debug_comm_t*, CYGNUM_CALL_IF_SET_DEBUG_COMM, (_i_))
598
__call_VV1(CYGNUM_CALL_IF_SET_DEBUG_COMM, __call_if_set_debug_comm_t, int, int)
599
#define CYGACC_CALL_IF_SET_DEBUG_COMM_SET(_x_) \
600
 hal_virtual_vector_table[CYGNUM_CALL_IF_SET_DEBUG_COMM]=(CYG_ADDRWORD)(_x_)
601
 
602
#define CYGACC_CALL_IF_SET_CONSOLE_COMM(_i_) \
603
 CYGACC_CALL_VV1(__call_if_set_console_comm_t*, CYGNUM_CALL_IF_SET_CONSOLE_COMM, (_i_))
604
__call_VV1(CYGNUM_CALL_IF_SET_CONSOLE_COMM, __call_if_set_console_comm_t, int, int)
605
#define CYGACC_CALL_IF_SET_CONSOLE_COMM_SET(_x_) \
606
 hal_virtual_vector_table[CYGNUM_CALL_IF_SET_CONSOLE_COMM]=(CYG_ADDRWORD)(_x_)
607
 
608
#define CYGACC_CALL_IF_DBG_DATA() \
609
 CYGACC_DATA_VV(__call_if_dbg_data_t, CYGNUM_CALL_IF_DBG_DATA)
610
__data_VV(CYGNUM_CALL_IF_DBG_DATA, __call_if_dbg_data_t)
611
#define CYGACC_CALL_IF_DBG_DATA_SET(_x_) \
612
 hal_virtual_vector_table[CYGNUM_CALL_IF_DBG_DATA]=(CYG_ADDRWORD)(_x_)
613
 
614
#define CYGACC_CALL_IF_DBG_SYSCALL(_id_,_p_) \
615
 CYGACC_CALL_VV2(__call_if_dbg_syscall_t, CYGNUM_CALL_IF_DBG_SYSCALL, _id_, _p_)
616
__call_VV2(CYGNUM_CALL_IF_DBG_SYSCALL, __call_if_dbg_syscall_t, int, enum dbg_syscall_ids ,  union dbg_thread_syscall_parms  *)
617
#define CYGACC_CALL_IF_DBG_SYSCALL_SET(_x_) \
618
 hal_virtual_vector_table[CYGNUM_CALL_IF_DBG_SYSCALL]=(CYG_ADDRWORD)(_x_)
619
 
620
#define CYGACC_CALL_IF_RESET() \
621
 CYGACC_CALL_VV0(__call_if_reset_t*, CYGNUM_CALL_IF_RESET)()
622
__call_voidVV0(CYGNUM_CALL_IF_RESET, __call_if_reset_t, void)
623
#define CYGACC_CALL_IF_RESET_SET(_x_) \
624
 hal_virtual_vector_table[CYGNUM_CALL_IF_RESET]=(CYG_ADDRWORD)(_x_)
625
#define CYGACC_CALL_IF_RESET_GET() \
626
 ((__call_if_reset_t*)hal_virtual_vector_table[CYGNUM_CALL_IF_RESET])
627
 
628
#define CYGACC_CALL_IF_MONITOR_VERSION() \
629
 CYGACC_DATA_VV(__call_if_monitor_version_t, CYGNUM_CALL_IF_MONITOR_VERSION)
630
__data_VV(CYGNUM_CALL_IF_MONITOR_VERSION, __call_if_monitor_version_t)
631
#define CYGACC_CALL_IF_MONITOR_VERSION_SET(_x_) \
632
 hal_virtual_vector_table[CYGNUM_CALL_IF_MONITOR_VERSION]=(CYG_ADDRWORD)(_x_)
633
 
634
#define CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG() \
635
 CYGACC_DATA_VV(__call_if_console_interrupt_flag_t, CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG)
636
__data_VV(CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG, __call_if_console_interrupt_flag_t)
637
#define CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(_x_) \
638
 hal_virtual_vector_table[CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG]=(CYG_ADDRWORD)(_x_)
639
 
640
#define CYGACC_CALL_IF_DELAY_US(_u_) \
641
 CYGACC_CALL_VV1(__call_if_delay_us_t*, CYGNUM_CALL_IF_DELAY_US, (_u_))
642
__call_voidVV1(CYGNUM_CALL_IF_DELAY_US, __call_if_delay_us_t, void, cyg_int32)
643
#define CYGACC_CALL_IF_DELAY_US_SET(_x_) \
644
 hal_virtual_vector_table[CYGNUM_CALL_IF_DELAY_US]=(CYG_ADDRWORD)(_x_)
645
 
646
#define CYGACC_CALL_IF_INSTALL_BPT_FN(_e_) \
647
 CYGACC_CALL_VV1(__call_if_install_bpt_fn_t*, CYGNUM_CALL_IF_INSTALL_BPT_FN, (_e_))
648
__call_voidVV1(CYGNUM_CALL_IF_INSTALL_BPT_FN, __call_if_install_bpt_fn_t, void, void *)
649
#define CYGACC_CALL_IF_INSTALL_BPT_FN_SET(_x_) \
650
 hal_virtual_vector_table[CYGNUM_CALL_IF_INSTALL_BPT_FN]=(CYG_ADDRWORD)(_x_)
651
 
652
//
653
// Access persistent data store - kept in FLASH or EEPROM by RedBoot
654
//
655
#define CYGNUM_CALL_IF_FLASH_CFG_GET  (0)     // Get a particular fconfig key
656
#define CYGNUM_CALL_IF_FLASH_CFG_NEXT (1)     // Enumerate keys (get the next one)
657
#define CYGNUM_CALL_IF_FLASH_CFG_SET  (2)     // Update particular fconfig key
658
#define CYGACC_CALL_IF_FLASH_CFG_OP2(_o_,_d_) \
659
 CYGACC_CALL_VV2(__call_if_flash_cfg_op_fn_t*, CYGNUM_CALL_IF_FLASH_CFG_OP, (_o_),(_d_))
660
__call_VV2(CYGNUM_CALL_IF_FLASH_CFG_OP, __call_if_flash_cfg_op_fn_t, cyg_bool, int, struct cyg_fconfig *)
661
 
662
static __inline__ cyg_bool
663
__call_if_flash_cfg_op(int op, char *key, void *data, int type)
664
{
665
    struct cyg_fconfig info;
666
    info.key = key;
667
    info.val = data;
668
    info.type = type;
669
    info.offset = 0;
670
    return CYGACC_CALL_IF_FLASH_CFG_OP2(op, &info);
671
}
672
#define CYGACC_CALL_IF_FLASH_CFG_OP(_o_,_k_,_d_,_t_) \
673
  __call_if_flash_cfg_op(_o_,_k_,_d_,_t_)
674
#define CYGACC_CALL_IF_FLASH_CFG_OP_SET(_x_) \
675
 hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_CFG_OP]=(CYG_ADDRWORD)(_x_)
676
 
677
#define CYGACC_CALL_IF_MONITOR_RETURN(_u_) \
678
 CYGACC_CALL_VV1(__call_if_monitor_return_t*, CYGNUM_CALL_IF_MONITOR_RETURN, (_u_))
679
__call_voidVV1(CYGNUM_CALL_IF_MONITOR_RETURN, __call_if_monitor_return_t, void, int)
680
#define CYGACC_CALL_IF_MONITOR_RETURN_SET(_x_) \
681
 hal_virtual_vector_table[CYGNUM_CALL_IF_MONITOR_RETURN]=(CYG_ADDRWORD)(_x_)
682
 
683
#define CYGACC_CALL_IF_FLASH_FIS_OP(_o_,_k_,_d_) \
684
 CYGACC_CALL_VV3(__call_if_flash_fis_op_fn_t*, CYGNUM_CALL_IF_FLASH_FIS_OP, (_o_),(_k_),(_d_))
685
__call_VV3(CYGNUM_CALL_IF_FLASH_FIS_OP, __call_if_flash_fis_op_fn_t, cyg_bool, int, char *, void *)
686
#define CYGACC_CALL_IF_FLASH_FIS_OP_SET(_x_) \
687
 hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_FIS_OP]=(CYG_ADDRWORD)(_x_)
688
#define CYGNUM_CALL_IF_FLASH_FIS_GET_FLASH_BASE  (0)
689
#define CYGNUM_CALL_IF_FLASH_FIS_GET_SIZE        (1)
690
#define CYGNUM_CALL_IF_FLASH_FIS_GET_MEM_BASE    (2)
691
#define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY_POINT (3)
692
#define CYGNUM_CALL_IF_FLASH_FIS_GET_DATA_LENGTH (4)
693
#define CYGNUM_CALL_IF_FLASH_FIS_GET_DESC_CKSUM  (5)
694
#define CYGNUM_CALL_IF_FLASH_FIS_GET_FILE_CKSUM  (6)
695
 
696
#define CYGACC_CALL_IF_FLASH_FIS_OP2(_o_,_k_,_d_) \
697
 CYGACC_CALL_VV3(__call_if_flash_fis_op2_fn_t*, CYGNUM_CALL_IF_FLASH_FIS_OP2, (_o_),(_k_),(_d_))
698
__call_VV3(CYGNUM_CALL_IF_FLASH_FIS_OP2, __call_if_flash_fis_op2_fn_t, int, int, unsigned int, struct fis_table_entry *)
699
#define CYGACC_CALL_IF_FLASH_FIS_OP2_SET(_x_) \
700
 hal_virtual_vector_table[CYGNUM_CALL_IF_FLASH_FIS_OP2]=(CYG_ADDRWORD)(_x_)
701
#define CYGNUM_CALL_IF_FLASH_FIS_GET_VERSION     (0)
702
#define CYGNUM_CALL_IF_FLASH_FIS_INIT            (1)
703
#define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY_COUNT (2)
704
#define CYGNUM_CALL_IF_FLASH_FIS_GET_ENTRY       (3)
705
#define CYGNUM_CALL_IF_FLASH_FIS_START_UPDATE    (4)
706
#define CYGNUM_CALL_IF_FLASH_FIS_FINISH_UPDATE   (5)
707
#define CYGNUM_CALL_IF_FLASH_FIS_MODIFY_ENTRY    (6)
708
 
709
 
710
 
711
// These need to be kept uptodate with the (unadorned) masters
712
// in RedBoot's flash_config.h:
713
#define CYGNUM_FLASH_CFG_TYPE_CONFIG_EMPTY   0
714
#define CYGNUM_FLASH_CFG_TYPE_CONFIG_BOOL    1
715
#define CYGNUM_FLASH_CFG_TYPE_CONFIG_INT     2
716
#define CYGNUM_FLASH_CFG_TYPE_CONFIG_STRING  3
717
#define CYGNUM_FLASH_CFG_TYPE_CONFIG_SCRIPT  4
718
#define CYGNUM_FLASH_CFG_TYPE_CONFIG_IP      5
719
#define CYGNUM_FLASH_CFG_TYPE_CONFIG_ESA     6
720
 
721
#endif // CYGACC_CALL_IF_DEFINED
722
 
723
//--------------------------------------------------------------------------
724
// Diag wrappers.
725
externC void hal_if_diag_init(void);
726
externC void hal_if_diag_write_char(char c);
727
externC void hal_if_diag_read_char(char *c);
728
 
729
//--------------------------------------------------------------------------
730
// Ctrl-c support.
731
externC cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data);
732
externC cyg_bool   hal_ctrlc_check(CYG_ADDRWORD vector, CYG_ADDRWORD data);
733
 
734
#define HAL_CTRLC_ISR hal_ctrlc_isr
735
#define HAL_CTRLC_CHECK hal_ctrlc_check
736
 
737
#else
738
 
739
#if defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT) \
740
    || defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)
741
// Then other code might invoke this macro
742
#define HAL_CTRLC_CHECK(a1,a2) (0) // Nothing, no CTRLC here
743
#endif
744
 
745
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
746
 
747
//--------------------------------------------------------------------------
748
// Functions provided by the HAL interface.
749
externC void hal_if_init(void);
750
#if 0 != CYGINT_HAL_PLF_IF_INIT
751
externC void plf_if_init(void);
752
#endif
753
 
754
//-----------------------------------------------------------------------------
755
#endif // CYGONCE_HAL_HAL_IF_H
756
// 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.