[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] set vidmode in linux kernel header when boot x8
From: |
joy zhao |
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 |
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
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 */