Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / grub-core / kern / mips / startup.S
blob2476038bc0478b6504a07ea7d94d2fdaa57e0270
1 /* startup.S - Startup code for the MIPS.  */
2 /*
3  *  GRUB  --  GRand Unified Bootloader
4  *  Copyright (C) 2009  Free Software Foundation, Inc.
5  *
6  *  GRUB is free software: you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation, either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  GRUB is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
18  */
20 #include <grub/symbol.h>
21 #include <grub/offsets.h>
22 #include <grub/machine/memory.h>
23 #include <grub/machine/kernel.h>
24 #include <grub/offsets.h>
26 #define BASE_ADDR 8     
28         .globl __start, _start, start
29         .set noreorder
30         .set nomacro
31 __start:
32 _start:
33 start:          
34 .extern __bss_start
35 .extern _end
36         bal cont
37          nop
39         . = _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
40 VARIABLE(grub_total_modules_size)
41         .long 0
43 VARIABLE (grub_arch_busclock)
44         .long 0
45 VARIABLE (grub_arch_cpuclock)
46         .long 0
47 VARIABLE (grub_arch_memsize)
48         .long 0
49 VARIABLE (grub_arch_highmemsize)
50         .long 0
51 #ifdef GRUB_MACHINE_MIPS_LOONGSON
52 VARIABLE (grub_arch_machine)
53         .long GRUB_ARCH_MACHINE_FULOONG2F
54 #endif
55 cont:
56         /* Save our base.  */
57         move $s0, $ra
59 #ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
60         lui $t1, %hi(grub_arch_busclock)
61         addiu $t1, %lo(grub_arch_busclock)
62         sw $s4, 8($t1)
63 #endif
65 #ifdef GRUB_MACHINE_MIPS_LOONGSON
66         lui $t1, %hi(grub_arch_busclock)
67         addiu $t1, %lo(grub_arch_busclock)
68         sw $s2, 0($t1)
69         sw $s3, 4($t1)
70         sw $s4, 8($t1)
71         sw $s5, 12($t1)
72         sw $s7, 16($t1)
73 #endif
75         /* Move the modules out of BSS.  */
76 #ifndef GRUB_MACHINE_ARC
77         lui $t2, %hi(__bss_start)
78         addiu $t2, %lo(__bss_start)
79         
80         lui $t1, %hi(_end)
81         addiu $t1, %lo(_end)
82         addiu $t1, (GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
83         li $t3, (GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
84         nor $t3, $t3, $0
85         and $t1, $t1, $t3
86         
87         lw $t3, (GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE - BASE_ADDR)($s0)
89         /* Backward copy.  */
90         add $t1, $t1, $t3
91         add $t2, $t2, $t3
92         addiu $t1, $t1, -1
93         addiu $t2, $t2, -1
95         /* $t2 is source. $t1 is destination. $t3 is size.  */
96 modulesmovcont:
97         beq $t3, $0, modulesmovdone
98          nop
99         lb $t4, 0($t2)
100         sb $t4, 0($t1)
101         addiu $t2, $t2, -1
102         addiu $t1, $t1, -1
103         b modulesmovcont
104          addiu $t3, $t3, -1
105 modulesmovdone:
106 #endif
108         /* Clean BSS.  */
109         
110         lui $t1, %hi(__bss_start)
111         addiu $t1, $t1, %lo(__bss_start)
112         lui $t2, %hi(_end)
113         addiu $t2, $t2, %lo(_end)
114 bsscont:
115         sb $0,0($t1)
116         addiu $t1, $t1, 1
117         sltu $t3, $t1, $t2
118         bne $t3, $0, bsscont
119          nop
121         lui $t1, %hi(grub_main)
122         addiu $t1, %lo(grub_main)
124         lui $sp, %hi(GRUB_MACHINE_MEMORY_STACK_HIGH)
125         jr $t1
126          addiu $sp, $sp, %lo(GRUB_MACHINE_MEMORY_STACK_HIGH)