]> git.lizzy.rs Git - plan9front.git/blob - sys/src/boot/bitsy/il.s
kencc: make "function not declared" a warning unless compiling with -T
[plan9front.git] / sys / src / boot / bitsy / il.s
1 #include "mem.h"
2 /*
3  *  Entered here from Compaq's bootldr.  First relocate to
4  *  the location we're linked for and then copy back the
5  *  decompressed kernel.
6  *
7  *  All 
8  */
9 TEXT _start(SB), $-4
10         MOVW    $setR12(SB), R12                /* load the SB */
11         MOVW    $1, R0          /* dance to make 5l think that the magic */
12         MOVW    $1, R1          /* numbers in WORDs below are being used */
13         CMP.S   R0, R1          /* and to align them to where bootldr wants */
14         BEQ     _start2
15         WORD    $0x016f2818     /* magic number to say we are a kernel */
16         WORD    $0xc0008000     /* entry point address */
17         WORD    $0              /* size?, or end of data? */
18
19 _start2:
20
21         /* SVC mode, interrupts disabled */
22         MOVW    $(PsrDirq|PsrDfiq|PsrMsvc), R1
23         MOVW    R1, CPSR
24
25         /* disable the MMU */
26         MOVW    $0x130, R1
27         MCR     CpMMU, 0, R1, C(CpControl), C(0x0)
28
29         /* enable caches */
30         MRC     CpMMU, 0, R0, C(CpControl), C(0x0)
31         ORR     $(CpCdcache|CpCicache|CpCwb), R0
32         MCR     CpMMU, 0, R0, C(CpControl), C(0x0)
33
34         /* flush caches */
35         MCR     CpMMU, 0, R0, C(CpCacheFlush), C(0x7), 0
36         /* drain prefetch */
37         MOVW    R0,R0                                           
38         MOVW    R0,R0
39         MOVW    R0,R0
40         MOVW    R0,R0
41
42         /* drain write buffer */
43         MCR     CpMMU, 0, R0, C(CpCacheFlush), C(0xa), 4
44
45         /* relocate to where we expect to be */
46         MOVW    $(512*1024),R3
47         MOVW    $0xC0008000,R1
48         MOVW    $0xC0200000,R2
49         ADD     R1,R3
50 _relloop:
51         MOVW    (R1),R0
52         MOVW    R0,(R2)
53         ADD     $4,R1
54         ADD     $4,R2
55         CMP.S   R1,R3
56         BNE     _relloop
57
58         MOVW    $(MACHADDR+BY2PG), R13          /* stack */
59         SUB     $4, R13                         /* link */
60
61         /* jump to where we've been relocated */
62         MOVW    $_relocated(SB),R15
63
64 TEXT _relocated(SB),$-4
65         BL      main(SB)
66         BL      exit(SB)
67         /* we shouldn't get here */
68 _mainloop:
69         B       _mainloop
70         BL      _div(SB)                        /* hack to get _div etc loaded */
71
72 TEXT mypc(SB),$-4
73         MOVW    R14,R0
74         RET
75
76 TEXT draincache(SB),$-4
77         /* write back any dirty data */
78         MOVW    $0xe0000000,R0
79         ADD     $(8*1024),R0,R1
80 _cfloop:
81         MOVW.P  32(R0),R2
82         CMP.S   R0,R1
83         BNE     _cfloop
84         
85         /* drain write buffer and invalidate i&d cache contents */
86         MCR     CpMMU, 0, R0, C(CpCacheFlush), C(0xa), 4
87         MCR     CpMMU, 0, R0, C(CpCacheFlush), C(0x7), 0
88
89         /* drain prefetch */
90         MOVW    R0,R0                                           
91         MOVW    R0,R0
92         MOVW    R0,R0
93         MOVW    R0,R0
94
95         /* disable caches */
96         MRC     CpMMU, 0, R0, C(CpControl), C(0x0)
97         BIC     $(CpCdcache|CpCicache|CpCwb), R0
98         MCR     CpMMU, 0, R0, C(CpControl), C(0x0)
99         RET