ebiederm | c779889 | 2009-04-01 11:03:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2003 Eric W. Biederman <ebiederm@xmission.com> |
| 5 | * Copyright (C) 2009 Ron Minnich <rminnich@gmail.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program 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 this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA |
| 19 | */ |
| 20 | |
Stefan Reinauer | 1377491 | 2011-10-14 15:19:21 -0700 | [diff] [blame] | 21 | #include <arch/byteorder.h> |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 22 | #include <console/console.h> |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 23 | #include <fallback.h> |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 24 | #include <boot/elf.h> |
| 25 | #include <boot/elf_boot.h> |
| 26 | #include <boot/coreboot_tables.h> |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 27 | #include <stdint.h> |
| 28 | #include <stdlib.h> |
| 29 | #include <string.h> |
Peter Stuge | 483b7bb | 2009-04-14 07:40:01 +0000 | [diff] [blame] | 30 | #include <cbfs.h> |
Myles Watson | 5817078 | 2009-10-28 16:13:28 +0000 | [diff] [blame] | 31 | #include <lib.h> |
Duncan Laurie | cde7801 | 2011-10-19 15:32:39 -0700 | [diff] [blame^] | 32 | #if CONFIG_COLLECT_TIMESTAMPS |
| 33 | #include <timestamp.h> |
| 34 | #endif |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 35 | |
Stefan Reinauer | 1943629 | 2011-11-07 12:43:03 -0800 | [diff] [blame] | 36 | /* Maximum physical address we can use for the coreboot bounce buffer. */ |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 37 | #ifndef MAX_ADDR |
| 38 | #define MAX_ADDR -1UL |
| 39 | #endif |
| 40 | |
Stefan Reinauer | 1943629 | 2011-11-07 12:43:03 -0800 | [diff] [blame] | 41 | /* from coreboot_ram.ld: */ |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 42 | extern unsigned char _ram_seg; |
| 43 | extern unsigned char _eram_seg; |
| 44 | |
Stefan Reinauer | 1943629 | 2011-11-07 12:43:03 -0800 | [diff] [blame] | 45 | static const unsigned long lb_start = (unsigned long)&_ram_seg; |
| 46 | static const unsigned long lb_end = (unsigned long)&_eram_seg; |
| 47 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 48 | struct segment { |
| 49 | struct segment *next; |
| 50 | struct segment *prev; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 51 | unsigned long s_dstaddr; |
| 52 | unsigned long s_srcaddr; |
| 53 | unsigned long s_memsz; |
| 54 | unsigned long s_filesz; |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 55 | int compression; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 58 | /* The problem: |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 59 | * Static executables all want to share the same addresses |
| 60 | * in memory because only a few addresses are reliably present on |
| 61 | * a machine, and implementing general relocation is hard. |
| 62 | * |
| 63 | * The solution: |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 64 | * - Allocate a buffer the size of the coreboot image plus additional |
| 65 | * required space. |
| 66 | * - Anything that would overwrite coreboot copy into the lower part of |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 67 | * the buffer. |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 68 | * - After loading an ELF image copy coreboot to the top of the buffer. |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 69 | * - Then jump to the loaded image. |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 70 | * |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 71 | * Benefits: |
| 72 | * - Nearly arbitrary standalone executables can be loaded. |
| 73 | * - Coreboot is preserved, so it can be returned to. |
| 74 | * - The implementation is still relatively simple, |
Zheng Bao | ba49fb7 | 2009-11-01 09:18:23 +0000 | [diff] [blame] | 75 | * and much simpler than the general case implemented in kexec. |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 76 | */ |
| 77 | |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 78 | static unsigned long bounce_size, bounce_buffer; |
| 79 | |
Myles Watson | 9202798 | 2009-09-23 20:32:21 +0000 | [diff] [blame] | 80 | static void get_bounce_buffer(struct lb_memory *mem, unsigned long req_size) |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 81 | { |
| 82 | unsigned long lb_size; |
| 83 | unsigned long mem_entries; |
| 84 | unsigned long buffer; |
| 85 | int i; |
Stefan Reinauer | 1943629 | 2011-11-07 12:43:03 -0800 | [diff] [blame] | 86 | lb_size = lb_end - lb_start; |
| 87 | /* Plus coreboot size so I have somewhere |
| 88 | * to place a copy to return to. |
| 89 | */ |
Myles Watson | 9202798 | 2009-09-23 20:32:21 +0000 | [diff] [blame] | 90 | lb_size = req_size + lb_size; |
Stefan Reinauer | 1943629 | 2011-11-07 12:43:03 -0800 | [diff] [blame] | 91 | mem_entries = (mem->size - sizeof(*mem)) / sizeof(mem->map[0]); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 92 | buffer = 0; |
| 93 | for(i = 0; i < mem_entries; i++) { |
| 94 | unsigned long mstart, mend; |
| 95 | unsigned long msize; |
| 96 | unsigned long tbuffer; |
| 97 | if (mem->map[i].type != LB_MEM_RAM) |
| 98 | continue; |
| 99 | if (unpack_lb64(mem->map[i].start) > MAX_ADDR) |
| 100 | continue; |
| 101 | if (unpack_lb64(mem->map[i].size) < lb_size) |
| 102 | continue; |
| 103 | mstart = unpack_lb64(mem->map[i].start); |
| 104 | msize = MAX_ADDR - mstart +1; |
| 105 | if (msize > unpack_lb64(mem->map[i].size)) |
| 106 | msize = unpack_lb64(mem->map[i].size); |
| 107 | mend = mstart + msize; |
| 108 | tbuffer = mend - lb_size; |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 109 | if (tbuffer < buffer) |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 110 | continue; |
| 111 | buffer = tbuffer; |
| 112 | } |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 113 | bounce_buffer = buffer; |
Myles Watson | 9202798 | 2009-09-23 20:32:21 +0000 | [diff] [blame] | 114 | bounce_size = req_size; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | static int valid_area(struct lb_memory *mem, unsigned long buffer, |
| 118 | unsigned long start, unsigned long len) |
| 119 | { |
| 120 | /* Check through all of the memory segments and ensure |
| 121 | * the segment that was passed in is completely contained |
| 122 | * in RAM. |
| 123 | */ |
| 124 | int i; |
| 125 | unsigned long end = start + len; |
Stefan Reinauer | 1943629 | 2011-11-07 12:43:03 -0800 | [diff] [blame] | 126 | unsigned long mem_entries = (mem->size - sizeof(*mem)) / |
| 127 | sizeof(mem->map[0]); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 128 | |
| 129 | /* See if I conflict with the bounce buffer */ |
| 130 | if (end >= buffer) { |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | /* Walk through the table of valid memory ranges and see if I |
| 135 | * have a match. |
| 136 | */ |
| 137 | for(i = 0; i < mem_entries; i++) { |
| 138 | uint64_t mstart, mend; |
| 139 | uint32_t mtype; |
| 140 | mtype = mem->map[i].type; |
| 141 | mstart = unpack_lb64(mem->map[i].start); |
| 142 | mend = mstart + unpack_lb64(mem->map[i].size); |
Stefan Reinauer | c6b8b7d | 2011-11-07 12:56:12 -0800 | [diff] [blame] | 143 | if ((mtype == LB_MEM_RAM) && (start >= mstart) && (end < mend)) { |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 144 | break; |
| 145 | } |
Stefan Reinauer | c6b8b7d | 2011-11-07 12:56:12 -0800 | [diff] [blame] | 146 | if ((mtype == LB_MEM_TABLE) && (start >= mstart) && (end < mend)) { |
Stefan Reinauer | d6b4f1c | 2010-09-23 18:29:40 +0000 | [diff] [blame] | 147 | printk(BIOS_ERR, "Payload is overwriting coreboot tables.\n"); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 148 | break; |
| 149 | } |
| 150 | } |
| 151 | if (i == mem_entries) { |
Stefan Reinauer | 9ec8ed8 | 2011-10-18 15:11:04 -0700 | [diff] [blame] | 152 | if (start < (1024*1024) && end <=(1024*1024)) { |
| 153 | printk(BIOS_DEBUG, "Payload (probably SeaBIOS) loaded" |
| 154 | " into a reserved area in the lower 1MB\n"); |
| 155 | return 1; |
| 156 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 157 | printk(BIOS_ERR, "No matching ram area found for range:\n"); |
| 158 | printk(BIOS_ERR, " [0x%016lx, 0x%016lx)\n", start, end); |
| 159 | printk(BIOS_ERR, "Ram areas\n"); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 160 | for(i = 0; i < mem_entries; i++) { |
| 161 | uint64_t mstart, mend; |
| 162 | uint32_t mtype; |
| 163 | mtype = mem->map[i].type; |
| 164 | mstart = unpack_lb64(mem->map[i].start); |
| 165 | mend = mstart + unpack_lb64(mem->map[i].size); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 166 | printk(BIOS_ERR, " [0x%016lx, 0x%016lx) %s\n", |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 167 | (unsigned long)mstart, |
| 168 | (unsigned long)mend, |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 169 | (mtype == LB_MEM_RAM)?"RAM":"Reserved"); |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 170 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 171 | } |
| 172 | return 0; |
| 173 | } |
| 174 | return 1; |
| 175 | } |
| 176 | |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 177 | |
| 178 | static int overlaps_coreboot(struct segment *seg) |
| 179 | { |
| 180 | unsigned long start, end; |
| 181 | start = seg->s_dstaddr; |
| 182 | end = start + seg->s_memsz; |
| 183 | return !((end <= lb_start) || (start >= lb_end)); |
| 184 | } |
| 185 | |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 186 | static int relocate_segment(unsigned long buffer, struct segment *seg) |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 187 | { |
| 188 | /* Modify all segments that want to load onto coreboot |
| 189 | * to load onto the bounce buffer instead. |
| 190 | */ |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 191 | /* ret: 1 : A new segment is inserted before the seg. |
Stefan Reinauer | 1943629 | 2011-11-07 12:43:03 -0800 | [diff] [blame] | 192 | * 0 : A new segment is inserted after the seg, or no new one. |
| 193 | */ |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 194 | unsigned long start, middle, end, ret = 0; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 195 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 196 | printk(BIOS_SPEW, "lb: [0x%016lx, 0x%016lx)\n", |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 197 | lb_start, lb_end); |
| 198 | |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 199 | /* I don't conflict with coreboot so get out of here */ |
| 200 | if (!overlaps_coreboot(seg)) |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 201 | return 0; |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 202 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 203 | start = seg->s_dstaddr; |
| 204 | middle = start + seg->s_filesz; |
| 205 | end = start + seg->s_memsz; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 206 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 207 | printk(BIOS_SPEW, "segment: [0x%016lx, 0x%016lx, 0x%016lx)\n", |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 208 | start, middle, end); |
| 209 | |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 210 | if (seg->compression == CBFS_COMPRESS_NONE) { |
| 211 | /* Slice off a piece at the beginning |
| 212 | * that doesn't conflict with coreboot. |
| 213 | */ |
| 214 | if (start < lb_start) { |
| 215 | struct segment *new; |
| 216 | unsigned long len = lb_start - start; |
| 217 | new = malloc(sizeof(*new)); |
| 218 | *new = *seg; |
| 219 | new->s_memsz = len; |
| 220 | seg->s_memsz -= len; |
| 221 | seg->s_dstaddr += len; |
| 222 | seg->s_srcaddr += len; |
| 223 | if (seg->s_filesz > len) { |
| 224 | new->s_filesz = len; |
| 225 | seg->s_filesz -= len; |
| 226 | } else { |
| 227 | seg->s_filesz = 0; |
| 228 | } |
| 229 | |
| 230 | /* Order by stream offset */ |
| 231 | new->next = seg; |
| 232 | new->prev = seg->prev; |
| 233 | seg->prev->next = new; |
| 234 | seg->prev = new; |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 235 | |
| 236 | /* compute the new value of start */ |
| 237 | start = seg->s_dstaddr; |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 238 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 239 | printk(BIOS_SPEW, " early: [0x%016lx, 0x%016lx, 0x%016lx)\n", |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 240 | new->s_dstaddr, |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 241 | new->s_dstaddr + new->s_filesz, |
| 242 | new->s_dstaddr + new->s_memsz); |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 243 | |
| 244 | ret = 1; |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 245 | } |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 246 | |
| 247 | /* Slice off a piece at the end |
| 248 | * that doesn't conflict with coreboot |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 249 | */ |
| 250 | if (end > lb_end) { |
| 251 | unsigned long len = lb_end - start; |
| 252 | struct segment *new; |
| 253 | new = malloc(sizeof(*new)); |
| 254 | *new = *seg; |
| 255 | seg->s_memsz = len; |
| 256 | new->s_memsz -= len; |
| 257 | new->s_dstaddr += len; |
| 258 | new->s_srcaddr += len; |
| 259 | if (seg->s_filesz > len) { |
| 260 | seg->s_filesz = len; |
| 261 | new->s_filesz -= len; |
| 262 | } else { |
| 263 | new->s_filesz = 0; |
| 264 | } |
| 265 | /* Order by stream offset */ |
| 266 | new->next = seg->next; |
| 267 | new->prev = seg; |
| 268 | seg->next->prev = new; |
| 269 | seg->next = new; |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 270 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 271 | printk(BIOS_SPEW, " late: [0x%016lx, 0x%016lx, 0x%016lx)\n", |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 272 | new->s_dstaddr, |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 273 | new->s_dstaddr + new->s_filesz, |
| 274 | new->s_dstaddr + new->s_memsz); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 275 | } |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 276 | } |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 277 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 278 | /* Now retarget this segment onto the bounce buffer */ |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 279 | /* sort of explanation: the buffer is a 1:1 mapping to coreboot. |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 280 | * so you will make the dstaddr be this buffer, and it will get copied |
| 281 | * later to where coreboot lives. |
| 282 | */ |
| 283 | seg->s_dstaddr = buffer + (seg->s_dstaddr - lb_start); |
| 284 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 285 | printk(BIOS_SPEW, " bounce: [0x%016lx, 0x%016lx, 0x%016lx)\n", |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 286 | seg->s_dstaddr, |
| 287 | seg->s_dstaddr + seg->s_filesz, |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 288 | seg->s_dstaddr + seg->s_memsz); |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 289 | |
| 290 | return ret; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | |
| 294 | static int build_self_segment_list( |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 295 | struct segment *head, |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 296 | struct lb_memory *mem, |
Peter Stuge | 483b7bb | 2009-04-14 07:40:01 +0000 | [diff] [blame] | 297 | struct cbfs_payload *payload, u32 *entry) |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 298 | { |
| 299 | struct segment *new; |
| 300 | struct segment *ptr; |
Peter Stuge | 483b7bb | 2009-04-14 07:40:01 +0000 | [diff] [blame] | 301 | struct cbfs_payload_segment *segment, *first_segment; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 302 | memset(head, 0, sizeof(*head)); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 303 | head->next = head->prev = head; |
| 304 | first_segment = segment = &payload->segments; |
| 305 | |
| 306 | while(1) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 307 | printk(BIOS_DEBUG, "Loading segment from rom address 0x%p\n", segment); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 308 | switch(segment->type) { |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 309 | case PAYLOAD_SEGMENT_PARAMS: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 310 | printk(BIOS_DEBUG, " parameter section (skipped)\n"); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 311 | segment++; |
| 312 | continue; |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 313 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 314 | case PAYLOAD_SEGMENT_CODE: |
| 315 | case PAYLOAD_SEGMENT_DATA: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 316 | printk(BIOS_DEBUG, " %s (compression=%x)\n", |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 317 | segment->type == PAYLOAD_SEGMENT_CODE ? "code" : "data", |
| 318 | ntohl(segment->compression)); |
| 319 | new = malloc(sizeof(*new)); |
Stefan Reinauer | 02e75b2 | 2011-10-17 09:51:15 -0700 | [diff] [blame] | 320 | new->s_dstaddr = ntohll(segment->load_addr); |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 321 | new->s_memsz = ntohl(segment->mem_len); |
| 322 | new->compression = ntohl(segment->compression); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 323 | |
Stefan Reinauer | 02e75b2 | 2011-10-17 09:51:15 -0700 | [diff] [blame] | 324 | new->s_srcaddr = (u32) ((unsigned char *)first_segment) |
| 325 | + ntohl(segment->offset); |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 326 | new->s_filesz = ntohl(segment->len); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 327 | printk(BIOS_DEBUG, " New segment dstaddr 0x%lx memsize 0x%lx srcaddr 0x%lx filesize 0x%lx\n", |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 328 | new->s_dstaddr, new->s_memsz, new->s_srcaddr, new->s_filesz); |
| 329 | /* Clean up the values */ |
| 330 | if (new->s_filesz > new->s_memsz) { |
| 331 | new->s_filesz = new->s_memsz; |
| 332 | } |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 333 | printk(BIOS_DEBUG, " (cleaned up) New segment addr 0x%lx size 0x%lx offset 0x%lx filesize 0x%lx\n", |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 334 | new->s_dstaddr, new->s_memsz, new->s_srcaddr, new->s_filesz); |
| 335 | break; |
| 336 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 337 | case PAYLOAD_SEGMENT_BSS: |
Stefan Reinauer | 02e75b2 | 2011-10-17 09:51:15 -0700 | [diff] [blame] | 338 | printk(BIOS_DEBUG, " BSS 0x%p (%d byte)\n", (void *) |
| 339 | (intptr_t)ntohll(segment->load_addr), |
| 340 | ntohl(segment->mem_len)); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 341 | new = malloc(sizeof(*new)); |
| 342 | new->s_filesz = 0; |
Stefan Reinauer | 02e75b2 | 2011-10-17 09:51:15 -0700 | [diff] [blame] | 343 | new->s_dstaddr = ntohll(segment->load_addr); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 344 | new->s_memsz = ntohl(segment->mem_len); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 345 | break; |
| 346 | |
| 347 | case PAYLOAD_SEGMENT_ENTRY: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 348 | printk(BIOS_DEBUG, " Entry Point 0x%p\n", (void *) ntohl((u32) segment->load_addr)); |
Stefan Reinauer | 02e75b2 | 2011-10-17 09:51:15 -0700 | [diff] [blame] | 349 | *entry = ntohll(segment->load_addr); |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 350 | /* Per definition, a payload always has the entry point |
| 351 | * as last segment. Thus, we use the occurence of the |
| 352 | * entry point as break condition for the loop. |
| 353 | * Can we actually just look at the number of section? |
| 354 | */ |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 355 | return 1; |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 356 | |
| 357 | default: |
| 358 | /* We found something that we don't know about. Throw |
| 359 | * hands into the sky and run away! |
| 360 | */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 361 | printk(BIOS_EMERG, "Bad segment type %x\n", segment->type); |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 362 | return -1; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 363 | } |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 364 | |
Stefan Reinauer | c44de49 | 2012-01-11 14:07:39 -0800 | [diff] [blame] | 365 | /* We have found another CODE, DATA or BSS segment */ |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 366 | segment++; |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 367 | |
Stefan Reinauer | c44de49 | 2012-01-11 14:07:39 -0800 | [diff] [blame] | 368 | /* Find place where to insert our segment */ |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 369 | for(ptr = head->next; ptr != head; ptr = ptr->next) { |
Stefan Reinauer | 02e75b2 | 2011-10-17 09:51:15 -0700 | [diff] [blame] | 370 | if (new->s_srcaddr < ntohll(segment->load_addr)) |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 371 | break; |
| 372 | } |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 373 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 374 | /* Order by stream offset */ |
| 375 | new->next = ptr; |
| 376 | new->prev = ptr->prev; |
| 377 | ptr->prev->next = new; |
| 378 | ptr->prev = new; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 379 | } |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 380 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 381 | return 1; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | static int load_self_segments( |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 385 | struct segment *head, |
| 386 | struct lb_memory *mem, |
| 387 | struct cbfs_payload *payload) |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 388 | { |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 389 | struct segment *ptr; |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 390 | |
Patrick Georgi | 26dd71c | 2009-09-30 21:36:38 +0000 | [diff] [blame] | 391 | unsigned long bounce_high = lb_end; |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 392 | for(ptr = head->next; ptr != head; ptr = ptr->next) { |
Stefan Reinauer | c44de49 | 2012-01-11 14:07:39 -0800 | [diff] [blame] | 393 | if (!overlaps_coreboot(ptr)) |
| 394 | continue; |
Patrick Georgi | 26dd71c | 2009-09-30 21:36:38 +0000 | [diff] [blame] | 395 | if (ptr->s_dstaddr + ptr->s_memsz > bounce_high) |
| 396 | bounce_high = ptr->s_dstaddr + ptr->s_memsz; |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 397 | } |
Patrick Georgi | 26dd71c | 2009-09-30 21:36:38 +0000 | [diff] [blame] | 398 | get_bounce_buffer(mem, bounce_high - lb_start); |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 399 | if (!bounce_buffer) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 400 | printk(BIOS_ERR, "Could not find a bounce buffer...\n"); |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 401 | return 0; |
| 402 | } |
| 403 | for(ptr = head->next; ptr != head; ptr = ptr->next) { |
| 404 | /* Verify the memory addresses in the segment are valid */ |
| 405 | if (!valid_area(mem, bounce_buffer, ptr->s_dstaddr, ptr->s_memsz)) |
| 406 | return 0; |
| 407 | } |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 408 | for(ptr = head->next; ptr != head; ptr = ptr->next) { |
Stefan Reinauer | f64893a | 2009-07-23 22:03:14 +0000 | [diff] [blame] | 409 | unsigned char *dest, *src; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 410 | printk(BIOS_DEBUG, "Loading Segment: addr: 0x%016lx memsz: 0x%016lx filesz: 0x%016lx\n", |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 411 | ptr->s_dstaddr, ptr->s_memsz, ptr->s_filesz); |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 412 | |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 413 | /* Modify the segment to load onto the bounce_buffer if necessary. |
| 414 | */ |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 415 | if (relocate_segment(bounce_buffer, ptr)) { |
| 416 | ptr = (ptr->prev)->prev; |
| 417 | continue; |
| 418 | } |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 419 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 420 | printk(BIOS_DEBUG, "Post relocation: addr: 0x%016lx memsz: 0x%016lx filesz: 0x%016lx\n", |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 421 | ptr->s_dstaddr, ptr->s_memsz, ptr->s_filesz); |
| 422 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 423 | /* Compute the boundaries of the segment */ |
| 424 | dest = (unsigned char *)(ptr->s_dstaddr); |
Myles Watson | fa12b67 | 2009-04-30 22:45:41 +0000 | [diff] [blame] | 425 | src = (unsigned char *)(ptr->s_srcaddr); |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 426 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 427 | /* Copy data from the initial buffer */ |
| 428 | if (ptr->s_filesz) { |
Ronald G. Minnich | 671cedc | 2009-05-14 21:26:28 +0000 | [diff] [blame] | 429 | unsigned char *middle, *end; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 430 | size_t len; |
| 431 | len = ptr->s_filesz; |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 432 | switch(ptr->compression) { |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 433 | case CBFS_COMPRESS_LZMA: { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 434 | printk(BIOS_DEBUG, "using LZMA\n"); |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 435 | len = ulzma(src, dest); |
Myles Watson | 94de72b | 2010-06-01 15:19:25 +0000 | [diff] [blame] | 436 | if (!len) /* Decompression Error. */ |
| 437 | return 0; |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 438 | break; |
| 439 | } |
Stefan Reinauer | 3e4fb9d | 2011-04-21 21:26:58 +0000 | [diff] [blame] | 440 | #if CONFIG_COMPRESSED_PAYLOAD_NRV2B |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 441 | case CBFS_COMPRESS_NRV2B: { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 442 | printk(BIOS_DEBUG, "using NRV2B\n"); |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 443 | unsigned long unrv2b(u8 *src, u8 *dst, unsigned long *ilen_p); |
| 444 | unsigned long tmp; |
| 445 | len = unrv2b(src, dest, &tmp); |
| 446 | break; |
| 447 | } |
| 448 | #endif |
| 449 | case CBFS_COMPRESS_NONE: { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 450 | printk(BIOS_DEBUG, "it's not compressed!\n"); |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 451 | memcpy(dest, src, len); |
| 452 | break; |
| 453 | } |
| 454 | default: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 455 | printk(BIOS_INFO, "CBFS: Unknown compression type %d\n", ptr->compression); |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 456 | return -1; |
| 457 | } |
| 458 | end = dest + ptr->s_memsz; |
| 459 | middle = dest + len; |
Myles Watson | 94de72b | 2010-06-01 15:19:25 +0000 | [diff] [blame] | 460 | printk(BIOS_SPEW, "[ 0x%08lx, %08lx, 0x%08lx) <- %08lx\n", |
Patrick Georgi | 369bc78 | 2009-04-25 07:32:24 +0000 | [diff] [blame] | 461 | (unsigned long)dest, |
| 462 | (unsigned long)middle, |
| 463 | (unsigned long)end, |
| 464 | (unsigned long)src); |
Ronald G. Minnich | 671cedc | 2009-05-14 21:26:28 +0000 | [diff] [blame] | 465 | |
| 466 | /* Zero the extra bytes between middle & end */ |
| 467 | if (middle < end) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 468 | printk(BIOS_DEBUG, "Clearing Segment: addr: 0x%016lx memsz: 0x%016lx\n", |
Ronald G. Minnich | 671cedc | 2009-05-14 21:26:28 +0000 | [diff] [blame] | 469 | (unsigned long)middle, (unsigned long)(end - middle)); |
Zheng Bao | e6ad7fa | 2009-11-05 10:02:59 +0000 | [diff] [blame] | 470 | |
Ronald G. Minnich | 671cedc | 2009-05-14 21:26:28 +0000 | [diff] [blame] | 471 | /* Zero the extra bytes */ |
| 472 | memset(middle, 0, end - middle); |
| 473 | } |
Patrick Georgi | 26dd71c | 2009-09-30 21:36:38 +0000 | [diff] [blame] | 474 | /* Copy the data that's outside the area that shadows coreboot_ram */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 475 | printk(BIOS_DEBUG, "dest %p, end %p, bouncebuffer %lx\n", dest, end, bounce_buffer); |
Patrick Georgi | 26dd71c | 2009-09-30 21:36:38 +0000 | [diff] [blame] | 476 | if ((unsigned long)end > bounce_buffer) { |
| 477 | if ((unsigned long)dest < bounce_buffer) { |
Myles Watson | 7943fe6 | 2009-10-30 02:08:07 +0000 | [diff] [blame] | 478 | unsigned char *from = dest; |
| 479 | unsigned char *to = (unsigned char*)(lb_start-(bounce_buffer-(unsigned long)dest)); |
Patrick Georgi | 26dd71c | 2009-09-30 21:36:38 +0000 | [diff] [blame] | 480 | unsigned long amount = bounce_buffer-(unsigned long)dest; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 481 | printk(BIOS_DEBUG, "move prefix around: from %p, to %p, amount: %lx\n", from, to, amount); |
Patrick Georgi | 26dd71c | 2009-09-30 21:36:38 +0000 | [diff] [blame] | 482 | memcpy(to, from, amount); |
| 483 | } |
| 484 | if ((unsigned long)end > bounce_buffer + (lb_end - lb_start)) { |
| 485 | unsigned long from = bounce_buffer + (lb_end - lb_start); |
| 486 | unsigned long to = lb_end; |
Myles Watson | 7943fe6 | 2009-10-30 02:08:07 +0000 | [diff] [blame] | 487 | unsigned long amount = (unsigned long)end - from; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 488 | printk(BIOS_DEBUG, "move suffix around: from %lx, to %lx, amount: %lx\n", from, to, amount); |
Myles Watson | 7943fe6 | 2009-10-30 02:08:07 +0000 | [diff] [blame] | 489 | memcpy((char*)to, (char*)from, amount); |
Patrick Georgi | 26dd71c | 2009-09-30 21:36:38 +0000 | [diff] [blame] | 490 | } |
| 491 | } |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 492 | } |
| 493 | } |
| 494 | return 1; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 495 | } |
| 496 | |
Myles Watson | 9202798 | 2009-09-23 20:32:21 +0000 | [diff] [blame] | 497 | static int selfboot(struct lb_memory *mem, struct cbfs_payload *payload) |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 498 | { |
Myles Watson | fa12b67 | 2009-04-30 22:45:41 +0000 | [diff] [blame] | 499 | u32 entry=0; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 500 | struct segment head; |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 501 | |
| 502 | /* Preprocess the self segments */ |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 503 | if (!build_self_segment_list(&head, mem, payload, &entry)) |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 504 | goto out; |
| 505 | |
| 506 | /* Load the segments */ |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 507 | if (!load_self_segments(&head, mem, payload)) |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 508 | goto out; |
| 509 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 510 | printk(BIOS_SPEW, "Loaded segments\n"); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 511 | |
| 512 | /* Reset to booting from this image as late as possible */ |
| 513 | boot_successful(); |
| 514 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 515 | printk(BIOS_DEBUG, "Jumping to boot code at %x\n", entry); |
Alexandru Gagniuc | 5005bb06 | 2011-04-11 20:17:22 +0000 | [diff] [blame] | 516 | post_code(POST_ENTER_ELF_BOOT); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 517 | |
Duncan Laurie | cde7801 | 2011-10-19 15:32:39 -0700 | [diff] [blame^] | 518 | #if CONFIG_COLLECT_TIMESTAMPS |
| 519 | timestamp_add_now(TS_SELFBOOT_JUMP); |
| 520 | #endif |
| 521 | |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 522 | /* Jump to kernel */ |
Patrick Georgi | 5eceb32 | 2009-05-13 16:27:25 +0000 | [diff] [blame] | 523 | jmp_to_elf_entry((void*)entry, bounce_buffer, bounce_size); |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 524 | return 1; |
| 525 | |
Patrick Georgi | c5fc7db | 2012-03-07 15:55:47 +0100 | [diff] [blame] | 526 | out: |
Ronald G. Minnich | ae63126 | 2009-04-01 10:48:39 +0000 | [diff] [blame] | 527 | return 0; |
| 528 | } |
| 529 | |
Stefan Reinauer | 1943629 | 2011-11-07 12:43:03 -0800 | [diff] [blame] | 530 | void *cbfs_load_payload(struct lb_memory *lb_mem, const char *name) |
| 531 | { |
| 532 | struct cbfs_payload *payload; |
| 533 | |
| 534 | payload = (struct cbfs_payload *)cbfs_find_file(name, CBFS_TYPE_PAYLOAD); |
| 535 | if (payload == NULL) |
| 536 | return (void *) -1; |
| 537 | printk(BIOS_DEBUG, "Got a payload\n"); |
| 538 | |
| 539 | selfboot(lb_mem, payload); |
| 540 | printk(BIOS_EMERG, "SELFBOOT RETURNED!\n"); |
| 541 | |
| 542 | return (void *) -1; |
| 543 | } |
| 544 | |