1/* 2** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3** Distributed under the terms of the MIT License. 4*/ 5 6#include <asm_defs.h> 7 8.text 9 10.cpu 68020 11 12/* 13 * Those two probe hardware register for presence, trapping bus errors. 14 * inspired by the Linux version, cf. 15 * http://lxr.linux.no/linux+v2.6.27/arch/m68k/mm/hwtest.c 16 * 17 * though I'm not sure why the tests are on words only. 18 * Some regs are bytes only and the even byte is unmapped... 19 * but probably ignored. 20 */ 21 22/* extern bool m68k_is_hw_register_readable(addr_t address); 23 */ 24FUNCTION(m68k_is_hw_register_readable): 25 /* a1: saved_vbr */ 26 /* save sp */ 27 move.l %sp,saved_sp 28 /* set our fault vector in the table */ 29 move.l #trap_fault_r,fault_vector 30 31 /* swap our table in */ 32 movec %vbr,%a1 33 move.l #temp_vectors,%a0 34 movec %a0,%vbr 35 36 /* attempt the access */ 37 move.l 4(%sp),%a0 38 moveq #0,%d0 39 move.w (%a0),%d1 40 41 nop /* flush the pipeline */ 42 moveq #1,%d0 43trap_fault_r: 44 /* restore */ 45 movec %a1,%vbr 46 move.l saved_sp,%sp 47 rts 48FUNCTION_END(m68k_is_hw_register_readable) 49 50 51/* extern bool m68k_is_hw_register_writable(addr_t address, uint32 value); 52 */ 53FUNCTION(m68k_is_hw_register_writable): 54 /* a1: saved_vbr */ 55 /* save sp */ 56 move.l %sp,saved_sp 57 /* set our fault vector in the table */ 58 move.l #trap_fault_w,fault_vector 59 60 /* swap our table in */ 61 movec %vbr,%a1 62 move.l #temp_vectors,%a0 63 movec %a0,%vbr 64 65 /* attempt the access */ 66 move.l 4(%sp),%a0 67 move.l 8(%sp),%d1 68 moveq #0,%d0 69 move.w %d1,(%a0) 70 71 nop /* flush the pipeline */ 72 moveq #1,%d0 73trap_fault_w: 74 /* restore */ 75 movec %a1,%vbr 76 move.l saved_sp,%sp 77 rts 78FUNCTION_END(m68k_is_hw_register_writable) 79 80/* scratch data for the 2 functions above */ 81saved_sp: 82 .long 0 83temp_vectors: 84 .long 0 /* reset sp */ 85 .long 0 /* reset pc */ 86fault_vector: 87 .long 0 /* fault */ 88 89 90