~ubuntu-branches/ubuntu/saucy/seabios/saucy-proposed

« back to all changes in this revision

Viewing changes to src/shadow.c

  • Committer: Package Import Robot
  • Author(s): Michael Tokarev
  • Date: 2013-07-08 21:34:44 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20130708213444-6ed9q23j39x143lu
Tags: 1.7.3-1
Multi-Arch: allowed

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#include "config.h" // CONFIG_*
11
11
#include "pci_ids.h" // PCI_VENDOR_ID_INTEL
12
12
#include "pci_regs.h" // PCI_VENDOR_ID
13
 
#include "xen.h" // usingXen
 
13
#include "paravirt.h" // runningOnXen
14
14
#include "dev-q35.h" // PCI_VENDOR_ID_INTEL
15
15
 
16
16
// On the emulators, the bios at 0xf0000 is also at 0xffff0000
80
80
    wbinvd();
81
81
 
82
82
    // Write protect roms from 0xc0000-0xf0000
83
 
    u32 romend = rom_get_last(), romtop = rom_get_top();
 
83
    u32 romend = rom_get_last(), romtop = rom_get_max();
84
84
    int i;
85
85
    for (i=0; i<6; i++) {
86
86
        u32 mem = BUILD_ROM_START + i * 32*1024;
97
97
    pci_config_writeb(bdf, pam0, 0x10);
98
98
}
99
99
 
100
 
static void i440fx_bios_make_readonly(struct pci_device *pci, void *arg)
101
 
{
102
 
    make_bios_readonly_intel(pci->bdf, I440FX_PAM0);
103
 
}
104
 
 
105
 
void mch_bios_make_readonly(struct pci_device *pci, void *arg)
106
 
{
107
 
    make_bios_readonly_intel(pci->bdf, Q35_HOST_BRIDGE_PAM0);
108
 
}
109
 
 
110
 
static const struct pci_device_id dram_controller_make_readonly_tbl[] = {
111
 
    PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441,
112
 
               i440fx_bios_make_readonly),
113
 
    PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_Q35_MCH,
114
 
               mch_bios_make_readonly),
115
 
    PCI_DEVICE_END
116
 
};
 
100
static int ShadowBDF = -1;
117
101
 
118
102
// Make the 0xc0000-0x100000 area read/writable.
119
103
void
120
104
make_bios_writable(void)
121
105
{
122
 
    if (CONFIG_COREBOOT || usingXen())
 
106
    if (!CONFIG_QEMU || runningOnXen())
123
107
        return;
124
108
 
125
109
    dprintf(3, "enabling shadow ram\n");
133
117
        if (vendor == PCI_VENDOR_ID_INTEL
134
118
            && device == PCI_DEVICE_ID_INTEL_82441) {
135
119
            make_bios_writable_intel(bdf, I440FX_PAM0);
 
120
            ShadowBDF = bdf;
136
121
            return;
137
122
        }
138
123
        if (vendor == PCI_VENDOR_ID_INTEL
139
124
            && device == PCI_DEVICE_ID_INTEL_Q35_MCH) {
140
125
            make_bios_writable_intel(bdf, Q35_HOST_BRIDGE_PAM0);
 
126
            ShadowBDF = bdf;
141
127
            return;
142
128
        }
143
129
    }
148
134
void
149
135
make_bios_readonly(void)
150
136
{
151
 
    if (CONFIG_COREBOOT || usingXen())
 
137
    if (!CONFIG_QEMU || runningOnXen())
152
138
        return;
153
 
 
154
139
    dprintf(3, "locking shadow ram\n");
155
 
    struct pci_device *pci = pci_find_init_device(
156
 
        dram_controller_make_readonly_tbl, NULL);
157
 
    if (!pci)
 
140
 
 
141
    if (ShadowBDF < 0) {
158
142
        dprintf(1, "Unable to lock ram - bridge not found\n");
 
143
        return;
 
144
    }
 
145
 
 
146
    u16 device = pci_config_readw(ShadowBDF, PCI_DEVICE_ID);
 
147
    if (device == PCI_DEVICE_ID_INTEL_82441)
 
148
        make_bios_readonly_intel(ShadowBDF, I440FX_PAM0);
 
149
    else
 
150
        make_bios_readonly_intel(ShadowBDF, Q35_HOST_BRIDGE_PAM0);
159
151
}
160
152
 
161
153
void
162
154
qemu_prep_reset(void)
163
155
{
164
 
    if (CONFIG_COREBOOT)
 
156
    if (!CONFIG_QEMU || runningOnXen())
165
157
        return;
166
158
    // QEMU doesn't map 0xc0000-0xfffff back to the original rom on a
167
159
    // reset, so do that manually before invoking a hard reset.