Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 1 | #ifndef __SPARC_HEAD_H |
| 2 | #define __SPARC_HEAD_H |
| 3 | |
| 4 | #define KERNBASE 0xf0000000 /* First address the kernel will eventually be */ |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 5 | |
| 6 | #define WRITE_PAUSE nop; nop; nop; /* Have to do this after %wim/%psr chg */ |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 7 | |
| 8 | /* Here are some trap goodies */ |
| 9 | |
| 10 | /* Generic trap entry. */ |
| 11 | #define TRAP_ENTRY(type, label) \ |
| 12 | rd %psr, %l0; b label; rd %wim, %l3; nop; |
| 13 | |
Sam Ravnborg | 306f123 | 2012-05-11 11:35:06 +0000 | [diff] [blame] | 14 | /* Data/text faults */ |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 15 | #define SRMMU_TFAULT rd %psr, %l0; rd %wim, %l3; b srmmu_fault; mov 1, %l7; |
| 16 | #define SRMMU_DFAULT rd %psr, %l0; rd %wim, %l3; b srmmu_fault; mov 0, %l7; |
| 17 | |
| 18 | /* This is for traps we should NEVER get. */ |
| 19 | #define BAD_TRAP(num) \ |
| 20 | rd %psr, %l0; mov num, %l7; b bad_trap_handler; rd %wim, %l3; |
| 21 | |
| 22 | /* This is for traps when we want just skip the instruction which caused it */ |
| 23 | #define SKIP_TRAP(type, name) \ |
| 24 | jmpl %l2, %g0; rett %l2 + 4; nop; nop; |
| 25 | |
| 26 | /* Notice that for the system calls we pull a trick. We load up a |
| 27 | * different pointer to the system call vector table in %l7, but call |
| 28 | * the same generic system call low-level entry point. The trap table |
| 29 | * entry sequences are also HyperSparc pipeline friendly ;-) |
| 30 | */ |
| 31 | |
| 32 | /* Software trap for Linux system calls. */ |
| 33 | #define LINUX_SYSCALL_TRAP \ |
| 34 | sethi %hi(sys_call_table), %l7; \ |
| 35 | or %l7, %lo(sys_call_table), %l7; \ |
| 36 | b linux_sparc_syscall; \ |
| 37 | rd %psr, %l0; |
| 38 | |
| 39 | #define BREAKPOINT_TRAP \ |
| 40 | b breakpoint_trap; \ |
| 41 | rd %psr,%l0; \ |
| 42 | nop; \ |
| 43 | nop; |
| 44 | |
| 45 | #ifdef CONFIG_KGDB |
| 46 | #define KGDB_TRAP(num) \ |
| 47 | b kgdb_trap_low; \ |
| 48 | rd %psr,%l0; \ |
| 49 | nop; \ |
| 50 | nop; |
| 51 | #else |
| 52 | #define KGDB_TRAP(num) \ |
| 53 | BAD_TRAP(num) |
| 54 | #endif |
| 55 | |
| 56 | /* The Get Condition Codes software trap for userland. */ |
| 57 | #define GETCC_TRAP \ |
David S. Miller | 598ec97 | 2013-04-06 17:51:48 -0400 | [diff] [blame] | 58 | b getcc_trap_handler; rd %psr, %l0; nop; nop; |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 59 | |
| 60 | /* The Set Condition Codes software trap for userland. */ |
| 61 | #define SETCC_TRAP \ |
David S. Miller | 598ec97 | 2013-04-06 17:51:48 -0400 | [diff] [blame] | 62 | b setcc_trap_handler; rd %psr, %l0; nop; nop; |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 63 | |
| 64 | /* The Get PSR software trap for userland. */ |
| 65 | #define GETPSR_TRAP \ |
David S. Miller | 598ec97 | 2013-04-06 17:51:48 -0400 | [diff] [blame] | 66 | rd %psr, %i0; jmp %l2; rett %l2 + 4; nop; |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 67 | |
| 68 | /* This is for hard interrupts from level 1-14, 15 is non-maskable (nmi) and |
| 69 | * gets handled with another macro. |
| 70 | */ |
| 71 | #define TRAP_ENTRY_INTERRUPT(int_level) \ |
| 72 | mov int_level, %l7; rd %psr, %l0; b real_irq_entry; rd %wim, %l3; |
| 73 | |
Sam Ravnborg | f5e706a | 2008-07-17 21:55:51 -0700 | [diff] [blame] | 74 | /* Window overflows/underflows are special and we need to try to be as |
| 75 | * efficient as possible here.... |
| 76 | */ |
| 77 | #define WINDOW_SPILL \ |
| 78 | rd %psr, %l0; rd %wim, %l3; b spill_window_entry; andcc %l0, PSR_PS, %g0; |
| 79 | |
| 80 | #define WINDOW_FILL \ |
| 81 | rd %psr, %l0; rd %wim, %l3; b fill_window_entry; andcc %l0, PSR_PS, %g0; |
| 82 | |
| 83 | #endif /* __SPARC_HEAD_H */ |