]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/pc/rebootcode.s
kernel: cleanup the software mouse cursor mess
[plan9front.git] / sys / src / 9 / pc / rebootcode.s
1 #include "mem.h"
2
3 /*
4  * Turn off MMU, then memmove the new kernel to its correct location
5  * in physical memory.  Then jumps the to start of the kernel.
6  */
7
8 TEXT    main(SB),$0
9         MOVL    p1+0(FP), DI            /* destination */
10         MOVL    DI, AX                  /* entry point */
11         MOVL    p2+4(FP), SI            /* source */
12         MOVL    n+8(FP), CX             /* byte count */
13
14 /*
15  * disable paging
16  */
17         MOVL    CR0, DX
18         ANDL    $~0x80000000, DX                /* ~(PG) */
19         MOVL    DX, CR0
20         MOVL    $0, DX
21         MOVL    DX, CR3
22
23         /* stack below entry point */
24         MOVL    AX, SP
25
26         /* park cpu for zero entry point */
27         ORL     AX, AX
28         JZ      _idle
29
30 /*
31  * the source and destination may overlap.
32  * determine whether to copy forward or backwards
33  */
34         CMPL    SI, DI
35         JGT     _forward
36         MOVL    SI, DX
37         ADDL    CX, DX
38         CMPL    DX, DI
39         JGT     _back
40
41 _forward:
42         CLD
43         REP;    MOVSB
44         JMP     _startkernel
45
46 _back:
47         ADDL    CX, DI
48         ADDL    CX, SI
49         SUBL    $1, DI
50         SUBL    $1, SI
51         STD
52         REP;    MOVSB
53         JMP     _startkernel
54 /*
55  * JMP to kernel entry point.  Note the true kernel entry point is
56  * the virtual address KZERO|AX, but this must wait until
57  * the MMU is enabled by the kernel in l.s
58  */
59 _startkernel:
60         ORL     AX, AX          /* NOP: avoid link bug */
61         JMP*    AX
62
63 _idle:
64         HLT
65         JMP     _idle