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. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | */ |
| 22 | |
| 23 | #include <console/console.h> |
| 24 | #include <cpu/cpu.h> |
| 25 | #include <boot/tables.h> |
| 26 | #include <boot/coreboot_tables.h> |
| 27 | #include <string.h> |
| 28 | #include <cbmem.h> |
| 29 | #include <lib.h> |
| 30 | |
| 31 | #define MAX_COREBOOT_TABLE_SIZE (8 * 1024) |
| 32 | |
Patrick Georgi | 6f723c2 | 2015-03-30 14:06:33 +0200 | [diff] [blame^] | 33 | void write_tables(void) |
Paul Burton | e853003 | 2014-06-14 00:00:10 +0100 | [diff] [blame] | 34 | { |
| 35 | unsigned long table_pointer, new_table_pointer; |
| 36 | |
| 37 | post_code(0x9d); |
| 38 | |
| 39 | table_pointer = (unsigned long)cbmem_add(CBMEM_ID_CBTABLE, |
| 40 | MAX_COREBOOT_TABLE_SIZE); |
| 41 | if (!table_pointer) { |
| 42 | printk(BIOS_ERR, "Could not add CBMEM for coreboot table.\n"); |
Patrick Georgi | 6f723c2 | 2015-03-30 14:06:33 +0200 | [diff] [blame^] | 43 | return; |
Paul Burton | e853003 | 2014-06-14 00:00:10 +0100 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | new_table_pointer = write_coreboot_table(0UL, 0UL, table_pointer, |
| 47 | table_pointer); |
| 48 | |
| 49 | if (new_table_pointer > (table_pointer + MAX_COREBOOT_TABLE_SIZE)) |
| 50 | printk(BIOS_ERR, "coreboot table didn't fit (%lx/%x bytes)\n", |
| 51 | new_table_pointer - table_pointer, |
| 52 | MAX_COREBOOT_TABLE_SIZE); |
| 53 | |
| 54 | printk(BIOS_DEBUG, "coreboot table: %ld bytes.\n", |
| 55 | new_table_pointer - table_pointer); |
| 56 | |
| 57 | post_code(0x9e); |
| 58 | |
| 59 | /* Print CBMEM sections */ |
| 60 | cbmem_list(); |
Paul Burton | e853003 | 2014-06-14 00:00:10 +0100 | [diff] [blame] | 61 | } |