2005-04-17 02:20:36 +04:00
/ *
* The A R M L D R D a n d T h u m b L D R S B i n s t r u c t i o n s u s e b i t 2 0 / 1 1 ( A R M / T h u m b )
* differently t h a n e v e r y o t h e r i n s t r u c t i o n , s o i t i s s e t t o 0 ( w r i t e )
* even t h o u g h t h e i n s t r u c t i o n s a r e r e a d i n s t r u c t i o n s . T h i s m e a n s t h a t
* during a n a b o r t t h e i n s t r u c t i o n s w i l l b e t r e a t e d a s a w r i t e a n d t h e
* handler w i l l r a i s e a s i g n a l f r o m u n w r i t e a b l e l o c a t i o n s i f t h e y
* fault. W e h a v e t o s p e c i f i c a l l y c h e c k f o r t h e s e i n s t r u c t i o n s
* from t h e a b o r t h a n d l e r s t o t r e a t t h e m p r o p e r l y .
*
* /
2011-06-26 16:42:01 +04:00
.macro do_ t h u m b _ a b o r t , f s r , p c , p s r , t m p
tst \ p s r , #P S R _ T _ B I T
2005-04-17 02:20:36 +04:00
beq n o t _ t h u m b
2011-06-26 16:42:01 +04:00
ldrh \ t m p , [ \ p c ] @ Read aborted Thumb instruction
and \ t m p , \ t m p , # 0xfe00 @ Mask opcode field
cmp \ t m p , # 0x5600 @ Is it ldrsb?
orreq \ t m p , \ t m p , #1 < < 1 1 @ Set L-bit if yes
tst \ t m p , #1 < < 1 1 @ L = 0 -> write
orreq \ p s r , \ p s r , #1 < < 1 1 @ yes.
2011-06-26 19:01:26 +04:00
b d o _ D a t a A b o r t
2005-04-17 02:20:36 +04:00
not_thumb :
.endm
/ *
2011-06-26 16:42:01 +04:00
* We c h e c k f o r t h e f o l l o w i n g i n s t r u c t i o n e n c o d i n g f o r L D R D .
2005-04-17 02:20:36 +04:00
*
2011-06-26 16:42:01 +04:00
* [ 27 : 2 5 ] = = 0 0 0
2005-04-17 02:20:36 +04:00
* [ 7 : 4 ] = = 1 1 0 1
* [ 2 0 ] = = 0
* /
2011-06-26 16:42:01 +04:00
.macro do_ l d r d _ a b o r t , t m p , i n s n
2011-06-26 16:51:44 +04:00
tst \ i n s n , #0x0e100000 @ [27:25,20] == 0
2005-04-17 02:20:36 +04:00
bne n o t _ l d r d
2011-06-26 16:42:01 +04:00
and \ t m p , \ i n s n , #0x000000f0 @ [7:4] == 1101
cmp \ t m p , #0x000000d0
2011-06-26 19:01:26 +04:00
beq d o _ D a t a A b o r t
2005-04-17 02:20:36 +04:00
not_ldrd :
.endm