/*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#include <mach/mach_types.h>
#include <ppc/proc_reg.h>
#include <kdp/kdp_internal.h>
#include <ppc/savearea.h>
+#include <ppc/misc_protos.h>
#include <kern/debug.h>
#include <IOKit/IOPlatformExpert.h>
-
#include <kern/thread.h>
#include <ppc/thread.h>
#include <vm/vm_map.h>
void print_saved_state(void *);
void kdp_call(void);
-void kdp_trap( unsigned int, struct savearea *saved_state);
int kdp_getc(void);
boolean_t kdp_call_kdb(void);
extern pmap_t kdp_pmap;
-extern uint32_t kdp_src_high32;
-
-
-extern unsigned kdp_vm_read(caddr_t src, caddr_t dst, unsigned len);
int
-machine_trace_thread(thread_t thread, uint32_t tracepos, uint32_t tracebound, int nframes, boolean_t user_p);
+machine_trace_thread(thread_t thread, char *tracepos, char *tracebound, int nframes, boolean_t user_p);
int
-machine_trace_thread64(thread_t thread, uint32_t tracepos, uint32_t tracebound, int nframes, boolean_t user_p);
+machine_trace_thread64(thread_t thread, char *tracepos, char *tracebound, int nframes, boolean_t user_p);
unsigned
machine_read64(addr64_t srcaddr, caddr_t dstaddr, uint32_t len);
kdp_exception_ack_t aligned_pkt;
kdp_exception_ack_t *rq = (kdp_exception_ack_t *)&aligned_pkt;
- if (len < sizeof (*rq))
+ if ((size_t)len < sizeof (*rq))
return(FALSE);
bcopy((char *)pkt, (char *)rq, sizeof(*rq));
kdp_error_t
kdp_machine_read_regs(
- unsigned int cpu,
+ __unused unsigned int cpu,
unsigned int flavor,
char *data,
int *size
kdp_error_t
kdp_machine_write_regs(
- unsigned int cpu,
+ __unused unsigned int cpu,
unsigned int flavor,
char *data,
- int *size
+ __unused int *size
)
{
switch (flavor) {
while(1) {}
}
+extern void halt_all_cpus(boolean_t);
void
-kdp_reboot(void)
+kdp_machine_reboot(void)
{
printf("Attempting system restart...");
/* Call the platform specific restart*/
void
kdp_us_spin(int usec)
{
- extern void delay(int);
-
delay(usec/100);
}
}
void
-kdp_call()
+kdp_call(void)
{
Debugger("inline call to debugger(machine_startup)");
}
};
int
-kdp_getc()
+kdp_getc(void)
{
return(cnmaygetc());
}
{
unsigned int *fp;
unsigned int sp;
- struct savearea *state;
if (kdp_noisy) {
if (kdp_backtrace) {
return(TRUE);
}
-void kdp_print_registers(struct savearea *state)
+static void kdp_print_registers(struct savearea *state)
{
int i;
for (i=0; i<32; i++) {
if ((i % 8) == 0)
printf("\n%4d :",i);
- printf(" %08x",*(&state->save_r0+i));
+ printf(" %08llx",*(&state->save_r0+i));
}
printf("\n");
printf("cr = 0x%08x\t\t",state->save_cr);
- printf("xer = 0x%08x\n",state->save_xer);
- printf("lr = 0x%08x\t\t",state->save_lr);
- printf("ctr = 0x%08x\n",state->save_ctr);
- printf("srr0(iar) = 0x%08x\t\t",state->save_srr0);
- printf("srr1(msr) = 0x%08B\n",state->save_srr1,
- "\x10\x11""EE\x12PR\x13""FP\x14ME\x15""FE0\x16SE\x18"
- "FE1\x19""AL\x1a""EP\x1bIT\x1c""DT");
+ printf("xer = 0x%08llx\n",state->save_xer);
+ printf("lr = 0x%08llx\t\t",state->save_lr);
+ printf("ctr = 0x%08llx\n",state->save_ctr);
+ printf("srr0(iar) = 0x%08llx\t\t",state->save_srr0);
+ printf("srr1(msr) = 0x%08llx\n",state->save_srr1);
printf("\n");
}
+void kdp_print_backtrace(unsigned, struct savearea *);
+
void
kdp_print_backtrace(
unsigned int exception,
struct savearea *saved_state)
{
- extern void kdp_print_registers(struct savearea *);
- extern void print_backtrace(struct savearea *);
-
- disableDebugOuput = FALSE;
+ disable_debug_output = FALSE;
debug_mode = TRUE;
printf("re-entering kdp:\n");
printf("vector=%x, \n", exception/4);
while(1);
}
-unsigned int kdp_ml_get_breakinsn(void)
+void
+kdp_machine_get_breakinsn(
+ uint8_t *bytes,
+ uint32_t *size
+)
{
- return 0x7fe00008;
+ *(uint32_t *)bytes = 0x7fe00008;
+ *size = sizeof(uint32_t);
}
+
#define LR_OFFSET 8
#define LR_OFFSET64 16
int
-machine_trace_thread(thread_t thread, uint32_t tracepos, uint32_t tracebound, int nframes, boolean_t user_p)
+machine_trace_thread(thread_t thread, char *tracepos, char *tracebound, int nframes, boolean_t user_p)
{
uint32_t *tracebuf = (uint32_t *)tracepos;
uint32_t fence = 0;
for (framecount = 0; framecount < nframes; framecount++) {
/* Bounds check */
- if ((tracebound - ((uint32_t) tracebuf)) < (4 * framesize)) {
+ if ((uint32_t) (tracebound - ((char *)tracebuf)) < (4 * framesize)) {
tracebuf--;
break;
}
break;
}
/* Assume there's a saved link register, and read it */
- if (kdp_vm_read((caddr_t) (stackptr + LR_OFFSET), (caddr_t) tracebuf, sizeof(caddr_t)) != sizeof(caddr_t)) {
+ if (kdp_machine_vm_read((caddr_t) (stackptr + LR_OFFSET), (caddr_t) tracebuf, sizeof(caddr_t)) != sizeof(caddr_t)) {
break;
}
tracebuf++;
prevsp = stackptr;
/* Next frame */
- if (kdp_vm_read((caddr_t) stackptr, (caddr_t) &stackptr, sizeof(caddr_t)) != sizeof(caddr_t)) {
+ if (kdp_machine_vm_read((caddr_t) stackptr, (caddr_t) &stackptr, sizeof(caddr_t)) != sizeof(caddr_t)) {
*tracebuf++ = 0;
break;
}
}
/* Reset the target pmap */
- kdp_pmap = 0;
- return ((uint32_t) tracebuf - tracepos);
+ kdp_pmap = NULL;
+ return (uint32_t) (((char *) tracebuf) - tracepos);
}
/* Routine to encapsulate the 64-bit address read hack*/
unsigned
machine_read64(addr64_t srcaddr, caddr_t dstaddr, uint32_t len)
{
- uint32_t kdp_vm_read_low32;
unsigned retval;
- kdp_src_high32 = srcaddr >> 32;
- kdp_vm_read_low32 = srcaddr & 0x00000000FFFFFFFFUL;
- retval = kdp_vm_read((caddr_t)kdp_vm_read_low32, dstaddr, len);
- kdp_src_high32 = 0;
+ retval = kdp_machine_vm_read(srcaddr, dstaddr, len);
return retval;
}
int
-machine_trace_thread64(thread_t thread, uint32_t tracepos, uint32_t tracebound, int nframes, boolean_t user_p)
+machine_trace_thread64(thread_t thread, char *tracepos, char *tracebound, int nframes, boolean_t user_p)
{
uint64_t *tracebuf = (uint64_t *)tracepos;
uint32_t fence = 0;
for (framecount = 0; framecount < nframes; framecount++) {
- if ((tracebound - ((uint32_t) tracebuf)) < (4 * framesize)) {
+ if ((uint32_t)(tracebound - ((char *)tracebuf)) < (4 * framesize)) {
tracebuf--;
break;
}
}
}
- kdp_pmap = 0;
+ kdp_pmap = NULL;
+ return (uint32_t) (((char *) tracebuf) - tracepos);
+}
+
- return ((uint32_t) tracebuf - tracepos);
+void
+kdp_ml_enter_debugger(void)
+{
+ __asm__ __volatile__("tw 4,r3,r3");
+}
+
+int
+kdp_machine_ioport_read(kdp_readioport_req_t *rq, caddr_t data, uint16_t lcpu)
+{
+ return 0;
+}
+
+int
+kdp_machine_ioport_write(kdp_writeioport_req_t *rq, caddr_t data, uint16_t lcpu)
+{
+ return 0;
+}
+
+int
+kdp_machine_msr64_read(kdp_readmsr64_req_t *rq, caddr_t data, uint16_t lcpu)
+{
+ return 0;
+}
+
+int
+kdp_machine_msr64_write(kdp_writemsr64_req_t *rq, __unused caddr_t data, uint16_t lcpu)
+{
+ return 0;
}