]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/bcm/arm.s
merge
[plan9front.git] / sys / src / 9 / bcm / arm.s
1 /*
2  * armv6/v7 machine assist, definitions
3  *
4  * loader uses R11 as scratch.
5  */
6
7 #include "mem.h"
8 #include "arm.h"
9
10 #define PADDR(va)       (PHYSDRAM | ((va) & ~KSEGM))
11
12 #define L1X(va)         (((((va))>>20) & 0x0fff)<<2)
13
14 /*
15  * new instructions
16  */
17
18 #define ISB     \
19         MOVW    $0, R0; \
20         MCR     CpSC, 0, R0, C(CpCACHE), C(CpCACHEinvi), CpCACHEwait
21
22 #define DSB \
23         MOVW    $0, R0; \
24         MCR     CpSC, 0, R0, C(CpCACHE), C(CpCACHEwb), CpCACHEwait
25
26 #define BARRIERS        DSB; ISB
27
28 #define MCRR(coproc, op, rd, rn, crm) \
29         WORD $(0xec400000|(rn)<<16|(rd)<<12|(coproc)<<8|(op)<<4|(crm))
30 #define MRRC(coproc, op, rd, rn, crm) \
31         WORD $(0xec500000|(rn)<<16|(rd)<<12|(coproc)<<8|(op)<<4|(crm))
32 #define MSR(R, rn, m, m1) \
33         WORD $(0xe120f200|(R)<<22|(m1)<<16|(m)<<8|(rn))
34
35 #define CPSIE   WORD    $0xf1080080     /* intr enable: zeroes I bit */
36 #define CPSID   WORD    $0xf10c0080     /* intr disable: sets I bit */
37
38 #define OKAY \
39         MOVW    $0x7E200028,R2; \
40         MOVW    $0x10000,R3; \
41         MOVW    R3,(R2)
42
43 /*
44  * get cpu id, or zero if armv6
45  */
46 #define CPUID(r) \
47         MRC     CpSC, 0, r, C(CpID), C(CpIDfeat), 7; \
48         CMP     $0, r; \
49         B.EQ    2(PC); \
50         MRC     CpSC, 0, r, C(CpID), C(CpIDidct), CpIDmpid; \
51         AND.S   $(MAXMACH-1), r
52