From: Vincent Hanquez Date: Wed, 17 Dec 2008 17:32:01 +0000 (+0000) Subject: patch get_bios_from_0xC0000 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0ca6e5874b0475ab8ec4deda15451795368a2463;p=xenclient%2Fxen.git patch get_bios_from_0xC0000 --- diff --git a/tools/libxc/xc_linux.c b/tools/libxc/xc_linux.c index 2480b3c..0c70e99 100644 --- a/tools/libxc/xc_linux.c +++ b/tools/libxc/xc_linux.c @@ -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 diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 100749a..ef68689 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -145,6 +145,10 @@ int xc_waitdomain( int *status, int options); +int xc_get_vgabios( + unsigned char *bios, + int len); + #endif /* __linux__ */ /*