summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2009-07-16 15:37:39 +1000
committerDave Airlie <airlied@redhat.com>2009-07-16 15:37:39 +1000
commitae7e48406413f533a07e4ebda399d67c1ee0b95f (patch)
tree5c3e645e65c4f534230d2cd9427fe948e237069d
parent3c28d1200eed16426b245a82401db38c19d76c4e (diff)
check for a kernel driver and/or a boot VGA device
-rw-r--r--posttool.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/posttool.c b/posttool.c
index 1cccaf9..8d2416c 100644
--- a/posttool.c
+++ b/posttool.c
@@ -35,6 +35,9 @@ version 2
#define DPMS_STATE_OFF 0x0400
#define DPMS_STATE_LOW 0x0800
+/* 1 on first boot, 0 on suspend/resume */
+int boot_flag;
+
int vbetool_init (void) {
if (!LRMI_init()) {
fprintf(stderr, "Failed to initialise LRMI (Linux Real-Mode Interface).\n");
@@ -52,11 +55,16 @@ int vbetool_init (void) {
#ifndef S2RAM
int main(int argc, char *argv[])
{
+ if (argc < 2) {
+ fprintf(stderr,"usage: posttool <bootflag>: bootflag = 0 for s/r, 1 for bootup\n");
+ return 0;
+ }
+ boot_flag = atoi(argv[1]);
+
vbetool_init();
/* Again, we don't really want to do this while X is in
control */
int err = check_console();
-
if (err) {
return err;
}
@@ -102,12 +110,12 @@ int do_vga_post(struct pci_device *dev)
/* need to pull the ROM file */
unsigned int pci_id;
int ret;
-
- pci_device_enable(dev);
+
pci_device_vgaarb_set_target(dev);
pci_device_vgaarb_lock(dev);
ret = pci_device_read_rom(dev, romfile);
if (ret) {
+ pci_device_vgaarb_unlock(dev);
fprintf(stderr,"rom read returned %d\n");
return 0;
}
@@ -153,6 +161,14 @@ int do_post(void)
while ((dev = pci_device_next(iter)) != NULL) {
if (!first_dev)
first_dev = dev;
+ if (pci_device_is_boot_vga(dev) && (boot_flag == 1)) {
+ fprintf(stderr,"not posting %d:%d:%d is firstboot and is boot VGA device\n", dev->bus, dev->dev, dev->func);
+ continue;
+ }
+ if (pci_device_has_kernel_driver(dev)) {
+ fprintf(stderr,"not posting %d:%d:%d has kernel driver\n", dev->bus, dev->dev, dev->func);
+ continue;
+ }
fprintf(stderr,"pretend posting %d:%d:%d\n", dev->bus, dev->dev, dev->func);
/* need to route VGA in here */
error = do_vga_post(dev);