source: examples-v2/micromonitor/diagnostics/cstart.c @ c304643

4.11
Last change on this file since c304643 was 9a0cbfd, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 6, 2009 at 11:23:20 PM

2009-08-06 Joel Sherrill <joel.sherrill@…>

  • ChangeLog?, README, diagnostics/README, diagnostics/cfg.h, diagnostics/cli.h, diagnostics/cstart.c, diagnostics/main.c, diagnostics/makefile, diagnostics/monlib.c, diagnostics/monlib.h, diagnostics/tfs.h, umon/Makefile, umon/README, umon/test.c: New files.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 * This file is a simple example of an application that could be run
3 * on top of the monitor.
4 *
5 * Cstart():
6 * The Cstart() function depends on the setting of MONCOMPTR in config.h.
7 * It demonstrates the use of monConnect and the first mon_XXX function
8 * typically called by an application, mon_getargv().
9 */
10
11#include "monlib.h"
12#include "tfs.h"
13#include "cfg.h"
14
15extern int main(int, char**);
16
17int Cstart(void)
18{
19  char  **argv;
20  int    argc;
21
22  /* Connect the application to the monitor.  This must be done
23   * prior to the application making any other attempts to use the
24   * "mon_" functions provided by the monitor.
25   */
26  monConnect((int(*)())(*(unsigned long *)MONCOMPTR),(void *)0,(void *)0);
27
28  /* When the monitor starts up an application, it stores the argument
29   * list internally.  The call to mon_getargv() retrieves the arg list
30   * for use by this application...
31   */
32  mon_getargv(&argc,&argv);
33
34  /* Call main, then exit to monitor.
35   */
36  main(argc,argv);
37
38  /* mon_appexit(0); */
39
40  /* Won't get here. */
41  return(0);
42}
43
44#if 0
45/* CstartAlt():
46 * Demonstrates the use of the "call -a" command in uMon.
47 * For example, if for some reason you wanted to do this...
48 * Load the application then load the symtbl file using
49 * "make TARGET_IP=1.2.3.4 sym", then issue these commands:
50 *
51 *  tfs -v ld app
52 *  call -a %CstartAlt one two three
53 *
54 * The "call -a" command in uMon correctly sets up the function
55 * call parameters so that the following function would see 4
56 * arguments (including arg0), with argv[1] thru argv[3] being
57 * pointers to each of the number strings (i.e. "one", "two", "three")
58 * and argv[0] being the ascii-coded-hex address of the function
59 * CstartAlt.
60 */
61int
62CstartAlt(int argc, char *argv[])
63{
64  monConnect((int(*)())(*(unsigned long *)MONCOMPTR),(void *)0,(void *)0);
65  main(argc,argv);
66  mon_appexit(0);
67  return(0);
68}
69#endif
Note: See TracBrowser for help on using the repository browser.