diff --git a/headers/private/kernel/arch/m68k/arch_cpu.h b/headers/private/kernel/arch/m68k/arch_cpu.h index 92fa937bd1..1fa572f20a 100644 --- a/headers/private/kernel/arch/m68k/arch_cpu.h +++ b/headers/private/kernel/arch/m68k/arch_cpu.h @@ -12,65 +12,201 @@ #define PAGE_SIZE 4096 -#warning M68K: check for missing regs/movem -struct iframe { - /* XXX: order depends on movem */ - uint32 d0; - uint32 d1; - uint32 d2; - uint32 d3; - uint32 d4; - uint32 d5; - uint32 d6; - uint32 d7; - uint32 a0; - uint32 a1; - uint32 a2; - uint32 a3; - uint32 a4; - uint32 a5; - uint32 a6; - uint32 a7; - /* 030 ex frame: */ - uint16 sr; /* contains ccr */ - uint32 pc; - uint16 vector; /* [12:15] frame type */ - /* other stuff depending on frame type... do we really need that ? */ +/* 68k has many different possible stack frames, differentiated by a 4 bit number, + * but they also depend on the cpu type. + * cf. mint/sys/arch/check_exc.h + */ + +/* definitions for special status word */ + +// 020 as well +struct mc68030_ssw { + uint16 fc:1; + uint16 fb:1; + uint16 rc:1; + uint16 rb:1; + uint16 :3; + uint16 df:1; + uint16 rm:1; + uint16 rw:1; + uint16 size:2; + uint16 :1; + uint16 as:3; +} _PACKED; + +struct mc68040_ssw { + uint16 cp:1; + uint16 cu:1; + uint16 ct:1; + uint16 cm:1; + uint16 ma:1; + uint16 atc:1; + uint16 lk:1; + uint16 rw:1; + uint16 :1; + uint16 size:2; + uint16 tt:2; + uint16 tm:3; +} _PACKED; + +struct mc68060_fslw { + uint32 :4; + uint32 ma:1; + uint32 :1; + uint32 lk:1; + uint32 rw:2; //XXX ?? + uint32 size:2; + uint32 tt:2; + uint32 tm:2; + uint32 io:1; + uint32 pbe:1; + uint32 sbe:1; + uint32 pta:1; + uint32 ptb:1; + uint32 il:1; + uint32 pf:1; + uint32 sb:1; + uint32 wp:1; + uint32 twe:1; + uint32 re:1; + uint32 we:1; + uint32 ttr:1; + uint32 bpe:1; + uint32 :1; + uint32 see:1; +} _PACKED; + +/* raw exception frames */ + +struct mc680x0_type_0_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; +}; + +struct mc680x0_type_1_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; +}; + +struct mc680x0_type_2_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + addr_t instruction_address; +}; + +struct mc680x0_type_3_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + addr_t effective_address; +}; + +struct mc68040_type_7_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + addr_t effective_address; + struct mc68040_ssw ssw; + // write-back status + uint16 wb3s; + uint16 wb2s; + uint16 wb1s; + addr_t fault_address; + addr_t wb3a; + uint32 wb3d; + addr_t wb2a; + uint32 wb2d; + addr_t wb1a; + uint32 wb1d; // also pd0 + uint32 pd1; + uint32 pd2; + uint32 pd3; +}; + +struct mc680x0_type_9_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + addr_t instruction_address; + uint16 intregs[4]; +}; + +struct mc68030_type_a_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + uint16 intreg1; + struct mc68030_ssw ssw; + uint16 instpipe_c; + uint16 instpipe_b; + addr_t fault_address; + uint16 intregs2[2]; + uint32 dataout; + uint16 intregs3[2]; +}; + +struct mc68030_type_b_frame { + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + uint16 intreg1; + struct mc68030_ssw ssw; + uint16 instpipe_c; + uint16 instpipe_b; + addr_t fault_address; + uint16 intregs2[2]; + uint32 dataout; + uint16 intregs3[4]; + uint32 stbaddr; + uint16 intregs4[2]; + uint32 datain; + uint16 intregs5[3]; + uint16 intinfo; + uint16 intregs6[18]; +}; + +//XXX: add 060 frames + +struct mc680x0_frame { union { struct { - uint32 inst; - } format2 _PACKED; - struct { - uint32 inst; - uint16 intregs[4]; - } format9 _PACKED; - struct { - uint16 intregs[1]; - uint16 ssw; - uint16 instpipe_c; - uint16 instpipe_b; - uint32 faultaddr; - uint16 intregs2[2]; - uint32 dataout; - uint16 intregs3[2]; - } formata _PACKED; - struct { - uint16 intregs[1]; - uint16 ssw; - uint16 instpipe_c; - uint16 instpipe_b; - uint32 faultaddr; - uint16 intregs2[2]; - uint32 dataout; - uint16 intregs3[4]; - uint32 stbaddr; - uint16 intregs4[2]; - uint32 datain; - uint16 intregs5[3]; - uint16 intinfo; - uint16 intregs6[18]; - } formatb _PACKED; + uint16 sr; + addr_t pc; + uint16 type:4; + uint16 vector:12; + }; + struct mc680x0_type_0_frame type_0; + struct mc680x0_type_1_frame type_1; + struct mc680x0_type_2_frame type_2; + struct mc68040_type_7_frame type_7; + struct mc680x0_type_9_frame type_9; + struct mc68030_type_a_frame type_a; + struct mc68030_type_b_frame type_b; + // XXX: add 060 frames }; +}; + +#warning M68K: check for missing regs/movem +struct iframe { + // XXX: fp_frame ? + /* data and address registers */ + // XXX: order depends on movem + uint32 d[8]; + uint32 a[7]; + /* cpu exception frame, including sr, pc, format and vector */ + struct mc680x0_frame cpu; + /* uint32 vector; uint32 srr0; uint32 srr1; diff --git a/headers/private/kernel/arch/m68k/arch_int.h b/headers/private/kernel/arch/m68k/arch_int.h index be7741abf2..d16d5d8522 100644 --- a/headers/private/kernel/arch/m68k/arch_int.h +++ b/headers/private/kernel/arch/m68k/arch_int.h @@ -13,34 +13,4 @@ #define NUM_IO_VECTORS 256 -/* The sprg0 register of each CPU points to the physical address of such - a structure. So it is at hand in the early exception handling code. -*/ -struct m68k_cpu_exception_context { - void *kernel_handle_exception; // exception handler routine in the - // kernel - void *exception_context; // the virtual address of this - // structure - void *kernel_stack; // kernel stack for the current thread - - uint32 scratch[8]; // scratch memory for free use in the - // early exception handling code -}; - -#ifdef __cplusplus -extern "C" { -#endif - - -struct m68k_cpu_exception_context *m68k_get_cpu_exception_context(int cpu); - -void m68k_set_current_cpu_exception_context( - struct m68k_cpu_exception_context *context); - // only called once per CPU - - -#ifdef __cplusplus -} -#endif - #endif /* _KERNEL_ARCH_M68K_INT_H */ diff --git a/src/system/kernel/arch/m68k/arch_int.cpp b/src/system/kernel/arch/m68k/arch_int.cpp index c60755dadb..4d2c3498fe 100644 --- a/src/system/kernel/arch/m68k/arch_int.cpp +++ b/src/system/kernel/arch/m68k/arch_int.cpp @@ -39,10 +39,6 @@ extern int __irqvec_end; extern"C" void m68k_exception_tail(void); -// the exception contexts for all CPUs -static m68k_cpu_exception_context sCPUExceptionContexts[SMP_MAX_CPUS]; - - // An iframe stack used in the early boot process when we don't have // threads yet. struct iframe_stack gBootFrameStack; @@ -82,13 +78,13 @@ print_iframe(struct iframe *frame) { dprintf("iframe at %p:\n", frame); dprintf(" d0 0x%08lx d1 0x%08lx d2 0x%08lx d3 0x%08lx\n", - frame->d0, frame->d1, frame->d2, frame->d3); + frame->d[0], frame->d[1], frame->d[2], frame->d[3]); kprintf(" d4 0x%08lx d5 0x%08lx d6 0x%08lx d7 0x%08lx\n", - frame->d4, frame->d5, frame->d6, frame->d7); + frame->d[4], frame->d[5], frame->d[6], frame->d[7]); kprintf(" a0 0x%08lx a1 0x%08lx a2 0x%08lx a3 0x%08lx\n", - frame->a0, frame->a1, frame->a2, frame->a3); - kprintf(" a4 0x%08lx a5 0x%08lx a6 0x%08lx a7 0x%08lx (sp)\n", - frame->d4, frame->d5, frame->d6, frame->d7); + frame->a[0], frame->a[1], frame->a[2], frame->a[3]); + kprintf(" a4 0x%08lx a5 0x%08lx a6 0x%08lx "/*"a7 0x%08lx (sp)"*/"\n", + frame->a[4], frame->a[5], frame->a[6]/*, frame->a[7]*/); /*kprintf(" pc 0x%08lx ccr 0x%02x\n", frame->pc, frame->ccr);*/