blob: e2e137c1bc6de413b7958ace9e14273bc5791037 [file] [log] [blame]
Paul Burtone8530032014-06-14 00:00:10 +01001/*
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 Burtone8530032014-06-14 00:00:10 +010017 */
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 Georgi6f723c22015-03-30 14:06:33 +020029void write_tables(void)
Paul Burtone8530032014-06-14 00:00:10 +010030{
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 Georgi6f723c22015-03-30 14:06:33 +020039 return;
Paul Burtone8530032014-06-14 00:00:10 +010040 }
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 Burtone8530032014-06-14 00:00:10 +010057}