From patchwork Fri Jun 3 19:37:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pekka Enberg X-Patchwork-Id: 848162 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p53JbBjQ009681 for ; Fri, 3 Jun 2011 19:37:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755704Ab1FCThI (ORCPT ); Fri, 3 Jun 2011 15:37:08 -0400 Received: from filtteri2.pp.htv.fi ([213.243.153.185]:48616 "EHLO filtteri2.pp.htv.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755707Ab1FCThG (ORCPT ); Fri, 3 Jun 2011 15:37:06 -0400 Received: from localhost (localhost [127.0.0.1]) by filtteri2.pp.htv.fi (Postfix) with ESMTP id 81ED319B432; Fri, 3 Jun 2011 22:37:05 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from smtp5.welho.com ([213.243.153.39]) by localhost (filtteri2.pp.htv.fi [213.243.153.185]) (amavisd-new, port 10024) with ESMTP id cigx7VmBhLYO; Fri, 3 Jun 2011 22:37:05 +0300 (EEST) Received: from localhost.localdomain (cs181148025.pp.htv.fi [82.181.148.25]) by smtp5.welho.com (Postfix) with ESMTP id 155845BC003; Fri, 3 Jun 2011 22:37:05 +0300 (EEST) From: Pekka Enberg To: kvm@vger.kernel.org Cc: Pekka Enberg , Ingo Molnar , Cyrill Gorcunov , John Floren , Sasha Levin Subject: [PATCH 1/2] kvm tools, vesa: Cleanup code in bios/int10.c Date: Fri, 3 Jun 2011 22:37:03 +0300 Message-Id: <1307129824-8396-1-git-send-email-penberg@kernel.org> X-Mailer: git-send-email 1.7.0.4 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 03 Jun 2011 19:37:14 +0000 (UTC) This patch cleans up the code in bios/int10.c without changing functionality. Cc: Ingo Molnar Cc: Cyrill Gorcunov Cc: John Floren Cc: Sasha Levin Signed-off-by: Pekka Enberg --- tools/kvm/bios/int10.c | 88 +++++++++++++++++++++++++---------------------- 1 files changed, 47 insertions(+), 41 deletions(-) diff --git a/tools/kvm/bios/int10.c b/tools/kvm/bios/int10.c index 57647a1..f7fecac 100644 --- a/tools/kvm/bios/int10.c +++ b/tools/kvm/bios/int10.c @@ -29,10 +29,9 @@ struct vesa_general_info { u16 modes[2]; /* 20 */ char oem_string[11]; /* 24 */ - u8 reserved[223]; /* 35 */ + u8 reserved[223]; /* 35 */ } __attribute__ ((packed)); - struct vminfo { u16 mode_attr; /* 0 */ u8 win_attr[2]; /* 2 */ @@ -87,56 +86,63 @@ static inline void int10_putchar(struct int10_args *args) outb(0x3f8, al); } +static void vbe_get_mode(struct int10_args *args) +{ + struct vminfo *info = (struct vminfo *) args->edi; + + *info = (struct vminfo) { + .mode_attr = 0xd9, /* 11011011 */ + .logical_scan = VESA_WIDTH*4, + .h_res = VESA_WIDTH, + .v_res = VESA_HEIGHT, + .bpp = VESA_BPP, + .memory_layout = 6, + .memory_planes = 1, + .lfb_ptr = VESA_MEM_ADDR, + .rmask = 8, + .gmask = 8, + .bmask = 8, + .resv_mask = 8, + .resv_pos = 24, + .bpos = 16, + .gpos = 8, + }; +} + +static void vbe_get_info(struct int10_args *args) +{ + struct vesa_general_info *info = (struct vesa_general_info *) args->edi; + + *info = (struct vesa_general_info) { + .signature = VESA_MAGIC, + .version = 0x102, + .vendor_string = &info->oem_string, + .capabilities = 0x10, + .video_mode_ptr = &info->modes, + .total_memory = (4 * VESA_WIDTH * VESA_HEIGHT) / 0x10000, + .oem_string = "KVM VESA", + .modes = { 0x0112, 0xffff }, + }; +} + +#define VBE_STATUS_OK 0x004F + static void int10_vesa(struct int10_args *args) { u8 al; - struct vesa_general_info *destination; - struct vminfo *vi; al = args->eax; switch (al) { - case 0: - /* Set controller info */ - - destination = (struct vesa_general_info *)args->edi; - *destination = (struct vesa_general_info) { - .signature = VESA_MAGIC, - .version = 0x102, - .vendor_string = &destination->oem_string, - .capabilities = 0x10, - .video_mode_ptr = &destination->modes, - .total_memory = (4*VESA_WIDTH * VESA_HEIGHT) / 0x10000, - .oem_string = "KVM VESA", - .modes = { 0x0112, 0xffff }, - }; - + case 0x00: + vbe_get_info(args); break; - case 1: - vi = (struct vminfo *)args->edi; - *vi = (struct vminfo) { - .mode_attr = 0xd9, /* 11011011 */ - .logical_scan = VESA_WIDTH*4, - .h_res = VESA_WIDTH, - .v_res = VESA_HEIGHT, - .bpp = VESA_BPP, - .memory_layout = 6, - .memory_planes = 1, - .lfb_ptr = VESA_MEM_ADDR, - .rmask = 8, - .gmask = 8, - .bmask = 8, - .resv_mask = 8, - .resv_pos = 24, - .bpos = 16, - .gpos = 8, - }; - + case 0x01: + vbe_get_mode(args); break; } - args->eax = 0x004f; /* return success every time */ - + args->eax = VBE_STATUS_OK; } bioscall void int10_handler(struct int10_args *args)