Cleanup debug logging, fix single stepping. WinBond works good!
[external/binutils.git] / gdb / w89k-rom.c
1 #include "defs.h"
2 #include "gdbcore.h"
3 #include "target.h"
4 #include "monitor.h"
5
6 extern int baud_rate;
7
8 void w89k_open();
9 void monitor_open();
10
11 /*
12  * this array of registers need to match the indexes used by GDB. The
13  * whole reason this exists is cause the various ROM monitors use
14  * different strings than GDB does, and doesn't support all the
15  * registers either. So, typing "info reg sp" becomes a "r30".
16  */
17 static char *w89k_regnames[] = {
18   "r0",   "r1",    "r2",   "r3",   "r4",  "r5",  "r6",  "r7",  "r8",  "r9",
19   "r10",  "r11",   "r12",  "r13",  "r14", "r15", "r16", "r17", "r18", "r19",
20   "r20",  "r21",   "r22",  "r23",  "r24", "r25", "r26", "r27", "r28", "r29",
21   "r30",  "r31",   "sar",  "pc",   "",    "",    "",
22   "eiem", "iir",   "iva",  "ior",  "ipsw","",    "",    "",    "",    "",
23   "",     "",      "",     "",     "",    "",    "",    "ccr", "",    "",
24   "tr0",  "tr1",   "",     "",     "",    "",    "",
25   "",     "",      "",     "",     "",    "",    "",    "",
26   "",     "",      "",     "",     "",    "",    "",    "",
27   "",     "",      "",     "",     "",    "",    "",    "",
28   "",     "",      "",     "",     "",    "",    "",    "",
29   "",     "",      "",     "",     "",    "",    "",    "",
30   "",     "",      "",     "",     "",    "",    "",    "",
31   "",     "",      "",     "",     "",    "",    "",    "",
32   "",     "",      "",     "",     "",    "",    "",    ""
33 };
34
35 /*
36  * Define the monitor command strings. Since these are passed directly
37  * through to a printf style function, we need can include formatting
38  * strings. We also need a CR or LF on the end.
39  */
40
41 struct target_ops w89k_ops = {
42   "w89k",
43   "WinBond's debug monitor for the W89k Eval board",
44   "Debug on a WinBond W89K eval board.\n\
45 Specify the serial device it is connected to (e.g. /dev/ttya).",
46   w89k_open,
47   monitor_close, 
48   monitor_attach,
49   monitor_detach,
50   monitor_resume,
51   monitor_wait,
52   monitor_fetch_register,
53   monitor_store_register,
54   monitor_prepare_to_store,
55   monitor_xfer_inferior_memory,
56   monitor_files_info,
57   monitor_insert_breakpoint,
58   monitor_remove_breakpoint,    /* Breakpoints */
59   0,
60   0,
61   0,
62   0,
63   0,                            /* Terminal handling */
64   monitor_kill,
65   monitor_load,                 /* load */
66   0,                            /* lookup_symbol */
67   monitor_create_inferior,
68   monitor_mourn_inferior,
69   0,                            /* can_run */
70   0,                            /* notice_signals */
71   process_stratum,
72   0,                            /* next */
73   1,
74   1,
75   1,
76   1,
77   1,                            /* all mem, mem, stack, regs, exec */
78   0,
79   0,                            /* Section pointers */
80   OPS_MAGIC,                    /* Always the last thing */
81 };
82
83 struct monitor_ops w89k_cmds = {
84   1,                                    /* 1 for ASCII, 0 for binary */
85   "\n",                                 /* monitor init string */
86   "g = %x\n",                           /* execute or usually GO command */
87   "g\n",                                /* continue command */
88   "t\n",                                /* single step */
89   "bp %x\n",                            /* set a breakpoint */
90   "bc %x\n",                            /* clear a breakpoint */
91   0,                                    /* 0 for number, 1 for address */
92   {
93     "e %x %x\n",                        /* set memory */
94     "",                                 /* delimiter */
95     "",                                 /* the result */
96   },
97   {
98     "db %x %x\n",                       /* get memory */
99     "",                                 /* delimiter */
100     "",                                 /* the result */
101   },
102   {
103     "r %s %x\n",                        /* set a register */
104     "",                                 /* delimiter between registers */
105     "",                                 /* the result */
106   },
107   {
108     "r %s\n",                           /* get a register */
109     "",                                 /* delimiter between registers */
110     "",                                 /* the result */
111   },
112   "U\r",                                /* download command */
113   "ROM>",                               /* monitor command prompt */
114   "",                                   /* end-of-command delimitor */
115   "",                                   /* optional command terminator */
116   &w89k_ops,                            /* target operations */
117   "xmodem-srec,xmodem-som",             /* load types */
118   w89k_regnames                         /* registers names */
119 };
120
121 void
122 w89k_open(args, from_tty)
123      char *args;
124      int from_tty;
125 {
126   target_preopen(from_tty);
127   push_target  (&w89k_ops);
128   push_monitor (&w89k_cmds);
129   monitor_open (args, "w89k", from_tty);
130 }
131
132 void
133 _initialize_w89k ()
134 {
135   add_target (&w89k_ops);
136
137   /* this is the default, since it's the only baud rate supported by the hardware */
138   baud_rate = 9600;
139 }
140
141
142
143