xref: /haiku/src/system/kernel/arch/m68k/arch_cpu_asm.S (revision b6f76ebe7153b94820cf35f8db4facc158841abb)
1845a180fSFrançois Revol/*
2*b6f76ebeSAugustin Cavalier** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3*b6f76ebeSAugustin Cavalier** Distributed under the terms of the MIT License.
4845a180fSFrançois Revol*/
5845a180fSFrançois Revol
69f5e12b6SFrançois Revol#include <asm_defs.h>
7845a180fSFrançois Revol
8845a180fSFrançois Revol.text
9845a180fSFrançois Revol
107d49488bSFrançois Revol.cpu	68020
117d49488bSFrançois Revol
127d49488bSFrançois Revol/*
137d49488bSFrançois Revol * Those two probe hardware register for presence, trapping bus errors.
147d49488bSFrançois Revol * inspired by the Linux version, cf.
157d49488bSFrançois Revol * http://lxr.linux.no/linux+v2.6.27/arch/m68k/mm/hwtest.c
167d49488bSFrançois Revol *
177d49488bSFrançois Revol * though I'm not sure why the tests are on words only.
187d49488bSFrançois Revol * Some regs are bytes only and the even byte is unmapped...
197d49488bSFrançois Revol * but probably ignored.
20845a180fSFrançois Revol */
21845a180fSFrançois Revol
227d49488bSFrançois Revol/* extern bool m68k_is_hw_register_readable(addr_t address);
23845a180fSFrançois Revol */
247d49488bSFrançois RevolFUNCTION(m68k_is_hw_register_readable):
257d49488bSFrançois Revol	/*	a1: saved_vbr */
267d49488bSFrançois Revol	/* save sp */
277d49488bSFrançois Revol	move.l	%sp,saved_sp
287d49488bSFrançois Revol	/* set our fault vector in the table */
297d49488bSFrançois Revol	move.l	#trap_fault_r,fault_vector
30845a180fSFrançois Revol
317d49488bSFrançois Revol	/* swap our table in */
327d49488bSFrançois Revol	movec	%vbr,%a1
337d49488bSFrançois Revol	move.l	#temp_vectors,%a0
347d49488bSFrançois Revol	movec	%a0,%vbr
357d49488bSFrançois Revol
367d49488bSFrançois Revol	/* attempt the access */
377d49488bSFrançois Revol	move.l	4(%sp),%a0
387d49488bSFrançois Revol	moveq	#0,%d0
397d49488bSFrançois Revol	move.w	(%a0),%d1
407d49488bSFrançois Revol
417d49488bSFrançois Revol	nop	/* flush the pipeline */
427d49488bSFrançois Revol	moveq	#1,%d0
437d49488bSFrançois Revoltrap_fault_r:
447d49488bSFrançois Revol	/* restore */
457d49488bSFrançois Revol	movec	%a1,%vbr
467d49488bSFrançois Revol	move.l	saved_sp,%sp
477d49488bSFrançois Revol	rts
487d49488bSFrançois RevolFUNCTION_END(m68k_is_hw_register_readable)
497d49488bSFrançois Revol
507d49488bSFrançois Revol
517d49488bSFrançois Revol/* extern bool m68k_is_hw_register_writable(addr_t address, uint32 value);
52845a180fSFrançois Revol */
537d49488bSFrançois RevolFUNCTION(m68k_is_hw_register_writable):
547d49488bSFrançois Revol	/*	a1: saved_vbr */
557d49488bSFrançois Revol	/* save sp */
567d49488bSFrançois Revol	move.l	%sp,saved_sp
577d49488bSFrançois Revol	/* set our fault vector in the table */
587d49488bSFrançois Revol	move.l	#trap_fault_w,fault_vector
59845a180fSFrançois Revol
607d49488bSFrançois Revol	/* swap our table in */
617d49488bSFrançois Revol	movec	%vbr,%a1
627d49488bSFrançois Revol	move.l	#temp_vectors,%a0
637d49488bSFrançois Revol	movec	%a0,%vbr
64845a180fSFrançois Revol
657d49488bSFrançois Revol	/* attempt the access */
667d49488bSFrançois Revol	move.l	4(%sp),%a0
677d49488bSFrançois Revol	move.l	8(%sp),%d1
687d49488bSFrançois Revol	moveq	#0,%d0
697d49488bSFrançois Revol	move.w	%d1,(%a0)
70845a180fSFrançois Revol
717d49488bSFrançois Revol	nop	/* flush the pipeline */
727d49488bSFrançois Revol	moveq	#1,%d0
737d49488bSFrançois Revoltrap_fault_w:
747d49488bSFrançois Revol	/* restore */
757d49488bSFrançois Revol	movec	%a1,%vbr
767d49488bSFrançois Revol	move.l	saved_sp,%sp
777d49488bSFrançois Revol	rts
787d49488bSFrançois RevolFUNCTION_END(m68k_is_hw_register_writable)
79845a180fSFrançois Revol
807d49488bSFrançois Revol/* scratch data for the 2 functions above */
817d49488bSFrançois Revolsaved_sp:
827d49488bSFrançois Revol	.long	0
837d49488bSFrançois Revoltemp_vectors:
847d49488bSFrançois Revol	.long	0	/* reset sp */
857d49488bSFrançois Revol	.long	0	/* reset pc */
867d49488bSFrançois Revolfault_vector:
877d49488bSFrançois Revol	.long	0	/* fault */
88845a180fSFrançois Revol
89845a180fSFrançois Revol
90