Received: from list by lists.gnu.org with archive (Exim 4.71) id 1QDQFc-00037z-29 for mharc-grub-devel@gnu.org; Fri, 22 Apr 2011 19:59:04 -0400 Received: from eggs.gnu.org ([140.186.70.92]:50019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QDQFZ-00037t-4d for grub-devel@gnu.org; Fri, 22 Apr 2011 19:59:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QDQFY-000526-39 for grub-devel@gnu.org; Fri, 22 Apr 2011 19:59:01 -0400 Received: from smarthost02.mail.zen.net.uk ([212.23.3.141]:57043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QDQFX-00051u-Rz for grub-devel@gnu.org; Fri, 22 Apr 2011 19:59:00 -0400 Received: from [82.69.40.219] (helo=riva.pelham.vpn.ucam.org) by smarthost02.mail.zen.net.uk with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1QDQFW-0006Bb-4f for grub-devel@gnu.org; Fri, 22 Apr 2011 23:58:58 +0000 Received: from cjwatson by riva.pelham.vpn.ucam.org with local (Exim 4.72) (envelope-from ) id 1QDQFP-0007SI-8r for grub-devel@gnu.org; Sat, 23 Apr 2011 00:58:53 +0100 Date: Sat, 23 Apr 2011 00:58:46 +0100 From: Colin Watson To: The development of GNU GRUB Subject: Re: Question: how to add new menu functionality Message-ID: <20110422235845.GG9163@riva.ucam.org> References: <1303466621.24395.8.camel@localhost.localdomain> <20110422114056.GD9163@riva.ucam.org> <1303511126.24395.25.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1303511126.24395.25.camel@localhost.localdomain> User-Agent: Mutt/1.5.20 (2009-06-14) X-Originating-Smarthost02-IP: [82.69.40.219] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 212.23.3.141 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 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: Fri, 22 Apr 2011 23:59:03 -0000 On Fri, Apr 22, 2011 at 06:25:26PM -0400, Stephen Torri wrote: > Thanks for the help. The build code for 1.99 is much easier to navigate > than for 1.98. I downloaded the 1.99-rc2 source from the ftp site. > > As I worked on the code today I came up with four more questions on > developing grub2: Vladimir has answered the first three. While the answer to the fourth does follow from his answer to the third, I'll be explicit about it: > 4. Lets say you manually compiled certain files by copying the Makefile > command and removed the -inostdinc and -isystem. When I was working on > 1.98 and used a system header to get a function I had to manually > include /usr/include and alter the appropriate def-.lst file to > get the code to compile. When I installed that code to a bootable device Don't do this - really! The build system made this an error because what you're trying to do is not possible; your hacks may have made it limp on anyway and compile, but the only thing that disregarding the errors from the build system achieves is that it will fail at run-time instead. The errors you got were correct. > When I installed that code to a bootable device and restarted the > system I saw a message that said: > > in is not defined > > Often the culprit was the system calls being used (e.g. select). I would > get a message when grub started on the bootable device that said: > > select in normal is not defined You can't do this. select and other functions you may be familiar with from the standard C library are implemented on top of your operating system's kernel. They simply do not exist in GRUB. In the terms of the C standard and many books on C, GRUB (the boot loader environment, as opposed to the userspace utilities) is more like a freestanding implementation than a hosted one. Programs written for freestanding implementations may only use an extremely limited subset of the standard library, essentially limited to macro definitions. A small number of familiar function names (memcmp, memmove, memcpy, memset) are present in GRUB because GCC may generate code that expects them to be available, but they should not be used in manually-written code. Aside from those, no C library functions are available in GRUB, and you must not attempt to use them. You need to find grub_* equivalents instead. (This does not apply to the GRUB userspace utilities - grub-probe, grub-mkimage, etc. - which run on top of an operating system. Those can and should generally use OS functions where appropriate. Code that is used in both boot and userspace contexts uses grub_* functions, and we provide a compatibility layer for userspace. This doesn't apply to normal.mod, though.) -- Colin Watson [cjwatson@ubuntu.com]