1
/* fixvideo.c - fix video problem in efi */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2009 Free Software Foundation, Inc.
6
* GRUB 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, either version 3 of the License, or
9
* (at your option) any later version.
11
* GRUB 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.
16
* You should have received a copy of the GNU General Public License
17
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
21
#include <grub/misc.h>
22
#include <grub/file.h>
24
#include <grub/command.h>
25
#include <grub/i18n.h>
27
static struct grub_video_patch
31
grub_uint32_t mmio_bar;
32
grub_uint32_t mmio_reg;
33
grub_uint32_t mmio_old;
36
{"Intel 945GM", 0x27a28086, 0, 0x71184, 0x1000000}, /* DSPBBASE */
37
{"Intel 965GM", 0x2a028086, 0, 0x7119C, 0x1000000}, /* DSPBSURF */
41
static int NESTED_FUNC_ATTR
42
scan_card (grub_pci_device_t dev, grub_pci_id_t pciid)
44
grub_pci_address_t addr;
46
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
47
if (grub_pci_read_byte (addr + 3) == 0x3)
49
struct grub_video_patch *p = video_patches;
53
if (p->pci_id == pciid)
55
grub_target_addr_t base;
57
grub_printf ("Found graphic card: %s\n", p->name);
58
addr += 8 + p->mmio_bar * 4;
59
base = grub_pci_read (addr);
60
if ((! base) || (base & GRUB_PCI_ADDR_SPACE_IO) ||
61
(base & GRUB_PCI_ADDR_MEM_PREFETCH))
62
grub_printf ("Invalid MMIO bar %d\n", p->mmio_bar);
65
base &= GRUB_PCI_ADDR_MEM_MASK;
68
if (*((volatile grub_uint32_t *) base) != p->mmio_old)
69
grub_printf ("Old value don't match\n");
72
*((volatile grub_uint32_t *) base) = 0;
73
if (*((volatile grub_uint32_t *) base))
74
grub_printf ("Set MMIO fails\n");
83
grub_printf ("Unknown graphic card: %x\n", pciid);
90
grub_cmd_fixvideo (grub_command_t cmd __attribute__ ((unused)),
91
int argc __attribute__ ((unused)),
92
char *argv[] __attribute__ ((unused)))
94
grub_pci_iterate (scan_card);
98
static grub_command_t cmd_fixvideo;
100
GRUB_MOD_INIT(fixvideo)
102
cmd_fixvideo = grub_register_command ("fix_video", grub_cmd_fixvideo,
103
0, N_("Fix video problem."));
107
GRUB_MOD_FINI(fixvideo)
109
grub_unregister_command (cmd_fixvideo);