Andrey Petrov | 060b215 | 2016-05-13 15:27:42 -0700 | [diff] [blame] | 1 | /* |
| 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 Kumar | ec2947f | 2016-07-14 18:43:54 -0700 | [diff] [blame] | 18 | #include <arch/acpi.h> |
| 19 | #include <bootmode.h> |
Andrey Petrov | 060b215 | 2016-05-13 15:27:42 -0700 | [diff] [blame] | 20 | |
| 21 | #include "vbt.h" |
| 22 | |
| 23 | #define VBT_SIGNATURE 0x54425624 |
| 24 | |
| 25 | enum 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 Kumar | ec2947f | 2016-07-14 18:43:54 -0700 | [diff] [blame] | 45 | |
| 46 | void *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 | } |