blob: dbaead982af0bcf6f06881147dbb1e0b731f639c [file] [log] [blame]
Gerd Hoffmannee941b382013-06-07 16:03:44 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2004 Stefan Reinauer
Patrick Rudolph1af89232018-11-11 12:50:51 +01005 * Copyright (C) 2018 Patrick Rudolph <siro@das-labor.org>
Gerd Hoffmannee941b382013-06-07 16:03:44 +02006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Gerd Hoffmannee941b382013-06-07 16:03:44 +020015 */
16
Kyösti Mälkki6e2d0c12019-06-28 10:08:51 +030017#include <arch/cpu.h>
Gerd Hoffmannee941b382013-06-07 16:03:44 +020018#include <stdint.h>
Patrick Rudolph69d5ef92018-11-11 12:43:48 +010019#include <cbmem.h>
Gerd Hoffmannee941b382013-06-07 16:03:44 +020020#include <console/console.h>
Kyösti Mälkkic6986fa2016-06-17 10:35:29 +030021#include <cpu/intel/romstage.h>
Gerd Hoffmannee941b382013-06-07 16:03:44 +020022#include <timestamp.h>
Patrick Rudolph1af89232018-11-11 12:50:51 +010023#include <southbridge/intel/i82801ix/i82801ix.h>
24#include <program_loading.h>
Patrick Rudolphfbdeb4a2019-02-14 19:47:03 +010025#include <device/pci_ops.h>
26
27#define D0F0_PCIEXBAR_LO 0x60
28
29static void mainboard_machine_check(void)
30{
31 /* Check that MCFG is active. If it's not qemu was started for machine PC */
32 if (!CONFIG(BOOTBLOCK_CONSOLE) &&
33 (pci_read_config32(PCI_DEV(0, 0, 0), D0F0_PCIEXBAR_LO) !=
34 (CONFIG_MMCONF_BASE_ADDRESS | 1)))
35 die("You must run qemu for machine Q35 (-M q35)");
36}
Gerd Hoffmannee941b382013-06-07 16:03:44 +020037
Patrick Rudolph1af89232018-11-11 12:50:51 +010038asmlinkage void car_stage_entry(void)
Gerd Hoffmannee941b382013-06-07 16:03:44 +020039{
Arthur Heymans65200f02018-12-20 11:23:56 +010040 struct postcar_frame pcf;
Gerd Hoffmannee941b382013-06-07 16:03:44 +020041 i82801ix_early_init();
42 console_init();
43
Patrick Rudolphfbdeb4a2019-02-14 19:47:03 +010044 mainboard_machine_check();
45
Patrick Rudolph1af89232018-11-11 12:50:51 +010046 cbmem_recovery(0);
Gerd Hoffmannee941b382013-06-07 16:03:44 +020047
Gerd Hoffmannee941b382013-06-07 16:03:44 +020048 timestamp_add_now(TS_START_ROMSTAGE);
Gerd Hoffmannee941b382013-06-07 16:03:44 +020049
Kyösti Mälkki6e2d0c12019-06-28 10:08:51 +030050 if (postcar_frame_init(&pcf, 0))
Arthur Heymans65200f02018-12-20 11:23:56 +010051 die("Unable to initialize postcar frame.\n");
52
53 /**
54 * Run postcar to tear down CAR and load relocatable ramstage.
55 * There's no CAR on qemu, but for educational purposes and
56 * testing the postcar stage is used on qemu, too.
57 */
58
59 run_postcar_phase(&pcf);
Gerd Hoffmannee941b382013-06-07 16:03:44 +020060}