18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ENTRY_H
38c2ecf20Sopenharmony_ci#define _ENTRY_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/kernel.h>
68c2ecf20Sopenharmony_ci#include <linux/types.h>
78c2ecf20Sopenharmony_ci#include <linux/init.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci/* irq */
108c2ecf20Sopenharmony_civoid handler_irq(int irq, struct pt_regs *regs);
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifdef CONFIG_SPARC32
138c2ecf20Sopenharmony_ci/* traps */
148c2ecf20Sopenharmony_civoid do_hw_interrupt(struct pt_regs *regs, unsigned long type);
158c2ecf20Sopenharmony_civoid do_illegal_instruction(struct pt_regs *regs, unsigned long pc,
168c2ecf20Sopenharmony_ci                            unsigned long npc, unsigned long psr);
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_civoid do_priv_instruction(struct pt_regs *regs, unsigned long pc,
198c2ecf20Sopenharmony_ci                         unsigned long npc, unsigned long psr);
208c2ecf20Sopenharmony_civoid do_memaccess_unaligned(struct pt_regs *regs, unsigned long pc,
218c2ecf20Sopenharmony_ci                            unsigned long npc, unsigned long psr);
228c2ecf20Sopenharmony_civoid do_fpd_trap(struct pt_regs *regs, unsigned long pc,
238c2ecf20Sopenharmony_ci                 unsigned long npc, unsigned long psr);
248c2ecf20Sopenharmony_civoid do_fpe_trap(struct pt_regs *regs, unsigned long pc,
258c2ecf20Sopenharmony_ci                 unsigned long npc, unsigned long psr);
268c2ecf20Sopenharmony_civoid handle_tag_overflow(struct pt_regs *regs, unsigned long pc,
278c2ecf20Sopenharmony_ci                         unsigned long npc, unsigned long psr);
288c2ecf20Sopenharmony_civoid handle_watchpoint(struct pt_regs *regs, unsigned long pc,
298c2ecf20Sopenharmony_ci                       unsigned long npc, unsigned long psr);
308c2ecf20Sopenharmony_civoid handle_reg_access(struct pt_regs *regs, unsigned long pc,
318c2ecf20Sopenharmony_ci                       unsigned long npc, unsigned long psr);
328c2ecf20Sopenharmony_civoid handle_cp_disabled(struct pt_regs *regs, unsigned long pc,
338c2ecf20Sopenharmony_ci                        unsigned long npc, unsigned long psr);
348c2ecf20Sopenharmony_civoid handle_cp_exception(struct pt_regs *regs, unsigned long pc,
358c2ecf20Sopenharmony_ci                         unsigned long npc, unsigned long psr);
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* entry.S */
408c2ecf20Sopenharmony_civoid fpsave(unsigned long *fpregs, unsigned long *fsr,
418c2ecf20Sopenharmony_ci            void *fpqueue, unsigned long *fpqdepth);
428c2ecf20Sopenharmony_civoid fpload(unsigned long *fpregs, unsigned long *fsr);
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#else /* CONFIG_SPARC32 */
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#include <asm/trap_block.h>
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cistruct popc_3insn_patch_entry {
498c2ecf20Sopenharmony_ci	unsigned int	addr;
508c2ecf20Sopenharmony_ci	unsigned int	insns[3];
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ciextern struct popc_3insn_patch_entry __popc_3insn_patch,
538c2ecf20Sopenharmony_ci	__popc_3insn_patch_end;
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_cistruct popc_6insn_patch_entry {
568c2ecf20Sopenharmony_ci	unsigned int	addr;
578c2ecf20Sopenharmony_ci	unsigned int	insns[6];
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ciextern struct popc_6insn_patch_entry __popc_6insn_patch,
608c2ecf20Sopenharmony_ci	__popc_6insn_patch_end;
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistruct pause_patch_entry {
638c2ecf20Sopenharmony_ci	unsigned int	addr;
648c2ecf20Sopenharmony_ci	unsigned int	insns[3];
658c2ecf20Sopenharmony_ci};
668c2ecf20Sopenharmony_ciextern struct pause_patch_entry __pause_3insn_patch,
678c2ecf20Sopenharmony_ci	__pause_3insn_patch_end;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_civoid sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *,
708c2ecf20Sopenharmony_ci			     struct sun4v_1insn_patch_entry *);
718c2ecf20Sopenharmony_civoid sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *,
728c2ecf20Sopenharmony_ci			     struct sun4v_2insn_patch_entry *);
738c2ecf20Sopenharmony_civoid sun_m7_patch_2insn_range(struct sun4v_2insn_patch_entry *,
748c2ecf20Sopenharmony_ci			     struct sun4v_2insn_patch_entry *);
758c2ecf20Sopenharmony_ciextern unsigned int dcache_parity_tl1_occurred;
768c2ecf20Sopenharmony_ciextern unsigned int icache_parity_tl1_occurred;
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciasmlinkage void sparc_breakpoint(struct pt_regs *regs);
798c2ecf20Sopenharmony_civoid timer_interrupt(int irq, struct pt_regs *regs);
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_civoid do_notify_resume(struct pt_regs *regs,
828c2ecf20Sopenharmony_ci		      unsigned long orig_i0,
838c2ecf20Sopenharmony_ci		      unsigned long thread_info_flags);
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ciasmlinkage int syscall_trace_enter(struct pt_regs *regs);
868c2ecf20Sopenharmony_ciasmlinkage void syscall_trace_leave(struct pt_regs *regs);
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_civoid bad_trap_tl1(struct pt_regs *regs, long lvl);
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_civoid do_fpieee(struct pt_regs *regs);
918c2ecf20Sopenharmony_civoid do_fpother(struct pt_regs *regs);
928c2ecf20Sopenharmony_civoid do_tof(struct pt_regs *regs);
938c2ecf20Sopenharmony_civoid do_div0(struct pt_regs *regs);
948c2ecf20Sopenharmony_civoid do_illegal_instruction(struct pt_regs *regs);
958c2ecf20Sopenharmony_civoid mem_address_unaligned(struct pt_regs *regs,
968c2ecf20Sopenharmony_ci			   unsigned long sfar,
978c2ecf20Sopenharmony_ci			   unsigned long sfsr);
988c2ecf20Sopenharmony_civoid sun4v_do_mna(struct pt_regs *regs,
998c2ecf20Sopenharmony_ci		  unsigned long addr,
1008c2ecf20Sopenharmony_ci		  unsigned long type_ctx);
1018c2ecf20Sopenharmony_civoid do_privop(struct pt_regs *regs);
1028c2ecf20Sopenharmony_civoid do_privact(struct pt_regs *regs);
1038c2ecf20Sopenharmony_civoid do_cee(struct pt_regs *regs);
1048c2ecf20Sopenharmony_civoid do_div0_tl1(struct pt_regs *regs);
1058c2ecf20Sopenharmony_civoid do_fpieee_tl1(struct pt_regs *regs);
1068c2ecf20Sopenharmony_civoid do_fpother_tl1(struct pt_regs *regs);
1078c2ecf20Sopenharmony_civoid do_ill_tl1(struct pt_regs *regs);
1088c2ecf20Sopenharmony_civoid do_irq_tl1(struct pt_regs *regs);
1098c2ecf20Sopenharmony_civoid do_lddfmna_tl1(struct pt_regs *regs);
1108c2ecf20Sopenharmony_civoid do_stdfmna_tl1(struct pt_regs *regs);
1118c2ecf20Sopenharmony_civoid do_paw(struct pt_regs *regs);
1128c2ecf20Sopenharmony_civoid do_paw_tl1(struct pt_regs *regs);
1138c2ecf20Sopenharmony_civoid do_vaw(struct pt_regs *regs);
1148c2ecf20Sopenharmony_civoid do_vaw_tl1(struct pt_regs *regs);
1158c2ecf20Sopenharmony_civoid do_tof_tl1(struct pt_regs *regs);
1168c2ecf20Sopenharmony_civoid do_getpsr(struct pt_regs *regs);
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_civoid spitfire_insn_access_exception(struct pt_regs *regs,
1198c2ecf20Sopenharmony_ci				    unsigned long sfsr,
1208c2ecf20Sopenharmony_ci				    unsigned long sfar);
1218c2ecf20Sopenharmony_civoid spitfire_insn_access_exception_tl1(struct pt_regs *regs,
1228c2ecf20Sopenharmony_ci				        unsigned long sfsr,
1238c2ecf20Sopenharmony_ci				        unsigned long sfar);
1248c2ecf20Sopenharmony_civoid spitfire_data_access_exception(struct pt_regs *regs,
1258c2ecf20Sopenharmony_ci				    unsigned long sfsr,
1268c2ecf20Sopenharmony_ci				    unsigned long sfar);
1278c2ecf20Sopenharmony_civoid spitfire_data_access_exception_tl1(struct pt_regs *regs,
1288c2ecf20Sopenharmony_ci				        unsigned long sfsr,
1298c2ecf20Sopenharmony_ci				        unsigned long sfar);
1308c2ecf20Sopenharmony_civoid spitfire_access_error(struct pt_regs *regs,
1318c2ecf20Sopenharmony_ci			   unsigned long status_encoded,
1328c2ecf20Sopenharmony_ci			   unsigned long afar);
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_civoid cheetah_fecc_handler(struct pt_regs *regs,
1358c2ecf20Sopenharmony_ci			  unsigned long afsr,
1368c2ecf20Sopenharmony_ci			  unsigned long afar);
1378c2ecf20Sopenharmony_civoid cheetah_cee_handler(struct pt_regs *regs,
1388c2ecf20Sopenharmony_ci			 unsigned long afsr,
1398c2ecf20Sopenharmony_ci			 unsigned long afar);
1408c2ecf20Sopenharmony_civoid cheetah_deferred_handler(struct pt_regs *regs,
1418c2ecf20Sopenharmony_ci			      unsigned long afsr,
1428c2ecf20Sopenharmony_ci			      unsigned long afar);
1438c2ecf20Sopenharmony_civoid cheetah_plus_parity_error(int type, struct pt_regs *regs);
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_civoid sun4v_insn_access_exception(struct pt_regs *regs,
1468c2ecf20Sopenharmony_ci				 unsigned long addr,
1478c2ecf20Sopenharmony_ci				 unsigned long type_ctx);
1488c2ecf20Sopenharmony_civoid sun4v_insn_access_exception_tl1(struct pt_regs *regs,
1498c2ecf20Sopenharmony_ci				     unsigned long addr,
1508c2ecf20Sopenharmony_ci				     unsigned long type_ctx);
1518c2ecf20Sopenharmony_civoid sun4v_data_access_exception(struct pt_regs *regs,
1528c2ecf20Sopenharmony_ci				 unsigned long addr,
1538c2ecf20Sopenharmony_ci				 unsigned long type_ctx);
1548c2ecf20Sopenharmony_civoid sun4v_data_access_exception_tl1(struct pt_regs *regs,
1558c2ecf20Sopenharmony_ci				     unsigned long addr,
1568c2ecf20Sopenharmony_ci				     unsigned long type_ctx);
1578c2ecf20Sopenharmony_civoid sun4v_resum_error(struct pt_regs *regs,
1588c2ecf20Sopenharmony_ci		       unsigned long offset);
1598c2ecf20Sopenharmony_civoid sun4v_resum_overflow(struct pt_regs *regs);
1608c2ecf20Sopenharmony_civoid sun4v_nonresum_error(struct pt_regs *regs,
1618c2ecf20Sopenharmony_ci			  unsigned long offset);
1628c2ecf20Sopenharmony_civoid sun4v_nonresum_overflow(struct pt_regs *regs);
1638c2ecf20Sopenharmony_civoid sun4v_mem_corrupt_detect_precise(struct pt_regs *regs,
1648c2ecf20Sopenharmony_ci				      unsigned long addr,
1658c2ecf20Sopenharmony_ci				      unsigned long context);
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ciextern unsigned long sun4v_err_itlb_vaddr;
1688c2ecf20Sopenharmony_ciextern unsigned long sun4v_err_itlb_ctx;
1698c2ecf20Sopenharmony_ciextern unsigned long sun4v_err_itlb_pte;
1708c2ecf20Sopenharmony_ciextern unsigned long sun4v_err_itlb_error;
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_civoid sun4v_itlb_error_report(struct pt_regs *regs, int tl);
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ciextern unsigned long sun4v_err_dtlb_vaddr;
1758c2ecf20Sopenharmony_ciextern unsigned long sun4v_err_dtlb_ctx;
1768c2ecf20Sopenharmony_ciextern unsigned long sun4v_err_dtlb_pte;
1778c2ecf20Sopenharmony_ciextern unsigned long sun4v_err_dtlb_error;
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_civoid sun4v_dtlb_error_report(struct pt_regs *regs, int tl);
1808c2ecf20Sopenharmony_civoid hypervisor_tlbop_error(unsigned long err,
1818c2ecf20Sopenharmony_ci			    unsigned long op);
1828c2ecf20Sopenharmony_civoid hypervisor_tlbop_error_xcall(unsigned long err,
1838c2ecf20Sopenharmony_ci				  unsigned long op);
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci/* WARNING: The error trap handlers in assembly know the precise
1868c2ecf20Sopenharmony_ci *	    layout of the following structure.
1878c2ecf20Sopenharmony_ci *
1888c2ecf20Sopenharmony_ci * C-level handlers in traps.c use this information to log the
1898c2ecf20Sopenharmony_ci * error and then determine how to recover (if possible).
1908c2ecf20Sopenharmony_ci */
1918c2ecf20Sopenharmony_cistruct cheetah_err_info {
1928c2ecf20Sopenharmony_ci/*0x00*/u64 afsr;
1938c2ecf20Sopenharmony_ci/*0x08*/u64 afar;
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci	/* D-cache state */
1968c2ecf20Sopenharmony_ci/*0x10*/u64 dcache_data[4];	/* The actual data	*/
1978c2ecf20Sopenharmony_ci/*0x30*/u64 dcache_index;	/* D-cache index	*/
1988c2ecf20Sopenharmony_ci/*0x38*/u64 dcache_tag;		/* D-cache tag/valid	*/
1998c2ecf20Sopenharmony_ci/*0x40*/u64 dcache_utag;	/* D-cache microtag	*/
2008c2ecf20Sopenharmony_ci/*0x48*/u64 dcache_stag;	/* D-cache snooptag	*/
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci	/* I-cache state */
2038c2ecf20Sopenharmony_ci/*0x50*/u64 icache_data[8];	/* The actual insns + predecode	*/
2048c2ecf20Sopenharmony_ci/*0x90*/u64 icache_index;	/* I-cache index	*/
2058c2ecf20Sopenharmony_ci/*0x98*/u64 icache_tag;		/* I-cache phys tag	*/
2068c2ecf20Sopenharmony_ci/*0xa0*/u64 icache_utag;	/* I-cache microtag	*/
2078c2ecf20Sopenharmony_ci/*0xa8*/u64 icache_stag;	/* I-cache snooptag	*/
2088c2ecf20Sopenharmony_ci/*0xb0*/u64 icache_upper;	/* I-cache upper-tag	*/
2098c2ecf20Sopenharmony_ci/*0xb8*/u64 icache_lower;	/* I-cache lower-tag	*/
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci	/* E-cache state */
2128c2ecf20Sopenharmony_ci/*0xc0*/u64 ecache_data[4];	/* 32 bytes from staging registers */
2138c2ecf20Sopenharmony_ci/*0xe0*/u64 ecache_index;	/* E-cache index	*/
2148c2ecf20Sopenharmony_ci/*0xe8*/u64 ecache_tag;		/* E-cache tag/state	*/
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci/*0xf0*/u64 __pad[32 - 30];
2178c2ecf20Sopenharmony_ci};
2188c2ecf20Sopenharmony_ci#define CHAFSR_INVALID		((u64)-1L)
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci/* This is allocated at boot time based upon the largest hardware
2218c2ecf20Sopenharmony_ci * cpu ID in the system.  We allocate two entries per cpu, one for
2228c2ecf20Sopenharmony_ci * TL==0 logging and one for TL >= 1 logging.
2238c2ecf20Sopenharmony_ci */
2248c2ecf20Sopenharmony_ciextern struct cheetah_err_info *cheetah_error_log;
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci/* UPA nodes send interrupt packet to UltraSparc with first data reg
2278c2ecf20Sopenharmony_ci * value low 5 (7 on Starfire) bits holding the IRQ identifier being
2288c2ecf20Sopenharmony_ci * delivered.  We must translate this into a non-vector IRQ so we can
2298c2ecf20Sopenharmony_ci * set the softint on this cpu.
2308c2ecf20Sopenharmony_ci *
2318c2ecf20Sopenharmony_ci * To make processing these packets efficient and race free we use
2328c2ecf20Sopenharmony_ci * an array of irq buckets below.  The interrupt vector handler in
2338c2ecf20Sopenharmony_ci * entry.S feeds incoming packets into per-cpu pil-indexed lists.
2348c2ecf20Sopenharmony_ci *
2358c2ecf20Sopenharmony_ci * If you make changes to ino_bucket, please update hand coded assembler
2368c2ecf20Sopenharmony_ci * of the vectored interrupt trap handler(s) in entry.S and sun4v_ivec.S
2378c2ecf20Sopenharmony_ci */
2388c2ecf20Sopenharmony_cistruct ino_bucket {
2398c2ecf20Sopenharmony_ci/*0x00*/unsigned long __irq_chain_pa;
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci	/* Interrupt number assigned to this INO.  */
2428c2ecf20Sopenharmony_ci/*0x08*/unsigned int __irq;
2438c2ecf20Sopenharmony_ci/*0x0c*/unsigned int __pad;
2448c2ecf20Sopenharmony_ci};
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ciextern struct ino_bucket *ivector_table;
2478c2ecf20Sopenharmony_ciextern unsigned long ivector_table_pa;
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_civoid init_irqwork_curcpu(void);
2508c2ecf20Sopenharmony_civoid sun4v_register_mondo_queues(int this_cpu);
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci#endif /* CONFIG_SPARC32 */
2538c2ecf20Sopenharmony_ci#endif /* _ENTRY_H */
254