From: joy zhao <yanhwizhao@gmail.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] set vidmode in linux kernel header when boot x86 using qemu bootloader
Date: Wed, 27 May 2009 14:01:14 +0800 [thread overview]
Message-ID: <162800e10905262301r35b0bdev77c4639ccd8967df@mail.gmail.com> (raw)
In-Reply-To: <4A1BEEC5.8050406@codemonkey.ws>
[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]
hi Anthony,
This is my updated version of patch. I've been using strtoul to translate
string. I do not have get_vga_mode() return vga_mode directly because I do
not want to leave the default value of vga_mode to be decided by qemu,
but by kernel when no "vga=..." is specified.
B.R.
Joy
Signed-off-by: Joy Zhao <yanhwizhao@gmail.com>
diff --git a/qemu/hw/pc.c b/qemu-new/hw/pc.c
index 66cc780..dc1c20f 100644
--- a/qemu/hw/pc.c
+++ b/qemu-new/hw/pc.c
@@ -36,6 +36,7 @@
#include "hpet_emul.h"
#include "watchdog.h"
#include "smbios.h"
+#include <stdlib.h>
/* output Bochs bios info messages */
//#define DEBUG_BIOS
@@ -593,6 +594,41 @@ static long get_file_size(FILE *f)
return size;
}
+static int get_vga_mode(const char* kernel_cmdline, uint16_t *vga_mode)
+{
+ char mode[10];
+ int i = 0;
+ char *p = strstr(kernel_cmdline, "vga=");
+ if(p == NULL)
+ return 1;
+
+ p += 4;
+
+ while(*p != ' ' && *p != '\0' && i < 9) {
+ mode[i] = *p;
+ i++;
+ p++;
+ }
+ mode[i] = '\0';
+
+ if(!strncmp(mode, "ask", 3))
+ *vga_mode = 0xfffd;
+ else if(!strncmp(mode, "normal",6))
+ *vga_mode = 0xffff;
+ else if(!strncmp(mode, "ext", 3))
+ *vga_mode = 0xfffe;
+ else{
+ errno = 0;
+ *vga_mode = strtoul(mode, NULL, 0);
+ if(errno){
+ fprintf(stderr, "vga mode Overflow or unsupported base
value\n");
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
static void load_linux(target_phys_addr_t option_rom,
const char *kernel_filename,
const char *initrd_filename,
@@ -605,6 +641,7 @@ static void load_linux(target_phys_addr_t option_rom,
uint16_t real_seg;
int setup_size, kernel_size, initrd_size, cmdline_size;
uint32_t initrd_max;
+ uint16_t vid_mode;
uint8_t header[1024];
target_phys_addr_t real_addr, prot_addr, cmdline_addr, initrd_addr;
FILE *f, *fi;
@@ -683,6 +720,10 @@ static void load_linux(target_phys_addr_t option_rom,
if (protocol >= 0x200)
header[0x210] = 0xB0;
+ /*parse cmdline and set vga mode*/
+ if(!get_vga_mode(kernel_cmdline, &vid_mode))
+ stw_p(header+0x1fa, vid_mode);
+
/* heap */
if (protocol >= 0x201) {
header[0x211] |= 0x80; /* CAN_USE_HEAP */
[-- Attachment #2: Type: text/html, Size: 3133 bytes --]
next prev parent reply other threads:[~2009-05-27 6:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-26 10:22 [Qemu-devel] [PATCH] set vidmode in linux kernel header when boot x86 using qemu bootloader joy zhao
2009-05-26 13:29 ` Anthony Liguori
2009-05-27 6:01 ` joy zhao [this message]
2009-05-26 14:26 ` Mark McLoughlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=162800e10905262301r35b0bdev77c4639ccd8967df@mail.gmail.com \
--to=yanhwizhao@gmail.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).