| 1 |
/* -*-Asm-*- */ |
| 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 |
|
| 20 |
#include <grub/machine/boot.h> |
| 21 |
#include <grub/offsets.h> |
| 22 |
|
| 23 |
.text |
| 24 |
.align 4 |
| 25 |
.globl _start |
| 26 |
_start: |
| 27 |
/* First stage boot block jumps to us here. */ |
| 28 |
pic_base: |
| 29 |
call after_info_block |
| 30 |
mov %o7, PIC_REG |
| 31 |
|
| 32 |
prom_write_name: .asciz "write" |
| 33 |
prom_seek_name: .asciz "seek" |
| 34 |
prom_read_name: .asciz "read" |
| 35 |
prom_close_name: .asciz "close" |
| 36 |
|
| 37 |
notification_string: .asciz "Loading kernel" |
| 38 |
#define NOTIFICATION_STRING_LEN 14 |
| 39 |
|
| 40 |
notification_step: .asciz "." |
| 41 |
#define NOTIFICATION_STEP_LEN 1 |
| 42 |
|
| 43 |
notification_done: .asciz "\r\n" |
| 44 |
#define NOTIFICATION_DONE_LEN 2 |
| 45 |
|
| 46 |
.align 4 |
| 47 |
|
| 48 |
/* %o2: message string |
| 49 |
* %o3: message length |
| 50 |
*/ |
| 51 |
console_write: |
| 52 |
GET_ABS(prom_write_name, %o0) |
| 53 |
mov STDOUT_NODE_REG, %o1 |
| 54 |
/* fallthru */ |
| 55 |
|
| 56 |
/* %o0: OF call name |
| 57 |
* %o1: input arg 1 |
| 58 |
* %o2: input arg 2 |
| 59 |
* %o3: input arg 3 |
| 60 |
*/ |
| 61 |
prom_call_3_1: |
| 62 |
mov 3, %g1 |
| 63 |
mov 1, %o5 |
| 64 |
/* fallthru */ |
| 65 |
|
| 66 |
/* %o0: OF call name |
| 67 |
* %g1: num inputs |
| 68 |
* %o5: num outputs |
| 69 |
* %o1-%o4: inputs |
| 70 |
*/ |
| 71 |
prom_call: |
| 72 |
stx %o0, [%l1 + 0x00] |
| 73 |
stx %g1, [%l1 + 0x08] |
| 74 |
stx %o5, [%l1 + 0x10] |
| 75 |
stx %o1, [%l1 + 0x18] |
| 76 |
stx %o2, [%l1 + 0x20] |
| 77 |
stx %o3, [%l1 + 0x28] |
| 78 |
stx %o4, [%l1 + 0x30] |
| 79 |
jmpl CIF_REG, %g0 |
| 80 |
mov %l1, %o0 |
| 81 |
|
| 82 |
|
| 83 |
after_info_block: |
| 84 |
sethi %hi(SCRATCH_PAD_DISKBOOT), %l1 /* OF argument slots */ |
| 85 |
|
| 86 |
GET_ABS(notification_string, %o2) |
| 87 |
call console_write |
| 88 |
mov NOTIFICATION_STRING_LEN, %o3 |
| 89 |
|
| 90 |
GET_ABS(firstlist - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2) |
| 91 |
set GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS, %l3 |
| 92 |
bootloop: |
| 93 |
lduw [%l2 + 0x08], %o0 |
| 94 |
brz %o0, bootit |
| 95 |
lduw [%l2 + 0x00], %o3 |
| 96 |
sllx %o3, 32, %o3 |
| 97 |
lduw [%l2 + 0x04], %o4 |
| 98 |
or %o3, %o4, %o3 |
| 99 |
GET_ABS(prom_seek_name, %o0) |
| 100 |
mov BOOTDEV_REG, %o1 |
| 101 |
clr %o2 |
| 102 |
call prom_call_3_1 |
| 103 |
sllx %o3, 9, %o3 |
| 104 |
|
| 105 |
GET_ABS(prom_read_name, %o0) |
| 106 |
mov BOOTDEV_REG, %o1 |
| 107 |
lduw [%l2 + 0x08], %o3 |
| 108 |
sllx %o3, 9, %o3 |
| 109 |
mov %l3, %o2 |
| 110 |
call prom_call_3_1 |
| 111 |
add %l3, %o3, %l3 |
| 112 |
|
| 113 |
GET_ABS(notification_step, %o2) |
| 114 |
call console_write |
| 115 |
mov NOTIFICATION_STEP_LEN, %o3 |
| 116 |
|
| 117 |
ba bootloop |
| 118 |
sub %l2, GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2 |
| 119 |
|
| 120 |
bootit: |
| 121 |
GET_ABS(prom_close_name, %o0) |
| 122 |
mov 1, %g1 |
| 123 |
mov 0, %o5 |
| 124 |
call prom_call |
| 125 |
mov BOOTDEV_REG, %o1 |
| 126 |
|
| 127 |
GET_ABS(notification_done, %o2) |
| 128 |
call console_write |
| 129 |
mov NOTIFICATION_DONE_LEN, %o3 |
| 130 |
sethi %hi(GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o2 |
| 131 |
jmpl %o2 + %lo(GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o7 |
| 132 |
mov CIF_REG, %o4 |
| 133 |
1: ba,a 1b |
| 134 |
|
| 135 |
lastlist: |
| 136 |
.word 0 |
| 137 |
.word 0 |
| 138 |
|
| 139 |
.org (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE) |
| 140 |
blocklist_default_start: |
| 141 |
.word 0 |
| 142 |
.word 2 |
| 143 |
blocklist_default_len: |
| 144 |
.word 0 |
| 145 |
firstlist: |