Debian Codegraph @

grub-core/kern/sparc64/ieee1275/crt0.S

raw
1 /* crt0.S - Startup code for the Sparc64. */
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 */
19 #include <grub/symbol.h>
20 #include <grub/machine/kernel.h>
21 #include <grub/offsets.h>
22
23 .text
24 .align 4
25 .globl _start
26 _start:
27 ba codestart
28 mov %o4, %o0
29
30 .org GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
31
32 VARIABLE(grub_total_module_size)
33 .word 0
34
35 codestart:
36 /* Copy the modules past the end of the kernel image.
37 * They are currently sitting in the BSS.
38 */
39 sethi %hi(__bss_start + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o2
40 or %o2, %lo(__bss_start + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o2
41 srl %o2, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o2
42 sll %o2, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o2
43 sethi %hi(_end + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o3
44 or %o3, %lo(_end + GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN - 1), %o3
45 srl %o3, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o3
46 sll %o3, GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN, %o3
47 sethi %hi(grub_total_module_size), %o4
48 lduw [%o4 + %lo(grub_total_module_size)], %o4
49
50 add %o2, %o4, %o2
51 add %o3, %o4, %o3
52
53 /* Save ieee1275 stack for future use by booter. */
54 mov %o6, %o1
55 /* Our future stack. */
56 sethi %hi(GRUB_KERNEL_MACHINE_STACK_SIZE), %o5
57 or %o5, %lo(GRUB_KERNEL_MACHINE_STACK_SIZE), %o5
58 add %o3, %o5, %o6
59 and %o6, ~0xff, %o6
60 sub %o6, 2047, %o6
61
62 sub %o2, 4, %o2
63 sub %o3, 4, %o3
64 1: lduw [%o2], %o5
65 stw %o5, [%o3]
66 subcc %o4, 4, %o4
67 sub %o2, 4, %o2
68 bne,pt %icc, 1b
69 sub %o3, 4, %o3
70
71 /* Now it's safe to clear out the BSS. */
72 sethi %hi(__bss_start), %o2
73 or %o2, %lo(__bss_start), %o2
74 1: stb %g0, [%o2]
75 add %o2, 1, %o2
76 and %o2, 7, %o3
77 brnz %o3, 1b
78 nop
79
80 sethi %hi(_end - 1), %o3
81 or %o3, %lo(_end - 1), %o3
82 srl %o3, 3, %o3
83 sll %o3, 3, %o3
84 1: stx %g0, [%o2]
85 add %o2, 8, %o2
86 cmp %o2, %o3
87 blt,pt %xcc, 1b
88 nop
89
90 sethi %hi(_end), %o3
91 or %o3, %lo(_end), %o3
92 1: stb %g0, [%o2]
93 add %o2, 1, %o2
94 cmp %o2, %o3
95 blt,pt %xcc, 1b
96 nop
97
98 sethi %hi(grub_ieee1275_original_stack), %o2
99 stx %o1, [%o2 + %lo(grub_ieee1275_original_stack)]
100 sethi %hi(grub_ieee1275_entry_fn), %o2
101 call grub_main
102 stx %o0, [%o2 + %lo(grub_ieee1275_entry_fn)]
103 1: ba,a 1b
104 nop