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
;
400 static void ardi_sigint_handler(int sig
) {
403 angel_DebugPrint("Expecting SIGINT got %d.\n", sig
);
407 boot_interrupted
= TRUE
;
408 interrupt_request
= TRUE
;
410 signal(SIGINT
, ardi_sigint_handler
);
414 static void install_ardi_handler( void ) {
415 if (!ardi_handler_installed
) {
416 /* install a new Ctrl-C handler so we can abandon waiting */
418 struct sigaction new_action
;
419 sigemptyset(&new_action
.sa_mask
);
420 new_action
.sa_handler
= ardi_sigint_handler
;
421 new_action
.sa_flags
= 0;
422 sigaction(SIGINT
, &new_action
, &old_action
);
424 old_handler
= signal(SIGINT
, ardi_sigint_handler
);
426 ardi_handler_installed
= TRUE
;
430 static int angel_RDI_errmess(char *buf
, int blen
, int errnum
);
432 static void receive_reset_acknowledge(Packet
*packet
, void *stateptr
) {
433 unsigned reason
, debugID
, OSinfo1
, OSinfo2
, status
;
436 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
, &debugID
,
437 &OSinfo1
, &OSinfo2
, &status
);
438 if (reason
==(ADP_Reset
| TtoH
) && status
==AB_NORMAL_ACK
) {
440 angel_DebugPrint("DEBUG: Successfully received normal reset acknowledgement\n");
443 } else if (reason
==(ADP_Reset
| TtoH
) && status
==AB_LATE_ACK
) {
444 char late_msg
[AdpMessLen_LateStartup
];
447 angel_DebugPrint("DEBUG: Successfully received LATE reset acknowledgement\n");
450 install_ardi_handler();
451 late_len
= angel_RDI_errmess(late_msg
,
452 AdpMessLen_LateStartup
, adp_late_startup
);
453 angel_hostif
->write(angel_hostif
->hostosarg
, late_msg
, late_len
);
456 angel_DebugPrint("DEBUG: Bad reset ack: reason=%8X, status=%8X\n", reason
, status
);
459 DevSW_FreePacket(packet
);
462 static int booted_not_received
;
463 static unsigned int angel_version
;
464 static unsigned int adp_version
;
465 static unsigned int arch_info
;
466 static unsigned int cpu_info
;
467 static unsigned int hw_status
;
469 static void receive_booted(Packet
*packet
, void *stateptr
) {
470 unsigned reason
, debugID
, OSinfo1
, OSinfo2
, banner_length
, bufsiz
, longsiz
;
475 count
= unpack_message(BUFFERDATA(packet
->pk_buffer
),
476 "%w%w%w%w%w%w%w%w%w%w%w%w",
477 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &bufsiz
, &longsiz
,
478 &angel_version
, &adp_version
,
479 &arch_info
, &cpu_info
, &hw_status
, &banner_length
);
480 if (reason
==(ADP_Booted
| TtoH
)) {
481 #ifdef MONITOR_DOWNLOAD_PACKETS
482 angel_DebugPrint("DEBUG: Successfully received Booted\n");
483 angel_DebugPrint(" cpu_info=%8X, hw_status=%8X, bufsiz=%d, longsiz=%d\n",
484 cpu_info
, hw_status
, bufsiz
, longsiz
);
486 /* Get the banner from the booted message */
487 for (i
=0; i
<banner_length
; i
++)
488 angel_hostif
->writec(angel_hostif
->hostosarg
,
489 (BUFFERDATA(packet
->pk_buffer
)+count
)[i
]);
491 booted_not_received
=0;
493 heartbeat_enabled
= TRUE
;
495 Armsd_BufferSize
= bufsiz
+ CHAN_HEADER_SIZE
;
496 Armsd_LongBufSize
= longsiz
+ CHAN_HEADER_SIZE
;
499 angel_DebugPrint("DEBUG: Bad Booted msg: reason=%8X\n", reason
);
502 DevSW_FreePacket(packet
);
506 /* forward declaration */
507 static int angel_negotiate_defaults( void );
509 /* Open communications. */
511 unsigned type
, Dbg_ConfigBlock
const *config
,
512 Dbg_HostosInterface
const *hostif
, struct Dbg_MCState
*dbg_state
)
515 int status
, reasoncode
, debugID
, OSinfo1
, OSinfo2
, err
;
516 ParameterOptions
*user_options
= NULL
;
522 if ((type
& 1) == 0) {
524 if (hostif
!= NULL
) {
525 angel_hostif
= hostif
;
526 err
= HostSysInit(hostif
, &ardi_commandline
, &hstate
);
527 if (err
!= RDIError_NoError
) {
529 angel_DebugPrint("DEBUG: HostSysInit error %i\n",err
);
538 angel_DebugPrint("DEBUG: Buffer allocated in angel_RDI_open(type=%i).\n",type
);
541 if ((type
& 1) == 0) {
544 Adp_Ioctl( DC_GET_USER_PARAMS
, (void *)&user_options
);
545 if ( user_options
!= NULL
) {
546 err
= negotiate_params( user_options
);
547 if (err
!= adp_ok
) return err
;
550 ParameterConfig
*default_config
= NULL
;
551 Adp_Ioctl( DC_GET_DEFAULT_PARAMS
, (void *)&default_config
);
552 if ( default_config
!= NULL
) {
553 ParameterOptions
*default_options
= config_to_options(default_config
);
554 err
= negotiate_params( default_options
);
555 if (err
!= adp_ok
) return err
;
559 /* Register handlers before sending any messages */
560 booted_not_received
=1;
561 Adp_ChannelRegisterRead(CI_HBOOT
, receive_reset_acknowledge
, NULL
);
562 Adp_ChannelRegisterRead(CI_TBOOT
, receive_booted
, NULL
);
565 if (config
->bytesex
& RDISex_Little
) endian
|= ADP_BootHostFeature_LittleEnd
;
566 if (config
->bytesex
& RDISex_Big
) endian
|= ADP_BootHostFeature_BigEnd
;
568 msgsend(CI_HBOOT
,"%w%w%w%w%w", ADP_Reset
| HtoT
, 0,
569 ADP_HandleUnknown
, ADP_HandleUnknown
, endian
);
571 angel_DebugPrint("DEBUG: Transmitted Reset message in angel_RDI_open.\n");
574 /* We will now either get an acknowledgement for the Reset message
575 * or if the target was started after the host, we will get a
576 * rebooted message first.
580 angel_DebugPrint("DEBUG: waiting for a booted message\n");
584 boot_interrupted
= FALSE
;
587 install_ardi_handler();
592 Adp_AsynchronousProcessing(async_block_on_nothing
);
593 if ((time(NULL
)-t
) > ADP_INITIAL_TIMEOUT_PERIOD
&& !late_booted
) {
594 return adp_timeout_on_open
;
596 } while (booted_not_received
&& !boot_interrupted
);
598 if (ardi_handler_installed
)
600 /* uninstall our Ctrl-C handler */
602 sigaction(SIGINT
, &old_action
, NULL
);
604 signal(SIGINT
, old_handler
);
608 if (boot_interrupted
) {
609 angel_negotiate_defaults();
610 return adp_abandon_boot_wait
;
614 booted_not_received
=1;
615 Adp_ChannelRegisterRead(CI_HBOOT
, NULL
, NULL
);
617 /* Leave the booted handler installed */
618 msgsend(CI_TBOOT
, "%w%w%w%w%w", ADP_Booted
| HtoT
, 0,
619 ADP_HandleUnknown
, ADP_HandleUnknown
, 0);
622 angel_DebugPrint("DEBUG: Transmitted ADP_Booted acknowledgement.\n");
623 angel_DebugPrint("DEBUG: Boot sequence completed, leaving angel_RDI_open.\n");
626 return (hw_status
& ADP_CPU_BigEndian
)? RDIError_BigEndian
:
627 RDIError_LittleEndian
;
631 register_debug_message_handler();
633 msgsend(CI_HADP
, "%w%w%w%w",
634 ADP_InitialiseApplication
| HtoT
, 0,
635 ADP_HandleUnknown
, ADP_HandleUnknown
);
637 angel_DebugPrint("DEBUG: Transmitted Initialise Application\n");
639 reasoncode
=ADP_InitialiseApplication
| TtoH
;
640 err
= wait_for_debug_message(&reasoncode
, &debugID
, &OSinfo1
, &OSinfo2
,
642 if (err
!= RDIError_NoError
) return err
;
649 /*----------------------------------------------------------------------*/
650 /*----angel_RDI_close----------------------------------------------------*/
651 /*----------------------------------------------------------------------*/
653 static int angel_negotiate_defaults( void ) {
655 ParameterConfig
*default_config
= NULL
;
656 Adp_Ioctl( DC_GET_DEFAULT_PARAMS
, (void *)&default_config
);
657 if ( default_config
!= NULL
) {
658 ParameterOptions
*default_options
= config_to_options(default_config
);
659 err
= negotiate_params( default_options
);
660 free( default_options
);
665 int angel_RDI_close(void) {
668 int status
,debugID
, OSinfo1
,OSinfo2
;
670 Packet
*packet
= NULL
;;
672 angel_DebugPrint("DEBUG: Entered angel_RDI_Close.\n");
675 register_debug_message_handler();
677 heartbeat_enabled
= FALSE
;
679 err
= msgsend(CI_HADP
,"%w%w%w%w",ADP_End
| HtoT
,0,
680 ADP_HandleUnknown
, ADP_HandleUnknown
);
681 if (err
!= RDIError_NoError
) return err
;
682 reason
= ADP_End
| TtoH
;
683 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
685 DevSW_FreePacket(packet
);
686 if (err
!= RDIError_NoError
) return err
;
687 if (status
== RDIError_NoError
) {
688 err
= angel_negotiate_defaults();
689 if (err
!= adp_ok
) return err
;
690 Adp_Ioctl( DC_RESET
, NULL
); /* just to be safe */
691 return HostSysExit(hstate
);
698 /*----------------------------------------------------------------------*/
699 /*----angel_RDI_read-----------------------------------------------------*/
700 /*----------------------------------------------------------------------*/
702 /* Read memory contents from target to host: use ADP_Read */
703 int angel_RDI_read(ARMword source
, void *dest
, unsigned *nbytes
)
706 int len
; /* Integer to hold message length. */
707 unsigned int nbtogo
= *nbytes
, nbinpacket
, nbdone
=0;
708 int rnbytes
= 0, status
, reason
, debugID
, OSinfo1
, OSinfo2
, err
;
709 unsigned int maxlen
= Armsd_BufferSize
-CHAN_HEADER_SIZE
-ADP_ReadHeaderSize
;
711 /* Print debug trace information, this is just copied straight from rdi.c
712 and I can see no reason why it should have to be changed. */
713 TracePrint(("angel_RDI_read: source=%.8lx dest=%p nbytes=%.8x\n",
714 (unsigned long)source
, dest
, *nbytes
));
715 if (*nbytes
== 0) return RDIError_NoError
; /* Read nothing - easy! */
716 /* check the buffer size */
718 register_debug_message_handler();
720 nbinpacket
= (nbtogo
<= maxlen
) ? nbtogo
: maxlen
;
721 len
= msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Read
| HtoT
, 0,
722 ADP_HandleUnknown
, ADP_HandleUnknown
, source
+nbdone
,
724 reason
=ADP_Read
| TtoH
;
725 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
727 TracePrint(("angel_RDI_read: nbinpacket =%d status=%08x err = %d\n",
728 nbinpacket
,status
,err
));
729 if (err
!= RDIError_NoError
) return err
; /* Was there an error? */
730 if (status
== RDIError_NoError
){
731 rnbytes
+= PREAD(LE
,(unsigned int *)(BUFFERDATA(packet
->pk_buffer
)+20));
732 TracePrint(("angel_RDI_read: rnbytes = %d\n",rnbytes
));
733 memcpy(((unsigned char *)dest
)+nbdone
, BUFFERDATA(packet
->pk_buffer
)+24,
736 nbdone
+= nbinpacket
;
737 nbtogo
-= nbinpacket
;
744 /*----------------------------------------------------------------------*/
745 /*----angel_RDI_write----------------------------------------------------*/
746 /*----------------------------------------------------------------------*/
748 /* Transfer memory block from host to target. Use ADP_Write>. */
749 int angel_RDI_write(const void *source
, ARMword dest
, unsigned *nbytes
)
751 Packet
*packet
;/* Message buffers. */
752 unsigned int len
, nbtogo
= *nbytes
, nboffset
= 0, nbinpacket
;
753 int status
, reason
, debugID
, OSinfo1
, OSinfo2
, err
;
754 unsigned int maxlen
= Armsd_LongBufSize
-CHAN_HEADER_SIZE
-ADP_WriteHeaderSize
;
756 TracePrint(("angel_RDI_write: source=%p dest=%.8lx nbytes=%.8x\n",
757 source
, (unsigned long)dest
, *nbytes
));
759 if (*nbytes
== 0) return RDIError_NoError
;
763 packet
= (Packet
*) DevSW_AllocatePacket(Armsd_LongBufSize
);
764 nbinpacket
= (nbtogo
<= maxlen
) ? nbtogo
: maxlen
;
765 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w",
766 ADP_Write
| HtoT
, 0, ADP_HandleUnknown
,
767 ADP_HandleUnknown
, dest
+nboffset
, nbinpacket
);
768 /* Copy the data into the packet. */
770 memcpy(BUFFERDATA(packet
->pk_buffer
)+len
,
771 ((const unsigned char *) source
)+nboffset
, nbinpacket
);
772 nboffset
+= nbinpacket
;
773 packet
->pk_length
= nbinpacket
+len
;
775 #ifdef MONITOR_DOWNLOAD_PACKETS
776 angel_DebugPrint("angel_RDI_write packet size=%i, bytes done=%i\n",
777 nbinpacket
, nboffset
);
780 register_debug_message_handler();
781 Adp_ChannelWrite(CI_HADP
, packet
);
782 reason
=ADP_Write
| TtoH
;
783 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
785 nbtogo
-= nbinpacket
;
786 if (err
!= RDIError_NoError
) return err
;
787 if (status
== RDIError_NoError
)
788 *nbytes
+= nbinpacket
;
790 DevSW_FreePacket(packet
);
796 /*----------------------------------------------------------------------*/
797 /*----angel_RDI_CPUread--------------------------------------------------*/
798 /*----------------------------------------------------------------------*/
800 /* Reads the values of registers in the CPU, uses ADP_CPUwrite. */
801 int angel_RDI_CPUread(unsigned mode
, unsigned long mask
, ARMword
*buffer
)
804 Packet
*packet
= NULL
;
805 int err
, status
, reason
, debugID
, OSinfo1
, OSinfo2
;
807 angel_DebugPrint("DEBUG: Entered angel_RDI_CPUread.\n");
809 for (i
=0, j
=0 ; i
< RDINumCPURegs
; i
++)
810 if (mask
& (1L << i
)) j
++; /* Count the number of registers. */
812 register_debug_message_handler();
813 msgsend(CI_HADP
, "%w%w%w%w%c%w", ADP_CPUread
| HtoT
, 0,
814 ADP_HandleUnknown
, ADP_HandleUnknown
, mode
, mask
);
815 reason
= ADP_CPUread
| TtoH
;
816 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
818 if (err
!= RDIError_NoError
) {
819 DevSW_FreePacket(packet
);
822 if(status
== RDIError_NoError
) {
824 buffer
[i
] = GET32LE(BUFFERDATA(packet
->pk_buffer
)+20+(i
*4));
825 TracePrint(("angel_RDI_CPUread: mode=%.8x mask=%.8lx", mode
, mask
));
826 DevSW_FreePacket(packet
);
830 for (k
= 0, j
= 0 ; j
<= 20 ; j
++)
831 if (mask
& (1L << j
)) {
832 angel_DebugPrint("%c%.8lx",k
%4==0?'\n':' ',
833 (unsigned long)buffer
[k
]);
836 angel_DebugPrint("\n") ;
844 /*----------------------------------------------------------------------*/
845 /*----angel_RDI_CPUwrite-------------------------------------------------*/
846 /*----------------------------------------------------------------------*/
848 /* Write CPU registers: use ADP_CPUwrite. */
849 int angel_RDI_CPUwrite(unsigned mode
, unsigned long mask
,
850 ARMword
const *buffer
){
854 int status
, reason
, debugID
, OSinfo1
, OSinfo2
, err
, len
;
856 TracePrint(("angel_RDI_CPUwrite: mode=%.8x mask=%.8lx", mode
, mask
));
859 for (j
= 0, i
= 0 ; i
<= 20 ; i
++)
860 if (mask
& (1L << i
)) {
861 angel_DebugPrint("%c%.8lx",j
%4==0?'\n':' ',
862 (unsigned long)buffer
[j
]);
865 angel_DebugPrint("\n") ;
868 packet
= (Packet
*)DevSW_AllocatePacket(Armsd_BufferSize
);
869 for (i
=0, j
=0; i
< RDINumCPURegs
; i
++)
870 if (mask
& (1L << i
)) j
++; /* count the number of registers */
872 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%b%w",
873 ADP_CPUwrite
| HtoT
, 0,
874 ADP_HandleUnknown
, ADP_HandleUnknown
, mode
, mask
);
876 PUT32LE(BUFFERDATA(packet
->pk_buffer
)+len
+(c
*4), buffer
[c
]);
877 packet
->pk_length
= len
+(j
*4);
878 register_debug_message_handler();
880 Adp_ChannelWrite(CI_HADP
, packet
);
881 reason
= ADP_CPUwrite
| TtoH
;
882 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
884 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
, &debugID
,
885 &OSinfo1
, &OSinfo2
, &status
);
886 DevSW_FreePacket(packet
);
887 if (err
!= RDIError_NoError
)
888 return err
; /* Was there an error? */
894 /*----------------------------------------------------------------------*/
895 /*----angel_RDI_CPread---------------------------------------------------*/
896 /*----------------------------------------------------------------------*/
898 /* Read coprocessor's internal state. See dbg_cp.h for help.
900 * It would appear that the correct behaviour at this point is to leave
901 * the unpacking to a the caller and to simply copy the stream of data
902 * words into the buffer
905 int angel_RDI_CPread(unsigned CPnum
, unsigned long mask
, ARMword
*buffer
){
906 Packet
*packet
= NULL
;
907 int i
, j
, status
, reasoncode
, OSinfo1
, OSinfo2
, err
, debugID
;
908 unsigned char *rmap
= cpwords
[CPnum
];
911 angel_DebugPrint("DEBUG: Entered angel_RDI_CPread.\n");
913 if (rmap
== NULL
) return RDIError_UnknownCoPro
;
915 register_debug_message_handler();
917 msgsend(CI_HADP
, "%w%w%w%w%b%w", ADP_CPread
| HtoT
, 0,
918 ADP_HandleUnknown
, ADP_HandleUnknown
, CPnum
, mask
);
919 reasoncode
=ADP_CPread
| TtoH
;
920 err
= wait_for_debug_message(&reasoncode
, &debugID
, &OSinfo1
, &OSinfo2
,
922 if (err
!= RDIError_NoError
) {
923 DevSW_FreePacket(packet
);
924 return err
; /* Was there an error? */
926 for (j
=i
=0; i
< n
; i
++) /* count the number of registers */
927 if (mask
& (1L << i
)) {
931 buffer
[i
] = PREAD32(LE
, BUFFERDATA(packet
->pk_buffer
) + 20 + (i
*4));
932 DevSW_FreePacket(packet
);
933 TracePrint(("angel_RDI_CPread: CPnum=%.8x mask=%.8lx\n", CPnum
, mask
));
936 for (i
= 0, j
= 0; j
< n
; j
++) {
937 if (mask
& (1L << j
)) {
939 angel_DebugPrint("%2d ", j
);
941 angel_DebugPrint("%.8lx ", (unsigned long)buffer
[i
++]);
942 angel_DebugPrint("%.8lx\n", (unsigned long)buffer
[i
++]);
951 /*----------------------------------------------------------------------*/
952 /*----angel_RDI_CPwrite--------------------------------------------------*/
953 /*----------------------------------------------------------------------*/
955 /* Write coprocessor's internal state. See dbg_cp.h for help. Use
959 int angel_RDI_CPwrite(unsigned CPnum
, unsigned long mask
,
960 ARMword
const *buffer
)
962 Packet
*packet
= NULL
;
963 int i
, j
, len
, status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
964 unsigned char *rmap
= cpwords
[CPnum
];
967 if (rmap
== NULL
) return RDIError_UnknownCoPro
;
970 TracePrint(("angel_RDI_CPwrite: CPnum=%d mask=%.8lx\n", CPnum
, mask
));
974 for (i
= 0, j
= 0; j
< n
; j
++)
975 if (mask
& (1L << j
)) {
977 angel_DebugPrint("%2d ", j
);
979 angel_DebugPrint("%.8lx ", (unsigned long)buffer
[i
++]);
980 angel_DebugPrint("%.8lx\n", (unsigned long)buffer
[i
++]);
985 for (j
=i
=0; i
< n
; i
++) /* Count the number of registers. */
986 if (mask
& (1L << i
)) j
++;
987 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
988 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%c%w",
989 ADP_CPwrite
| HtoT
, 0,
990 ADP_HandleUnknown
, ADP_HandleUnknown
, CPnum
, mask
);
992 len
+=msgbuild(BUFFERDATA(packet
->pk_buffer
) + len
, "%w", buffer
[i
]);
993 packet
->pk_length
= len
;
994 register_debug_message_handler();
995 Adp_ChannelWrite(CI_HADP
, packet
); /* Transmit message. */
996 reason
=ADP_CPwrite
| TtoH
;
997 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
999 DevSW_FreePacket(packet
);
1000 if (err
!= RDIError_NoError
)
1007 /*----------------------------------------------------------------------*/
1008 /*----angel_RDI_pointinq-------------------------------------------------*/
1009 /*----------------------------------------------------------------------*/
1011 /* Do test calls to ADP_SetBreak/ADP_SetWatch to see if resources exist to
1012 carry out request. */
1013 int angel_RDI_pointinq(ARMword
*address
, unsigned type
, unsigned datatype
,
1016 Packet
*packet
= NULL
;
1017 int len
, status
, reason
, OSinfo1
, OSinfo2
, err
=RDIError_NoError
;
1018 /* stop a compiler warning */
1019 int debugID
, pointhandle
;
1021 ("angel_RDI_pointinq: address=%.8lx type=%d datatype=%d bound=%.8lx ",
1022 (unsigned long)*address
, type
, datatype
, (unsigned long)*bound
));
1024 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
1025 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%b",
1026 ((datatype
== 0) ? ADP_SetBreak
: ADP_SetWatch
) | HtoT
, 0,
1027 ADP_HandleUnknown
, ADP_HandleUnknown
, address
, type
);
1029 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
) + 21, "%w", bound
);
1031 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
) + 21, "%b%w", datatype
, bound
);
1033 register_debug_message_handler();
1034 packet
->pk_length
= len
;
1035 Adp_ChannelWrite(CI_HADP
, packet
);
1036 reason
= ((datatype
== 0) ? ADP_SetBreak
: ADP_SetWatch
| TtoH
);
1037 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1039 if (err
!= RDIError_NoError
) {
1040 DevSW_FreePacket(packet
);
1041 return err
; /* Was there an error? */
1043 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
1044 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &status
,
1045 &pointhandle
, &address
, &bound
);
1046 DevSW_FreePacket(packet
);
1051 /*----------------------------------------------------------------------*/
1052 /*----angel_RDI_setbreak-------------------------------------------------*/
1053 /*----------------------------------------------------------------------*/
1055 /* Set a breakpoint: Use ADP_SetBreak */
1056 int angel_RDI_setbreak(ARMword address
, unsigned type
, ARMword bound
,
1057 PointHandle
*handle
)
1059 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1060 int tmpval
, tmpaddr
, tmpbnd
;
1062 TracePrint(("angel_RDI_setbreak address=%.8lx type=%d bound=%.8lx \n",
1063 (unsigned long)address
, type
, (unsigned long)bound
));
1065 register_debug_message_handler();
1066 msgsend(CI_HADP
, "%w%w%w%w%w%b%w",
1067 ADP_SetBreak
| HtoT
, 0, ADP_HandleUnknown
,
1068 ADP_HandleUnknown
, address
, type
, bound
);
1069 reason
= ADP_SetBreak
|TtoH
;
1070 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1072 if (err
!= RDIError_NoError
) {
1073 DevSW_FreePacket(packet
);
1074 return err
; /* Was there an error? */
1076 /* Work around varargs problem... -sts */
1077 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
1078 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &status
,
1079 &tmpval
, &tmpaddr
, &tmpbnd
);
1083 DevSW_FreePacket(packet
);
1084 if (status
!= RDIError_NoError
) return status
;
1085 TracePrint(("returns handle %.8lx\n", (unsigned long)*handle
));
1086 return RDIError_NoError
;
1090 /*----------------------------------------------------------------------*/
1091 /*----angel_RDI_clearbreak-----------------------------------------------*/
1092 /*----------------------------------------------------------------------*/
1094 /* Clear a breakpoint: Use ADP_ClearBreak. */
1095 int angel_RDI_clearbreak(PointHandle handle
)
1097 Packet
*packet
= NULL
;
1098 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1100 TracePrint(("angel_RDI_clearbreak: handle=%.8lx\n", (unsigned long)handle
));
1102 register_debug_message_handler();
1103 msgsend(CI_HADP
, "%w%w%w%w%w",
1104 ADP_ClearBreak
| HtoT
, 0, ADP_HandleUnknown
,
1105 ADP_HandleUnknown
, handle
);
1106 reason
= ADP_ClearBreak
|TtoH
;
1107 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1109 if (err
!= RDIError_NoError
) {
1110 DevSW_FreePacket(packet
);
1111 angel_DebugPrint("***RECEIVE DEBUG MESSAGE RETURNED ERR = %d.\n", err
);
1112 return err
; /* Was there an error? */
1114 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
,
1115 &debugID
, &OSinfo1
, &OSinfo2
, &status
);
1116 DevSW_FreePacket(packet
);
1118 angel_DebugPrint("DEBUG: Clear Break completed OK.\n");
1120 return RDIError_NoError
;
1124 /*----------------------------------------------------------------------*/
1125 /*----angel_RDI_setwatch-------------------------------------------------*/
1126 /*----------------------------------------------------------------------*/
1128 /* Set a watchpoint: use ADP_SetWatch. */
1129 int angel_RDI_setwatch(ARMword address
, unsigned type
, unsigned datatype
,
1130 ARMword bound
, PointHandle
*handle
)
1132 Packet
*packet
= NULL
;
1133 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1135 TracePrint(("angel_RDI_setwatch: address=%.8lx type=%d bound=%.8lx ",
1136 (unsigned long)address
, type
, (unsigned long)bound
));
1138 register_debug_message_handler();
1139 msgsend(CI_HADP
, "%w%w%w%w%w%b%b%w",
1140 ADP_SetWatch
| HtoT
, 0, ADP_HandleUnknown
,
1141 ADP_HandleUnknown
, address
, type
, datatype
, bound
);
1143 reason
= ADP_SetWatch
| TtoH
;
1144 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1146 if (err
!= RDIError_NoError
) {
1147 DevSW_FreePacket(packet
);
1148 return err
; /* Was there an error? */
1150 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
1151 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &status
,
1152 handle
, &address
, &bound
);
1153 DevSW_FreePacket(packet
);
1154 TracePrint(("returns handle %.8lx\n", (unsigned long)*handle
));
1155 return RDIError_NoError
;
1158 /*----------------------------------------------------------------------*/
1159 /*----angel_RDI_clearwatch-----------------------------------------------*/
1160 /*----------------------------------------------------------------------*/
1162 /* Clear a watchpoint: use ADP_ClearWatch. */
1163 int angel_RDI_clearwatch(PointHandle handle
) {
1165 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1166 Packet
*packet
= NULL
;
1168 TracePrint(("angel_RDI_clearwatch: handle=%.8lx\n", (unsigned long)handle
));
1170 register_debug_message_handler();
1171 msgsend(CI_HADP
, "%w%w%w%w%w",
1172 ADP_ClearWatch
| HtoT
, 0, ADP_HandleUnknown
,
1173 ADP_HandleUnknown
, handle
);
1174 reason
= ADP_ClearWatch
|TtoH
;
1175 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1177 if (err
!= RDIError_NoError
) {
1178 DevSW_FreePacket(packet
);
1179 return err
; /* Was there an error? */
1181 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
, &debugID
,
1182 &OSinfo1
, &OSinfo2
, &status
);
1183 DevSW_FreePacket(packet
);
1184 return RDIError_NoError
;
1188 unsigned stopped_reason
;
1191 } adp_stopped_struct
;
1194 int angel_RDI_OnTargetStopping(angel_RDI_TargetStoppedProc
*fn
,
1197 stoppedProcListElement
**lptr
= &stopped_proc_list
;
1199 /* Find the address of the NULL ptr at the end of the list */
1200 for (; *lptr
!=NULL
; lptr
= &((*lptr
)->next
))
1203 *lptr
= (stoppedProcListElement
*) malloc(sizeof(stoppedProcListElement
));
1204 if (*lptr
== NULL
) return RDIError_OutOfStore
;
1208 return RDIError_NoError
;
1211 static int CallStoppedProcs(unsigned reason
)
1213 stoppedProcListElement
*p
= stopped_proc_list
;
1214 int err
=RDIError_NoError
;
1216 for (; p
!=NULL
; p
=p
->next
) {
1217 int local_err
= p
->fn(reason
, p
->arg
);
1218 if (local_err
!= RDIError_NoError
) err
=local_err
;
1224 /*----------------------------------------------------------------------*/
1225 /*----angel_RDI_execute--------------------------------------------------*/
1226 /*----------------------------------------------------------------------*/
1228 static int HandleStoppedMessage(Packet
*packet
, void *stateptr
) {
1229 unsigned int err
, reason
, debugID
, OSinfo1
, OSinfo2
, count
;
1230 adp_stopped_struct
*stopped_info
;
1231 stopped_info
= (adp_stopped_struct
*) stateptr
;
1233 count
= unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w",
1236 &stopped_info
->stopped_reason
, &stopped_info
->data
);
1237 DevSW_FreePacket(packet
);
1239 if (reason
!= (ADP_Stopped
| TtoH
)) {
1241 angel_DebugPrint("Expecting stopped message, got %x", reason
);
1243 return RDIError_Error
;
1248 angel_DebugPrint("Received stopped message.\n");
1252 err
= msgsend(CI_TADP
, "%w%w%w%w%w", (ADP_Stopped
| HtoT
), 0,
1253 ADP_HandleUnknown
, ADP_HandleUnknown
, RDIError_NoError
);
1255 angel_DebugPrint("Transmiting stopped acknowledge.\n");
1257 if (err
!= RDIError_NoError
) angel_DebugPrint("Transmit failed.\n");
1259 angel_DebugPrint("DEBUG: Stopped reason : %x\n", stopped_info
->stopped_reason
);
1261 switch (stopped_info
->stopped_reason
) {
1262 case ADP_Stopped_BranchThroughZero
:
1263 stopped_info
->stopped_status
= RDIError_BranchThrough0
;
1265 case ADP_Stopped_UndefinedInstr
:
1266 stopped_info
->stopped_status
= RDIError_UndefinedInstruction
;
1268 case ADP_Stopped_SoftwareInterrupt
:
1269 stopped_info
->stopped_status
= RDIError_SoftwareInterrupt
;
1271 case ADP_Stopped_PrefetchAbort
:
1272 stopped_info
->stopped_status
= RDIError_PrefetchAbort
;
1274 case ADP_Stopped_DataAbort
:
1275 stopped_info
->stopped_status
= RDIError_DataAbort
;
1277 case ADP_Stopped_AddressException
:
1278 stopped_info
->stopped_status
= RDIError_AddressException
;
1280 case ADP_Stopped_IRQ
:
1281 stopped_info
->stopped_status
= RDIError_IRQ
;
1283 case ADP_Stopped_BreakPoint
:
1284 stopped_info
->stopped_status
= RDIError_BreakpointReached
;
1286 case ADP_Stopped_WatchPoint
:
1287 stopped_info
->stopped_status
= RDIError_WatchpointAccessed
;
1289 case ADP_Stopped_StepComplete
:
1290 stopped_info
->stopped_status
= RDIError_ProgramFinishedInStep
;
1292 case ADP_Stopped_RunTimeErrorUnknown
:
1293 case ADP_Stopped_StackOverflow
:
1294 case ADP_Stopped_DivisionByZero
:
1295 stopped_info
->stopped_status
= RDIError_Error
;
1297 case ADP_Stopped_FIQ
:
1298 stopped_info
->stopped_status
= RDIError_FIQ
;
1300 case ADP_Stopped_UserInterruption
:
1301 case ADP_Stopped_OSSpecific
:
1302 stopped_info
->stopped_status
= RDIError_UserInterrupt
;
1304 case ADP_Stopped_ApplicationExit
:
1305 stopped_info
->stopped_status
= RDIError_NoError
;
1308 stopped_info
->stopped_status
= RDIError_Error
;
1311 return RDIError_NoError
;
1315 static void interrupt_target( void )
1317 Packet
*packet
= NULL
;
1319 int reason
, debugID
, OSinfo1
, OSinfo2
, status
;
1322 angel_DebugPrint("DEBUG: interrupt_target.\n");
1325 register_debug_message_handler();
1326 msgsend(CI_HADP
, "%w%w%w%w", ADP_InterruptRequest
| HtoT
, 0,
1327 ADP_HandleUnknown
, ADP_HandleUnknown
);
1329 reason
= ADP_InterruptRequest
|TtoH
;
1330 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1332 DevSW_FreePacket(packet
);
1334 angel_DebugPrint("DEBUG: got interrupt ack ok err = %d, status=%i\n",
1342 extern void test_dc_appl_handler( const DeviceDescr
*device
,
1346 /* Core functionality for execute and step */
1347 static int angel_RDI_ExecuteOrStep(PointHandle
*handle
, word type
,
1351 adp_stopped_struct stopped_info
;
1352 void* stateptr
= (void *)&stopped_info
;
1353 ChannelCallback HandleStoppedMessageFPtr
=(ChannelCallback
) HandleStoppedMessage
;
1354 int status
, reasoncode
, debugID
, OSinfo1
, OSinfo2
;
1355 Packet
*packet
= NULL
;
1357 TracePrint(("angel_RDI_ExecuteOrStep\n"));
1359 err
= Adp_ChannelRegisterRead(CI_TADP
,
1360 HandleStoppedMessageFPtr
, stateptr
);
1361 if (err
!= RDIError_NoError
) {
1363 angel_DebugPrint("TADP Register failed.\n");
1367 /* Set executing TRUE here, as it must be set up before the target has
1368 * had any chance at all to execute, or it may send its stopped message
1369 * before we get round to setting executing = TRUE !!!
1373 register_debug_message_handler();
1376 Adp_Install_DC_Appl_Handler( test_dc_appl_handler
);
1380 angel_DebugPrint("Transmiting %s message.\n",
1381 type
== ADP_Execute
? "execute": "step");
1384 register_debug_message_handler();
1385 /* Extra ninstr parameter for execute message will simply be ignored */
1386 err
= msgsend(CI_HADP
,"%w%w%w%w%w", type
| HtoT
, 0,
1387 ADP_HandleUnknown
, ADP_HandleUnknown
, ninstr
);
1389 if (err
!= RDIError_NoError
) angel_DebugPrint("Transmit failed.\n");
1392 reasoncode
= type
| TtoH
;
1393 err
= wait_for_debug_message( &reasoncode
, &debugID
, &OSinfo1
, &OSinfo2
,
1395 if (err
!= RDIError_NoError
)
1397 else if (status
!= RDIError_NoError
)
1401 angel_DebugPrint("Waiting for program to finish...\n");
1404 signal(SIGINT
, ardi_sigint_handler
);
1407 if (interrupt_request
)
1410 interrupt_request
= FALSE
;
1412 Adp_AsynchronousProcessing( async_block_on_nothing
);
1414 signal(SIGINT
, SIG_IGN
);
1418 Adp_Install_DC_Appl_Handler( NULL
);
1421 (void)Adp_ChannelRegisterRead(CI_TADP
, NULL
, NULL
);
1423 *handle
= (PointHandle
)stopped_info
.data
;
1425 CallStoppedProcs(stopped_info
.stopped_reason
);
1427 return stopped_info
.stopped_status
;
1430 /* Request that the target starts executing from the stored CPU state: use
1432 int angel_RDI_execute(PointHandle
*handle
)
1434 return angel_RDI_ExecuteOrStep(handle
, ADP_Execute
, 0);
1438 typedef void handlertype(int);
1440 static int interrupted
=0;
1442 static void myhandler(int sig
) {
1445 signal(SIGINT
, myhandler
);
1449 /*----------------------------------------------------------------------*/
1450 /*----angel_RDI_step-----------------------------------------------------*/
1451 /*----------------------------------------------------------------------*/
1453 /* Step 'ninstr' through the code: use ADP_Step. */
1454 int angel_RDI_step(unsigned ninstr
, PointHandle
*handle
)
1456 int err
= angel_RDI_ExecuteOrStep(handle
, ADP_Step
, ninstr
);
1457 if (err
== RDIError_ProgramFinishedInStep
)
1458 return RDIError_NoError
;
1464 static void SetCPWords(int cpnum
, struct Dbg_CoProDesc
const *cpd
) {
1466 for (i
= 0; i
< cpd
->entries
; i
++)
1467 if (cpd
->regdesc
[i
].rmax
> rmax
)
1468 rmax
= cpd
->regdesc
[i
].rmax
;
1470 { unsigned char *rmap
= (unsigned char *)malloc(rmax
+ 2);
1472 for (i
= 0; i
< cpd
->entries
; i
++) {
1474 for (r
= cpd
->regdesc
[i
].rmin
; r
<= cpd
->regdesc
[i
].rmax
; r
++)
1475 rmap
[r
] = (cpd
->regdesc
[i
].nbytes
+3) / 4;
1477 /* if (cpwords[cpnum] != NULL) free(cpwords[cpnum]); */
1478 cpwords
[cpnum
] = rmap
;
1482 /*----------------------------------------------------------------------*/
1483 /*----angel_RDI_info-----------------------------------------------------*/
1484 /*----------------------------------------------------------------------*/
1486 /* Use ADP_Info, ADP_Ctrl and ADP_Profile calls to implement these,
1487 see adp.h for more details. */
1489 static int angel_cc_exists( void )
1491 Packet
*packet
= NULL
;
1493 int reason
, debugID
, OSinfo1
, OSinfo2
, subreason
, status
;
1496 angel_DebugPrint("DEBUG: ADP_ICEB_CC_Exists.\n");
1499 if ( angel_RDI_info( RDIInfo_Icebreaker
, NULL
, NULL
) == RDIError_NoError
) {
1500 register_debug_message_handler();
1501 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_ICEbreakerHADP
| HtoT
, 0,
1502 ADP_HandleUnknown
, ADP_HandleUnknown
,
1503 ADP_ICEB_CC_Exists
);
1504 reason
= ADP_ICEbreakerHADP
|TtoH
;
1505 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1507 if (err
!= RDIError_NoError
) {
1508 DevSW_FreePacket(packet
);
1511 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
1512 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1513 if (subreason
!= ADP_ICEB_CC_Exists
) {
1514 DevSW_FreePacket(packet
);
1515 return RDIError_Error
;
1521 return RDIError_UnimplementedMessage
;
1525 RDICCProc_ToHost
*tohost
; void *tohostarg
;
1526 RDICCProc_FromHost
*fromhost
; void *fromhostarg
;
1529 static CCState ccstate
= { NULL
, NULL
, NULL
, NULL
, FALSE
};
1531 static void HandleDCCMessage( Packet
*packet
, void *stateptr
)
1533 unsigned int reason
, debugID
, OSinfo1
, OSinfo2
;
1535 CCState
*ccstate_p
= (CCState
*)stateptr
;
1537 count
= unpack_message( BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w",
1538 &reason
, &debugID
, &OSinfo1
, &OSinfo2
);
1541 case ADP_TDCC_ToHost
| TtoH
:
1543 /* only handles a single word of data, for now */
1545 unsigned int nbytes
, data
;
1547 unpack_message( BUFFERDATA(packet
->pk_buffer
)+count
, "%w%w",
1550 angel_DebugPrint( "DEBUG: received CC_ToHost message: nbytes %d data %08x.\n",
1553 ccstate_p
->tohost( ccstate_p
->tohostarg
, data
);
1554 msgsend(CI_TTDCC
, "%w%w%w%w%w",
1555 ADP_TDCC_ToHost
| HtoT
, debugID
, OSinfo1
, OSinfo2
,
1560 case ADP_TDCC_FromHost
| TtoH
:
1562 /* only handles a single word of data, for now */
1567 ccstate_p
->fromhost( ccstate_p
->fromhostarg
, &data
, &valid
);
1569 angel_DebugPrint( "DEBUG: received CC_FromHost message, returning: %08x %s.\n",
1570 data
, valid
? "VALID" : "INvalid" );
1572 msgsend(CI_TTDCC
, "%w%w%w%w%w%w%w",
1573 ADP_TDCC_FromHost
| HtoT
, debugID
, OSinfo1
, OSinfo2
,
1574 RDIError_NoError
, valid
? 1 : 0, data
);
1580 angel_DebugPrint( "Unexpected TDCC message %08x received\n", reason
);
1584 DevSW_FreePacket(packet
);
1588 static void angel_check_DCC_handler( CCState
*ccstate_p
)
1592 if ( ccstate_p
->tohost
!= NULL
|| ccstate_p
->fromhost
!= NULL
)
1594 /* doing DCC, so need a handler */
1595 if ( ! ccstate_p
->registered
)
1598 angel_DebugPrint( "Registering handler for TTDCC channel.\n" );
1600 err
= Adp_ChannelRegisterRead( CI_TTDCC
, HandleDCCMessage
,
1602 if ( err
== adp_ok
)
1603 ccstate_p
->registered
= TRUE
;
1606 angel_DebugPrint( "angel_check_DCC_handler: register failed!\n" );
1612 /* not doing DCC, so don't need a handler */
1613 if ( ccstate_p
->registered
)
1616 angel_DebugPrint( "Unregistering handler for TTDCC channel.\n" );
1618 err
= Adp_ChannelRegisterRead( CI_TTDCC
, NULL
, NULL
);
1619 if ( err
== adp_ok
)
1620 ccstate_p
->registered
= FALSE
;
1623 angel_DebugPrint( "angel_check_DCC_handler: unregister failed!\n" );
1630 static int CheckSubMessageReply(int reason
, int subreason
) {
1631 Packet
*packet
= NULL
;
1632 int status
, debugID
, OSinfo1
, OSinfo2
;
1633 int err
= RDIError_NoError
;
1635 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1637 if (err
!= RDIError_NoError
) {
1641 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
1642 &OSinfo1
, &OSinfo2
, &sr
, &status
);
1643 if (subreason
!= sr
) status
= RDIError_Error
;
1645 DevSW_FreePacket(packet
);
1649 static int SendSubMessageAndCheckReply(int reason
, int subreason
) {
1650 register_debug_message_handler();
1651 msgsend(CI_HADP
, "%w%w%w%w%w", reason
| HtoT
, 0,
1652 ADP_HandleUnknown
, ADP_HandleUnknown
,
1654 return CheckSubMessageReply(reason
, subreason
);
1657 static int SendSubMessageWordAndCheckReply(int reason
, int subreason
, ARMword word
) {
1658 register_debug_message_handler();
1659 msgsend(CI_HADP
, "%w%w%w%w%w%w", reason
| HtoT
, 0,
1660 ADP_HandleUnknown
, ADP_HandleUnknown
,
1662 return CheckSubMessageReply(reason
, subreason
);
1665 static int SendSubMessageGetWordAndCheckReply(int reason
, int subreason
, ARMword
*resp
) {
1666 Packet
*packet
= NULL
;
1667 int status
, debugID
, OSinfo1
, OSinfo2
;
1668 int err
= RDIError_NoError
;
1670 register_debug_message_handler();
1671 msgsend(CI_HADP
, "%w%w%w%w%w", reason
| HtoT
, 0,
1672 ADP_HandleUnknown
, ADP_HandleUnknown
,
1675 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1677 if (err
!= RDIError_NoError
) {
1681 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w", &reason
, &debugID
,
1682 &OSinfo1
, &OSinfo2
, &sr
, &status
, resp
);
1683 if (subreason
!= sr
) status
= RDIError_Error
;
1685 DevSW_FreePacket(packet
);
1689 static int const hostsex
= 1;
1691 int angel_RDI_info(unsigned type
, ARMword
*arg1
, ARMword
*arg2
) {
1692 Packet
*packet
= NULL
;
1693 int len
, status
, c
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
;
1694 int err
=RDIError_NoError
, cpnum
=0;
1695 struct Dbg_CoProDesc
*cpd
;
1700 angel_DebugPrint("DEBUG: Entered angel_RDI_info.\n");
1703 case RDIInfo_Target
:
1705 angel_DebugPrint("DEBUG: RDIInfo_Target.\n");
1708 register_debug_message_handler();
1709 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1710 ADP_HandleUnknown
, ADP_HandleUnknown
, ADP_Info_Target
);
1711 reason
= ADP_Info
|TtoH
;
1712 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1714 if (err
!= RDIError_NoError
) {
1715 DevSW_FreePacket(packet
);
1718 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w", &reason
,
1719 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
,
1721 DevSW_FreePacket(packet
);
1723 if (subreason
!= ADP_Info_Target
)
1724 return RDIError_Error
;
1728 case RDISignal_Stop
:
1730 angel_DebugPrint("DEBUG: RDISignal_Stop.\n");
1731 if (interrupt_request
)
1732 angel_DebugPrint(" STILL WAITING to send previous interrupt request\n");
1734 interrupt_request
= TRUE
;
1735 return RDIError_NoError
;
1737 case RDIInfo_Points
:
1739 angel_DebugPrint("DEBUG: RDIInfo_Points.\n");
1741 return SendSubMessageGetWordAndCheckReply(ADP_Info
, ADP_Info_Points
, arg1
);
1745 angel_DebugPrint("DEBUG: RDIInfo_Step.\n");
1747 return SendSubMessageGetWordAndCheckReply(ADP_Info
, ADP_Info_Step
, arg1
);
1749 case RDISet_Cmdline
:
1751 angel_DebugPrint("DEBUG: RDISet_Cmdline.\n");
1753 if (ardi_commandline
!= &dummycline
)
1754 free(ardi_commandline
);
1755 ardi_commandline
= (char *)malloc(strlen((char*)arg1
) + 1) ;
1756 (void)strcpy(ardi_commandline
, (char *)arg1
) ;
1757 return RDIError_NoError
;
1759 case RDIInfo_SetLog
:
1761 angel_DebugPrint("DEBUG: RDIInfo_SetLog.\n");
1763 rdi_log
= (int) *arg1
;
1764 return RDIError_NoError
;
1768 angel_DebugPrint("DEBUG: RDIInfo_Log.\n");
1771 return RDIError_NoError
;
1776 angel_DebugPrint("DEBUG: RDIInfo_MMU.\n");
1778 return SendSubMessageGetWordAndCheckReply(ADP_Info
, ADP_Info_MMU
, arg1
);
1780 case RDIInfo_SemiHosting
:
1782 angel_DebugPrint("DEBUG: RDIInfo_SemiHosting.\n");
1784 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_SemiHosting
);
1788 angel_DebugPrint("DEBUG: RDIInfo_CoPro.\n");
1790 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_CoPro
);
1794 angel_DebugPrint("DEBUG: RDICycles.\n");
1796 register_debug_message_handler();
1797 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1798 ADP_HandleUnknown
, ADP_HandleUnknown
, ADP_Info_Cycles
);
1799 reason
= ADP_Info
|TtoH
;
1800 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1802 if (err
!= RDIError_NoError
) {
1803 DevSW_FreePacket(packet
);
1806 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
1807 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1808 DevSW_FreePacket(packet
);
1809 if (subreason
!= ADP_Info_Cycles
)
1810 return RDIError_Error
;
1811 if (status
!= RDIError_NoError
) return status
;
1812 for (c
=0; c
<12; c
++)
1813 arg1
[c
]=GET32LE(BUFFERDATA(packet
->pk_buffer
)+24+(c
*4));
1816 case RDIInfo_DescribeCoPro
:
1818 angel_DebugPrint("DEBUG: RDIInfo_DescribeCoPro.\n");
1820 cpnum
= *(int *)arg1
;
1821 cpd
= (struct Dbg_CoProDesc
*)arg2
;
1822 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
1823 if (angel_RDI_info(ADP_Info_CoPro
, NULL
, NULL
) != RDIError_NoError
)
1824 return RDIError_Error
;
1825 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1826 ADP_HandleUnknown
, ADP_HandleUnknown
,
1827 ADP_Info_DescribeCoPro
);
1828 len
+=msgbuild(BUFFERDATA(packet
->pk_buffer
)+20, "%b%b%b%b%b", cpnum
,
1829 cpd
->regdesc
[cpnum
].rmin
, cpd
->regdesc
[cpnum
].rmax
,
1830 cpd
->regdesc
[cpnum
].nbytes
, cpd
->regdesc
[cpnum
].access
);
1831 if (cpd
->regdesc
[cpnum
].access
&0x3 == 0x3){
1832 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
)+25, "%b%b%b%b%b",
1833 cpd
->regdesc
[cpnum
].accessinst
.cprt
.read_b0
,
1834 cpd
->regdesc
[cpnum
].accessinst
.cprt
.read_b1
,
1835 cpd
->regdesc
[cpnum
].accessinst
.cprt
.write_b0
,
1836 cpd
->regdesc
[cpnum
].accessinst
.cprt
.write_b1
, 0xff);
1839 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
)+25, "%b%b%b%b%b%",
1840 cpd
->regdesc
[cpnum
].accessinst
.cpdt
.rdbits
,
1841 cpd
->regdesc
[cpnum
].accessinst
.cpdt
.nbit
,0,0, 0xff);
1843 register_debug_message_handler();
1844 packet
->pk_length
= len
;
1845 Adp_ChannelWrite(CI_HADP
, packet
); /* Transmit message. */
1846 reason
= ADP_Info
|TtoH
;
1847 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1849 if (err
!= RDIError_NoError
) {
1850 DevSW_FreePacket(packet
);
1853 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
1854 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1855 DevSW_FreePacket(packet
);
1856 if (subreason
!= ADP_Info_DescribeCoPro
)
1857 return RDIError_Error
;
1861 case RDIInfo_RequestCoProDesc
:
1863 angel_DebugPrint("DEBUG: RDIInfo_RequestCoProDesc.\n");
1865 cpnum
= *(int *)arg1
;
1866 cpd
= (struct Dbg_CoProDesc
*)arg2
;
1867 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
1868 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1869 ADP_HandleUnknown
, ADP_HandleUnknown
,
1870 ADP_Info_RequestCoProDesc
);
1871 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
)+20, "%b", *(int *)arg1
);
1872 packet
->pk_length
= len
;
1873 register_debug_message_handler();
1874 Adp_ChannelWrite(CI_HADP
, packet
); /* Transmit message. */
1875 reason
= ADP_Info
|TtoH
;
1876 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1878 if (err
!= RDIError_NoError
) {
1879 DevSW_FreePacket(packet
);
1882 count
= unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
1883 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1884 if (subreason
!= ADP_Info_RequestCoProDesc
) {
1885 DevSW_FreePacket(packet
);
1886 return RDIError_Error
;
1887 } else if ( status
!= RDIError_NoError
) {
1888 DevSW_FreePacket(packet
);
1891 bp
= BUFFERDATA(packet
->pk_buffer
)+count
;
1892 for ( i
= 0; *bp
!= 0xFF && i
< cpd
->entries
; ++i
) {
1893 cpd
->regdesc
[i
].rmin
= *bp
++;
1894 cpd
->regdesc
[i
].rmax
= *bp
++;
1895 cpd
->regdesc
[i
].nbytes
= *bp
++;
1896 cpd
->regdesc
[i
].access
= *bp
++;
1900 status
= RDIError_BufferFull
;
1902 SetCPWords( cpnum
, cpd
);
1903 DevSW_FreePacket(packet
);
1907 case RDIInfo_GetLoadSize
:
1909 angel_DebugPrint("DEBUG: ADP_Info_AngelBufferSize.\n");
1911 register_debug_message_handler();
1912 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1913 ADP_HandleUnknown
, ADP_HandleUnknown
,
1914 ADP_Info_AngelBufferSize
);
1915 reason
= ADP_Info
|TtoH
;
1916 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1918 if (err
!= RDIError_NoError
) {
1919 DevSW_FreePacket(packet
);
1922 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
1923 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1924 if (subreason
!= ADP_Info_AngelBufferSize
) {
1925 DevSW_FreePacket(packet
);
1926 return RDIError_Error
;
1929 word defaultsize
, longsize
;
1930 unpack_message(BUFFERDATA(packet
->pk_buffer
)+24, "%w%w",
1931 &defaultsize
, &longsize
);
1932 *arg1
= longsize
- ADP_WriteHeaderSize
; /* space for ADP header */
1933 #ifdef MONITOR_DOWNLOAD_PACKETS
1934 angel_DebugPrint("DEBUG: ADP_Info_AngelBufferSize: got (%d, %d), returning %d.\n",
1935 defaultsize
, longsize
, *arg1
);
1937 DevSW_FreePacket(packet
);
1941 case RDIVector_Catch
:
1943 angel_DebugPrint("DEBUG: ADP_Ctrl_VectorCatch %lx.\n", *arg1
);
1945 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_VectorCatch
, *arg1
);
1947 case RDISemiHosting_SetState
:
1949 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetState %lx.\n", *arg1
);
1951 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetState
, *arg1
);
1953 case RDISemiHosting_GetState
:
1955 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetState.\n");
1957 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetState
, arg1
);
1959 case RDISemiHosting_SetVector
:
1961 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetVector %lx.\n", *arg1
);
1963 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetVector
, *arg1
);
1965 case RDISemiHosting_GetVector
:
1967 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetVector.\n");
1969 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetVector
, arg1
);
1971 case RDISemiHosting_SetARMSWI
:
1973 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetARMSWI.\n");
1975 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetARMSWI
, *arg1
);
1977 case RDISemiHosting_GetARMSWI
:
1979 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetARMSWI.\n");
1981 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetARMSWI
, arg1
);
1983 case RDISemiHosting_SetThumbSWI
:
1985 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetThumbSWI.\n");
1987 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetThumbSWI
, *arg1
);
1989 case RDISemiHosting_GetThumbSWI
:
1991 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetThumbSWI.\n");
1993 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetThumbSWI
, arg1
);
1995 case RDIInfo_SetTopMem
:
1997 angel_DebugPrint("DEBUG: ADP_Ctrl_SetTopMem.\n");
1999 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SetTopMem
, *arg1
);
2001 case RDIPointStatus_Watch
:
2003 angel_DebugPrint("DEBUG: ADP_Ctrl_PointStatus_Watch.\n");
2005 register_debug_message_handler();
2006 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Control
| HtoT
, 0,
2007 ADP_HandleUnknown
, ADP_HandleUnknown
,
2008 ADP_Ctrl_PointStatus_Watch
, *arg1
);
2009 reason
= ADP_Control
|TtoH
;
2010 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2012 if (err
!= RDIError_NoError
) {
2013 DevSW_FreePacket(packet
);
2016 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w", &reason
,
2017 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
,
2019 if (subreason
!= ADP_Ctrl_PointStatus_Watch
) {
2020 DevSW_FreePacket(packet
);
2021 return RDIError_Error
;
2026 case RDIPointStatus_Break
:
2028 angel_DebugPrint("DEBUG: ADP_Ctrl_PointStatus_Break.\n");
2030 register_debug_message_handler();
2031 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Control
| HtoT
, 0,
2032 ADP_HandleUnknown
, ADP_HandleUnknown
,
2033 ADP_Ctrl_PointStatus_Break
, *arg1
);
2034 reason
= ADP_Control
|TtoH
;
2035 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2037 if (err
!= RDIError_NoError
) {
2038 DevSW_FreePacket(packet
);
2041 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w", &reason
,
2042 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
,
2044 if (subreason
!= ADP_Ctrl_PointStatus_Break
) {
2045 DevSW_FreePacket(packet
);
2046 return RDIError_Error
;
2051 case RDIInfo_DownLoad
:
2053 angel_DebugPrint("DEBUG: ADP_Ctrl_Download_Supported.\n");
2055 return SendSubMessageAndCheckReply(ADP_Control
, ADP_Ctrl_Download_Supported
);
2057 case RDIConfig_Count
:
2059 angel_DebugPrint("DEBUG: ADP_ICEM_ConfigCount.\n");
2061 return SendSubMessageGetWordAndCheckReply(ADP_ICEman
, ADP_ICEM_ConfigCount
, arg1
);
2065 angel_DebugPrint("DEBUG: ADP_ICEM_ConfigNth.\n");
2067 register_debug_message_handler();
2068 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_ICEman
| HtoT
, 0,
2069 ADP_HandleUnknown
, ADP_HandleUnknown
,
2070 ADP_ICEM_ConfigNth
, *arg1
);
2071 reason
= ADP_ICEman
|TtoH
;
2072 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2074 if (err
!= RDIError_NoError
) {
2075 DevSW_FreePacket(packet
);
2078 RDI_ConfigDesc
*cd
= (RDI_ConfigDesc
*)arg2
;
2080 len
= unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%b",
2082 &OSinfo1
, &OSinfo2
, &subreason
, &status
,
2084 if (subreason
!= ADP_ICEM_ConfigNth
) {
2085 DevSW_FreePacket(packet
);
2086 return RDIError_Error
;
2089 memcpy( cd
->name
, BUFFERDATA(packet
->pk_buffer
)+len
, n
+1 );
2095 case RDIInfo_Icebreaker
:
2097 angel_DebugPrint("DEBUG: ADP_ICEB_Exists.\n");
2099 return SendSubMessageAndCheckReply(ADP_ICEbreakerHADP
, ADP_ICEB_Exists
);
2101 case RDIIcebreaker_GetLocks
:
2103 angel_DebugPrint("DEBUG: ADP_ICEB_GetLocks.\n");
2105 return SendSubMessageGetWordAndCheckReply(ADP_ICEbreakerHADP
, ADP_ICEB_GetLocks
, arg1
);
2107 case RDIIcebreaker_SetLocks
:
2109 angel_DebugPrint("DEBUG: ADP_ICEB_SetLocks.\n");
2111 return SendSubMessageWordAndCheckReply(ADP_ICEbreakerHADP
, ADP_ICEB_SetLocks
, *arg1
);
2113 case RDICommsChannel_ToHost
:
2115 angel_DebugPrint("DEBUG: ADP_ICEB_CC_Connect_ToHost.\n");
2117 if ( angel_cc_exists() == RDIError_NoError
) {
2120 * The following three lines of code have to be removed in order to get
2121 * the Windows Angel Channel Viewer working with the Thumb comms channel.
2122 * At the moment it allows the ARMSD command line to register a CCIN/CCOUT
2123 * callback which stops the ACV working!
2126 ccstate
.tohost
= (RDICCProc_ToHost
*)arg1
;
2127 ccstate
.tohostarg
= arg2
;
2128 angel_check_DCC_handler( &ccstate
);
2134 register_debug_message_handler();
2135 msgsend(CI_HADP
, "%w%w%w%w%w%b", ADP_ICEbreakerHADP
| HtoT
, 0,
2136 ADP_HandleUnknown
, ADP_HandleUnknown
,
2137 ADP_ICEB_CC_Connect_ToHost
, (arg1
!= NULL
) );
2138 return CheckSubMessageReply(ADP_ICEbreakerHADP
, ADP_ICEB_CC_Connect_ToHost
);
2140 return RDIError_UnimplementedMessage
;
2143 case RDICommsChannel_FromHost
:
2145 angel_DebugPrint("DEBUG: ADP_ICEB_CC_Connect_FromHost.\n");
2147 if ( angel_cc_exists() == RDIError_NoError
) {
2149 ccstate
.fromhost
= (RDICCProc_FromHost
*)arg1
;
2150 ccstate
.fromhostarg
= arg2
;
2151 angel_check_DCC_handler( &ccstate
);
2153 register_debug_message_handler();
2154 msgsend(CI_HADP
, "%w%w%w%w%w%b", ADP_ICEbreakerHADP
| HtoT
, 0,
2155 ADP_HandleUnknown
, ADP_HandleUnknown
,
2156 ADP_ICEB_CC_Connect_FromHost
, (arg1
!= NULL
) );
2157 return CheckSubMessageReply(ADP_ICEbreakerHADP
, ADP_ICEB_CC_Connect_FromHost
);
2159 return RDIError_UnimplementedMessage
;
2162 case RDIProfile_Stop
:
2163 return SendSubMessageAndCheckReply(ADP_Profile
, ADP_Profile_Stop
);
2165 case RDIProfile_ClearCounts
:
2166 return SendSubMessageAndCheckReply(ADP_Profile
, ADP_Profile_ClearCounts
);
2168 case RDIProfile_Start
:
2170 angel_DebugPrint("DEBUG: ADP_Profile_Start %ld.\n", (long)*arg1
);
2172 return SendSubMessageWordAndCheckReply(ADP_Profile
, ADP_Profile_Start
, *arg1
);
2174 case RDIProfile_WriteMap
:
2175 { RDI_ProfileMap
*map
= (RDI_ProfileMap
*)arg1
;
2176 int32 maplen
= map
->len
,
2179 int32 chunk
= (Armsd_LongBufSize
-CHAN_HEADER_SIZE
-ADP_ProfileWriteHeaderSize
) / sizeof(ARMword
);
2180 /* Maximum number of words sendable in one message */
2181 int oldrev
= bytesex_reversing();
2182 int host_little
= *(uint8
const *)&hostsex
;
2184 angel_DebugPrint("DEBUG: ADP_Profile_WriteMap %ld.\n", maplen
);
2186 status
= RDIError_NoError
;
2189 for (offset
= 0; offset
< maplen
; offset
++)
2190 map
->map
[offset
] = bytesex_hostval(map
->map
[offset
]);
2192 for (offset
= 0; offset
< maplen
; offset
+= size
) {
2194 size
= maplen
- offset
;
2195 packet
= (Packet
*)DevSW_AllocatePacket(Armsd_LongBufSize
);
2196 if (size
> chunk
) size
= chunk
;
2197 hdrlen
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
2198 ADP_Profile
| HtoT
, 0, ADP_HandleUnknown
,
2199 ADP_HandleUnknown
, ADP_Profile_WriteMap
,
2200 maplen
, size
, offset
);
2202 /* Copy the data into the packet. */
2203 memcpy(BUFFERDATA(packet
->pk_buffer
)+hdrlen
,
2204 &map
->map
[offset
], (size_t)size
* sizeof(ARMword
));
2205 packet
->pk_length
= size
* sizeof(ARMword
) + hdrlen
;
2206 register_debug_message_handler();
2207 Adp_ChannelWrite(CI_HADP
, packet
);
2208 reason
= ADP_Profile
| TtoH
;
2209 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2211 if (err
== RDIError_NoError
) {
2212 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
2213 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2214 if (subreason
!= ADP_Profile_WriteMap
) {
2215 err
= RDIError_Error
;
2217 DevSW_FreePacket(packet
);
2219 if (err
!= RDIError_NoError
) { status
= err
; break; }
2222 for (offset
= 0; offset
< maplen
; offset
++)
2223 map
->map
[offset
] = bytesex_hostval(map
->map
[offset
]);
2224 bytesex_reverse(oldrev
);
2229 case RDIProfile_ReadMap
:
2230 { int32 maplen
= *(int32
*)arg1
,
2233 int32 chunk
= (Armsd_BufferSize
-CHAN_HEADER_SIZE
-ADP_ProfileReadHeaderSize
) / sizeof(ARMword
);
2235 angel_DebugPrint("DEBUG: ADP_Profile_ReadMap %ld.\n", maplen
);
2237 status
= RDIError_NoError
;
2238 for (offset
= 0; offset
< maplen
; offset
+= size
) {
2239 size
= maplen
- offset
;
2240 if (size
> chunk
) size
= chunk
;
2241 register_debug_message_handler();
2242 msgsend(CI_HADP
, "%w%w%w%w%w%w%w", ADP_Profile
| HtoT
, 0,
2243 ADP_HandleUnknown
, ADP_HandleUnknown
,
2244 ADP_Profile_ReadMap
, offset
, size
);
2245 reason
= ADP_Profile
| TtoH
;
2246 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2248 if (err
!= RDIError_NoError
) return err
;
2249 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
2250 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2251 memcpy(&arg2
[offset
], BUFFERDATA(packet
->pk_buffer
)+ADP_ProfileReadHeaderSize
,
2252 size
* sizeof(ARMword
));
2253 DevSW_FreePacket(packet
);
2254 if (status
!= RDIError_NoError
) break;
2256 { int oldrev
= bytesex_reversing();
2257 int host_little
= *(uint8
const *)&hostsex
;
2260 for (offset
= 0; offset
< maplen
; offset
++)
2261 arg2
[offset
] = bytesex_hostval(arg2
[offset
]);
2263 bytesex_reverse(oldrev
);
2268 case RDIInfo_CanTargetExecute
:
2270 printf("DEBUG: RDIInfo_CanTargetExecute.\n");
2272 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_CanTargetExecute
);
2274 case RDIInfo_AgentEndianess
:
2275 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_AgentEndianess
);
2279 angel_DebugPrint("DEBUG: Fell through ADP_Info, default case taken.\n");
2280 angel_DebugPrint("DEBUG: type = 0x%x.\n", type
);
2282 if (type
& RDIInfo_CapabilityRequest
) {
2283 switch (type
& ~RDIInfo_CapabilityRequest
) {
2284 case RDISemiHosting_SetARMSWI
:
2285 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_ChangeableSHSWI
);
2289 "DEBUG: ADP_Info - Capability Request(%d) - reporting unimplemented \n",
2290 type
& ~RDIInfo_CapabilityRequest
);
2295 return RDIError_UnimplementedMessage
;
2300 /*----------------------------------------------------------------------*/
2301 /*----angel_RDI_AddConfig------------------------------------------------*/
2302 /*----------------------------------------------------------------------*/
2304 /* Add a configuration: use ADP_ICEM_AddConfig. */
2305 int angel_RDI_AddConfig(unsigned long nbytes
) {
2306 Packet
*packet
= NULL
;
2307 int status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2310 angel_DebugPrint("DEBUG: Entered angel_RDI_AddConfig.\n");
2312 register_debug_message_handler();
2313 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_ICEman
| HtoT
,
2314 0, ADP_HandleUnknown
, ADP_HandleUnknown
,
2315 ADP_ICEM_AddConfig
, nbytes
);
2316 reason
=ADP_ICEman
| TtoH
;
2317 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2319 if (err
!= RDIError_NoError
) {
2320 DevSW_FreePacket(packet
);
2323 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
2324 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2325 DevSW_FreePacket(packet
);
2326 if ( subreason
!= ADP_ICEM_AddConfig
)
2327 return RDIError_Error
;
2333 /*----------------------------------------------------------------------*/
2334 /*----angel_RDI_LoadConfigData-------------------------------------------*/
2335 /*----------------------------------------------------------------------*/
2337 /* Load configuration data: use ADP_Ctrl_Download_Data. */
2338 int angel_RDI_LoadConfigData(unsigned long nbytes
, char const *data
) {
2339 Packet
*packet
= NULL
;
2340 int len
, status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2343 angel_DebugPrint("DEBUG: Entered angel_RDI_LoadConfigData (%d bytes)\n", nbytes
);
2346 if (err
= angel_RDI_AddConfig(nbytes
) != RDIError_NoError
)
2349 packet
= DevSW_AllocatePacket(Armsd_LongBufSize
);
2350 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w",
2351 ADP_Control
| HtoT
, 0,
2352 ADP_HandleUnknown
, ADP_HandleUnknown
,
2353 ADP_Ctrl_Download_Data
, nbytes
);
2354 memcpy(BUFFERDATA(packet
->pk_buffer
)+len
, data
, nbytes
);
2356 packet
->pk_length
= len
;
2358 angel_DebugPrint("DEBUG: packet len %d.\n", len
);
2360 register_debug_message_handler();
2361 Adp_ChannelWrite(CI_HADP
, packet
);
2362 reason
=ADP_Control
| TtoH
;
2363 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2365 if (err
!= RDIError_NoError
) {
2366 DevSW_FreePacket(packet
);
2369 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
2370 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2371 DevSW_FreePacket(packet
);
2372 if ( subreason
!= ADP_Ctrl_Download_Data
)
2373 return RDIError_Error
;
2379 /*----------------------------------------------------------------------*/
2380 /*----angel_RDI_SelectConfig---------------------------------------------*/
2381 /*----------------------------------------------------------------------*/
2383 /* Select a configuration: use ADP_ICEM_SelecConfig.*/
2384 int angel_RDI_SelectConfig(RDI_ConfigAspect aspect
, char const *name
,
2385 RDI_ConfigMatchType matchtype
, unsigned versionreq
,
2388 Packet
*packet
= NULL
;
2389 int len
, status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2392 angel_DebugPrint("DEBUG: Entered angel_RDI_SelectConfig.\n");
2394 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
2395 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%b%b%b%w",
2396 ADP_ICEman
| HtoT
, 0,
2397 ADP_HandleUnknown
, ADP_HandleUnknown
,
2398 ADP_ICEM_SelectConfig
, aspect
, strlen(name
),
2399 matchtype
, versionreq
);
2400 /* copy the name into the buffer */
2401 memcpy(BUFFERDATA(packet
->pk_buffer
)+len
, name
, strlen(name
));
2402 len
+= strlen(name
);
2403 packet
->pk_length
= len
;
2404 register_debug_message_handler();
2405 Adp_ChannelWrite(CI_HADP
, packet
);
2406 reason
=ADP_ICEman
| TtoH
;
2407 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2409 if (err
!= RDIError_NoError
) {
2410 DevSW_FreePacket(packet
);
2413 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w",
2414 &reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2415 &subreason
, &status
, versionp
);
2416 DevSW_FreePacket(packet
);
2417 if ( subreason
!= ADP_ICEM_SelectConfig
)
2418 return RDIError_Error
;
2424 /*----------------------------------------------------------------------*/
2425 /*----angel_RDI_LoadAgent------------------------------------------------*/
2426 /*----------------------------------------------------------------------*/
2428 /* Load a new debug agent: use ADP_Ctrl_Download_Agent. */
2429 int angel_RDI_LoadAgent(ARMword dest
, unsigned long size
,
2430 getbufferproc
*getb
, void *getbarg
)
2432 Packet
*packet
= NULL
;
2433 int status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2436 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2437 angel_DebugPrint("DEBUG: Entered angel_RDI_LoadAgent.\n");
2439 register_debug_message_handler();
2440 msgsend(CI_HADP
, "%w%w%w%w%w%w%w", ADP_Control
| HtoT
,
2441 0, ADP_HandleUnknown
, ADP_HandleUnknown
,
2442 ADP_Ctrl_Download_Agent
, dest
, size
);
2443 reason
=ADP_Control
| TtoH
;
2444 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2446 if (err
!= RDIError_NoError
) {
2447 DevSW_FreePacket(packet
);
2450 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
2451 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2452 DevSW_FreePacket(packet
);
2453 if ( subreason
!= ADP_Ctrl_Download_Agent
)
2454 return RDIError_Error
;
2455 if ( status
!= RDIError_NoError
)
2458 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2459 angel_DebugPrint("DEBUG: starting agent data download.\n");
2461 { unsigned long pos
= 0, segsize
;
2462 for (; pos
< size
; pos
+= segsize
) {
2463 char *b
= getb(getbarg
, &segsize
);
2464 if (b
== NULL
) return RDIError_NoError
;
2465 err
= angel_RDI_LoadConfigData( segsize
, b
);
2466 if (err
!= RDIError_NoError
) return err
;
2469 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2470 angel_DebugPrint("DEBUG: finished downloading new agent.\n");
2473 /* renegotiate back down */
2474 err
= angel_negotiate_defaults();
2478 /* Output a message to tell the user what is going on. This is vital
2479 * when switching from ADP EICE to ADP over JTAG, as then the user
2480 * has to reset the target board !
2483 int len
=angel_RDI_errmess(msg
, 256, adp_new_agent_starting
);
2484 angel_hostif
->write(angel_hostif
->hostosarg
, msg
, len
);
2487 /* get new image started */
2488 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2489 angel_DebugPrint("DEBUG: sending start message for new agent.\n");
2492 register_debug_message_handler();
2493 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Control
| HtoT
,
2494 0, ADP_HandleUnknown
, ADP_HandleUnknown
,
2495 ADP_Ctrl_Start_Agent
, dest
);
2496 reason
=ADP_Control
| TtoH
;
2497 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2499 if (err
!= RDIError_NoError
) {
2500 DevSW_FreePacket(packet
);
2503 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
2504 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2505 DevSW_FreePacket(packet
);
2506 if ( subreason
!= ADP_Ctrl_Start_Agent
)
2507 return RDIError_Error
;
2508 if ( status
!= RDIError_NoError
)
2511 /* wait for image to start up */
2512 heartbeat_enabled
= FALSE
;
2515 Adp_AsynchronousProcessing(async_block_on_nothing
);
2516 if ((time(NULL
)-t
) > 2) {
2518 angel_DebugPrint("DEBUG: no booted message from new image yet.\n");
2522 } while (booted_not_received
);
2523 booted_not_received
=1;
2525 /* Give device driver a chance to do any necessary resyncing with new agent.
2526 * Only used by etherdrv.c at the moment.
2528 (void)Adp_Ioctl( DC_RESYNC
, NULL
);
2530 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2531 angel_DebugPrint("DEBUG: reopening to new agent.\n");
2533 err
= angel_RDI_open(0, NULL
, NULL
, NULL
);
2536 case RDIError_NoError
:
2538 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2539 angel_DebugPrint( "LoadAgent: Open returned RDIError_NoError\n" );
2544 case RDIError_LittleEndian
:
2546 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2547 angel_DebugPrint( "LoadAgent: Open returned RDIError_LittleEndian (OK)\n" );
2549 err
= RDIError_NoError
;
2553 case RDIError_BigEndian
:
2555 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2556 angel_DebugPrint( "LoadAgent: Open returned RDIError_BigEndian (OK)\n" );
2558 err
= RDIError_NoError
;
2564 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2565 angel_DebugPrint( "LoadAgent: Open returned %d - unexpected!\n", err
);
2570 #ifndef NO_HEARTBEAT
2571 heartbeat_enabled
= TRUE
;
2576 static int angel_RDI_errmess(char *buf
, int blen
, int errnum
) {
2581 case adp_malloc_failure
:
2582 s
=AdpMess_MallocFailed
; break;
2583 case adp_illegal_args
:
2584 s
=AdpMess_IllegalArgs
; break;
2585 case adp_device_not_found
:
2586 s
=AdpMess_DeviceNotFound
; break;
2587 case adp_device_open_failed
:
2588 s
=AdpMess_DeviceOpenFailed
; break;
2589 case adp_device_already_open
:
2590 s
=AdpMess_DeviceAlreadyOpen
; break;
2591 case adp_device_not_open
:
2592 s
=AdpMess_DeviceNotOpen
; break;
2593 case adp_bad_channel_id
:
2594 s
=AdpMess_BadChannelId
; break;
2595 case adp_callback_already_registered
:
2596 s
=AdpMess_CBAlreadyRegd
; break;
2597 case adp_write_busy
:
2598 s
=AdpMess_WriteBusy
; break;
2599 case adp_bad_packet
:
2600 s
=AdpMess_BadPacket
; break;
2602 s
=AdpMess_SeqHigh
; break;
2604 s
=AdpMess_SeqLow
; break;
2605 case adp_timeout_on_open
:
2606 s
=AdpMess_TimeoutOnOpen
; break;
2608 s
=AdpMess_Failed
; break;
2609 case adp_abandon_boot_wait
:
2610 s
=AdpMess_AbandonBootWait
; break;
2611 case adp_late_startup
:
2612 s
=AdpMess_LateStartup
; break;
2613 case adp_new_agent_starting
:
2614 s
=AdpMess_NewAgentStarting
; break;
2618 if (n
>blen
-1) n
=blen
-1;
2624 extern const struct RDIProcVec angel_rdi
;
2625 const struct RDIProcVec angel_rdi
= {
2636 angel_RDI_clearbreak
,
2638 angel_RDI_clearwatch
,
2644 angel_RDI_AddConfig
,
2645 angel_RDI_LoadConfigData
,
2646 angel_RDI_SelectConfig
,
2648 0, /*angel_RDI_drivernames,*/
2658 /* Not strictly necessary, but allows linking this code into armsd. */
2668 } hostappl_CmdTable
[1] = {{"", NULL
}};