Changeset b06e68ef in rtems for c/src/lib


Ignore:
Timestamp:
08/17/95 19:51:51 (28 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
95fbca1
Parents:
3b438fa
Message:

Numerous miscellaneous features incorporated from Tony Bennett
(tbennett@…) including the following major additions:

+ variable length messages
+ named devices
+ debug monitor
+ association tables/variables

Location:
c/src/lib
Files:
26 added
17 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/include/clockdrv.h

    r3b438fa rb06e68ef  
    2424
    2525extern volatile rtems_unsigned32 Clock_driver_ticks;
     26extern rtems_device_major_number rtems_clock_major;
     27extern rtems_device_minor_number rtems_clock_minor;
    2628
    27 /* functions */
    28 
    29 rtems_task Exit_task();
    30 void exit_task_init();
    31 
    32 void Install_clock( rtems_isr_entry );
    33 void ReInstall_clock( rtems_isr_entry );
    34 void Clock_exit();
    35 
    36 rtems_isr Clock_isr(
    37   rtems_vector_number
    38 );
    39 
    40 /* driver entries */
     29/* default clock driver entry */
    4130
    4231#define CLOCK_DRIVER_TABLE_ENTRY \
    43   { Clock_initialize, NULL, NULL, NULL, NULL, NULL }
    44 
     32  { Clock_initialize, NULL, NULL, NULL, NULL, Clock_control }
     33 
    4534rtems_device_driver Clock_initialize(
    4635  rtems_device_major_number,
    4736  rtems_device_minor_number,
    48   void *,
    49   rtems_id,
    50   rtems_unsigned32 *
     37  void *
     38);
     39
     40rtems_device_driver Clock_control(
     41  rtems_device_major_number major,
     42  rtems_device_minor_number minor,
     43  void *pargp
    5144);
    5245
  • c/src/lib/libbsp/hppa1.1/simhppa/include/bsp.h

    r3b438fa rb06e68ef  
    2222
    2323#include <rtems.h>
    24 #include <iosupp.h>
     24#include <clockdrv.h>
     25#include <rtems/ttydrv.h>
     26#include <libcsupport.h>
    2527
    2628/*
     
    6668
    6769/*
     70 * Todo: this should be put somewhere else
     71 */
     72
     73#undef CLOCK_DRIVER_TABLE_ENTRY
     74#define CLOCK_DRIVER_TABLE_ENTRY { Clock_initialize, NULL, NULL, NULL, NULL, Clock_control }
     75rtems_device_driver Clock_control(
     76  rtems_device_major_number major,
     77  rtems_device_minor_number minor,
     78  void *pargp
     79);
     80
     81/*
    6882 * We printf() to a buffer if multiprocessing, *or* if this is set.
    6983 * ref: src/lib/libbsp/hppa/simhppa/iosupp/consupp.c
     
    7286extern int use_print_buffer;
    7387
     88/*
     89 * When not doing printf to a buffer, we do printf thru RTEMS libio
     90 * and our tty driver.  Set it up so that console is right.
     91 */
     92
     93#define CONSOLE_DRIVER_TABLE_ENTRY \
     94  { tty_initialize, tty_open, tty_close, tty_read, tty_write, tty_control }
     95
     96/*
     97 * How many libio files we want
     98 */
     99#define BSP_LIBIO_MAX_FDS       20
     100
    74101#define HPPA_INTERRUPT_EXTERNAL_MPCI        HPPA_INTERRUPT_EXTERNAL_10
     102
     103rtems_isr_entry set_vector(rtems_isr_entry, rtems_vector_number, int);
    75104
    76105void bsp_start( void );
  • c/src/lib/libbsp/hppa1.1/simhppa/startup/bspstart.c

    r3b438fa rb06e68ef  
    11/*
    2  *      @(#)bspstart.c  1.14 - 95/05/16
    3  *     
     2 *      @(#)bspstart.c  1.16 - 95/06/28
    43 */
    54
     
    2524 *  notice must appear in all copies of this file and its derivatives.
    2625 *
    27  *  bspstart.c,v 1.2 1995/05/09 20:17:33 joel Exp
    28  */
    29 
     26 *  $Id$
     27 */
     28
     29#include <rtems.h>
    3030#include <bsp.h>
     31#include <rtems/libio.h>
     32
    3133#include <libcsupport.h>
    3234
    3335#include <string.h>
     36#include <fcntl.h>
    3437
    3538#ifdef STACK_CHECKER_ON
     
    129132
    130133    /*
     134     * Init the RTEMS libio facility to provide UNIX-like system
     135     *  calls for use by newlib (ie: provide __open, __close, etc)
     136     *  Uses malloc() to get area for the iops, so must be after malloc init
     137     */
     138
     139    rtems_libio_init();
     140
     141    /*
    131142     * Set up for the libc handling.
     143     * XXX; this should allow for case of some other non-clock interrupts
    132144     */
    133145
     
    218230    Stack_check_Initialize();
    219231#endif
     232}
     233
     234/*
     235 * After drivers are setup, register some "filenames"
     236 * and open stdin, stdout, stderr files
     237 *
     238 * Newlib will automatically associate the files with these
     239 * (it hardcodes the numbers)
     240 */
     241
     242void
     243bsp_postdriver_hook(void)
     244{
     245    int stdin_fd, stdout_fd, stderr_fd;
     246   
     247    if ((stdin_fd = __open("/dev/tty00", O_RDONLY, 0)) == -1)
     248        rtems_fatal_error_occurred('STD0');
     249
     250    if ((stdout_fd = __open("/dev/tty00", O_WRONLY, 0)) == -1)
     251        rtems_fatal_error_occurred('STD1');
     252
     253    if ((stderr_fd = __open("/dev/tty00", O_WRONLY, 0)) == -1)
     254        rtems_fatal_error_occurred('STD2');
     255
     256    if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
     257        rtems_fatal_error_occurred('STIO');
    220258}
    221259
     
    290328    Cpu_table.predriver_hook = NULL;
    291329
    292     Cpu_table.postdriver_hook = NULL;
     330    Cpu_table.postdriver_hook = bsp_postdriver_hook;    /* register drivers */
    293331
    294332    Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
     
    343381
    344382#ifdef STACK_CHECKER_ON
    345   /*
    346    * Add 1 extension for stack checker
    347    */
     383    /*
     384     * Add 1 extension for stack checker
     385     */
    348386
    349387    BSP_Configuration.maximum_extensions++;
     
    351389
    352390#if SIMHPPA_FAST_IDLE
    353   /*
    354    * Add 1 extension for fast idle
    355    */
     391    /*
     392     * Add 1 extension for fast idle
     393     */
    356394
    357395    BSP_Configuration.maximum_extensions++;
    358396#endif
     397
     398    /*
     399     * Tell libio how many fd's we want and allow it to tweak config
     400     */
     401
     402    rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
    359403
    360404    /*
  • c/src/lib/libbsp/shmdr/poll.c

    r3b438fa rb06e68ef  
    1717 *  notice must appear in all copies of this file and its derivatives.
    1818 *
    19  *  poll.c,v 1.2 1995/05/09 20:22:57 joel Exp
     19 *  $Id$
    2020 */
    2121
    2222#include <rtems.h>
    2323#include <rtems/sysstate.h>
     24#include <rtems/libio.h>
     25
    2426#include "shm.h"
    25 #include "clockdrv.h"
    2627
    2728void Shm_Poll()
    2829{
    2930  rtems_unsigned32 tmpfront;
     31  rtems_libio_ioctl_args_t args;
    3032
    31   Clock_isr( 0 );             /* invoke standard clock ISR */
    32 
     33  /* invoke clock isr */
     34  args.iop = 0;
     35  args.command = rtems_build_name('I', 'S', 'R', ' ');
     36  (void) rtems_io_control(rtems_clock_major, rtems_clock_minor, &args);
    3337
    3438  /*
     
    4044  if (_System_state_Is_up(_System_state_Get()))
    4145  {
    42       /* enable_tracing(); */
    43       /* ticks += 1; */
    44       Shm_Lock( Shm_Local_receive_queue );
    4546      tmpfront = Shm_Local_receive_queue->front;
    46       Shm_Unlock( Shm_Local_receive_queue );
    47       if ( Shm_Convert(tmpfront) != Shm_Locked_queue_End_of_list ) {
    48         rtems_multiprocessing_announce();
    49         Shm_Interrupt_count++;
     47      if ( Shm_Convert(tmpfront) != Shm_Locked_queue_End_of_list )
     48      {
     49          rtems_multiprocessing_announce();
     50          Shm_Interrupt_count++;
    5051      }
    5152  }
  • c/src/lib/libbsp/shmdr/setckvec.c

    r3b438fa rb06e68ef  
    2020
    2121#include <rtems.h>
     22#include <rtems/libio.h>
     23
    2224#include "shm.h"
    23 #include "clockdrv.h"
    2425
    2526rtems_isr Shm_setclockvec()
    2627{
    27   ReInstall_clock( Shm_Poll );
     28    rtems_libio_ioctl_args_t args;
     29    args.iop = 0;
     30    args.command = rtems_build_name('N', 'E', 'W', ' ');
     31    args.buffer = (void *) Shm_Poll;
     32
     33    (void) rtems_io_control(rtems_clock_major, rtems_clock_minor, &args);
    2834}
  • c/src/lib/libbsp/shmdr/shm.h

    r3b438fa rb06e68ef  
    2020#ifndef __SHM_h
    2121#define __SHM_h
     22
     23#include <clockdrv.h>
    2224
    2325#ifdef __cplusplus
     
    519521rtems_mpci_table MPCI_table  = {
    520522  100000,                     /* default timeout value in ticks */
     523  MAX_PACKET_SIZE,            /* maximum packet size */
    521524  Shm_Initialization,         /* initialization procedure   */
    522525  Shm_Get_packet,             /* get packet procedure       */
  • c/src/lib/libbsp/shmdr/shm_driver.h

    r3b438fa rb06e68ef  
    2020#ifndef __SHM_h
    2121#define __SHM_h
     22
     23#include <clockdrv.h>
    2224
    2325#ifdef __cplusplus
     
    519521rtems_mpci_table MPCI_table  = {
    520522  100000,                     /* default timeout value in ticks */
     523  MAX_PACKET_SIZE,            /* maximum packet size */
    521524  Shm_Initialization,         /* initialization procedure   */
    522525  Shm_Get_packet,             /* get packet procedure       */
  • c/src/lib/libbsp/unix/posix/clock/clock.c

    r3b438fa rb06e68ef  
    11/*  Clock
    22 *
    3  *  This routine initializes the interval timer on the
    4  *  PA-RISC CPU.  The tick frequency is specified by the bsp.
     3 *  This routine generates clock ticks using standard POSIX services.
     4 *  The tick frequency is specified by the bsp.
    55 *
    66 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
     
    1616
    1717#include <rtems.h>
     18#include <rtems/libio.h>
     19#include <bsp.h>
    1820
     21/*
     22 *  In order to get the types and prototypes used in this file under
     23 *  Solaris 2.3, it is necessary to pull the following magic.
     24 */
     25 
     26#if defined(solaris)
     27#warning "Ignore the undefining __STDC__ warning"
     28#undef __STDC__
     29#define __STDC__ 0
     30#undef  _POSIX_C_SOURCE
     31#endif
     32 
    1933#include <stdlib.h>
    2034#include <stdio.h>
    2135#include <signal.h>
    2236#include <time.h>
    23 #include <sys/time.h>
    2437
    2538extern rtems_configuration_table Configuration;
    26 extern sigset_t                  UNIX_SIGNAL_MASK;
    2739
    28 /*
    29  * Function prototypes
    30  */
    31 
    32 void Install_clock();
    33 void Clock_isr();
    34 void Clock_exit();
    35 
    36 /*
    37  * CPU_HPPA_CLICKS_PER_TICK is either a #define or an rtems_unsigned32
    38  *   allocated and set by bsp_start()
    39  */
    40 
    41 #ifndef CPU_HPPA_CLICKS_PER_TICK
    42 extern rtems_unsigned32 CPU_HPPA_CLICKS_PER_TICK;
    43 #endif
     40void Clock_exit(void);
    4441
    4542volatile rtems_unsigned32 Clock_driver_ticks;
    4643
    47 struct itimerval  new;
     44/*
     45 * These are set by clock driver during its init
     46 */
    4847
    49 rtems_device_driver
    50 Clock_initialize(
    51   rtems_device_major_number major,
    52   rtems_device_minor_number minor,
    53   void *pargp,
    54   rtems_id tid,
    55   rtems_unsigned32 *rval
    56 )
    57 {
    58     Install_clock(Clock_isr);
    59 }
    60 
    61 void
    62 ReInstall_clock(rtems_isr_entry new_clock_isr)
    63 {
    64     rtems_unsigned32  isrlevel = 0;
    65 
    66     rtems_interrupt_disable(isrlevel);
    67     (void)set_vector(new_clock_isr, SIGALRM, 1);
    68     rtems_interrupt_enable(isrlevel);
    69 }
     48rtems_device_major_number rtems_clock_major = ~0;
     49rtems_device_minor_number rtems_clock_minor;
    7050
    7151void
    7252Install_clock(rtems_isr_entry clock_isr)
    7353{
     54    struct itimerval  new;
     55
    7456    Clock_driver_ticks = 0;
    7557
     
    8769
    8870void
     71ReInstall_clock(rtems_isr_entry new_clock_isr)
     72{
     73    rtems_unsigned32  isrlevel = 0;
     74
     75    rtems_interrupt_disable(isrlevel);
     76    (void)set_vector(new_clock_isr, SIGALRM, 1);
     77    rtems_interrupt_enable(isrlevel);
     78}
     79
     80void
    8981Clock_isr(int vector)
    9082{
    9183    Clock_driver_ticks++;
    92 
    9384    rtems_clock_tick();
    9485}
     
    10293Clock_exit(void)
    10394{
     95    struct itimerval  new;
    10496     struct sigaction  act;
    10597
     
    122114    (void)set_vector(0, SIGALRM, 1);
    123115}
     116
     117rtems_device_driver
     118Clock_initialize(
     119  rtems_device_major_number major,
     120  rtems_device_minor_number minor,
     121  void *pargp
     122)
     123{
     124    Install_clock((rtems_isr_entry) Clock_isr);
     125
     126    /*
     127     * make major/minor avail to others such as shared memory driver
     128     */
     129    rtems_clock_major = major;
     130    rtems_clock_minor = minor;
     131
     132    return RTEMS_SUCCESSFUL;
     133}
     134
     135rtems_device_driver Clock_control(
     136  rtems_device_major_number major,
     137  rtems_device_minor_number minor,
     138  void *pargp
     139)
     140{
     141    rtems_libio_ioctl_args_t *args = pargp;
     142
     143    if (args == 0)
     144        goto done;
     145
     146    /*
     147     * This is hokey, but until we get a defined interface
     148     * to do this, it will just be this simple...
     149     */
     150
     151    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     152    {
     153        Clock_isr(SIGALRM);
     154    }
     155    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     156    {
     157        ReInstall_clock(args->buffer);
     158    }
     159   
     160done:
     161    return RTEMS_SUCCESSFUL;
     162}
  • c/src/lib/libbsp/unix/posix/console/console.c

    r3b438fa rb06e68ef  
    2929console_initialize(rtems_device_major_number major,
    3030                   rtems_device_minor_number minor,
    31                    void                    * arg,
    32                    rtems_id                  self,
    33                    rtems_unsigned32        * status)
     31                   void                    * arg
     32)
    3433{
    35     *status = RTEMS_SUCCESSFUL;
     34    return RTEMS_SUCCESSFUL;
    3635}
    3736
  • c/src/lib/libbsp/unix/posix/include/bsp.h

    r3b438fa rb06e68ef  
    7979 
    8080/* #define INTERRUPT_EXTERNAL_MPCI        SIGUSR1 */
     81
     82/*
     83 * Console driver init
     84 */
     85 
     86rtems_device_driver console_initialize(
     87  rtems_device_major_number, rtems_device_minor_number minor, void *);
     88 
     89#define CONSOLE_DRIVER_TABLE_ENTRY \
     90  { console_initialize, NULL, NULL, NULL, NULL, NULL }
     91 
     92/*
     93 * NOTE: Use the standard Clock driver entry
     94 */
    8195 
    8296/* functions */
  • c/src/lib/libc/syscalls.c

    r3b438fa rb06e68ef  
    3636}
    3737
    38 int
    39 __close(int _fd)
    40 {
    41   /* return value usually ignored anyhow */
    42   return 0;
    43 }
    44 
    45 int
    46 __open(const char *filename)
    47 {
    48   /* always fail */
    49   return -1;
    50 }
    51 
    52 int
    53 __lseek(int _fd, off_t offset, int whence)
    54 {
    55   /* nothing is ever seekable */
    56   return -1;
    57 }
    58 
    5938int stat( const char *path, struct stat *buf )
    6039{
  • c/src/lib/libcpu/hppa1.1/clock/clock.c

    r3b438fa rb06e68ef  
    1515 */
    1616
     17#include <rtems.h>
    1718#include <bsp.h>
    18 #include <clockdrv.h>
     19#include <rtems/libio.h>
    1920
    2021#include <stdlib.h>                     /* for atexit() */
     
    2324
    2425typedef unsigned long long hppa_click_count_t;
     26
     27/*
     28 * These are set by clock driver during its init
     29 */
     30
     31rtems_device_major_number rtems_clock_major = ~0;
     32rtems_device_minor_number rtems_clock_minor;
    2533
    2634/*
     
    4250rtems_unsigned32   Clock_clicks_interrupt;
    4351
    44 rtems_device_driver Clock_initialize(
    45   rtems_device_major_number major,
    46   rtems_device_minor_number minor,
    47   void *pargp,
    48   rtems_id tid,
    49   rtems_unsigned32 *rval
    50 )
    51 {
    52     Install_clock(Clock_isr);
    53 }
     52void  Clock_exit(void);
    5453
    5554void
     
    219218}
    220219
     220rtems_device_driver Clock_initialize(
     221  rtems_device_major_number major,
     222  rtems_device_minor_number minor,
     223  void *pargp
     224)
     225{
     226    Install_clock(Clock_isr);
     227
     228    /*
     229     * make major/minor avail to others such as shared memory driver
     230     */
     231    rtems_clock_major = major;
     232    rtems_clock_minor = minor;
     233
     234    return RTEMS_SUCCESSFUL;
     235}
     236
     237rtems_device_driver Clock_control(
     238  rtems_device_major_number major,
     239  rtems_device_minor_number minor,
     240  void *pargp
     241)
     242{
     243    rtems_libio_ioctl_args_t *args = pargp;
     244
     245    if (args == 0)
     246        goto done;
     247
     248    /*
     249     * This is hokey, but until we get a defined interface
     250     * to do this, it will just be this simple...
     251     */
     252
     253    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     254    {
     255        Clock_isr(HPPA_INTERRUPT_EXTERNAL_INTERVAL_TIMER);
     256    }
     257    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     258    {
     259        ReInstall_clock(args->buffer);
     260    }
     261   
     262done:
     263    return RTEMS_SUCCESSFUL;
     264}
  • c/src/lib/libmisc/monitor/README

    r3b438fa rb06e68ef  
    33#
    44
    5 This is a snapshot of a work in process.  It is the beginnings of a
    6 debug monitor task and trap handler which is tasking aware.
     5monitor task
    76
     7The monitor task is an optional task that knows about RTEMS
     8data structures and can print out information about them.
     9It is a work-in-progress and needs many more commands, but
     10is useful now.
     11
     12The monitor works best when it is the highest priority task,
     13so all your other tasks should ideally be at some priority
     14greater than 1.
     15
     16To use the monitor:
     17-------------------
     18
     19    #include <rtems/monitor.h>
     20
     21        ...
     22
     23    rtems_monitor_init(0);
     24
     25    The parameter to rtems_monitor_init() tells the monitor whether
     26    to suspend itself on startup.  A value of 0 causes the monitor
     27    to immediately enter command mode; a non-zero value causes the
     28    monitor to suspend itself after creation and wait for explicit
     29    wakeup.
     30
     31
     32    rtems_monitor_wakeup();
     33   
     34    wakes up a suspended monitor and causes it to reenter command mode.
     35
     36Monitor commands
     37----------------
     38
     39    The monitor prompt is 'rtems> '.
     40    Can abbreviate commands to "uniquity"
     41    There is a 'help' command.  Here is the output from various
     42    help commands:
     43
     44        Commands (may be abbreviated)
     45
     46          help      -- get this message or command specific help
     47          task      -- show task information
     48          queue     -- show message queue information
     49          symbol    -- show entries from symbol table
     50          pause     -- pause monitor for a specified number of ticks
     51          fatal     -- invoke a fatal RTEMS error
     52
     53        task [id [id ...] ]
     54          display information about the specified tasks.
     55          Default is to display information about all tasks on this node
     56
     57        queue [id [id ... ] ]
     58          display information about the specified message queues
     59          Default is to display information about all queues on this node
     60
     61        symbol [ symbolname [symbolname ... ] ]
     62          display value associated with specified symbol.
     63          Defaults to displaying all known symbols.
     64
     65        pause [ticks]
     66          monitor goes to "sleep" for specified ticks (default is 1)
     67          monitor will resume at end of period or if explicitly awakened
     68
     69        fatal [status]
     70          Invoke 'rtems_fatal_error_occurred' with 'status'
     71          (default is RTEMS_INTERNAL_ERROR)
     72
     73        continue
     74          put the monitor to sleep waiting for an explicit wakeup from the
     75          program running.
     76
     77
     78Sample output from 'task' command
     79---------------------------------
     80
     81    rtems> task
     82      ID       NAME   PRIO   STAT   MODES  EVENTS   WAITID  WAITARG  NOTES
     83    ------------------------------------------------------------------------
     84    00010001   UI1     2    READY    P:T:nA    NONE15: 0x40606348
     85    00010002   RMON    1    READY    nP    NONE15: 0x40604110
     86
     87    'RMON' is the monitor itself, so we have 1 "user" task.
     88    Its modes are P:T:nA which translate to:
     89
     90        preemptable
     91        timesliced
     92        no ASRS
     93
     94    It has no events.
     95    It has a notepad value for notepad 15 which is 0x40606348
     96    (this is the libc thread state)
     97
  • c/src/lib/libmisc/monitor/mon-monitor.c

    r3b438fa rb06e68ef  
    11/*
    2  *      @(#)monitor.c   1.6 - 95/04/24
     2 *      @(#)monitor.c   1.18 - 95/08/02
    33 *     
    4  */
    5 
    6 /*
    7  *  mon-task.c
    8  *
    9  *  Description:
    10  *      RTEMS monitor task
    11  *     
    12  *     
     4 *
     5 * RTEMS monitor main body
    136 *     
    147 *  TODO:
    15  *      add pause command (monitor sleeps for 'n' ticks, then wakes up)
    16  *     
     8 *      add stuff to RTEMS api
     9 *            rtems_get_name(id)
     10 *            rtems_get_type(id)
     11 *            rtems_build_id(node, type, num)
     12 *      Add a command to dump out info about an arbitrary id when
     13 *         types are added to id's
     14 *         rtems> id idnum
     15 *                idnum: node n, object: whatever, id: whatever
     16 *      allow id's to be specified as n:t:id, where 'n:t' is optional
     17 *      should have a separate monitor FILE stream (ala the debugger)
     18 *      remote request/response stuff should be cleaned up
     19 *         maybe we can use real rpc??
     20 *
     21 *  $Id$
    1722 */
    1823
    1924#include <rtems.h>
    20 /* #include <bsp.h> */
    21 
    22 #include "symbols.h"
    23 #include "monitor.h"
    2425
    2526#include <stdio.h>
     
    2829#include <unistd.h>
    2930
    30 #define STREQ(a,b)      (strcmp(a,b) == 0)
     31#include "monitor.h"
    3132
    3233/* set by trap handler */
     
    3536extern rtems_unsigned32 debugger_trap;
    3637
    37 /* our task id needs to be public so any debugger can resume us */
    38 rtems_unsigned32        rtems_monitor_task_id;
    39 
     38/*
     39 * Various id's for the monitor
     40 * They need to be public variables for access by other agencies
     41 * such as debugger and remote servers'
     42 */
     43
     44rtems_id  rtems_monitor_task_id;
     45
     46unsigned32 rtems_monitor_node;          /* our node number */
     47unsigned32 rtems_monitor_default_node;  /* current default for commands */
     48
     49/*
     50 * The rtems symbol table
     51 */
    4052
    4153rtems_symbol_table_t *rtems_monitor_symbols;
    4254
    43 
    44 #ifndef MONITOR_PROMPT
    45 #define MONITOR_PROMPT "rtems> "
     55/*
     56 * The top-level commands
     57 */
     58
     59rtems_monitor_command_entry_t rtems_monitor_commands[] = {
     60    { "--usage--",
     61      "\n"
     62      "RTEMS monitor\n"
     63      "\n"
     64      "Commands (may be abbreviated)\n"
     65      "\n"
     66      "  help      -- get this message or command specific help\n"
     67      "  pause     -- pause monitor for a specified number of ticks\n"
     68      "  exit      -- invoke a fatal RTEMS error\n"
     69      "  symbol    -- show entries from symbol table\n"
     70      "  continue  -- put monitor to sleep waiting for explicit wakeup\n"
     71      "  config    -- show system configuration\n"
     72      "  itask     -- list init tasks\n"
     73      "  mpci      -- list mpci config\n"
     74      "  task      -- show task information\n"
     75      "  queue     -- show message queue information\n"
     76      "  extension -- user extensions\n"
     77      "  driver    -- show information about named drivers\n"
     78      "  object    -- generic object information\n"
     79      "  node      -- specify default node for commands that take id's\n"
     80#ifdef CPU_INVOKE_DEBUGGER
     81      "  debugger  -- invoke system debugger\n"
    4682#endif
    47 
    48 #define MONITOR_WAKEUP_EVENT   RTEMS_EVENT_0
    49 
    50 /*
    51  *  Function:   rtems_monitor_init
    52  *
    53  *  Description:
    54  *      Create the RTEMS monitor task
    55  *     
    56  *  Parameters:
    57  *      'monitor_suspend' arg is passed as initial arg to monitor task
    58  *      If TRUE, monitor will suspend itself as it starts up.  Otherwise
    59  *      it will begin its command loop.
    60  *     
    61  *  Returns:
    62  *     
    63  *     
    64  *  Side Effects:
    65  *     
    66  *     
    67  *  Notes:
    68  *     
    69  *     
    70  *  Deficiencies/ToDo:
    71  *     
    72  *     
    73  */
    74 
    75 /*
    76  * make_argv(cp): token-count
    77  *      Break up the command line in 'cp' into global argv[] and argc (return
    78  *      value).
    79  */
    80 
    81 int
    82 rtems_monitor_make_argv(
    83     char *cp,
    84     int  *argc_p,
    85     char **argv)
    86 {
    87     int argc = 0;
    88 
    89     while ((cp = strtok(cp, " \t\n\r")))
    90     {
    91         argv[argc++] = cp;
    92         cp = (char *) NULL;
    93     }
    94     argv[argc] = (char *) NULL;                 /* end of argv */
    95 
    96     return *argc_p = argc;
    97 }
    98 
    99 void
    100 rtems_monitor_init(rtems_boolean monitor_suspend)
    101 {
    102     rtems_status_code status;
    103    
    104     status = rtems_task_create(rtems_build_name('R', 'M', 'O', 'N'),
    105                                1, 0/*stack*/, RTEMS_NO_PREEMPT | RTEMS_INTERRUPT_LEVEL(0), RTEMS_DEFAULT_ATTRIBUTES, &rtems_monitor_task_id);
    106     if (status != RTEMS_SUCCESSFUL)
    107     {
    108         printf("could not create monitor task\n");
    109         goto done;
    110     }
    111 
    112     rtems_monitor_symbols_loadup();
    113 
    114     status = rtems_task_start(rtems_monitor_task_id, rtems_monitor_task, monitor_suspend);
    115     if (status != RTEMS_SUCCESSFUL)
    116     {
    117         printf("could not start monitor!\n");
    118         goto done;
    119     }
    120 
    121 done:
    122 }
     83      ,
     84      0,
     85      0,
     86      (unsigned32) rtems_monitor_commands,
     87    },
     88    { "config",
     89      "config\n"
     90      "  Show the system configuration.\n",
     91      0,
     92      rtems_monitor_object_cmd,
     93      RTEMS_OBJECT_CONFIG,
     94    },
     95    { "itask",
     96      "itask\n"
     97      "  List init tasks for the system\n",
     98      0,
     99      rtems_monitor_object_cmd,
     100      RTEMS_OBJECT_INIT_TASK,
     101    },
     102   { "mpci",
     103      "mpci\n"
     104      "  Show the MPCI system configuration, if configured.\n",
     105      0,
     106      rtems_monitor_object_cmd,
     107      RTEMS_OBJECT_MPCI,
     108    },
     109    { "pause",
     110      "pause [ticks]\n"
     111      "  monitor goes to \"sleep\" for specified ticks (default is 1)\n"
     112      "  monitor will resume at end of period or if explicitly awakened\n",
     113      0,
     114      rtems_monitor_pause_cmd,
     115      0,
     116    },
     117    { "continue",
     118      "continue\n"
     119      "  put the monitor to sleep waiting for an explicit wakeup from the\n"
     120      "  program running.\n",
     121      0,
     122      rtems_monitor_continue_cmd,
     123      0,
     124    },
     125    { "go",
     126      "go\n"
     127      "  Alias for 'continue'\n",
     128      0,
     129      rtems_monitor_continue_cmd,
     130      0,
     131    },
     132    { "node",
     133      "node [ node number ]\n"
     134      "  Specify default node number for commands that take id's\n",
     135      0,
     136      rtems_monitor_node_cmd,
     137      0,
     138    },
     139    { "symbol",
     140      "symbol [ symbolname [symbolname ... ] ]\n"
     141      "  display value associated with specified symbol.\n"
     142      "  Defaults to displaying all known symbols.\n",
     143      0,
     144      rtems_monitor_symbol_cmd,
     145      (unsigned32) &rtems_monitor_symbols,
     146    },
     147    { "extension",
     148      "extension [id [id ...] ]\n"
     149      "  display information about specified extensions.\n"
     150      "  Default is to display information about all extensions on this node\n",
     151      0,
     152      rtems_monitor_object_cmd,
     153      RTEMS_OBJECT_EXTENSION,
     154    },
     155    { "task",
     156      "task [id [id ...] ]\n"
     157      "  display information about the specified tasks.\n"
     158      "  Default is to display information about all tasks on this node\n",
     159      0,
     160      rtems_monitor_object_cmd,
     161      RTEMS_OBJECT_TASK,
     162    },
     163    { "queue",
     164      "queue [id [id ... ] ]\n"
     165      "  display information about the specified message queues\n"
     166      "  Default is to display information about all queues on this node\n",
     167      0,
     168      rtems_monitor_object_cmd,
     169      RTEMS_OBJECT_QUEUE,
     170    },
     171    { "object",
     172      "object [id [id ...] ]\n"
     173      "  display information about specified RTEMS objects.\n"
     174      "  Object id's must include 'type' information.\n"
     175      "  (which may normally be defaulted)\n",
     176      0,
     177      rtems_monitor_object_cmd,
     178      RTEMS_OBJECT_INVALID,
     179    },
     180    { "driver",
     181      "driver [ major [ major ... ] ]\n"
     182      "  Display the RTEMS device driver table.\n",
     183      0,
     184      rtems_monitor_object_cmd,
     185      RTEMS_OBJECT_DRIVER,
     186    },
     187    { "dname",
     188      "dname\n"
     189      "  Displays information about named drivers.\n",
     190      0,
     191      rtems_monitor_object_cmd,
     192      RTEMS_OBJECT_DNAME,
     193    },
     194    { "exit",
     195      "exit [status]\n"
     196      "  Invoke 'rtems_fatal_error_occurred' with 'status'\n"
     197      "  (default is RTEMS_SUCCESSFUL)\n",
     198      0,
     199      rtems_monitor_fatal_cmd,
     200      RTEMS_SUCCESSFUL,
     201    },
     202    { "fatal",
     203      "fatal [status]\n"
     204      "  'exit' with fatal error; default error is RTEMS_TASK_EXITTED\n",
     205      0,
     206      rtems_monitor_fatal_cmd,
     207      RTEMS_TASK_EXITTED,                       /* exit value */
     208    },
     209    { "quit",
     210      "quit [status]\n"
     211      "  Alias for 'exit'\n",
     212      0,
     213      rtems_monitor_fatal_cmd,
     214      RTEMS_SUCCESSFUL,                         /* exit value */
     215    },
     216    { "help",
     217      "help [ command [ command ] ]\n"
     218      "  provide information about commands\n"
     219      "  Default is show basic command summary.\n",
     220      0,
     221      rtems_monitor_help_cmd,
     222      (unsigned32) rtems_monitor_commands,
     223    },
     224#ifdef CPU_INVOKE_DEBUGGER
     225    { "debugger",
     226      "debugger\n"
     227      "  Enter the debugger, if possible.\n"
     228      "  A continue from the debugger will return to the monitor.\n",
     229      0,
     230      CPU_INVOKE_DEBUGGER,
     231      0,
     232    },
     233#endif           
     234    { 0, 0, 0, 0, 0 },
     235};
     236
    123237
    124238rtems_status_code
     
    128242    rtems_status_code status;
    129243   
    130     status = rtems_event_receive(MONITOR_WAKEUP_EVENT, RTEMS_DEFAULT_OPTIONS, timeout, &event_set);
     244    status = rtems_event_receive(MONITOR_WAKEUP_EVENT,
     245                                 RTEMS_DEFAULT_OPTIONS,
     246                                 timeout,
     247                                 &event_set);
    131248    return status;
    132249}
     
    141258
    142259
    143 /*
    144  * Read and break up a monitor command
    145  *
    146  * We have to loop on the gets call, since it will return NULL under UNIX
    147  *  RTEMS when we get a signal (eg: SIGALRM).
    148  */
    149 
    150 int
    151 rtems_monitor_read_command(char *command,
    152                            int  *argc,
    153                            char **argv)
    154 {
    155     printf("%s", MONITOR_PROMPT);  fflush(stdout);
    156     while (gets(command) == (char *) 0)
    157         ;
    158     return rtems_monitor_make_argv(command, argc, argv);
    159 }
    160 
    161 void
    162 rtems_monitor_task(rtems_task_argument monitor_suspend)
    163 {
    164     rtems_tcb *debugee = 0;
    165     char command[513];
    166     rtems_context *rp;
    167     rtems_context_fp *fp;
    168     char *cp;
    169     int argc;
    170     char *argv[64];       
    171 
    172     if ((rtems_boolean) monitor_suspend)
    173         (void) rtems_monitor_suspend(RTEMS_NO_TIMEOUT);
    174 
    175     for (;;)
     260void
     261rtems_monitor_pause_cmd(
     262    int        argc,
     263    char     **argv,
     264    unsigned32 command_arg,
     265    boolean    verbose
     266)
     267{
     268    if (argc == 1)
     269        rtems_monitor_suspend(1);
     270    else
     271        rtems_monitor_suspend(strtoul(argv[1], 0, 0));
     272}
     273
     274void
     275rtems_monitor_fatal_cmd(
     276    int     argc,
     277    char  **argv,
     278    unsigned32 command_arg,
     279    boolean verbose
     280)
     281{
     282    if (argc == 1)
     283        rtems_fatal_error_occurred(command_arg);
     284    else
     285        rtems_fatal_error_occurred(strtoul(argv[1], 0, 0));
     286}
     287
     288void
     289rtems_monitor_continue_cmd(
     290    int     argc,
     291    char  **argv,
     292    unsigned32 command_arg,
     293    boolean verbose
     294)
     295{
     296    rtems_monitor_suspend(RTEMS_NO_TIMEOUT);
     297}
     298
     299
     300void
     301rtems_monitor_node_cmd(
     302    int     argc,
     303    char  **argv,
     304    unsigned32 command_arg,
     305    boolean verbose
     306)
     307{
     308    unsigned32 new_node = rtems_monitor_default_node;
     309   
     310    switch (argc)
    176311    {
    177         extern rtems_tcb * _Thread_Executing;
    178         debugee = _Thread_Executing;
    179         rp = &debugee->Registers;
    180         fp = (rtems_context_fp *) debugee->fp_context;  /* possibly 0 */
    181 
    182         if (0 == rtems_monitor_read_command(command, &argc, argv))
    183             continue;
    184        
    185         if (STREQ(argv[0], "quit"))
    186             rtems_monitor_suspend(RTEMS_NO_TIMEOUT);
    187         else if (STREQ(argv[0], "pause"))
    188             rtems_monitor_suspend(1);
    189 
    190 #ifdef CPU_INVOKE_DEBUGGER
    191         else if (STREQ(argv[0], "debug"))
    192         {
    193             CPU_INVOKE_DEBUGGER;
    194         }
    195 #endif           
    196         else if (STREQ(argv[0], "symbol"))
    197         {
    198             char *symbol;
    199             char *value;
    200 
    201             if (argc != 3)
    202             {
    203                 printf("usage: symbol symname symvalue\n");
    204                 continue;
    205             }
    206 
    207             symbol = argv[1];
    208             value = argv[2];
    209             if (symbol && value)
    210             {
    211                 rtems_symbol_t *sp;
    212                 sp = rtems_symbol_create(rtems_monitor_symbols,
    213                                          symbol,
    214                                          (rtems_unsigned32) strtoul(value, 0, 16));
    215                 if (sp)
    216                     printf("symbol defined is at %p\n", sp);
    217                 else
    218                     printf("could not define symbol\n");
    219             }
    220             else
    221                 printf("parsing error\n");
    222         }
    223         else
    224         {
    225             printf("Unrecognized command: '%s'\n", argv[0]);
    226         }
     312        case 1:                 /* no node, just set back to ours */
     313            new_node = rtems_monitor_node;
     314            break;
     315
     316        case 2:
     317            new_node = strtoul(argv[1], 0, 0);
     318            break;
     319
     320        default:
     321            printf("invalid syntax, try 'help node'\n");
     322            break;
    227323    }
    228 }
     324
     325    if ((new_node >= 1) && (new_node <= _Configuration_MP_table->maximum_nodes))
     326        rtems_monitor_default_node = new_node;
     327}
     328
    229329
    230330/*
     
    267367    char buffer[128];
    268368
     369    if (rtems_monitor_symbols)
     370        rtems_symbol_table_destroy(rtems_monitor_symbols);
     371   
    269372    rtems_monitor_symbols = rtems_symbol_table_create(10);
    270373    if (rtems_monitor_symbols == 0)
    271374        return;
    272375
    273     fp = fdopen(8, "r");
     376#ifdef simhppa
     377    fp = fdopen(8, "r");                /* don't ask; don't tell */
     378#else
     379    fp = fopen("symbols", "r");
     380#endif
     381   
    274382    if (fp == 0)
    275383        return;
     
    293401            if (sp == 0)
    294402            {
    295                 printf("could not define symbol\n");
     403                printf("could not define symbol '%s'\n", symbol);
    296404                goto done;
    297405            }
     
    299407        else
    300408        {
    301             printf("parsing error\n");
     409            printf("parsing error on '%s'\n", buffer);
    302410            goto done;
    303411        }
     
    306414done:
    307415}
     416
     417
     418/*
     419 * Main monitor command loop
     420 */
     421
     422void
     423rtems_monitor_task(
     424    rtems_task_argument monitor_flags
     425)
     426{
     427    rtems_tcb *debugee = 0;
     428    rtems_context *rp;
     429    rtems_context_fp *fp;
     430    char command_buffer[513];
     431    int argc;
     432    char *argv[64];       
     433    boolean verbose = FALSE;
     434
     435    if (monitor_flags & RTEMS_MONITOR_SUSPEND)
     436        (void) rtems_monitor_suspend(RTEMS_NO_TIMEOUT);
     437
     438    for (;;)
     439    {
     440        extern rtems_tcb * _Thread_Executing;
     441        rtems_monitor_command_entry_t *command;
     442
     443        debugee = _Thread_Executing;
     444        rp = &debugee->Registers;
     445        fp = (rtems_context_fp *) debugee->fp_context;  /* possibly 0 */
     446
     447        if (0 == rtems_monitor_command_read(command_buffer, &argc, argv))
     448            continue;
     449        if ((command = rtems_monitor_command_lookup(rtems_monitor_commands,
     450                                                    argc,
     451                                                    argv)) == 0)
     452            continue;
     453
     454        command->command_function(argc, argv, command->command_arg, verbose);
     455
     456        fflush(stdout);
     457    }
     458}
     459
     460
     461void
     462rtems_monitor_kill(void)
     463{
     464    if (rtems_monitor_task_id)
     465        rtems_task_delete(rtems_monitor_task_id);
     466    rtems_monitor_task_id = 0;
     467   
     468    rtems_monitor_server_kill();
     469}
     470
     471void
     472rtems_monitor_init(
     473    unsigned32 monitor_flags
     474)
     475{
     476    rtems_status_code status;
     477   
     478    rtems_monitor_kill();
     479
     480    status = rtems_task_create(RTEMS_MONITOR_NAME,
     481                               1,
     482                               0 /* default stack */,
     483                               RTEMS_INTERRUPT_LEVEL(0),
     484                               RTEMS_DEFAULT_ATTRIBUTES,
     485                               &rtems_monitor_task_id);
     486    if (status != RTEMS_SUCCESSFUL)
     487    {
     488        rtems_error(status, "could not create monitor task");
     489        goto done;
     490    }
     491
     492    rtems_monitor_node = rtems_get_node(rtems_monitor_task_id);
     493    rtems_monitor_default_node = rtems_monitor_node;
     494
     495    rtems_monitor_symbols_loadup();
     496
     497    if (monitor_flags & RTEMS_MONITOR_GLOBAL)
     498        rtems_monitor_server_init(monitor_flags);
     499
     500    /*
     501     * Start the monitor task itself
     502     */
     503   
     504    status = rtems_task_start(rtems_monitor_task_id,
     505                              rtems_monitor_task,
     506                              monitor_flags);
     507    if (status != RTEMS_SUCCESSFUL)
     508    {
     509        rtems_error(status, "could not start monitor");
     510        goto done;
     511    }
     512
     513done:
     514}
  • c/src/lib/libmisc/monitor/mon-symbols.c

    r3b438fa rb06e68ef  
    11/*
    2  *      @(#)symbols.c   1.3 - 95/04/24
     2 *      @(#)symbols.c   1.10 - 95/08/02
    33 *     
     4 *  $Id$
    45 */
    56
     
    2223#include <string.h>
    2324
     25#include "monitor.h"
    2426#include "symbols.h"
    2527
    26 extern rtems_symbol_table_t *rtems_monitor_symbols;
    27 
    28 #ifdef RTEMS_DEBUG
    29 #define CHK_ADR_PTR(p)  \
    30 do { \
    31     if (((p) < rtems_monitor_symbols->addresses) || \
    32         ((p) >= (rtems_monitor_symbols->addresses + rtems_monitor_symbols->next))) \
    33     { \
    34         printf("bad address pointer %p\n", (p)); \
    35         rtems_fatal_error_occurred(RTEMS_INVALID_ADDRESS); \
    36     } \
    37 } while (0)
    38 
    39 #define CHK_NAME_PTR(p) \
    40 do { \
    41     if (((p) < rtems_monitor_symbols->symbols) || \
    42         ((p) >= (rtems_monitor_symbols->symbols + rtems_monitor_symbols->next))) \
    43     { \
    44         printf("bad symbol pointer %p\n", (p)); \
    45         rtems_fatal_error_occurred(RTEMS_INVALID_ADDRESS); \
    46     } \
    47 } while (0)
    48 #else
    49 #define CHK_ADR_PTR(p)
    50 #define CHK_NAME_PTR(p)
    51 #endif
    5228
    5329rtems_symbol_table_t *
     
    179155    s2 = (rtems_symbol_t *) e2;
    180156
    181     CHK_ADR_PTR(s1);
    182     CHK_ADR_PTR(s2);
    183 
    184157    if (s1->value < s2->value)
    185158        return -1;
     
    200173    s1 = (rtems_symbol_t *) e1;
    201174    s2 = (rtems_symbol_t *) e2;
    202 
    203     CHK_NAME_PTR(s1);
    204     CHK_NAME_PTR(s2);
    205175
    206176    return strcasecmp(s1->name, s2->name);
     
    252222    rtems_unsigned32 best_distance = ~0;
    253223    rtems_unsigned32 elements;
     224
     225    if (table == 0)
     226        table = rtems_monitor_symbols;
    254227
    255228    if ((table == 0) || (table->size == 0))
     
    301274    rtems_symbol_t  key;
    302275
     276    if (table == 0)
     277        table = rtems_monitor_symbols;
     278
    303279    if ((table == 0) || (name == 0))
    304280        goto done;
    305281
    306282    if (table->sorted == 0)
    307     {
    308283        rtems_symbol_sort(table);
    309     }
    310284
    311285    /*
     
    326300}
    327301
     302void *
     303rtems_monitor_symbol_next(
     304    void                   *object_info,
     305    rtems_monitor_symbol_t *canonical,
     306    rtems_id               *next_id
     307)
     308{
     309    rtems_symbol_table_t *table;
     310    int n = rtems_get_index(*next_id);
     311
     312    table = *(rtems_symbol_table_t **) object_info;
     313    if (table == 0)
     314        goto failed;
     315
     316    if (n >= table->next)
     317        goto failed;
     318
     319    /* NOTE: symbols do not have id and name fields */
     320     
     321    if (table->sorted == 0)
     322        rtems_symbol_sort(table);
     323
     324    _Thread_Disable_dispatch();
     325
     326    *next_id += 1;
     327    return (void *) (table->symbols + n);
     328
     329failed:
     330    *next_id = RTEMS_OBJECT_ID_FINAL;
     331    return 0;
     332}
     333
     334void
     335rtems_monitor_symbol_canonical(
     336    rtems_monitor_symbol_t *canonical_symbol,
     337    rtems_symbol_t *sp
     338)
     339{
     340    canonical_symbol->value = sp->value;
     341    canonical_symbol->offset = 0;
     342    strncpy(canonical_symbol->name, sp->name, sizeof(canonical_symbol->name));
     343}
     344
     345
     346void
     347rtems_monitor_symbol_canonical_by_name(
     348    rtems_monitor_symbol_t *canonical_symbol,
     349    char                   *name
     350)
     351{
     352    rtems_symbol_t *sp;
     353
     354    sp = rtems_symbol_name_lookup(0, name);
     355
     356    canonical_symbol->value = sp ? sp->value : 0;
     357
     358    strncpy(canonical_symbol->name, name, sizeof(canonical_symbol->name));
     359    canonical_symbol->offset = 0;
     360}
     361
     362void
     363rtems_monitor_symbol_canonical_by_value(
     364    rtems_monitor_symbol_t *canonical_symbol,
     365    void                   *value_void_p
     366)
     367{
     368    unsigned32 value = (unsigned32) value_void_p;
     369    rtems_symbol_t *sp;
     370
     371    sp = rtems_symbol_value_lookup(0, value);
     372    if (sp)
     373    {
     374        canonical_symbol->value = sp->value;
     375        canonical_symbol->offset = value - sp->value;
     376        strncpy(canonical_symbol->name, sp->name, sizeof(canonical_symbol->name));
     377    }
     378    else
     379    {
     380        canonical_symbol->value = value;
     381        canonical_symbol->offset = 0;
     382        canonical_symbol->name[0] = '\0';
     383    }
     384}
     385
     386
     387unsigned32
     388rtems_monitor_symbol_dump(
     389    rtems_monitor_symbol_t *canonical_symbol,
     390    boolean                 verbose
     391)
     392{
     393    unsigned32 length = 0;
     394
     395    /*
     396     * print the name if it exists AND if value is non-zero
     397     * Ie: don't print some garbage symbol for address 0
     398     */
     399
     400    if (canonical_symbol->name[0] && (canonical_symbol->value != 0))
     401    {
     402        if (canonical_symbol->offset == 0)
     403            length += printf("%.*s",
     404                             sizeof(canonical_symbol->name),
     405                             canonical_symbol->name);
     406        else
     407            length += printf("<%.*s+0x%x>",
     408                             sizeof(canonical_symbol->name),
     409                             canonical_symbol->name,
     410                             canonical_symbol->offset);
     411        if (verbose)
     412            length += printf(" [0x%x]", canonical_symbol->value);
     413    }
     414    else
     415        length += printf("[0x%x]", canonical_symbol->value);
     416
     417    return length;
     418}
     419
     420
     421void
     422rtems_monitor_symbol_dump_all(
     423    rtems_symbol_table_t *table,
     424    boolean               verbose
     425)
     426{
     427    int s;
     428    rtems_symbol_t *sp;
     429
     430    if (table == 0)
     431    {
     432        table = rtems_monitor_symbols;
     433        if (table == 0)
     434            return;
     435    }
     436
     437    if (table->sorted == 0)
     438        rtems_symbol_sort(table);
     439
     440    for (s = 0, sp = table->symbols; s < table->next; s++, sp++)
     441    {
     442        rtems_monitor_symbol_t canonical_symbol;
     443
     444        rtems_monitor_symbol_canonical(&canonical_symbol, sp);
     445        rtems_monitor_symbol_dump(&canonical_symbol, TRUE);
     446        printf("\n");
     447    }
     448}
     449
     450
     451/*
     452 * 'symbol' command
     453 */
     454
     455void
     456rtems_monitor_symbol_cmd(
     457    int        argc,
     458    char     **argv,
     459    unsigned32 command_arg,
     460    boolean    verbose
     461)
     462{
     463    int arg;
     464    rtems_symbol_table_t *table;
     465
     466    table = *(rtems_symbol_table_t **) command_arg;
     467    if (table == 0)
     468    {
     469        table = rtems_monitor_symbols;
     470        if (table == 0)
     471            return;
     472    }
     473
     474    /*
     475     * Use object command to dump out whole symbol table
     476     */
     477    if (argc == 1)
     478        rtems_monitor_symbol_dump_all(table, verbose);
     479    else
     480    {
     481        rtems_monitor_symbol_t canonical_symbol;
     482
     483        for (arg=1; argv[arg]; arg++)
     484        {
     485            rtems_monitor_symbol_canonical_by_name(&canonical_symbol, argv[arg]);
     486            rtems_monitor_symbol_dump(&canonical_symbol, verbose);
     487            printf("\n");
     488        }
     489    }
     490}
  • c/src/lib/libmisc/monitor/monitor.h

    r3b438fa rb06e68ef  
    11/*
    2  *      @(#)monitor.h   1.2 - 95/04/24
     2 *      @(#)monitor.h   1.14 - 95/08/02
    33 *     
     4 *  $Id$
    45 */
    56
     
    1011 *    The RTEMS monitor task include file.
    1112 *
    12  *
    13  *
    1413 *  TODO:
    15  *
    1614 */
    1715
    1816#ifndef __MONITOR_H
    1917#define __MONITOR_H
     18
     19#include "symbols.h"
     20#include <rtems/error.h>                /* rtems_error() */
    2021
    2122#ifdef __cplusplus
     
    2324#endif
    2425
    25 void    rtems_monitor_init(rtems_boolean monitor_suspend);
     26/*
     27 * XXX this should be in rtems proper when type becomes part of id
     28 */
     29
     30typedef enum {
     31    RTEMS_OBJECT_INVALID   =  0,
     32    RTEMS_OBJECT_TASK      =  1,
     33    RTEMS_OBJECT_EXTENSION =  2,
     34    RTEMS_OBJECT_QUEUE     =  3,
     35    RTEMS_OBJECT_SEMAPHORE =  4,
     36    RTEMS_OBJECT_DRIVER    =  5,
     37    RTEMS_OBJECT_DNAME     =  6,
     38    RTEMS_OBJECT_CONFIG    =  7,
     39    RTEMS_OBJECT_INIT_TASK =  8,
     40    RTEMS_OBJECT_MPCI      =  9,
     41    RTEMS_OBJECT_PARTITION = 10,
     42    RTEMS_OBJECT_REGION    = 11,
     43    RTEMS_OBJECT_PORT      = 12,
     44    RTEMS_OBJECT_SYMBOL    = 13,
     45} rtems_object_type_t;
     46
     47/*
     48 * rtems_monitor_init() flags
     49 */
     50
     51#define RTEMS_MONITOR_SUSPEND   0x0001          /* suspend monitor on startup */
     52#define RTEMS_MONITOR_GLOBAL    0x0002          /* monitor should be global */
     53
     54
     55/*
     56 * Public interfaces for RTEMS data structures monitor is aware of.
     57 * These are only used by the monitor.
     58 *
     59 * NOTE:
     60 *  All the canonical objects that correspond to RTEMS managed "objects"
     61 *  must have an identical first portion with 'id' and 'name' fields.
     62 *
     63 *  Others do not have that restriction, even tho we would like them to.
     64 *  This is because some of the canonical structures are almost too big
     65 *  for shared memory driver (eg: mpci) and we are nickel and diming it.
     66 */
     67
     68/*
     69 * Type of a pointer that may be a symbol
     70 */
     71   
     72#define MONITOR_SYMBOL_LEN 20
     73typedef struct {
     74    char       name[MONITOR_SYMBOL_LEN];
     75    unsigned32 value;
     76    unsigned32 offset;
     77} rtems_monitor_symbol_t;   
     78
     79typedef struct {
     80    rtems_id            id;
     81    rtems_name          name;
     82  /* end of common portion */
     83} rtems_monitor_generic_t;       
     84
     85/*
     86 * Task
     87 */
     88typedef struct {
     89    rtems_id            id;
     90    rtems_name          name;
     91  /* end of common portion */
     92    Thread_Entry        entry;
     93    unsigned32          argument;
     94    void               *stack;
     95    unsigned32          stack_size;
     96    rtems_task_priority priority;
     97    States_Control      state;
     98    rtems_event_set     events;
     99    rtems_mode          modes;
     100    rtems_attribute     attributes;
     101    unsigned32          notepad[RTEMS_NUMBER_NOTEPADS];
     102    rtems_id            wait_id;
     103    unsigned32          wait_args;
     104} rtems_monitor_task_t;
     105
     106/*
     107 * Init task
     108 */
     109
     110typedef struct {
     111    rtems_id            id;             /* not really an id */
     112    rtems_name          name;
     113  /* end of common portion */
     114    rtems_monitor_symbol_t entry;
     115    unsigned32             argument;
     116    unsigned32             stack_size;
     117    rtems_task_priority    priority;
     118    rtems_mode             modes;
     119    rtems_attribute        attributes;
     120} rtems_monitor_init_task_t;
     121
     122
     123/*
     124 * Message queue
     125 */
     126typedef struct {
     127    rtems_id            id;
     128    rtems_name          name;
     129  /* end of common portion */
     130    rtems_attribute     attributes;
     131    unsigned32          number_of_pending_messages;
     132    unsigned32          maximum_pending_messages;
     133    unsigned32          maximum_message_size;
     134} rtems_monitor_queue_t;
     135
     136/*
     137 * Extension
     138 */
     139typedef struct {
     140    rtems_id                 id;
     141    rtems_name               name;
     142  /* end of common portion */
     143    rtems_monitor_symbol_t  create;
     144    rtems_monitor_symbol_t  start;
     145    rtems_monitor_symbol_t  restart;
     146    rtems_monitor_symbol_t  delete;
     147    rtems_monitor_symbol_t  tswitch;
     148    rtems_monitor_symbol_t  begin;
     149    rtems_monitor_symbol_t  exitted;
     150    rtems_monitor_symbol_t  fatal;
     151} rtems_monitor_extension_t;
     152
     153/*
     154 * Device driver
     155 */
     156
     157typedef struct {
     158    rtems_id            id;                /* not really an id (should be tho) */
     159    rtems_name          name;              /* ditto */
     160  /* end of common portion */
     161    rtems_monitor_symbol_t initialization; /* initialization procedure */
     162    rtems_monitor_symbol_t open;           /* open request procedure */
     163    rtems_monitor_symbol_t close;          /* close request procedure */
     164    rtems_monitor_symbol_t read;           /* read request procedure */
     165    rtems_monitor_symbol_t write;          /* write request procedure */
     166    rtems_monitor_symbol_t control;        /* special functions procedure */
     167} rtems_monitor_driver_t;
     168
     169typedef struct {
     170    rtems_id            id;                 /* not used for drivers (yet) */
     171    rtems_name          name;               /* not used for drivers (yet) */
     172  /* end of common portion */
     173    unsigned32          major;
     174    unsigned32          minor;
     175    char                name_string[64];
     176} rtems_monitor_dname_t;
     177
     178/*
     179 * System config
     180 */
     181
     182typedef struct {
     183    void               *work_space_start;
     184    unsigned32          work_space_size;
     185    unsigned32          maximum_tasks;
     186    unsigned32          maximum_timers;
     187    unsigned32          maximum_semaphores;
     188    unsigned32          maximum_message_queues;
     189    unsigned32          maximum_partitions;
     190    unsigned32          maximum_regions;
     191    unsigned32          maximum_ports;
     192    unsigned32          maximum_periods;
     193    unsigned32          maximum_extensions;
     194    unsigned32          microseconds_per_tick;
     195    unsigned32          ticks_per_timeslice;
     196    unsigned32          number_of_initialization_tasks;
     197} rtems_monitor_config_t;
     198
     199/*
     200 * MPCI config
     201 */
     202
     203typedef struct {
     204    unsigned32  node;                   /* local node number */
     205    unsigned32  maximum_nodes;          /* maximum # nodes in system */
     206    unsigned32  maximum_global_objects; /* maximum # global objects */
     207    unsigned32  maximum_proxies;        /* maximum # proxies */
     208
     209    unsigned32               default_timeout;        /* in ticks */
     210    unsigned32               maximum_packet_size;
     211    rtems_monitor_symbol_t   initialization;
     212    rtems_monitor_symbol_t   get_packet;
     213    rtems_monitor_symbol_t   return_packet;
     214    rtems_monitor_symbol_t   send_packet;
     215    rtems_monitor_symbol_t   receive_packet;
     216} rtems_monitor_mpci_t;
     217
     218/*
     219 * The generic canonical information union
     220 */
     221
     222typedef union {
     223    rtems_monitor_generic_t    generic;
     224    rtems_monitor_task_t       task;
     225    rtems_monitor_queue_t      queue;
     226    rtems_monitor_extension_t  extension;
     227    rtems_monitor_driver_t     driver;
     228    rtems_monitor_dname_t      dname;
     229    rtems_monitor_config_t     config;
     230    rtems_monitor_mpci_t       mpci;
     231    rtems_monitor_init_task_t  itask;
     232} rtems_monitor_union_t;
     233
     234/*
     235 * Support for talking to other monitors
     236 */
     237
     238/*
     239 * Names of other monitors
     240 */
     241
     242#define RTEMS_MONITOR_NAME        (rtems_build_name('R', 'M', 'O', 'N'))
     243#define RTEMS_MONITOR_SERVER_NAME (rtems_build_name('R', 'M', 'S', 'V'))
     244#define RTEMS_MONITOR_QUEUE_NAME  (rtems_build_name('R', 'M', 'S', 'Q'))
     245#define RTEMS_MONITOR_RESPONSE_QUEUE_NAME (rtems_build_name('R', 'M', 'R', 'Q'))
     246
     247#define RTEMS_MONITOR_SERVER_RESPONSE    0x0001
     248#define RTEMS_MONITOR_SERVER_CANONICAL   0x0002
     249
     250typedef struct
     251{
     252    unsigned32  command;
     253    rtems_id    return_id;
     254    unsigned32  argument0;
     255    unsigned32  argument1;
     256    unsigned32  argument2;
     257    unsigned32  argument3;
     258    unsigned32  argument4;
     259    unsigned32  argument5;
     260} rtems_monitor_server_request_t;
     261
     262typedef struct
     263{
     264    unsigned32  command;
     265    unsigned32  result0;
     266    unsigned32  result1;
     267    rtems_monitor_union_t payload;
     268} rtems_monitor_server_response_t;
     269
     270extern rtems_id  rtems_monitor_task_id;
     271
     272extern unsigned32 rtems_monitor_node;          /* our node number */
     273extern unsigned32 rtems_monitor_default_node;  /* current default for commands */
     274
     275/*
     276 * Monitor command function and table entry
     277 */
     278
     279typedef struct rtems_monitor_command_entry_s rtems_monitor_command_entry_t;
     280
     281typedef void ( *rtems_monitor_command_function_t )(
     282                 int         argc,
     283                 char      **argv,
     284                 unsigned32  command_arg,
     285                 boolean     verbose
     286             );
     287
     288struct rtems_monitor_command_entry_s {
     289    char        *command;      /* command name */
     290    char        *usage;        /* usage string for the command */
     291    unsigned32   arguments_required;    /* # of required args */
     292    rtems_monitor_command_function_t command_function;
     293
     294                               /* Some argument for the command */
     295    unsigned32          command_arg;
     296};
     297
     298typedef void *(*rtems_monitor_object_next_fn)(void *, void *, rtems_id *);
     299typedef void (*rtems_monitor_object_canonical_fn)(void *, void *);
     300typedef void (*rtems_monitor_object_dump_header_fn)(boolean);
     301typedef void (*rtems_monitor_object_dump_fn)(void *, boolean);
     302
     303typedef struct {
     304    rtems_object_type_t                 type;
     305    void                               *object_information;
     306    int                                 size;   /* of canonical object */
     307    rtems_monitor_object_next_fn        next;
     308    rtems_monitor_object_canonical_fn   canonical;
     309    rtems_monitor_object_dump_header_fn dump_header;
     310    rtems_monitor_object_dump_fn        dump;
     311} rtems_monitor_object_info_t;
     312
     313
     314/* monitor.c */
     315void    rtems_monitor_kill(void);
     316void    rtems_monitor_init(rtems_boolean);
    26317void    rtems_monitor_wakeup(void);
    27 void    rtems_monitor_task(rtems_task_argument monitor_suspend);
     318void    rtems_monitor_pause_cmd(int, char **, unsigned32, boolean);
     319void    rtems_monitor_fatal_cmd(int, char **, unsigned32, boolean);
     320void    rtems_monitor_continue_cmd(int, char **, unsigned32, boolean);
     321void    rtems_monitor_node_cmd(int, char **, unsigned32, boolean);
    28322void    rtems_monitor_symbols_loadup(void);
    29 
    30 extern rtems_unsigned32        rtems_monitor_task_id;
     323void    rtems_monitor_task(rtems_task_argument);
     324
     325/* server.c */
     326void    rtems_monitor_server_kill(void);
     327rtems_status_code rtems_monitor_server_request(unsigned32, rtems_monitor_server_request_t *, rtems_monitor_server_response_t *);
     328void    rtems_monitor_server_task(rtems_task_argument);
     329void    rtems_monitor_server_init(unsigned32);
     330 
     331/* command.c */
     332int     rtems_monitor_make_argv(char *, int *, char **);
     333int     rtems_monitor_command_read(char *, int *, char **);
     334rtems_monitor_command_entry_t *rtems_monitor_command_lookup(
     335    rtems_monitor_command_entry_t * table, int argc, char **argv);
     336void    rtems_monitor_command_usage(rtems_monitor_command_entry_t *, char *);
     337void    rtems_monitor_help_cmd(int, char **, unsigned32, boolean);
     338
     339/* prmisc.c */
     340void       rtems_monitor_separator(void);
     341unsigned32 rtems_monitor_pad(unsigned32 dest_col, unsigned32 curr_col);
     342unsigned32 rtems_monitor_dump_char(unsigned8 ch);
     343unsigned32 rtems_monitor_dump_decimal(unsigned32 num);
     344unsigned32 rtems_monitor_dump_hex(unsigned32 num);
     345unsigned32 rtems_monitor_dump_id(rtems_id id);
     346unsigned32 rtems_monitor_dump_name(rtems_name name);
     347unsigned32 rtems_monitor_dump_priority(rtems_task_priority priority);
     348unsigned32 rtems_monitor_dump_state(States_Control state);
     349unsigned32 rtems_monitor_dump_modes(rtems_mode modes);
     350unsigned32 rtems_monitor_dump_attributes(rtems_attribute attributes);
     351unsigned32 rtems_monitor_dump_events(rtems_event_set events);
     352unsigned32 rtems_monitor_dump_notepad(unsigned32 *notepad);
     353
     354/* object.c */
     355rtems_id   rtems_monitor_id_fixup(rtems_id, unsigned32, rtems_object_type_t);
     356rtems_id   rtems_monitor_object_canonical_get(rtems_object_type_t, rtems_id, void *, unsigned32 *size_p);
     357rtems_id   rtems_monitor_object_canonical_next(rtems_monitor_object_info_t *, rtems_id, void *);
     358void      *rtems_monitor_object_next(void *, void *, rtems_id, rtems_id *);
     359rtems_id   rtems_monitor_object_canonical(rtems_id, void *);
     360void       rtems_monitor_object_cmd(int, char **, unsigned32, boolean);
     361
     362/* manager.c */
     363void      *rtems_monitor_manager_next(void *, void *, rtems_id *);
     364
     365/* config.c */
     366void       rtems_monitor_config_canonical(rtems_monitor_config_t *, void *);
     367void      *rtems_monitor_config_next(void *, rtems_monitor_config_t *, rtems_id *);
     368void       rtems_monitor_config_dump_header(boolean);
     369void       rtems_monitor_config_dump(rtems_monitor_config_t *, boolean verbose);
     370
     371/* mpci.c */
     372void       rtems_monitor_mpci_canonical(rtems_monitor_mpci_t *, void *);
     373void      *rtems_monitor_mpci_next(void *, rtems_monitor_mpci_t *, rtems_id *);
     374void       rtems_monitor_mpci_dump_header(boolean);
     375void       rtems_monitor_mpci_dump(rtems_monitor_mpci_t *, boolean verbose);
     376
     377/* itask.c */
     378void       rtems_monitor_init_task_canonical(rtems_monitor_init_task_t *, void *);
     379void      *rtems_monitor_init_task_next(void *, rtems_monitor_init_task_t *, rtems_id *);
     380void       rtems_monitor_init_task_dump_header(boolean);
     381void       rtems_monitor_init_task_dump(rtems_monitor_init_task_t *, boolean verbose);
     382
     383/* extension.c */
     384void       rtems_monitor_extension_canonical(rtems_monitor_extension_t *, void *);
     385void       rtems_monitor_extension_dump_header(boolean verbose);
     386void       rtems_monitor_extension_dump(rtems_monitor_extension_t *, boolean);
     387
     388/* task.c */
     389void    rtems_monitor_task_canonical(rtems_monitor_task_t *, void *);
     390void    rtems_monitor_task_dump_header(boolean verbose);
     391void    rtems_monitor_task_dump(rtems_monitor_task_t *, boolean);
     392
     393/* queue.c */
     394void    rtems_monitor_queue_canonical(rtems_monitor_queue_t *, void *);
     395void    rtems_monitor_queue_dump_header(boolean verbose);
     396void    rtems_monitor_queue_dump(rtems_monitor_queue_t *, boolean);
     397
     398/* driver.c */
     399void    *rtems_monitor_driver_next(void *, rtems_monitor_driver_t *, rtems_id *);
     400void     rtems_monitor_driver_canonical(rtems_monitor_driver_t *, void *);
     401void     rtems_monitor_driver_dump_header(boolean);
     402void     rtems_monitor_driver_dump(rtems_monitor_driver_t *, boolean);
     403
     404/* dname.c */
     405void    *rtems_monitor_dname_next(void *, rtems_monitor_dname_t *, rtems_id *);
     406void     rtems_monitor_dname_canonical(rtems_monitor_dname_t *, void *);
     407void     rtems_monitor_dname_dump_header(boolean);
     408void     rtems_monitor_dname_dump(rtems_monitor_dname_t *, boolean);
     409
     410/* symbols.c */
     411rtems_symbol_table_t *rtems_symbol_table_create();
     412void                  rtems_symbol_table_destroy(rtems_symbol_table_t *table);
     413
     414rtems_symbol_t *rtems_symbol_create(rtems_symbol_table_t *, char *, unsigned32);
     415rtems_symbol_t *rtems_symbol_value_lookup(rtems_symbol_table_t *, unsigned32);
     416rtems_symbol_t *rtems_symbol_name_lookup(rtems_symbol_table_t *, char *);
     417void   *rtems_monitor_symbol_next(void *object_info, rtems_monitor_symbol_t *, rtems_id *);
     418void    rtems_monitor_symbol_canonical(rtems_monitor_symbol_t *, rtems_symbol_t *);
     419void    rtems_monitor_symbol_canonical_by_name(rtems_monitor_symbol_t *, char *);
     420void    rtems_monitor_symbol_canonical_by_value(rtems_monitor_symbol_t *, void *);
     421unsigned32 rtems_monitor_symbol_dump(rtems_monitor_symbol_t *, boolean);
     422void    rtems_monitor_symbol_cmd(int, char **, unsigned32, boolean);
     423
    31424
    32425extern rtems_symbol_table_t *rtems_monitor_symbols;
     426
     427#ifndef MONITOR_PROMPT
     428#define MONITOR_PROMPT "rtems"          /* will have '> ' appended */
     429#endif
     430
     431#define MONITOR_WAKEUP_EVENT   RTEMS_EVENT_0
     432
     433
     434#define STREQ(a,b)      (strcmp(a,b) == 0)
     435#define STRNEQ(a,b,n)   (strncmp(a,b,n) == 0)
    33436
    34437#ifdef __cplusplus
  • c/src/lib/libmisc/monitor/symbols.h

    r3b438fa rb06e68ef  
    11/*
    2  *  File:       symbols.h
     2 *      @(#)symbols.h   1.3 - 95/06/09
     3 *     
     4 *
     5 *  RTEMS monitor symbol table functions
    36 *
    47 *  Description:
     
    912 *  TODO:
    1013 *
     14 *  $Id$
    1115 */
    1216
     
    6266} rtems_symbol_table_t;
    6367
    64 void                  rtems_symbol_table_destroy(rtems_symbol_table_t *table);
    65 rtems_symbol_table_t *rtems_symbol_table_create();
    66 rtems_symbol_t       *rtems_symbol_create(rtems_symbol_table_t *,
    67                                           char *, rtems_unsigned32);
    68 rtems_symbol_t       *rtems_symbol_value_lookup(rtems_symbol_table_t *,
    69                                                 rtems_unsigned32);
    70 rtems_symbol_t       *rtems_symbol_name_lookup(rtems_symbol_table_t *,
    71                                                 char *);
    72 
    7368#define rtems_symbol_name(sp)   ((sp)->name)
    7469#define rtems_symbol_value(sp)  ((sp)->value)
Note: See TracChangeset for help on using the changeset viewer.