]> xenbits.xen.org Git - xenclient/xen.git/commitdiff
patch get_bios_from_0xC0000
authorVincent Hanquez <vincent@snarc.org>
Wed, 17 Dec 2008 17:32:01 +0000 (17:32 +0000)
committerVincent Hanquez <vincent@snarc.org>
Wed, 17 Dec 2008 17:32:01 +0000 (17:32 +0000)
tools/libxc/xc_linux.c
tools/libxc/xenctrl.h

index 2480b3ce7277ed2cf59c587a518b271187433f43..0c70e99afb002cdc156e3e51a29a9b6da0fa86d5 100644 (file)
@@ -562,6 +562,58 @@ int xc_gnttab_set_max_grants(int xcg_handle,
     return 0;
 }
 
+int xc_get_vgabios(unsigned char        *buf,
+                   int                  len)
+{
+    int         mem;
+    uint32_t    start, size = 0;
+    uint16_t    magic = 0;
+
+    start = 0xC0000;
+    if (len < size)
+        return 0;
+    if ((mem = open("/dev/mem", O_RDONLY)) < 0)
+        return 0;
+   
+    /*
+    ** Check if it a real bios extension.
+    ** The magic number is 0xAA55.
+    */
+    if (start != lseek(mem, start, SEEK_SET))
+        goto out;
+    if (read(mem, &magic, 2) != 2)
+        goto out;
+    if (magic != 0xAA55)
+        goto out;
+
+    /* Find the size of the rom extension */
+    if (start != lseek(mem, start, SEEK_SET))
+        goto out;
+    if (lseek(mem, 2, SEEK_CUR) != (start + 2))
+        goto out;
+    if (read(mem, &size, 1) != 1)
+        goto out;
+    /* This size is in 512K */
+    size *= 512;
+
+    /*
+    ** Set the file to the begining of the rombios,
+    ** to start the copy.
+    */
+    if (start != lseek(mem, start, SEEK_SET))
+    {
+        size = 0;
+        goto out;
+    }
+    if (size != read(mem, buf, size))
+        size = 0;
+
+out:
+    close(mem);
+    return size;
+} 
+
+
 /*
  * Local variables:
  * mode: C
index 100749a9ab07afa1e70f793765814bfcf2b8c267..ef68689683b21166f163f7a70fec08bcae36e3f7 100644 (file)
@@ -145,6 +145,10 @@ int xc_waitdomain(
     int *status,
     int options);
 
+int xc_get_vgabios(
+    unsigned char       *bios,
+    int                 len);
+
 #endif /* __linux__ */
 
 /*