Memory_reads_inferior() and monitor_fetch_registers() now work good on
[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",  "",     "",    "",    "",
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   0,
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   "\r",                                 /* monitor init string */
86   "G = 100000\r",                       /* execute or usually GO command */
87   "G\r",                                /* continue command */
88   "T\r",                                /* single step */
89   "BP %x\r",                            /* set a breakpoint */
90   "BC %x\r",                            /* clear a breakpoint */
91   {
92     "e %x %x\n",                        /* set memory */
93     "",                                 /* delimiter */
94     "",                                 /* the result */
95   },
96   {
97     "db %x %x\n",                       /* get memory */
98     "",                                 /* delimiter */
99     "",                                 /* the result */
100   },
101   {                                     /* set a register */
102     "r %s %x\n",                        /* set a register */
103     "",                                 /* delimiter between registers */
104     "",                                 /* the result */
105   },
106   {
107     "r %s\r",                           /* get a register */
108     "",                                 /* delimiter between registers */
109     "",                                 /* the result */
110   },
111   "U\r",                                /* download command */
112   "ROM>",                               /* monitor command prompt */
113   "",                                   /* end-of-command delimitor */
114   "",                           /* optional command terminator */
115   &w89k_ops,                            /* target operations */
116   "xmodem-srec,xmodem-som",             /* load types */
117   w89k_regnames                         /* registers names */
118 };
119
120 void
121 w89k_open(args, from_tty)
122      char *args;
123      int from_tty;
124 {
125   target_preopen(from_tty);
126   push_target  (&w89k_ops);
127   push_monitor (&w89k_cmds);
128   monitor_open (args, "w89k", from_tty);
129 }
130
131 void
132 _initialize_w89k ()
133 {
134   add_target (&w89k_ops);
135
136   /* this is the default, since it's the only baud rate supported by the hardware */
137   baud_rate = 9600;
138 }
139
140
141
142