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: "Memory Read Settings",
    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 Symbol Settings",
    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                    ['ConsoleFilter',
    84                        {
    85                            description: "Console Settings",
    86                            args: [
    87                                {
    88                                    name: "filter",
    89                                    type: "string",
    90                                    defaultValue: ""
    91                                },
    92                                {
    93                                    name: "regexp",
    94                                    type: "boolean",
    95                                    defaultValue: "false"
    96                                },
    97                                {
    98                                    name: "maxLines",
    99                                    type: "number",
   100                                    defaultValue: "1000"
   101                                }
   102                            ]
   103                        }
   104                     ]
   105                ],
   106                viewMap: [
   107                    ['Module',
   108                        {
   109                            type: ViewInfo.MODULE,
   110                            viewInitFxn: 'viewInitModule',
   111                            structName: 'ModuleView'
   112                        }
   113                    ],
   114                    ['Variable',
   115                        {
   116                            type: ViewInfo.MODULE,
   117                            viewInitFxn: 'viewInitVariable',
   118                            structName: 'VariableView',
   119                            argsName: 'VariableNameOrAddr'
   120                        }
   121                    ],
   122                    ['UChar',
   123                        {
   124                            type: xdc.rov.ViewInfo.MODULE_DATA,
   125                            viewInitFxn: 'viewInitUChar',
   126                            structName: 'UCharView',
   127                            argsName: 'ReadMemory'
   128                        }
   129                    ],
   130                    ['Bits16',
   131                        {
   132                            type: xdc.rov.ViewInfo.MODULE_DATA,
   133                            viewInitFxn: 'viewInitBits16',
   134                            structName: 'Bits16View',
   135                            argsName: 'ReadMemory'
   136                        }
   137                    ],
   138                    ['Bits32',
   139                        {
   140                            type: xdc.rov.ViewInfo.MODULE_DATA,
   141                            viewInitFxn: 'viewInitBits32',
   142                            structName: 'Bits32View',
   143                            argsName: 'ReadMemory'
   144                        }
   145                    ],
   146                    ['Sections',
   147                        {
   148                            type: xdc.rov.ViewInfo.MODULE_DATA,
   149                            viewInitFxn: 'viewInitSections',
   150                            structName: 'SectionView'
   151                        }
   152                    ],
   153                    ['Symbols',
   154                        {
   155                            type: xdc.rov.ViewInfo.MODULE_DATA,
   156                            viewInitFxn: 'viewInitSymbols',
   157                            structName: 'SymbolView',
   158                            argsName: 'FindSymbols'
   159                        }
   160                    ],
   161                    ['Console',
   162                        {
   163                            type: xdc.rov.ViewInfo.MODULE_DATA,
   164                            viewInitFxn: 'viewInitConsole',
   165                            structName: 'ConsoleEntryView',
   166                            argsName: 'ConsoleFilter'
   167                        }
   168                    ]
   169                ]
   170            });
   171    
   172        /*!
   173         *  ======== ModuleView ========
   174         *  @_nodoc
   175         */
   176        metaonly struct ModuleView {
   177            String command;   /* current monitor command */
   178            String readFxn;   /* monitor's read function */
   179            String writeFxn;  /* monitor's write function */
   180        }
   181    
   182        /*!
   183         *  ======== SectionView ========
   184         *  @_nodoc
   185         */
   186        metaonly struct SectionView {
   187            String name;
   188            Ptr    start;    /* first valid address of this section */
   189            Ptr    end;      /* last valid address of this section */
   190            UInt   len;      /* bytes on this section */
   191            UInt   gap;      /* gap between the previous section's end and start */
   192            String kind;     /* "code" or "data" */
   193            String startSym; /* symbol name (if any) whose address equals start */
   194        };
   195    
   196        /*!
   197         *  ======== SymbolView ========
   198         *  @_nodoc
   199         */
   200        metaonly struct SymbolView {
   201            String name;
   202            Ptr    addr;
   203            String type;
   204        };
   205    
   206        /*!
   207         *  ======== VariableView ========
   208         *  @_nodoc
   209         */
   210        metaonly struct VariableView {
   211            String name;      /* variable's symbolic name */
   212            String character; /* variable as a char */
   213            String int8_t;    /* variable as a int8_t */
   214            String int16_t;   /* variable as a int16_t */
   215            String int32_t;   /* variable as a int32_t */
   216            String uint8_t;   /* variable as a uint8_t */
   217            String uint16_t;  /* variable as a uint16_t */
   218            String uint32_t;  /* variable as a uint32_t */
   219        }
   220    
   221        /*!
   222         *  ======== Bits16View ========
   223         *  One row of Bits16 values
   224         *  @_nodoc
   225         */
   226        metaonly struct Bits16View {
   227            Ptr    addr;
   228            Bits16 word0;
   229            Bits16 word1;
   230            Bits16 word2;
   231            Bits16 word3;
   232            Bits16 word4;
   233            Bits16 word5;
   234            Bits16 word6;
   235            Bits16 word7;
   236        };
   237    
   238        /*!
   239         *  ======== Bits32View ========
   240         *  One row of Bits32 values
   241         *  @_nodoc
   242         */
   243        metaonly struct Bits32View {
   244            Ptr    addr;
   245            Bits32 word0;
   246            Bits32 word1;
   247            Bits32 word2;
   248            Bits32 word3;
   249        };
   250    
   251        /*!
   252         *  ======== UCharView ========
   253         *  One row of UChar values
   254         *  @_nodoc
   255         */
   256        metaonly struct UCharView {
   257            Ptr   addr;
   258            UChar byte0;
   259            UChar byte1;
   260            UChar byte2;
   261            UChar byte3;
   262            UChar byte4;
   263            UChar byte5;
   264            UChar byte6;
   265            UChar byte7;
   266        };
   267    
   268        /*
   269         *  ======== ConsoleEntryView ========
   270         *  Each line in the console output is an entry
   271         */
   272        metaonly struct ConsoleEntryView {
   273            Bits32 lineId;
   274            String entry;
   275        }
   276    
   277        /*
   278         *  ======== print ========
   279         *  Append string to the end of the console buffer
   280         *
   281         *  Lines are separated by new lines: '\n'
   282         */
   283        metaonly void print(String str, ...);
   284    
   285        /*
   286         *  ======== println ========
   287         *  Append string plus a trailing new line to the console buffer
   288         *
   289         *  Lines are separated by new lines: '\n'
   290         */
   291        metaonly void println(String str, ...);
   292    
   293        /*! @_nodoc - target datatype used to fetch data for UCharView */
   294        struct UCharBuffer {
   295            UChar elem;
   296        };
   297    
   298        /*! @_nodoc - target datatype used to fetch data for Bits16View */
   299        struct Bits16Buffer {
   300            Bits16 elem;
   301        };
   302    
   303        /*! @_nodoc - target datatype used to fetch data for Bits32View */
   304        struct Bits32Buffer {
   305            Bits32 elem;
   306        };
   307    
   308        /*! @_nodoc - matches Mon command size */
   309        config Int MAXCMDSIZE = 128;
   310    
   311        /*! @_nodoc - Mon state structure address */
   312        config Ptr STATEADDR = "&monObject";
   313    
   314        /*! @_nodoc - matches Mon state structure */
   315        struct MonState {
   316            Char *buffer; /* command buffer (of length MAXCMDSIZE) */
   317            Fxn  read;
   318            Fxn  write;
   319        };
   320    }