Furquan Shaikh | 2af76f4 | 2014-04-28 16:39:40 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2003 Eric Biederman |
| 5 | * Copyright (C) 2005 Steve Magnani |
| 6 | * Copyright (C) 2008-2009 coresystems GmbH |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of 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, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #include <console/console.h> |
| 23 | #include <cpu/cpu.h> |
| 24 | #include <boot/tables.h> |
| 25 | #include <boot/coreboot_tables.h> |
| 26 | #include <string.h> |
| 27 | #include <cbmem.h> |
| 28 | #include <lib.h> |
| 29 | |
| 30 | #define MAX_COREBOOT_TABLE_SIZE (8 * 1024) |
| 31 | |
Marc Jones | 17b9c19 | 2015-01-16 13:45:23 -0700 | [diff] [blame] | 32 | void write_tables(void) |
Furquan Shaikh | 2af76f4 | 2014-04-28 16:39:40 -0700 | [diff] [blame] | 33 | { |
| 34 | unsigned long table_pointer, new_table_pointer; |
| 35 | |
Furquan Shaikh | 2af76f4 | 2014-04-28 16:39:40 -0700 | [diff] [blame] | 36 | post_code(0x9d); |
| 37 | |
| 38 | table_pointer = (unsigned long)cbmem_add(CBMEM_ID_CBTABLE, |
| 39 | MAX_COREBOOT_TABLE_SIZE); |
| 40 | if (!table_pointer) { |
| 41 | printk(BIOS_ERR, "Could not add CBMEM for coreboot table.\n"); |
Marc Jones | 17b9c19 | 2015-01-16 13:45:23 -0700 | [diff] [blame] | 42 | return; |
Furquan Shaikh | 2af76f4 | 2014-04-28 16:39:40 -0700 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | new_table_pointer = write_coreboot_table(0UL, 0UL, |
| 46 | table_pointer, table_pointer); |
| 47 | |
| 48 | if (new_table_pointer > (table_pointer + MAX_COREBOOT_TABLE_SIZE)) { |
| 49 | printk(BIOS_ERR, "coreboot table didn't fit (%lx/%x bytes)\n", |
| 50 | new_table_pointer - table_pointer, MAX_COREBOOT_TABLE_SIZE); |
| 51 | } |
| 52 | |
| 53 | printk(BIOS_DEBUG, "coreboot table: %ld bytes.\n", |
| 54 | new_table_pointer - table_pointer); |
| 55 | |
| 56 | post_code(0x9e); |
| 57 | |
| 58 | /* Print CBMEM sections */ |
| 59 | cbmem_list(); |
Furquan Shaikh | 2af76f4 | 2014-04-28 16:39:40 -0700 | [diff] [blame] | 60 | } |