~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to grub-core/kern/sparc64/ieee1275/crt0.S

Tags: upstream-1.99~20101122
ImportĀ upstreamĀ versionĀ 1.99~20101122

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
        . = EXT_C(_start) + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
 
31
 
 
32
VARIABLE(grub_total_module_size)
 
33
        .word   0
 
34
VARIABLE(grub_kernel_image_size)
 
35
        .word   0
 
36
VARIABLE(grub_compressed_size)
 
37
        .word   0
 
38
VARIABLE(grub_prefix)
 
39
        /* to be filled by grub-mkimage */
 
40
 
 
41
        /*
 
42
         *  Leave some breathing room for the prefix.
 
43
         */
 
44
 
 
45
        . = EXT_C(_start) + GRUB_KERNEL_MACHINE_PREFIX_END
 
46
 
 
47
codestart:
 
48
        /* Copy the modules past the end of the kernel image.
 
49
         * They are currently sitting in the BSS.
 
50
         */
 
51
        sethi   %hi(__bss_start), %o2
 
52
        or      %o2, %lo(__bss_start), %o2
 
53
        sethi   %hi(_end), %o3
 
54
        or      %o3, %lo(_end), %o3
 
55
        sethi   %hi(grub_total_module_size), %o4
 
56
        lduw    [%o4 + %lo(grub_total_module_size)], %o4
 
57
 
 
58
        add     %o2, %o4, %o2
 
59
        add     %o3, %o4, %o3
 
60
 
 
61
        /* Save ieee1275 stack for future use by booter.  */
 
62
        mov     %o6, %o1
 
63
        /* Our future stack.  */
 
64
        sethi   %hi(GRUB_KERNEL_MACHINE_STACK_SIZE), %o5
 
65
        or      %o5, %lo(GRUB_KERNEL_MACHINE_STACK_SIZE), %o5
 
66
        add     %o3, %o5, %o6
 
67
        and     %o6, ~0xff, %o6
 
68
        sub     %o6, 2047, %o6
 
69
        
 
70
        sub     %o2, 4, %o2
 
71
        sub     %o3, 4, %o3
 
72
1:      lduw    [%o2], %o5
 
73
        stw     %o5, [%o3]
 
74
        subcc   %o4, 4, %o4
 
75
        sub     %o2, 4, %o2
 
76
        bne,pt  %icc, 1b
 
77
         sub    %o3, 4, %o3
 
78
 
 
79
        /* Now it's safe to clear out the BSS.  */
 
80
        sethi   %hi(__bss_start), %o2
 
81
        or      %o2, %lo(__bss_start), %o2
 
82
        sethi   %hi(_end), %o3
 
83
        or      %o3, %lo(_end), %o3
 
84
1:      stx     %g0, [%o2]
 
85
        add     %o2, 8, %o2
 
86
        cmp     %o2, %o3
 
87
        blt,pt  %xcc, 1b
 
88
         nop
 
89
        sethi   %hi(grub_ieee1275_original_stack), %o2
 
90
        stx     %o1, [%o2 + %lo(grub_ieee1275_original_stack)]
 
91
        sethi   %hi(grub_ieee1275_entry_fn), %o2
 
92
        call    grub_main
 
93
         stx    %o0, [%o2 + %lo(grub_ieee1275_entry_fn)]
 
94
1:      ba,a    1b