source: rtems/c/src/lib/libbsp/mips/rbtx4938/console/yamon_api.h @ efdfd48

4.104.115
Last change on this file since efdfd48 was efdfd48, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/29/09 at 15:27:07

Whitespace removal.

  • Property mode set to 100644
File size: 19.7 KB
Line 
1
2/************************************************************************
3 *
4 *  yamon_api.h
5 *
6 *  YAMON interface definitions
7 *
8 * ######################################################################
9 *
10 * mips_start_of_legal_notice
11 *
12 * Copyright (c) 2003 MIPS Technologies, Inc. All rights reserved.
13 *
14 *
15 * Unpublished rights (if any) reserved under the copyright laws of the
16 * United States of America and other countries.
17 *
18 * This code is proprietary to MIPS Technologies, Inc. ("MIPS
19 * Technologies"). Any copying, reproducing, modifying or use of this code
20 * (in whole or in part) that is not expressly permitted in writing by MIPS
21 * Technologies or an authorized third party is strictly prohibited. At a
22 * minimum, this code is protected under unfair competition and copyright
23 * laws. Violations thereof may result in criminal penalties and fines.
24 *
25 * MIPS Technologies reserves the right to change this code to improve
26 * function, design or otherwise. MIPS Technologies does not assume any
27 * liability arising out of the application or use of this code, or of any
28 * error or omission in such code. Any warranties, whether express,
29 * statutory, implied or otherwise, including but not limited to the implied
30 * warranties of merchantability or fitness for a particular purpose, are
31 * excluded. Except as expressly provided in any written license agreement
32 * from MIPS Technologies or an authorized third party, the furnishing of
33 * this code does not give recipient any license to any intellectual
34 * property rights, including any patent rights, that cover this code.
35 *
36 * This code shall not be exported or transferred for the purpose of
37 * reexporting in violation of any U.S. or non-U.S. regulation, treaty,
38 * Executive Order, law, statute, amendment or supplement thereto.
39 *
40 * This code constitutes one or more of the following: commercial computer
41 * software, commercial computer software documentation or other commercial
42 * items. If the user of this code, or any related documentation of any
43 * kind, including related technical data or manuals, is an agency,
44 * department, or other entity of the United States government
45 * ("Government"), the use, duplication, reproduction, release,
46 * modification, disclosure, or transfer of this code, or any related
47 * documentation of any kind, is restricted in accordance with Federal
48 * Acquisition Regulation 12.212 for civilian agencies and Defense Federal
49 * Acquisition Regulation Supplement 227.7202 for military agencies. The use
50 * of this code by the Government is further restricted in accordance with
51 * the terms of the license agreement(s) and/or applicable contract terms
52 * and conditions covering this code from MIPS Technologies or an authorized
53 * third party.
54 *
55 *
56 * mips_end_of_legal_notice
57 *
58 *
59 ************************************************************************/
60
61#ifndef YAMON_API_H
62#define YAMON_API_H
63
64/************************************************************************
65 *  Include files
66 ************************************************************************/
67
68
69/************************************************************************
70 *  Definitions
71*************************************************************************/
72
73/* Basic types */
74
75typedef unsigned int        t_yamon_uint32;
76typedef unsigned short      t_yamon_uint16;
77typedef unsigned char       t_yamon_uint8;
78typedef signed int          t_yamon_int32;
79typedef signed short        t_yamon_int16;
80typedef signed char         t_yamon_int8;
81
82typedef unsigned char       t_yamon_bool;
83
84#define YAMON_FALSE         0
85#define YAMON_TRUE          (!YAMON_FALSE)
86
87/* YAMON Environment variable */
88typedef struct
89{
90    char *name;
91    char *val;
92}
93t_yamon_env_var;
94
95/* Format of application function */
96typedef t_yamon_uint32
97(*t_yamon_appl_main)(
98    t_yamon_uint32  argc,      /* Number of tokens in argv array        */
99    char            **argv,    /* Array of tokens (first is "go")       */
100    t_yamon_env_var *env,      /* Array of env. variables               */
101    t_yamon_uint32  memsize ); /* Size of memory (byte count)           */
102
103
104/* ID of YAMON configuration object */
105typedef t_yamon_uint32 t_yamon_syscon_id;
106
107
108/*  Number used by the exception registration functions in order to register
109 *  a default ISR/ESR.
110 */
111#define YAMON_DEFAULT_HANDLER               0xfffffff0
112
113/*  Number used by the exception registration functions in order to register
114 *  an EJTAG debug exception ESR.
115 */
116#define YAMON_DEFAULT_EJTAG_ESR             0xfffffff1
117
118/* Registered Interrupt Service Routine (ISR) */
119typedef void (*t_yamon_isr)(void *data);
120
121/* Registered Exception Service Routine (ESR) */
122typedef void (*t_yamon_esr)(void);
123
124/* Entry point called by ESRs wishing to pass control back to YAMON */
125typedef void (*t_yamon_retfunc)(void);
126
127/* Handle used for deregistration of ISR/ESR */
128typedef void *t_yamon_ref;
129
130
131/* YAMONE Vector table address */
132#define YAMON_FUNCTION_BASE                 0x9fc00500
133
134/* YAMON Vector table offsets */
135#define YAMON_FUNC_PRINT_COUNT_OFS          0x04
136#define YAMON_FUNC_EXIT_OFS                 0x20
137#define YAMON_FUNC_FLUSH_CACHE_OFS          0x2C
138#define YAMON_FUNC_PRINT_OFS                0x34
139#define YAMON_FUNC_REGISTER_CPU_ISR_OFS     0x38
140#define YAMON_FUNC_DEREGISTER_CPU_ISR_OFS   0x3c
141#define YAMON_FUNC_REGISTER_IC_ISR_OFS      0x40
142#define YAMON_FUNC_DEREGISTER_IC_ISR_OFS    0x44
143#define YAMON_FUNC_REGISTER_ESR_OFS         0x48
144#define YAMON_FUNC_DEREGISTER_ESR_OFS       0x4c
145#define YAMON_FUNC_GETCHAR_OFS              0x50
146#define YAMON_FUNC_SYSCON_READ_OFS          0x54
147
148/* Macro for accessing YAMON function */
149#define YAMON_FUNC(ofs)\
150    (*(t_yamon_uint32 *)(YAMON_FUNCTION_BASE + (ofs)))
151
152
153/************************************************************************
154 *  Public variables
155 ************************************************************************/
156
157/************************************************************************
158 *  Public functions
159 ************************************************************************/
160
161
162/************************************************************************
163 *
164 *                          t_yamon_exit
165 *  Description :
166 *  -------------
167 *
168 *  Exit application and return to YAMON.
169 *
170 *  Parameters :
171 *  ------------
172 *
173 *  'rc' (OUT) : Return code
174 *
175 *  Return values :
176 *  ---------------
177 *
178 *  None (never returns)
179 *
180 ************************************************************************/
181typedef void
182(*t_yamon_exit)(
183    t_yamon_uint32 rc );        /* Return code                          */
184
185#define YAMON_FUNC_EXIT( rc )\
186    ((t_yamon_exit)( YAMON_FUNC(YAMON_FUNC_EXIT_OFS) ))\
187        ( rc )
188
189
190/************************************************************************
191 *
192 *                          t_yamon_print
193 *  Description :
194 *  -------------
195 *
196 *  Print null-terminated string to tty0.
197 *
198 *  Parameters :
199 *  ------------
200 *
201 *  'port' (OUT) : Ignored, always prints to tty0. Not included in macro.
202 *  's'    (OUT) : String to print.
203 *
204 *  Return values :
205 *  ---------------
206 *
207 *  None
208 *
209 ************************************************************************/
210typedef void
211(*t_yamon_print)(
212    t_yamon_uint32 port, /* Output port (not used, always tty0)         */
213    const char           *s ); /* String to output                              */
214
215#define YAMON_FUNC_PRINT( s )\
216    ((t_yamon_print)( YAMON_FUNC(YAMON_FUNC_PRINT_OFS) ))\
217        ( 0, s )
218
219
220/************************************************************************
221 *
222 *                          t_yamon_print_count
223 *  Description :
224 *  -------------
225 *
226 *  Print specified number of characters to tty0.
227 *
228 *  Parameters :
229 *  ------------
230 *
231 *  'port'  (OUT) : Ignored, always prints to tty0. Not included in macro.
232 *  's'     (OUT) : Array of characters to print.
233 *  'count' (OUT) : Number of characters to print.
234 *
235 *  Return values :
236 *  ---------------
237 *
238 *  None
239 *
240 ************************************************************************/
241typedef void
242(*t_yamon_print_count)(
243    t_yamon_uint32 port,        /* Output port (not used, always tty0   */
244    char           *s,          /* String to output                     */
245    t_yamon_uint32 count );     /* Number of characters to output       */
246
247#define YAMON_FUNC_PRINT_COUNT( s, count )\
248    ((t_yamon_print_count)( YAMON_FUNC(YAMON_FUNC_PRINT_COUNT_OFS) ))\
249        ( 0, s, count )
250
251
252/************************************************************************
253 *
254 *                          t_yamon_getchar
255 *  Description :
256 *  -------------
257 *
258 *  Get character from tty0 if character is available. Function
259 *  returns immediately if no character is available.
260 *
261 *  Parameters :
262 *  ------------
263 *
264 *  'port'  (OUT) : Ignored, always uses tty0. Not included in macro.
265 *  'ch'    (OUT) : Character read (if available).
266 *
267 *  Return values :
268 *  ---------------
269 *
270 *  YAMON_TRUE if character was available, else YAMON_FALSE.
271 *
272 ************************************************************************/
273typedef t_yamon_bool
274(*t_yamon_getchar)(
275    t_yamon_uint32 port,        /* Output port (not used, always tty0   */
276    char           *ch );       /* Character to output                  */
277
278#define YAMON_FUNC_GETCHAR( ch )\
279    ((t_yamon_getchar)( YAMON_FUNC(YAMON_FUNC_GETCHAR_OFS) ))\
280        ( 0, ch )
281
282
283/************************************************************************
284 *
285 *                          t_yamon_syscon_read
286 *  Description :
287 *  -------------
288 *
289 *  Read the value of system configuration object given by 'id'.
290 *
291 *  See syscon_api.h in YAMON source distribution for further details
292 *  on object IDs and error codes.
293 *
294 *  Parameters :
295 *  ------------
296 *
297 *  'id'    (IN)    : Object id.
298 *  'param' (INOUT) : Buffer for object value.
299 *  'size'  (IN)    : Size of buffer (must match size of object).
300 *
301 *  Return values :
302 *  ---------------
303 *
304 *  0 : Returned parameter is valid.
305 *  Other values indicate error.
306 *
307 ************************************************************************/
308typedef t_yamon_int32
309(*t_yamon_syscon_read)(
310    t_yamon_syscon_id   id,           /* Object ID                      */
311    void                *param,       /* Buffer for object value        */
312    t_yamon_uint32      size);        /* Buffer size (bytes)            */
313
314#define YAMON_FUNC_SYSCON_READ( id, param, size )\
315    ((t_yamon_syscon_read)( YAMON_FUNC(YAMON_FUNC_SYSCON_READ_OFS) ))\
316        ( id, param, size )
317
318
319/************************************************************************
320 *
321 *                          t_yamon_flush_cache
322 *  Description :
323 *  -------------
324 *
325 *  Flush I-or D-cache
326 *
327 *  Function performs "writeback and invalidate" operations on D-cache
328 *  lines and "invalidate" operations on I-cache lines.
329 *
330 *  Parameters :
331 *  ------------
332 *
333 *  'type' (IN) : Cache to be flushed.
334 *
335 *  Return values :
336 *  ---------------
337 *
338 *  None
339 *
340 ************************************************************************/
341typedef void
342(*t_yamon_flush_cache)(
343#define YAMON_FLUSH_ICACHE      0
344#define YAMON_FLUSH_DCACHE      1
345    t_yamon_uint32 type );      /* I- or D-cache indication             */
346
347#define YAMON_FUNC_FLUSH_CACHE( type )\
348    ((t_yamon_flush_cache)( YAMON_FUNC(YAMON_FUNC_FLUSH_CACHE_OFS) ))\
349        ( type )
350
351
352/************************************************************************
353 *
354 *                          t_yamon_register_esr
355 *  Description :
356 *  -------------
357 *
358 *  Registers an exception handler, also known as an "Exception Service
359 *  Routine" (ESR) for the specified exception.
360 *
361 *  Two special exception IDs are defined :
362 *      YAMON_DEFAULT_HANDLER used for a default ESR.
363 *      YAMON_DEFAULT_EJTAG_ESR used for EJTAG exceptions.
364 *
365 *  The default ESR is called if no other ESR is registered
366 *  for an exception. If no default ESR is registered, a static
367 *  (i.e. not registered) "super default" function is invoked.
368 *  This function prints out the registers and halts.
369 *
370 *  Deregistration of an ESR may be be done by calling this function
371 *  with 'esr' set to NULL.
372 *  An ESR can also be deregistered using the 'yamon_deregister_esr'
373 *  function.
374 *
375 *  An ESR may be registered even if a previously registered
376 *  ESR has not been deregistered. In this case the previously
377 *  registered ESR is lost.
378 *
379 *  The ESR will get called with registers in the state they were
380 *  when the exception occurred. This includes all CP0 registers and
381 *  CPU registers $0..$31, except for k0,k1 ($26,$27).
382 *
383 *  In case an ESR does not want to handle the exception, it may
384 *  call the return function passed in the 'retfunc' parameter.
385 *
386 *  Case 1 : 'retfunc' called by ESR registered for the
387 *           INTERRUPT exception.
388 *
389 *  We assume an application has registered this ESR and wants
390 *  YAMON to process the (remaining) interrupts.
391 *
392 *  Case 2 :  'retfunc' called by an ESR registered for a specific
393 *            exception (not INTERRUPT).
394 *
395 *  Default handling will be done.
396 *
397 *  Case 3 : 'retfunc' is called by the ESR registered as default ESR.
398 *
399 *  The exception will be handled as though no ESR is registered
400 *  (i.e. the "super default" function is called).
401 *
402 *  Parameters :
403 *  ------------
404 *
405 *  'exception' (IN)  : Exception code
406 *                      or YAMON_DEFAULT_HANDLER for a default ESR
407 *                      or YAMON_DEFAULT_EJTAG_ESR for ejtag exceptions.
408 *  'esr'       (IN)  : Function pointer for ESR.
409 *  'ref'       (OUT) : Handle used for deregistration of ESR.
410 *  'retfunc'   (OUT) : Pointer to function pointer for the return
411 *                      function described above.
412 *
413 *  Return values :
414 *  ---------------
415 *
416 *  0 : Registration went well.
417 *  Other values indicate error.
418 *
419 ************************************************************************/
420typedef t_yamon_int32
421(*t_yamon_register_esr)(
422    t_yamon_uint32  exception,       /* Exception identification        */
423    t_yamon_esr     esr,             /* ESR to be registered            */
424    t_yamon_ref     *ref,            /* Handle for deregistration       */
425    t_yamon_retfunc *retfunc );      /* Return function                 */
426
427#define YAMON_FUNC_REGISTER_ESR( exc, esr, ref, retfunc )\
428    ((t_yamon_register_esr)( YAMON_FUNC(YAMON_FUNC_REGISTER_ESR_OFS) ))\
429        ( exc, esr, ref, retfunc )
430
431
432/************************************************************************
433 *
434 *                          t_yamon_deregister_esr
435 *  Description :
436 *  -------------
437 *
438 *  Deregisters ESR..
439 *
440 *  Parameters :
441 *  ------------
442 *
443 *  'ref' (IN) : Handle obtained when calling 'yamon_register_esr'.
444 *
445 *  Return values :
446 *  ---------------
447 *
448 *  0 : Deregistration went well.
449 *  Other values indicate error.
450 *
451 ************************************************************************/
452typedef t_yamon_int32
453(*t_yamon_deregister_esr)(
454    t_yamon_ref ref );             /* Handle for deregistration         */
455
456#define YAMON_FUNC_DEREGISTER_ESR( ref )\
457    ((t_yamon_deregister_esr)( YAMON_FUNC(YAMON_FUNC_DEREGISTER_ESR_OFS) ))\
458        ( ref )
459
460
461/************************************************************************
462 *
463 *                          t_yamon_register_cpu_isr
464 *  Description :
465 *  -------------
466 *
467 *  Registers an Interrupt Service Routine (ISR) for the specified
468 *  CPU interrupt.
469 *  The highest service priority is attached to HW-INT5, which is
470 *  connected to the CPU-built-in CP0-timer. SW_INT0 gets the lowest
471 *  service priority. During registration, the interrupt mask field
472 *  in the CPU CP0-status register is updated to enable interrupts
473 *  from the specified interrupt source.
474 *
475 *  A special ID is defined :
476 *      YAMON_DEFAULT_HANDLER used for a default ISR.
477 *
478 *  The default ISR is called if no other ISR is registered
479 *  for a CPU interrupt.
480 *
481 *  Deregistration of the default ISR may be done by calling
482 *  this function with 'isr' set to NULL.
483 *  Also, a new default ISR may be registered even if a
484 *  previously registered ISR has not been deregistered.
485 *  ISRs for specific CPU interrupts must be deregistered using
486 *  'yamon_deregister_cpu_isr'.
487 *
488 *  Parameters :
489 *  ------------
490 *
491 *  'cpu_int' (IN)  : CPU interrupt (0..7)
492 *                    or YAMON_DEFAULT_HANDLER for a default ISR.
493 *  'isr'     (IN)  : Function pointer for ISR.
494 *  'data'    (IN)  : Data pointer (may be NULL). Will be passed to
495 *                    ISR when called.
496 *  'ref'     (OUT) : Handle used for deregistration of ISR.
497 *
498 *  Return values :
499 *  ---------------
500 *
501 *  0 : Registration went well.
502 *  Other values indicate error.
503 *
504 ************************************************************************/
505typedef t_yamon_int32
506(*t_yamon_register_cpu_isr)(
507    t_yamon_uint32 cpu_int,     /* CPU interrupt (0..7)                 */
508    t_yamon_isr    isr,         /* ISR to be registered                 */
509    void           *data,       /* Data reference to be registered      */
510    t_yamon_ref    *ref );      /* Handle for deregistration            */
511
512#define YAMON_FUNC_REGISTER_CPU_ISR( cpu_int, isr, data, ref )\
513    ((t_yamon_register_cpu_isr)( YAMON_FUNC(YAMON_FUNC_REGISTER_CPU_ISR_OFS) ))\
514        ( cpu_int, isr, data, ref )
515
516
517/************************************************************************
518 *
519 *                          t_yamon_deregister_cpu_isr
520 *  Description :
521 *  -------------
522 *
523 *  Deregisters ISR for CPU interrupt.
524 *
525 *  Parameters :
526 *  ------------
527 *
528 *  'ref' (IN) : Handle obtained when calling 'yamon_register_cpu_isr'.
529 *
530 *  Return values :
531 *  ---------------
532 *
533 *  0 : Deregistration went well.
534 *  Other values indicate error
535 *
536 ************************************************************************/
537typedef t_yamon_int32
538(*t_yamon_deregister_cpu_isr)(
539    t_yamon_ref ref );               /* Handle for deregistration       */
540
541#define YAMON_FUNC_DEREGISTER_CPU_ISR( ref )\
542    ((t_yamon_deregister_cpu_isr)( YAMON_FUNC(YAMON_FUNC_DEREGISTER_CPU_ISR_OFS) ))\
543        ( ref )
544
545
546/************************************************************************
547 *
548 *                          t_yamon_register_ic_isr
549 *  Description :
550 *  -------------
551 *
552 *  Registers an Interrupt Service Routine (ISR) for the specified
553 *  source in the interrupt controller.
554 *
555 *  A special ID is defined :
556 *      YAMON_DEFAULT_HANDLER used for a default ISR.
557 *
558 *  The default ISR is called if no other ISR is registered
559 *  for an interrupt.
560 *
561 *  Deregistration of the default ISR may be done by calling
562 *  this function with 'isr' set to NULL.
563 *  Also, a new default ISR may be registered even if a
564 *  previously registered ISR has not been deregistered.
565 *  ISRs for specific interrupts must be deregistered using
566 *  'yamon_deregister_ic_isr'.
567 *
568 *  Parameters :
569 *  ------------
570 *
571 *  'ic_line' (IN)  : Interrupt source line in Int. Controller
572 *                    or YAMON_DEFAULT_HANDLER for a default ISR.
573 *  'isr',    (IN)  : Function pointer for user defined ISR.
574 *  'data'    (IN)  : Data pointer (may be NULL). Will be passed to
575 *                    ISR when called.
576 *  'ref',    (OUT) : Handle used for deregistration of ISR.
577 *
578 *  Return values :
579 *  ---------------
580 *
581 *  0 : Registration went well.
582 *  Other values indicate error.
583 *
584 ************************************************************************/
585typedef t_yamon_int32
586(*t_yamon_register_ic_isr)(
587    t_yamon_uint32 ic_line,         /* Interrupt controller line        */
588    t_yamon_isr    isr,             /* ISR to be registered             */
589    void           *data,           /* Data reference to be registered  */
590    t_yamon_ref    *ref );          /* Handle for deregistration        */
591
592#define YAMON_FUNC_REGISTER_IC_ISR( ic_line, isr, data, ref )\
593    ((t_yamon_register_ic_isr)( YAMON_FUNC(YAMON_FUNC_REGISTER_IC_ISR_OFS) ))\
594        ( ic_line, isr, data, ref )
595
596
597/************************************************************************
598 *
599 *                          t_yamon_deregister_ic_isr
600 *  Description :
601 *  -------------
602 *
603 *  Deregisters ISR for source in interrupt controller.
604 *
605 *  Parameters :
606 *  ------------
607 *
608 *  'ref' (IN) : Handle obtained when calling 'yamon_register_ic_isr'.
609 *
610 *  Return values :
611 *  ---------------
612 *
613 *  0 : Deregistration went well.
614 *  Other values indicate error
615 *
616 ************************************************************************/
617typedef t_yamon_int32
618(*t_yamon_deregister_ic_isr)(
619    t_yamon_ref ref );               /* Handle for deregistration       */
620
621#define YAMON_FUNC_DEREGISTER_IC_ISR( ref )\
622    ((t_yamon_deregister_ic_isr)( YAMON_FUNC(YAMON_FUNC_DEREGISTER_IC_ISR_OFS) ))\
623        ( ref )
624
625
626#endif /* #ifndef YAMON_API_H */
627
628
629
630
631
632
Note: See TracBrowser for help on using the repository browser.