2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-01-09 17:34:14 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1994 - 1999, 2000, 01, 06 Ralf Baechle
|
|
|
|
* Copyright (C) 1995, 1996 Paul M. Antoine
|
|
|
|
* Copyright (C) 1998 Ulf Carlsson
|
|
|
|
* Copyright (C) 1999 Silicon Graphics, Inc.
|
|
|
|
* Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
|
|
|
|
* Copyright (C) 2002, 2003, 2004, 2005, 2007 Maciej W. Rozycki
|
|
|
|
* Copyright (C) 2000, 2001, 2012 MIPS Technologies, Inc. All rights reserved.
|
|
|
|
* Copyright (C) 2014, Imagination Technologies Ltd.
|
|
|
|
*/
|
|
|
|
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2020-05-10 17:40:06 +00:00
|
|
|
#include <asm/ptrace.h>
|
2023-10-12 23:03:58 +00:00
|
|
|
#include <config.h>
|
2019-11-14 19:57:39 +00:00
|
|
|
#include <cpu_func.h>
|
2019-12-28 17:45:07 +00:00
|
|
|
#include <hang.h>
|
2019-11-14 19:57:48 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2016-01-09 17:34:14 +00:00
|
|
|
#include <asm/mipsregs.h>
|
|
|
|
#include <asm/addrspace.h>
|
|
|
|
#include <asm/system.h>
|
2023-10-12 23:03:58 +00:00
|
|
|
#include <asm/u-boot.h>
|
2016-01-09 17:34:14 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2020-04-21 07:28:25 +00:00
|
|
|
static unsigned long saved_ebase;
|
|
|
|
|
2016-01-09 17:34:14 +00:00
|
|
|
static void show_regs(const struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
const int field = 2 * sizeof(unsigned long);
|
|
|
|
unsigned int cause = regs->cp0_cause;
|
|
|
|
unsigned int exccode;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Saved main processor registers
|
|
|
|
*/
|
|
|
|
for (i = 0; i < 32; ) {
|
|
|
|
if ((i % 4) == 0)
|
|
|
|
printf("$%2d :", i);
|
|
|
|
if (i == 0)
|
|
|
|
printf(" %0*lx", field, 0UL);
|
|
|
|
else if (i == 26 || i == 27)
|
|
|
|
printf(" %*s", field, "");
|
|
|
|
else
|
|
|
|
printf(" %0*lx", field, regs->regs[i]);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
if ((i % 4) == 0)
|
|
|
|
puts("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Hi : %0*lx\n", field, regs->hi);
|
|
|
|
printf("Lo : %0*lx\n", field, regs->lo);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Saved cp0 registers
|
|
|
|
*/
|
|
|
|
printf("epc : %0*lx (text %0*lx)\n", field, regs->cp0_epc,
|
|
|
|
field, regs->cp0_epc - gd->reloc_off);
|
|
|
|
printf("ra : %0*lx (text %0*lx)\n", field, regs->regs[31],
|
|
|
|
field, regs->regs[31] - gd->reloc_off);
|
|
|
|
|
|
|
|
printf("Status: %08x\n", (uint32_t) regs->cp0_status);
|
|
|
|
|
|
|
|
exccode = (cause & CAUSEF_EXCCODE) >> CAUSEB_EXCCODE;
|
|
|
|
printf("Cause : %08x (ExcCode %02x)\n", cause, exccode);
|
|
|
|
|
|
|
|
if (1 <= exccode && exccode <= 5)
|
|
|
|
printf("BadVA : %0*lx\n", field, regs->cp0_badvaddr);
|
|
|
|
|
|
|
|
printf("PrId : %08x\n", read_c0_prid());
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_reserved(const struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
puts("\nOoops:\n");
|
|
|
|
show_regs(regs);
|
|
|
|
hang();
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_ejtag_debug(const struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
const int field = 2 * sizeof(unsigned long);
|
|
|
|
unsigned long depc;
|
|
|
|
unsigned int debug;
|
|
|
|
|
|
|
|
depc = read_c0_depc();
|
|
|
|
debug = read_c0_debug();
|
|
|
|
|
|
|
|
printf("SDBBP EJTAG debug exception: c0_depc = %0*lx, DEBUG = %08x\n",
|
|
|
|
field, depc, debug);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_handler(unsigned long offset, void *addr, unsigned long size)
|
|
|
|
{
|
|
|
|
unsigned long ebase = gd->irq_sp;
|
|
|
|
|
|
|
|
memcpy((void *)(ebase + offset), addr, size);
|
|
|
|
flush_cache(ebase + offset, size);
|
|
|
|
}
|
|
|
|
|
2020-11-28 08:43:18 +00:00
|
|
|
static void trap_init(ulong reloc_addr)
|
2016-01-09 17:34:14 +00:00
|
|
|
{
|
|
|
|
unsigned long ebase = gd->irq_sp;
|
|
|
|
|
|
|
|
set_handler(0x180, &except_vec3_generic, 0x80);
|
|
|
|
set_handler(0x280, &except_vec_ejtag_debug, 0x80);
|
|
|
|
|
2020-04-21 07:28:25 +00:00
|
|
|
saved_ebase = read_c0_ebase() & 0xfffff000;
|
|
|
|
|
2020-05-14 09:59:06 +00:00
|
|
|
/* Set WG bit on Octeon to enable writing to bits 63:30 */
|
|
|
|
if (IS_ENABLED(CONFIG_ARCH_OCTEON))
|
2020-07-11 23:46:18 +00:00
|
|
|
ebase |= MIPS_EBASE_WG;
|
2020-05-14 09:59:06 +00:00
|
|
|
|
2016-01-09 17:34:14 +00:00
|
|
|
write_c0_ebase(ebase);
|
|
|
|
clear_c0_status(ST0_BEV);
|
|
|
|
execution_hazard_barrier();
|
|
|
|
}
|
2020-04-21 07:28:25 +00:00
|
|
|
|
|
|
|
void trap_restore(void)
|
|
|
|
{
|
|
|
|
set_c0_status(ST0_BEV);
|
|
|
|
execution_hazard_barrier();
|
|
|
|
|
|
|
|
#ifdef CONFIG_OVERRIDE_EXCEPTION_VECTOR_BASE
|
|
|
|
write_c0_ebase(CONFIG_NEW_EXCEPTION_VECTOR_BASE & 0xfffff000);
|
|
|
|
#else
|
|
|
|
write_c0_ebase(saved_ebase);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
clear_c0_status(ST0_BEV);
|
|
|
|
execution_hazard_barrier();
|
|
|
|
}
|
2020-11-28 08:43:18 +00:00
|
|
|
|
|
|
|
int arch_initr_trap(void)
|
|
|
|
{
|
2022-11-16 18:10:37 +00:00
|
|
|
trap_init(CFG_SYS_SDRAM_BASE);
|
2020-11-28 08:43:18 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|