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