1/* 2 * Copyright 2003, Travis Geiselbrecht. All rights reserved. 3 * Distributed under the terms of the NewOS License. 4 */ 5 6 7#include <arch/m68k/arch_cpu.h> 8 9#include <asm_defs.h> 10 11.text 12 13// ToDo: fixme -- platform dependant ? 14FUNCTION(reboot): 15 reset 16 rts 17FUNCTION_END(reboot) 18 19 20/* void arch_int_enable_interrupts(void) */ 21FUNCTION(arch_int_enable_interrupts): 22 andi #0xf8ff,%sr 23 rts 24FUNCTION_END(arch_int_enable_interrupts) 25 26 27/* int arch_int_disable_interrupts(void) 28 */ 29FUNCTION(arch_int_disable_interrupts): 30 clr.l %d0 31 move %sr,%d0 32 move.l %d0,%d1 33 ori.w #0x0700,%d1 34 move %d1,%sr 35 // return value: previous IPM 36 lsr.l #8,%d0 37 andi.l #7,%d0 38 rts 39FUNCTION_END(arch_int_disable_interrupts) 40 41 42/* void arch_int_restore_interrupts(int oldState) 43 */ 44FUNCTION(arch_int_restore_interrupts): 45 move.l (4,%a7),%d0 46 // make sure we only have IPM bits 47 andi.w #7,%d0 48 lsl.w #8,%d0 49 move %sr,%d1 50 andi.w #0xf8ff,%d1 51 or.w %d0,%d1 52 move %d1,%sr 53 rts 54FUNCTION_END(arch_int_restore_interrupts) 55 56 57/* bool arch_int_are_interrupts_enabled(void) */ 58FUNCTION(arch_int_are_interrupts_enabled): 59 clr.l %d0 60 move %sr,%d1 61 andi.w #0x0700,%d1 62 bne arch_int_are_interrupts_enabled_no 63 moveq.l #1,%d0 64arch_int_are_interrupts_enabled_no: 65 rts 66FUNCTION_END(arch_int_are_interrupts_enabled) 67 68 69// ToDo: fixme 70FUNCTION(dbg_save_registers): 71#warning M68K: implement dbx_save_registers! 72 rts 73FUNCTION_END(dbg_save_registers) 74 75 76/* long long get_time_base(void) */ 77FUNCTION(get_time_base): 78#warning M68K: implement get_time_base! 79 clr.l %d0 80 clr.l %d1 81 //passed through a0 or d0:d1 ? 82 rts 83FUNCTION_END(get_time_base) 84 85 86#warning M68K: FIX m68k_context_switch 87// XXX:sync with arch_thread.c:arch_thread_init_kthread_stack 88// void m68k_context_switch(addr_t *old_sp, addr_t new_sp); 89FUNCTION(m68k_context_switch): 90 // save fp ? 91 //move.w %sr,-(%sp) 92 movem.l %d0-%d7/%a0-%a7,-(%sp) 93 fmovem %fp0-%fp7,-(%sp) 94 fsave -(%sp) 95#warning M68K: use fixed size for fsave 96 97 // XXX 98 99 frestore (%sp)+ 100 fmovem (%sp)+,%fp0-%fp7 101 movem.l (%sp)+,%d0-%d7/%a0-%a7 102 //move.w (%sp)+,%sr 103 104 rts 105FUNCTION_END(m68k_context_switch) 106 107 108// m68k_kernel_thread_root(): parameters in r13-r15, the functions to call 109// (in that order). The function is used when spawing threads. It usually calls 110// an initialization function, the actual thread function, and a function that 111// destroys the thread. 112FUNCTION(m68k_kernel_thread_root): 113#warning M68K: check 114 move.l 4(%sp),%a0 115 jsr (%a0) 116 move.l 8(%sp),%a0 117 jsr (%a0) 118 move.l 12(%sp),%a0 119 jsr (%a0) 120 121 // We should never get here. If we do, it's time to enter the kernel 122 // debugger (without a message at the moment). 123 clr.l -(%sp) 124 jmp kernel_debugger 125FUNCTION_END(m68k_kernel_thread_root) 126 127