Paul Burton | e853003 | 2014-06-14 00:00:10 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Based on src/arch/armv7/tables.c: |
| 5 | * Copyright (C) 2003 Eric Biederman |
| 6 | * Copyright (C) 2005 Steve Magnani |
| 7 | * Copyright (C) 2008-2009 coresystems GmbH |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; version 2 of the License. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
Paul Burton | e853003 | 2014-06-14 00:00:10 +0100 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #include <console/console.h> |
| 20 | #include <cpu/cpu.h> |
| 21 | #include <boot/tables.h> |
| 22 | #include <boot/coreboot_tables.h> |
| 23 | #include <string.h> |
| 24 | #include <cbmem.h> |
| 25 | #include <lib.h> |
| 26 | |
| 27 | #define MAX_COREBOOT_TABLE_SIZE (8 * 1024) |
| 28 | |
Patrick Georgi | 6f723c2 | 2015-03-30 14:06:33 +0200 | [diff] [blame] | 29 | void write_tables(void) |
Paul Burton | e853003 | 2014-06-14 00:00:10 +0100 | [diff] [blame] | 30 | { |
| 31 | unsigned long table_pointer, new_table_pointer; |
| 32 | |
| 33 | post_code(0x9d); |
| 34 | |
| 35 | table_pointer = (unsigned long)cbmem_add(CBMEM_ID_CBTABLE, |
| 36 | MAX_COREBOOT_TABLE_SIZE); |
| 37 | if (!table_pointer) { |
| 38 | printk(BIOS_ERR, "Could not add CBMEM for coreboot table.\n"); |
Patrick Georgi | 6f723c2 | 2015-03-30 14:06:33 +0200 | [diff] [blame] | 39 | return; |
Paul Burton | e853003 | 2014-06-14 00:00:10 +0100 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | new_table_pointer = write_coreboot_table(0UL, 0UL, table_pointer, |
| 43 | table_pointer); |
| 44 | |
| 45 | if (new_table_pointer > (table_pointer + MAX_COREBOOT_TABLE_SIZE)) |
| 46 | printk(BIOS_ERR, "coreboot table didn't fit (%lx/%x bytes)\n", |
| 47 | new_table_pointer - table_pointer, |
| 48 | MAX_COREBOOT_TABLE_SIZE); |
| 49 | |
| 50 | printk(BIOS_DEBUG, "coreboot table: %ld bytes.\n", |
| 51 | new_table_pointer - table_pointer); |
| 52 | |
| 53 | post_code(0x9e); |
| 54 | |
| 55 | /* Print CBMEM sections */ |
| 56 | cbmem_list(); |
Paul Burton | e853003 | 2014-06-14 00:00:10 +0100 | [diff] [blame] | 57 | } |