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 FALSE
, FALSE
, FALSE
, &accepted_config
};
327 angel_DebugPrint( "negotiate_params\n" );
330 Adp_ChannelRegisterRead( CI_HBOOT
, receive_negotiate
, (void *)&n_state
);
332 packet
= (Packet
*)DevSW_AllocatePacket(Armsd_BufferSize
);
333 count
= msgbuild( BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w",
334 ADP_ParamNegotiate
| HtoT
, 0,
335 ADP_HandleUnknown
, ADP_HandleUnknown
);
336 count
+= Angel_BuildParamOptionsMessage(
337 BUFFERDATA(packet
->pk_buffer
) + count
, user_options
);
338 packet
->pk_length
= count
;
339 Adp_ChannelWriteAsync( CI_HBOOT
, packet
);
342 angel_DebugPrint( "sent negotiate packet\n" );
348 Adp_AsynchronousProcessing(async_block_on_nothing
);
350 if ((time(NULL
)-t
) > ADP_INITIAL_TIMEOUT_PERIOD
) {
351 return adp_timeout_on_open
;
353 } while ( ! n_state
.negotiate_resp
);
355 if ( n_state
.negotiate_ack
)
357 /* select accepted config */
358 Adp_Ioctl( DC_SET_PARAMS
, (void *)n_state
.accepted_config
);
363 * There is a race in the renegotiation protocol: the
364 * target has to have had time to load new config before
365 * we send the link check packet - insert a deliberate
366 * pause (100ms) to give the target some time
371 msgsend( CI_HBOOT
, "%w%w%w%w", ADP_LinkCheck
| HtoT
, 0,
372 ADP_HandleUnknown
, ADP_HandleUnknown
);
374 angel_DebugPrint("sent link check\n");
378 Adp_AsynchronousProcessing(async_block_on_read
);
379 } while ( ! n_state
.link_check_resp
);
385 static int late_booted
= FALSE
;
386 static bool ardi_handler_installed
= FALSE
;
389 static struct sigaction old_action
;
391 static void (*old_handler
)();
394 static bool boot_interrupted
= FALSE
;
395 static volatile bool interrupt_request
= FALSE
;
397 static void ardi_sigint_handler(int sig
) {
400 angel_DebugPrint("Expecting SIGINT got %d.\n", sig
);
404 boot_interrupted
= TRUE
;
405 interrupt_request
= TRUE
;
407 signal(SIGINT
, ardi_sigint_handler
);
411 static void install_ardi_handler( void ) {
412 if (!ardi_handler_installed
) {
413 /* install a new Ctrl-C handler so we can abandon waiting */
415 struct sigaction new_action
;
416 sigemptyset(&new_action
.sa_mask
);
417 new_action
.sa_handler
= ardi_sigint_handler
;
418 new_action
.sa_flags
= 0;
419 sigaction(SIGINT
, &new_action
, &old_action
);
421 old_handler
= signal(SIGINT
, ardi_sigint_handler
);
423 ardi_handler_installed
= TRUE
;
427 static int angel_RDI_errmess(char *buf
, int blen
, int errnum
);
429 static void receive_reset_acknowledge(Packet
*packet
, void *stateptr
) {
430 unsigned reason
, debugID
, OSinfo1
, OSinfo2
, status
;
433 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
, &debugID
,
434 &OSinfo1
, &OSinfo2
, &status
);
435 if (reason
==(ADP_Reset
| TtoH
) && status
==AB_NORMAL_ACK
) {
437 angel_DebugPrint("DEBUG: Successfully received normal reset acknowledgement\n");
440 } else if (reason
==(ADP_Reset
| TtoH
) && status
==AB_LATE_ACK
) {
441 char late_msg
[AdpMessLen_LateStartup
];
444 angel_DebugPrint("DEBUG: Successfully received LATE reset acknowledgement\n");
447 install_ardi_handler();
448 late_len
= angel_RDI_errmess(late_msg
,
449 AdpMessLen_LateStartup
, adp_late_startup
);
450 angel_hostif
->write(angel_hostif
->hostosarg
, late_msg
, late_len
);
453 angel_DebugPrint("DEBUG: Bad reset ack: reason=%8X, status=%8X\n", reason
, status
);
456 DevSW_FreePacket(packet
);
459 static int booted_not_received
;
460 static unsigned int angel_version
;
461 static unsigned int adp_version
;
462 static unsigned int arch_info
;
463 static unsigned int cpu_info
;
464 static unsigned int hw_status
;
466 static void receive_booted(Packet
*packet
, void *stateptr
) {
467 unsigned reason
, debugID
, OSinfo1
, OSinfo2
, banner_length
, bufsiz
, longsiz
;
472 count
= unpack_message(BUFFERDATA(packet
->pk_buffer
),
473 "%w%w%w%w%w%w%w%w%w%w%w%w",
474 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &bufsiz
, &longsiz
,
475 &angel_version
, &adp_version
,
476 &arch_info
, &cpu_info
, &hw_status
, &banner_length
);
477 if (reason
==(ADP_Booted
| TtoH
)) {
478 #ifdef MONITOR_DOWNLOAD_PACKETS
479 angel_DebugPrint("DEBUG: Successfully received Booted\n");
480 angel_DebugPrint(" cpu_info=%8X, hw_status=%8X, bufsiz=%d, longsiz=%d\n",
481 cpu_info
, hw_status
, bufsiz
, longsiz
);
483 /* Get the banner from the booted message */
484 for (i
=0; i
<banner_length
; i
++)
485 angel_hostif
->writec(angel_hostif
->hostosarg
,
486 (BUFFERDATA(packet
->pk_buffer
)+count
)[i
]);
488 booted_not_received
=0;
490 heartbeat_enabled
= TRUE
;
492 Armsd_BufferSize
= bufsiz
+ CHAN_HEADER_SIZE
;
493 Armsd_LongBufSize
= longsiz
+ CHAN_HEADER_SIZE
;
496 angel_DebugPrint("DEBUG: Bad Booted msg: reason=%8X\n", reason
);
499 DevSW_FreePacket(packet
);
503 /* forward declaration */
504 static int angel_negotiate_defaults( void );
506 /* Open communications. */
508 unsigned type
, Dbg_ConfigBlock
const *config
,
509 Dbg_HostosInterface
const *hostif
, struct Dbg_MCState
*dbg_state
)
512 int status
, reasoncode
, debugID
, OSinfo1
, OSinfo2
, err
;
513 ParameterOptions
*user_options
= NULL
;
519 if ((type
& 1) == 0) {
521 if (hostif
!= NULL
) {
522 angel_hostif
= hostif
;
523 err
= HostSysInit(hostif
, &ardi_commandline
, &hstate
);
524 if (err
!= RDIError_NoError
) {
526 angel_DebugPrint("DEBUG: HostSysInit error %i\n",err
);
535 angel_DebugPrint("DEBUG: Buffer allocated in angel_RDI_open(type=%i).\n",type
);
538 if ((type
& 1) == 0) {
541 Adp_Ioctl( DC_GET_USER_PARAMS
, (void *)&user_options
);
542 if ( user_options
!= NULL
) {
543 err
= negotiate_params( user_options
);
544 if (err
!= adp_ok
) return err
;
547 ParameterConfig
*default_config
= NULL
;
548 Adp_Ioctl( DC_GET_DEFAULT_PARAMS
, (void *)&default_config
);
549 if ( default_config
!= NULL
) {
550 ParameterOptions
*default_options
= config_to_options(default_config
);
551 err
= negotiate_params( default_options
);
552 if (err
!= adp_ok
) return err
;
556 /* Register handlers before sending any messages */
557 booted_not_received
=1;
558 Adp_ChannelRegisterRead(CI_HBOOT
, receive_reset_acknowledge
, NULL
);
559 Adp_ChannelRegisterRead(CI_TBOOT
, receive_booted
, NULL
);
562 if (config
->bytesex
& RDISex_Little
) endian
|= ADP_BootHostFeature_LittleEnd
;
563 if (config
->bytesex
& RDISex_Big
) endian
|= ADP_BootHostFeature_BigEnd
;
565 msgsend(CI_HBOOT
,"%w%w%w%w%w", ADP_Reset
| HtoT
, 0,
566 ADP_HandleUnknown
, ADP_HandleUnknown
, endian
);
568 angel_DebugPrint("DEBUG: Transmitted Reset message in angel_RDI_open.\n");
571 /* We will now either get an acknowledgement for the Reset message
572 * or if the target was started after the host, we will get a
573 * rebooted message first.
577 angel_DebugPrint("DEBUG: waiting for a booted message\n");
581 boot_interrupted
= FALSE
;
584 install_ardi_handler();
589 Adp_AsynchronousProcessing(async_block_on_nothing
);
590 if ((time(NULL
)-t
) > ADP_INITIAL_TIMEOUT_PERIOD
&& !late_booted
) {
591 return adp_timeout_on_open
;
593 } while (booted_not_received
&& !boot_interrupted
);
595 if (ardi_handler_installed
)
597 /* uninstall our Ctrl-C handler */
599 sigaction(SIGINT
, &old_action
, NULL
);
601 signal(SIGINT
, old_handler
);
605 if (boot_interrupted
) {
606 angel_negotiate_defaults();
607 return adp_abandon_boot_wait
;
611 booted_not_received
=1;
612 Adp_ChannelRegisterRead(CI_HBOOT
, NULL
, NULL
);
614 /* Leave the booted handler installed */
615 msgsend(CI_TBOOT
, "%w%w%w%w%w", ADP_Booted
| HtoT
, 0,
616 ADP_HandleUnknown
, ADP_HandleUnknown
, 0);
619 angel_DebugPrint("DEBUG: Transmitted ADP_Booted acknowledgement.\n");
620 angel_DebugPrint("DEBUG: Boot sequence completed, leaving angel_RDI_open.\n");
623 return (hw_status
& ADP_CPU_BigEndian
)? RDIError_BigEndian
:
624 RDIError_LittleEndian
;
628 register_debug_message_handler();
630 msgsend(CI_HADP
, "%w%w%w%w",
631 ADP_InitialiseApplication
| HtoT
, 0,
632 ADP_HandleUnknown
, ADP_HandleUnknown
);
634 angel_DebugPrint("DEBUG: Transmitted Initialise Application\n");
636 reasoncode
=ADP_InitialiseApplication
| TtoH
;
637 err
= wait_for_debug_message(&reasoncode
, &debugID
, &OSinfo1
, &OSinfo2
,
639 if (err
!= RDIError_NoError
) return err
;
646 /*----------------------------------------------------------------------*/
647 /*----angel_RDI_close----------------------------------------------------*/
648 /*----------------------------------------------------------------------*/
650 static int angel_negotiate_defaults( void ) {
652 ParameterConfig
*default_config
= NULL
;
653 Adp_Ioctl( DC_GET_DEFAULT_PARAMS
, (void *)&default_config
);
654 if ( default_config
!= NULL
) {
655 ParameterOptions
*default_options
= config_to_options(default_config
);
656 err
= negotiate_params( default_options
);
657 free( default_options
);
662 int angel_RDI_close(void) {
665 int status
,debugID
, OSinfo1
,OSinfo2
;
667 Packet
*packet
= NULL
;;
669 angel_DebugPrint("DEBUG: Entered angel_RDI_Close.\n");
672 register_debug_message_handler();
674 heartbeat_enabled
= FALSE
;
676 err
= msgsend(CI_HADP
,"%w%w%w%w",ADP_End
| HtoT
,0,
677 ADP_HandleUnknown
, ADP_HandleUnknown
);
678 if (err
!= RDIError_NoError
) return err
;
679 reason
= ADP_End
| TtoH
;
680 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
682 DevSW_FreePacket(packet
);
683 if (err
!= RDIError_NoError
) return err
;
684 if (status
== RDIError_NoError
) {
685 err
= angel_negotiate_defaults();
686 if (err
!= adp_ok
) return err
;
687 Adp_Ioctl( DC_RESET
, NULL
); /* just to be safe */
688 return HostSysExit(hstate
);
695 /*----------------------------------------------------------------------*/
696 /*----angel_RDI_read-----------------------------------------------------*/
697 /*----------------------------------------------------------------------*/
699 /* Read memory contents from target to host: use ADP_Read */
700 int angel_RDI_read(ARMword source
, void *dest
, unsigned *nbytes
)
703 int len
; /* Integer to hold message length. */
704 unsigned int nbtogo
= *nbytes
, nbinpacket
, nbdone
=0;
705 int rnbytes
= 0, status
, reason
, debugID
, OSinfo1
, OSinfo2
, err
;
706 unsigned int maxlen
= Armsd_BufferSize
-CHAN_HEADER_SIZE
-ADP_ReadHeaderSize
;
708 /* Print debug trace information, this is just copied straight from rdi.c
709 and I can see no reason why it should have to be changed. */
710 TracePrint(("angel_RDI_read: source=%.8lx dest=%p nbytes=%.8x\n",
711 (unsigned long)source
, dest
, *nbytes
));
712 if (*nbytes
== 0) return RDIError_NoError
; /* Read nothing - easy! */
713 /* check the buffer size */
715 register_debug_message_handler();
717 nbinpacket
= (nbtogo
<= maxlen
) ? nbtogo
: maxlen
;
718 len
= msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Read
| HtoT
, 0,
719 ADP_HandleUnknown
, ADP_HandleUnknown
, source
+nbdone
,
721 reason
=ADP_Read
| TtoH
;
722 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
724 TracePrint(("angel_RDI_read: nbinpacket =%d status=%08x err = %d\n",
725 nbinpacket
,status
,err
));
726 if (err
!= RDIError_NoError
) return err
; /* Was there an error? */
727 if (status
== RDIError_NoError
){
728 rnbytes
+= PREAD(LE
,(unsigned int *)(BUFFERDATA(packet
->pk_buffer
)+20));
729 TracePrint(("angel_RDI_read: rnbytes = %d\n",rnbytes
));
730 memcpy(((unsigned char *)dest
)+nbdone
, BUFFERDATA(packet
->pk_buffer
)+24,
733 nbdone
+= nbinpacket
;
734 nbtogo
-= nbinpacket
;
741 /*----------------------------------------------------------------------*/
742 /*----angel_RDI_write----------------------------------------------------*/
743 /*----------------------------------------------------------------------*/
745 /* Transfer memory block from host to target. Use ADP_Write>. */
746 int angel_RDI_write(const void *source
, ARMword dest
, unsigned *nbytes
)
748 Packet
*packet
;/* Message buffers. */
749 unsigned int len
, nbtogo
= *nbytes
, nboffset
= 0, nbinpacket
;
750 int status
, reason
, debugID
, OSinfo1
, OSinfo2
, err
;
751 unsigned int maxlen
= Armsd_LongBufSize
-CHAN_HEADER_SIZE
-ADP_WriteHeaderSize
;
753 TracePrint(("angel_RDI_write: source=%p dest=%.8lx nbytes=%.8x\n",
754 source
, (unsigned long)dest
, *nbytes
));
756 if (*nbytes
== 0) return RDIError_NoError
;
760 packet
= (Packet
*) DevSW_AllocatePacket(Armsd_LongBufSize
);
761 nbinpacket
= (nbtogo
<= maxlen
) ? nbtogo
: maxlen
;
762 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w",
763 ADP_Write
| HtoT
, 0, ADP_HandleUnknown
,
764 ADP_HandleUnknown
, dest
+nboffset
, nbinpacket
);
765 /* Copy the data into the packet. */
767 memcpy(BUFFERDATA(packet
->pk_buffer
)+len
,
768 ((const unsigned char *) source
)+nboffset
, nbinpacket
);
769 nboffset
+= nbinpacket
;
770 packet
->pk_length
= nbinpacket
+len
;
772 #ifdef MONITOR_DOWNLOAD_PACKETS
773 angel_DebugPrint("angel_RDI_write packet size=%i, bytes done=%i\n",
774 nbinpacket
, nboffset
);
777 register_debug_message_handler();
778 Adp_ChannelWrite(CI_HADP
, packet
);
779 reason
=ADP_Write
| TtoH
;
780 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
782 nbtogo
-= nbinpacket
;
783 if (err
!= RDIError_NoError
) return err
;
784 if (status
== RDIError_NoError
)
785 *nbytes
+= nbinpacket
;
787 DevSW_FreePacket(packet
);
793 /*----------------------------------------------------------------------*/
794 /*----angel_RDI_CPUread--------------------------------------------------*/
795 /*----------------------------------------------------------------------*/
797 /* Reads the values of registers in the CPU, uses ADP_CPUwrite. */
798 int angel_RDI_CPUread(unsigned mode
, unsigned long mask
, ARMword
*buffer
)
801 Packet
*packet
= NULL
;
802 int err
, status
, reason
, debugID
, OSinfo1
, OSinfo2
;
804 angel_DebugPrint("DEBUG: Entered angel_RDI_CPUread.\n");
806 for (i
=0, j
=0 ; i
< RDINumCPURegs
; i
++)
807 if (mask
& (1L << i
)) j
++; /* Count the number of registers. */
809 register_debug_message_handler();
810 msgsend(CI_HADP
, "%w%w%w%w%c%w", ADP_CPUread
| HtoT
, 0,
811 ADP_HandleUnknown
, ADP_HandleUnknown
, mode
, mask
);
812 reason
= ADP_CPUread
| TtoH
;
813 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
815 if (err
!= RDIError_NoError
) {
816 DevSW_FreePacket(packet
);
819 if(status
== RDIError_NoError
) {
821 buffer
[i
] = GET32LE(BUFFERDATA(packet
->pk_buffer
)+20+(i
*4));
822 TracePrint(("angel_RDI_CPUread: mode=%.8x mask=%.8lx", mode
, mask
));
823 DevSW_FreePacket(packet
);
827 for (k
= 0, j
= 0 ; j
<= 20 ; j
++)
828 if (mask
& (1L << j
)) {
829 angel_DebugPrint("%c%.8lx",k
%4==0?'\n':' ',
830 (unsigned long)buffer
[k
]);
833 angel_DebugPrint("\n") ;
841 /*----------------------------------------------------------------------*/
842 /*----angel_RDI_CPUwrite-------------------------------------------------*/
843 /*----------------------------------------------------------------------*/
845 /* Write CPU registers: use ADP_CPUwrite. */
846 int angel_RDI_CPUwrite(unsigned mode
, unsigned long mask
,
847 ARMword
const *buffer
){
851 int status
, reason
, debugID
, OSinfo1
, OSinfo2
, err
, len
;
853 TracePrint(("angel_RDI_CPUwrite: mode=%.8x mask=%.8lx", mode
, mask
));
856 for (j
= 0, i
= 0 ; i
<= 20 ; i
++)
857 if (mask
& (1L << i
)) {
858 angel_DebugPrint("%c%.8lx",j
%4==0?'\n':' ',
859 (unsigned long)buffer
[j
]);
862 angel_DebugPrint("\n") ;
865 packet
= (Packet
*)DevSW_AllocatePacket(Armsd_BufferSize
);
866 for (i
=0, j
=0; i
< RDINumCPURegs
; i
++)
867 if (mask
& (1L << i
)) j
++; /* count the number of registers */
869 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%b%w",
870 ADP_CPUwrite
| HtoT
, 0,
871 ADP_HandleUnknown
, ADP_HandleUnknown
, mode
, mask
);
873 PUT32LE(BUFFERDATA(packet
->pk_buffer
)+len
+(c
*4), buffer
[c
]);
874 packet
->pk_length
= len
+(j
*4);
875 register_debug_message_handler();
877 Adp_ChannelWrite(CI_HADP
, packet
);
878 reason
= ADP_CPUwrite
| TtoH
;
879 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
881 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
, &debugID
,
882 &OSinfo1
, &OSinfo2
, &status
);
883 DevSW_FreePacket(packet
);
884 if (err
!= RDIError_NoError
)
885 return err
; /* Was there an error? */
891 /*----------------------------------------------------------------------*/
892 /*----angel_RDI_CPread---------------------------------------------------*/
893 /*----------------------------------------------------------------------*/
895 /* Read coprocessor's internal state. See dbg_cp.h for help.
897 * It would appear that the correct behaviour at this point is to leave
898 * the unpacking to a the caller and to simply copy the stream of data
899 * words into the buffer
902 int angel_RDI_CPread(unsigned CPnum
, unsigned long mask
, ARMword
*buffer
){
903 Packet
*packet
= NULL
;
904 int i
, j
, status
, reasoncode
, OSinfo1
, OSinfo2
, err
, debugID
;
905 unsigned char *rmap
= cpwords
[CPnum
];
908 angel_DebugPrint("DEBUG: Entered angel_RDI_CPread.\n");
910 if (rmap
== NULL
) return RDIError_UnknownCoPro
;
912 register_debug_message_handler();
914 msgsend(CI_HADP
, "%w%w%w%w%b%w", ADP_CPread
| HtoT
, 0,
915 ADP_HandleUnknown
, ADP_HandleUnknown
, CPnum
, mask
);
916 reasoncode
=ADP_CPread
| TtoH
;
917 err
= wait_for_debug_message(&reasoncode
, &debugID
, &OSinfo1
, &OSinfo2
,
919 if (err
!= RDIError_NoError
) {
920 DevSW_FreePacket(packet
);
921 return err
; /* Was there an error? */
923 for (j
=i
=0; i
< n
; i
++) /* count the number of registers */
924 if (mask
& (1L << i
)) {
928 buffer
[i
] = PREAD32(LE
, BUFFERDATA(packet
->pk_buffer
) + 20 + (i
*4));
929 DevSW_FreePacket(packet
);
930 TracePrint(("angel_RDI_CPread: CPnum=%.8x mask=%.8lx\n", CPnum
, mask
));
933 for (i
= 0, j
= 0; j
< n
; j
++) {
934 if (mask
& (1L << j
)) {
936 angel_DebugPrint("%2d ", j
);
938 angel_DebugPrint("%.8lx ", (unsigned long)buffer
[i
++]);
939 angel_DebugPrint("%.8lx\n", (unsigned long)buffer
[i
++]);
948 /*----------------------------------------------------------------------*/
949 /*----angel_RDI_CPwrite--------------------------------------------------*/
950 /*----------------------------------------------------------------------*/
952 /* Write coprocessor's internal state. See dbg_cp.h for help. Use
956 int angel_RDI_CPwrite(unsigned CPnum
, unsigned long mask
,
957 ARMword
const *buffer
)
959 Packet
*packet
= NULL
;
960 int i
, j
, len
, status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
961 unsigned char *rmap
= cpwords
[CPnum
];
964 if (rmap
== NULL
) return RDIError_UnknownCoPro
;
967 TracePrint(("angel_RDI_CPwrite: CPnum=%d mask=%.8lx\n", CPnum
, mask
));
971 for (i
= 0, j
= 0; j
< n
; j
++)
972 if (mask
& (1L << j
)) {
974 angel_DebugPrint("%2d ", j
);
976 angel_DebugPrint("%.8lx ", (unsigned long)buffer
[i
++]);
977 angel_DebugPrint("%.8lx\n", (unsigned long)buffer
[i
++]);
982 for (j
=i
=0; i
< n
; i
++) /* Count the number of registers. */
983 if (mask
& (1L << i
)) j
++;
984 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
985 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%c%w",
986 ADP_CPwrite
| HtoT
, 0,
987 ADP_HandleUnknown
, ADP_HandleUnknown
, CPnum
, mask
);
989 len
+=msgbuild(BUFFERDATA(packet
->pk_buffer
) + len
, "%w", buffer
[i
]);
990 packet
->pk_length
= len
;
991 register_debug_message_handler();
992 Adp_ChannelWrite(CI_HADP
, packet
); /* Transmit message. */
993 reason
=ADP_CPwrite
| TtoH
;
994 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
996 DevSW_FreePacket(packet
);
997 if (err
!= RDIError_NoError
)
1004 /*----------------------------------------------------------------------*/
1005 /*----angel_RDI_pointinq-------------------------------------------------*/
1006 /*----------------------------------------------------------------------*/
1008 /* Do test calls to ADP_SetBreak/ADP_SetWatch to see if resources exist to
1009 carry out request. */
1010 int angel_RDI_pointinq(ARMword
*address
, unsigned type
, unsigned datatype
,
1013 Packet
*packet
= NULL
;
1014 int len
, status
, reason
, OSinfo1
, OSinfo2
, err
=RDIError_NoError
;
1015 /* stop a compiler warning */
1016 int debugID
, pointhandle
;
1018 ("angel_RDI_pointinq: address=%.8lx type=%d datatype=%d bound=%.8lx ",
1019 (unsigned long)*address
, type
, datatype
, (unsigned long)*bound
));
1021 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
1022 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%b",
1023 ((datatype
== 0) ? ADP_SetBreak
: ADP_SetWatch
) | HtoT
, 0,
1024 ADP_HandleUnknown
, ADP_HandleUnknown
, address
, type
);
1026 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
) + 21, "%w", bound
);
1028 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
) + 21, "%b%w", datatype
, bound
);
1030 register_debug_message_handler();
1031 packet
->pk_length
= len
;
1032 Adp_ChannelWrite(CI_HADP
, packet
);
1033 reason
= ((datatype
== 0) ? ADP_SetBreak
: ADP_SetWatch
| TtoH
);
1034 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1036 if (err
!= RDIError_NoError
) {
1037 DevSW_FreePacket(packet
);
1038 return err
; /* Was there an error? */
1040 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
1041 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &status
,
1042 &pointhandle
, &address
, &bound
);
1043 DevSW_FreePacket(packet
);
1048 /*----------------------------------------------------------------------*/
1049 /*----angel_RDI_setbreak-------------------------------------------------*/
1050 /*----------------------------------------------------------------------*/
1052 /* Set a breakpoint: Use ADP_SetBreak */
1053 int angel_RDI_setbreak(ARMword address
, unsigned type
, ARMword bound
,
1054 PointHandle
*handle
)
1056 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1057 int tmpval
, tmpaddr
, tmpbnd
;
1059 TracePrint(("angel_RDI_setbreak address=%.8lx type=%d bound=%.8lx \n",
1060 (unsigned long)address
, type
, (unsigned long)bound
));
1062 register_debug_message_handler();
1063 msgsend(CI_HADP
, "%w%w%w%w%w%b%w",
1064 ADP_SetBreak
| HtoT
, 0, ADP_HandleUnknown
,
1065 ADP_HandleUnknown
, address
, type
, bound
);
1066 reason
= ADP_SetBreak
|TtoH
;
1067 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1069 if (err
!= RDIError_NoError
) {
1070 DevSW_FreePacket(packet
);
1071 return err
; /* Was there an error? */
1073 /* Work around varargs problem... -sts */
1074 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
1075 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &status
,
1076 &tmpval
, &tmpaddr
, &tmpbnd
);
1080 DevSW_FreePacket(packet
);
1081 if (status
!= RDIError_NoError
) return status
;
1082 TracePrint(("returns handle %.8lx\n", (unsigned long)*handle
));
1083 return RDIError_NoError
;
1087 /*----------------------------------------------------------------------*/
1088 /*----angel_RDI_clearbreak-----------------------------------------------*/
1089 /*----------------------------------------------------------------------*/
1091 /* Clear a breakpoint: Use ADP_ClearBreak. */
1092 int angel_RDI_clearbreak(PointHandle handle
)
1094 Packet
*packet
= NULL
;
1095 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1097 TracePrint(("angel_RDI_clearbreak: handle=%.8lx\n", (unsigned long)handle
));
1099 register_debug_message_handler();
1100 msgsend(CI_HADP
, "%w%w%w%w%w",
1101 ADP_ClearBreak
| HtoT
, 0, ADP_HandleUnknown
,
1102 ADP_HandleUnknown
, handle
);
1103 reason
= ADP_ClearBreak
|TtoH
;
1104 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1106 if (err
!= RDIError_NoError
) {
1107 DevSW_FreePacket(packet
);
1108 angel_DebugPrint("***RECEIVE DEBUG MESSAGE RETURNED ERR = %d.\n", err
);
1109 return err
; /* Was there an error? */
1111 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
,
1112 &debugID
, &OSinfo1
, &OSinfo2
, &status
);
1113 DevSW_FreePacket(packet
);
1115 angel_DebugPrint("DEBUG: Clear Break completed OK.\n");
1117 return RDIError_NoError
;
1121 /*----------------------------------------------------------------------*/
1122 /*----angel_RDI_setwatch-------------------------------------------------*/
1123 /*----------------------------------------------------------------------*/
1125 /* Set a watchpoint: use ADP_SetWatch. */
1126 int angel_RDI_setwatch(ARMword address
, unsigned type
, unsigned datatype
,
1127 ARMword bound
, PointHandle
*handle
)
1129 Packet
*packet
= NULL
;
1130 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1132 TracePrint(("angel_RDI_setwatch: address=%.8lx type=%d bound=%.8lx ",
1133 (unsigned long)address
, type
, (unsigned long)bound
));
1135 register_debug_message_handler();
1136 msgsend(CI_HADP
, "%w%w%w%w%w%b%b%w",
1137 ADP_SetWatch
| HtoT
, 0, ADP_HandleUnknown
,
1138 ADP_HandleUnknown
, address
, type
, datatype
, bound
);
1140 reason
= ADP_SetWatch
| TtoH
;
1141 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1143 if (err
!= RDIError_NoError
) {
1144 DevSW_FreePacket(packet
);
1145 return err
; /* Was there an error? */
1147 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
1148 &reason
, &debugID
, &OSinfo1
, &OSinfo2
, &status
,
1149 handle
, &address
, &bound
);
1150 DevSW_FreePacket(packet
);
1151 TracePrint(("returns handle %.8lx\n", (unsigned long)*handle
));
1152 return RDIError_NoError
;
1155 /*----------------------------------------------------------------------*/
1156 /*----angel_RDI_clearwatch-----------------------------------------------*/
1157 /*----------------------------------------------------------------------*/
1159 /* Clear a watchpoint: use ADP_ClearWatch. */
1160 int angel_RDI_clearwatch(PointHandle handle
) {
1162 int status
, reason
, OSinfo1
, OSinfo2
, err
, debugID
;
1163 Packet
*packet
= NULL
;
1165 TracePrint(("angel_RDI_clearwatch: handle=%.8lx\n", (unsigned long)handle
));
1167 register_debug_message_handler();
1168 msgsend(CI_HADP
, "%w%w%w%w%w",
1169 ADP_ClearWatch
| HtoT
, 0, ADP_HandleUnknown
,
1170 ADP_HandleUnknown
, handle
);
1171 reason
= ADP_ClearWatch
|TtoH
;
1172 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1174 if (err
!= RDIError_NoError
) {
1175 DevSW_FreePacket(packet
);
1176 return err
; /* Was there an error? */
1178 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", &reason
, &debugID
,
1179 &OSinfo1
, &OSinfo2
, &status
);
1180 DevSW_FreePacket(packet
);
1181 return RDIError_NoError
;
1185 unsigned stopped_reason
;
1188 } adp_stopped_struct
;
1191 int angel_RDI_OnTargetStopping(angel_RDI_TargetStoppedProc
*fn
,
1194 stoppedProcListElement
**lptr
= &stopped_proc_list
;
1196 /* Find the address of the NULL ptr at the end of the list */
1197 for (; *lptr
!=NULL
; lptr
= &((*lptr
)->next
))
1200 *lptr
= (stoppedProcListElement
*) malloc(sizeof(stoppedProcListElement
));
1201 if (*lptr
== NULL
) return RDIError_OutOfStore
;
1205 return RDIError_NoError
;
1208 static int CallStoppedProcs(unsigned reason
)
1210 stoppedProcListElement
*p
= stopped_proc_list
;
1211 int err
=RDIError_NoError
;
1213 for (; p
!=NULL
; p
=p
->next
) {
1214 int local_err
= p
->fn(reason
, p
->arg
);
1215 if (local_err
!= RDIError_NoError
) err
=local_err
;
1221 /*----------------------------------------------------------------------*/
1222 /*----angel_RDI_execute--------------------------------------------------*/
1223 /*----------------------------------------------------------------------*/
1225 static int HandleStoppedMessage(Packet
*packet
, void *stateptr
) {
1226 unsigned int err
, reason
, debugID
, OSinfo1
, OSinfo2
, count
;
1227 adp_stopped_struct
*stopped_info
;
1228 stopped_info
= (adp_stopped_struct
*) stateptr
;
1230 count
= unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w",
1233 &stopped_info
->stopped_reason
, &stopped_info
->data
);
1234 DevSW_FreePacket(packet
);
1236 if (reason
!= (ADP_Stopped
| TtoH
)) {
1238 angel_DebugPrint("Expecting stopped message, got %x", reason
);
1240 return RDIError_Error
;
1245 angel_DebugPrint("Received stopped message.\n");
1249 err
= msgsend(CI_TADP
, "%w%w%w%w%w", (ADP_Stopped
| HtoT
), 0,
1250 ADP_HandleUnknown
, ADP_HandleUnknown
, RDIError_NoError
);
1252 angel_DebugPrint("Transmiting stopped acknowledge.\n");
1254 if (err
!= RDIError_NoError
) angel_DebugPrint("Transmit failed.\n");
1256 angel_DebugPrint("DEBUG: Stopped reason : %x\n", stopped_info
->stopped_reason
);
1258 switch (stopped_info
->stopped_reason
) {
1259 case ADP_Stopped_BranchThroughZero
:
1260 stopped_info
->stopped_status
= RDIError_BranchThrough0
;
1262 case ADP_Stopped_UndefinedInstr
:
1263 stopped_info
->stopped_status
= RDIError_UndefinedInstruction
;
1265 case ADP_Stopped_SoftwareInterrupt
:
1266 stopped_info
->stopped_status
= RDIError_SoftwareInterrupt
;
1268 case ADP_Stopped_PrefetchAbort
:
1269 stopped_info
->stopped_status
= RDIError_PrefetchAbort
;
1271 case ADP_Stopped_DataAbort
:
1272 stopped_info
->stopped_status
= RDIError_DataAbort
;
1274 case ADP_Stopped_AddressException
:
1275 stopped_info
->stopped_status
= RDIError_AddressException
;
1277 case ADP_Stopped_IRQ
:
1278 stopped_info
->stopped_status
= RDIError_IRQ
;
1280 case ADP_Stopped_BreakPoint
:
1281 stopped_info
->stopped_status
= RDIError_BreakpointReached
;
1283 case ADP_Stopped_WatchPoint
:
1284 stopped_info
->stopped_status
= RDIError_WatchpointAccessed
;
1286 case ADP_Stopped_StepComplete
:
1287 stopped_info
->stopped_status
= RDIError_ProgramFinishedInStep
;
1289 case ADP_Stopped_RunTimeErrorUnknown
:
1290 case ADP_Stopped_StackOverflow
:
1291 case ADP_Stopped_DivisionByZero
:
1292 stopped_info
->stopped_status
= RDIError_Error
;
1294 case ADP_Stopped_FIQ
:
1295 stopped_info
->stopped_status
= RDIError_FIQ
;
1297 case ADP_Stopped_UserInterruption
:
1298 case ADP_Stopped_OSSpecific
:
1299 stopped_info
->stopped_status
= RDIError_UserInterrupt
;
1301 case ADP_Stopped_ApplicationExit
:
1302 stopped_info
->stopped_status
= RDIError_NoError
;
1305 stopped_info
->stopped_status
= RDIError_Error
;
1308 return RDIError_NoError
;
1312 static void interrupt_target( void )
1314 Packet
*packet
= NULL
;
1316 int reason
, debugID
, OSinfo1
, OSinfo2
, status
;
1319 angel_DebugPrint("DEBUG: interrupt_target.\n");
1322 register_debug_message_handler();
1323 msgsend(CI_HADP
, "%w%w%w%w", ADP_InterruptRequest
| HtoT
, 0,
1324 ADP_HandleUnknown
, ADP_HandleUnknown
);
1326 reason
= ADP_InterruptRequest
|TtoH
;
1327 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1329 DevSW_FreePacket(packet
);
1331 angel_DebugPrint("DEBUG: got interrupt ack ok err = %d, status=%i\n",
1339 extern void test_dc_appl_handler( const DeviceDescr
*device
,
1343 /* Core functionality for execute and step */
1344 static int angel_RDI_ExecuteOrStep(PointHandle
*handle
, word type
,
1348 adp_stopped_struct stopped_info
;
1349 void* stateptr
= (void *)&stopped_info
;
1350 ChannelCallback HandleStoppedMessageFPtr
=(ChannelCallback
) HandleStoppedMessage
;
1351 int status
, reasoncode
, debugID
, OSinfo1
, OSinfo2
;
1352 Packet
*packet
= NULL
;
1354 TracePrint(("angel_RDI_ExecuteOrStep\n"));
1356 err
= Adp_ChannelRegisterRead(CI_TADP
,
1357 HandleStoppedMessageFPtr
, stateptr
);
1358 if (err
!= RDIError_NoError
) {
1360 angel_DebugPrint("TADP Register failed.\n");
1364 /* Set executing TRUE here, as it must be set up before the target has
1365 * had any chance at all to execute, or it may send its stopped message
1366 * before we get round to setting executing = TRUE !!!
1370 register_debug_message_handler();
1373 Adp_Install_DC_Appl_Handler( test_dc_appl_handler
);
1377 angel_DebugPrint("Transmiting %s message.\n",
1378 type
== ADP_Execute
? "execute": "step");
1381 register_debug_message_handler();
1382 /* Extra ninstr parameter for execute message will simply be ignored */
1383 err
= msgsend(CI_HADP
,"%w%w%w%w%w", type
| HtoT
, 0,
1384 ADP_HandleUnknown
, ADP_HandleUnknown
, ninstr
);
1386 if (err
!= RDIError_NoError
) angel_DebugPrint("Transmit failed.\n");
1389 reasoncode
= type
| TtoH
;
1390 err
= wait_for_debug_message( &reasoncode
, &debugID
, &OSinfo1
, &OSinfo2
,
1392 if (err
!= RDIError_NoError
)
1394 else if (status
!= RDIError_NoError
)
1398 angel_DebugPrint("Waiting for program to finish...\n");
1401 signal(SIGINT
, ardi_sigint_handler
);
1404 if (interrupt_request
)
1407 interrupt_request
= FALSE
;
1409 Adp_AsynchronousProcessing( async_block_on_nothing
);
1411 signal(SIGINT
, SIG_IGN
);
1415 Adp_Install_DC_Appl_Handler( NULL
);
1418 (void)Adp_ChannelRegisterRead(CI_TADP
, NULL
, NULL
);
1420 *handle
= (PointHandle
)stopped_info
.data
;
1422 CallStoppedProcs(stopped_info
.stopped_reason
);
1424 return stopped_info
.stopped_status
;
1427 /* Request that the target starts executing from the stored CPU state: use
1429 int angel_RDI_execute(PointHandle
*handle
)
1431 return angel_RDI_ExecuteOrStep(handle
, ADP_Execute
, 0);
1435 typedef void handlertype(int);
1437 static int interrupted
=0;
1439 static void myhandler(int sig
) {
1442 signal(SIGINT
, myhandler
);
1446 /*----------------------------------------------------------------------*/
1447 /*----angel_RDI_step-----------------------------------------------------*/
1448 /*----------------------------------------------------------------------*/
1450 /* Step 'ninstr' through the code: use ADP_Step. */
1451 int angel_RDI_step(unsigned ninstr
, PointHandle
*handle
)
1453 int err
= angel_RDI_ExecuteOrStep(handle
, ADP_Step
, ninstr
);
1454 if (err
== RDIError_ProgramFinishedInStep
)
1455 return RDIError_NoError
;
1461 static void SetCPWords(int cpnum
, struct Dbg_CoProDesc
const *cpd
) {
1463 for (i
= 0; i
< cpd
->entries
; i
++)
1464 if (cpd
->regdesc
[i
].rmax
> rmax
)
1465 rmax
= cpd
->regdesc
[i
].rmax
;
1467 { unsigned char *rmap
= (unsigned char *)malloc(rmax
+ 2);
1469 for (i
= 0; i
< cpd
->entries
; i
++) {
1471 for (r
= cpd
->regdesc
[i
].rmin
; r
<= cpd
->regdesc
[i
].rmax
; r
++)
1472 rmap
[r
] = (cpd
->regdesc
[i
].nbytes
+3) / 4;
1474 /* if (cpwords[cpnum] != NULL) free(cpwords[cpnum]); */
1475 cpwords
[cpnum
] = rmap
;
1479 /*----------------------------------------------------------------------*/
1480 /*----angel_RDI_info-----------------------------------------------------*/
1481 /*----------------------------------------------------------------------*/
1483 /* Use ADP_Info, ADP_Ctrl and ADP_Profile calls to implement these,
1484 see adp.h for more details. */
1486 static int angel_cc_exists( void )
1488 Packet
*packet
= NULL
;
1490 int reason
, debugID
, OSinfo1
, OSinfo2
, subreason
, status
;
1493 angel_DebugPrint("DEBUG: ADP_ICEB_CC_Exists.\n");
1496 if ( angel_RDI_info( RDIInfo_Icebreaker
, NULL
, NULL
) == RDIError_NoError
) {
1497 register_debug_message_handler();
1498 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_ICEbreakerHADP
| HtoT
, 0,
1499 ADP_HandleUnknown
, ADP_HandleUnknown
,
1500 ADP_ICEB_CC_Exists
);
1501 reason
= ADP_ICEbreakerHADP
|TtoH
;
1502 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1504 if (err
!= RDIError_NoError
) {
1505 DevSW_FreePacket(packet
);
1508 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
1509 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1510 if (subreason
!= ADP_ICEB_CC_Exists
) {
1511 DevSW_FreePacket(packet
);
1512 return RDIError_Error
;
1518 return RDIError_UnimplementedMessage
;
1522 RDICCProc_ToHost
*tohost
; void *tohostarg
;
1523 RDICCProc_FromHost
*fromhost
; void *fromhostarg
;
1526 static CCState ccstate
= { NULL
, NULL
, NULL
, NULL
, FALSE
};
1528 static void HandleDCCMessage( Packet
*packet
, void *stateptr
)
1530 unsigned int reason
, debugID
, OSinfo1
, OSinfo2
;
1532 CCState
*ccstate_p
= (CCState
*)stateptr
;
1534 count
= unpack_message( BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w",
1535 &reason
, &debugID
, &OSinfo1
, &OSinfo2
);
1538 case ADP_TDCC_ToHost
| TtoH
:
1540 /* only handles a single word of data, for now */
1542 unsigned int nbytes
, data
;
1544 unpack_message( BUFFERDATA(packet
->pk_buffer
)+count
, "%w%w",
1547 angel_DebugPrint( "DEBUG: received CC_ToHost message: nbytes %d data %08x.\n",
1550 ccstate_p
->tohost( ccstate_p
->tohostarg
, data
);
1551 msgsend(CI_TTDCC
, "%w%w%w%w%w",
1552 ADP_TDCC_ToHost
| HtoT
, debugID
, OSinfo1
, OSinfo2
,
1557 case ADP_TDCC_FromHost
| TtoH
:
1559 /* only handles a single word of data, for now */
1564 ccstate_p
->fromhost( ccstate_p
->fromhostarg
, &data
, &valid
);
1566 angel_DebugPrint( "DEBUG: received CC_FromHost message, returning: %08x %s.\n",
1567 data
, valid
? "VALID" : "INvalid" );
1569 msgsend(CI_TTDCC
, "%w%w%w%w%w%w%w",
1570 ADP_TDCC_FromHost
| HtoT
, debugID
, OSinfo1
, OSinfo2
,
1571 RDIError_NoError
, valid
? 1 : 0, data
);
1577 angel_DebugPrint( "Unexpected TDCC message %08x received\n", reason
);
1581 DevSW_FreePacket(packet
);
1585 static void angel_check_DCC_handler( CCState
*ccstate_p
)
1589 if ( ccstate_p
->tohost
!= NULL
|| ccstate_p
->fromhost
!= NULL
)
1591 /* doing DCC, so need a handler */
1592 if ( ! ccstate_p
->registered
)
1595 angel_DebugPrint( "Registering handler for TTDCC channel.\n" );
1597 err
= Adp_ChannelRegisterRead( CI_TTDCC
, HandleDCCMessage
,
1599 if ( err
== adp_ok
)
1600 ccstate_p
->registered
= TRUE
;
1603 angel_DebugPrint( "angel_check_DCC_handler: register failed!\n" );
1609 /* not doing DCC, so don't need a handler */
1610 if ( ccstate_p
->registered
)
1613 angel_DebugPrint( "Unregistering handler for TTDCC channel.\n" );
1615 err
= Adp_ChannelRegisterRead( CI_TTDCC
, NULL
, NULL
);
1616 if ( err
== adp_ok
)
1617 ccstate_p
->registered
= FALSE
;
1620 angel_DebugPrint( "angel_check_DCC_handler: unregister failed!\n" );
1627 static int CheckSubMessageReply(int reason
, int subreason
) {
1628 Packet
*packet
= NULL
;
1629 int status
, debugID
, OSinfo1
, OSinfo2
;
1630 int err
= RDIError_NoError
;
1632 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1634 if (err
!= RDIError_NoError
) {
1638 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
1639 &OSinfo1
, &OSinfo2
, &sr
, &status
);
1640 if (subreason
!= sr
) status
= RDIError_Error
;
1642 DevSW_FreePacket(packet
);
1646 static int SendSubMessageAndCheckReply(int reason
, int subreason
) {
1647 register_debug_message_handler();
1648 msgsend(CI_HADP
, "%w%w%w%w%w", reason
| HtoT
, 0,
1649 ADP_HandleUnknown
, ADP_HandleUnknown
,
1651 return CheckSubMessageReply(reason
, subreason
);
1654 static int SendSubMessageWordAndCheckReply(int reason
, int subreason
, ARMword word
) {
1655 register_debug_message_handler();
1656 msgsend(CI_HADP
, "%w%w%w%w%w%w", reason
| HtoT
, 0,
1657 ADP_HandleUnknown
, ADP_HandleUnknown
,
1659 return CheckSubMessageReply(reason
, subreason
);
1662 static int SendSubMessageGetWordAndCheckReply(int reason
, int subreason
, ARMword
*resp
) {
1663 Packet
*packet
= NULL
;
1664 int status
, debugID
, OSinfo1
, OSinfo2
;
1665 int err
= RDIError_NoError
;
1667 register_debug_message_handler();
1668 msgsend(CI_HADP
, "%w%w%w%w%w", reason
| HtoT
, 0,
1669 ADP_HandleUnknown
, ADP_HandleUnknown
,
1672 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1674 if (err
!= RDIError_NoError
) {
1678 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w", &reason
, &debugID
,
1679 &OSinfo1
, &OSinfo2
, &sr
, &status
, resp
);
1680 if (subreason
!= sr
) status
= RDIError_Error
;
1682 DevSW_FreePacket(packet
);
1686 static int const hostsex
= 1;
1688 int angel_RDI_info(unsigned type
, ARMword
*arg1
, ARMword
*arg2
) {
1689 Packet
*packet
= NULL
;
1690 int len
, status
, c
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
;
1691 int err
=RDIError_NoError
, cpnum
=0;
1692 struct Dbg_CoProDesc
*cpd
;
1697 angel_DebugPrint("DEBUG: Entered angel_RDI_info.\n");
1700 case RDIInfo_Target
:
1702 angel_DebugPrint("DEBUG: RDIInfo_Target.\n");
1705 register_debug_message_handler();
1706 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1707 ADP_HandleUnknown
, ADP_HandleUnknown
, ADP_Info_Target
);
1708 reason
= ADP_Info
|TtoH
;
1709 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1711 if (err
!= RDIError_NoError
) {
1712 DevSW_FreePacket(packet
);
1715 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w", &reason
,
1716 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
,
1718 DevSW_FreePacket(packet
);
1720 if (subreason
!= ADP_Info_Target
)
1721 return RDIError_Error
;
1725 case RDISignal_Stop
:
1727 angel_DebugPrint("DEBUG: RDISignal_Stop.\n");
1728 if (interrupt_request
)
1729 angel_DebugPrint(" STILL WAITING to send previous interrupt request\n");
1731 interrupt_request
= TRUE
;
1732 return RDIError_NoError
;
1734 case RDIInfo_Points
:
1736 angel_DebugPrint("DEBUG: RDIInfo_Points.\n");
1738 return SendSubMessageGetWordAndCheckReply(ADP_Info
, ADP_Info_Points
, arg1
);
1742 angel_DebugPrint("DEBUG: RDIInfo_Step.\n");
1744 return SendSubMessageGetWordAndCheckReply(ADP_Info
, ADP_Info_Step
, arg1
);
1746 case RDISet_Cmdline
:
1748 angel_DebugPrint("DEBUG: RDISet_Cmdline.\n");
1750 if (ardi_commandline
!= &dummycline
)
1751 free(ardi_commandline
);
1752 ardi_commandline
= (char *)malloc(strlen((char*)arg1
) + 1) ;
1753 (void)strcpy(ardi_commandline
, (char *)arg1
) ;
1754 return RDIError_NoError
;
1756 case RDIInfo_SetLog
:
1758 angel_DebugPrint("DEBUG: RDIInfo_SetLog.\n");
1760 rdi_log
= (int) *arg1
;
1761 return RDIError_NoError
;
1765 angel_DebugPrint("DEBUG: RDIInfo_Log.\n");
1768 return RDIError_NoError
;
1773 angel_DebugPrint("DEBUG: RDIInfo_MMU.\n");
1775 return SendSubMessageGetWordAndCheckReply(ADP_Info
, ADP_Info_MMU
, arg1
);
1777 case RDIInfo_SemiHosting
:
1779 angel_DebugPrint("DEBUG: RDIInfo_SemiHosting.\n");
1781 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_SemiHosting
);
1785 angel_DebugPrint("DEBUG: RDIInfo_CoPro.\n");
1787 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_CoPro
);
1791 angel_DebugPrint("DEBUG: RDICycles.\n");
1793 register_debug_message_handler();
1794 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1795 ADP_HandleUnknown
, ADP_HandleUnknown
, ADP_Info_Cycles
);
1796 reason
= ADP_Info
|TtoH
;
1797 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1799 if (err
!= RDIError_NoError
) {
1800 DevSW_FreePacket(packet
);
1803 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
1804 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1805 DevSW_FreePacket(packet
);
1806 if (subreason
!= ADP_Info_Cycles
)
1807 return RDIError_Error
;
1808 if (status
!= RDIError_NoError
) return status
;
1809 for (c
=0; c
<12; c
++)
1810 arg1
[c
]=GET32LE(BUFFERDATA(packet
->pk_buffer
)+24+(c
*4));
1813 case RDIInfo_DescribeCoPro
:
1815 angel_DebugPrint("DEBUG: RDIInfo_DescribeCoPro.\n");
1817 cpnum
= *(int *)arg1
;
1818 cpd
= (struct Dbg_CoProDesc
*)arg2
;
1819 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
1820 if (angel_RDI_info(ADP_Info_CoPro
, NULL
, NULL
) != RDIError_NoError
)
1821 return RDIError_Error
;
1822 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1823 ADP_HandleUnknown
, ADP_HandleUnknown
,
1824 ADP_Info_DescribeCoPro
);
1825 len
+=msgbuild(BUFFERDATA(packet
->pk_buffer
)+20, "%b%b%b%b%b", cpnum
,
1826 cpd
->regdesc
[cpnum
].rmin
, cpd
->regdesc
[cpnum
].rmax
,
1827 cpd
->regdesc
[cpnum
].nbytes
, cpd
->regdesc
[cpnum
].access
);
1828 if (cpd
->regdesc
[cpnum
].access
&0x3 == 0x3){
1829 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
)+25, "%b%b%b%b%b",
1830 cpd
->regdesc
[cpnum
].accessinst
.cprt
.read_b0
,
1831 cpd
->regdesc
[cpnum
].accessinst
.cprt
.read_b1
,
1832 cpd
->regdesc
[cpnum
].accessinst
.cprt
.write_b0
,
1833 cpd
->regdesc
[cpnum
].accessinst
.cprt
.write_b1
, 0xff);
1836 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
)+25, "%b%b%b%b%b%",
1837 cpd
->regdesc
[cpnum
].accessinst
.cpdt
.rdbits
,
1838 cpd
->regdesc
[cpnum
].accessinst
.cpdt
.nbit
,0,0, 0xff);
1840 register_debug_message_handler();
1841 packet
->pk_length
= len
;
1842 Adp_ChannelWrite(CI_HADP
, packet
); /* Transmit message. */
1843 reason
= ADP_Info
|TtoH
;
1844 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1846 if (err
!= RDIError_NoError
) {
1847 DevSW_FreePacket(packet
);
1850 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
1851 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1852 DevSW_FreePacket(packet
);
1853 if (subreason
!= ADP_Info_DescribeCoPro
)
1854 return RDIError_Error
;
1858 case RDIInfo_RequestCoProDesc
:
1860 angel_DebugPrint("DEBUG: RDIInfo_RequestCoProDesc.\n");
1862 cpnum
= *(int *)arg1
;
1863 cpd
= (struct Dbg_CoProDesc
*)arg2
;
1864 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
1865 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1866 ADP_HandleUnknown
, ADP_HandleUnknown
,
1867 ADP_Info_RequestCoProDesc
);
1868 len
+= msgbuild(BUFFERDATA(packet
->pk_buffer
)+20, "%b", *(int *)arg1
);
1869 packet
->pk_length
= len
;
1870 register_debug_message_handler();
1871 Adp_ChannelWrite(CI_HADP
, packet
); /* Transmit message. */
1872 reason
= ADP_Info
|TtoH
;
1873 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1875 if (err
!= RDIError_NoError
) {
1876 DevSW_FreePacket(packet
);
1879 count
= unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
1880 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1881 if (subreason
!= ADP_Info_RequestCoProDesc
) {
1882 DevSW_FreePacket(packet
);
1883 return RDIError_Error
;
1884 } else if ( status
!= RDIError_NoError
) {
1885 DevSW_FreePacket(packet
);
1888 bp
= BUFFERDATA(packet
->pk_buffer
)+count
;
1889 for ( i
= 0; *bp
!= 0xFF && i
< cpd
->entries
; ++i
) {
1890 cpd
->regdesc
[i
].rmin
= *bp
++;
1891 cpd
->regdesc
[i
].rmax
= *bp
++;
1892 cpd
->regdesc
[i
].nbytes
= *bp
++;
1893 cpd
->regdesc
[i
].access
= *bp
++;
1897 status
= RDIError_BufferFull
;
1899 SetCPWords( cpnum
, cpd
);
1900 DevSW_FreePacket(packet
);
1904 case RDIInfo_GetLoadSize
:
1906 angel_DebugPrint("DEBUG: ADP_Info_AngelBufferSize.\n");
1908 register_debug_message_handler();
1909 msgsend(CI_HADP
, "%w%w%w%w%w", ADP_Info
| HtoT
, 0,
1910 ADP_HandleUnknown
, ADP_HandleUnknown
,
1911 ADP_Info_AngelBufferSize
);
1912 reason
= ADP_Info
|TtoH
;
1913 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
1915 if (err
!= RDIError_NoError
) {
1916 DevSW_FreePacket(packet
);
1919 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
1920 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
1921 if (subreason
!= ADP_Info_AngelBufferSize
) {
1922 DevSW_FreePacket(packet
);
1923 return RDIError_Error
;
1926 word defaultsize
, longsize
;
1927 unpack_message(BUFFERDATA(packet
->pk_buffer
)+24, "%w%w",
1928 &defaultsize
, &longsize
);
1929 *arg1
= longsize
- ADP_WriteHeaderSize
; /* space for ADP header */
1930 #ifdef MONITOR_DOWNLOAD_PACKETS
1931 angel_DebugPrint("DEBUG: ADP_Info_AngelBufferSize: got (%d, %d), returning %d.\n",
1932 defaultsize
, longsize
, *arg1
);
1934 DevSW_FreePacket(packet
);
1938 case RDIVector_Catch
:
1940 angel_DebugPrint("DEBUG: ADP_Ctrl_VectorCatch %lx.\n", *arg1
);
1942 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_VectorCatch
, *arg1
);
1944 case RDISemiHosting_SetState
:
1946 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetState %lx.\n", *arg1
);
1948 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetState
, *arg1
);
1950 case RDISemiHosting_GetState
:
1952 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetState.\n");
1954 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetState
, arg1
);
1956 case RDISemiHosting_SetVector
:
1958 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetVector %lx.\n", *arg1
);
1960 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetVector
, *arg1
);
1962 case RDISemiHosting_GetVector
:
1964 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetVector.\n");
1966 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetVector
, arg1
);
1968 case RDISemiHosting_SetARMSWI
:
1970 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetARMSWI.\n");
1972 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetARMSWI
, *arg1
);
1974 case RDISemiHosting_GetARMSWI
:
1976 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetARMSWI.\n");
1978 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetARMSWI
, arg1
);
1980 case RDISemiHosting_SetThumbSWI
:
1982 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_SetThumbSWI.\n");
1984 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_SetThumbSWI
, *arg1
);
1986 case RDISemiHosting_GetThumbSWI
:
1988 angel_DebugPrint("DEBUG: ADP_Ctrl_SemiHosting_GetThumbSWI.\n");
1990 return SendSubMessageGetWordAndCheckReply(ADP_Control
, ADP_Ctrl_SemiHosting_GetThumbSWI
, arg1
);
1992 case RDIInfo_SetTopMem
:
1994 angel_DebugPrint("DEBUG: ADP_Ctrl_SetTopMem.\n");
1996 return SendSubMessageWordAndCheckReply(ADP_Control
, ADP_Ctrl_SetTopMem
, *arg1
);
1998 case RDIPointStatus_Watch
:
2000 angel_DebugPrint("DEBUG: ADP_Ctrl_PointStatus_Watch.\n");
2002 register_debug_message_handler();
2003 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Control
| HtoT
, 0,
2004 ADP_HandleUnknown
, ADP_HandleUnknown
,
2005 ADP_Ctrl_PointStatus_Watch
, *arg1
);
2006 reason
= ADP_Control
|TtoH
;
2007 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2009 if (err
!= RDIError_NoError
) {
2010 DevSW_FreePacket(packet
);
2013 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w", &reason
,
2014 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
,
2016 if (subreason
!= ADP_Ctrl_PointStatus_Watch
) {
2017 DevSW_FreePacket(packet
);
2018 return RDIError_Error
;
2023 case RDIPointStatus_Break
:
2025 angel_DebugPrint("DEBUG: ADP_Ctrl_PointStatus_Break.\n");
2027 register_debug_message_handler();
2028 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Control
| HtoT
, 0,
2029 ADP_HandleUnknown
, ADP_HandleUnknown
,
2030 ADP_Ctrl_PointStatus_Break
, *arg1
);
2031 reason
= ADP_Control
|TtoH
;
2032 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2034 if (err
!= RDIError_NoError
) {
2035 DevSW_FreePacket(packet
);
2038 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w", &reason
,
2039 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
,
2041 if (subreason
!= ADP_Ctrl_PointStatus_Break
) {
2042 DevSW_FreePacket(packet
);
2043 return RDIError_Error
;
2048 case RDIInfo_DownLoad
:
2050 angel_DebugPrint("DEBUG: ADP_Ctrl_Download_Supported.\n");
2052 return SendSubMessageAndCheckReply(ADP_Control
, ADP_Ctrl_Download_Supported
);
2054 case RDIConfig_Count
:
2056 angel_DebugPrint("DEBUG: ADP_ICEM_ConfigCount.\n");
2058 return SendSubMessageGetWordAndCheckReply(ADP_ICEman
, ADP_ICEM_ConfigCount
, arg1
);
2062 angel_DebugPrint("DEBUG: ADP_ICEM_ConfigNth.\n");
2064 register_debug_message_handler();
2065 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_ICEman
| HtoT
, 0,
2066 ADP_HandleUnknown
, ADP_HandleUnknown
,
2067 ADP_ICEM_ConfigNth
, *arg1
);
2068 reason
= ADP_ICEman
|TtoH
;
2069 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2071 if (err
!= RDIError_NoError
) {
2072 DevSW_FreePacket(packet
);
2075 RDI_ConfigDesc
*cd
= (RDI_ConfigDesc
*)arg2
;
2077 len
= unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%b",
2079 &OSinfo1
, &OSinfo2
, &subreason
, &status
,
2081 if (subreason
!= ADP_ICEM_ConfigNth
) {
2082 DevSW_FreePacket(packet
);
2083 return RDIError_Error
;
2086 memcpy( cd
->name
, BUFFERDATA(packet
->pk_buffer
)+len
, n
+1 );
2092 case RDIInfo_Icebreaker
:
2094 angel_DebugPrint("DEBUG: ADP_ICEB_Exists.\n");
2096 return SendSubMessageAndCheckReply(ADP_ICEbreakerHADP
, ADP_ICEB_Exists
);
2098 case RDIIcebreaker_GetLocks
:
2100 angel_DebugPrint("DEBUG: ADP_ICEB_GetLocks.\n");
2102 return SendSubMessageGetWordAndCheckReply(ADP_ICEbreakerHADP
, ADP_ICEB_GetLocks
, arg1
);
2104 case RDIIcebreaker_SetLocks
:
2106 angel_DebugPrint("DEBUG: ADP_ICEB_SetLocks.\n");
2108 return SendSubMessageWordAndCheckReply(ADP_ICEbreakerHADP
, ADP_ICEB_SetLocks
, *arg1
);
2110 case RDICommsChannel_ToHost
:
2112 angel_DebugPrint("DEBUG: ADP_ICEB_CC_Connect_ToHost.\n");
2114 if ( angel_cc_exists() == RDIError_NoError
) {
2117 * The following three lines of code have to be removed in order to get
2118 * the Windows Angel Channel Viewer working with the Thumb comms channel.
2119 * At the moment it allows the ARMSD command line to register a CCIN/CCOUT
2120 * callback which stops the ACV working!
2123 ccstate
.tohost
= (RDICCProc_ToHost
*)arg1
;
2124 ccstate
.tohostarg
= arg2
;
2125 angel_check_DCC_handler( &ccstate
);
2131 register_debug_message_handler();
2132 msgsend(CI_HADP
, "%w%w%w%w%w%b", ADP_ICEbreakerHADP
| HtoT
, 0,
2133 ADP_HandleUnknown
, ADP_HandleUnknown
,
2134 ADP_ICEB_CC_Connect_ToHost
, (arg1
!= NULL
) );
2135 return CheckSubMessageReply(ADP_ICEbreakerHADP
, ADP_ICEB_CC_Connect_ToHost
);
2137 return RDIError_UnimplementedMessage
;
2140 case RDICommsChannel_FromHost
:
2142 angel_DebugPrint("DEBUG: ADP_ICEB_CC_Connect_FromHost.\n");
2144 if ( angel_cc_exists() == RDIError_NoError
) {
2146 ccstate
.fromhost
= (RDICCProc_FromHost
*)arg1
;
2147 ccstate
.fromhostarg
= arg2
;
2148 angel_check_DCC_handler( &ccstate
);
2150 register_debug_message_handler();
2151 msgsend(CI_HADP
, "%w%w%w%w%w%b", ADP_ICEbreakerHADP
| HtoT
, 0,
2152 ADP_HandleUnknown
, ADP_HandleUnknown
,
2153 ADP_ICEB_CC_Connect_FromHost
, (arg1
!= NULL
) );
2154 return CheckSubMessageReply(ADP_ICEbreakerHADP
, ADP_ICEB_CC_Connect_FromHost
);
2156 return RDIError_UnimplementedMessage
;
2159 case RDIProfile_Stop
:
2160 return SendSubMessageAndCheckReply(ADP_Profile
, ADP_Profile_Stop
);
2162 case RDIProfile_ClearCounts
:
2163 return SendSubMessageAndCheckReply(ADP_Profile
, ADP_Profile_ClearCounts
);
2165 case RDIProfile_Start
:
2167 angel_DebugPrint("DEBUG: ADP_Profile_Start %ld.\n", (long)*arg1
);
2169 return SendSubMessageWordAndCheckReply(ADP_Profile
, ADP_Profile_Start
, *arg1
);
2171 case RDIProfile_WriteMap
:
2172 { RDI_ProfileMap
*map
= (RDI_ProfileMap
*)arg1
;
2173 int32 maplen
= map
->len
,
2176 int32 chunk
= (Armsd_LongBufSize
-CHAN_HEADER_SIZE
-ADP_ProfileWriteHeaderSize
) / sizeof(ARMword
);
2177 /* Maximum number of words sendable in one message */
2178 int oldrev
= bytesex_reversing();
2179 int host_little
= *(uint8
const *)&hostsex
;
2181 angel_DebugPrint("DEBUG: ADP_Profile_WriteMap %ld.\n", maplen
);
2183 status
= RDIError_NoError
;
2186 for (offset
= 0; offset
< maplen
; offset
++)
2187 map
->map
[offset
] = bytesex_hostval(map
->map
[offset
]);
2189 for (offset
= 0; offset
< maplen
; offset
+= size
) {
2191 size
= maplen
- offset
;
2192 packet
= (Packet
*)DevSW_AllocatePacket(Armsd_LongBufSize
);
2193 if (size
> chunk
) size
= chunk
;
2194 hdrlen
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w%w",
2195 ADP_Profile
| HtoT
, 0, ADP_HandleUnknown
,
2196 ADP_HandleUnknown
, ADP_Profile_WriteMap
,
2197 maplen
, size
, offset
);
2199 /* Copy the data into the packet. */
2200 memcpy(BUFFERDATA(packet
->pk_buffer
)+hdrlen
,
2201 &map
->map
[offset
], (size_t)size
* sizeof(ARMword
));
2202 packet
->pk_length
= size
* sizeof(ARMword
) + hdrlen
;
2203 register_debug_message_handler();
2204 Adp_ChannelWrite(CI_HADP
, packet
);
2205 reason
= ADP_Profile
| TtoH
;
2206 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2208 if (err
== RDIError_NoError
) {
2209 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
2210 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2211 if (subreason
!= ADP_Profile_WriteMap
) {
2212 err
= RDIError_Error
;
2214 DevSW_FreePacket(packet
);
2216 if (err
!= RDIError_NoError
) { status
= err
; break; }
2219 for (offset
= 0; offset
< maplen
; offset
++)
2220 map
->map
[offset
] = bytesex_hostval(map
->map
[offset
]);
2221 bytesex_reverse(oldrev
);
2226 case RDIProfile_ReadMap
:
2227 { int32 maplen
= *(int32
*)arg1
,
2230 int32 chunk
= (Armsd_BufferSize
-CHAN_HEADER_SIZE
-ADP_ProfileReadHeaderSize
) / sizeof(ARMword
);
2232 angel_DebugPrint("DEBUG: ADP_Profile_ReadMap %ld.\n", maplen
);
2234 status
= RDIError_NoError
;
2235 for (offset
= 0; offset
< maplen
; offset
+= size
) {
2236 size
= maplen
- offset
;
2237 if (size
> chunk
) size
= chunk
;
2238 register_debug_message_handler();
2239 msgsend(CI_HADP
, "%w%w%w%w%w%w%w", ADP_Profile
| HtoT
, 0,
2240 ADP_HandleUnknown
, ADP_HandleUnknown
,
2241 ADP_Profile_ReadMap
, offset
, size
);
2242 reason
= ADP_Profile
| TtoH
;
2243 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2245 if (err
!= RDIError_NoError
) return err
;
2246 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
2247 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2248 memcpy(&arg2
[offset
], BUFFERDATA(packet
->pk_buffer
)+ADP_ProfileReadHeaderSize
,
2249 size
* sizeof(ARMword
));
2250 DevSW_FreePacket(packet
);
2251 if (status
!= RDIError_NoError
) break;
2253 { int oldrev
= bytesex_reversing();
2254 int host_little
= *(uint8
const *)&hostsex
;
2257 for (offset
= 0; offset
< maplen
; offset
++)
2258 arg2
[offset
] = bytesex_hostval(arg2
[offset
]);
2260 bytesex_reverse(oldrev
);
2265 case RDIInfo_CanTargetExecute
:
2267 printf("DEBUG: RDIInfo_CanTargetExecute.\n");
2269 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_CanTargetExecute
);
2271 case RDIInfo_AgentEndianess
:
2272 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_AgentEndianess
);
2276 angel_DebugPrint("DEBUG: Fell through ADP_Info, default case taken.\n");
2277 angel_DebugPrint("DEBUG: type = 0x%x.\n", type
);
2279 if (type
& RDIInfo_CapabilityRequest
) {
2280 switch (type
& ~RDIInfo_CapabilityRequest
) {
2281 case RDISemiHosting_SetARMSWI
:
2282 return SendSubMessageAndCheckReply(ADP_Info
, ADP_Info_ChangeableSHSWI
);
2286 "DEBUG: ADP_Info - Capability Request(%d) - reporting unimplemented \n",
2287 type
& ~RDIInfo_CapabilityRequest
);
2292 return RDIError_UnimplementedMessage
;
2297 /*----------------------------------------------------------------------*/
2298 /*----angel_RDI_AddConfig------------------------------------------------*/
2299 /*----------------------------------------------------------------------*/
2301 /* Add a configuration: use ADP_ICEM_AddConfig. */
2302 int angel_RDI_AddConfig(unsigned long nbytes
) {
2303 Packet
*packet
= NULL
;
2304 int status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2307 angel_DebugPrint("DEBUG: Entered angel_RDI_AddConfig.\n");
2309 register_debug_message_handler();
2310 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_ICEman
| HtoT
,
2311 0, ADP_HandleUnknown
, ADP_HandleUnknown
,
2312 ADP_ICEM_AddConfig
, nbytes
);
2313 reason
=ADP_ICEman
| TtoH
;
2314 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2316 if (err
!= RDIError_NoError
) {
2317 DevSW_FreePacket(packet
);
2320 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
2321 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2322 DevSW_FreePacket(packet
);
2323 if ( subreason
!= ADP_ICEM_AddConfig
)
2324 return RDIError_Error
;
2330 /*----------------------------------------------------------------------*/
2331 /*----angel_RDI_LoadConfigData-------------------------------------------*/
2332 /*----------------------------------------------------------------------*/
2334 /* Load configuration data: use ADP_Ctrl_Download_Data. */
2335 int angel_RDI_LoadConfigData(unsigned long nbytes
, char const *data
) {
2336 Packet
*packet
= NULL
;
2337 int len
, status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2340 angel_DebugPrint("DEBUG: Entered angel_RDI_LoadConfigData (%d bytes)\n", nbytes
);
2343 if (err
= angel_RDI_AddConfig(nbytes
) != RDIError_NoError
)
2346 packet
= DevSW_AllocatePacket(Armsd_LongBufSize
);
2347 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w",
2348 ADP_Control
| HtoT
, 0,
2349 ADP_HandleUnknown
, ADP_HandleUnknown
,
2350 ADP_Ctrl_Download_Data
, nbytes
);
2351 memcpy(BUFFERDATA(packet
->pk_buffer
)+len
, data
, nbytes
);
2353 packet
->pk_length
= len
;
2355 angel_DebugPrint("DEBUG: packet len %d.\n", len
);
2357 register_debug_message_handler();
2358 Adp_ChannelWrite(CI_HADP
, packet
);
2359 reason
=ADP_Control
| TtoH
;
2360 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2362 if (err
!= RDIError_NoError
) {
2363 DevSW_FreePacket(packet
);
2366 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
2367 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2368 DevSW_FreePacket(packet
);
2369 if ( subreason
!= ADP_Ctrl_Download_Data
)
2370 return RDIError_Error
;
2376 /*----------------------------------------------------------------------*/
2377 /*----angel_RDI_SelectConfig---------------------------------------------*/
2378 /*----------------------------------------------------------------------*/
2380 /* Select a configuration: use ADP_ICEM_SelecConfig.*/
2381 int angel_RDI_SelectConfig(RDI_ConfigAspect aspect
, char const *name
,
2382 RDI_ConfigMatchType matchtype
, unsigned versionreq
,
2385 Packet
*packet
= NULL
;
2386 int len
, status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2389 angel_DebugPrint("DEBUG: Entered angel_RDI_SelectConfig.\n");
2391 packet
= DevSW_AllocatePacket(Armsd_BufferSize
);
2392 len
= msgbuild(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%b%b%b%w",
2393 ADP_ICEman
| HtoT
, 0,
2394 ADP_HandleUnknown
, ADP_HandleUnknown
,
2395 ADP_ICEM_SelectConfig
, aspect
, strlen(name
),
2396 matchtype
, versionreq
);
2397 /* copy the name into the buffer */
2398 memcpy(BUFFERDATA(packet
->pk_buffer
)+len
, name
, strlen(name
));
2399 len
+= strlen(name
);
2400 packet
->pk_length
= len
;
2401 register_debug_message_handler();
2402 Adp_ChannelWrite(CI_HADP
, packet
);
2403 reason
=ADP_ICEman
| TtoH
;
2404 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2406 if (err
!= RDIError_NoError
) {
2407 DevSW_FreePacket(packet
);
2410 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w%w",
2411 &reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2412 &subreason
, &status
, versionp
);
2413 DevSW_FreePacket(packet
);
2414 if ( subreason
!= ADP_ICEM_SelectConfig
)
2415 return RDIError_Error
;
2421 /*----------------------------------------------------------------------*/
2422 /*----angel_RDI_LoadAgent------------------------------------------------*/
2423 /*----------------------------------------------------------------------*/
2425 /* Load a new debug agent: use ADP_Ctrl_Download_Agent. */
2426 int angel_RDI_LoadAgent(ARMword dest
, unsigned long size
,
2427 getbufferproc
*getb
, void *getbarg
)
2429 Packet
*packet
= NULL
;
2430 int status
, reason
, subreason
, debugID
, OSinfo1
, OSinfo2
, err
;
2433 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2434 angel_DebugPrint("DEBUG: Entered angel_RDI_LoadAgent.\n");
2436 register_debug_message_handler();
2437 msgsend(CI_HADP
, "%w%w%w%w%w%w%w", ADP_Control
| HtoT
,
2438 0, ADP_HandleUnknown
, ADP_HandleUnknown
,
2439 ADP_Ctrl_Download_Agent
, dest
, size
);
2440 reason
=ADP_Control
| TtoH
;
2441 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2443 if (err
!= RDIError_NoError
) {
2444 DevSW_FreePacket(packet
);
2447 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
, &debugID
,
2448 &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2449 DevSW_FreePacket(packet
);
2450 if ( subreason
!= ADP_Ctrl_Download_Agent
)
2451 return RDIError_Error
;
2452 if ( status
!= RDIError_NoError
)
2455 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2456 angel_DebugPrint("DEBUG: starting agent data download.\n");
2458 { unsigned long pos
= 0, segsize
;
2459 for (; pos
< size
; pos
+= segsize
) {
2460 char *b
= getb(getbarg
, &segsize
);
2461 if (b
== NULL
) return RDIError_NoError
;
2462 err
= angel_RDI_LoadConfigData( segsize
, b
);
2463 if (err
!= RDIError_NoError
) return err
;
2466 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2467 angel_DebugPrint("DEBUG: finished downloading new agent.\n");
2470 /* renegotiate back down */
2471 err
= angel_negotiate_defaults();
2475 /* Output a message to tell the user what is going on. This is vital
2476 * when switching from ADP EICE to ADP over JTAG, as then the user
2477 * has to reset the target board !
2480 int len
=angel_RDI_errmess(msg
, 256, adp_new_agent_starting
);
2481 angel_hostif
->write(angel_hostif
->hostosarg
, msg
, len
);
2484 /* get new image started */
2485 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2486 angel_DebugPrint("DEBUG: sending start message for new agent.\n");
2489 register_debug_message_handler();
2490 msgsend(CI_HADP
, "%w%w%w%w%w%w", ADP_Control
| HtoT
,
2491 0, ADP_HandleUnknown
, ADP_HandleUnknown
,
2492 ADP_Ctrl_Start_Agent
, dest
);
2493 reason
=ADP_Control
| TtoH
;
2494 err
= wait_for_debug_message(&reason
, &debugID
, &OSinfo1
, &OSinfo2
,
2496 if (err
!= RDIError_NoError
) {
2497 DevSW_FreePacket(packet
);
2500 unpack_message(BUFFERDATA(packet
->pk_buffer
), "%w%w%w%w%w%w", &reason
,
2501 &debugID
, &OSinfo1
, &OSinfo2
, &subreason
, &status
);
2502 DevSW_FreePacket(packet
);
2503 if ( subreason
!= ADP_Ctrl_Start_Agent
)
2504 return RDIError_Error
;
2505 if ( status
!= RDIError_NoError
)
2508 /* wait for image to start up */
2509 heartbeat_enabled
= FALSE
;
2512 Adp_AsynchronousProcessing(async_block_on_nothing
);
2513 if ((time(NULL
)-t
) > 2) {
2515 angel_DebugPrint("DEBUG: no booted message from new image yet.\n");
2519 } while (booted_not_received
);
2520 booted_not_received
=1;
2522 /* Give device driver a chance to do any necessary resyncing with new agent.
2523 * Only used by etherdrv.c at the moment.
2525 (void)Adp_Ioctl( DC_RESYNC
, NULL
);
2527 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2528 angel_DebugPrint("DEBUG: reopening to new agent.\n");
2530 err
= angel_RDI_open(0, NULL
, NULL
, NULL
);
2533 case RDIError_NoError
:
2535 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2536 angel_DebugPrint( "LoadAgent: Open returned RDIError_NoError\n" );
2541 case RDIError_LittleEndian
:
2543 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2544 angel_DebugPrint( "LoadAgent: Open returned RDIError_LittleEndian (OK)\n" );
2546 err
= RDIError_NoError
;
2550 case RDIError_BigEndian
:
2552 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2553 angel_DebugPrint( "LoadAgent: Open returned RDIError_BigEndian (OK)\n" );
2555 err
= RDIError_NoError
;
2561 #if defined(DEBUG) || defined(DEBUG_LOADAGENT)
2562 angel_DebugPrint( "LoadAgent: Open returned %d - unexpected!\n", err
);
2567 #ifndef NO_HEARTBEAT
2568 heartbeat_enabled
= TRUE
;
2573 static int angel_RDI_errmess(char *buf
, int blen
, int errnum
) {
2578 case adp_malloc_failure
:
2579 s
=AdpMess_MallocFailed
; break;
2580 case adp_illegal_args
:
2581 s
=AdpMess_IllegalArgs
; break;
2582 case adp_device_not_found
:
2583 s
=AdpMess_DeviceNotFound
; break;
2584 case adp_device_open_failed
:
2585 s
=AdpMess_DeviceOpenFailed
; break;
2586 case adp_device_already_open
:
2587 s
=AdpMess_DeviceAlreadyOpen
; break;
2588 case adp_device_not_open
:
2589 s
=AdpMess_DeviceNotOpen
; break;
2590 case adp_bad_channel_id
:
2591 s
=AdpMess_BadChannelId
; break;
2592 case adp_callback_already_registered
:
2593 s
=AdpMess_CBAlreadyRegd
; break;
2594 case adp_write_busy
:
2595 s
=AdpMess_WriteBusy
; break;
2596 case adp_bad_packet
:
2597 s
=AdpMess_BadPacket
; break;
2599 s
=AdpMess_SeqHigh
; break;
2601 s
=AdpMess_SeqLow
; break;
2602 case adp_timeout_on_open
:
2603 s
=AdpMess_TimeoutOnOpen
; break;
2605 s
=AdpMess_Failed
; break;
2606 case adp_abandon_boot_wait
:
2607 s
=AdpMess_AbandonBootWait
; break;
2608 case adp_late_startup
:
2609 s
=AdpMess_LateStartup
; break;
2610 case adp_new_agent_starting
:
2611 s
=AdpMess_NewAgentStarting
; break;
2615 if (n
>blen
-1) n
=blen
-1;
2621 extern const struct RDIProcVec angel_rdi
;
2622 const struct RDIProcVec angel_rdi
= {
2633 angel_RDI_clearbreak
,
2635 angel_RDI_clearwatch
,
2641 angel_RDI_AddConfig
,
2642 angel_RDI_LoadConfigData
,
2643 angel_RDI_SelectConfig
,
2645 0, /*angel_RDI_drivernames,*/
2655 /* Not strictly necessary, but allows linking this code into armsd. */
2665 } hostappl_CmdTable
[1] = {{"", NULL
}};