Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __M68K_ENTRY_H |
| 2 | #define __M68K_ENTRY_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <asm/setup.h> |
| 5 | #include <asm/page.h> |
Greg Ungerer | cddafa3 | 2010-09-13 14:10:45 +1000 | [diff] [blame] | 6 | #ifdef __ASSEMBLY__ |
| 7 | #include <asm/thread_info.h> |
| 8 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
| 10 | /* |
| 11 | * Stack layout in 'ret_from_exception': |
| 12 | * |
| 13 | * This allows access to the syscall arguments in registers d1-d5 |
| 14 | * |
| 15 | * 0(sp) - d1 |
| 16 | * 4(sp) - d2 |
| 17 | * 8(sp) - d3 |
| 18 | * C(sp) - d4 |
| 19 | * 10(sp) - d5 |
| 20 | * 14(sp) - a0 |
| 21 | * 18(sp) - a1 |
| 22 | * 1C(sp) - a2 |
| 23 | * 20(sp) - d0 |
| 24 | * 24(sp) - orig_d0 |
| 25 | * 28(sp) - stack adjustment |
| 26 | * 2C(sp) - sr |
| 27 | * 2E(sp) - pc |
| 28 | * 32(sp) - format & vector |
| 29 | */ |
| 30 | |
| 31 | /* |
| 32 | * 97/05/14 Andreas: Register %a2 is now set to the current task throughout |
| 33 | * the whole kernel. |
| 34 | */ |
| 35 | |
| 36 | /* the following macro is used when enabling interrupts */ |
Adrian Bunk | 29c8a24 | 2008-10-13 21:58:59 +0200 | [diff] [blame] | 37 | #if defined(MACH_ATARI_ONLY) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | /* block out HSYNC on the atari */ |
| 39 | #define ALLOWINT (~0x400) |
| 40 | #define MAX_NOINT_IPL 3 |
| 41 | #else |
| 42 | /* portable version */ |
| 43 | #define ALLOWINT (~0x700) |
| 44 | #define MAX_NOINT_IPL 0 |
| 45 | #endif /* machine compilation types */ |
| 46 | |
| 47 | #ifdef __ASSEMBLY__ |
| 48 | |
| 49 | #define curptr a2 |
| 50 | |
| 51 | LFLUSH_I_AND_D = 0x00000808 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | #define SAVE_ALL_INT save_all_int |
| 54 | #define SAVE_ALL_SYS save_all_sys |
| 55 | #define RESTORE_ALL restore_all |
| 56 | /* |
| 57 | * This defines the normal kernel pt-regs layout. |
| 58 | * |
| 59 | * regs a3-a6 and d6-d7 are preserved by C code |
| 60 | * the kernel doesn't mess with usp unless it needs to |
| 61 | */ |
| 62 | |
| 63 | /* |
| 64 | * a -1 in the orig_d0 field signifies |
| 65 | * that the stack frame is NOT for syscall |
| 66 | */ |
| 67 | .macro save_all_int |
| 68 | clrl %sp@- | stk_adj |
| 69 | pea -1:w | orig d0 |
| 70 | movel %d0,%sp@- | d0 |
| 71 | moveml %d1-%d5/%a0-%a1/%curptr,%sp@- |
| 72 | .endm |
| 73 | |
| 74 | .macro save_all_sys |
| 75 | clrl %sp@- | stk_adj |
| 76 | movel %d0,%sp@- | orig d0 |
| 77 | movel %d0,%sp@- | d0 |
| 78 | moveml %d1-%d5/%a0-%a1/%curptr,%sp@- |
| 79 | .endm |
| 80 | |
| 81 | .macro restore_all |
| 82 | moveml %sp@+,%a0-%a1/%curptr/%d1-%d5 |
| 83 | movel %sp@+,%d0 |
| 84 | addql #4,%sp | orig d0 |
| 85 | addl %sp@+,%sp | stk adj |
| 86 | rte |
| 87 | .endm |
| 88 | |
| 89 | #define SWITCH_STACK_SIZE (6*4+4) /* includes return address */ |
| 90 | |
| 91 | #define SAVE_SWITCH_STACK save_switch_stack |
| 92 | #define RESTORE_SWITCH_STACK restore_switch_stack |
| 93 | #define GET_CURRENT(tmp) get_current tmp |
| 94 | |
| 95 | .macro save_switch_stack |
| 96 | moveml %a3-%a6/%d6-%d7,%sp@- |
| 97 | .endm |
| 98 | |
| 99 | .macro restore_switch_stack |
| 100 | moveml %sp@+,%a3-%a6/%d6-%d7 |
| 101 | .endm |
| 102 | |
| 103 | .macro get_current reg=%d0 |
| 104 | movel %sp,\reg |
| 105 | andw #-THREAD_SIZE,\reg |
| 106 | movel \reg,%curptr |
| 107 | movel %curptr@,%curptr |
| 108 | .endm |
| 109 | |
| 110 | #else /* C source */ |
| 111 | |
| 112 | #define STR(X) STR1(X) |
| 113 | #define STR1(X) #X |
| 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | #define SAVE_ALL_INT \ |
| 116 | "clrl %%sp@-;" /* stk_adj */ \ |
| 117 | "pea -1:w;" /* orig d0 = -1 */ \ |
| 118 | "movel %%d0,%%sp@-;" /* d0 */ \ |
| 119 | "moveml %%d1-%%d5/%%a0-%%a2,%%sp@-" |
| 120 | #define GET_CURRENT(tmp) \ |
| 121 | "movel %%sp,"#tmp"\n\t" \ |
| 122 | "andw #-"STR(THREAD_SIZE)","#tmp"\n\t" \ |
| 123 | "movel "#tmp",%%a2\n\t" \ |
| 124 | "movel %%a2@,%%a2" |
| 125 | |
| 126 | #endif |
| 127 | |
| 128 | #endif /* __M68K_ENTRY_H */ |