blob: d9bb98a8d10310ea02301d30781953f09b028562 [file] [log] [blame]
Andrey Petrov060b2152016-05-13 15:27:42 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016 Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <cbfs.h>
17#include <console/console.h>
Abhay Kumarec2947f2016-07-14 18:43:54 -070018#include <arch/acpi.h>
19#include <bootmode.h>
Andrey Petrov060b2152016-05-13 15:27:42 -070020
21#include "vbt.h"
22
23#define VBT_SIGNATURE 0x54425624
24
25enum cb_err locate_vbt(struct region_device *rdev)
26{
27 uint32_t vbtsig = 0;
28 struct cbfsf file_desc;
29
30 if (cbfs_boot_locate(&file_desc, "vbt.bin", NULL) < 0) {
31 printk(BIOS_ERR, "Could not locate a VBT file in in CBFS\n");
32 return CB_ERR;
33 }
34
35 cbfs_file_data(rdev, &file_desc);
36 rdev_readat(rdev, &vbtsig, 0, sizeof(uint32_t));
37
38 if (vbtsig != VBT_SIGNATURE) {
39 printk(BIOS_ERR, "Missing/invalid signature in VBT data file!\n");
40 return CB_ERR;
41 }
42
43 return CB_SUCCESS;
44}
Abhay Kumarec2947f2016-07-14 18:43:54 -070045
46void *vbt_get(struct region_device *rdev)
47{
48 void *vbt_data;
49
50 /* Normal mode and S3 resume path PEIM GFX init is not needed.
51 * Passing NULL as VBT will not make PEIM GFX to execute. */
52 if (acpi_is_wakeup_s3())
53 return NULL;
54 if (!display_init_required())
55 return NULL;
56 if (locate_vbt(rdev) != CB_ERR) {
57 vbt_data = rdev_mmap_full(rdev);
58 return vbt_data;
59 } else {
60 return NULL;
61 }
62}