#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.12 2010/06/06 03:34:14 mrg Exp $");
#include <sys/param.h>
#include <sys/proc.h>
#include <uvm/uvm_extern.h>
#include <machine/db_machdep.h>
#include <machine/promlib.h>
#include <machine/pte.h>
#include <sun2/sun2/machdep.h>
#include <sun2/sun2/control.h>
#include <ddb/db_command.h>
#include <ddb/db_output.h>
#include <ddb/db_interface.h>
static void db_mach_abort (db_expr_t, bool, db_expr_t, const char *);
static void db_mach_halt (db_expr_t, bool, db_expr_t, const char *);
static void db_mach_reboot (db_expr_t, bool, db_expr_t, const char *);
static void db_mach_pagemap(db_expr_t, bool, db_expr_t, const char *);
const struct db_command db_machine_command_table[] = {
{ DDB_ADD_CMD("abort", db_mach_abort, 0,
"Calls prom_abort()", NULL, NULL) },
{ DDB_ADD_CMD("halt", db_mach_halt, 0,
"Calls prom_halt()", NULL, NULL) },
{ DDB_ADD_CMD("pgmap", db_mach_pagemap, CS_SET_DOT,
"Prints the PTE and segmap values", "virtual-address", NULL) },
{ DDB_ADD_CMD("reboot", db_mach_reboot, 0,
"Calls prom_boot()", NULL, NULL) },
{ DDB_ADD_CMD( NULL,NULL,0,NULL,NULL,NULL) }
};
static void
db_mach_abort(db_expr_t addr, bool have_addr, db_expr_t count,
const char *modif)
{
prom_abort();
}
static void
db_mach_halt(db_expr_t addr, bool have_addr, db_expr_t count,
const char *modif)
{
prom_halt();
}
static void
db_mach_reboot(db_expr_t addr, bool have_addr, db_expr_t count,
const char *modif)
{
prom_boot("");
}
static void pte_print(int);
static void
db_mach_pagemap(db_expr_t addr, bool have_addr, db_expr_t count,
const char *modif)
{
u_long va = m68k_trunc_page((u_long)addr);
int pte;
int sme;
sme = get_segmap(va);
if (sme == 0xFF) pte = 0;
else pte = get_pte(va);
db_printf("0x%08lx [%02x] 0x%08x", va, sme, pte);
pte_print(pte);
db_next = va + PAGE_SIZE;
}
static void
pte_print(int pte)
{
int t;
static const char *pgt_names[] = {
"MEM", "OBIO", "VME0", "VME8",
};
if (pte & PG_VALID) {
db_printf(" V");
if (pte & PG_WRITE)
db_printf(" W");
if (pte & PG_SYSTEM)
db_printf(" S");
if (pte & PG_NC)
db_printf(" NC");
if (pte & PG_REF)
db_printf(" Ref");
if (pte & PG_MOD)
db_printf(" Mod");
t = (pte >> PG_TYPE_SHIFT) & 3;
db_printf(" %s", pgt_names[t]);
db_printf(" PA=0x%x\n", PG_PA(pte));
}
else db_printf(" INVALID\n");
}