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