/*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <ppc/db_machdep.h>
#include <ppc/mappings.h>
#include <ppc/Firmware.h>
+#include <ppc/serial_io.h> /* for switch_to_serial_console */
#include <mach/vm_param.h>
#include <mach/machine/vm_types.h>
#include <kern/thread.h>
#include <kern/task.h>
#include <kern/debug.h>
+#include <kern/machine.h> /* for halt_all_cpus() */
#include <pexpert/pexpert.h>
#include <IOKit/IOPlatformExpert.h>
struct savearea *ppc_last_saved_statep;
struct savearea ppc_nested_saved_state;
unsigned ppc_last_kdb_sp;
+db_regs_t ddb_regs; /* register state */
extern int debugger_cpu; /* Current cpu running debugger */
struct ppc_interrupt_state *is;
};
-extern char * trap_type[];
extern int TRAP_TYPES;
/*
== BKPT_INST))
regs->save_srr0 += BKPT_SIZE;
-kdb_exit:
getPerProc()->db_saved_state = 0;
switch_to_old_console(previous_console_device);
/*
*
*/
-addr64_t db_vtophys(
- pmap_t pmap,
- vm_offset_t va)
+static addr64_t
+db_vtophys(pmap_t pmap, vm_offset_t va)
{
ppnum_t pp;
addr64_t pa;
task_t task)
{
register int n;
- unsigned int kern_addr;
if (task == kernel_task || task == TASK_NULL) {
if (kernel_task == TASK_NULL) return(TRUE);
#define DB_USER_STACK_ADDR (0xc0000000)
#define DB_NAME_SEARCH_LIMIT (DB_USER_STACK_ADDR-(PPC_PGBYTES*3))
-boolean_t db_phys_cmp(
- vm_offset_t a1,
- vm_offset_t a2,
- vm_size_t s1) {
-
+boolean_t
+db_phys_cmp(__unused vm_offset_t a1, __unused vm_offset_t a2,
+ __unused vm_size_t s1)
+{
db_printf("db_phys_cmp: not implemented\n");
return 0;
}
int
-db_search_null(
- task_t task,
- unsigned *svaddr,
- unsigned evaddr,
- unsigned *skaddr,
- int flag)
+db_search_null(__unused task_t task, __unused unsigned *svaddr,
+ __unused unsigned evaddr, __unused unsigned *skaddr,
+ __unused int flag)
{
- register unsigned vaddr;
- register unsigned *kaddr;
-
db_printf("db_search_null: not implemented\n");
-
return(-1);
}
+struct proc;
unsigned char *getProcName(struct proc *proc);
void
task_t task)
{
register unsigned char *p;
- register int n;
- unsigned int vaddr, kaddr;
unsigned char tname[33];
int i;
else db_printf("no name");
}
+extern int kdb_flag;
void
-db_machdep_init(void) {
+db_machdep_init(void)
+{
#define KDB_READY 0x1
- extern int kdb_flag;
-
kdb_flag |= KDB_READY;
}
#ifdef __STDC__
-#define KDB_SAVE(type, name) extern type name; type name##_save = name
+//#define KDB_SAVE(type, name) extern type name; type name##_save = name
+#define KDB_SAVE(type, name) type name##_save = name
#define KDB_RESTORE(name) name = name##_save
#else /* __STDC__ */
-#define KDB_SAVE(type, name) extern type name; type name/**/_save = name
+#define KDB_SAVE(type, name) type name/**/_save = name
+//#define KDB_SAVE(type, name) extern type name; type name/**/_save = name
#define KDB_RESTORE(name) name = name/**/_save
#endif /* __STDC__ */
KDB_RESTORE(db_next); \
KDB_RESTORE(ddb_regs);
+extern boolean_t db_sstep_print;
+extern int db_loop_count;
+extern int db_call_depth;
+extern int db_inst_count;
+extern int db_last_inst_count;
+extern int db_load_count;
+extern int db_store_count;
+extern boolean_t db_cmd_loop_done;
+extern void unlock_debugger(void);
+extern void lock_debugger(void);
/*
* switch to another cpu
*/
int cpu)
{
KDB_SAVE_CTXT();
- if (cpu < 0 || cpu >= real_ncpus || !PerProcTable[cpu].ppe_vaddr->debugger_active)
+ if (cpu < 0 || cpu >= (int)real_ncpus || !PerProcTable[cpu].ppe_vaddr->debugger_active)
return;
db_set_breakpoints();
db_set_watchpoints();
KDB_RESTORE_CTXT();
if (debugger_cpu == -1) {/* someone continued */
debugger_cpu = cpu_number();
- db_continue_cmd(0, 0, 0, "");
+ db_continue_cmd(0, 0, 0, NULL);
}
}
* system reboot
*/
-extern int (*PE_halt_restart)(unsigned int type);
-
-void db_reboot(
- db_expr_t addr,
- boolean_t have_addr,
- db_expr_t count,
- char *modif)
+void
+db_reboot(__unused db_expr_t addr, __unused boolean_t have_addr,
+ __unused db_expr_t count, char *modif)
{
boolean_t reboot = TRUE;
char *cp, c;
}
if(!reboot) halt_all_cpus(FALSE); /* If no reboot, try to be clean about it */
- if (PE_halt_restart) return (*PE_halt_restart)(kPERestartCPU);
+ if (PE_halt_restart)
+ (*PE_halt_restart)(kPERestartCPU);
db_printf("Sorry, system can't reboot automatically yet... You need to do it by hand...\n");
}
-
-/*
- * Switch to gdb
- */
-void
-db_to_gdb(
- void)
-{
- extern unsigned int switch_debugger;
-
- switch_debugger=1;
-}