From patchwork Tue Jun 7 19:41:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrill Gorcunov X-Patchwork-Id: 859342 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p57Jg9Yc006587 for ; Tue, 7 Jun 2011 19:42:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932402Ab1FGTmE (ORCPT ); Tue, 7 Jun 2011 15:42:04 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:43821 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754938Ab1FGTmB (ORCPT ); Tue, 7 Jun 2011 15:42:01 -0400 Received: by mail-bw0-f46.google.com with SMTP id 15so50469bwz.19 for ; Tue, 07 Jun 2011 12:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:user-agent:date:from:to:cc:subject :references:content-disposition; bh=zICuFeINmM4KKYyjytlnpF/lb7S3L5QgaVe/8lw22LM=; b=DhH2TD9L43Yfw0ssjjUGJbrCIdV1G08ZxHYgxgeRqwl/UZZt4hHHcOpdjuq8GtMjei QEHv/+SxQ1I6hbLCZq6F6G/okvfw9ikyGJl+lkO1w6sjIQLsRtt6PjW0/btJt2xtwOGM tKM8csdFgMu8WtFAqFj/YojW7RimnfTddRxUg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:user-agent:date:from:to:cc:subject:references :content-disposition; b=lchXnFfQIzKr2OlG+gAiFS0su3FiSDxZoc0WO3WAwJgZkMEKCF2AcyTlpGzsOI078/ j5v4Hb7KYN6S5fsN4e2+tjijOmDy76uCZpTHvypgP/jWSdF0bZa8rLpFgsy7rAogrs0M 9kdYz4Pp46f7oziP9PQ01zTioyFxqpKat7FdQ= Received: by 10.204.39.68 with SMTP id f4mr292225bke.17.1307475720790; Tue, 07 Jun 2011 12:42:00 -0700 (PDT) Received: from sun.localdomain (95-26-151-198.broadband.corbina.ru [95.26.151.198]) by mx.google.com with ESMTPS id x6sm4482547bkv.0.2011.06.07.12.41.57 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Jun 2011 12:41:58 -0700 (PDT) Received: by sun.localdomain (Postfix, from userid 500) id A7D556092D; Tue, 7 Jun 2011 23:41:54 +0400 (MSD) Message-Id: <20110607194154.492625503@gmail.com> User-Agent: quilt/0.48-1 Date: Tue, 07 Jun 2011 23:41:16 +0400 From: Cyrill Gorcunov To: penberg@kernel.org Cc: asias.hejun@gmail.com, mingo@elte.hu, levinsasha928@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org, Cyrill Gorcunov Subject: [patch 5/5] kvm tools: Reform bios make fules References: <20110607194111.025052224@gmail.com> Content-Disposition: inline; filename=kvm-tools-bios-rename 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 (demeter2.kernel.org [140.211.167.43]); Tue, 07 Jun 2011 19:42:09 +0000 (UTC) Put bios code into bios.s and adjust makefile rules accordingly. It's more natural than bios-rom.S (which is now simply a container over real bios code). Also improve bios deps in Makefile. Signed-off-by: Cyrill Gorcunov --- tools/kvm/Makefile | 29 +++++++----- tools/kvm/bios/bios-rom.S | 95 +++--------------------------------------- tools/kvm/bios/bios.S | 95 ++++++++++++++++++++++++++++++++++++++---- tools/kvm/bios/gen-offsets.sh | 3 - 4 files changed, 115 insertions(+), 107 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6.git/tools/kvm/Makefile =================================================================== --- linux-2.6.git.orig/tools/kvm/Makefile +++ linux-2.6.git/tools/kvm/Makefile @@ -82,7 +82,7 @@ DEPS := $(patsubst %.o,%.d,$(OBJS)) # Exclude BIOS object files from header dependencies. OBJS += bios.o -OBJS += bios/bios.o +OBJS += bios/bios-rom.o LIBS += -lrt LIBS += -lpthread @@ -165,20 +165,27 @@ BIOS_CFLAGS += -m32 BIOS_CFLAGS += -march=i386 BIOS_CFLAGS += -mregparm=3 -bios.o: bios/bios-rom.bin -bios/bios.o: bios/bios.S bios/bios-rom.bin - $(E) " CC " $@ - $(Q) $(CC) -c $(CFLAGS) bios/bios.S -o bios/bios.o - -bios/bios-rom.bin: bios/bios-rom.S bios/e820.c - $(E) " CC " $@ +bios.o: bios/bios.bin bios/bios-rom.h + +bios/bios.bin.elf: bios/bios.S bios/e820.c bios/int10.c bios/rom.ld.S + $(E) " CC bios/e820.o" $(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/e820.c -o bios/e820.o + $(E) " CC bios/int10.o" $(Q) $(CC) -include code16gcc.h $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/int10.c -o bios/int10.o - $(Q) $(CC) $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/bios-rom.S -o bios/bios-rom.o + $(E) " CC bios/bios.o" + $(Q) $(CC) $(CFLAGS) $(BIOS_CFLAGS) -c -s bios/bios.S -o bios/bios.o $(E) " LD " $@ - $(Q) ld -T bios/rom.ld.S -o bios/bios-rom.bin.elf bios/bios-rom.o bios/e820.o bios/int10.o + $(Q) ld -T bios/rom.ld.S -o bios/bios.bin.elf bios/bios.o bios/e820.o bios/int10.o + +bios/bios.bin: bios/bios.bin.elf $(E) " OBJCOPY " $@ - $(Q) objcopy -O binary -j .text bios/bios-rom.bin.elf bios/bios-rom.bin + $(Q) objcopy -O binary -j .text bios/bios.bin.elf bios/bios.bin + +bios/bios-rom.o: bios/bios-rom.S bios/bios.bin bios/bios-rom.h + $(E) " CC " $@ + $(Q) $(CC) -c $(CFLAGS) bios/bios-rom.S -o bios/bios-rom.o + +bios/bios-rom.h: bios/bios.bin.elf $(E) " NM " $@ $(Q) cd bios && sh gen-offsets.sh > bios-rom.h && cd .. Index: linux-2.6.git/tools/kvm/bios/bios-rom.S =================================================================== --- linux-2.6.git.orig/tools/kvm/bios/bios-rom.S +++ linux-2.6.git/tools/kvm/bios/bios-rom.S @@ -1,89 +1,12 @@ -/* - * Our pretty trivial BIOS emulation - */ - -#include #include .org 0 - .code16gcc - -#include "macro.S" - -/* - * fake interrupt handler, nothing can be faster ever - */ -ENTRY(bios_intfake) - IRET -ENTRY_END(bios_intfake) - -/* - * int 10 - video - service - */ -ENTRY(bios_int10) - pushw %fs - pushl %es - pushl %edi - pushl %esi - pushl %ebp - pushl %esp - pushl %edx - pushl %ecx - pushl %ebx - pushl %eax - - movl %esp, %eax - /* this is way easier than doing it in assembly */ - /* just push all the regs and jump to a C handler */ - call int10_handler - - popl %eax - popl %ebx - popl %ecx - popl %edx - popl %esp - popl %ebp - popl %esi - popl %edi - popl %es - popw %fs - - IRET -ENTRY_END(bios_int10) - -#define EFLAGS_CF (1 << 0) - -ENTRY(bios_int15) - cmp $0xE820, %eax - jne 1f - - pushw %fs - - pushl %edx - pushl %ecx - pushl %edi - pushl %ebx - pushl %eax - - movl %esp, %eax # it's bioscall case - call e820_query_map - - popl %eax - popl %ebx - popl %edi - popl %ecx - popl %edx - - popw %fs - - /* Clear CF */ - andl $~EFLAGS_CF, 0x4(%esp) -1: - IRET -ENTRY_END(bios_int15) - -GLOBAL(__locals) - -#include "local.S" - -END(__locals) +#ifdef CONFIG_X86_64 + .code64 +#else + .code32 +#endif + +GLOBAL(bios_rom) + .incbin "bios/bios.bin" +END(bios_rom) Index: linux-2.6.git/tools/kvm/bios/bios.S =================================================================== --- linux-2.6.git.orig/tools/kvm/bios/bios.S +++ linux-2.6.git/tools/kvm/bios/bios.S @@ -1,12 +1,89 @@ +/* + * Our pretty trivial BIOS emulation + */ + +#include #include .org 0 -#ifdef CONFIG_X86_64 - .code64 -#else - .code32 -#endif - -GLOBAL(bios_rom) - .incbin "bios/bios-rom.bin" -END(bios_rom) + .code16gcc + +#include "macro.S" + +/* + * fake interrupt handler, nothing can be faster ever + */ +ENTRY(bios_intfake) + IRET +ENTRY_END(bios_intfake) + +/* + * int 10 - video - service + */ +ENTRY(bios_int10) + pushw %fs + pushl %es + pushl %edi + pushl %esi + pushl %ebp + pushl %esp + pushl %edx + pushl %ecx + pushl %ebx + pushl %eax + + movl %esp, %eax + /* this is way easier than doing it in assembly */ + /* just push all the regs and jump to a C handler */ + call int10_handler + + popl %eax + popl %ebx + popl %ecx + popl %edx + popl %esp + popl %ebp + popl %esi + popl %edi + popl %es + popw %fs + + IRET +ENTRY_END(bios_int10) + +#define EFLAGS_CF (1 << 0) + +ENTRY(bios_int15) + cmp $0xE820, %eax + jne 1f + + pushw %fs + + pushl %edx + pushl %ecx + pushl %edi + pushl %ebx + pushl %eax + + movl %esp, %eax # it's bioscall case + call e820_query_map + + popl %eax + popl %ebx + popl %edi + popl %ecx + popl %edx + + popw %fs + + /* Clear CF */ + andl $~EFLAGS_CF, 0x4(%esp) +1: + IRET +ENTRY_END(bios_int15) + +GLOBAL(__locals) + +#include "local.S" + +END(__locals) Index: linux-2.6.git/tools/kvm/bios/gen-offsets.sh =================================================================== --- linux-2.6.git.orig/tools/kvm/bios/gen-offsets.sh +++ linux-2.6.git/tools/kvm/bios/gen-offsets.sh @@ -8,6 +8,7 @@ echo "" echo "#define BIOS_ENTRY_SIZE(name) (name##_end - name)" echo "" -nm bios-rom.bin.elf | grep ' [Tt] ' | awk '{ print "#define BIOS_OFFSET__" $3 " 0x" $1; }' +nm bios.bin.elf | grep ' [Tt] ' | awk '{ print "#define BIOS_OFFSET__" $3 " 0x" $1; }' +echo "" echo "#endif"