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                    ['VariableNameOrAddr',
    23                        {
    24                            description: "Variable Name/Address",
    25                            args: [
    26                                {
    27                                    name: "name/addr",
    28                                    type: "number",
    29                                    defaultValue: "0"
    30                                },
    31                                {
    32                                    name: "check",
    33                                    type: "boolean",
    34                                    defaultValue: "true"
    35                                }
    36                            ]
    37                         }
    38                    ],
    39                    ['ReadMemory',
    40                        {
    41                            description: "Read Memory",
    42                            args: [
    43                                {
    44                                    name: "addr/name",
    45                                    type: "number",
    46                                    defaultValue: "0"
    47                                },
    48                                {
    49                                    name: "length",
    50                                    type: "number",
    51                                    defaultValue: "0"
    52                                },
    53                                {
    54                                    name: "check",
    55                                    type: "boolean",
    56                                    defaultValue: "true"
    57                                }
    58                            ]
    59                        }
    60                    ],
    61                    ['FindSymbols',
    62                        {
    63                            description: "Find Symbols",
    64                            args: [
    65                                {
    66                                    name: "addr/name",
    67                                    type: "number",
    68                                    defaultValue: "0"
    69                                },
    70                                {
    71                                    name: "radius",
    72                                    type: "number",
    73                                    defaultValue: "0"
    74                                },
    75                                {
    76                                    name: "check",
    77                                    type: "boolean",
    78                                    defaultValue: "true"
    79                                }
    80                            ]
    81                        }
    82                     ]
    83                    
    84                ],
    85                viewMap: [
    86                    ['Module',
    87                        {
    88                            type: ViewInfo.MODULE,
    89                            viewInitFxn: 'viewInitModule',
    90                            structName: 'ModuleView'
    91                        }
    92                    ],
    93                    ['Variable',
    94                        {
    95                            type: ViewInfo.MODULE,
    96                            viewInitFxn: 'viewInitVariable',
    97                            structName: 'VariableView',
    98                            argsName: 'VariableNameOrAddr'
    99                        }
   100                    ],
   101                    ['UChar',
   102                        {
   103                            type: xdc.rov.ViewInfo.MODULE_DATA,
   104                            viewInitFxn: 'viewInitUChar',
   105                            structName: 'UCharView',
   106                            argsName: 'ReadMemory'
   107                        }
   108                    ],
   109                    ['Bits16',
   110                        {
   111                            type: xdc.rov.ViewInfo.MODULE_DATA,
   112                            viewInitFxn: 'viewInitBits16',
   113                            structName: 'Bits16View',
   114                            argsName: 'ReadMemory'
   115                        }
   116                    ],
   117                    ['Bits32',
   118                        {
   119                            type: xdc.rov.ViewInfo.MODULE_DATA,
   120                            viewInitFxn: 'viewInitBits32',
   121                            structName: 'Bits32View',
   122                            argsName: 'ReadMemory'
   123                        }
   124                    ],
   125                    ['Sections',
   126                        {
   127                            type: xdc.rov.ViewInfo.MODULE_DATA,
   128                            viewInitFxn: 'viewInitSections',
   129                            structName: 'SectionView'
   130                        }
   131                    ],
   132                    ['Symbols',
   133                        {
   134                            type: xdc.rov.ViewInfo.MODULE_DATA,
   135                            viewInitFxn: 'viewInitSymbols',
   136                            structName: 'SymbolView',
   137                            argsName: 'FindSymbols'
   138                        }
   139                    ],
   140                ]
   141            });
   142    
   143        /*!
   144         *  ======== ModuleView ========
   145         *  @_nodoc
   146         */
   147        metaonly struct ModuleView {
   148            String command;   /* current monitor command */
   149            String readFxn;   /* monitor's read function */   
   150            String writeFxn;  /* monitor's write function */
   151        }
   152    
   153        /*!
   154         *  ======== SectionView ========
   155         *  @_nodoc
   156         */
   157        metaonly struct SectionView {
   158            String name;
   159            Ptr    start;    /* first valid address of this section */
   160            Ptr    end;      /* last valid address of this section */
   161            UInt   len;      /* bytes on this section */
   162            UInt   gap;      /* gap between the previous section's end and start */
   163            String kind;     /* "code" or "data" */
   164            String startSym; /* symbol name (if any) whose address equals start */
   165        };
   166    
   167        /*!
   168         *  ======== SymbolView ========
   169         *  @_nodoc
   170         */
   171        metaonly struct SymbolView {
   172            String name;
   173            Ptr    addr;
   174            String type;
   175        };
   176        
   177        /*!
   178         *  ======== VariableView ========
   179         *  @_nodoc
   180         */
   181        metaonly struct VariableView {
   182            String name;      /* variable's symbolic name */
   183            String character; /* variable as a char */
   184            String int8_t;    /* variable as a int8_t */
   185            String int16_t;   /* variable as a int16_t */
   186            String int32_t;   /* variable as a int32_t */
   187            String uint8_t;   /* variable as a uint8_t */
   188            String uint16_t;  /* variable as a uint16_t */
   189            String uint32_t;  /* variable as a uint32_t */
   190        }
   191    
   192        /*!
   193         *  ======== Bits16View ========
   194         *  One row of Bits16 values
   195         *  @_nodoc
   196         */
   197        metaonly struct Bits16View {
   198            Ptr    addr;
   199            Bits16 word0;
   200            Bits16 word1;
   201            Bits16 word2;
   202            Bits16 word3;
   203            Bits16 word4;
   204            Bits16 word5;
   205            Bits16 word6;
   206            Bits16 word7;
   207        };
   208    
   209        /*!
   210         *  ======== Bits32View ========
   211         *  One row of Bits32 values
   212         *  @_nodoc
   213         */
   214        metaonly struct Bits32View {
   215            Ptr    addr;
   216            Bits32 word0;
   217            Bits32 word1;
   218            Bits32 word2;
   219            Bits32 word3;
   220        };
   221    
   222        /*!
   223         *  ======== UCharView ========
   224         *  One row of UChar values
   225         *  @_nodoc
   226         */
   227        metaonly struct UCharView {
   228            Ptr   addr;
   229            UChar byte0;
   230            UChar byte1;
   231            UChar byte2;
   232            UChar byte3;
   233            UChar byte4;
   234            UChar byte5;
   235            UChar byte6;
   236            UChar byte7;
   237        };
   238    
   239        /*! @_nodoc - target datatype used to fetch data for UCharView */
   240        struct UCharBuffer {
   241            UChar elem;
   242        };
   243        
   244        /*! @_nodoc - target datatype used to fetch data for Bits16View */
   245        struct Bits16Buffer {
   246            Bits16 elem;
   247        };
   248        
   249        /*! @_nodoc - target datatype used to fetch data for Bits32View */
   250        struct Bits32Buffer {
   251            Bits32 elem;
   252        };
   253        
   254        /*! @_nodoc - matches Mon command size */
   255        config Int MAXCMDSIZE = 128;
   256        
   257        /*! @_nodoc - Mon state structure address */
   258        config Ptr STATEADDR = "&monObject";
   259        
   260        /*! @_nodoc - matches Mon state structure */
   261        struct MonState {
   262            Char *buffer; /* command buffer (of length MAXCMDSIZE) */
   263            Fxn  read;
   264            Fxn  write;
   265        };
   266    }