* remote-mips.c (close_ports, mips_initialize_cleanups)

(mips_exit_cleanups, mips_send_command, mips_open, pmon_open)
	(ddb_open, lsi_open, mips_remove_breakpoint, mips_remove_watchpoint)
	(mips_stopped_by_watchpoint, send_srec, pmon_checkset)
	(pmon_make_fastrec, pmon_check_ack, mips_expect_download)
	(pmon_check_entry_address, pmon_check_total, pmon_end_download)
	(pmon_download, pmon_load_fast, _initialize_remote_mips): Add
	comments describing each of these functions.
	(mips_enter_debug, mips_exit_debug, common_open)
	(mips_signal_from_protocol, pmon_makeb64, pmon_zeroset): Add
	blank line after the comment describing the function.
This commit is contained in:
Kevin Buettner 2010-03-11 03:45:49 +00:00
parent 4c5193b7db
commit 477c84a75f
2 changed files with 131 additions and 0 deletions

View File

@ -1,3 +1,17 @@
2010-03-10 Kevin Buettner <kevinb@redhat.com>
* remote-mips.c (close_ports, mips_initialize_cleanups)
(mips_exit_cleanups, mips_send_command, mips_open, pmon_open)
(ddb_open, lsi_open, mips_remove_breakpoint, mips_remove_watchpoint)
(mips_stopped_by_watchpoint, send_srec, pmon_checkset)
(pmon_make_fastrec, pmon_check_ack, mips_expect_download)
(pmon_check_entry_address, pmon_check_total, pmon_end_download)
(pmon_download, pmon_load_fast, _initialize_remote_mips): Add
comments describing each of these functions.
(mips_enter_debug, mips_exit_debug, common_open)
(mips_signal_from_protocol, pmon_makeb64, pmon_zeroset): Add
blank line after the comment describing the function.
2010-03-10 Jan Kratochvil <jan.kratochvil@redhat.com> 2010-03-10 Jan Kratochvil <jan.kratochvil@redhat.com>
* solib-svr4.c (svr4_exec_displacement): Return now success, new * solib-svr4.c (svr4_exec_displacement): Return now success, new

View File

@ -451,6 +451,9 @@ static int monitor_warnings;
inferior_ptid. */ inferior_ptid. */
static ptid_t remote_mips_ptid; static ptid_t remote_mips_ptid;
/* Close any ports which might be open. Reset certain globals indicating
the state of those ports. */
static void static void
close_ports (void) close_ports (void)
{ {
@ -1290,18 +1293,25 @@ mips_request (int cmd,
return rresponse; return rresponse;
} }
/* Cleanup associated with mips_initialize(). */
static void static void
mips_initialize_cleanups (void *arg) mips_initialize_cleanups (void *arg)
{ {
mips_initializing = 0; mips_initializing = 0;
} }
/* Cleanup associated with mips_exit_debug(). */
static void static void
mips_exit_cleanups (void *arg) mips_exit_cleanups (void *arg)
{ {
mips_exiting = 0; mips_exiting = 0;
} }
/* Send a command and wait for that command to be echoed back. Wait,
too, for the following prompt. */
static void static void
mips_send_command (const char *cmd, int prompt) mips_send_command (const char *cmd, int prompt)
{ {
@ -1313,6 +1323,7 @@ mips_send_command (const char *cmd, int prompt)
} }
/* Enter remote (dbx) debug mode: */ /* Enter remote (dbx) debug mode: */
static void static void
mips_enter_debug (void) mips_enter_debug (void)
{ {
@ -1343,6 +1354,7 @@ mips_enter_debug (void)
} }
/* Exit remote (dbx) debug mode, returning to the monitor prompt: */ /* Exit remote (dbx) debug mode, returning to the monitor prompt: */
static int static int
mips_exit_debug (void) mips_exit_debug (void)
{ {
@ -1505,6 +1517,7 @@ mips_initialize (void)
} }
/* Open a connection to the remote board. */ /* Open a connection to the remote board. */
static void static void
common_open (struct target_ops *ops, char *name, int from_tty, common_open (struct target_ops *ops, char *name, int from_tty,
enum mips_monitor_type new_monitor, enum mips_monitor_type new_monitor,
@ -1629,6 +1642,8 @@ device is attached to the target board (e.g., /dev/ttya).\n"
xfree (serial_port_name); xfree (serial_port_name);
} }
/* Open a connection to an IDT board. */
static void static void
mips_open (char *name, int from_tty) mips_open (char *name, int from_tty)
{ {
@ -1652,12 +1667,16 @@ mips_open (char *name, int from_tty)
common_open (&mips_ops, name, from_tty, MON_IDT, monitor_prompt); common_open (&mips_ops, name, from_tty, MON_IDT, monitor_prompt);
} }
/* Open a connection to a PMON board. */
static void static void
pmon_open (char *name, int from_tty) pmon_open (char *name, int from_tty)
{ {
common_open (&pmon_ops, name, from_tty, MON_PMON, "PMON> "); common_open (&pmon_ops, name, from_tty, MON_PMON, "PMON> ");
} }
/* Open a connection to a DDB board. */
static void static void
ddb_open (char *name, int from_tty) ddb_open (char *name, int from_tty)
{ {
@ -1672,6 +1691,8 @@ rockhopper_open (char *name, int from_tty)
common_open (&rockhopper_ops, name, from_tty, MON_ROCKHOPPER, "NEC01>"); common_open (&rockhopper_ops, name, from_tty, MON_ROCKHOPPER, "NEC01>");
} }
/* Open a connection to an LSI board. */
static void static void
lsi_open (char *name, int from_tty) lsi_open (char *name, int from_tty)
{ {
@ -1735,6 +1756,7 @@ mips_resume (struct target_ops *ops,
/* Return the signal corresponding to SIG, where SIG is the number which /* Return the signal corresponding to SIG, where SIG is the number which
the MIPS protocol uses for the signal. */ the MIPS protocol uses for the signal. */
static enum target_signal static enum target_signal
mips_signal_from_protocol (int sig) mips_signal_from_protocol (int sig)
{ {
@ -2324,6 +2346,8 @@ mips_insert_breakpoint (struct gdbarch *gdbarch,
return memory_insert_breakpoint (gdbarch, bp_tgt); return memory_insert_breakpoint (gdbarch, bp_tgt);
} }
/* Remove a breakpoint. */
static int static int
mips_remove_breakpoint (struct gdbarch *gdbarch, mips_remove_breakpoint (struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt) struct bp_target_info *bp_tgt)
@ -2382,6 +2406,8 @@ mips_insert_watchpoint (CORE_ADDR addr, int len, int type)
return 0; return 0;
} }
/* Remove a watchpoint. */
int int
mips_remove_watchpoint (CORE_ADDR addr, int len, int type) mips_remove_watchpoint (CORE_ADDR addr, int len, int type)
{ {
@ -2391,6 +2417,9 @@ mips_remove_watchpoint (CORE_ADDR addr, int len, int type)
return 0; return 0;
} }
/* Test to see if a watchpoint has been hit. Return 1 if so; return 0,
if not. */
int int
mips_stopped_by_watchpoint (void) mips_stopped_by_watchpoint (void)
{ {
@ -2685,6 +2714,11 @@ mips_common_breakpoint (%s): Got error: 0x%x\n",
return 0; return 0;
} }
/* Send one S record as specified by SREC of length LEN, starting
at ADDR. Note, however, that ADDR is not used except to provide
a useful message to the user in the event that a NACK is received
from the board. */
static void static void
send_srec (char *srec, int len, CORE_ADDR addr) send_srec (char *srec, int len, CORE_ADDR addr)
{ {
@ -2905,6 +2939,7 @@ static char encoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01
at a time (range 0..63). Keep a checksum if required (passed at a time (range 0..63). Keep a checksum if required (passed
pointer non-NULL). The function returns the number of encoded pointer non-NULL). The function returns the number of encoded
characters written into the buffer. */ characters written into the buffer. */
static int static int
pmon_makeb64 (unsigned long v, char *p, int n, int *chksum) pmon_makeb64 (unsigned long v, char *p, int n, int *chksum)
{ {
@ -2949,6 +2984,7 @@ pmon_makeb64 (unsigned long v, char *p, int n, int *chksum)
/* Shorthand function (that could be in-lined) to output the zero-fill /* Shorthand function (that could be in-lined) to output the zero-fill
escape sequence into the data stream. */ escape sequence into the data stream. */
static int static int
pmon_zeroset (int recsize, char **buff, int *amount, unsigned int *chksum) pmon_zeroset (int recsize, char **buff, int *amount, unsigned int *chksum)
{ {
@ -2961,6 +2997,20 @@ pmon_zeroset (int recsize, char **buff, int *amount, unsigned int *chksum)
return (recsize + count + 2); return (recsize + count + 2);
} }
/* Add the checksum specified by *VALUE to end of the record under
construction. *BUF specifies the location at which to begin
writing characters comprising the checksum information. RECSIZE
specifies the size of the record constructed thus far. (A trailing
NUL character may be present in the buffer holding the record, but
the record size does not include this character.)
Return the total size of the record after adding the checksum escape,
the checksum itself, and the trailing newline.
The checksum specified by *VALUE is zeroed out prior to returning.
Additionally, *BUF is updated to refer to the location just beyond
the record elements added by this call. */
static int static int
pmon_checkset (int recsize, char **buff, int *value) pmon_checkset (int recsize, char **buff, int *value)
{ {
@ -2991,6 +3041,32 @@ pmon_checkset (int recsize, char **buff, int *value)
/* NOTE: This constant depends on the monitor being used. This value /* NOTE: This constant depends on the monitor being used. This value
is for PMON 5.x on the Cogent Vr4300 board. */ is for PMON 5.x on the Cogent Vr4300 board. */
/* Create a FastLoad format record.
*OUTBUF is the buffer into which a FastLoad formatted record is
written. On return, the pointer position represented by *OUTBUF
is updated to point at the end of the data, i.e. the next position
in the buffer that may be written. No attempt is made to NUL-
terminate this portion of the record written to the buffer.
INBUF contains the binary input data from which the FastLoad
formatted record will be built. *INPTR is an index into this
buffer. *INPTR is updated as the input is consumed. Thus, on
return, the caller has access to the position of the next input
byte yet to be processed. INAMOUNT is the size, in bytes, of the
input data.
*RECSIZE will be written with the size of the record written to the
output buffer prior to returning. This size does not include a
NUL-termination byte as none is written to the output buffer.
*CSUM is the output buffer checksum. It is updated as data is
written to the output buffer.
*ZEROFILL is the current number of 3-byte zero sequences that have
been encountered. It is both an input and an output to this
function. */
static void static void
pmon_make_fastrec (char **outbuf, unsigned char *inbuf, int *inptr, pmon_make_fastrec (char **outbuf, unsigned char *inbuf, int *inptr,
int inamount, int *recsize, unsigned int *csum, int inamount, int *recsize, unsigned int *csum,
@ -3048,6 +3124,10 @@ pmon_make_fastrec (char **outbuf, unsigned char *inbuf, int *inptr,
return; return;
} }
/* Attempt to read an ACK. If an ACK is not read in a timely manner,
output the message specified by MESG. Return -1 for failure, 0
for success. */
static int static int
pmon_check_ack (char *mesg) pmon_check_ack (char *mesg)
{ {
@ -3090,6 +3170,12 @@ pmon_start_download (void)
} }
} }
/* Look for the string specified by STRING sent from the target board
during a download operation. If the string in question is not
seen, output an error message, remove the temporary file, if
appropriate, and return 0. Otherwise, return 1 to indicate
success. */
static int static int
mips_expect_download (char *string) mips_expect_download (char *string)
{ {
@ -3104,6 +3190,15 @@ mips_expect_download (char *string)
return 1; return 1;
} }
/* Look for messages from the target board associated with the entry
address.
NOTE: This function doesn't indicate success or failure, so we
have no way to determine whether or not the output from the board
was correctly seen. However, given that other items are checked
after this, it seems unlikely that those checks will pass if this
check doesn't first (silently) pass. */
static void static void
pmon_check_entry_address (char *entry_address, int final) pmon_check_entry_address (char *entry_address, int final)
{ {
@ -3114,6 +3209,10 @@ pmon_check_entry_address (char *entry_address, int final)
mips_expect ("\r\n"); mips_expect ("\r\n");
} }
/* Look for messages from the target board showing the total number of
bytes downloaded to the board. Output 1 for success if the tail
end of the message was read correctly, 0 otherwise. */
static int static int
pmon_check_total (int bintotal) pmon_check_total (int bintotal)
{ {
@ -3124,6 +3223,13 @@ pmon_check_total (int bintotal)
return mips_expect_download (" bytes\r\n"); return mips_expect_download (" bytes\r\n");
} }
/* Look for the termination messages associated with the end of
a download to the board.
Also, when `tftp_in_use' is set, issue the load command to the
board causing the file to be transferred. (This is done prior
to looking for the above mentioned termination messages.) */
static void static void
pmon_end_download (int final, int bintotal) pmon_end_download (int final, int bintotal)
{ {
@ -3190,6 +3296,10 @@ pmon_end_download (int final, int bintotal)
remove (tftp_localname); /* Remove temporary file */ remove (tftp_localname); /* Remove temporary file */
} }
/* Write the buffer specified by BUFFER of length LENGTH to either
the board or the temporary file that'll eventually be transferred
to the board. */
static void static void
pmon_download (char *buffer, int length) pmon_download (char *buffer, int length)
{ {
@ -3199,6 +3309,9 @@ pmon_download (char *buffer, int length)
serial_write (udp_in_use ? udp_desc : mips_desc, buffer, length); serial_write (udp_in_use ? udp_desc : mips_desc, buffer, length);
} }
/* Open object or executable file, FILE, and send it to the board
using the FastLoad format. */
static void static void
pmon_load_fast (char *file) pmon_load_fast (char *file)
{ {
@ -3430,6 +3543,10 @@ pmon_command (char *args, int from_tty)
extern initialize_file_ftype _initialize_remote_mips; /* -Wmissing-prototypes */ extern initialize_file_ftype _initialize_remote_mips; /* -Wmissing-prototypes */
/* Initialize mips_ops, lsi_ops, ddb_ops, pmon_ops, and rockhopper_ops.
Create target specific commands and perform other initializations
specific to this file. */
void void
_initialize_remote_mips (void) _initialize_remote_mips (void)
{ {