| 595 | } |
| 596 | |
| 597 | void *write_tables(void) |
| 598 | { |
| 599 | uintptr_t cbtable_start; |
| 600 | uintptr_t cbtable_end; |
| 601 | size_t cbtable_size; |
| 602 | const size_t max_table_size = COREBOOT_TABLE_SIZE; |
| 603 | |
| 604 | cbtable_start = (uintptr_t)cbmem_add(CBMEM_ID_CBTABLE, max_table_size); |
| 605 | |
| 606 | if (!cbtable_start) { |
| 607 | printk(BIOS_ERR, "Could not add CBMEM for coreboot table.\n"); |
| 608 | return NULL; |
| 609 | } |
| 610 | |
| 611 | /* Add architecture specific tables. */ |
| 612 | arch_write_tables(cbtable_start); |
| 613 | |
| 614 | /* Write the coreboot table. */ |
| 615 | cbtable_end = write_coreboot_table(cbtable_start); |
| 616 | cbtable_size = cbtable_end - cbtable_start; |
| 617 | |
| 618 | if (cbtable_size > max_table_size) { |
| 619 | printk(BIOS_ERR, "%s: coreboot table didn't fit (%zx/%zx)\n", |
| 620 | __func__, cbtable_size, max_table_size); |
| 621 | } |
| 622 | |
| 623 | printk(BIOS_DEBUG, "coreboot table: %zd bytes.\n", cbtable_size); |
| 624 | |
| 625 | /* Print CBMEM sections */ |
| 626 | cbmem_list(); |
| 627 | return (void *)cbtable_start; |
| 628 | } |