2 * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved.
4 * This software may be freely used, copied, modified, and distributed
5 * provided that the above copyright notice is preserved in all copies of the
11 * Angel Remote Debug Interface
17 * This file is based on /plg/pisd/rdi.c, but instead of using RDP it uses
25 #define uint HIDE_HPs_uint
30 #include "angel_endian.h"
36 #include "angel_bytesex.h"
46 #ifdef COMPILING_ON_WINDOWS
47 # define IGNORE(x) (x = x) /* must go after #includes to work on Windows */
51 #define ADP_INITIAL_TIMEOUT_PERIOD 5
53 static volatile int executing
;
54 static int rdi_log
= 0 ; /* debugging ? */
56 /* we need a starting point for our first buffers, this is a safe one */
57 int Armsd_BufferSize
= ADP_BUFFER_MIN_SIZE
;
58 int Armsd_LongBufSize
= ADP_BUFFER_MIN_SIZE
;
61 extern int interrupted
;
62 extern int swiprocessing
;
65 static char dummycline
= 0;
66 char *ardi_commandline
= &dummycline
; /* exported in ardi.h */
68 extern unsigned int heartbeat_enabled
;
70 static unsigned char *cpwords
[16];
72 typedef struct stoppedProcListElement
{
73 struct stoppedProcListElement
*next
;
74 angel_RDI_TargetStoppedProc
*fn
;
76 } stoppedProcListElement
;
78 static stoppedProcListElement
*stopped_proc_list
=NULL
;
80 const struct Dbg_HostosInterface
*angel_hostif
;
81 static hsys_state
*hstate
;
83 static void angel_DebugPrint(const char *format
, ...)
86 angel_hostif
->dbgprint(angel_hostif
->dbgarg
, format
, ap
);
91 #define TracePrint(s) \
92 if (rdi_log & 2) angel_DebugPrint("\n"); \
93 if (rdi_log & 1) angel_DebugPrint s
98 typedef struct receive_dbgmsg_state
{
99 volatile int received
;
101 } receive_dbgmsg_state
;
103 static receive_dbgmsg_state dbgmsg_state
;
105 static void receive_debug_packet(Packet
*packet
, void *stateptr
)
107 receive_dbgmsg_state
*state
= stateptr
;
109 state
->packet
= packet
;
113 static int register_debug_message_handler(void)
116 dbgmsg_state
.received
= 0;
118 err
= Adp_ChannelRegisterRead(CI_HADP
, receive_debug_packet
, &dbgmsg_state
);
120 if (err
!=adp_ok
) angel_DebugPrint("register_debug_message_handler failed %i\n", err
);
126 static int wait_for_debug_message(int *rcode
, int *debugID
,
127 int *OSinfo1
, int *OSinfo2
,
128 int *status
, Packet
**packet
)
133 angel_DebugPrint("wait_for_debug_message waiting for %X\n", *rcode
);
136 for ( ; dbgmsg_state
.received
== 0 ; )
137 Adp_AsynchronousProcessing(async_block_on_read
);
140 angel_DebugPrint("wait_for_debug_message got packet\n");
143 *packet
= dbgmsg_state
.packet
;
145 Adp_ChannelRegisterRead(CI_HADP
, NULL
, NULL
);
149 * If ADP_Unrecognised return error.
150 * If ADP_Acknowledge - handle appropriately.
151 * If expected message read arguments and return RDIError_NoError.
152 * Note: if RDIError occurs then the data values returned are junk
155 unpack_message(BUFFERDATA((*packet
)->pk_buffer
), "%w%w%w%w%w", &reason
, debugID
,
156 OSinfo1
, OSinfo2
, status
);
157 if (reason
&0xffffff == ADP_HADPUnrecognised
)
158 return RDIError_UnimplementedMessage
;
159 if (reason
!= (unsigned ) *rcode
) {
160 if((reason
&0xffffff) == ADP_HADPUnrecognised
)
161 return RDIError_UnimplementedMessage
;
163 angel_DebugPrint("ARDI ERROR: Expected reasoncode %x got reasoncode %x.\n",
165 return RDIError_Error
;
169 return RDIError_NoError
;
170 return RDIError_Error
; /* stop a pesky ANSI compiler warning */
175 * Handler and registration for logging messages from target
177 static void TargetLogCallback( Packet
*packet
, void *state
)
179 p_Buffer reply
= BUFFERDATA(packet
->pk_buffer
);
180 unsigned int len
= packet
->pk_length
;
182 angel_hostif
->write(angel_hostif
->hostosarg
,
183 (char *)reply
, len
- CHAN_HEADER_SIZE
);
184 DevSW_FreePacket(packet
);
186 packet
= DevSW_AllocatePacket(4); /* better not ask for 0 */
187 /* the reply is the ACK - any contents are ignored */
189 Adp_ChannelWrite( CI_TLOG
, packet
);
192 static void TargetLogInit( void )
194 AdpErrs err
= Adp_ChannelRegisterRead( CI_TLOG
, TargetLogCallback
, NULL
);
198 angel_DebugPrint("CI_TLOG RegisterRead failed %d\n", err
);
204 /*----------------------------------------------------------------------*/
205 /*----angel_RDI_open-----------------------------------------------------*/
206 /*----------------------------------------------------------------------*/
208 typedef struct NegotiateState
{
211 bool link_check_resp
;
212 ParameterConfig
*accepted_config
;
215 static void receive_negotiate(Packet
*packet
, void *stateptr
)
217 unsigned reason
, debugID
, OSinfo1
, OSinfo2
, status
;
218 NegotiateState
*n_state
= (NegotiateState
*)stateptr
;
219 p_Buffer reply
= BUFFERDATA(packet
->pk_buffer
);
221 unpack_message( reply
, "%w%w%w%w",
222 &reason
, &debugID
, &OSinfo1
, &OSinfo2
);
223 reply
+= ADP_DEFAULT_HEADER_SIZE
;
226 angel_DebugPrint( "receive_negotiate: reason %x\n", reason
);
231 case ADP_ParamNegotiate
| TtoH
:
233 n_state
->negotiate_resp
= TRUE
;
235 status
= GET32LE( reply
);
236 reply
+= sizeof(word
);
238 angel_DebugPrint( "ParamNegotiate status %u\n", status
);
240 if ( status
== RDIError_NoError
)
242 if ( Angel_ReadParamConfigMessage(
243 reply
, n_state
->accepted_config
) )
244 n_state
->negotiate_ack
= TRUE
;
249 case ADP_LinkCheck
| TtoH
:
252 angel_DebugPrint( "PONG!\n" );
254 n_state
->link_check_resp
= TRUE
;
261 angel_DebugPrint( "Unexpected!\n" );
266 DevSW_FreePacket( packet
);
269 # include <sys/types.h>
271 # include <sys/time.h>
277 * convert a config into a single-valued options list
279 static ParameterOptions
*config_to_options( const ParameterConfig
*config
)
281 unsigned int num_params
;
283 ParameterOptions
*base_p
;
285 num_params
= config
->num_parameters
;
287 sizeof(ParameterOptions
)
288 + num_params
*(sizeof(ParameterList
) + sizeof(unsigned int));
289 base_p
= malloc( size
);
291 if ( base_p
!= NULL
)
294 ParameterList
*list_p
=
295 (ParameterList
*)((char *)base_p
+ sizeof(ParameterOptions
));
296 unsigned int *option_p
=
297 (unsigned int *)(list_p
+ num_params
);
299 base_p
->num_param_lists
= num_params
;
300 base_p
->param_list
= list_p
;
302 for ( u
= 0; u
< num_params
; ++u
)
304 option_p
[u
] = config
->param
[u
].value
;
305 list_p
[u
].type
= config
->param
[u
].type
;
306 list_p
[u
].num_options
= 1;
307 list_p
[u
].option
= &option_p
[u
];
314 static AdpErrs
negotiate_params( const ParameterOptions
*user_options
)
318 static Parameter params
[AP_NUM_PARAMS
];
319 static ParameterConfig accepted_config
= { AP_NUM_PARAMS
, params
};
323 static volatile NegotiateState n_state
;
324 n_state
.negotiate_resp
= FALSE
;
325 n_state
.negotiate_ack
= FALSE
;
326 n_state
.link_check_resp
= FALSE
;
327 n_state
.accepted_config
= &accepted_config
;
330 angel_DebugPrint( "negotiate_params\n" );
333 Adp_ChannelRegisterRead( CI_HBOOT
, receive_negotiate
, (void *)&n_state
);
335 packet
= (Packet
*)DevSW_AllocatePacket(Armsd_BufferSize
);
336 count
= msgbuild( BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w",
337 ADP_ParamNegotiate
| HtoT
, 0,
338 ADP_HandleUnknown
, ADP_HandleUnknown
);
339 count
+= Angel_BuildParamOptionsMessage(
340 BUFFERDATA(packet
->pk_buffer
) + count
, user_options
);
341 packet
->pk_length
= count
;
342 Adp_ChannelWriteAsync( CI_HBOOT
, packet
);
345 angel_DebugPrint( "sent negotiate packet\n" );
351 Adp_AsynchronousProcessing(async_block_on_nothing
);
353 if ((time(NULL
)-t
) > ADP_INITIAL_TIMEOUT_PERIOD
) {
354 return adp_timeout_on_open
;
356 } while ( ! n_state
.negotiate_resp
);
358 if ( n_state
.negotiate_ack
)
360 /* select accepted config */
361 Adp_Ioctl( DC_SET_PARAMS
, (void *)n_state
.accepted_config
);
366 * There is a race in the renegotiation protocol: the
367 * target has to have had time to load new config before
368 * we send the link check packet - insert a deliberate
369 * pause (100ms) to give the target some time
374 msgsend( CI_HBOOT
, "%w%w%w%w", ADP_LinkCheck
| HtoT
, 0,
375 ADP_HandleUnknown
, ADP_HandleUnknown
);
377 angel_DebugPrint("sent link check\n");
381 Adp_AsynchronousProcessing(async_block_on_read
);
382 } while ( ! n_state
.link_check_resp
);
388 static int late_booted
= FALSE
;
389 static bool ardi_handler_installed
= FALSE
;
392 static struct sigaction old_action
;
394 static void (*old_handler
)();
397 static bool boot_interrupted
= FALSE
;
398 static volatile bool interrupt_request
= FALSE
;
399 static volatile bool stop_request
= FALSE
;
401 static void ardi_sigint_handler(int sig
) {
404 angel_DebugPrint("Expecting SIGINT got %d.\n", sig
);
408 boot_interrupted
= TRUE
;
409 interrupt_request
= TRUE
;
411 signal(SIGINT
, ardi_sigint_handler
);
415 static void install_ardi_handler( void ) {
416 if (!ardi_handler_installed
) {
417 /* install a new Ctrl-C handler so we can abandon waiting */
419 struct sigaction new_action
;
420 sigemptyset(&new_action
.sa_mask
);
421 new_action
.sa_handler
= ardi_sigint_handler
;
422 new_action
.sa_flags
= 0;
423 sigaction(SIGINT
, &new_action
, &old_action
);
425 old_handler
= signal(SIGINT
, ardi_sigint_handler
);
427 ardi_handler_installed
= TRUE
;
431 static int angel_RDI_errmess(char *buf
, int blen
, int errnum
);
433 static void receive_reset_acknowledge(Packet
*packet
, void *stateptr
) {
434 unsigned reason
, debugID
, OSinfo1
, OSinfo2
, status
;
437 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
, &debugID
,
438 &OSinfo1
, &OSinfo2
, &status
);
439 if (reason
==(ADP_Reset
| TtoH
) && status
==AB_NORMAL_ACK
) {
441 angel_DebugPrint("DEBUG: Successfully received normal reset acknowledgement\n");
444 } else if (reason
==(ADP_Reset
| TtoH
) && status
==AB_LATE_ACK
) {
445 char late_msg
[AdpMessLen_LateStartup
];
448 angel_DebugPrint("DEBUG: Successfully received LATE reset acknowledgement\n");
451 install_ardi_handler();
452 late_len
= angel_RDI_errmess(late_msg
,
453 AdpMessLen_LateStartup
, adp_late_startup
);
454 angel_hostif
->write(angel_hostif
->hostosarg
, late_msg
, late_len
);
457 angel_DebugPrint("DEBUG: Bad reset ack: reason=%8X, status=%8X\n", reason
, status
);
460 DevSW_FreePacket(packet
);
463 static int booted_not_received
;
464 static unsigned int angel_version
;
465 static unsigned int adp_version
;
466 static unsigned int arch_info
;
467 static unsigned int cpu_info
;
468 static unsigned int hw_status
;
470 static void receive_booted(Packet
*packet
, void *stateptr
) {
471 unsigned reason
, debugID
, OSinfo1
, OSinfo2
, banner_length
, bufsiz
, longsiz
;
476 count
= unpack_message(BUFFERDATA(packet
->pk_buffer
),
477 "%w%w%w%w%w%w%w%w%w%w%w%w",
478 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &bufsiz
, &longsiz
,
479 &angel_version
, &adp_version
,
480 &arch_info
, &cpu_info
, &hw_status
, &banner_length
);
481 if (reason
==(ADP_Booted
| TtoH
)) {
482 #ifdef MONITOR_DOWNLOAD_PACKETS
483 angel_DebugPrint("DEBUG: Successfully received Booted\n");
484 angel_DebugPrint(" cpu_info=%8X, hw_status=%8X, bufsiz=%d, longsiz=%d\n",
485 cpu_info
, hw_status
, bufsiz
, longsiz
);
487 /* Get the banner from the booted message */
488 for (i
=0; i
<banner_length
; i
++)
489 angel_hostif
->writec(angel_hostif
->hostosarg
,
490 (BUFFERDATA(packet
->pk_buffer
)+count
)[i
]);
492 booted_not_received
=0;
494 heartbeat_enabled
= TRUE
;
496 Armsd_BufferSize
= bufsiz
+ CHAN_HEADER_SIZE
;
497 Armsd_LongBufSize
= longsiz
+ CHAN_HEADER_SIZE
;
500 angel_DebugPrint("DEBUG: Bad Booted msg: reason=%8X\n", reason
);
503 DevSW_FreePacket(packet
);
507 /* forward declaration */
508 static int angel_negotiate_defaults( void );
510 /* Open communications. */
512 unsigned type
, Dbg_ConfigBlock
const *config
,
513 Dbg_HostosInterface
const *hostif
, struct Dbg_MCState
*dbg_state
)
516 int status
, reasoncode
, debugID
, OSinfo1
, OSinfo2
, err
;
517 ParameterOptions
*user_options
= NULL
;
523 if ((type
& 1) == 0) {
525 if (hostif
!= NULL
) {
526 angel_hostif
= hostif
;
527 err
= HostSysInit(hostif
, &ardi_commandline
, &hstate
);
528 if (err
!= RDIError_NoError
) {
530 angel_DebugPrint("DEBUG: HostSysInit error %i\n",err
);
539 angel_DebugPrint("DEBUG: Buffer allocated in angel_RDI_open(type=%i).\n",type
);
542 if ((type
& 1) == 0) {
545 Adp_Ioctl( DC_GET_USER_PARAMS
, (void *)&user_options
);
546 if ( user_options
!= NULL
) {
547 err
= negotiate_params( user_options
);
548 if (err
!= adp_ok
) return err
;
551 ParameterConfig
*default_config
= NULL
;
552 Adp_Ioctl( DC_GET_DEFAULT_PARAMS
, (void *)&default_config
);
553 if ( default_config
!= NULL
) {
554 ParameterOptions
*default_options
= config_to_options(default_config
);
555 err
= negotiate_params( default_options
);
556 if (err
!= adp_ok
) return err
;
560 /* Register handlers before sending any messages */
561 booted_not_received
=1;
562 Adp_ChannelRegisterRead(CI_HBOOT
, receive_reset_acknowledge
, NULL
);
563 Adp_ChannelRegisterRead(CI_TBOOT
, receive_booted
, NULL
);
566 if (config
->bytesex
& RDISex_Little
) endian
|= ADP_BootHostFeature_LittleEnd
;
567 if (config
->bytesex
& RDISex_Big
) endian
|= ADP_BootHostFeature_BigEnd
;
569 msgsend(CI_HBOOT
,"%w%w%w%w%w", ADP_Reset
| HtoT
, 0,
570 ADP_HandleUnknown
, ADP_HandleUnknown
, endian
);
572 angel_DebugPrint("DEBUG: Transmitted Reset message in angel_RDI_open.\n");
575 /* We will now either get an acknowledgement for the Reset message
576 * or if the target was started after the host, we will get a
577 * rebooted message first.
581 angel_DebugPrint("DEBUG: waiting for a booted message\n");
585 boot_interrupted
= FALSE
;
588 install_ardi_handler();
593 Adp_AsynchronousProcessing(async_block_on_nothing
);
594 if ((time(NULL
)-t
) > ADP_INITIAL_TIMEOUT_PERIOD
&& !late_booted
) {
595 return adp_timeout_on_open
;
597 } while (booted_not_received
&& !boot_interrupted
);
599 if (ardi_handler_installed
)
601 /* uninstall our Ctrl-C handler */
603 sigaction(SIGINT
, &old_action
, NULL
);
605 signal(SIGINT
, old_handler
);
609 if (boot_interrupted
) {
610 angel_negotiate_defaults();
611 return adp_abandon_boot_wait
;
615 booted_not_received
=1;
616 Adp_ChannelRegisterRead(CI_HBOOT
, NULL
, NULL
);
618 /* Leave the booted handler installed */
619 msgsend(CI_TBOOT
, "%w%w%w%w%w", ADP_Booted
| HtoT
, 0,
620 ADP_HandleUnknown
, ADP_HandleUnknown
, 0);
623 angel_DebugPrint("DEBUG: Transmitted ADP_Booted acknowledgement.\n");
624 angel_DebugPrint("DEBUG: Boot sequence completed, leaving angel_RDI_open.\n");
627 return (hw_status
& ADP_CPU_BigEndian
)? RDIError_BigEndian
:
628 RDIError_LittleEndian
;
632 register_debug_message_handler();
634 msgsend(CI_HADP
, "%w%w%w%w",
635 ADP_InitialiseApplication
| HtoT
, 0,
636 ADP_HandleUnknown
, ADP_HandleUnknown
);
638 angel_DebugPrint("DEBUG: Transmitted Initialise Application\n");
640 reasoncode
=ADP_InitialiseApplication
| TtoH
;
641 err
= wait_for_debug_message(&reasoncode
, &debugID
, &OSinfo1
, &OSinfo2
,
643 if (err
!= RDIError_NoError
) return err
;
650 /*----------------------------------------------------------------------*/
651 /*----angel_RDI_close----------------------------------------------------*/
652 /*----------------------------------------------------------------------*/
654 static int angel_negotiate_defaults( void ) {
656 ParameterConfig
*default_config
= NULL
;
657 Adp_Ioctl( DC_GET_DEFAULT_PARAMS
, (void *)&default_config
);
658 if ( default_config
!= NULL
) {
659 ParameterOptions
*default_options
= config_to_options(default_config
);
660 err
= negotiate_params( default_options
);
661 free( default_options
);
666 int angel_RDI_close(void) {
669 int status
,debugID
, OSinfo1
,OSinfo2
;
671 Packet
*packet
= NULL
;;
673 angel_DebugPrint("DEBUG: Entered angel_RDI_Close.\n");
676 register_debug_message_handler();
678 heartbeat_enabled
= FALSE
;
680 err
= msgsend(CI_HADP
,"%w%w%w%w",ADP_End
| HtoT
,0,
681 ADP_HandleUnknown
, ADP_HandleUnknown
);
682 if (err
!= RDIError_NoError
) return err
;
683 reason
= ADP_End
| TtoH
;
684 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
686 DevSW_FreePacket(packet
);
687 if (err
!= RDIError_NoError
) return err
;
688 if (status
== RDIError_NoError
) {
689 err
= angel_negotiate_defaults();
690 if (err
!= adp_ok
) return err
;
691 Adp_Ioctl( DC_RESET
, NULL
); /* just to be safe */
692 return HostSysExit(hstate
);
699 /*----------------------------------------------------------------------*/
700 /*----angel_RDI_read-----------------------------------------------------*/
701 /*----------------------------------------------------------------------*/
703 /* Read memory contents from target to host: use ADP_Read */
704 int angel_RDI_read(ARMword source
, void *dest
, unsigned *nbytes
)
707 int len
; /* Integer to hold message length. */
708 unsigned int nbtogo
= *nbytes
, nbinpacket
, nbdone
=0;
709 int rnbytes
= 0, status
, reason
, debugID
, OSinfo1
, OSinfo2
, err
;
710 unsigned int maxlen
= Armsd_BufferSize
-CHAN_HEADER_SIZE
-ADP_ReadHeaderSize
;
712 /* Print debug trace information, this is just copied straight from rdi.c
713 and I can see no reason why it should have to be changed. */
714 TracePrint(("angel_RDI_read: source=%.8lx dest=%p nbytes=%.8x\n",
715 (unsigned long)source
, dest
, *nbytes
));
716 if (*nbytes
== 0) return RDIError_NoError
; /* Read nothing - easy! */
717 /* check the buffer size */
719 register_debug_message_handler();
721 nbinpacket
= (nbtogo
<= maxlen
) ? nbtogo
: maxlen
;
722 len
= msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Read
| HtoT
, 0,
723 ADP_HandleUnknown
, ADP_HandleUnknown
, source
+nbdone
,
725 reason
=ADP_Read
| TtoH
;
726 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
728 TracePrint(("angel_RDI_read: nbinpacket =%d status=%08x err = %d\n",
729 nbinpacket
,status
,err
));
730 if (err
!= RDIError_NoError
) return err
; /* Was there an error? */
731 if (status
== RDIError_NoError
){
732 rnbytes
+= PREAD(LE
,(unsigned int *)(BUFFERDATA(packet
->pk_buffer
)+20));
733 TracePrint(("angel_RDI_read: rnbytes = %d\n",rnbytes
));
734 memcpy(((unsigned char *)dest
)+nbdone
, BUFFERDATA(packet
->pk_buffer
)+24,
737 nbdone
+= nbinpacket
;
738 nbtogo
-= nbinpacket
;
745 /*----------------------------------------------------------------------*/
746 /*----angel_RDI_write----------------------------------------------------*/
747 /*----------------------------------------------------------------------*/
749 /* Transfer memory block from host to target. Use ADP_Write>. */
750 int angel_RDI_write(const void *source
, ARMword dest
, unsigned *nbytes
)
752 Packet
*packet
;/* Message buffers. */
753 unsigned int len
, nbtogo
= *nbytes
, nboffset
= 0, nbinpacket
;
754 int status
, reason
, debugID
, OSinfo1
, OSinfo2
, err
;
755 unsigned int maxlen
= Armsd_LongBufSize
-CHAN_HEADER_SIZE
-ADP_WriteHeaderSize
;
757 TracePrint(("angel_RDI_write: source=%p dest=%.8lx nbytes=%.8x\n",
758 source
, (unsigned long)dest
, *nbytes
));
760 if (*nbytes
== 0) return RDIError_NoError
;
764 packet
= (Packet
*) DevSW_AllocatePacket(Armsd_LongBufSize
);
765 nbinpacket
= (nbtogo
<= maxlen
) ? nbtogo
: maxlen
;
766 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w",
767 ADP_Write
| HtoT
, 0, ADP_HandleUnknown
,
768 ADP_HandleUnknown
, dest
+nboffset
, nbinpacket
);
769 /* Copy the data into the packet. */
771 memcpy(BUFFERDATA(packet
->pk_buffer
)+len
,
772 ((const unsigned char *) source
)+nboffset
, nbinpacket
);
773 nboffset
+= nbinpacket
;
774 packet
->pk_length
= nbinpacket
+len
;
776 #ifdef MONITOR_DOWNLOAD_PACKETS
777 angel_DebugPrint("angel_RDI_write packet size=%i, bytes done=%i\n",
778 nbinpacket
, nboffset
);
781 register_debug_message_handler();
782 Adp_ChannelWrite(CI_HADP
, packet
);
783 reason
=ADP_Write
| TtoH
;
784 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
786 nbtogo
-= nbinpacket
;
787 if (err
!= RDIError_NoError
) return err
;
788 if (status
== RDIError_NoError
)
789 *nbytes
+= nbinpacket
;
791 DevSW_FreePacket(packet
);
797 /*----------------------------------------------------------------------*/
798 /*----angel_RDI_CPUread--------------------------------------------------*/
799 /*----------------------------------------------------------------------*/
801 /* Reads the values of registers in the CPU, uses ADP_CPUwrite. */
802 int angel_RDI_CPUread(unsigned mode
, unsigned long mask
, ARMword
*buffer
)
805 Packet
*packet
= NULL
;
806 int err
, status
, reason
, debugID
, OSinfo1
, OSinfo2
;
808 angel_DebugPrint("DEBUG: Entered angel_RDI_CPUread.\n");
810 for (i
=0, j
=0 ; i
< RDINumCPURegs
; i
++)
811 if (mask
& (1L << i
)) j
++; /* Count the number of registers. */
813 register_debug_message_handler();
814 msgsend(CI_HADP
, "%w%w%w%w%c%w", ADP_CPUread
| HtoT
, 0,
815 ADP_HandleUnknown
, ADP_HandleUnknown
, mode
, mask
);
816 reason
= ADP_CPUread
| TtoH
;
817 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
819 if (err
!= RDIError_NoError
) {
820 DevSW_FreePacket(packet
);
823 if(status
== RDIError_NoError
) {
825 buffer
[i
] = GET32LE(BUFFERDATA(packet
->pk_buffer
)+20+(i
*4));
826 TracePrint(("angel_RDI_CPUread: mode=%.8x mask=%.8lx", mode
, mask
));
827 DevSW_FreePacket(packet
);
831 for (k
= 0, j
= 0 ; j
<= 20 ; j
++)
832 if (mask
& (1L << j
)) {
833 angel_DebugPrint("%c%.8lx",k
%4==0?'\n':' ',
834 (unsigned long)buffer
[k
]);
837 angel_DebugPrint("\n") ;
845 /*----------------------------------------------------------------------*/
846 /*----angel_RDI_CPUwrite-------------------------------------------------*/
847 /*----------------------------------------------------------------------*/
849 /* Write CPU registers: use ADP_CPUwrite. */
850 int angel_RDI_CPUwrite(unsigned mode
, unsigned long mask
,
851 ARMword
const *buffer
){
855 int status
, reason
, debugID
, OSinfo1
, OSinfo2
, err
, len
;
857 TracePrint(("angel_RDI_CPUwrite: mode=%.8x mask=%.8lx", mode
, mask
));
860 for (j
= 0, i
= 0 ; i
<= 20 ; i
++)
861 if (mask
& (1L << i
)) {
862 angel_DebugPrint("%c%.8lx",j
%4==0?'\n':' ',
863 (unsigned long)buffer
[j
]);
866 angel_DebugPrint("\n") ;
869 packet
= (Packet
*)DevSW_AllocatePacket(Armsd_BufferSize
);
870 for (i
=0, j
=0; i
< RDINumCPURegs
; i
++)
871 if (mask
& (1L << i
)) j
++; /* count the number of registers */
873 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%b%w",
874 ADP_CPUwrite
| HtoT
, 0,
875 ADP_HandleUnknown
, ADP_HandleUnknown
, mode
, mask
);
877 PUT32LE(BUFFERDATA(packet
->pk_buffer
)+len
+(c
*4), buffer
[c
]);
878 packet
->pk_length
= len
+(j
*4);
879 register_debug_message_handler();
881 Adp_ChannelWrite(CI_HADP
, packet
);
882 reason
= ADP_CPUwrite
| TtoH
;
883 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
885 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
, &debugID
,
886 &OSinfo1
, &OSinfo2
, &status
);
887 DevSW_FreePacket(packet
);
888 if (err
!= RDIError_NoError
)
889 return err
; /* Was there an error? */
895 /*----------------------------------------------------------------------*/
896 /*----angel_RDI_CPread---------------------------------------------------*/
897 /*----------------------------------------------------------------------*/
899 /* Read coprocessor's internal state. See dbg_cp.h for help.
901 * It would appear that the correct behaviour at this point is to leave
902 * the unpacking to a the caller and to simply copy the stream of data
903 * words into the buffer
906 int angel_RDI_CPread(unsigned CPnum
, unsigned long mask
, ARMword
*buffer
){
907 Packet
*packet
= NULL
;
908 int i
, j
, status
, reasoncode
, OSinfo1
, OSinfo2
, err
, debugID
;
909 unsigned char *rmap
= cpwords
[CPnum
];
912 angel_DebugPrint("DEBUG: Entered angel_RDI_CPread.\n");
914 if (rmap
== NULL
) return RDIError_UnknownCoPro
;
916 register_debug_message_handler();
918 msgsend(CI_HADP
, "%w%w%w%w%b%w", ADP_CPread
| HtoT
, 0,
919 ADP_HandleUnknown
, ADP_HandleUnknown
, CPnum
, mask
);
920 reasoncode
=ADP_CPread
| TtoH
;
921 err
= wait_for_debug_message(&reasoncode
, &debugID
, &OSinfo1
, &OSinfo2
,
923 if (err
!= RDIError_NoError
) {
924 DevSW_FreePacket(packet
);
925 return err
; /* Was there an error? */
927 for (j
=i
=0; i
< n
; i
++) /* count the number of registers */
928 if (mask
& (1L << i
)) {
932 buffer
[i
] = PREAD32(LE
, BUFFERDATA(packet
->pk_buffer
) + 20 + (i
*4));
933 DevSW_FreePacket(packet
);
934 TracePrint(("angel_RDI_CPread: CPnum=%.8x mask=%.8lx\n", CPnum
, mask
));
937 for (i
= 0, j
= 0; j
< n
; j
++) {
938 if (mask
& (1L << j
)) {
940 angel_DebugPrint("%2d ", j
);
942 angel_DebugPrint("%.8lx ", (unsigned long)buffer
[i
++]);
943 angel_DebugPrint("%.8lx\n", (unsigned long)buffer
[i
++]);
952 /*----------------------------------------------------------------------*/
953 /*----angel_RDI_CPwrite--------------------------------------------------*/
954 /*----------------------------------------------------------------------*/
956 /* Write coprocessor's internal state. See dbg_cp.h for help. Use
960 int angel_RDI_CPwrite(unsigned CPnum
, unsigned long mask
,
961 ARMword
const *buffer
)
963 Packet
*packet
= NULL
;
964 int i
, j
, len
, status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
965 unsigned char *rmap
= cpwords
[CPnum
];
968 if (rmap
== NULL
) return RDIError_UnknownCoPro
;
971 TracePrint(("angel_RDI_CPwrite: CPnum=%d mask=%.8lx\n", CPnum
, mask
));
975 for (i
= 0, j
= 0; j
< n
; j
++)
976 if (mask
& (1L << j
)) {
978 angel_DebugPrint("%2d ", j
);
980 angel_DebugPrint("%.8lx ", (unsigned long)buffer
[i
++]);
981 angel_DebugPrint("%.8lx\n", (unsigned long)buffer
[i
++]);
986 for (j
=i
=0; i
< n
; i
++) /* Count the number of registers. */
987 if (mask
& (1L << i
)) j
++;
988 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
989 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%c%w",
990 ADP_CPwrite
| HtoT
, 0,
991 ADP_HandleUnknown
, ADP_HandleUnknown
, CPnum
, mask
);
993 len
+=msgbuild(BUFFERDATA(packet
->pk_buffer
) + len
, "%w", buffer
[i
]);
994 packet
->pk_length
= len
;
995 register_debug_message_handler();
996 Adp_ChannelWrite(CI_HADP
, packet
); /* Transmit message. */
997 reason
=ADP_CPwrite
| TtoH
;
998 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1000 DevSW_FreePacket(packet
);
1001 if (err
!= RDIError_NoError
)
1008 /*----------------------------------------------------------------------*/
1009 /*----angel_RDI_pointinq-------------------------------------------------*/
1010 /*----------------------------------------------------------------------*/
1012 /* Do test calls to ADP_SetBreak/ADP_SetWatch to see if resources exist to
1013 carry out request. */
1014 int angel_RDI_pointinq(ARMword
*address
, unsigned type
, unsigned datatype
,
1017 Packet
*packet
= NULL
;
1018 int len
, status
, reason
, OSinfo1
, OSinfo2
, err
=RDIError_NoError
;
1019 /* stop a compiler warning */
1020 int debugID
, pointhandle
;
1022 ("angel_RDI_pointinq: address=%.8lx type=%d datatype=%d bound=%.8lx ",
1023 (unsigned long)*address
, type
, datatype
, (unsigned long)*bound
));
1025 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
1026 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%b",
1027 ((datatype
== 0) ? ADP_SetBreak
: ADP_SetWatch
) | HtoT
, 0,
1028 ADP_HandleUnknown
, ADP_HandleUnknown
, address
, type
);
1030 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
) + 21, "%w", bound
);
1032 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
) + 21, "%b%w", datatype
, bound
);
1034 register_debug_message_handler();
1035 packet
->pk_length
= len
;
1036 Adp_ChannelWrite(CI_HADP
, packet
);
1037 reason
= ((datatype
== 0) ? ADP_SetBreak
: ADP_SetWatch
| TtoH
);
1038 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1040 if (err
!= RDIError_NoError
) {
1041 DevSW_FreePacket(packet
);
1042 return err
; /* Was there an error? */
1044 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
1045 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &status
,
1046 &pointhandle
, &address
, &bound
);
1047 DevSW_FreePacket(packet
);
1052 /*----------------------------------------------------------------------*/
1053 /*----angel_RDI_setbreak-------------------------------------------------*/
1054 /*----------------------------------------------------------------------*/
1056 /* Set a breakpoint: Use ADP_SetBreak */
1057 int angel_RDI_setbreak(ARMword address
, unsigned type
, ARMword bound
,
1058 PointHandle
*handle
)
1060 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1061 int tmpval
, tmpaddr
, tmpbnd
;
1063 TracePrint(("angel_RDI_setbreak address=%.8lx type=%d bound=%.8lx \n",
1064 (unsigned long)address
, type
, (unsigned long)bound
));
1066 register_debug_message_handler();
1067 msgsend(CI_HADP
, "%w%w%w%w%w%b%w",
1068 ADP_SetBreak
| HtoT
, 0, ADP_HandleUnknown
,
1069 ADP_HandleUnknown
, address
, type
, bound
);
1070 reason
= ADP_SetBreak
|TtoH
;
1071 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1073 if (err
!= RDIError_NoError
) {
1074 DevSW_FreePacket(packet
);
1075 return err
; /* Was there an error? */
1077 /* Work around varargs problem... -sts */
1078 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
1079 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &status
,
1080 &tmpval
, &tmpaddr
, &tmpbnd
);
1084 DevSW_FreePacket(packet
);
1085 if (status
!= RDIError_NoError
) return status
;
1086 TracePrint(("returns handle %.8lx\n", (unsigned long)*handle
));
1087 return RDIError_NoError
;
1091 /*----------------------------------------------------------------------*/
1092 /*----angel_RDI_clearbreak-----------------------------------------------*/
1093 /*----------------------------------------------------------------------*/
1095 /* Clear a breakpoint: Use ADP_ClearBreak. */
1096 int angel_RDI_clearbreak(PointHandle handle
)
1098 Packet
*packet
= NULL
;
1099 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1101 TracePrint(("angel_RDI_clearbreak: handle=%.8lx\n", (unsigned long)handle
));
1103 register_debug_message_handler();
1104 msgsend(CI_HADP
, "%w%w%w%w%w",
1105 ADP_ClearBreak
| HtoT
, 0, ADP_HandleUnknown
,
1106 ADP_HandleUnknown
, handle
);
1107 reason
= ADP_ClearBreak
|TtoH
;
1108 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1110 if (err
!= RDIError_NoError
) {
1111 DevSW_FreePacket(packet
);
1112 angel_DebugPrint("***RECEIVE DEBUG MESSAGE RETURNED ERR = %d.\n", err
);
1113 return err
; /* Was there an error? */
1115 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
,
1116 &debugID
, &OSinfo1
, &OSinfo2
, &status
);
1117 DevSW_FreePacket(packet
);
1119 angel_DebugPrint("DEBUG: Clear Break completed OK.\n");
1121 return RDIError_NoError
;
1125 /*----------------------------------------------------------------------*/
1126 /*----angel_RDI_setwatch-------------------------------------------------*/
1127 /*----------------------------------------------------------------------*/
1129 /* Set a watchpoint: use ADP_SetWatch. */
1130 int angel_RDI_setwatch(ARMword address
, unsigned type
, unsigned datatype
,
1131 ARMword bound
, PointHandle
*handle
)
1133 Packet
*packet
= NULL
;
1134 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1136 TracePrint(("angel_RDI_setwatch: address=%.8lx type=%d bound=%.8lx ",
1137 (unsigned long)address
, type
, (unsigned long)bound
));
1139 register_debug_message_handler();
1140 msgsend(CI_HADP
, "%w%w%w%w%w%b%b%w",
1141 ADP_SetWatch
| HtoT
, 0, ADP_HandleUnknown
,
1142 ADP_HandleUnknown
, address
, type
, datatype
, bound
);
1144 reason
= ADP_SetWatch
| TtoH
;
1145 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1147 if (err
!= RDIError_NoError
) {
1148 DevSW_FreePacket(packet
);
1149 return err
; /* Was there an error? */
1151 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
1152 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &status
,
1153 handle
, &address
, &bound
);
1154 DevSW_FreePacket(packet
);
1155 TracePrint(("returns handle %.8lx\n", (unsigned long)*handle
));
1156 return RDIError_NoError
;
1159 /*----------------------------------------------------------------------*/
1160 /*----angel_RDI_clearwatch-----------------------------------------------*/
1161 /*----------------------------------------------------------------------*/
1163 /* Clear a watchpoint: use ADP_ClearWatch. */
1164 int angel_RDI_clearwatch(PointHandle handle
) {
1166 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1167 Packet
*packet
= NULL
;
1169 TracePrint(("angel_RDI_clearwatch: handle=%.8lx\n", (unsigned long)handle
));
1171 register_debug_message_handler();
1172 msgsend(CI_HADP
, "%w%w%w%w%w",
1173 ADP_ClearWatch
| HtoT
, 0, ADP_HandleUnknown
,
1174 ADP_HandleUnknown
, handle
);
1175 reason
= ADP_ClearWatch
|TtoH
;
1176 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1178 if (err
!= RDIError_NoError
) {
1179 DevSW_FreePacket(packet
);
1180 return err
; /* Was there an error? */
1182 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
, &debugID
,
1183 &OSinfo1
, &OSinfo2
, &status
);
1184 DevSW_FreePacket(packet
);
1185 return RDIError_NoError
;
1189 unsigned stopped_reason
;
1192 } adp_stopped_struct
;
1195 int angel_RDI_OnTargetStopping(angel_RDI_TargetStoppedProc
*fn
,
1198 stoppedProcListElement
**lptr
= &stopped_proc_list
;
1200 /* Find the address of the NULL ptr at the end of the list */
1201 for (; *lptr
!=NULL
; lptr
= &((*lptr
)->next
))
1204 *lptr
= (stoppedProcListElement
*) malloc(sizeof(stoppedProcListElement
));
1205 if (*lptr
== NULL
) return RDIError_OutOfStore
;
1209 return RDIError_NoError
;
1212 static int CallStoppedProcs(unsigned reason
)
1214 stoppedProcListElement
*p
= stopped_proc_list
;
1215 int err
=RDIError_NoError
;
1217 for (; p
!=NULL
; p
=p
->next
) {
1218 int local_err
= p
->fn(reason
, p
->arg
);
1219 if (local_err
!= RDIError_NoError
) err
=local_err
;
1225 /*----------------------------------------------------------------------*/
1226 /*----angel_RDI_execute--------------------------------------------------*/
1227 /*----------------------------------------------------------------------*/
1229 static int HandleStoppedMessage(Packet
*packet
, void *stateptr
) {
1230 unsigned int err
, reason
, debugID
, OSinfo1
, OSinfo2
, count
;
1231 adp_stopped_struct
*stopped_info
;
1232 stopped_info
= (adp_stopped_struct
*) stateptr
;
1234 count
= unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w",
1237 &stopped_info
->stopped_reason
, &stopped_info
->data
);
1238 DevSW_FreePacket(packet
);
1240 if (reason
!= (ADP_Stopped
| TtoH
)) {
1242 angel_DebugPrint("Expecting stopped message, got %x", reason
);
1244 return RDIError_Error
;
1249 angel_DebugPrint("Received stopped message.\n");
1253 err
= msgsend(CI_TADP
, "%w%w%w%w%w", (ADP_Stopped
| HtoT
), 0,
1254 ADP_HandleUnknown
, ADP_HandleUnknown
, RDIError_NoError
);
1256 angel_DebugPrint("Transmiting stopped acknowledge.\n");
1258 if (err
!= RDIError_NoError
) angel_DebugPrint("Transmit failed.\n");
1260 angel_DebugPrint("DEBUG: Stopped reason : %x\n", stopped_info
->stopped_reason
);
1262 switch (stopped_info
->stopped_reason
) {
1263 case ADP_Stopped_BranchThroughZero
:
1264 stopped_info
->stopped_status
= RDIError_BranchThrough0
;
1266 case ADP_Stopped_UndefinedInstr
:
1267 stopped_info
->stopped_status
= RDIError_UndefinedInstruction
;
1269 case ADP_Stopped_SoftwareInterrupt
:
1270 stopped_info
->stopped_status
= RDIError_SoftwareInterrupt
;
1272 case ADP_Stopped_PrefetchAbort
:
1273 stopped_info
->stopped_status
= RDIError_PrefetchAbort
;
1275 case ADP_Stopped_DataAbort
:
1276 stopped_info
->stopped_status
= RDIError_DataAbort
;
1278 case ADP_Stopped_AddressException
:
1279 stopped_info
->stopped_status
= RDIError_AddressException
;
1281 case ADP_Stopped_IRQ
:
1282 stopped_info
->stopped_status
= RDIError_IRQ
;
1284 case ADP_Stopped_BreakPoint
:
1285 stopped_info
->stopped_status
= RDIError_BreakpointReached
;
1287 case ADP_Stopped_WatchPoint
:
1288 stopped_info
->stopped_status
= RDIError_WatchpointAccessed
;
1290 case ADP_Stopped_StepComplete
:
1291 stopped_info
->stopped_status
= RDIError_ProgramFinishedInStep
;
1293 case ADP_Stopped_RunTimeErrorUnknown
:
1294 case ADP_Stopped_StackOverflow
:
1295 case ADP_Stopped_DivisionByZero
:
1296 stopped_info
->stopped_status
= RDIError_Error
;
1298 case ADP_Stopped_FIQ
:
1299 stopped_info
->stopped_status
= RDIError_FIQ
;
1301 case ADP_Stopped_UserInterruption
:
1302 case ADP_Stopped_OSSpecific
:
1303 stopped_info
->stopped_status
= RDIError_UserInterrupt
;
1305 case ADP_Stopped_ApplicationExit
:
1306 stopped_info
->stopped_status
= RDIError_NoError
;
1309 stopped_info
->stopped_status
= RDIError_Error
;
1312 return RDIError_NoError
;
1316 static void interrupt_target( void )
1318 Packet
*packet
= NULL
;
1320 int reason
, debugID
, OSinfo1
, OSinfo2
, status
;
1323 angel_DebugPrint("DEBUG: interrupt_target.\n");
1326 register_debug_message_handler();
1327 msgsend(CI_HADP
, "%w%w%w%w", ADP_InterruptRequest
| HtoT
, 0,
1328 ADP_HandleUnknown
, ADP_HandleUnknown
);
1330 reason
= ADP_InterruptRequest
|TtoH
;
1331 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1333 DevSW_FreePacket(packet
);
1335 angel_DebugPrint("DEBUG: got interrupt ack ok err = %d, status=%i\n",
1343 extern void test_dc_appl_handler( const DeviceDescr
*device
,
1347 void angel_RDI_stop_request(void)
1352 /* Core functionality for execute and step */
1353 static int angel_RDI_ExecuteOrStep(PointHandle
*handle
, word type
,
1356 extern int (*ui_loop_hook
) (int);
1358 adp_stopped_struct stopped_info
;
1359 void* stateptr
= (void *)&stopped_info
;
1360 ChannelCallback HandleStoppedMessageFPtr
=(ChannelCallback
) HandleStoppedMessage
;
1361 int status
, reasoncode
, debugID
, OSinfo1
, OSinfo2
;
1362 Packet
*packet
= NULL
;
1364 TracePrint(("angel_RDI_ExecuteOrStep\n"));
1366 err
= Adp_ChannelRegisterRead(CI_TADP
,
1367 HandleStoppedMessageFPtr
, stateptr
);
1368 if (err
!= RDIError_NoError
) {
1370 angel_DebugPrint("TADP Register failed.\n");
1374 /* Set executing TRUE here, as it must be set up before the target has
1375 * had any chance at all to execute, or it may send its stopped message
1376 * before we get round to setting executing = TRUE !!!
1380 register_debug_message_handler();
1383 Adp_Install_DC_Appl_Handler( test_dc_appl_handler
);
1387 angel_DebugPrint("Transmiting %s message.\n",
1388 type
== ADP_Execute
? "execute": "step");
1391 register_debug_message_handler();
1392 /* Extra ninstr parameter for execute message will simply be ignored */
1393 err
= msgsend(CI_HADP
,"%w%w%w%w%w", type
| HtoT
, 0,
1394 ADP_HandleUnknown
, ADP_HandleUnknown
, ninstr
);
1396 if (err
!= RDIError_NoError
) angel_DebugPrint("Transmit failed.\n");
1399 reasoncode
= type
| TtoH
;
1400 err
= wait_for_debug_message( &reasoncode
, &debugID
, &OSinfo1
, &OSinfo2
,
1402 if (err
!= RDIError_NoError
)
1404 else if (status
!= RDIError_NoError
)
1408 angel_DebugPrint("Waiting for program to finish...\n");
1411 interrupt_request
= FALSE
;
1412 stop_request
= FALSE
;
1414 signal(SIGINT
, ardi_sigint_handler
);
1420 if (interrupt_request
|| stop_request
)
1423 interrupt_request
= FALSE
;
1424 stop_request
= FALSE
;
1426 Adp_AsynchronousProcessing( async_block_on_nothing
);
1428 signal(SIGINT
, SIG_IGN
);
1432 Adp_Install_DC_Appl_Handler( NULL
);
1435 (void)Adp_ChannelRegisterRead(CI_TADP
, NULL
, NULL
);
1437 *handle
= (PointHandle
)stopped_info
.data
;
1439 CallStoppedProcs(stopped_info
.stopped_reason
);
1441 return stopped_info
.stopped_status
;
1444 /* Request that the target starts executing from the stored CPU state: use
1446 int angel_RDI_execute(PointHandle
*handle
)
1448 return angel_RDI_ExecuteOrStep(handle
, ADP_Execute
, 0);
1452 typedef void handlertype(int);
1454 static int interrupted
=0;
1456 static void myhandler(int sig
) {
1459 signal(SIGINT
, myhandler
);
1463 /*----------------------------------------------------------------------*/
1464 /*----angel_RDI_step-----------------------------------------------------*/
1465 /*----------------------------------------------------------------------*/
1467 /* Step 'ninstr' through the code: use ADP_Step. */
1468 int angel_RDI_step(unsigned ninstr
, PointHandle
*handle
)
1470 int err
= angel_RDI_ExecuteOrStep(handle
, ADP_Step
, ninstr
);
1471 if (err
== RDIError_ProgramFinishedInStep
)
1472 return RDIError_NoError
;
1478 static void SetCPWords(int cpnum
, struct Dbg_CoProDesc
const *cpd
) {
1480 for (i
= 0; i
< cpd
->entries
; i
++)
1481 if (cpd
->regdesc
[i
].rmax
> rmax
)
1482 rmax
= cpd
->regdesc
[i
].rmax
;
1484 { unsigned char *rmap
= (unsigned char *)malloc(rmax
+ 2);
1486 for (i
= 0; i
< cpd
->entries
; i
++) {
1488 for (r
= cpd
->regdesc
[i
].rmin
; r
<= cpd
->regdesc
[i
].rmax
; r
++)
1489 rmap
[r
] = (cpd
->regdesc
[i
].nbytes
+3) / 4;
1491 /* if (cpwords[cpnum] != NULL) free(cpwords[cpnum]); */
1492 cpwords
[cpnum
] = rmap
;
1496 /*----------------------------------------------------------------------*/
1497 /*----angel_RDI_info-----------------------------------------------------*/
1498 /*----------------------------------------------------------------------*/
1500 /* Use ADP_Info, ADP_Ctrl and ADP_Profile calls to implement these,
1501 see adp.h for more details. */
1503 static int angel_cc_exists( void )
1505 Packet
*packet
= NULL
;
1507 int reason
, debugID
, OSinfo1
, OSinfo2
, subreason
, status
;
1510 angel_DebugPrint("DEBUG: ADP_ICEB_CC_Exists.\n");
1513 if ( angel_RDI_info( RDIInfo_Icebreaker
, NULL
, NULL
) == RDIError_NoError
) {
1514 register_debug_message_handler();
1515 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_ICEbreakerHADP
| HtoT
, 0,
1516 ADP_HandleUnknown
, ADP_HandleUnknown
,
1517 ADP_ICEB_CC_Exists
);
1518 reason
= ADP_ICEbreakerHADP
|TtoH
;
1519 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1521 if (err
!= RDIError_NoError
) {
1522 DevSW_FreePacket(packet
);
1525 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
1526 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1527 if (subreason
!= ADP_ICEB_CC_Exists
) {
1528 DevSW_FreePacket(packet
);
1529 return RDIError_Error
;
1535 return RDIError_UnimplementedMessage
;
1539 RDICCProc_ToHost
*tohost
; void *tohostarg
;
1540 RDICCProc_FromHost
*fromhost
; void *fromhostarg
;
1543 static CCState ccstate
= { NULL
, NULL
, NULL
, NULL
, FALSE
};
1545 static void HandleDCCMessage( Packet
*packet
, void *stateptr
)
1547 unsigned int reason
, debugID
, OSinfo1
, OSinfo2
;
1549 CCState
*ccstate_p
= (CCState
*)stateptr
;
1551 count
= unpack_message( BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w",
1552 &reason
, &debugID
, &OSinfo1
, &OSinfo2
);
1555 case ADP_TDCC_ToHost
| TtoH
:
1557 /* only handles a single word of data, for now */
1559 unsigned int nbytes
, data
;
1561 unpack_message( BUFFERDATA(packet
->pk_buffer
)+count
, "%w%w",
1564 angel_DebugPrint( "DEBUG: received CC_ToHost message: nbytes %d data %08x.\n",
1567 ccstate_p
->tohost( ccstate_p
->tohostarg
, data
);
1568 msgsend(CI_TTDCC
, "%w%w%w%w%w",
1569 ADP_TDCC_ToHost
| HtoT
, debugID
, OSinfo1
, OSinfo2
,
1574 case ADP_TDCC_FromHost
| TtoH
:
1576 /* only handles a single word of data, for now */
1581 ccstate_p
->fromhost( ccstate_p
->fromhostarg
, &data
, &valid
);
1583 angel_DebugPrint( "DEBUG: received CC_FromHost message, returning: %08x %s.\n",
1584 data
, valid
? "VALID" : "INvalid" );
1586 msgsend(CI_TTDCC
, "%w%w%w%w%w%w%w",
1587 ADP_TDCC_FromHost
| HtoT
, debugID
, OSinfo1
, OSinfo2
,
1588 RDIError_NoError
, valid
? 1 : 0, data
);
1594 angel_DebugPrint( "Unexpected TDCC message %08x received\n", reason
);
1598 DevSW_FreePacket(packet
);
1602 static void angel_check_DCC_handler( CCState
*ccstate_p
)
1606 if ( ccstate_p
->tohost
!= NULL
|| ccstate_p
->fromhost
!= NULL
)
1608 /* doing DCC, so need a handler */
1609 if ( ! ccstate_p
->registered
)
1612 angel_DebugPrint( "Registering handler for TTDCC channel.\n" );
1614 err
= Adp_ChannelRegisterRead( CI_TTDCC
, HandleDCCMessage
,
1616 if ( err
== adp_ok
)
1617 ccstate_p
->registered
= TRUE
;
1620 angel_DebugPrint( "angel_check_DCC_handler: register failed!\n" );
1626 /* not doing DCC, so don't need a handler */
1627 if ( ccstate_p
->registered
)
1630 angel_DebugPrint( "Unregistering handler for TTDCC channel.\n" );
1632 err
= Adp_ChannelRegisterRead( CI_TTDCC
, NULL
, NULL
);
1633 if ( err
== adp_ok
)
1634 ccstate_p
->registered
= FALSE
;
1637 angel_DebugPrint( "angel_check_DCC_handler: unregister failed!\n" );
1644 static int CheckSubMessageReply(int reason
, int subreason
) {
1645 Packet
*packet
= NULL
;
1646 int status
, debugID
, OSinfo1
, OSinfo2
;
1647 int err
= RDIError_NoError
;
1649 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1651 if (err
!= RDIError_NoError
) {
1655 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
1656 &OSinfo1
, &OSinfo2
, &sr
, &status
);
1657 if (subreason
!= sr
) status
= RDIError_Error
;
1659 DevSW_FreePacket(packet
);
1663 static int SendSubMessageAndCheckReply(int reason
, int subreason
) {
1664 register_debug_message_handler();
1665 msgsend(CI_HADP
, "%w%w%w%w%w", reason
| HtoT
, 0,
1666 ADP_HandleUnknown
, ADP_HandleUnknown
,
1668 return CheckSubMessageReply(reason
, subreason
);
1671 static int SendSubMessageWordAndCheckReply(int reason
, int subreason
, ARMword word
) {
1672 register_debug_message_handler();
1673 msgsend(CI_HADP
, "%w%w%w%w%w%w", reason
| HtoT
, 0,
1674 ADP_HandleUnknown
, ADP_HandleUnknown
,
1676 return CheckSubMessageReply(reason
, subreason
);
1679 static int SendSubMessageGetWordAndCheckReply(int reason
, int subreason
, ARMword
*resp
) {
1680 Packet
*packet
= NULL
;
1681 int status
, debugID
, OSinfo1
, OSinfo2
;
1682 int err
= RDIError_NoError
;
1684 register_debug_message_handler();
1685 msgsend(CI_HADP
, "%w%w%w%w%w", reason
| HtoT
, 0,
1686 ADP_HandleUnknown
, ADP_HandleUnknown
,
1689 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1691 if (err
!= RDIError_NoError
) {
1695 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w", &reason
, &debugID
,
1696 &OSinfo1
, &OSinfo2
, &sr
, &status
, resp
);
1697 if (subreason
!= sr
) status
= RDIError_Error
;
1699 DevSW_FreePacket(packet
);
1703 static int const hostsex
= 1;
1705 int angel_RDI_info(unsigned type
, ARMword
*arg1
, ARMword
*arg2
) {
1706 Packet
*packet
= NULL
;
1707 int len
, status
, c
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
;
1708 int err
=RDIError_NoError
, cpnum
=0;
1709 struct Dbg_CoProDesc
*cpd
;
1714 angel_DebugPrint("DEBUG: Entered angel_RDI_info.\n");
1717 case RDIInfo_Target
:
1719 angel_DebugPrint("DEBUG: RDIInfo_Target.\n");
1722 register_debug_message_handler();
1723 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1724 ADP_HandleUnknown
, ADP_HandleUnknown
, ADP_Info_Target
);
1725 reason
= ADP_Info
|TtoH
;
1726 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1728 if (err
!= RDIError_NoError
) {
1729 DevSW_FreePacket(packet
);
1732 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w", &reason
,
1733 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
,
1735 DevSW_FreePacket(packet
);
1737 if (subreason
!= ADP_Info_Target
)
1738 return RDIError_Error
;
1742 case RDISignal_Stop
:
1744 angel_DebugPrint("DEBUG: RDISignal_Stop.\n");
1745 if (interrupt_request
)
1746 angel_DebugPrint(" STILL WAITING to send previous interrupt request\n");
1748 interrupt_request
= TRUE
;
1749 return RDIError_NoError
;
1751 case RDIInfo_Points
:
1753 angel_DebugPrint("DEBUG: RDIInfo_Points.\n");
1755 return SendSubMessageGetWordAndCheckReply(ADP_Info
, ADP_Info_Points
, arg1
);
1759 angel_DebugPrint("DEBUG: RDIInfo_Step.\n");
1761 return SendSubMessageGetWordAndCheckReply(ADP_Info
, ADP_Info_Step
, arg1
);
1763 case RDISet_Cmdline
:
1765 angel_DebugPrint("DEBUG: RDISet_Cmdline.\n");
1767 if (ardi_commandline
!= &dummycline
)
1768 free(ardi_commandline
);
1769 ardi_commandline
= (char *)malloc(strlen((char*)arg1
) + 1) ;
1770 (void)strcpy(ardi_commandline
, (char *)arg1
) ;
1771 return RDIError_NoError
;
1773 case RDIInfo_SetLog
:
1775 angel_DebugPrint("DEBUG: RDIInfo_SetLog.\n");
1777 rdi_log
= (int) *arg1
;
1778 return RDIError_NoError
;
1782 angel_DebugPrint("DEBUG: RDIInfo_Log.\n");
1785 return RDIError_NoError
;
1790 angel_DebugPrint("DEBUG: RDIInfo_MMU.\n");
1792 return SendSubMessageGetWordAndCheckReply(ADP_Info
, ADP_Info_MMU
, arg1
);
1794 case RDIInfo_SemiHosting
:
1796 angel_DebugPrint("DEBUG: RDIInfo_SemiHosting.\n");
1798 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_SemiHosting
);
1802 angel_DebugPrint("DEBUG: RDIInfo_CoPro.\n");
1804 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_CoPro
);
1808 angel_DebugPrint("DEBUG: RDICycles.\n");
1810 register_debug_message_handler();
1811 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1812 ADP_HandleUnknown
, ADP_HandleUnknown
, ADP_Info_Cycles
);
1813 reason
= ADP_Info
|TtoH
;
1814 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1816 if (err
!= RDIError_NoError
) {
1817 DevSW_FreePacket(packet
);
1820 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
1821 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1822 DevSW_FreePacket(packet
);
1823 if (subreason
!= ADP_Info_Cycles
)
1824 return RDIError_Error
;
1825 if (status
!= RDIError_NoError
) return status
;
1826 for (c
=0; c
<12; c
++)
1827 arg1
[c
]=GET32LE(BUFFERDATA(packet
->pk_buffer
)+24+(c
*4));
1830 case RDIInfo_DescribeCoPro
:
1832 angel_DebugPrint("DEBUG: RDIInfo_DescribeCoPro.\n");
1834 cpnum
= *(int *)arg1
;
1835 cpd
= (struct Dbg_CoProDesc
*)arg2
;
1836 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
1837 if (angel_RDI_info(ADP_Info_CoPro
, NULL
, NULL
) != RDIError_NoError
)
1838 return RDIError_Error
;
1839 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1840 ADP_HandleUnknown
, ADP_HandleUnknown
,
1841 ADP_Info_DescribeCoPro
);
1842 len
+=msgbuild(BUFFERDATA(packet
->pk_buffer
)+20, "%b%b%b%b%b", cpnum
,
1843 cpd
->regdesc
[cpnum
].rmin
, cpd
->regdesc
[cpnum
].rmax
,
1844 cpd
->regdesc
[cpnum
].nbytes
, cpd
->regdesc
[cpnum
].access
);
1845 if (cpd
->regdesc
[cpnum
].access
&0x3 == 0x3){
1846 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
)+25, "%b%b%b%b%b",
1847 cpd
->regdesc
[cpnum
].accessinst
.cprt
.read_b0
,
1848 cpd
->regdesc
[cpnum
].accessinst
.cprt
.read_b1
,
1849 cpd
->regdesc
[cpnum
].accessinst
.cprt
.write_b0
,
1850 cpd
->regdesc
[cpnum
].accessinst
.cprt
.write_b1
, 0xff);
1853 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
)+25, "%b%b%b%b%b%",
1854 cpd
->regdesc
[cpnum
].accessinst
.cpdt
.rdbits
,
1855 cpd
->regdesc
[cpnum
].accessinst
.cpdt
.nbit
,0,0, 0xff);
1857 register_debug_message_handler();
1858 packet
->pk_length
= len
;
1859 Adp_ChannelWrite(CI_HADP
, packet
); /* Transmit message. */
1860 reason
= ADP_Info
|TtoH
;
1861 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1863 if (err
!= RDIError_NoError
) {
1864 DevSW_FreePacket(packet
);
1867 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
1868 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1869 DevSW_FreePacket(packet
);
1870 if (subreason
!= ADP_Info_DescribeCoPro
)
1871 return RDIError_Error
;
1875 case RDIInfo_RequestCoProDesc
:
1877 angel_DebugPrint("DEBUG: RDIInfo_RequestCoProDesc.\n");
1879 cpnum
= *(int *)arg1
;
1880 cpd
= (struct Dbg_CoProDesc
*)arg2
;
1881 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
1882 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1883 ADP_HandleUnknown
, ADP_HandleUnknown
,
1884 ADP_Info_RequestCoProDesc
);
1885 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
)+20, "%b", *(int *)arg1
);
1886 packet
->pk_length
= len
;
1887 register_debug_message_handler();
1888 Adp_ChannelWrite(CI_HADP
, packet
); /* Transmit message. */
1889 reason
= ADP_Info
|TtoH
;
1890 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1892 if (err
!= RDIError_NoError
) {
1893 DevSW_FreePacket(packet
);
1896 count
= unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
1897 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1898 if (subreason
!= ADP_Info_RequestCoProDesc
) {
1899 DevSW_FreePacket(packet
);
1900 return RDIError_Error
;
1901 } else if ( status
!= RDIError_NoError
) {
1902 DevSW_FreePacket(packet
);
1905 bp
= BUFFERDATA(packet
->pk_buffer
)+count
;
1906 for ( i
= 0; *bp
!= 0xFF && i
< cpd
->entries
; ++i
) {
1907 cpd
->regdesc
[i
].rmin
= *bp
++;
1908 cpd
->regdesc
[i
].rmax
= *bp
++;
1909 cpd
->regdesc
[i
].nbytes
= *bp
++;
1910 cpd
->regdesc
[i
].access
= *bp
++;
1914 status
= RDIError_BufferFull
;
1916 SetCPWords( cpnum
, cpd
);
1917 DevSW_FreePacket(packet
);
1921 case RDIInfo_GetLoadSize
:
1923 angel_DebugPrint("DEBUG: ADP_Info_AngelBufferSize.\n");
1925 register_debug_message_handler();
1926 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1927 ADP_HandleUnknown
, ADP_HandleUnknown
,
1928 ADP_Info_AngelBufferSize
);
1929 reason
= ADP_Info
|TtoH
;
1930 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1932 if (err
!= RDIError_NoError
) {
1933 DevSW_FreePacket(packet
);
1936 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
1937 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1938 if (subreason
!= ADP_Info_AngelBufferSize
) {
1939 DevSW_FreePacket(packet
);
1940 return RDIError_Error
;
1943 word defaultsize
, longsize
;
1944 unpack_message(BUFFERDATA(packet
->pk_buffer
)+24, "%w%w",
1945 &defaultsize
, &longsize
);
1946 *arg1
= longsize
- ADP_WriteHeaderSize
; /* space for ADP header */
1947 #ifdef MONITOR_DOWNLOAD_PACKETS
1948 angel_DebugPrint("DEBUG: ADP_Info_AngelBufferSize: got (%d, %d), returning %d.\n",
1949 defaultsize
, longsize
, *arg1
);
1951 DevSW_FreePacket(packet
);
1955 case RDIVector_Catch
:
1957 angel_DebugPrint("DEBUG: ADP_Ctrl_VectorCatch %lx.\n", *arg1
);
1959 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_VectorCatch
, *arg1
);
1961 case RDISemiHosting_SetState
:
1963 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetState %lx.\n", *arg1
);
1965 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetState
, *arg1
);
1967 case RDISemiHosting_GetState
:
1969 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetState.\n");
1971 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetState
, arg1
);
1973 case RDISemiHosting_SetVector
:
1975 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetVector %lx.\n", *arg1
);
1977 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetVector
, *arg1
);
1979 case RDISemiHosting_GetVector
:
1981 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetVector.\n");
1983 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetVector
, arg1
);
1985 case RDISemiHosting_SetARMSWI
:
1987 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetARMSWI.\n");
1989 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetARMSWI
, *arg1
);
1991 case RDISemiHosting_GetARMSWI
:
1993 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetARMSWI.\n");
1995 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetARMSWI
, arg1
);
1997 case RDISemiHosting_SetThumbSWI
:
1999 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetThumbSWI.\n");
2001 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetThumbSWI
, *arg1
);
2003 case RDISemiHosting_GetThumbSWI
:
2005 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetThumbSWI.\n");
2007 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetThumbSWI
, arg1
);
2009 case RDIInfo_SetTopMem
:
2011 angel_DebugPrint("DEBUG: ADP_Ctrl_SetTopMem.\n");
2013 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SetTopMem
, *arg1
);
2015 case RDIPointStatus_Watch
:
2017 angel_DebugPrint("DEBUG: ADP_Ctrl_PointStatus_Watch.\n");
2019 register_debug_message_handler();
2020 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Control
| HtoT
, 0,
2021 ADP_HandleUnknown
, ADP_HandleUnknown
,
2022 ADP_Ctrl_PointStatus_Watch
, *arg1
);
2023 reason
= ADP_Control
|TtoH
;
2024 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2026 if (err
!= RDIError_NoError
) {
2027 DevSW_FreePacket(packet
);
2030 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w", &reason
,
2031 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
,
2033 if (subreason
!= ADP_Ctrl_PointStatus_Watch
) {
2034 DevSW_FreePacket(packet
);
2035 return RDIError_Error
;
2040 case RDIPointStatus_Break
:
2042 angel_DebugPrint("DEBUG: ADP_Ctrl_PointStatus_Break.\n");
2044 register_debug_message_handler();
2045 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Control
| HtoT
, 0,
2046 ADP_HandleUnknown
, ADP_HandleUnknown
,
2047 ADP_Ctrl_PointStatus_Break
, *arg1
);
2048 reason
= ADP_Control
|TtoH
;
2049 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2051 if (err
!= RDIError_NoError
) {
2052 DevSW_FreePacket(packet
);
2055 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w", &reason
,
2056 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
,
2058 if (subreason
!= ADP_Ctrl_PointStatus_Break
) {
2059 DevSW_FreePacket(packet
);
2060 return RDIError_Error
;
2065 case RDIInfo_DownLoad
:
2067 angel_DebugPrint("DEBUG: ADP_Ctrl_Download_Supported.\n");
2069 return SendSubMessageAndCheckReply(ADP_Control
, ADP_Ctrl_Download_Supported
);
2071 case RDIConfig_Count
:
2073 angel_DebugPrint("DEBUG: ADP_ICEM_ConfigCount.\n");
2075 return SendSubMessageGetWordAndCheckReply(ADP_ICEman
, ADP_ICEM_ConfigCount
, arg1
);
2079 angel_DebugPrint("DEBUG: ADP_ICEM_ConfigNth.\n");
2081 register_debug_message_handler();
2082 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_ICEman
| HtoT
, 0,
2083 ADP_HandleUnknown
, ADP_HandleUnknown
,
2084 ADP_ICEM_ConfigNth
, *arg1
);
2085 reason
= ADP_ICEman
|TtoH
;
2086 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2088 if (err
!= RDIError_NoError
) {
2089 DevSW_FreePacket(packet
);
2092 RDI_ConfigDesc
*cd
= (RDI_ConfigDesc
*)arg2
;
2094 len
= unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%b",
2096 &OSinfo1
, &OSinfo2
, &subreason
, &status
,
2098 if (subreason
!= ADP_ICEM_ConfigNth
) {
2099 DevSW_FreePacket(packet
);
2100 return RDIError_Error
;
2103 memcpy( cd
->name
, BUFFERDATA(packet
->pk_buffer
)+len
, n
+1 );
2109 case RDIInfo_Icebreaker
:
2111 angel_DebugPrint("DEBUG: ADP_ICEB_Exists.\n");
2113 return SendSubMessageAndCheckReply(ADP_ICEbreakerHADP
, ADP_ICEB_Exists
);
2115 case RDIIcebreaker_GetLocks
:
2117 angel_DebugPrint("DEBUG: ADP_ICEB_GetLocks.\n");
2119 return SendSubMessageGetWordAndCheckReply(ADP_ICEbreakerHADP
, ADP_ICEB_GetLocks
, arg1
);
2121 case RDIIcebreaker_SetLocks
:
2123 angel_DebugPrint("DEBUG: ADP_ICEB_SetLocks.\n");
2125 return SendSubMessageWordAndCheckReply(ADP_ICEbreakerHADP
, ADP_ICEB_SetLocks
, *arg1
);
2127 case RDICommsChannel_ToHost
:
2129 angel_DebugPrint("DEBUG: ADP_ICEB_CC_Connect_ToHost.\n");
2131 if ( angel_cc_exists() == RDIError_NoError
) {
2134 * The following three lines of code have to be removed in order to get
2135 * the Windows Angel Channel Viewer working with the Thumb comms channel.
2136 * At the moment it allows the ARMSD command line to register a CCIN/CCOUT
2137 * callback which stops the ACV working!
2140 ccstate
.tohost
= (RDICCProc_ToHost
*)arg1
;
2141 ccstate
.tohostarg
= arg2
;
2142 angel_check_DCC_handler( &ccstate
);
2148 register_debug_message_handler();
2149 msgsend(CI_HADP
, "%w%w%w%w%w%b", ADP_ICEbreakerHADP
| HtoT
, 0,
2150 ADP_HandleUnknown
, ADP_HandleUnknown
,
2151 ADP_ICEB_CC_Connect_ToHost
, (arg1
!= NULL
) );
2152 return CheckSubMessageReply(ADP_ICEbreakerHADP
, ADP_ICEB_CC_Connect_ToHost
);
2154 return RDIError_UnimplementedMessage
;
2157 case RDICommsChannel_FromHost
:
2159 angel_DebugPrint("DEBUG: ADP_ICEB_CC_Connect_FromHost.\n");
2161 if ( angel_cc_exists() == RDIError_NoError
) {
2163 ccstate
.fromhost
= (RDICCProc_FromHost
*)arg1
;
2164 ccstate
.fromhostarg
= arg2
;
2165 angel_check_DCC_handler( &ccstate
);
2167 register_debug_message_handler();
2168 msgsend(CI_HADP
, "%w%w%w%w%w%b", ADP_ICEbreakerHADP
| HtoT
, 0,
2169 ADP_HandleUnknown
, ADP_HandleUnknown
,
2170 ADP_ICEB_CC_Connect_FromHost
, (arg1
!= NULL
) );
2171 return CheckSubMessageReply(ADP_ICEbreakerHADP
, ADP_ICEB_CC_Connect_FromHost
);
2173 return RDIError_UnimplementedMessage
;
2176 case RDIProfile_Stop
:
2177 return SendSubMessageAndCheckReply(ADP_Profile
, ADP_Profile_Stop
);
2179 case RDIProfile_ClearCounts
:
2180 return SendSubMessageAndCheckReply(ADP_Profile
, ADP_Profile_ClearCounts
);
2182 case RDIProfile_Start
:
2184 angel_DebugPrint("DEBUG: ADP_Profile_Start %ld.\n", (long)*arg1
);
2186 return SendSubMessageWordAndCheckReply(ADP_Profile
, ADP_Profile_Start
, *arg1
);
2188 case RDIProfile_WriteMap
:
2189 { RDI_ProfileMap
*map
= (RDI_ProfileMap
*)arg1
;
2190 int32 maplen
= map
->len
,
2193 int32 chunk
= (Armsd_LongBufSize
-CHAN_HEADER_SIZE
-ADP_ProfileWriteHeaderSize
) / sizeof(ARMword
);
2194 /* Maximum number of words sendable in one message */
2195 int oldrev
= bytesex_reversing();
2196 int host_little
= *(uint8
const *)&hostsex
;
2198 angel_DebugPrint("DEBUG: ADP_Profile_WriteMap %ld.\n", maplen
);
2200 status
= RDIError_NoError
;
2203 for (offset
= 0; offset
< maplen
; offset
++)
2204 map
->map
[offset
] = bytesex_hostval(map
->map
[offset
]);
2206 for (offset
= 0; offset
< maplen
; offset
+= size
) {
2208 size
= maplen
- offset
;
2209 packet
= (Packet
*)DevSW_AllocatePacket(Armsd_LongBufSize
);
2210 if (size
> chunk
) size
= chunk
;
2211 hdrlen
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
2212 ADP_Profile
| HtoT
, 0, ADP_HandleUnknown
,
2213 ADP_HandleUnknown
, ADP_Profile_WriteMap
,
2214 maplen
, size
, offset
);
2216 /* Copy the data into the packet. */
2217 memcpy(BUFFERDATA(packet
->pk_buffer
)+hdrlen
,
2218 &map
->map
[offset
], (size_t)size
* sizeof(ARMword
));
2219 packet
->pk_length
= size
* sizeof(ARMword
) + hdrlen
;
2220 register_debug_message_handler();
2221 Adp_ChannelWrite(CI_HADP
, packet
);
2222 reason
= ADP_Profile
| TtoH
;
2223 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2225 if (err
== RDIError_NoError
) {
2226 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
2227 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2228 if (subreason
!= ADP_Profile_WriteMap
) {
2229 err
= RDIError_Error
;
2231 DevSW_FreePacket(packet
);
2233 if (err
!= RDIError_NoError
) { status
= err
; break; }
2236 for (offset
= 0; offset
< maplen
; offset
++)
2237 map
->map
[offset
] = bytesex_hostval(map
->map
[offset
]);
2238 bytesex_reverse(oldrev
);
2243 case RDIProfile_ReadMap
:
2244 { int32 maplen
= *(int32
*)arg1
,
2247 int32 chunk
= (Armsd_BufferSize
-CHAN_HEADER_SIZE
-ADP_ProfileReadHeaderSize
) / sizeof(ARMword
);
2249 angel_DebugPrint("DEBUG: ADP_Profile_ReadMap %ld.\n", maplen
);
2251 status
= RDIError_NoError
;
2252 for (offset
= 0; offset
< maplen
; offset
+= size
) {
2253 size
= maplen
- offset
;
2254 if (size
> chunk
) size
= chunk
;
2255 register_debug_message_handler();
2256 msgsend(CI_HADP
, "%w%w%w%w%w%w%w", ADP_Profile
| HtoT
, 0,
2257 ADP_HandleUnknown
, ADP_HandleUnknown
,
2258 ADP_Profile_ReadMap
, offset
, size
);
2259 reason
= ADP_Profile
| TtoH
;
2260 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2262 if (err
!= RDIError_NoError
) return err
;
2263 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
2264 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2265 memcpy(&arg2
[offset
], BUFFERDATA(packet
->pk_buffer
)+ADP_ProfileReadHeaderSize
,
2266 size
* sizeof(ARMword
));
2267 DevSW_FreePacket(packet
);
2268 if (status
!= RDIError_NoError
) break;
2270 { int oldrev
= bytesex_reversing();
2271 int host_little
= *(uint8
const *)&hostsex
;
2274 for (offset
= 0; offset
< maplen
; offset
++)
2275 arg2
[offset
] = bytesex_hostval(arg2
[offset
]);
2277 bytesex_reverse(oldrev
);
2282 case RDIInfo_CanTargetExecute
:
2284 printf("DEBUG: RDIInfo_CanTargetExecute.\n");
2286 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_CanTargetExecute
);
2288 case RDIInfo_AgentEndianess
:
2289 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_AgentEndianess
);
2293 angel_DebugPrint("DEBUG: Fell through ADP_Info, default case taken.\n");
2294 angel_DebugPrint("DEBUG: type = 0x%x.\n", type
);
2296 if (type
& RDIInfo_CapabilityRequest
) {
2297 switch (type
& ~RDIInfo_CapabilityRequest
) {
2298 case RDISemiHosting_SetARMSWI
:
2299 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_ChangeableSHSWI
);
2303 "DEBUG: ADP_Info - Capability Request(%d) - reporting unimplemented \n",
2304 type
& ~RDIInfo_CapabilityRequest
);
2309 return RDIError_UnimplementedMessage
;
2314 /*----------------------------------------------------------------------*/
2315 /*----angel_RDI_AddConfig------------------------------------------------*/
2316 /*----------------------------------------------------------------------*/
2318 /* Add a configuration: use ADP_ICEM_AddConfig. */
2319 int angel_RDI_AddConfig(unsigned long nbytes
) {
2320 Packet
*packet
= NULL
;
2321 int status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2324 angel_DebugPrint("DEBUG: Entered angel_RDI_AddConfig.\n");
2326 register_debug_message_handler();
2327 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_ICEman
| HtoT
,
2328 0, ADP_HandleUnknown
, ADP_HandleUnknown
,
2329 ADP_ICEM_AddConfig
, nbytes
);
2330 reason
=ADP_ICEman
| TtoH
;
2331 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2333 if (err
!= RDIError_NoError
) {
2334 DevSW_FreePacket(packet
);
2337 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
2338 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2339 DevSW_FreePacket(packet
);
2340 if ( subreason
!= ADP_ICEM_AddConfig
)
2341 return RDIError_Error
;
2347 /*----------------------------------------------------------------------*/
2348 /*----angel_RDI_LoadConfigData-------------------------------------------*/
2349 /*----------------------------------------------------------------------*/
2351 /* Load configuration data: use ADP_Ctrl_Download_Data. */
2352 int angel_RDI_LoadConfigData(unsigned long nbytes
, char const *data
) {
2353 Packet
*packet
= NULL
;
2354 int len
, status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2357 angel_DebugPrint("DEBUG: Entered angel_RDI_LoadConfigData (%d bytes)\n", nbytes
);
2360 if (err
= angel_RDI_AddConfig(nbytes
) != RDIError_NoError
)
2363 packet
= DevSW_AllocatePacket(Armsd_LongBufSize
);
2364 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w",
2365 ADP_Control
| HtoT
, 0,
2366 ADP_HandleUnknown
, ADP_HandleUnknown
,
2367 ADP_Ctrl_Download_Data
, nbytes
);
2368 memcpy(BUFFERDATA(packet
->pk_buffer
)+len
, data
, nbytes
);
2370 packet
->pk_length
= len
;
2372 angel_DebugPrint("DEBUG: packet len %d.\n", len
);
2374 register_debug_message_handler();
2375 Adp_ChannelWrite(CI_HADP
, packet
);
2376 reason
=ADP_Control
| TtoH
;
2377 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2379 if (err
!= RDIError_NoError
) {
2380 DevSW_FreePacket(packet
);
2383 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
2384 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2385 DevSW_FreePacket(packet
);
2386 if ( subreason
!= ADP_Ctrl_Download_Data
)
2387 return RDIError_Error
;
2393 /*----------------------------------------------------------------------*/
2394 /*----angel_RDI_SelectConfig---------------------------------------------*/
2395 /*----------------------------------------------------------------------*/
2397 /* Select a configuration: use ADP_ICEM_SelecConfig.*/
2398 int angel_RDI_SelectConfig(RDI_ConfigAspect aspect
, char const *name
,
2399 RDI_ConfigMatchType matchtype
, unsigned versionreq
,
2402 Packet
*packet
= NULL
;
2403 int len
, status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2406 angel_DebugPrint("DEBUG: Entered angel_RDI_SelectConfig.\n");
2408 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
2409 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%b%b%b%w",
2410 ADP_ICEman
| HtoT
, 0,
2411 ADP_HandleUnknown
, ADP_HandleUnknown
,
2412 ADP_ICEM_SelectConfig
, aspect
, strlen(name
),
2413 matchtype
, versionreq
);
2414 /* copy the name into the buffer */
2415 memcpy(BUFFERDATA(packet
->pk_buffer
)+len
, name
, strlen(name
));
2416 len
+= strlen(name
);
2417 packet
->pk_length
= len
;
2418 register_debug_message_handler();
2419 Adp_ChannelWrite(CI_HADP
, packet
);
2420 reason
=ADP_ICEman
| TtoH
;
2421 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2423 if (err
!= RDIError_NoError
) {
2424 DevSW_FreePacket(packet
);
2427 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w",
2428 &reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2429 &subreason
, &status
, versionp
);
2430 DevSW_FreePacket(packet
);
2431 if ( subreason
!= ADP_ICEM_SelectConfig
)
2432 return RDIError_Error
;
2438 /*----------------------------------------------------------------------*/
2439 /*----angel_RDI_LoadAgent------------------------------------------------*/
2440 /*----------------------------------------------------------------------*/
2442 /* Load a new debug agent: use ADP_Ctrl_Download_Agent. */
2443 int angel_RDI_LoadAgent(ARMword dest
, unsigned long size
,
2444 getbufferproc
*getb
, void *getbarg
)
2446 Packet
*packet
= NULL
;
2447 int status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2450 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2451 angel_DebugPrint("DEBUG: Entered angel_RDI_LoadAgent.\n");
2453 register_debug_message_handler();
2454 msgsend(CI_HADP
, "%w%w%w%w%w%w%w", ADP_Control
| HtoT
,
2455 0, ADP_HandleUnknown
, ADP_HandleUnknown
,
2456 ADP_Ctrl_Download_Agent
, dest
, size
);
2457 reason
=ADP_Control
| TtoH
;
2458 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2460 if (err
!= RDIError_NoError
) {
2461 DevSW_FreePacket(packet
);
2464 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
2465 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2466 DevSW_FreePacket(packet
);
2467 if ( subreason
!= ADP_Ctrl_Download_Agent
)
2468 return RDIError_Error
;
2469 if ( status
!= RDIError_NoError
)
2472 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2473 angel_DebugPrint("DEBUG: starting agent data download.\n");
2475 { unsigned long pos
= 0, segsize
;
2476 for (; pos
< size
; pos
+= segsize
) {
2477 char *b
= getb(getbarg
, &segsize
);
2478 if (b
== NULL
) return RDIError_NoError
;
2479 err
= angel_RDI_LoadConfigData( segsize
, b
);
2480 if (err
!= RDIError_NoError
) return err
;
2483 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2484 angel_DebugPrint("DEBUG: finished downloading new agent.\n");
2487 /* renegotiate back down */
2488 err
= angel_negotiate_defaults();
2492 /* Output a message to tell the user what is going on. This is vital
2493 * when switching from ADP EICE to ADP over JTAG, as then the user
2494 * has to reset the target board !
2497 int len
=angel_RDI_errmess(msg
, 256, adp_new_agent_starting
);
2498 angel_hostif
->write(angel_hostif
->hostosarg
, msg
, len
);
2501 /* get new image started */
2502 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2503 angel_DebugPrint("DEBUG: sending start message for new agent.\n");
2506 register_debug_message_handler();
2507 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Control
| HtoT
,
2508 0, ADP_HandleUnknown
, ADP_HandleUnknown
,
2509 ADP_Ctrl_Start_Agent
, dest
);
2510 reason
=ADP_Control
| TtoH
;
2511 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2513 if (err
!= RDIError_NoError
) {
2514 DevSW_FreePacket(packet
);
2517 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
2518 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2519 DevSW_FreePacket(packet
);
2520 if ( subreason
!= ADP_Ctrl_Start_Agent
)
2521 return RDIError_Error
;
2522 if ( status
!= RDIError_NoError
)
2525 /* wait for image to start up */
2526 heartbeat_enabled
= FALSE
;
2529 Adp_AsynchronousProcessing(async_block_on_nothing
);
2530 if ((time(NULL
)-t
) > 2) {
2532 angel_DebugPrint("DEBUG: no booted message from new image yet.\n");
2536 } while (booted_not_received
);
2537 booted_not_received
=1;
2539 /* Give device driver a chance to do any necessary resyncing with new agent.
2540 * Only used by etherdrv.c at the moment.
2542 (void)Adp_Ioctl( DC_RESYNC
, NULL
);
2544 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2545 angel_DebugPrint("DEBUG: reopening to new agent.\n");
2547 err
= angel_RDI_open(0, NULL
, NULL
, NULL
);
2550 case RDIError_NoError
:
2552 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2553 angel_DebugPrint( "LoadAgent: Open returned RDIError_NoError\n" );
2558 case RDIError_LittleEndian
:
2560 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2561 angel_DebugPrint( "LoadAgent: Open returned RDIError_LittleEndian (OK)\n" );
2563 err
= RDIError_NoError
;
2567 case RDIError_BigEndian
:
2569 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2570 angel_DebugPrint( "LoadAgent: Open returned RDIError_BigEndian (OK)\n" );
2572 err
= RDIError_NoError
;
2578 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2579 angel_DebugPrint( "LoadAgent: Open returned %d - unexpected!\n", err
);
2584 #ifndef NO_HEARTBEAT
2585 heartbeat_enabled
= TRUE
;
2590 static int angel_RDI_errmess(char *buf
, int blen
, int errnum
) {
2595 case adp_malloc_failure
:
2596 s
=AdpMess_MallocFailed
; break;
2597 case adp_illegal_args
:
2598 s
=AdpMess_IllegalArgs
; break;
2599 case adp_device_not_found
:
2600 s
=AdpMess_DeviceNotFound
; break;
2601 case adp_device_open_failed
:
2602 s
=AdpMess_DeviceOpenFailed
; break;
2603 case adp_device_already_open
:
2604 s
=AdpMess_DeviceAlreadyOpen
; break;
2605 case adp_device_not_open
:
2606 s
=AdpMess_DeviceNotOpen
; break;
2607 case adp_bad_channel_id
:
2608 s
=AdpMess_BadChannelId
; break;
2609 case adp_callback_already_registered
:
2610 s
=AdpMess_CBAlreadyRegd
; break;
2611 case adp_write_busy
:
2612 s
=AdpMess_WriteBusy
; break;
2613 case adp_bad_packet
:
2614 s
=AdpMess_BadPacket
; break;
2616 s
=AdpMess_SeqHigh
; break;
2618 s
=AdpMess_SeqLow
; break;
2619 case adp_timeout_on_open
:
2620 s
=AdpMess_TimeoutOnOpen
; break;
2622 s
=AdpMess_Failed
; break;
2623 case adp_abandon_boot_wait
:
2624 s
=AdpMess_AbandonBootWait
; break;
2625 case adp_late_startup
:
2626 s
=AdpMess_LateStartup
; break;
2627 case adp_new_agent_starting
:
2628 s
=AdpMess_NewAgentStarting
; break;
2632 if (n
>blen
-1) n
=blen
-1;
2638 extern const struct RDIProcVec angel_rdi
;
2639 const struct RDIProcVec angel_rdi
= {
2650 angel_RDI_clearbreak
,
2652 angel_RDI_clearwatch
,
2658 angel_RDI_AddConfig
,
2659 angel_RDI_LoadConfigData
,
2660 angel_RDI_SelectConfig
,
2662 0, /*angel_RDI_drivernames,*/
2672 /* Not strictly necessary, but allows linking this code into armsd. */
2682 } hostappl_CmdTable
[1] = {{"", NULL
}};