[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question: how to add new menu functionality

From: Colin Watson
Subject: Re: Question: how to add new menu functionality
Date: Sat, 23 Apr 2011 00:58:46 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

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-<name>.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:
>      <function name> in <module> 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                                       address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]