blob: 4d392191a4678d87bf55f7431f15b787c4d7a5a2 [file] [log] [blame]
Stefan Reinauerb883d4c2009-08-27 11:23:06 +00001/*
2 * This file is part of the coreboot project.
Stefan Reinauer14e22772010-04-27 06:56:47 +00003 *
Stefan Reinauerb883d4c2009-08-27 11:23:06 +00004 * Copyright (C) 2003-2004 Eric Biederman
Stefan Reinauerb5828d72010-03-29 17:14:28 +00005 * Copyright (C) 2005-2010 coresystems GmbH
Stefan Reinauerb883d4c2009-08-27 11:23:06 +00006 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
10 * the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20 * MA 02110-1301 USA
21 */
22
Eric Biederman8ca8d762003-04-22 19:02:15 +000023#include <console/console.h>
Kyösti Mälkki1d7541f2014-02-17 21:34:42 +020024#include <console/uart.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000025#include <ip_checksum.h>
Stefan Reinauerca374d42008-01-18 16:16:45 +000026#include <boot/coreboot_tables.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +000027#include <string.h>
28#include <version.h>
Eric Biedermanb78c1972004-10-14 20:54:17 +000029#include <device/device.h>
30#include <stdlib.h>
Duncan Laurie66ecdc52011-08-15 16:35:10 -070031#include <cbfs.h>
Vadim Bendebury2e438672011-09-23 09:56:11 -070032#include <cbmem.h>
Aaron Durbin49048022014-02-18 21:55:02 -060033#include <bootmem.h>
Stefan Reinauer0e672b52012-04-27 00:34:54 +020034#if CONFIG_CHROMEOS
Stefan Reinauer3e4e3032013-03-20 14:08:04 -070035#if CONFIG_GENERATE_ACPI_TABLES
Stefan Reinauer0e672b52012-04-27 00:34:54 +020036#include <arch/acpi.h>
Stefan Reinauer3e4e3032013-03-20 14:08:04 -070037#endif
Aaron Durbindd32a312013-03-07 23:15:06 -060038#include <vendorcode/google/chromeos/chromeos.h>
Stefan Reinauer0e672b52012-04-27 00:34:54 +020039#include <vendorcode/google/chromeos/gnvs.h>
40#endif
Aaron Durbinbc07f5d2013-03-26 13:09:39 -050041#if CONFIG_ARCH_X86
42#include <cpu/x86/mtrr.h>
43#endif
Eric Biederman8ca8d762003-04-22 19:02:15 +000044
Stefan Reinauerb883d4c2009-08-27 11:23:06 +000045static struct lb_header *lb_table_init(unsigned long addr)
Eric Biederman8ca8d762003-04-22 19:02:15 +000046{
47 struct lb_header *header;
48
49 /* 16 byte align the address */
50 addr += 15;
51 addr &= ~15;
52
53 header = (void *)addr;
54 header->signature[0] = 'L';
55 header->signature[1] = 'B';
56 header->signature[2] = 'I';
57 header->signature[3] = 'O';
58 header->header_bytes = sizeof(*header);
59 header->header_checksum = 0;
60 header->table_bytes = 0;
61 header->table_checksum = 0;
62 header->table_entries = 0;
63 return header;
64}
65
Stefan Reinauerb883d4c2009-08-27 11:23:06 +000066static struct lb_record *lb_first_record(struct lb_header *header)
Eric Biederman8ca8d762003-04-22 19:02:15 +000067{
68 struct lb_record *rec;
69 rec = (void *)(((char *)header) + sizeof(*header));
70 return rec;
71}
72
Stefan Reinauerb883d4c2009-08-27 11:23:06 +000073static struct lb_record *lb_last_record(struct lb_header *header)
Eric Biederman8ca8d762003-04-22 19:02:15 +000074{
75 struct lb_record *rec;
76 rec = (void *)(((char *)header) + sizeof(*header) + header->table_bytes);
77 return rec;
78}
79
Stefan Reinauerb883d4c2009-08-27 11:23:06 +000080static struct lb_record *lb_new_record(struct lb_header *header)
Eric Biederman8ca8d762003-04-22 19:02:15 +000081{
82 struct lb_record *rec;
83 rec = lb_last_record(header);
84 if (header->table_entries) {
85 header->table_bytes += rec->size;
86 }
87 rec = lb_last_record(header);
88 header->table_entries++;
89 rec->tag = LB_TAG_UNUSED;
90 rec->size = sizeof(*rec);
91 return rec;
92}
93
Stefan Reinauerb883d4c2009-08-27 11:23:06 +000094static struct lb_memory *lb_memory(struct lb_header *header)
Eric Biederman8ca8d762003-04-22 19:02:15 +000095{
96 struct lb_record *rec;
97 struct lb_memory *mem;
98 rec = lb_new_record(header);
99 mem = (struct lb_memory *)rec;
100 mem->tag = LB_TAG_MEMORY;
101 mem->size = sizeof(*mem);
102 return mem;
103}
104
Stefan Reinauerb883d4c2009-08-27 11:23:06 +0000105static struct lb_serial *lb_serial(struct lb_header *header)
Patrick Georgi8c2a0c12008-01-25 18:28:18 +0000106{
Myles Watsonec0ee642009-10-19 16:21:30 +0000107#if CONFIG_CONSOLE_SERIAL8250
Patrick Georgi8c2a0c12008-01-25 18:28:18 +0000108 struct lb_record *rec;
109 struct lb_serial *serial;
110 rec = lb_new_record(header);
111 serial = (struct lb_serial *)rec;
112 serial->tag = LB_TAG_SERIAL;
113 serial->size = sizeof(*serial);
Stefan Reinauerd1bc3312011-06-22 16:39:19 -0700114 serial->type = LB_SERIAL_TYPE_IO_MAPPED;
115 serial->baseaddr = CONFIG_TTYS0_BASE;
116 serial->baud = CONFIG_TTYS0_BAUD;
117 return serial;
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700118#elif CONFIG_CONSOLE_SERIAL8250MEM || CONFIG_CONSOLE_SERIAL_UART
Gabe Black32829ca2011-10-05 01:57:03 -0700119 if (uartmem_getbaseaddr()) {
120 struct lb_record *rec;
121 struct lb_serial *serial;
122 rec = lb_new_record(header);
123 serial = (struct lb_serial *)rec;
124 serial->tag = LB_TAG_SERIAL;
125 serial->size = sizeof(*serial);
126 serial->type = LB_SERIAL_TYPE_MEMORY_MAPPED;
127 serial->baseaddr = uartmem_getbaseaddr();
128 serial->baud = CONFIG_TTYS0_BAUD;
129 return serial;
130 } else {
131 return NULL;
132 }
Patrick Georgi8c2a0c12008-01-25 18:28:18 +0000133#else
Stefan Reinauer40e42a82011-04-14 21:05:41 +0000134 return NULL;
Patrick Georgi8c2a0c12008-01-25 18:28:18 +0000135#endif
136}
137
Stefan Reinauer5ae31752013-06-19 13:47:46 -0700138#if CONFIG_CONSOLE_SERIAL8250 || CONFIG_CONSOLE_SERIAL8250MEM || \
139 CONFIG_CONSOLE_SERIAL_UART || CONFIG_USBDEBUG
Stefan Reinauerb883d4c2009-08-27 11:23:06 +0000140static void add_console(struct lb_header *header, u16 consoletype)
Patrick Georgi3bbf2ff2008-01-27 14:12:54 +0000141{
Patrick Georgi3bbf2ff2008-01-27 14:12:54 +0000142 struct lb_console *console;
Patrick Georgi16cdbb22009-04-21 20:14:31 +0000143
Patrick Georgi3bbf2ff2008-01-27 14:12:54 +0000144 console = (struct lb_console *)lb_new_record(header);
145 console->tag = LB_TAG_CONSOLE;
146 console->size = sizeof(*console);
147 console->type = consoletype;
148}
Stefan Reinauer513eb5a2011-06-01 14:04:50 -0700149#endif
150
Stefan Reinauerb883d4c2009-08-27 11:23:06 +0000151static void lb_console(struct lb_header *header)
Patrick Georgi3bbf2ff2008-01-27 14:12:54 +0000152{
Myles Watsonec0ee642009-10-19 16:21:30 +0000153#if CONFIG_CONSOLE_SERIAL8250
Patrick Georgi3bbf2ff2008-01-27 14:12:54 +0000154 add_console(header, LB_TAG_CONSOLE_SERIAL8250);
155#endif
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700156#if CONFIG_CONSOLE_SERIAL8250MEM || CONFIG_CONSOLE_SERIAL_UART
Stefan Reinauer4885daa2011-04-26 23:47:04 +0000157 add_console(header, LB_TAG_CONSOLE_SERIAL8250MEM);
158#endif
Stefan Reinauer7e00a442010-05-25 17:09:05 +0000159#if CONFIG_USBDEBUG
Patrick Georgi3bbf2ff2008-01-27 14:12:54 +0000160 add_console(header, LB_TAG_CONSOLE_EHCI);
161#endif
162}
163
Stefan Reinauerd650e992010-02-22 04:33:13 +0000164static void lb_framebuffer(struct lb_header *header)
165{
Ronald G. Minnich69efaa02013-02-26 10:07:40 -0800166#if CONFIG_FRAMEBUFFER_KEEP_VESA_MODE || CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT
Stefan Reinauerd650e992010-02-22 04:33:13 +0000167 void fill_lb_framebuffer(struct lb_framebuffer *framebuffer);
Gabe Blackfb8632a2012-09-30 04:47:48 -0700168 int vbe_mode_info_valid(void);
Stefan Reinauerd650e992010-02-22 04:33:13 +0000169
Gabe Blackfb8632a2012-09-30 04:47:48 -0700170 // If there isn't any mode info to put in the table, don't ask for it
171 // to be filled with junk.
172 if (!vbe_mode_info_valid())
173 return;
Stefan Reinauerd650e992010-02-22 04:33:13 +0000174 struct lb_framebuffer *framebuffer;
175 framebuffer = (struct lb_framebuffer *)lb_new_record(header);
Vladimir Serbinenko617f8532013-11-23 14:46:34 +0100176 fill_lb_framebuffer(framebuffer);
Stefan Reinauerd650e992010-02-22 04:33:13 +0000177 framebuffer->tag = LB_TAG_FRAMEBUFFER;
178 framebuffer->size = sizeof(*framebuffer);
Stefan Reinauerd650e992010-02-22 04:33:13 +0000179#endif
180}
181
Stefan Reinauer31324c62012-04-05 21:22:02 +0200182#if CONFIG_CHROMEOS
183static void lb_gpios(struct lb_header *header)
184{
185 struct lb_gpios *gpios;
186 gpios = (struct lb_gpios *)lb_new_record(header);
187 gpios->tag = LB_TAG_GPIO;
188 gpios->size = sizeof(*gpios);
189 gpios->count = 0;
190 fill_lb_gpios(gpios);
191}
192
193static void lb_vdat(struct lb_header *header)
194{
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700195#if CONFIG_GENERATE_ACPI_TABLES
Stefan Reinauer31324c62012-04-05 21:22:02 +0200196 struct lb_vdat* vdat;
197
198 vdat = (struct lb_vdat *)lb_new_record(header);
199 vdat->tag = LB_TAG_VDAT;
200 vdat->size = sizeof(*vdat);
201 acpi_get_vdat_info(&vdat->vdat_addr, &vdat->vdat_size);
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700202#endif
Stefan Reinauer31324c62012-04-05 21:22:02 +0200203}
204
205static void lb_vbnv(struct lb_header *header)
206{
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700207#if CONFIG_PC80_SYSTEM
Stefan Reinauer31324c62012-04-05 21:22:02 +0200208 struct lb_vbnv* vbnv;
209
210 vbnv = (struct lb_vbnv *)lb_new_record(header);
211 vbnv->tag = LB_TAG_VBNV;
212 vbnv->size = sizeof(*vbnv);
213 vbnv->vbnv_start = CONFIG_VBNV_OFFSET + 14;
214 vbnv->vbnv_size = CONFIG_VBNV_SIZE;
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700215#endif
Stefan Reinauer31324c62012-04-05 21:22:02 +0200216}
Aaron Durbindd32a312013-03-07 23:15:06 -0600217
218#if CONFIG_VBOOT_VERIFY_FIRMWARE
219static void lb_vboot_handoff(struct lb_header *header)
220{
221 void *addr;
222 uint32_t size;
223 struct lb_vboot_handoff* vbho;
224
225 if (vboot_get_handoff_info(&addr, &size))
226 return;
227
228 vbho = (struct lb_vboot_handoff *)lb_new_record(header);
229 vbho->tag = LB_TAB_VBOOT_HANDOFF;
230 vbho->size = sizeof(*vbho);
Stefan Reinauer642b1db72013-04-18 18:01:34 -0700231 vbho->vboot_handoff_addr = (intptr_t)addr;
Aaron Durbindd32a312013-03-07 23:15:06 -0600232 vbho->vboot_handoff_size = size;
233}
234#else
235static inline void lb_vboot_handoff(struct lb_header *header) {}
236#endif /* CONFIG_VBOOT_VERIFY_FIRMWARE */
237#endif /* CONFIG_CHROMEOS */
Stefan Reinauer31324c62012-04-05 21:22:02 +0200238
Vadim Bendebury22c04682011-10-03 14:58:57 -0700239static void add_cbmem_pointers(struct lb_header *header)
Vadim Bendebury2e438672011-09-23 09:56:11 -0700240{
Vadim Bendebury22c04682011-10-03 14:58:57 -0700241 /*
242 * These CBMEM sections' addresses are included in the coreboot table
243 * with the appropriate tags.
244 */
245 const struct section_id {
246 int cbmem_id;
247 int table_tag;
248 } section_ids[] = {
249 {CBMEM_ID_TIMESTAMP, LB_TAG_TIMESTAMPS},
Duncan Laurie16e899b2013-12-12 10:43:21 -0800250 {CBMEM_ID_CONSOLE, LB_TAG_CBMEM_CONSOLE},
251 {CBMEM_ID_ACPI_GNVS, LB_TAG_ACPI_GNVS},
Vadim Bendebury22c04682011-10-03 14:58:57 -0700252 };
253 int i;
Vadim Bendebury2e438672011-09-23 09:56:11 -0700254
Vadim Bendebury22c04682011-10-03 14:58:57 -0700255 for (i = 0; i < ARRAY_SIZE(section_ids); i++) {
256 const struct section_id *sid = section_ids + i;
257 struct lb_cbmem_ref *cbmem_ref;
258 void *cbmem_addr = cbmem_find(sid->cbmem_id);
Vadim Bendebury2e438672011-09-23 09:56:11 -0700259
Vadim Bendebury22c04682011-10-03 14:58:57 -0700260 if (!cbmem_addr)
261 continue; /* This section is not present */
Vadim Bendebury2e438672011-09-23 09:56:11 -0700262
Vadim Bendebury22c04682011-10-03 14:58:57 -0700263 cbmem_ref = (struct lb_cbmem_ref *)lb_new_record(header);
264 if (!cbmem_ref) {
265 printk(BIOS_ERR, "No more room in coreboot table!\n");
266 break;
267 }
268 cbmem_ref->tag = sid->table_tag;
269 cbmem_ref->size = sizeof(*cbmem_ref);
Stefan Reinauerb8ad2242013-01-11 10:41:42 -0800270 cbmem_ref->cbmem_addr = (unsigned long)cbmem_addr;
Vadim Bendebury22c04682011-10-03 14:58:57 -0700271 }
Vadim Bendebury2e438672011-09-23 09:56:11 -0700272}
Vadim Bendebury2e438672011-09-23 09:56:11 -0700273
Stefan Reinauere3778572010-01-30 09:47:18 +0000274static struct lb_mainboard *lb_mainboard(struct lb_header *header)
Eric Biederman8ca8d762003-04-22 19:02:15 +0000275{
276 struct lb_record *rec;
277 struct lb_mainboard *mainboard;
278 rec = lb_new_record(header);
279 mainboard = (struct lb_mainboard *)rec;
280 mainboard->tag = LB_TAG_MAINBOARD;
281
282 mainboard->size = (sizeof(*mainboard) +
Stefan Reinauer14e22772010-04-27 06:56:47 +0000283 strlen(mainboard_vendor) + 1 +
Eric Biederman8ca8d762003-04-22 19:02:15 +0000284 strlen(mainboard_part_number) + 1 +
285 3) & ~3;
286
287 mainboard->vendor_idx = 0;
288 mainboard->part_number_idx = strlen(mainboard_vendor) + 1;
289
290 memcpy(mainboard->strings + mainboard->vendor_idx,
291 mainboard_vendor, strlen(mainboard_vendor) + 1);
292 memcpy(mainboard->strings + mainboard->part_number_idx,
293 mainboard_part_number, strlen(mainboard_part_number) + 1);
294
295 return mainboard;
296}
297
Stefan Reinauerb883d4c2009-08-27 11:23:06 +0000298static void lb_strings(struct lb_header *header)
Eric Biederman8ca8d762003-04-22 19:02:15 +0000299{
300 static const struct {
301 uint32_t tag;
Stefan Reinauer0dff6e32007-10-23 22:17:45 +0000302 const char *string;
Eric Biederman8ca8d762003-04-22 19:02:15 +0000303 } strings[] = {
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000304 { LB_TAG_VERSION, coreboot_version, },
305 { LB_TAG_EXTRA_VERSION, coreboot_extra_version, },
306 { LB_TAG_BUILD, coreboot_build, },
307 { LB_TAG_COMPILE_TIME, coreboot_compile_time, },
308 { LB_TAG_COMPILE_BY, coreboot_compile_by, },
309 { LB_TAG_COMPILE_HOST, coreboot_compile_host, },
310 { LB_TAG_COMPILE_DOMAIN, coreboot_compile_domain, },
311 { LB_TAG_COMPILER, coreboot_compiler, },
312 { LB_TAG_LINKER, coreboot_linker, },
313 { LB_TAG_ASSEMBLER, coreboot_assembler, },
Eric Biederman8ca8d762003-04-22 19:02:15 +0000314 };
Eric Biederman52685572003-05-19 19:16:21 +0000315 unsigned int i;
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +0000316 for(i = 0; i < ARRAY_SIZE(strings); i++) {
Eric Biederman8ca8d762003-04-22 19:02:15 +0000317 struct lb_string *rec;
318 size_t len;
319 rec = (struct lb_string *)lb_new_record(header);
320 len = strlen(strings[i].string);
321 rec->tag = strings[i].tag;
322 rec->size = (sizeof(*rec) + len + 1 + 3) & ~3;
323 memcpy(rec->string, strings[i].string, len+1);
324 }
325
326}
327
Stefan Reinauerb883d4c2009-08-27 11:23:06 +0000328static struct lb_forward *lb_forward(struct lb_header *header, struct lb_header *next_header)
Stefan Reinauerefab4ba2009-03-17 14:38:48 +0000329{
330 struct lb_record *rec;
331 struct lb_forward *forward;
332 rec = lb_new_record(header);
333 forward = (struct lb_forward *)rec;
334 forward->tag = LB_TAG_FORWARD;
335 forward->size = sizeof(*forward);
Stefan Reinauerdf77f342009-04-06 14:00:53 +0000336 forward->forward = (uint64_t)(unsigned long)next_header;
Stefan Reinauerefab4ba2009-03-17 14:38:48 +0000337 return forward;
338}
339
Aaron Durbin28adb6e2013-03-23 00:06:36 -0500340static unsigned long lb_table_fini(struct lb_header *head)
Eric Biederman8ca8d762003-04-22 19:02:15 +0000341{
342 struct lb_record *rec, *first_rec;
343 rec = lb_last_record(head);
344 if (head->table_entries) {
345 head->table_bytes += rec->size;
346 }
Stefan Reinauerefab4ba2009-03-17 14:38:48 +0000347
Eric Biederman8ca8d762003-04-22 19:02:15 +0000348 first_rec = lb_first_record(head);
349 head->table_checksum = compute_ip_checksum(first_rec, head->table_bytes);
350 head->header_checksum = 0;
351 head->header_checksum = compute_ip_checksum(head, sizeof(*head));
Vadim Bendebury05239892011-08-16 11:44:35 -0700352 printk(BIOS_DEBUG,
353 "Wrote coreboot table at: %p, 0x%x bytes, checksum %x\n",
354 head, head->table_bytes, head->table_checksum);
355 return (unsigned long)rec + rec->size;
Eric Biederman8ca8d762003-04-22 19:02:15 +0000356}
357
Stefan Reinauer14e22772010-04-27 06:56:47 +0000358unsigned long write_coreboot_table(
359 unsigned long low_table_start, unsigned long low_table_end,
Stefan Reinauer4f1cb232006-07-19 15:32:49 +0000360 unsigned long rom_table_start, unsigned long rom_table_end)
Eric Biederman8ca8d762003-04-22 19:02:15 +0000361{
Eric Biederman8ca8d762003-04-22 19:02:15 +0000362 struct lb_header *head;
Eric Biederman8ca8d762003-04-22 19:02:15 +0000363
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700364 if (low_table_start || low_table_end) {
365 printk(BIOS_DEBUG, "Writing table forward entry at 0x%08lx\n",
366 low_table_end);
367 head = lb_table_init(low_table_end);
368 lb_forward(head, (struct lb_header*)rom_table_end);
Stefan Reinauerefab4ba2009-03-17 14:38:48 +0000369
Aaron Durbin28adb6e2013-03-23 00:06:36 -0500370 low_table_end = (unsigned long) lb_table_fini(head);
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700371 printk(BIOS_DEBUG, "Table forward entry ends at 0x%08lx.\n",
372 low_table_end);
373 low_table_end = ALIGN(low_table_end, 4096);
374 printk(BIOS_DEBUG, "... aligned to 0x%08lx\n", low_table_end);
375 }
376
377 printk(BIOS_DEBUG, "Writing coreboot table at 0x%08lx\n",
378 rom_table_end);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000379
Stefan Reinauerefab4ba2009-03-17 14:38:48 +0000380 head = lb_table_init(rom_table_end);
381 rom_table_end = (unsigned long)head;
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000382 printk(BIOS_DEBUG, "rom_table_end = 0x%08lx\n", rom_table_end);
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700383 rom_table_end = ALIGN(rom_table_end, (64 * 1024));
384 printk(BIOS_DEBUG, "... aligned to 0x%08lx\n", rom_table_end);
Stefan Reinauer4f1cb232006-07-19 15:32:49 +0000385
Stefan Reinauerc75bfde2011-08-15 11:26:35 -0700386#if CONFIG_USE_OPTION_TABLE
Stefan Reinauerba430642007-04-06 12:14:51 +0000387 {
Hung-Te Lin6fe0cab2013-01-22 18:57:56 +0800388 struct cmos_option_table *option_table = cbfs_get_file_content(
389 CBFS_DEFAULT_MEDIA, "cmos_layout.bin",
Vladimir Serbinenko0af61b62014-01-12 13:45:52 +0100390 CBFS_COMPONENT_CMOS_LAYOUT, NULL);
Patrick Georgi24479372011-01-18 13:56:36 +0000391 if (option_table) {
392 struct lb_record *rec_dest = lb_new_record(head);
393 /* Copy the option config table, it's already a lb_record... */
Josef Kellermann679d38b2011-01-24 21:07:57 +0000394 memcpy(rec_dest, option_table, option_table->size);
Patrick Georgicef3b892011-01-18 14:28:45 +0000395 } else {
396 printk(BIOS_ERR, "cmos_layout.bin could not be found!\n");
Patrick Georgi24479372011-01-18 13:56:36 +0000397 }
Eric Biederman8ca8d762003-04-22 19:02:15 +0000398 }
Stefan Reinauerba430642007-04-06 12:14:51 +0000399#endif
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700400
Aaron Durbin49048022014-02-18 21:55:02 -0600401 /* Initialize the memory map at boot time. */
402 bootmem_init();
Stefan Reinauer14e22772010-04-27 06:56:47 +0000403
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700404 if (low_table_start || low_table_end) {
Aaron Durbin49048022014-02-18 21:55:02 -0600405 uint64_t size = low_table_end - low_table_start;
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700406 /* Record the mptable and the the lb_table.
407 * (This will be adjusted later) */
Aaron Durbin49048022014-02-18 21:55:02 -0600408 bootmem_add_range(low_table_start, size, LB_MEM_TABLE);
Stefan Reinauer3e4e3032013-03-20 14:08:04 -0700409 }
Eric Biederman6e53f502004-10-27 08:53:57 +0000410
Aaron Durbindf3a1092013-03-13 12:41:44 -0500411 /* Record the pirq table, acpi tables, and maybe the mptable. However,
412 * these only need to be added when the rom_table is sitting below
413 * 1MiB. If it isn't that means high tables are being written.
414 * The code below handles high tables correctly. */
Aaron Durbin49048022014-02-18 21:55:02 -0600415 if (rom_table_end <= (1 << 20)) {
416 uint64_t size = rom_table_end - rom_table_start;
417 bootmem_add_range(rom_table_start, size, LB_MEM_TABLE);
418 }
Patrick Georgibccaafc2009-04-28 12:57:25 +0000419
Aaron Durbin28adb6e2013-03-23 00:06:36 -0500420 /* No other memory areas can be added after the memory table has been
421 * committed as the entries won't show up in the serialize mem table. */
Aaron Durbin2d5cec62014-02-25 00:24:22 -0600422 bootmem_write_memory_table(lb_memory(head));
Eric Biederman8ca8d762003-04-22 19:02:15 +0000423
Patrick Georgi8c2a0c12008-01-25 18:28:18 +0000424 /* Record our motherboard */
Eric Biederman8ca8d762003-04-22 19:02:15 +0000425 lb_mainboard(head);
Patrick Georgi8c2a0c12008-01-25 18:28:18 +0000426 /* Record the serial port, if present */
427 lb_serial(head);
Patrick Georgi3bbf2ff2008-01-27 14:12:54 +0000428 /* Record our console setup */
429 lb_console(head);
Eric Biederman8ca8d762003-04-22 19:02:15 +0000430 /* Record our various random string information */
431 lb_strings(head);
Stefan Reinauerd650e992010-02-22 04:33:13 +0000432 /* Record our framebuffer */
433 lb_framebuffer(head);
Eric Biederman8ca8d762003-04-22 19:02:15 +0000434
Stefan Reinauer31324c62012-04-05 21:22:02 +0200435#if CONFIG_CHROMEOS
436 /* Record our GPIO settings (ChromeOS specific) */
437 lb_gpios(head);
438
Martin Rothcbf2bd72013-07-09 21:51:14 -0600439 /* pass along the VDAT buffer address */
Stefan Reinauer31324c62012-04-05 21:22:02 +0200440 lb_vdat(head);
441
442 /* pass along VBNV offsets in CMOS */
443 lb_vbnv(head);
Aaron Durbindd32a312013-03-07 23:15:06 -0600444
445 /* pass along the vboot_handoff address. */
446 lb_vboot_handoff(head);
Stefan Reinauer31324c62012-04-05 21:22:02 +0200447#endif
Vadim Bendebury22c04682011-10-03 14:58:57 -0700448 add_cbmem_pointers(head);
449
Eric Biederman8ca8d762003-04-22 19:02:15 +0000450 /* Remember where my valid memory ranges are */
Aaron Durbin28adb6e2013-03-23 00:06:36 -0500451 return lb_table_fini(head);
Eric Biederman8ca8d762003-04-22 19:02:15 +0000452}