Ronald G. Minnich | e0e784a | 2014-11-26 19:25:47 +0000 | [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 | |
| 32 | #if ! IS_ENABLED(CONFIG_DYNAMIC_CBMEM) |
| 33 | /* |
| 34 | * TODO: "High" tables are a convention used on x86. Maybe we can |
| 35 | * clean up that naming at some point. |
| 36 | */ |
| 37 | uint64_t high_tables_base = 0; |
| 38 | uint64_t high_tables_size; |
| 39 | #endif |
| 40 | |
| 41 | void cbmem_arch_init(void) |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | // WTF. this does not agre with the prototype! |
| 46 | static struct lb_memory *wtf_write_tables(void) |
| 47 | { |
| 48 | unsigned long table_pointer, new_table_pointer; |
| 49 | |
| 50 | #if ! IS_ENABLED(CONFIG_DYNAMIC_CBMEM) |
| 51 | if (!high_tables_base) { |
| 52 | printk(BIOS_ERR, "ERROR: high_tables_base is not set.\n"); |
| 53 | } |
| 54 | |
| 55 | printk(BIOS_DEBUG, "high_tables_base: %llx.\n", high_tables_base); |
| 56 | #endif |
| 57 | |
| 58 | post_code(0x9d); |
| 59 | |
| 60 | table_pointer = (unsigned long)cbmem_add(CBMEM_ID_CBTABLE, |
| 61 | MAX_COREBOOT_TABLE_SIZE); |
| 62 | if (!table_pointer) { |
| 63 | printk(BIOS_ERR, "Could not add CBMEM for coreboot table.\n"); |
| 64 | return NULL; |
| 65 | } |
| 66 | |
| 67 | new_table_pointer = write_coreboot_table(0UL, 0UL, |
| 68 | table_pointer, table_pointer); |
| 69 | |
| 70 | if (new_table_pointer > (table_pointer + MAX_COREBOOT_TABLE_SIZE)) { |
| 71 | printk(BIOS_ERR, "coreboot table didn't fit (%lx/%x bytes)\n", |
| 72 | new_table_pointer - table_pointer, MAX_COREBOOT_TABLE_SIZE); |
| 73 | } |
| 74 | |
| 75 | printk(BIOS_DEBUG, "coreboot table: %ld bytes.\n", |
| 76 | new_table_pointer - table_pointer); |
| 77 | |
| 78 | post_code(0x9e); |
| 79 | |
| 80 | /* Print CBMEM sections */ |
| 81 | cbmem_list(); |
| 82 | |
| 83 | // return get_lb_mem(); |
| 84 | return NULL; |
| 85 | } |
| 86 | void write_tables(void) |
| 87 | { |
| 88 | wtf_write_tables(); |
| 89 | } |
| 90 | |
| 91 | void cbmem_fail_resume(void) |
| 92 | { |
| 93 | } |
| 94 | void get_cbmem_table(uint64_t *base, uint64_t *size) |
| 95 | { |
| 96 | } |