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