1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2013, 2014 Vladimir Serbinenko
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 or (at your option)
* any later version of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <arch/io.h>
#include <console/console.h>
#include <delay.h>
#include <device/device.h>
#include <string.h>
#include <device/pci_rom.h>
#include "i915.h"
#include "intel_bios.h"
static size_t generate_vbt(const struct i915_gpu_controller_info *conf,
void *vbt, const char *idstr)
{
struct vbt_header *head = vbt;
struct bdb_header *bdb_head;
struct bdb_general_features *genfeat;
u8 *ptr;
memset(head, 0, sizeof (*head));
memset(head->signature, ' ', sizeof(head->signature));
memcpy(head->signature, idstr, MIN(strlen(idstr),
sizeof(head->signature)));
head->version = 100;
head->header_size = sizeof (*head);
head->bdb_offset = sizeof (*head);
bdb_head = (struct bdb_header *) (head + 1);
memset(bdb_head, 0, sizeof (*bdb_head));
memcpy(bdb_head->signature, "BIOS_DATA_BLOCK ", 16);
bdb_head->version = 0xa8;
bdb_head->header_size = sizeof (*bdb_head);
ptr = (u8 *) (bdb_head + 1);
ptr[0] = BDB_GENERAL_FEATURES;
ptr[1] = sizeof (*genfeat);
ptr[2] = sizeof (*genfeat) >> 8;
ptr += 3;
genfeat = (struct bdb_general_features *) ptr;
memset(genfeat, 0, sizeof (*genfeat));
genfeat->panel_fitting = 3;
genfeat->flexaim = 1;
genfeat->download_ext_vbt = 1;
genfeat->enable_ssc = conf->use_spread_spectrum_clock;
genfeat->ssc_freq = !conf->link_frequency_270_mhz;
genfeat->rsvd10 = 0x4;
genfeat->legacy_monitor_detect = 1;
genfeat->int_crt_support = 1;
genfeat->dp_ssc_enb = 1;
ptr += sizeof (*genfeat);
bdb_head->bdb_size = ptr - (u8 *)bdb_head;
head->vbt_size = ptr - (u8 *)head;
head->vbt_checksum = 0;
return ptr - (u8 *)head;
}
void
generate_fake_intel_oprom(const struct i915_gpu_controller_info *conf,
struct device *dev, const char *idstr)
{
optionrom_header_t *oh = (void *)PCI_VGA_RAM_IMAGE_START;
optionrom_pcir_t *pcir;
size_t vbt_size;
size_t fake_oprom_size;
memset(oh, 0, 8192);
oh->signature = PCI_ROM_HDR;
oh->pcir_offset = 0x40;
oh->vbt_offset = 0x80;
pcir = (void *)(PCI_VGA_RAM_IMAGE_START + 0x40);
pcir->signature = 0x52494350; // PCIR
pcir->vendor = dev->vendor;
pcir->device = dev->device;
pcir->length = sizeof(*pcir);
pcir->revision = dev->class;
pcir->classcode[0] = dev->class;
pcir->classcode[1] = dev->class >> 8;
pcir->classcode[2] = dev->class >> 16;
pcir->indicator = 0x80;
vbt_size = generate_vbt (conf, (void *)(PCI_VGA_RAM_IMAGE_START + 0x80), idstr);
fake_oprom_size = (0x80 + vbt_size + 511) / 512;
oh->size = fake_oprom_size;
pcir->imagelength = fake_oprom_size;
}
|