From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Q7t4P-00023Y-MP for mharc-grub-devel@gnu.org; Thu, 07 Apr 2011 13:32:37 -0400 Received: from [140.186.70.92] (port=44172 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7t4H-0001vU-GZ for grub-devel@gnu.org; Thu, 07 Apr 2011 13:32:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7t4F-0007Bv-1A for grub-devel@gnu.org; Thu, 07 Apr 2011 13:32:28 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:56177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q7t4E-0007BP-Hs for grub-devel@gnu.org; Thu, 07 Apr 2011 13:32:26 -0400 Received: from smtp03.web.de ( [172.20.0.65]) by fmmailgate03.web.de (Postfix) with ESMTP id EDF3618B44ABF; Thu, 7 Apr 2011 19:32:08 +0200 (CEST) Received: from [78.43.204.177] (helo=frosties.localnet) by smtp03.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1Q7t3w-0002uQ-00; Thu, 07 Apr 2011 19:32:08 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.72) (envelope-from ) id 1Q7t3w-00040V-4o; Thu, 07 Apr 2011 19:32:08 +0200 From: Goswin von Brederlow To: =?iso-8859-1?Q?Vladimir_'=CF=86-coder=2Fphcoder'_Serbinenko?= References: <87r59efek1.fsf@frosties.localnet> <4D9DB463.20903@gmail.com> <87y63mnmja.fsf@frosties.localnet> <4D9DD0CD.5040904@gmail.com> Date: Thu, 07 Apr 2011 19:32:07 +0200 In-Reply-To: <4D9DD0CD.5040904@gmail.com> (Vladimir Serbinenko's message of "Thu, 07 Apr 2011 16:57:17 +0200") Message-ID: <87y63motm0.fsf@frosties.localnet> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1+tw27ZjEz6ErJiXpRQy7HqGqeoZC1ii52uolj6 tB6xX+K894dDCZdsL522x0v+fz2oR+a+2tK4Kmsbofo4R7/6Wq Wk73KtPe8= Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.234 Cc: The development of GNU GRUB , Goswin von Brederlow Subject: Re: Would a cleanup+extending of docs/multiboot.h be acceptable? X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Apr 2011 17:32:36 -0000 "Vladimir '=CF=86-coder/phcoder' Serbinenko" writes: > On 07.04.2011 16:50, Goswin von Brederlow wrote: >> "Vladimir '=C3=8F=E2=80=A0-coder/phcoder' Serbinenko" writes: >> >>> On 07.04.2011 14:09, Goswin von Brederlow wrote: >>>> Hi, >>>> >>>> I've been working on a 32bit->64bit trampoline based on the example >>>> kernel that just switches to 64bit mode and executes a real kernel >>>> passed as module. As real kernel I want to use grubs example kernel = as >>>> well to just verify the multiboot infos passed through the trampolin= e >>>> are intact. >>> Please don't use outdated code as base. Now we work on multiboot2 and >> I've seen multiboot2 mentioned but I can't find specs for it. What I >> did find are the "Multiboot Specification version 0.6.96" [1] >> >> So where is this multiboot2? >> > Latest multiboot1 (cleanups) is at > http://bzr.savannah.gnu.org/r/grub/trunk/multiboot/ Ok, this is much cleaner than what is in the grub source in Debian alread= y. Remaining issues: 1) hardcoded bit numbers: /* Check if the bit BIT in FLAGS is set. */ #define CHECK_FLAG(flags,bit) ((flags) & (1 << (bit))) ... /* Are mem_* valid? */ if (CHECK_FLAG (mbi->flags, 0)) The multiboot.h does not define the bit numbers, only masks for each bit. Maybe this could be changed to In multiboot.h add: #define MULTIBOOT_INFO_MEMORY_BIT 0 In kernel.c: /* Check if the bit BIT in FLAGS is set. */ #define CHECK_FLAG(flags,bit) ((flags) & (1 << (MULTIBOOT_INFO_##bit##_= BIT))) ... /* Are mem_* valid? */ if (CHECK_FLAG (mbi->flags, MEMORY)) 2) Wrong types void cmain (unsigned long magic, unsigned long addr); static void itoa (char *buf, int base, int d); should be: void cmain (multiboot_uint32_t magic, multiboot_uint32_t addr); static void itoa (char *buf, char base, int d); All occurances of '(unsigned)' should be '(multiboot_uint32_t)'. 3) Could we use 64bit types? It might be nice to teach printf about '%llx' (or '%q' for quad word) and add a 64bit itoa. And maybe add a '%p' which would be 64bit in 64bit code and 32bit in 32bit code while '%x' is allways 32bit. > Multiboot2 is at http://bzr.savannah.gnu.org/r/grub/branches/multiboot2= / I see that you have added 32bit MIPS support. No 64bit x86_64 support though. So my trampoline + 64bit kernel stuff would still be interesting to people. The bigger problem though is the thing doesn't build or work: 1) ./autogen.sh doc/Makefile.am:2: compiling `kernel.c' with per-target flags requires `A= M_PROG_CC_C_O' in `configure.ac' 2) wrong source file Making all in doc make[2]: Entering directory `/home/mrvn/t/t/multiboot2/doc' make[2]: *** No rule to make target `boot_mips.o', needed by `kernel'. S= top. There is only the boot.S, which is for x86. Fixing that: 3) -m32 missing gcc -DHAVE_CONFIG_H -I. -I.. -DHAVE_CONFIG_H -I. -I.. -nostdlib -g = -O2 -MT boot.o -MD -MP -MF .deps/boot.Tpo -c -o boot.o boot.S boot.S: Assembler messages: boot.S:97: Error: invalid instruction suffix for `push' boot.S:101: Error: invalid instruction suffix for `push' boot.S:103: Error: invalid instruction suffix for `push' boot.S:109: Error: invalid instruction suffix for `push' make[2]: *** [boot.o] Error 1 Note that the CFLAGS aren't used for the assembler file at all. exporting CC=3D"gcc -m32" to work around this. 4) typos in boot.S --- doc/boot.S.orig 2011-04-07 18:58:41.000000000 +0200 +++ doc/boot.S 2011-04-07 18:58:59.000000000 +0200 @@ -50,11 +50,11 @@ /* magic */ .long MULTIBOOT2_HEADER_MAGIC /* ISA: i386 */ - .long GRUB_MULTIBOOT_ARCHITECTURE_I386 + .long MULTIBOOT_ARCHITECTURE_I386 /* Header length. */ .long multiboot_header_end - multiboot_header /* checksum */ - .long -(MULTIBOOT2_HEADER_MAGIC + GRUB_MULTIBOOT_ARCHITECTURE_I= 386 + (multiboot_header_end - multiboot_header)) + .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 += (multiboot_header_end - multiboot_header)) #ifndef __ELF__ address_tag_start: .short MULTIBOOT_HEADER_TAG_ADDRESS Ok, after all this I get: % make gcc -m32 -DHAVE_CONFIG_H -I. -I.. -DHAVE_CONFIG_H -I. -I.. -nostdli= b -g -O2 -MT boot.o -MD -MP -MF .deps/boot.Tpo -c -o boot.o boot.S gcc -m32 -DHAVE_CONFIG_H -I. -I.. -fno-builtin -nostdinc -O -g -Wall -= imacros ../config.h -nostdlib -g -O2 -MT kernel-kernel.o -MD -MP -MF .dep= s/kernel-kernel.Tpo -c -o kernel-kernel.o `test -f 'kernel.c' || echo './= '`kernel.c gcc -m32 -fno-builtin -nostdinc -O -g -Wall -imacros ../config.h -nostdli= b -g -O2 -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=3Dnone = -o kernel boot.o kernel-kernel.o =20 % file doc/kernel doc/kernel: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), sta= tically linked, not stripped % kvm -m 64 -kernel doc/kernel doesn't output anything, doesn't clear the screen. And here I'm stuck. Everything looks alright. I thought maybe the extra "-O2" screws something up. So I tried doc% gcc -m32 -DHAVE_CONFIG_H -I. -I.. -DHAVE_CONFIG_H -I. -I.. -no= stdlib -g -O -MT boot.o -MD -MP -MF .deps/boot.Tpo -c -o boot.o boot.S=20 doc% gcc -m32 -DHAVE_CONFIG_H -I. -I.. -fno-builtin -nostdinc -O -g -W= all -imacros ../config.h -nostdlib -g -O -MT kernel-kernel.o -MD -MP -MF = .deps/kernel-kernel.Tpo -c -o kernel-kernel.o `test -f 'kernel.c' || echo= './'`kernel.c=20 doc% gcc -m32 -fno-builtin -nostdinc -O -g -Wall -imacros ../config.h -no= stdlib -g -O -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=3Dno= ne -o kernel boot.o kernel-kernel.o=20 doc% kvm -m 64 -kernel kernel =20 open /dev/kvm: No such file or directory Could not initialize KVM, will disable KVM support Failed to allocate memory: Cannot allocate memory zsh: abort kvm -m 64 -kernel kernel It tries to allocate -0xE000 byte of memory, which is a few trillion gazillion byte. Trying the commands the old multiboot (from your first url) used to build: doc% gcc -DHAVE_CONFIG_H -I. -I.. -m32 -nostdlib -fno-builtin -nostdinc = -O -g -Wall -imacros ../config.h -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT = kernel-boot.o -MD -MP -MF .deps/kernel-boot.Tpo -c -o kernel-boot.o `test= -f 'boot.S' || echo './'`boot.S doc% gcc -DHAVE_CONFIG_H -I. -I.. -m32 -nostdlib -fno-builtin -nostdinc = -O -g -Wall -imacros ../config.h -g -O2 -MT kernel-kernel.o -MD -MP -MF= .deps/kernel-kernel.Tpo -c -o kernel-kernel.o `test -f 'kernel.c' || ech= o './'`kernel.c doc% gcc -g -O2 -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000 -Wl,--build-= id=3Dnone -o kernel kernel-boot.o kernel-kernel.o =20 doc% kvm -m 64 -kernel kernel doesn't output anything, doesn't clear the screen. Any idea what is going wrong? MfG Goswin