#include "opt_ddb.h"
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/reg.h>
#include <sys/systm.h>
#include <machine/cpu.h>
#include <machine/pcb.h>
#ifdef DDB
#include <ddb/ddb.h>
DB_SHOW_COMMAND(cp15, db_show_cp15)
{
u_int reg;
reg = cp15_midr_get();
db_printf("Cpu ID: 0x%08x\n", reg);
reg = cp15_ctr_get();
db_printf("Current Cache Lvl ID: 0x%08x\n",reg);
reg = cp15_sctlr_get();
db_printf("Ctrl: 0x%08x\n",reg);
reg = cp15_actlr_get();
db_printf("Aux Ctrl: 0x%08x\n",reg);
reg = cp15_id_pfr0_get();
db_printf("Processor Feat 0: 0x%08x\n", reg);
reg = cp15_id_pfr1_get();
db_printf("Processor Feat 1: 0x%08x\n", reg);
reg = cp15_id_dfr0_get();
db_printf("Debug Feat 0: 0x%08x\n", reg);
reg = cp15_id_afr0_get();
db_printf("Auxiliary Feat 0: 0x%08x\n", reg);
reg = cp15_id_mmfr0_get();
db_printf("Memory Model Feat 0: 0x%08x\n", reg);
reg = cp15_id_mmfr1_get();
db_printf("Memory Model Feat 1: 0x%08x\n", reg);
reg = cp15_id_mmfr2_get();
db_printf("Memory Model Feat 2: 0x%08x\n", reg);
reg = cp15_id_mmfr3_get();
db_printf("Memory Model Feat 3: 0x%08x\n", reg);
reg = cp15_ttbr_get();
db_printf("TTB0: 0x%08x\n", reg);
}
DB_SHOW_COMMAND(vtop, db_show_vtop)
{
u_int reg;
if (have_addr) {
cp15_ats1cpr_set(addr);
reg = cp15_par_get();
db_printf("Physical address reg: 0x%08x\n",reg);
} else
db_printf("show vtop <virt_addr>\n");
}
#endif
int
fill_regs(struct thread *td, struct reg *regs)
{
struct trapframe *tf = td->td_frame;
bcopy(&tf->tf_r0, regs->r, sizeof(regs->r));
regs->r_sp = tf->tf_usr_sp;
regs->r_lr = tf->tf_usr_lr;
regs->r_pc = tf->tf_pc;
regs->r_cpsr = tf->tf_spsr;
return (0);
}
int
fill_fpregs(struct thread *td, struct fpreg *regs)
{
#ifdef VFP
struct pcb *pcb;
pcb = td->td_pcb;
if ((pcb->pcb_fpflags & PCB_FP_STARTED) != 0) {
if (td == curthread)
vfp_save_state(td, pcb);
}
KASSERT(pcb->pcb_vfpsaved == &pcb->pcb_vfpstate,
("Called fill_fpregs while the kernel is using the VFP"));
memcpy(regs->fpr_r, pcb->pcb_vfpstate.reg,
sizeof(regs->fpr_r));
regs->fpr_fpscr = pcb->pcb_vfpstate.fpscr;
#else
memset(regs, 0, sizeof(*regs));
#endif
return (0);
}
int
set_regs(struct thread *td, struct reg *regs)
{
struct trapframe *tf = td->td_frame;
bcopy(regs->r, &tf->tf_r0, sizeof(regs->r));
tf->tf_usr_sp = regs->r_sp;
tf->tf_usr_lr = regs->r_lr;
tf->tf_pc = regs->r_pc;
tf->tf_spsr &= ~PSR_FLAGS;
tf->tf_spsr |= regs->r_cpsr & PSR_FLAGS;
return (0);
}
int
set_fpregs(struct thread *td, struct fpreg *regs)
{
#ifdef VFP
struct pcb *pcb;
pcb = td->td_pcb;
KASSERT(pcb->pcb_vfpsaved == &pcb->pcb_vfpstate,
("Called set_fpregs while the kernel is using the VFP"));
memcpy(pcb->pcb_vfpstate.reg, regs->fpr_r, sizeof(regs->fpr_r));
pcb->pcb_vfpstate.fpscr = regs->fpr_fpscr;
#endif
return (0);
}
int
fill_dbregs(struct thread *td, struct dbreg *regs)
{
bzero(regs, sizeof(*regs));
return (0);
}
int
set_dbregs(struct thread *td, struct dbreg *regs)
{
return (0);
}