1    import xdc.rov.ViewInfo;
     2    
     3    /*!
     4     *  ======== Monitor ========
     5     *  ROV support for the pure C "module" Mod.c[h]
     6     *
     7     *  The file `Board_serialMon.txt` (contained in this package) illustrates
     8     *  how to use the runtime monitor `Mon.[ch]` with a TI-RTOS UART driver.
     9     */
    10    //@NoRuntime
    11    //@HeaderName("")
    12    module Monitor
    13    {
    14        /*!
    15         *  ======== rovViewInfo ========
    16         *  @_nodoc
    17         */
    18        @Facet
    19        metaonly config ViewInfo.Instance rovViewInfo = 
    20            ViewInfo.create({
    21                argsMap: [
    22                    ['ReadMemory',
    23                        {
    24                            description: "Read Memory",
    25                            args: [
    26                                {
    27                                    name: "addr",
    28                                    type: "number",
    29                                    defaultValue: "0"
    30                                },
    31                                {
    32                                    name: "length",
    33                                    type: "number",
    34                                    defaultValue: "0"
    35                                },
    36                                {
    37                                    name: "check",
    38                                    type: "boolean",
    39                                    defaultValue: "true"
    40                                }
    41                            ]
    42                        }
    43                     ]
    44                ],
    45                viewMap: [
    46                    ['Module',
    47                        {
    48                            type: ViewInfo.MODULE,
    49                            viewInitFxn: 'viewInitModule',
    50                            structName: 'ModuleView'
    51                        }
    52                    ],
    53                    ['UChar',
    54                        {
    55                            type: xdc.rov.ViewInfo.MODULE_DATA,
    56                            viewInitFxn: 'viewInitUChar',
    57                            structName: 'UCharView',
    58                            argsName: 'ReadMemory'
    59                        }
    60                    ],
    61                    ['Bits16',
    62                        {
    63                            type: xdc.rov.ViewInfo.MODULE_DATA,
    64                            viewInitFxn: 'viewInitBits16',
    65                            structName: 'Bits16View',
    66                            argsName: 'ReadMemory'
    67                        }
    68                    ],
    69                    ['Bits32',
    70                        {
    71                            type: xdc.rov.ViewInfo.MODULE_DATA,
    72                            viewInitFxn: 'viewInitBits32',
    73                            structName: 'Bits32View',
    74                            argsName: 'ReadMemory'
    75                        }
    76                    ],
    77                    ['Sections',
    78                        {
    79                            type: xdc.rov.ViewInfo.MODULE_DATA,
    80                            viewInitFxn: 'viewInitSections',
    81                            structName: 'SectionView'
    82                        }
    83                    ],
    84                    ['Symbols',
    85                        {
    86                            type: xdc.rov.ViewInfo.MODULE_DATA,
    87                            viewInitFxn: 'viewInitSymbols',
    88                            structName: 'SymbolView',
    89                            argsName: 'ReadMemory'
    90                        }
    91                    ],
    92                ]
    93            });
    94    
    95        /*!
    96         *  ======== ModuleView ========
    97         *  @_nodoc
    98         */
    99        metaonly struct ModuleView {
   100            String command;   /* current monitor command */
   101            String readFxn;   /* monitor's read function */   
   102            String writeFxn;  /* monitor's write function */
   103        }
   104    
   105        /*!
   106         *  ======== SectionView ========
   107         *  @_nodoc
   108         */
   109        metaonly struct SectionView {
   110            String name;
   111            Ptr    start;
   112            Ptr    end;
   113            UInt   len;
   114        };
   115    
   116        /*!
   117         *  ======== SymbolView ========
   118         *  @_nodoc
   119         */
   120        metaonly struct SymbolView {
   121            String name;
   122            Ptr    addr;
   123            String type;
   124        };
   125        
   126        /*!
   127         *  ======== Bits16View ========
   128         *  One row of Bits16 values
   129         *  @_nodoc
   130         */
   131        metaonly struct Bits16View {
   132            Ptr    addr;
   133            Bits16 word0;
   134            Bits16 word1;
   135            Bits16 word2;
   136            Bits16 word3;
   137            Bits16 word4;
   138            Bits16 word5;
   139            Bits16 word6;
   140            Bits16 word7;
   141        };
   142    
   143        /*!
   144         *  ======== Bits32View ========
   145         *  One row of Bits32 values
   146         *  @_nodoc
   147         */
   148        metaonly struct Bits32View {
   149            Ptr    addr;
   150            Bits32 word0;
   151            Bits32 word1;
   152            Bits32 word2;
   153            Bits32 word3;
   154        };
   155    
   156        /*!
   157         *  ======== UCharView ========
   158         *  One row of UChar values
   159         *  @_nodoc
   160         */
   161        metaonly struct UCharView {
   162            Ptr   addr;
   163            UChar byte0;
   164            UChar byte1;
   165            UChar byte2;
   166            UChar byte3;
   167            UChar byte4;
   168            UChar byte5;
   169            UChar byte6;
   170            UChar byte7;
   171        };
   172    
   173        /*! @_nodoc - target datatype used to fetch data for UCharView */
   174        struct UCharBuffer {
   175            UChar elem;
   176        };
   177        
   178        /*! @_nodoc - target datatype used to fetch data for Bits16View */
   179        struct Bits16Buffer {
   180            Bits16 elem;
   181        };
   182        
   183        /*! @_nodoc - target datatype used to fetch data for Bits32View */
   184        struct Bits32Buffer {
   185            Bits32 elem;
   186        };
   187        
   188        /*! @_nodoc - matches Mon command size */
   189        config Int MAXCMDSIZE = 128;
   190        
   191        /*! @_nodoc - Mon state structure address */
   192        config Ptr STATEADDR = "&monObject";
   193        
   194        /*! @_nodoc - matches Mon state structure */
   195        struct MonState {
   196            Char *buffer; /* command buffer (of length MAXCMDSIZE) */
   197            Fxn  read;
   198            Fxn  write;
   199        };
   200    }