2004-04-04 Yoshinori K. Okuji <okuji@enbug.org>

All symbols prefixed with PUPA_ and pupa_ are renamed to GRUB_
	and grub_, respectively. Because the conversion is trivial and
	mechanical, I omit the details here. Please refer to the CVS
	if you need more information.
This commit is contained in:
okuji 2004-04-04 13:46:03 +00:00
parent 6a1425510d
commit 4b13b216f4
125 changed files with 6198 additions and 6181 deletions

View file

@ -6,5 +6,5 @@ Yoshinori K. Okuji designed and implemented the initial version.
Jeroen Dekkers added initrd support, Multiboot support, and fixed bugs Jeroen Dekkers added initrd support, Multiboot support, and fixed bugs
in ext2fs. in ext2fs.
Marco Gerards added ext2fs support, pupa-emu, a new command-line Marco Gerards added ext2fs support, grub-emu, a new command-line
engine, and fixed many bugs. engine, and fixed many bugs.

View file

@ -1,3 +1,10 @@
2004-04-04 Yoshinori K. Okuji <okuji@enbug.org>
All symbols prefixed with PUPA_ and pupa_ are renamed to GRUB_
and grub_, respectively. Because the conversion is trivial and
mechanical, I omit the details here. Please refer to the CVS
if you need more information.
2004-04-04 Yoshinori K. Okuji <okuji@enbug.org> 2004-04-04 Yoshinori K. Okuji <okuji@enbug.org>
* include/pupa: Renamed to ... * include/pupa: Renamed to ...

18
INSTALL
View file

@ -1,15 +1,15 @@
-*- Text -*- -*- Text -*-
This is the PUPA. Welcome. This is the GRUB. Welcome.
This file contains instructions for compiling and installing the PUPA. This file contains instructions for compiling and installing the GRUB.
The Requirements The Requirements
================ ================
PUPA depends on some software packages installed into your system. If GRUB depends on some software packages installed into your system. If
you don't have any of them, please obtain and install them before you don't have any of them, please obtain and install them before
configuring the PUPA. configuring the GRUB.
* GCC 2.95 or later * GCC 2.95 or later
* GNU Make * GNU Make
@ -17,12 +17,12 @@ configuring the PUPA.
* Other standard GNU/Unix tools * Other standard GNU/Unix tools
* LZO 1.02 or later * LZO 1.02 or later
If you'd like to develop PUPA, these below are also required. If you'd like to develop GRUB, these below are also required.
* Ruby 1.6 or later * Ruby 1.6 or later
* Autoconf 2.53 or later * Autoconf 2.53 or later
Configuring the PUPA Configuring the GRUB
==================== ====================
The `configure' shell script attempts to guess correct values for The `configure' shell script attempts to guess correct values for
@ -46,7 +46,7 @@ called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'. it or regenerate `configure' using a newer version of `autoconf'.
Building the PUPA Building the GRUB
================= =================
The simplest way to compile this package is: The simplest way to compile this package is:
@ -111,10 +111,10 @@ If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' with an extra prefix or suffix on their names by giving `configure'
the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Please note, however, that the PUPA knows where it is located in the Please note, however, that the GRUB knows where it is located in the
filesystem. If you have installed it in an unusual location, the filesystem. If you have installed it in an unusual location, the
system might not work properly, or at all. The chief utility of these system might not work properly, or at all. The chief utility of these
options for the PUPA is to allow you to "install" in some alternate options for the GRUB is to allow you to "install" in some alternate
location, and then copy these to the actual root filesystem later. location, and then copy these to the actual root filesystem later.

View file

@ -60,7 +60,7 @@ CPPFLAGS = -I. -Iinclude -I$(srcdir)/include -Wall -W
BUILD_CC = @BUILD_CC@ BUILD_CC = @BUILD_CC@
BUILD_CFLAGS = -g -O2 BUILD_CFLAGS = -g -O2
BUILD_CPPFLAGS = -I. -Iinclude -I$(srcdir)/include -Wall -W \ BUILD_CPPFLAGS = -I. -Iinclude -I$(srcdir)/include -Wall -W \
-DPUPA_DATADIR=\"$(pkgdatadir)\" -DGRUB_DATADIR=\"$(pkgdatadir)\"
OBJCOPY = @OBJCOPY@ OBJCOPY = @OBJCOPY@
STRIP = @STRIP@ STRIP = @STRIP@
NM = @NM@ NM = @NM@
@ -86,14 +86,14 @@ DISK_DISTFILES = $(addprefix disk/i386/pc/,biosdisk.c partition.c)
FS_DISTFILES = $(addprefix fs/,fat.c) FS_DISTFILES = $(addprefix fs/,fat.c)
INCLUDE_DISTFILES = $(addprefix include/pupa/,boot.h device.h disk.h \ INCLUDE_DISTFILES = $(addprefix include/grub/,boot.h device.h disk.h \
dl.h elf.h err.h file.h fs.h kernel.h loader.h misc.h mm.h \ dl.h elf.h err.h file.h fs.h kernel.h loader.h misc.h mm.h \
net.h rescue.h symbol.h term.h types.h) \ net.h rescue.h symbol.h term.h types.h) \
$(addprefix include/pupa/util/,misc.h resolve.h) \ $(addprefix include/grub/util/,misc.h resolve.h) \
include/pupa/i386/types.h \ include/grub/i386/types.h \
$(addprefix include/pupa/i386/pc/,biosdisk.h boot.h \ $(addprefix include/grub/i386/pc/,biosdisk.h boot.h \
console.h init.h kernel.h loader.h memory.h partition.h) \ console.h init.h kernel.h loader.h memory.h partition.h) \
$(addprefix include/pupa/i386/pc/util/,biosdisk.h) $(addprefix include/grub/i386/pc/util/,biosdisk.h)
KERN_DISTFILES = $(addprefix kern/,device.c disk.c dl.c err.c file.c \ KERN_DISTFILES = $(addprefix kern/,device.c disk.c dl.c err.c file.c \
fs.c loader.c main.c misc.c mm.c rescue.c term.c) \ fs.c loader.c main.c misc.c mm.c rescue.c term.c) \
@ -105,8 +105,8 @@ LOADER_DISTFILES = $(addprefix loader/i386/pc/,chainloader.c)
TERM_DISTFILES = $(addprefix term/i386/pc/,console.c) TERM_DISTFILES = $(addprefix term/i386/pc/,console.c)
UTIL_DISTFILES = $(addprefix util/,genmoddep.c misc.c resolve.c) \ UTIL_DISTFILES = $(addprefix util/,genmoddep.c misc.c resolve.c) \
$(addprefix util/i386/pc/,biosdisk.c pupa-mkimage.c \ $(addprefix util/i386/pc/,biosdisk.c grub-mkimage.c \
pupa-setup.c) grub-setup.c)
DISTFILES = $(COMMON_DISTFILES) $(BOOT_DISTFILES) $(CONF_DISTFILES) \ DISTFILES = $(COMMON_DISTFILES) $(BOOT_DISTFILES) $(CONF_DISTFILES) \
$(DISK_DISTFILES) $(FS_DISTFILES) $(INCLUDE_DISTFILES) \ $(DISK_DISTFILES) $(FS_DISTFILES) $(INCLUDE_DISTFILES) \
@ -120,7 +120,7 @@ SCRIPTS =
CLEANFILES = CLEANFILES =
MOSTLYCLEANFILES = MOSTLYCLEANFILES =
DISTCLEANFILES = config.status config.cache config.log config.h \ DISTCLEANFILES = config.status config.cache config.log config.h \
Makefile stamp-h include/pupa/cpu include/pupa/machine Makefile stamp-h include/grub/cpu include/grub/machine
MAINTAINER_CLEANFILES = $(srcdir)/configure $(addprefix $(srcdir)/,$(MKFILES)) MAINTAINER_CLEANFILES = $(srcdir)/configure $(addprefix $(srcdir)/,$(MKFILES))
# The default target. # The default target.

12
NEWS
View file

@ -1,3 +1,15 @@
New in 1.90:
* Rename the project name PUPA to GRUB. Now this version is the
developmental version of GRUB officially.
* The GRUB emulator ``grub-emu'' is added.
* Add support for newworld Mac. This should work with other
PowerPC-based machines as well, if they use IEEE 1275
(Open Firmware).
New in 0.7: New in 0.7:
* Problems in cross-compiling PUPA are fixed. * Problems in cross-compiling PUPA are fixed.

2
README
View file

@ -21,7 +21,7 @@ use (yet). For now, you can install GRUB 2 into a floppy by these
instructions: instructions:
$ configure && make $ configure && make
$ ./pupa-mkimage -v -d . -o core.img _chain ext2 $ ./grub-mkimage -v -d . -o core.img _chain ext2
$ dd if=boot.img of=/dev/fd0 bs=512 count=1 $ dd if=boot.img of=/dev/fd0 bs=512 count=1
$ dd if=core.img of=/dev/fd0 bs=512 seek=1 $ dd if=core.img of=/dev/fd0 bs=512 seek=1

6
TODO
View file

@ -1,9 +1,9 @@
-*- Mode: Outline -*- -*- Mode: Outline -*-
Before working on anything in this file, it's very important that you Before working on anything in this file, it's very important that you
make contact with the core PUPA developers. Things herein might be make contact with the core GRUB developers. Things herein might be
slightly out of date or otherwise not easy to understand at first slightly out of date or otherwise not easy to understand at first
glance. So write to <pupa-devel@nongnu.org> first. glance. So write to <grub-devel@gnu.org> first.
Priorities: Priorities:
Reported bugs generally have top priority. Reported bugs generally have top priority.
@ -13,8 +13,6 @@ Priorities:
higher priority. higher priority.
* Replace PUPA with GRUB (or GRUB 2). !!!
* Add more filesystems (such as jfs, ffs, and reiserfs). ! * Add more filesystems (such as jfs, ffs, and reiserfs). !
* Add journal playback support to ext2fs (so it will become ext3fs). * Add journal playback support to ext2fs (so it will become ext3fs).

168
aclocal.m4 vendored
View file

@ -1,11 +1,11 @@
dnl pupa_ASM_USCORE checks if C symbols get an underscore after dnl grub_ASM_USCORE checks if C symbols get an underscore after
dnl compiling to assembler. dnl compiling to assembler.
dnl Written by Pavel Roskin. Based on grub_ASM_EXT_C written by dnl Written by Pavel Roskin. Based on grub_ASM_EXT_C written by
dnl Erich Boleyn and modified by Yoshinori K. Okuji. dnl Erich Boleyn and modified by Yoshinori K. Okuji.
AC_DEFUN(pupa_ASM_USCORE, AC_DEFUN(grub_ASM_USCORE,
[AC_REQUIRE([AC_PROG_CC]) [AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if C symbols get an underscore after compilation]) AC_MSG_CHECKING([if C symbols get an underscore after compilation])
AC_CACHE_VAL(pupa_cv_asm_uscore, AC_CACHE_VAL(grub_cv_asm_uscore,
[cat > conftest.c <<\EOF [cat > conftest.c <<\EOF
int int
func (int *list) func (int *list)
@ -22,27 +22,27 @@ else
fi fi
if grep _func conftest.s >/dev/null 2>&1; then if grep _func conftest.s >/dev/null 2>&1; then
pupa_cv_asm_uscore=yes grub_cv_asm_uscore=yes
else else
pupa_cv_asm_uscore=no grub_cv_asm_uscore=no
fi fi
rm -f conftest*]) rm -f conftest*])
if test "x$pupa_cv_asm_uscore" = xyes; then if test "x$grub_cv_asm_uscore" = xyes; then
AC_DEFINE_UNQUOTED([HAVE_ASM_USCORE], $pupa_cv_asm_uscore, AC_DEFINE_UNQUOTED([HAVE_ASM_USCORE], $grub_cv_asm_uscore,
[Define if C symbols get an underscore after compilation]) [Define if C symbols get an underscore after compilation])
fi fi
AC_MSG_RESULT([$pupa_cv_asm_uscore]) AC_MSG_RESULT([$grub_cv_asm_uscore])
]) ])
dnl Some versions of `objcopy -O binary' vary their output depending dnl Some versions of `objcopy -O binary' vary their output depending
dnl on the link address. dnl on the link address.
AC_DEFUN(pupa_PROG_OBJCOPY_ABSOLUTE, AC_DEFUN(grub_PROG_OBJCOPY_ABSOLUTE,
[AC_MSG_CHECKING([whether ${OBJCOPY} works for absolute addresses]) [AC_MSG_CHECKING([whether ${OBJCOPY} works for absolute addresses])
AC_CACHE_VAL(pupa_cv_prog_objcopy_absolute, AC_CACHE_VAL(grub_cv_prog_objcopy_absolute,
[cat > conftest.c <<\EOF [cat > conftest.c <<\EOF
void void
cmain (void) cmain (void)
@ -55,7 +55,7 @@ if AC_TRY_EVAL(ac_compile) && test -s conftest.o; then :
else else
AC_MSG_ERROR([${CC-cc} cannot compile C source code]) AC_MSG_ERROR([${CC-cc} cannot compile C source code])
fi fi
pupa_cv_prog_objcopy_absolute=yes grub_cv_prog_objcopy_absolute=yes
for link_addr in 2000 8000 7C00; do for link_addr in 2000 8000 7C00; do
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then : if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then :
else else
@ -68,15 +68,15 @@ for link_addr in 2000 8000 7C00; do
if test ! -f conftest.old || AC_TRY_COMMAND([cmp -s conftest.old conftest]); then if test ! -f conftest.old || AC_TRY_COMMAND([cmp -s conftest.old conftest]); then
mv -f conftest conftest.old mv -f conftest conftest.old
else else
pupa_cv_prog_objcopy_absolute=no grub_cv_prog_objcopy_absolute=no
break break
fi fi
done done
rm -f conftest*]) rm -f conftest*])
AC_MSG_RESULT([$pupa_cv_prog_objcopy_absolute]) AC_MSG_RESULT([$grub_cv_prog_objcopy_absolute])
if test "x$pupa_cv_prog_objcopy_absolute" = xno; then if test "x$grub_cv_prog_objcopy_absolute" = xno; then
AC_MSG_ERROR([PUPA requires a working absolute objcopy; upgrade your binutils]) AC_MSG_ERROR([GRUB requires a working absolute objcopy; upgrade your binutils])
fi fi
]) ])
@ -94,77 +94,77 @@ dnl
dnl We only support the newer versions, because the old versions cause dnl We only support the newer versions, because the old versions cause
dnl major pain, by requiring manual assembly to get 16-bit instructions into dnl major pain, by requiring manual assembly to get 16-bit instructions into
dnl asm files. dnl asm files.
AC_DEFUN(pupa_I386_ASM_ADDR32, AC_DEFUN(grub_I386_ASM_ADDR32,
[AC_REQUIRE([AC_PROG_CC]) [AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([pupa_I386_ASM_PREFIX_REQUIREMENT]) AC_REQUIRE([grub_I386_ASM_PREFIX_REQUIREMENT])
AC_MSG_CHECKING([for .code16 addr32 assembler support]) AC_MSG_CHECKING([for .code16 addr32 assembler support])
AC_CACHE_VAL(pupa_cv_i386_asm_addr32, AC_CACHE_VAL(grub_cv_i386_asm_addr32,
[cat > conftest.s.in <<\EOF [cat > conftest.s.in <<\EOF
.code16 .code16
l1: @ADDR32@ movb %al, l1 l1: @ADDR32@ movb %al, l1
EOF EOF
if test "x$pupa_cv_i386_asm_prefix_requirement" = xyes; then if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then
sed -e s/@ADDR32@/addr32/ < conftest.s.in > conftest.s sed -e s/@ADDR32@/addr32/ < conftest.s.in > conftest.s
else else
sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s
fi fi
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
pupa_cv_i386_asm_addr32=yes grub_cv_i386_asm_addr32=yes
else else
pupa_cv_i386_asm_addr32=no grub_cv_i386_asm_addr32=no
fi fi
rm -f conftest*]) rm -f conftest*])
AC_MSG_RESULT([$pupa_cv_i386_asm_addr32])]) AC_MSG_RESULT([$grub_cv_i386_asm_addr32])])
dnl Later versions of GAS requires that addr32 and data32 prefixes dnl Later versions of GAS requires that addr32 and data32 prefixes
dnl appear in the same lines as the instructions they modify, while dnl appear in the same lines as the instructions they modify, while
dnl earlier versions requires that they appear in separate lines. dnl earlier versions requires that they appear in separate lines.
AC_DEFUN(pupa_I386_ASM_PREFIX_REQUIREMENT, AC_DEFUN(grub_I386_ASM_PREFIX_REQUIREMENT,
[AC_REQUIRE([AC_PROG_CC]) [AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(dnl AC_MSG_CHECKING(dnl
[whether addr32 must be in the same line as the instruction]) [whether addr32 must be in the same line as the instruction])
AC_CACHE_VAL(pupa_cv_i386_asm_prefix_requirement, AC_CACHE_VAL(grub_cv_i386_asm_prefix_requirement,
[cat > conftest.s <<\EOF [cat > conftest.s <<\EOF
.code16 .code16
l1: addr32 movb %al, l1 l1: addr32 movb %al, l1
EOF EOF
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
pupa_cv_i386_asm_prefix_requirement=yes grub_cv_i386_asm_prefix_requirement=yes
else else
pupa_cv_i386_asm_prefix_requirement=no grub_cv_i386_asm_prefix_requirement=no
fi fi
rm -f conftest*]) rm -f conftest*])
if test "x$pupa_cv_i386_asm_prefix_requirement" = xyes; then if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then
pupa_tmp_addr32="addr32" grub_tmp_addr32="addr32"
pupa_tmp_data32="data32" grub_tmp_data32="data32"
else else
pupa_tmp_addr32="addr32;" grub_tmp_addr32="addr32;"
pupa_tmp_data32="data32;" grub_tmp_data32="data32;"
fi fi
AC_DEFINE_UNQUOTED([ADDR32], $pupa_tmp_addr32, AC_DEFINE_UNQUOTED([ADDR32], $grub_tmp_addr32,
[Define it to \"addr32\" or \"addr32;\" to make GAS happy]) [Define it to \"addr32\" or \"addr32;\" to make GAS happy])
AC_DEFINE_UNQUOTED([DATA32], $pupa_tmp_data32, AC_DEFINE_UNQUOTED([DATA32], $grub_tmp_data32,
[Define it to \"data32\" or \"data32;\" to make GAS happy]) [Define it to \"data32\" or \"data32;\" to make GAS happy])
AC_MSG_RESULT([$pupa_cv_i386_asm_prefix_requirement])]) AC_MSG_RESULT([$grub_cv_i386_asm_prefix_requirement])])
dnl Older versions of GAS require that absolute indirect calls/jumps are dnl Older versions of GAS require that absolute indirect calls/jumps are
dnl not prefixed with `*', while later versions warn if not prefixed. dnl not prefixed with `*', while later versions warn if not prefixed.
AC_DEFUN(pupa_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK, AC_DEFUN(grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK,
[AC_REQUIRE([AC_PROG_CC]) [AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(dnl AC_MSG_CHECKING(dnl
[whether an absolute indirect call/jump must not be prefixed with an asterisk]) [whether an absolute indirect call/jump must not be prefixed with an asterisk])
AC_CACHE_VAL(pupa_cv_i386_asm_absolute_without_asterisk, AC_CACHE_VAL(grub_cv_i386_asm_absolute_without_asterisk,
[cat > conftest.s <<\EOF [cat > conftest.s <<\EOF
lcall *(offset) lcall *(offset)
offset: offset:
@ -173,46 +173,46 @@ offset:
EOF EOF
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
pupa_cv_i386_asm_absolute_without_asterisk=no grub_cv_i386_asm_absolute_without_asterisk=no
else else
pupa_cv_i386_asm_absolute_without_asterisk=yes grub_cv_i386_asm_absolute_without_asterisk=yes
fi fi
rm -f conftest*]) rm -f conftest*])
if test "x$pupa_cv_i386_asm_absolute_without_asterisk" = xyes; then if test "x$grub_cv_i386_asm_absolute_without_asterisk" = xyes; then
AC_DEFINE([ABSOLUTE_WITHOUT_ASTERISK], 1, AC_DEFINE([ABSOLUTE_WITHOUT_ASTERISK], 1,
[Define it if GAS requires that absolute indirect calls/jumps are not prefixed with an asterisk]) [Define it if GAS requires that absolute indirect calls/jumps are not prefixed with an asterisk])
fi fi
AC_MSG_RESULT([$pupa_cv_i386_asm_absolute_without_asterisk])]) AC_MSG_RESULT([$grub_cv_i386_asm_absolute_without_asterisk])])
dnl Check what symbol is defined as a start symbol. dnl Check what symbol is defined as a start symbol.
dnl Written by Yoshinori K. Okuji. dnl Written by Yoshinori K. Okuji.
AC_DEFUN(pupa_CHECK_START_SYMBOL, AC_DEFUN(grub_CHECK_START_SYMBOL,
[AC_REQUIRE([AC_PROG_CC]) [AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if start is defined by the compiler]) AC_MSG_CHECKING([if start is defined by the compiler])
AC_CACHE_VAL(pupa_cv_check_start_symbol, AC_CACHE_VAL(grub_cv_check_start_symbol,
[AC_TRY_LINK([], [asm ("incl start")], [AC_TRY_LINK([], [asm ("incl start")],
pupa_cv_check_start_symbol=yes, grub_cv_check_start_symbol=yes,
pupa_cv_check_start_symbol=no)]) grub_cv_check_start_symbol=no)])
AC_MSG_RESULT([$pupa_cv_check_start_symbol]) AC_MSG_RESULT([$grub_cv_check_start_symbol])
AC_MSG_CHECKING([if _start is defined by the compiler]) AC_MSG_CHECKING([if _start is defined by the compiler])
AC_CACHE_VAL(pupa_cv_check_uscore_start_symbol, AC_CACHE_VAL(grub_cv_check_uscore_start_symbol,
[AC_TRY_LINK([], [asm ("incl _start")], [AC_TRY_LINK([], [asm ("incl _start")],
pupa_cv_check_uscore_start_symbol=yes, grub_cv_check_uscore_start_symbol=yes,
pupa_cv_check_uscore_start_symbol=no)]) grub_cv_check_uscore_start_symbol=no)])
AC_MSG_RESULT([$pupa_cv_check_uscore_start_symbol]) AC_MSG_RESULT([$grub_cv_check_uscore_start_symbol])
AH_TEMPLATE([START_SYMBOL], [Define it to either start or _start]) AH_TEMPLATE([START_SYMBOL], [Define it to either start or _start])
if test "x$pupa_cv_check_start_symbol" = xyes; then if test "x$grub_cv_check_start_symbol" = xyes; then
AC_DEFINE([START_SYMBOL], [start]) AC_DEFINE([START_SYMBOL], [start])
elif test "x$pupa_cv_check_uscore_start_symbol" = xyes; then elif test "x$grub_cv_check_uscore_start_symbol" = xyes; then
AC_DEFINE([START_SYMBOL], [_start]) AC_DEFINE([START_SYMBOL], [_start])
else else
AC_MSG_ERROR([neither start nor _start is defined]) AC_MSG_ERROR([neither start nor _start is defined])
@ -221,39 +221,39 @@ fi
dnl Check what symbol is defined as a bss start symbol. dnl Check what symbol is defined as a bss start symbol.
dnl Written by Michael Hohmoth and Yoshinori K. Okuji. dnl Written by Michael Hohmoth and Yoshinori K. Okuji.
AC_DEFUN(pupa_CHECK_BSS_START_SYMBOL, AC_DEFUN(grub_CHECK_BSS_START_SYMBOL,
[AC_REQUIRE([AC_PROG_CC]) [AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if __bss_start is defined by the compiler]) AC_MSG_CHECKING([if __bss_start is defined by the compiler])
AC_CACHE_VAL(pupa_cv_check_uscore_uscore_bss_start_symbol, AC_CACHE_VAL(grub_cv_check_uscore_uscore_bss_start_symbol,
[AC_TRY_LINK([], [asm ("incl __bss_start")], [AC_TRY_LINK([], [asm ("incl __bss_start")],
pupa_cv_check_uscore_uscore_bss_start_symbol=yes, grub_cv_check_uscore_uscore_bss_start_symbol=yes,
pupa_cv_check_uscore_uscore_bss_start_symbol=no)]) grub_cv_check_uscore_uscore_bss_start_symbol=no)])
AC_MSG_RESULT([$pupa_cv_check_uscore_uscore_bss_start_symbol]) AC_MSG_RESULT([$grub_cv_check_uscore_uscore_bss_start_symbol])
AC_MSG_CHECKING([if edata is defined by the compiler]) AC_MSG_CHECKING([if edata is defined by the compiler])
AC_CACHE_VAL(pupa_cv_check_edata_symbol, AC_CACHE_VAL(grub_cv_check_edata_symbol,
[AC_TRY_LINK([], [asm ("incl edata")], [AC_TRY_LINK([], [asm ("incl edata")],
pupa_cv_check_edata_symbol=yes, grub_cv_check_edata_symbol=yes,
pupa_cv_check_edata_symbol=no)]) grub_cv_check_edata_symbol=no)])
AC_MSG_RESULT([$pupa_cv_check_edata_symbol]) AC_MSG_RESULT([$grub_cv_check_edata_symbol])
AC_MSG_CHECKING([if _edata is defined by the compiler]) AC_MSG_CHECKING([if _edata is defined by the compiler])
AC_CACHE_VAL(pupa_cv_check_uscore_edata_symbol, AC_CACHE_VAL(grub_cv_check_uscore_edata_symbol,
[AC_TRY_LINK([], [asm ("incl _edata")], [AC_TRY_LINK([], [asm ("incl _edata")],
pupa_cv_check_uscore_edata_symbol=yes, grub_cv_check_uscore_edata_symbol=yes,
pupa_cv_check_uscore_edata_symbol=no)]) grub_cv_check_uscore_edata_symbol=no)])
AC_MSG_RESULT([$pupa_cv_check_uscore_edata_symbol]) AC_MSG_RESULT([$grub_cv_check_uscore_edata_symbol])
AH_TEMPLATE([BSS_START_SYMBOL], [Define it to one of __bss_start, edata and _edata]) AH_TEMPLATE([BSS_START_SYMBOL], [Define it to one of __bss_start, edata and _edata])
if test "x$pupa_cv_check_uscore_uscore_bss_start_symbol" = xyes; then if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" = xyes; then
AC_DEFINE([BSS_START_SYMBOL], [__bss_start]) AC_DEFINE([BSS_START_SYMBOL], [__bss_start])
elif test "x$pupa_cv_check_edata_symbol" = xyes; then elif test "x$grub_cv_check_edata_symbol" = xyes; then
AC_DEFINE([BSS_START_SYMBOL], [edata]) AC_DEFINE([BSS_START_SYMBOL], [edata])
elif test "x$pupa_cv_check_uscore_edata_symbol" = xyes; then elif test "x$grub_cv_check_uscore_edata_symbol" = xyes; then
AC_DEFINE([BSS_START_SYMBOL], [_edata]) AC_DEFINE([BSS_START_SYMBOL], [_edata])
else else
AC_MSG_ERROR([none of __bss_start, edata or _edata is defined]) AC_MSG_ERROR([none of __bss_start, edata or _edata is defined])
@ -262,29 +262,29 @@ fi
dnl Check what symbol is defined as an end symbol. dnl Check what symbol is defined as an end symbol.
dnl Written by Yoshinori K. Okuji. dnl Written by Yoshinori K. Okuji.
AC_DEFUN(pupa_CHECK_END_SYMBOL, AC_DEFUN(grub_CHECK_END_SYMBOL,
[AC_REQUIRE([AC_PROG_CC]) [AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if end is defined by the compiler]) AC_MSG_CHECKING([if end is defined by the compiler])
AC_CACHE_VAL(pupa_cv_check_end_symbol, AC_CACHE_VAL(grub_cv_check_end_symbol,
[AC_TRY_LINK([], [asm ("incl end")], [AC_TRY_LINK([], [asm ("incl end")],
pupa_cv_check_end_symbol=yes, grub_cv_check_end_symbol=yes,
pupa_cv_check_end_symbol=no)]) grub_cv_check_end_symbol=no)])
AC_MSG_RESULT([$pupa_cv_check_end_symbol]) AC_MSG_RESULT([$grub_cv_check_end_symbol])
AC_MSG_CHECKING([if _end is defined by the compiler]) AC_MSG_CHECKING([if _end is defined by the compiler])
AC_CACHE_VAL(pupa_cv_check_uscore_end_symbol, AC_CACHE_VAL(grub_cv_check_uscore_end_symbol,
[AC_TRY_LINK([], [asm ("incl _end")], [AC_TRY_LINK([], [asm ("incl _end")],
pupa_cv_check_uscore_end_symbol=yes, grub_cv_check_uscore_end_symbol=yes,
pupa_cv_check_uscore_end_symbol=no)]) grub_cv_check_uscore_end_symbol=no)])
AC_MSG_RESULT([$pupa_cv_check_uscore_end_symbol]) AC_MSG_RESULT([$grub_cv_check_uscore_end_symbol])
AH_TEMPLATE([END_SYMBOL], [Define it to either end or _end]) AH_TEMPLATE([END_SYMBOL], [Define it to either end or _end])
if test "x$pupa_cv_check_end_symbol" = xyes; then if test "x$grub_cv_check_end_symbol" = xyes; then
AC_DEFINE([END_SYMBOL], [end]) AC_DEFINE([END_SYMBOL], [end])
elif test "x$pupa_cv_check_uscore_end_symbol" = xyes; then elif test "x$grub_cv_check_uscore_end_symbol" = xyes; then
AC_DEFINE([END_SYMBOL], [_end]) AC_DEFINE([END_SYMBOL], [_end])
else else
AC_MSG_ERROR([neither end nor _end is defined]) AC_MSG_ERROR([neither end nor _end is defined])
@ -295,10 +295,10 @@ dnl Check if the C compiler has a bug while using nested functions when
dnl mregparm is used on the i386. Some gcc versions do not pass the third dnl mregparm is used on the i386. Some gcc versions do not pass the third
dnl parameter correctly to the nested function. dnl parameter correctly to the nested function.
dnl Written by Marco Gerards. dnl Written by Marco Gerards.
AC_DEFUN(pupa_I386_CHECK_REGPARM_BUG, AC_DEFUN(grub_I386_CHECK_REGPARM_BUG,
[AC_REQUIRE([AC_PROG_CC]) [AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if GCC has the regparm=3 bug]) AC_MSG_CHECKING([if GCC has the regparm=3 bug])
AC_CACHE_VAL(pupa_cv_i386_check_nested_functions, AC_CACHE_VAL(grub_cv_i386_check_nested_functions,
[AC_RUN_IFELSE([AC_LANG_SOURCE( [AC_RUN_IFELSE([AC_LANG_SOURCE(
[[int *p; [[int *p;
@ -316,12 +316,12 @@ main ()
return nestedfunc (0, 0, 0); return nestedfunc (0, 0, 0);
} }
]])], ]])],
[pupa_cv_i386_check_nested_functions=yes], [grub_cv_i386_check_nested_functions=yes],
[pupa_cv_i386_check_nested_functions=no])]) [grub_cv_i386_check_nested_functions=no])])
AC_MSG_RESULT([$pupa_cv_i386_check_nested_functions]) AC_MSG_RESULT([$grub_cv_i386_check_nested_functions])
if test "x$pupa_cv_i386_check_nested_functions" = xyes; then if test "x$grub_cv_i386_check_nested_functions" = xyes; then
AC_DEFINE([NESTED_FUNC_ATTR], AC_DEFINE([NESTED_FUNC_ATTR],
[__attribute__ ((__regparm__ (2)))], [__attribute__ ((__regparm__ (2)))],
[Catch gcc bug]) [Catch gcc bug])

View file

@ -1,6 +1,6 @@
/* -*-Asm-*- */ /* -*-Asm-*- */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,8 +18,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/boot.h> #include <grub/boot.h>
#include <pupa/machine/boot.h> #include <grub/machine/boot.h>
/* /*
* defines for the code go here * defines for the code go here
@ -83,25 +83,25 @@ cylinder_start:
.word 0 .word 0
/* more space... */ /* more space... */
. = _start + PUPA_BOOT_MACHINE_BPB_END . = _start + GRUB_BOOT_MACHINE_BPB_END
/* /*
* End of BIOS parameter block. * End of BIOS parameter block.
*/ */
boot_version: boot_version:
.byte PUPA_BOOT_VERSION_MAJOR, PUPA_BOOT_VERSION_MINOR .byte GRUB_BOOT_VERSION_MAJOR, GRUB_BOOT_VERSION_MINOR
boot_drive: boot_drive:
.byte 0xff /* the disk to load kernel from */ .byte 0xff /* the disk to load kernel from */
/* 0xff means use the boot drive */ /* 0xff means use the boot drive */
force_lba: force_lba:
.byte 0 .byte 0
kernel_address: kernel_address:
.word PUPA_BOOT_MACHINE_KERNEL_ADDR .word GRUB_BOOT_MACHINE_KERNEL_ADDR
kernel_sector: kernel_sector:
.long 1 .long 1
kernel_segment: kernel_segment:
.word PUPA_BOOT_MACHINE_KERNEL_SEG .word GRUB_BOOT_MACHINE_KERNEL_SEG
after_BPB: after_BPB:
@ -122,7 +122,7 @@ real_start:
movw %ax, %ss movw %ax, %ss
/* set up the REAL stack */ /* set up the REAL stack */
movw $PUPA_BOOT_MACHINE_STACK_SEG, %sp movw $GRUB_BOOT_MACHINE_STACK_SEG, %sp
sti /* we're safe again */ sti /* we're safe again */
@ -141,7 +141,7 @@ real_start:
MSG(notification_string) MSG(notification_string)
/* do not probe LBA if the drive is a floppy */ /* do not probe LBA if the drive is a floppy */
testb $PUPA_BOOT_MACHINE_BIOS_HD_FLAG, %dl testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
jz chs_mode jz chs_mode
/* check if LBA is supported */ /* check if LBA is supported */
@ -190,7 +190,7 @@ lba_mode:
movl %ebx, 8(%si) movl %ebx, 8(%si)
/* the segment of buffer address */ /* the segment of buffer address */
movw $PUPA_BOOT_MACHINE_BUFFER_SEG, 6(%si) movw $GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si)
xorl %eax, %eax xorl %eax, %eax
movw %ax, 4(%si) movw %ax, 4(%si)
@ -211,7 +211,7 @@ lba_mode:
/* LBA read is not supported, so fallback to CHS. */ /* LBA read is not supported, so fallback to CHS. */
jc chs_mode jc chs_mode
movw $PUPA_BOOT_MACHINE_BUFFER_SEG, %bx movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
jmp copy_buffer jmp copy_buffer
chs_mode: chs_mode:
@ -226,7 +226,7 @@ chs_mode:
/* /*
* The call failed, so maybe use the floppy probe instead. * The call failed, so maybe use the floppy probe instead.
*/ */
testb $PUPA_BOOT_MACHINE_BIOS_HD_FLAG, %dl testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
jz floppy_probe jz floppy_probe
/* Nope, we definitely have a hard disk, and we're screwed. */ /* Nope, we definitely have a hard disk, and we're screwed. */
@ -322,7 +322,7 @@ setup_sectors:
* %al = 0x0 on success; err code on failure * %al = 0x0 on success; err code on failure
*/ */
movw $PUPA_BOOT_MACHINE_BUFFER_SEG, %bx movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
movw %bx, %es /* load %es segment with disk buffer */ movw %bx, %es /* load %es segment with disk buffer */
xorw %bx, %bx /* %bx = 0, put it at 0 in the segment */ xorw %bx, %bx /* %bx = 0, put it at 0 in the segment */
@ -387,7 +387,7 @@ general_error:
/* go here when you need to stop the machine hard after an error condition */ /* go here when you need to stop the machine hard after an error condition */
stop: jmp stop stop: jmp stop
notification_string: .string "PUPA " notification_string: .string "GRUB "
geometry_error_string: .string "Geom" geometry_error_string: .string "Geom"
hd_probe_error_string: .string "Hard Disk" hd_probe_error_string: .string "Hard Disk"
read_error_string: .string "Read" read_error_string: .string "Read"
@ -419,7 +419,7 @@ message:
* number here. * number here.
*/ */
. = _start + PUPA_BOOT_MACHINE_WINDOWS_NT_MAGIC . = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
nt_magic: nt_magic:
.long 0 .long 0
.word 0 .word 0
@ -431,7 +431,7 @@ nt_magic:
*/ */
part_start: part_start:
. = _start + PUPA_BOOT_MACHINE_PART_START . = _start + GRUB_BOOT_MACHINE_PART_START
probe_values: probe_values:
.byte 36, 18, 15, 9, 0 .byte 36, 18, 15, 9, 0
@ -465,7 +465,7 @@ fd_probe_error_string: .string "Floppy"
1: 1:
/* perform read */ /* perform read */
movw $PUPA_BOOT_MACHINE_BUFFER_SEG, %bx movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
movw $0x201, %ax movw $0x201, %ax
movb $0, %ch movb $0, %ch
movb $0, %dh movb $0, %dh
@ -480,7 +480,7 @@ fd_probe_error_string: .string "Floppy"
jmp final_init jmp final_init
. = _start + PUPA_BOOT_MACHINE_PART_END . = _start + GRUB_BOOT_MACHINE_PART_END
/* the last 2 bytes in the sector 0 contain the signature */ /* the last 2 bytes in the sector 0 contain the signature */
.word PUPA_BOOT_MACHINE_SIGNATURE .word GRUB_BOOT_MACHINE_SIGNATURE

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,7 +17,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/machine/boot.h> #include <grub/machine/boot.h>
/* /*
* defines for the code go here * defines for the code go here
@ -26,7 +26,7 @@
/* Absolute addresses /* Absolute addresses
This makes the assembler generate the address without support This makes the assembler generate the address without support
from the linker. (ELF can't relocate 16-bit addresses!) */ from the linker. (ELF can't relocate 16-bit addresses!) */
#define ABS(x) (x-_start+PUPA_BOOT_MACHINE_KERNEL_ADDR) #define ABS(x) (x-_start+GRUB_BOOT_MACHINE_KERNEL_ADDR)
/* Print message string */ /* Print message string */
#define MSG(x) movw $ABS(x), %si; call message #define MSG(x) movw $ABS(x), %si; call message
@ -62,7 +62,7 @@ _start:
popw %si popw %si
/* this sets up for the first run through "bootloop" */ /* this sets up for the first run through "bootloop" */
movw $ABS(firstlist - PUPA_BOOT_MACHINE_LIST_SIZE), %di movw $ABS(firstlist - GRUB_BOOT_MACHINE_LIST_SIZE), %di
/* save the sector number of the second sector in %ebp */ /* save the sector number of the second sector in %ebp */
movl (%di), %ebp movl (%di), %ebp
@ -119,7 +119,7 @@ lba_mode:
movl %ebx, 8(%si) movl %ebx, 8(%si)
/* the segment of buffer address */ /* the segment of buffer address */
movw $PUPA_BOOT_MACHINE_BUFFER_SEG, 6(%si) movw $GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si)
/* save %ax from destruction! */ /* save %ax from destruction! */
pushw %ax pushw %ax
@ -148,7 +148,7 @@ lba_mode:
jc read_error jc read_error
movw $PUPA_BOOT_MACHINE_BUFFER_SEG, %bx movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
jmp copy_buffer jmp copy_buffer
chs_mode: chs_mode:
@ -237,7 +237,7 @@ chs_mode:
* %al = 0x0 on success; err code on failure * %al = 0x0 on success; err code on failure
*/ */
movw $PUPA_BOOT_MACHINE_BUFFER_SEG, %bx movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
movw %bx, %es /* load %es segment with disk buffer */ movw %bx, %es /* load %es segment with disk buffer */
xorw %bx, %bx /* %bx = 0, put it at 0 in the segment */ xorw %bx, %bx /* %bx = 0, put it at 0 in the segment */
@ -292,7 +292,7 @@ copy_buffer:
jne setup_sectors jne setup_sectors
/* update position to load from */ /* update position to load from */
subw $PUPA_BOOT_MACHINE_LIST_SIZE, %di subw $GRUB_BOOT_MACHINE_LIST_SIZE, %di
/* jump to bootloop */ /* jump to bootloop */
jmp bootloop jmp bootloop
@ -303,7 +303,7 @@ bootit:
/* print a newline */ /* print a newline */
MSG(notification_done) MSG(notification_done)
popw %dx /* this makes sure %dl is our "boot" drive */ popw %dx /* this makes sure %dl is our "boot" drive */
ljmp $0, $(PUPA_BOOT_MACHINE_KERNEL_ADDR + 0x200) ljmp $0, $(GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
/* /*
@ -368,7 +368,7 @@ lastlist:
.word 0 .word 0
.word 0 .word 0
. = _start + 0x200 - PUPA_BOOT_MACHINE_LIST_SIZE . = _start + 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE
/* fill the first data listing with the default */ /* fill the first data listing with the default */
blocklist_default_start: blocklist_default_start:
@ -381,6 +381,6 @@ blocklist_default_len:
.word 0 .word 0
blocklist_default_seg: blocklist_default_seg:
/* this is the segment of the starting address to load the data into */ /* this is the segment of the starting address to load the data into */
.word (PUPA_BOOT_MACHINE_KERNEL_SEG + 0x20) .word (GRUB_BOOT_MACHINE_KERNEL_SEG + 0x20)
firstlist: /* this label has to be after the list data!!! */ firstlist: /* this label has to be after the list data!!! */

View file

@ -1,6 +1,6 @@
/* cmain.c - Startup code for the PowerPC. */ /* cmain.c - Startup code for the PowerPC. */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 2004 Free Software Foundation, Inc. * Copyright (C) 2003, 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -21,8 +21,8 @@
#include <alloca.h> #include <alloca.h>
#include <stdint.h> #include <stdint.h>
#include "pupa/machine/ieee1275.h" #include "grub/machine/ieee1275.h"
#include "pupa/kernel.h" #include "grub/kernel.h"
struct module_info struct module_info
{ {
@ -33,7 +33,7 @@ struct module_info
#define roundup(a, s) (((a) + ((s) - 1)) & ~((s) - 1)) #define roundup(a, s) (((a) + ((s) - 1)) & ~((s) - 1))
/* OpenFirmware entry point passed to us from the real bootloader. */ /* OpenFirmware entry point passed to us from the real bootloader. */
intptr_t (*pupa_ieee1275_entry_fn) (void *); intptr_t (*grub_ieee1275_entry_fn) (void *);
/* Return a help text for this architecture. */ /* Return a help text for this architecture. */
@ -51,11 +51,11 @@ void
cmain (uint32_t firmware_entry) cmain (uint32_t firmware_entry)
{ {
char **argv, args[256]; char **argv, args[256];
pupa_ieee1275_phandle_t chosen; grub_ieee1275_phandle_t chosen;
int argc = 0, actual; int argc = 0, actual;
long batl, batu; long batl, batu;
pupa_ieee1275_entry_fn = (intptr_t (*)(void *)) firmware_entry; grub_ieee1275_entry_fn = (intptr_t (*)(void *)) firmware_entry;
/* Initialize BAT registers to unmapped to not generate overlapping /* Initialize BAT registers to unmapped to not generate overlapping
mappings below. */ mappings below. */
@ -83,8 +83,8 @@ cmain (uint32_t firmware_entry)
be null (just the nul-character), so check that the size be null (just the nul-character), so check that the size
is actually greater than one. */ is actually greater than one. */
pupa_ieee1275_finddevice ("/chosen", &chosen); grub_ieee1275_finddevice ("/chosen", &chosen);
if (pupa_ieee1275_get_property (chosen, "bootargs", args, if (grub_ieee1275_get_property (chosen, "bootargs", args,
sizeof args, &actual) == 0 sizeof args, &actual) == 0
&& actual > 1) && actual > 1)
{ {
@ -109,7 +109,7 @@ cmain (uint32_t firmware_entry)
/* The bootargs property does not contain the program /* The bootargs property does not contain the program
name, just the arguments. */ name, just the arguments. */
argv[0] = "pupa"; argv[0] = "grub";
/* Second time around we fill in the argv. */ /* Second time around we fill in the argv. */
str = args; str = args;
@ -136,13 +136,13 @@ cmain (uint32_t firmware_entry)
else else
{ {
argv = alloca (sizeof (char *) * 2); argv = alloca (sizeof (char *) * 2);
argv[0] = "pupa"; argv[0] = "grub";
argv[1] = 0; argv[1] = 0;
argc = 1; argc = 1;
} }
/* Now invoke the main function. */ /* Now invoke the main function. */
/* XXX: pupa_main does not parse arguments yet. */ /* XXX: grub_main does not parse arguments yet. */
pupa_main (); grub_main ();
/* Never reached. */ /* Never reached. */
} }

View file

@ -1,6 +1,6 @@
/* crt0.S - Startup code for the PowerPC. */ /* crt0.S - Startup code for the PowerPC. */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 2004 Free Software Foundation, Inc. * Copyright (C) 2003, 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View file

@ -1,6 +1,6 @@
/* ieee1275.c - Access the Open Firmware client interface. */ /* ieee1275.c - Access the Open Firmware client interface. */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 2004 Free Software Foundation, Inc. * Copyright (C) 2003, 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,16 +18,16 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/machine/ieee1275.h> #include <grub/machine/ieee1275.h>
#define IEEE1275_PHANDLE_ROOT ((pupa_ieee1275_phandle_t) 0) #define IEEE1275_PHANDLE_ROOT ((grub_ieee1275_phandle_t) 0)
#define IEEE1275_PHANDLE_INVALID ((pupa_ieee1275_phandle_t) -1) #define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1)
intptr_t (*pupa_ieee1275_entry_fn) (void *); intptr_t (*grub_ieee1275_entry_fn) (void *);
#ifndef IEEE1275_CALL_ENTRY_FN #ifndef IEEE1275_CALL_ENTRY_FN
#define IEEE1275_CALL_ENTRY_FN(args) (*pupa_ieee1275_entry_fn) (args) #define IEEE1275_CALL_ENTRY_FN(args) (*grub_ieee1275_entry_fn) (args)
#endif #endif
/* All backcalls to the firmware is done by calling an entry function /* All backcalls to the firmware is done by calling an entry function
@ -35,7 +35,7 @@ intptr_t (*pupa_ieee1275_entry_fn) (void *);
a structure is passed which specifies what the firmware should do. a structure is passed which specifies what the firmware should do.
NAME is the requested service. NR_INS and NR_OUTS is the number of NAME is the requested service. NR_INS and NR_OUTS is the number of
passed arguments and the expected number of return values, resp. */ passed arguments and the expected number of return values, resp. */
struct pupa_ieee1275_common_hdr struct grub_ieee1275_common_hdr
{ {
char *name; char *name;
int nr_ins; int nr_ins;
@ -46,10 +46,10 @@ struct pupa_ieee1275_common_hdr
(p)->name = xname; (p)->nr_ins = xins; (p)->nr_outs = xouts (p)->name = xname; (p)->nr_ins = xins; (p)->nr_outs = xouts
/* FIXME is this function needed? */ /* FIXME is this function needed? */
pupa_uint32_t grub_uint32_t
pupa_ieee1275_decode_int_4 (unsigned char *p) grub_ieee1275_decode_int_4 (unsigned char *p)
{ {
pupa_uint32_t val = (*p++ << 8); grub_uint32_t val = (*p++ << 8);
val = (val + *p++) << 8; val = (val + *p++) << 8;
val = (val + *p++) << 8; val = (val + *p++) << 8;
return (val + *p); return (val + *p);
@ -57,12 +57,12 @@ pupa_ieee1275_decode_int_4 (unsigned char *p)
int int
pupa_ieee1275_finddevice (char *name, pupa_ieee1275_phandle_t *phandlep) grub_ieee1275_finddevice (char *name, grub_ieee1275_phandle_t *phandlep)
{ {
struct find_device_args { struct find_device_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
char *device; char *device;
pupa_ieee1275_phandle_t phandle; grub_ieee1275_phandle_t phandle;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1); INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1);
@ -75,12 +75,12 @@ pupa_ieee1275_finddevice (char *name, pupa_ieee1275_phandle_t *phandlep)
} }
int int
pupa_ieee1275_get_property (int handle, const char *property, void *buf, grub_ieee1275_get_property (int handle, const char *property, void *buf,
pupa_size_t size, pupa_size_t *actual) grub_size_t size, grub_size_t *actual)
{ {
struct get_property_args { struct get_property_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_phandle_t phandle; grub_ieee1275_phandle_t phandle;
const char *prop; const char *prop;
void *buf; void *buf;
int buflen; int buflen;
@ -101,12 +101,12 @@ pupa_ieee1275_get_property (int handle, const char *property, void *buf,
} }
int int
pupa_ieee1275_next_property (int handle, char *prev_prop, char *prop, grub_ieee1275_next_property (int handle, char *prev_prop, char *prop,
int *flags) int *flags)
{ {
struct get_property_args { struct get_property_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_phandle_t phandle; grub_ieee1275_phandle_t phandle;
char *prev_prop; char *prev_prop;
char *next_prop; char *next_prop;
int flags; int flags;
@ -126,14 +126,14 @@ pupa_ieee1275_next_property (int handle, char *prev_prop, char *prop,
} }
int int
pupa_ieee1275_get_property_length (pupa_ieee1275_phandle_t handle, grub_ieee1275_get_property_length (grub_ieee1275_phandle_t handle,
const char *prop, pupa_size_t *length) const char *prop, grub_size_t *length)
{ {
struct get_property_args { struct get_property_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_phandle_t phandle; grub_ieee1275_phandle_t phandle;
const char *prop; const char *prop;
pupa_size_t length; grub_size_t length;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1); INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1);
@ -148,13 +148,13 @@ pupa_ieee1275_get_property_length (pupa_ieee1275_phandle_t handle,
} }
int int
pupa_ieee1275_instance_to_package (pupa_ieee1275_ihandle_t ihandle, grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle,
pupa_ieee1275_phandle_t *phandlep) grub_ieee1275_phandle_t *phandlep)
{ {
struct instance_to_package_args { struct instance_to_package_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_ihandle_t ihandle; grub_ieee1275_ihandle_t ihandle;
pupa_ieee1275_phandle_t phandle; grub_ieee1275_phandle_t phandle;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1); INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1);
@ -167,12 +167,12 @@ pupa_ieee1275_instance_to_package (pupa_ieee1275_ihandle_t ihandle,
} }
int int
pupa_ieee1275_package_to_path (pupa_ieee1275_phandle_t phandle, grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle,
char *path, pupa_size_t len, pupa_size_t *actual) char *path, grub_size_t len, grub_size_t *actual)
{ {
struct instance_to_package_args { struct instance_to_package_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_phandle_t phandle; grub_ieee1275_phandle_t phandle;
char *buf; char *buf;
int buflen; int buflen;
int actual; int actual;
@ -191,13 +191,13 @@ pupa_ieee1275_package_to_path (pupa_ieee1275_phandle_t phandle,
} }
int int
pupa_ieee1275_instance_to_path (pupa_ieee1275_ihandle_t ihandle, grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
char *path, pupa_size_t len, char *path, grub_size_t len,
pupa_size_t *actual) grub_size_t *actual)
{ {
struct instance_to_package_args { struct instance_to_package_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_ihandle_t ihandle; grub_ieee1275_ihandle_t ihandle;
char *buf; char *buf;
int buflen; int buflen;
int actual; int actual;
@ -216,15 +216,15 @@ pupa_ieee1275_instance_to_path (pupa_ieee1275_ihandle_t ihandle,
} }
int int
pupa_ieee1275_write (pupa_ieee1275_ihandle_t ihandle, void *buffer, grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer,
pupa_size_t len, pupa_size_t *actualp) grub_size_t len, grub_size_t *actualp)
{ {
struct write_args { struct write_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_ihandle_t ihandle; grub_ieee1275_ihandle_t ihandle;
void *buf; void *buf;
pupa_size_t len; grub_size_t len;
pupa_size_t actual; grub_size_t actual;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "write", 3, 1); INIT_IEEE1275_COMMON (&args.common, "write", 3, 1);
@ -240,15 +240,15 @@ pupa_ieee1275_write (pupa_ieee1275_ihandle_t ihandle, void *buffer,
} }
int int
pupa_ieee1275_read (pupa_ieee1275_ihandle_t ihandle, void *buffer, grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
pupa_size_t len, pupa_size_t *actualp) grub_size_t len, grub_size_t *actualp)
{ {
struct write_args { struct write_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_ihandle_t ihandle; grub_ieee1275_ihandle_t ihandle;
void *buf; void *buf;
pupa_size_t len; grub_size_t len;
pupa_size_t actual; grub_size_t actual;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "read", 3, 1); INIT_IEEE1275_COMMON (&args.common, "read", 3, 1);
@ -264,12 +264,12 @@ pupa_ieee1275_read (pupa_ieee1275_ihandle_t ihandle, void *buffer,
} }
int int
pupa_ieee1275_seek (pupa_ieee1275_ihandle_t ihandle, int pos_hi, grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi,
int pos_lo, int *result) int pos_lo, int *result)
{ {
struct write_args { struct write_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_ihandle_t ihandle; grub_ieee1275_ihandle_t ihandle;
int pos_hi; int pos_hi;
int pos_lo; int pos_lo;
int result; int result;
@ -289,13 +289,13 @@ pupa_ieee1275_seek (pupa_ieee1275_ihandle_t ihandle, int pos_hi,
} }
int int
pupa_ieee1275_peer (pupa_ieee1275_phandle_t node, grub_ieee1275_peer (grub_ieee1275_phandle_t node,
pupa_ieee1275_phandle_t *result) grub_ieee1275_phandle_t *result)
{ {
struct peer_args { struct peer_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_phandle_t node; grub_ieee1275_phandle_t node;
pupa_ieee1275_phandle_t result; grub_ieee1275_phandle_t result;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1); INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1);
@ -308,13 +308,13 @@ pupa_ieee1275_peer (pupa_ieee1275_phandle_t node,
} }
int int
pupa_ieee1275_child (pupa_ieee1275_phandle_t node, grub_ieee1275_child (grub_ieee1275_phandle_t node,
pupa_ieee1275_phandle_t *result) grub_ieee1275_phandle_t *result)
{ {
struct child_args { struct child_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_phandle_t node; grub_ieee1275_phandle_t node;
pupa_ieee1275_phandle_t result; grub_ieee1275_phandle_t result;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "child", 1, 1); INIT_IEEE1275_COMMON (&args.common, "child", 1, 1);
@ -328,13 +328,13 @@ pupa_ieee1275_child (pupa_ieee1275_phandle_t node,
} }
int int
pupa_ieee1275_parent (pupa_ieee1275_phandle_t node, grub_ieee1275_parent (grub_ieee1275_phandle_t node,
pupa_ieee1275_phandle_t *result) grub_ieee1275_phandle_t *result)
{ {
struct parent_args { struct parent_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_phandle_t node; grub_ieee1275_phandle_t node;
pupa_ieee1275_phandle_t result; grub_ieee1275_phandle_t result;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1); INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1);
@ -348,10 +348,10 @@ pupa_ieee1275_parent (pupa_ieee1275_phandle_t node,
} }
int int
pupa_ieee1275_exit (void) grub_ieee1275_exit (void)
{ {
struct exit_args { struct exit_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0); INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0);
@ -362,12 +362,12 @@ pupa_ieee1275_exit (void)
} }
int int
pupa_ieee1275_open (char *node, pupa_ieee1275_ihandle_t *result) grub_ieee1275_open (char *node, grub_ieee1275_ihandle_t *result)
{ {
struct open_args { struct open_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
char *cstr; char *cstr;
pupa_ieee1275_ihandle_t result; grub_ieee1275_ihandle_t result;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "open", 1, 1); INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
@ -380,11 +380,11 @@ pupa_ieee1275_open (char *node, pupa_ieee1275_ihandle_t *result)
} }
int int
pupa_ieee1275_close (pupa_ieee1275_ihandle_t ihandle) grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
{ {
struct close_args { struct close_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_ihandle_t ihandle; grub_ieee1275_ihandle_t ihandle;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "close", 1, 0); INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
@ -397,13 +397,13 @@ pupa_ieee1275_close (pupa_ieee1275_ihandle_t ihandle)
} }
int int
pupa_ieee1275_claim (void *p, pupa_size_t size, grub_ieee1275_claim (void *p, grub_size_t size,
unsigned int align, void **result) unsigned int align, void **result)
{ {
struct claim_args { struct claim_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
void *p; void *p;
pupa_size_t size; grub_size_t size;
unsigned int align; unsigned int align;
void *addr; void *addr;
} args; } args;
@ -420,17 +420,17 @@ pupa_ieee1275_claim (void *p, pupa_size_t size,
} }
int int
pupa_ieee1275_set_property (pupa_ieee1275_phandle_t phandle, grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle,
const char *propname, void *buf, const char *propname, void *buf,
pupa_size_t size, pupa_size_t *actual) grub_size_t size, grub_size_t *actual)
{ {
struct set_property_args { struct set_property_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
pupa_ieee1275_phandle_t phandle; grub_ieee1275_phandle_t phandle;
const char *propname; const char *propname;
void *buf; void *buf;
pupa_size_t size; grub_size_t size;
pupa_size_t actual; grub_size_t actual;
} args; } args;
INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1); INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1);
@ -446,13 +446,13 @@ pupa_ieee1275_set_property (pupa_ieee1275_phandle_t phandle,
} }
int int
pupa_ieee1275_set_color (pupa_ieee1275_ihandle_t ihandle, grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle,
int index, int r, int g, int b) int index, int r, int g, int b)
{ {
struct set_color_args { struct set_color_args {
struct pupa_ieee1275_common_hdr common; struct grub_ieee1275_common_hdr common;
char *method; char *method;
pupa_ieee1275_ihandle_t ihandle; grub_ieee1275_ihandle_t ihandle;
int index; int index;
int b; int b;
int g; int g;

View file

@ -1,9 +1,9 @@
/* boot.c - command to boot an operating system */ /* boot.c - command to boot an operating system */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,52 +14,52 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/normal.h> #include <grub/normal.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/arg.h> #include <grub/arg.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/loader.h> #include <grub/loader.h>
static pupa_err_t static grub_err_t
pupa_cmd_boot (struct pupa_arg_list *state __attribute__ ((unused)), grub_cmd_boot (struct grub_arg_list *state __attribute__ ((unused)),
int argc, char **args __attribute__ ((unused))) int argc, char **args __attribute__ ((unused)))
{ {
if (argc) if (argc)
return pupa_error (PUPA_ERR_BAD_ARGUMENT, "too many arguments"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many arguments");
pupa_loader_boot (); grub_loader_boot ();
return 0; return 0;
} }
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
void void
pupa_boot_init (void) grub_boot_init (void)
{ {
pupa_register_command ("boot", pupa_cmd_boot, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("boot", grub_cmd_boot, GRUB_COMMAND_FLAG_BOTH,
"boot", "Boot an operating system", 0); "boot", "Boot an operating system", 0);
} }
void void
pupa_boot_fini (void) grub_boot_fini (void)
{ {
pupa_unregister_command ("boot"); grub_unregister_command ("boot");
} }
#else /* ! PUPA_UTIL */ #else /* ! GRUB_UTIL */
PUPA_MOD_INIT GRUB_MOD_INIT
{ {
(void)mod; /* To stop warning. */ (void)mod; /* To stop warning. */
pupa_register_command ("boot", pupa_cmd_boot, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("boot", grub_cmd_boot, GRUB_COMMAND_FLAG_BOTH,
"boot", "Boot an operating system", 0); "boot", "Boot an operating system", 0);
} }
PUPA_MOD_FINI GRUB_MOD_FINI
{ {
pupa_unregister_command ("boot"); grub_unregister_command ("boot");
} }
#endif /* ! PUPA_UTIL */ #endif /* ! GRUB_UTIL */

View file

@ -1,9 +1,9 @@
/* cat.c - command to show the contents of a file */ /* cat.c - command to show the contents of a file */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,35 +14,35 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/normal.h> #include <grub/normal.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/arg.h> #include <grub/arg.h>
#include <pupa/file.h> #include <grub/file.h>
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/term.h> #include <grub/term.h>
#include <pupa/misc.h> #include <grub/misc.h>
static pupa_err_t static grub_err_t
pupa_cmd_cat (struct pupa_arg_list *state __attribute__ ((unused)), grub_cmd_cat (struct grub_arg_list *state __attribute__ ((unused)),
int argc, char **args) int argc, char **args)
{ {
pupa_file_t file; grub_file_t file;
char buf[PUPA_DISK_SECTOR_SIZE]; char buf[GRUB_DISK_SECTOR_SIZE];
pupa_ssize_t size; grub_ssize_t size;
if (argc != 1) if (argc != 1)
return pupa_error (PUPA_ERR_BAD_ARGUMENT, "file name required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
file = pupa_file_open (args[0]); file = grub_file_open (args[0]);
if (! file) if (! file)
return 0; return 0;
while ((size = pupa_file_read (file, buf, sizeof (buf))) > 0) while ((size = grub_file_read (file, buf, sizeof (buf))) > 0)
{ {
int i; int i;
@ -50,48 +50,48 @@ pupa_cmd_cat (struct pupa_arg_list *state __attribute__ ((unused)),
{ {
unsigned char c = buf[i]; unsigned char c = buf[i];
if (pupa_isprint (c) || pupa_isspace (c)) if (grub_isprint (c) || grub_isspace (c))
pupa_putchar (c); grub_putchar (c);
else else
{ {
pupa_setcolorstate (PUPA_TERM_COLOR_HIGHLIGHT); grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
pupa_printf ("<%x>", (int) c); grub_printf ("<%x>", (int) c);
pupa_setcolorstate (PUPA_TERM_COLOR_STANDARD); grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
} }
} }
} }
pupa_putchar ('\n'); grub_putchar ('\n');
pupa_refresh (); grub_refresh ();
pupa_file_close (file); grub_file_close (file);
return 0; return 0;
} }
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
void void
pupa_cat_init (void) grub_cat_init (void)
{ {
pupa_register_command ("cat", pupa_cmd_cat, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("cat", grub_cmd_cat, GRUB_COMMAND_FLAG_BOTH,
"cat FILE", "Show the contents of a file", 0); "cat FILE", "Show the contents of a file", 0);
} }
void void
pupa_cat_fini (void) grub_cat_fini (void)
{ {
pupa_unregister_command ("cat"); grub_unregister_command ("cat");
} }
#else /* ! PUPA_UTIL */ #else /* ! GRUB_UTIL */
PUPA_MOD_INIT GRUB_MOD_INIT
{ {
(void)mod; /* To stop warning. */ (void)mod; /* To stop warning. */
pupa_register_command ("cat", pupa_cmd_cat, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("cat", grub_cmd_cat, GRUB_COMMAND_FLAG_BOTH,
"cat FILE", "Show the contents of a file", 0); "cat FILE", "Show the contents of a file", 0);
} }
PUPA_MOD_FINI GRUB_MOD_FINI
{ {
pupa_unregister_command ("cat"); grub_unregister_command ("cat");
} }
#endif /* ! PUPA_UTIL */ #endif /* ! GRUB_UTIL */

View file

@ -1,9 +1,9 @@
/* cmd.c - command to cmp an operating system */ /* cmd.c - command to cmp an operating system */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,57 +14,57 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/normal.h> #include <grub/normal.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/arg.h> #include <grub/arg.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/file.h> #include <grub/file.h>
static pupa_err_t static grub_err_t
pupa_cmd_cmp (struct pupa_arg_list *state __attribute__ ((unused)), grub_cmd_cmp (struct grub_arg_list *state __attribute__ ((unused)),
int argc, char **args) int argc, char **args)
{ {
pupa_file_t file1; grub_file_t file1;
pupa_file_t file2; grub_file_t file2;
if (argc != 2) if (argc != 2)
return pupa_error (PUPA_ERR_BAD_ARGUMENT, "two arguments required"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "two arguments required");
pupa_printf ("Compare `%s' and `%s':\n", args[0], grub_printf ("Compare `%s' and `%s':\n", args[0],
args[1]); args[1]);
file1 = pupa_file_open (args[0]); file1 = grub_file_open (args[0]);
if (! file1) if (! file1)
return pupa_errno; return grub_errno;
file2 = pupa_file_open (args[1]); file2 = grub_file_open (args[1]);
if (! file2) if (! file2)
{ {
pupa_file_close (file2); grub_file_close (file2);
return pupa_errno; return grub_errno;
} }
if (pupa_file_size (file1) != pupa_file_size (file2)) if (grub_file_size (file1) != grub_file_size (file2))
pupa_printf ("Differ in size: %d [%s], %d [%s]\n", grub_printf ("Differ in size: %d [%s], %d [%s]\n",
pupa_file_size (file1), args[0], grub_file_size (file1), args[0],
pupa_file_size (file2), args[1]); grub_file_size (file2), args[1]);
else else
{ {
char buf1[512]; char buf1[512];
char buf2[512]; char buf2[512];
pupa_ssize_t rd1, rd2; grub_ssize_t rd1, rd2;
pupa_uint32_t pos = 0; grub_uint32_t pos = 0;
do do
{ {
int i; int i;
rd1 = pupa_file_read (file1, buf1, 512); rd1 = grub_file_read (file1, buf1, 512);
rd2 = pupa_file_read (file2, buf2, 512); rd2 = grub_file_read (file2, buf2, 512);
if (rd1 != rd2) if (rd1 != rd2)
return 0; return 0;
@ -73,12 +73,12 @@ pupa_cmd_cmp (struct pupa_arg_list *state __attribute__ ((unused)),
{ {
if (buf1[i] != buf2[i]) if (buf1[i] != buf2[i])
{ {
pupa_printf ("Differ at the offset %d: 0x%x [%s], 0x%x [%s]\n", grub_printf ("Differ at the offset %d: 0x%x [%s], 0x%x [%s]\n",
i + pos, buf1[i], args[0], i + pos, buf1[i], args[0],
buf2[i], args[1]); buf2[i], args[1]);
pupa_file_close (file1); grub_file_close (file1);
pupa_file_close (file2); grub_file_close (file2);
return 0; return 0;
} }
} }
@ -87,38 +87,38 @@ pupa_cmd_cmp (struct pupa_arg_list *state __attribute__ ((unused)),
} while (rd2); } while (rd2);
} }
pupa_file_close (file1); grub_file_close (file1);
pupa_file_close (file2); grub_file_close (file2);
pupa_printf ("The files are identical.\n"); grub_printf ("The files are identical.\n");
return 0; return 0;
} }
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
void void
pupa_cmp_init (void) grub_cmp_init (void)
{ {
pupa_register_command ("cmp", pupa_cmd_cmp, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("cmp", grub_cmd_cmp, GRUB_COMMAND_FLAG_BOTH,
"cmp FILE1 FILE2", "Compare two files", 0); "cmp FILE1 FILE2", "Compare two files", 0);
} }
void void
pupa_cmp_fini (void) grub_cmp_fini (void)
{ {
pupa_unregister_command ("cmp"); grub_unregister_command ("cmp");
} }
#else /* ! PUPA_UTIL */ #else /* ! GRUB_UTIL */
PUPA_MOD_INIT GRUB_MOD_INIT
{ {
(void)mod; /* To stop warning. */ (void)mod; /* To stop warning. */
pupa_register_command ("cmp", pupa_cmd_cmp, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("cmp", grub_cmd_cmp, GRUB_COMMAND_FLAG_BOTH,
"cmp FILE1 FILE2", "Compare two files", 0); "cmp FILE1 FILE2", "Compare two files", 0);
} }
PUPA_MOD_FINI GRUB_MOD_FINI
{ {
pupa_unregister_command ("cmp"); grub_unregister_command ("cmp");
} }
#endif /* ! PUPA_UTIL */ #endif /* ! GRUB_UTIL */

View file

@ -1,9 +1,9 @@
/* ls.c - command to list files and devices */ /* ls.c - command to list files and devices */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,24 +14,24 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/normal.h> #include <grub/normal.h>
#include <pupa/arg.h> #include <grub/arg.h>
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/device.h> #include <grub/device.h>
#include <pupa/term.h> #include <grub/term.h>
#include <pupa/machine/partition.h> #include <grub/machine/partition.h>
#include <pupa/file.h> #include <grub/file.h>
static const struct pupa_arg_option options[] = static const struct grub_arg_option options[] =
{ {
{"long", 'l', 0, "Show a long list with more detailed information", 0, 0}, {"long", 'l', 0, "Show a long list with more detailed information", 0, 0},
{"human-readable", 'h', 0, "Print sizes in a human readable format", 0, 0}, {"human-readable", 'h', 0, "Print sizes in a human readable format", 0, 0},
@ -39,105 +39,105 @@ static const struct pupa_arg_option options[] =
{0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0}
}; };
static const char pupa_human_sizes[] = {' ', 'K', 'M', 'G', 'T'}; static const char grub_human_sizes[] = {' ', 'K', 'M', 'G', 'T'};
static pupa_err_t static grub_err_t
pupa_ls_list_disks (int longlist) grub_ls_list_disks (int longlist)
{ {
auto int pupa_ls_print_disks (const char *name); auto int grub_ls_print_disks (const char *name);
int pupa_ls_print_disks (const char *name) int grub_ls_print_disks (const char *name)
{ {
pupa_device_t dev; grub_device_t dev;
auto int print_partition (const pupa_partition_t p); auto int print_partition (const grub_partition_t p);
int print_partition (const pupa_partition_t p) int print_partition (const grub_partition_t p)
{ {
char *pname = pupa_partition_get_name (p); char *pname = grub_partition_get_name (p);
if (pname) if (pname)
{ {
if (longlist) if (longlist)
pupa_print_partinfo (dev, pname); grub_print_partinfo (dev, pname);
else else
pupa_printf ("(%s,%s) ", name, pname); grub_printf ("(%s,%s) ", name, pname);
} }
return 0; return 0;
} }
dev = pupa_device_open (name); dev = grub_device_open (name);
pupa_errno = PUPA_ERR_NONE; grub_errno = GRUB_ERR_NONE;
if (dev) if (dev)
{ {
if (longlist) if (longlist)
pupa_printf ("Disk: %s\n", name); grub_printf ("Disk: %s\n", name);
else else
pupa_printf ("(%s) ", name); grub_printf ("(%s) ", name);
if (dev->disk && dev->disk->has_partitions) if (dev->disk && dev->disk->has_partitions)
{ {
pupa_partition_iterate (dev->disk, print_partition); grub_partition_iterate (dev->disk, print_partition);
pupa_errno = PUPA_ERR_NONE; grub_errno = GRUB_ERR_NONE;
} }
pupa_device_close (dev); grub_device_close (dev);
} }
return 0; return 0;
} }
pupa_disk_dev_iterate (pupa_ls_print_disks); grub_disk_dev_iterate (grub_ls_print_disks);
pupa_putchar ('\n'); grub_putchar ('\n');
pupa_refresh (); grub_refresh ();
return 0; return 0;
} }
static pupa_err_t static grub_err_t
pupa_ls_list_files (const char *dirname, int longlist, int all, int human) grub_ls_list_files (const char *dirname, int longlist, int all, int human)
{ {
char *device_name; char *device_name;
pupa_fs_t fs; grub_fs_t fs;
char *path; char *path;
pupa_device_t dev; grub_device_t dev;
static int print_files (const char *filename, int dir) static int print_files (const char *filename, int dir)
{ {
if (all || filename[0] != '.') if (all || filename[0] != '.')
pupa_printf ("%s%s ", filename, dir ? "/" : ""); grub_printf ("%s%s ", filename, dir ? "/" : "");
return 0; return 0;
} }
static int print_files_long (const char *filename, int dir) static int print_files_long (const char *filename, int dir)
{ {
char pathname[pupa_strlen (dirname) + pupa_strlen (filename) + 1]; char pathname[grub_strlen (dirname) + grub_strlen (filename) + 1];
if ((! all) && (filename[0] == '.')) if ((! all) && (filename[0] == '.'))
return 0; return 0;
if (! dir) if (! dir)
{ {
pupa_file_t file; grub_file_t file;
if (dirname[pupa_strlen (dirname) - 1] == '/') if (dirname[grub_strlen (dirname) - 1] == '/')
pupa_sprintf (pathname, "%s%s", dirname, filename); grub_sprintf (pathname, "%s%s", dirname, filename);
else else
pupa_sprintf (pathname, "%s/%s", dirname, filename); grub_sprintf (pathname, "%s/%s", dirname, filename);
/* XXX: For ext2fs symlinks are detected as files while they /* XXX: For ext2fs symlinks are detected as files while they
should be reported as directories. */ should be reported as directories. */
file = pupa_file_open (pathname); file = grub_file_open (pathname);
if (! file) if (! file)
{ {
pupa_errno = 0; grub_errno = 0;
return 0; return 0;
} }
if (! human) if (! human)
pupa_printf ("%-12d", file->size); grub_printf ("%-12d", file->size);
else else
{ {
float fsize = file->size; float fsize = file->size;
@ -154,43 +154,43 @@ pupa_ls_list_files (const char *dirname, int longlist, int all, int human)
if (units) if (units)
{ {
pupa_sprintf (buf, "%0.2f%c", fsize, pupa_human_sizes[units]); grub_sprintf (buf, "%0.2f%c", fsize, grub_human_sizes[units]);
pupa_printf ("%-12s", buf); grub_printf ("%-12s", buf);
} }
else else
pupa_printf ("%-12d", file->size); grub_printf ("%-12d", file->size);
} }
(fs->close) (file); (fs->close) (file);
} }
else else
pupa_printf ("%-12s", "DIR"); grub_printf ("%-12s", "DIR");
pupa_printf ("%s%s\n", filename, dir ? "/" : ""); grub_printf ("%s%s\n", filename, dir ? "/" : "");
return 0; return 0;
} }
device_name = pupa_file_get_device_name (dirname); device_name = grub_file_get_device_name (dirname);
dev = pupa_device_open (device_name); dev = grub_device_open (device_name);
if (! dev) if (! dev)
goto fail; goto fail;
fs = pupa_fs_probe (dev); fs = grub_fs_probe (dev);
path = pupa_strchr (dirname, '/'); path = grub_strchr (dirname, '/');
if (! path && ! device_name) if (! path && ! device_name)
{ {
pupa_error (PUPA_ERR_BAD_ARGUMENT, "invalid argument"); grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
goto fail; goto fail;
} }
if (! path) if (! path)
{ {
if (pupa_errno == PUPA_ERR_UNKNOWN_FS) if (grub_errno == GRUB_ERR_UNKNOWN_FS)
pupa_errno = PUPA_ERR_NONE; grub_errno = GRUB_ERR_NONE;
pupa_printf ("(%s): Filesystem is %s.\n", grub_printf ("(%s): Filesystem is %s.\n",
device_name, fs ? fs->name : "unknown"); device_name, fs ? fs->name : "unknown");
} }
else if (fs) else if (fs)
@ -199,64 +199,64 @@ pupa_ls_list_files (const char *dirname, int longlist, int all, int human)
(fs->dir) (dev, path, print_files_long); (fs->dir) (dev, path, print_files_long);
else else
(fs->dir) (dev, path, print_files); (fs->dir) (dev, path, print_files);
pupa_putchar ('\n'); grub_putchar ('\n');
pupa_refresh (); grub_refresh ();
} }
fail: fail:
if (dev) if (dev)
pupa_device_close (dev); grub_device_close (dev);
pupa_free (device_name); grub_free (device_name);
return 0; return 0;
} }
static pupa_err_t static grub_err_t
pupa_cmd_ls (struct pupa_arg_list *state, int argc, char **args) grub_cmd_ls (struct grub_arg_list *state, int argc, char **args)
{ {
static int pupa_ls_print_files (const char *filename, int dir) static int grub_ls_print_files (const char *filename, int dir)
{ {
if (state[2].set/*all*/ || filename[0] != '.') if (state[2].set/*all*/ || filename[0] != '.')
pupa_printf ("%s%s ", filename, dir ? "/" : ""); grub_printf ("%s%s ", filename, dir ? "/" : "");
return 0; return 0;
} }
if (argc == 0) if (argc == 0)
pupa_ls_list_disks (state[0].set); grub_ls_list_disks (state[0].set);
else else
pupa_ls_list_files (args[0], state[0].set, state[2].set, grub_ls_list_files (args[0], state[0].set, state[2].set,
state[1].set); state[1].set);
return 0; return 0;
} }
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
void void
pupa_ls_init (void) grub_ls_init (void)
{ {
pupa_register_command ("ls", pupa_cmd_ls, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("ls", grub_cmd_ls, GRUB_COMMAND_FLAG_BOTH,
"ls [OPTIONS...] [DIR]", "ls [OPTIONS...] [DIR]",
"List devices and files", options); "List devices and files", options);
} }
void void
pupa_ls_fini (void) grub_ls_fini (void)
{ {
pupa_unregister_command ("ls"); grub_unregister_command ("ls");
} }
#else /* ! PUPA_UTIL */ #else /* ! GRUB_UTIL */
PUPA_MOD_INIT GRUB_MOD_INIT
{ {
(void)mod; /* To stop warning. */ (void)mod; /* To stop warning. */
pupa_register_command ("ls", pupa_cmd_ls, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("ls", grub_cmd_ls, GRUB_COMMAND_FLAG_BOTH,
"ls [OPTIONS...] [DIR]", "ls [OPTIONS...] [DIR]",
"List devices and files", options); "List devices and files", options);
} }
PUPA_MOD_FINI GRUB_MOD_FINI
{ {
pupa_unregister_command ("ls"); grub_unregister_command ("ls");
} }
#endif /* ! PUPA_UTIL */ #endif /* ! GRUB_UTIL */

View file

@ -1,9 +1,9 @@
/* terminal.c - command to show and select a terminal */ /* terminal.c - command to show and select a terminal */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,34 +14,34 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/normal.h> #include <grub/normal.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/arg.h> #include <grub/arg.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/term.h> #include <grub/term.h>
static pupa_err_t static grub_err_t
pupa_cmd_terminal (struct pupa_arg_list *state __attribute__ ((unused)), grub_cmd_terminal (struct grub_arg_list *state __attribute__ ((unused)),
int argc, char **args) int argc, char **args)
{ {
pupa_term_t term = 0; grub_term_t term = 0;
auto int print_terminal (pupa_term_t); auto int print_terminal (grub_term_t);
auto int find_terminal (pupa_term_t); auto int find_terminal (grub_term_t);
int print_terminal (pupa_term_t t) int print_terminal (grub_term_t t)
{ {
pupa_printf (" %s", t->name); grub_printf (" %s", t->name);
return 0; return 0;
} }
int find_terminal (pupa_term_t t) int find_terminal (grub_term_t t)
{ {
if (pupa_strcmp (t->name, args[0]) == 0) if (grub_strcmp (t->name, args[0]) == 0)
{ {
term = t; term = t;
return 1; return 1;
@ -52,48 +52,48 @@ pupa_cmd_terminal (struct pupa_arg_list *state __attribute__ ((unused)),
if (argc == 0) if (argc == 0)
{ {
pupa_printf ("Available terminal(s):"); grub_printf ("Available terminal(s):");
pupa_term_iterate (print_terminal); grub_term_iterate (print_terminal);
pupa_putchar ('\n'); grub_putchar ('\n');
pupa_printf ("Current terminal: %s\n", pupa_term_get_current ()->name); grub_printf ("Current terminal: %s\n", grub_term_get_current ()->name);
} }
else else
{ {
pupa_term_iterate (find_terminal); grub_term_iterate (find_terminal);
if (! term) if (! term)
return pupa_error (PUPA_ERR_BAD_ARGUMENT, "no such terminal"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "no such terminal");
pupa_term_set_current (term); grub_term_set_current (term);
} }
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
void void
pupa_terminal_init (void) grub_terminal_init (void)
{ {
pupa_register_command ("terminal", pupa_cmd_terminal, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("terminal", grub_cmd_terminal, GRUB_COMMAND_FLAG_BOTH,
"terminal [TERM...]", "Select a terminal.", 0); "terminal [TERM...]", "Select a terminal.", 0);
} }
void void
pupa_terminal_fini (void) grub_terminal_fini (void)
{ {
pupa_unregister_command ("terminal"); grub_unregister_command ("terminal");
} }
#else /* ! PUPA_UTIL */ #else /* ! GRUB_UTIL */
PUPA_MOD_INIT GRUB_MOD_INIT
{ {
(void)mod; /* To stop warning. */ (void)mod; /* To stop warning. */
pupa_register_command ("terminal", pupa_cmd_terminal, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("terminal", grub_cmd_terminal, GRUB_COMMAND_FLAG_BOTH,
"terminal [TERM...]", "Select a terminal.", 0); "terminal [TERM...]", "Select a terminal.", 0);
} }
PUPA_MOD_FINI GRUB_MOD_FINI
{ {
pupa_unregister_command ("terminal"); grub_unregister_command ("terminal");
} }
#endif /* ! PUPA_UTIL */ #endif /* ! GRUB_UTIL */

View file

@ -239,432 +239,432 @@ kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,8200
MOSTLYCLEANFILES += symlist.c kernel_syms.lst MOSTLYCLEANFILES += symlist.c kernel_syms.lst
DEFSYMFILES += kernel_syms.lst DEFSYMFILES += kernel_syms.lst
symlist.c: $(addprefix include/pupa/,$(kernel_img_HEADERS)) gensymlist.sh symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) gensymlist.sh
sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@ sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@
kernel_syms.lst: $(addprefix include/pupa/,$(kernel_img_HEADERS)) genkernsyms.sh kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) genkernsyms.sh
sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@ sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@
# Utilities. # Utilities.
bin_UTILITIES = pupa-mkimage bin_UTILITIES = grub-mkimage
sbin_UTILITIES = pupa-setup pupa-emu sbin_UTILITIES = grub-setup grub-emu
noinst_UTILITIES = genmoddep noinst_UTILITIES = genmoddep
# For pupa-mkimage. # For grub-mkimage.
pupa_mkimage_SOURCES = util/i386/pc/pupa-mkimage.c util/misc.c \ grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \
util/resolve.c util/resolve.c
CLEANFILES += pupa-mkimage pupa_mkimage-util_i386_pc_pupa_mkimage.o pupa_mkimage-util_misc.o pupa_mkimage-util_resolve.o CLEANFILES += grub-mkimage grub_mkimage-util_i386_pc_grub_mkimage.o grub_mkimage-util_misc.o grub_mkimage-util_resolve.o
MOSTLYCLEANFILES += pupa_mkimage-util_i386_pc_pupa_mkimage.d pupa_mkimage-util_misc.d pupa_mkimage-util_resolve.d MOSTLYCLEANFILES += grub_mkimage-util_i386_pc_grub_mkimage.d grub_mkimage-util_misc.d grub_mkimage-util_resolve.d
pupa-mkimage: pupa_mkimage-util_i386_pc_pupa_mkimage.o pupa_mkimage-util_misc.o pupa_mkimage-util_resolve.o grub-mkimage: grub_mkimage-util_i386_pc_grub_mkimage.o grub_mkimage-util_misc.o grub_mkimage-util_resolve.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(pupa_mkimage_LDFLAGS) $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_mkimage_LDFLAGS)
pupa_mkimage-util_i386_pc_pupa_mkimage.o: util/i386/pc/pupa-mkimage.c grub_mkimage-util_i386_pc_grub_mkimage.o: util/i386/pc/grub-mkimage.c
$(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_mkimage_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_mkimage_CFLAGS) -c -o $@ $<
pupa_mkimage-util_i386_pc_pupa_mkimage.d: util/i386/pc/pupa-mkimage.c grub_mkimage-util_i386_pc_grub_mkimage.d: util/i386/pc/grub-mkimage.c
set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_mkimage_CFLAGS) -M $< | sed 's,pupa\-mkimage\.o[ :]*,pupa_mkimage-util_i386_pc_pupa_mkimage.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_mkimage_CFLAGS) -M $< | sed 's,grub\-mkimage\.o[ :]*,grub_mkimage-util_i386_pc_grub_mkimage.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_mkimage-util_i386_pc_pupa_mkimage.d -include grub_mkimage-util_i386_pc_grub_mkimage.d
pupa_mkimage-util_misc.o: util/misc.c grub_mkimage-util_misc.o: util/misc.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_mkimage_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_mkimage_CFLAGS) -c -o $@ $<
pupa_mkimage-util_misc.d: util/misc.c grub_mkimage-util_misc.d: util/misc.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_mkimage_CFLAGS) -M $< | sed 's,misc\.o[ :]*,pupa_mkimage-util_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_mkimage_CFLAGS) -M $< | sed 's,misc\.o[ :]*,grub_mkimage-util_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_mkimage-util_misc.d -include grub_mkimage-util_misc.d
pupa_mkimage-util_resolve.o: util/resolve.c grub_mkimage-util_resolve.o: util/resolve.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_mkimage_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_mkimage_CFLAGS) -c -o $@ $<
pupa_mkimage-util_resolve.d: util/resolve.c grub_mkimage-util_resolve.d: util/resolve.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_mkimage_CFLAGS) -M $< | sed 's,resolve\.o[ :]*,pupa_mkimage-util_resolve.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_mkimage_CFLAGS) -M $< | sed 's,resolve\.o[ :]*,grub_mkimage-util_resolve.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_mkimage-util_resolve.d -include grub_mkimage-util_resolve.d
pupa_mkimage_LDFLAGS = -llzo grub_mkimage_LDFLAGS = -llzo
# For pupa-setup. # For grub-setup.
pupa_setup_SOURCES = util/i386/pc/pupa-setup.c util/i386/pc/biosdisk.c \ grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \
util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \ util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \
kern/err.c kern/misc.c disk/i386/pc/partition.c fs/fat.c fs/ext2.c \ kern/err.c kern/misc.c disk/i386/pc/partition.c fs/fat.c fs/ext2.c \
kern/file.c kern/fs.c kern/env.c kern/file.c kern/fs.c kern/env.c
CLEANFILES += pupa-setup pupa_setup-util_i386_pc_pupa_setup.o pupa_setup-util_i386_pc_biosdisk.o pupa_setup-util_misc.o pupa_setup-util_i386_pc_getroot.o pupa_setup-kern_device.o pupa_setup-kern_disk.o pupa_setup-kern_err.o pupa_setup-kern_misc.o pupa_setup-disk_i386_pc_partition.o pupa_setup-fs_fat.o pupa_setup-fs_ext2.o pupa_setup-kern_file.o pupa_setup-kern_fs.o pupa_setup-kern_env.o CLEANFILES += grub-setup grub_setup-util_i386_pc_grub_setup.o grub_setup-util_i386_pc_biosdisk.o grub_setup-util_misc.o grub_setup-util_i386_pc_getroot.o grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-disk_i386_pc_partition.o grub_setup-fs_fat.o grub_setup-fs_ext2.o grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o
MOSTLYCLEANFILES += pupa_setup-util_i386_pc_pupa_setup.d pupa_setup-util_i386_pc_biosdisk.d pupa_setup-util_misc.d pupa_setup-util_i386_pc_getroot.d pupa_setup-kern_device.d pupa_setup-kern_disk.d pupa_setup-kern_err.d pupa_setup-kern_misc.d pupa_setup-disk_i386_pc_partition.d pupa_setup-fs_fat.d pupa_setup-fs_ext2.d pupa_setup-kern_file.d pupa_setup-kern_fs.d pupa_setup-kern_env.d MOSTLYCLEANFILES += grub_setup-util_i386_pc_grub_setup.d grub_setup-util_i386_pc_biosdisk.d grub_setup-util_misc.d grub_setup-util_i386_pc_getroot.d grub_setup-kern_device.d grub_setup-kern_disk.d grub_setup-kern_err.d grub_setup-kern_misc.d grub_setup-disk_i386_pc_partition.d grub_setup-fs_fat.d grub_setup-fs_ext2.d grub_setup-kern_file.d grub_setup-kern_fs.d grub_setup-kern_env.d
pupa-setup: pupa_setup-util_i386_pc_pupa_setup.o pupa_setup-util_i386_pc_biosdisk.o pupa_setup-util_misc.o pupa_setup-util_i386_pc_getroot.o pupa_setup-kern_device.o pupa_setup-kern_disk.o pupa_setup-kern_err.o pupa_setup-kern_misc.o pupa_setup-disk_i386_pc_partition.o pupa_setup-fs_fat.o pupa_setup-fs_ext2.o pupa_setup-kern_file.o pupa_setup-kern_fs.o pupa_setup-kern_env.o grub-setup: grub_setup-util_i386_pc_grub_setup.o grub_setup-util_i386_pc_biosdisk.o grub_setup-util_misc.o grub_setup-util_i386_pc_getroot.o grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-disk_i386_pc_partition.o grub_setup-fs_fat.o grub_setup-fs_ext2.o grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(pupa_setup_LDFLAGS) $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_setup_LDFLAGS)
pupa_setup-util_i386_pc_pupa_setup.o: util/i386/pc/pupa-setup.c grub_setup-util_i386_pc_grub_setup.o: util/i386/pc/grub-setup.c
$(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-util_i386_pc_pupa_setup.d: util/i386/pc/pupa-setup.c grub_setup-util_i386_pc_grub_setup.d: util/i386/pc/grub-setup.c
set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,pupa\-setup\.o[ :]*,pupa_setup-util_i386_pc_pupa_setup.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,grub\-setup\.o[ :]*,grub_setup-util_i386_pc_grub_setup.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-util_i386_pc_pupa_setup.d -include grub_setup-util_i386_pc_grub_setup.d
pupa_setup-util_i386_pc_biosdisk.o: util/i386/pc/biosdisk.c grub_setup-util_i386_pc_biosdisk.o: util/i386/pc/biosdisk.c
$(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-util_i386_pc_biosdisk.d: util/i386/pc/biosdisk.c grub_setup-util_i386_pc_biosdisk.d: util/i386/pc/biosdisk.c
set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,biosdisk\.o[ :]*,pupa_setup-util_i386_pc_biosdisk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,biosdisk\.o[ :]*,grub_setup-util_i386_pc_biosdisk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-util_i386_pc_biosdisk.d -include grub_setup-util_i386_pc_biosdisk.d
pupa_setup-util_misc.o: util/misc.c grub_setup-util_misc.o: util/misc.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-util_misc.d: util/misc.c grub_setup-util_misc.d: util/misc.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,misc\.o[ :]*,pupa_setup-util_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,misc\.o[ :]*,grub_setup-util_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-util_misc.d -include grub_setup-util_misc.d
pupa_setup-util_i386_pc_getroot.o: util/i386/pc/getroot.c grub_setup-util_i386_pc_getroot.o: util/i386/pc/getroot.c
$(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-util_i386_pc_getroot.d: util/i386/pc/getroot.c grub_setup-util_i386_pc_getroot.d: util/i386/pc/getroot.c
set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,getroot\.o[ :]*,pupa_setup-util_i386_pc_getroot.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,getroot\.o[ :]*,grub_setup-util_i386_pc_getroot.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-util_i386_pc_getroot.d -include grub_setup-util_i386_pc_getroot.d
pupa_setup-kern_device.o: kern/device.c grub_setup-kern_device.o: kern/device.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-kern_device.d: kern/device.c grub_setup-kern_device.d: kern/device.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,device\.o[ :]*,pupa_setup-kern_device.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,device\.o[ :]*,grub_setup-kern_device.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-kern_device.d -include grub_setup-kern_device.d
pupa_setup-kern_disk.o: kern/disk.c grub_setup-kern_disk.o: kern/disk.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-kern_disk.d: kern/disk.c grub_setup-kern_disk.d: kern/disk.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,disk\.o[ :]*,pupa_setup-kern_disk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,disk\.o[ :]*,grub_setup-kern_disk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-kern_disk.d -include grub_setup-kern_disk.d
pupa_setup-kern_err.o: kern/err.c grub_setup-kern_err.o: kern/err.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-kern_err.d: kern/err.c grub_setup-kern_err.d: kern/err.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,err\.o[ :]*,pupa_setup-kern_err.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,err\.o[ :]*,grub_setup-kern_err.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-kern_err.d -include grub_setup-kern_err.d
pupa_setup-kern_misc.o: kern/misc.c grub_setup-kern_misc.o: kern/misc.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-kern_misc.d: kern/misc.c grub_setup-kern_misc.d: kern/misc.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,misc\.o[ :]*,pupa_setup-kern_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,misc\.o[ :]*,grub_setup-kern_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-kern_misc.d -include grub_setup-kern_misc.d
pupa_setup-disk_i386_pc_partition.o: disk/i386/pc/partition.c grub_setup-disk_i386_pc_partition.o: disk/i386/pc/partition.c
$(BUILD_CC) -Idisk/i386/pc -I$(srcdir)/disk/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Idisk/i386/pc -I$(srcdir)/disk/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-disk_i386_pc_partition.d: disk/i386/pc/partition.c grub_setup-disk_i386_pc_partition.d: disk/i386/pc/partition.c
set -e; $(BUILD_CC) -Idisk/i386/pc -I$(srcdir)/disk/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,partition\.o[ :]*,pupa_setup-disk_i386_pc_partition.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Idisk/i386/pc -I$(srcdir)/disk/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,partition\.o[ :]*,grub_setup-disk_i386_pc_partition.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-disk_i386_pc_partition.d -include grub_setup-disk_i386_pc_partition.d
pupa_setup-fs_fat.o: fs/fat.c grub_setup-fs_fat.o: fs/fat.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-fs_fat.d: fs/fat.c grub_setup-fs_fat.d: fs/fat.c
set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,fat\.o[ :]*,pupa_setup-fs_fat.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,fat\.o[ :]*,grub_setup-fs_fat.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-fs_fat.d -include grub_setup-fs_fat.d
pupa_setup-fs_ext2.o: fs/ext2.c grub_setup-fs_ext2.o: fs/ext2.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-fs_ext2.d: fs/ext2.c grub_setup-fs_ext2.d: fs/ext2.c
set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,ext2\.o[ :]*,pupa_setup-fs_ext2.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,ext2\.o[ :]*,grub_setup-fs_ext2.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-fs_ext2.d -include grub_setup-fs_ext2.d
pupa_setup-kern_file.o: kern/file.c grub_setup-kern_file.o: kern/file.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-kern_file.d: kern/file.c grub_setup-kern_file.d: kern/file.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,file\.o[ :]*,pupa_setup-kern_file.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,file\.o[ :]*,grub_setup-kern_file.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-kern_file.d -include grub_setup-kern_file.d
pupa_setup-kern_fs.o: kern/fs.c grub_setup-kern_fs.o: kern/fs.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-kern_fs.d: kern/fs.c grub_setup-kern_fs.d: kern/fs.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,fs\.o[ :]*,pupa_setup-kern_fs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,fs\.o[ :]*,grub_setup-kern_fs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-kern_fs.d -include grub_setup-kern_fs.d
pupa_setup-kern_env.o: kern/env.c grub_setup-kern_env.o: kern/env.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -c -o $@ $<
pupa_setup-kern_env.d: kern/env.c grub_setup-kern_env.d: kern/env.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_setup_CFLAGS) -M $< | sed 's,env\.o[ :]*,pupa_setup-kern_env.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -M $< | sed 's,env\.o[ :]*,grub_setup-kern_env.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_setup-kern_env.d -include grub_setup-kern_env.d
# For pupa # For grub
pupa_emu_SOURCES = kern/main.c kern/device.c \ grub_emu_SOURCES = kern/main.c kern/device.c \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
kern/misc.c kern/loader.c kern/rescue.c kern/term.c \ kern/misc.c kern/loader.c kern/rescue.c kern/term.c \
disk/i386/pc/partition.c kern/env.c commands/ls.c \ disk/i386/pc/partition.c kern/env.c commands/ls.c \
commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c \ commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c \
util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c \ util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c \
normal/cmdline.c normal/command.c normal/main.c normal/menu.c normal/arg.c \ normal/cmdline.c normal/command.c normal/main.c normal/menu.c normal/arg.c \
util/console.c util/pupa-emu.c util/misc.c util/i386/pc/getroot.c util/console.c util/grub-emu.c util/misc.c util/i386/pc/getroot.c
CLEANFILES += pupa-emu pupa_emu-kern_main.o pupa_emu-kern_device.o pupa_emu-kern_disk.o pupa_emu-kern_dl.o pupa_emu-kern_file.o pupa_emu-kern_fs.o pupa_emu-kern_err.o pupa_emu-kern_misc.o pupa_emu-kern_loader.o pupa_emu-kern_rescue.o pupa_emu-kern_term.o pupa_emu-disk_i386_pc_partition.o pupa_emu-kern_env.o pupa_emu-commands_ls.o pupa_emu-commands_terminal.o pupa_emu-commands_boot.o pupa_emu-commands_cmp.o pupa_emu-commands_cat.o pupa_emu-util_i386_pc_biosdisk.o pupa_emu-fs_fat.o pupa_emu-fs_ext2.o pupa_emu-normal_cmdline.o pupa_emu-normal_command.o pupa_emu-normal_main.o pupa_emu-normal_menu.o pupa_emu-normal_arg.o pupa_emu-util_console.o pupa_emu-util_pupa_emu.o pupa_emu-util_misc.o pupa_emu-util_i386_pc_getroot.o CLEANFILES += grub-emu grub_emu-kern_main.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_err.o grub_emu-kern_misc.o grub_emu-kern_loader.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-disk_i386_pc_partition.o grub_emu-kern_env.o grub_emu-commands_ls.o grub_emu-commands_terminal.o grub_emu-commands_boot.o grub_emu-commands_cmp.o grub_emu-commands_cat.o grub_emu-util_i386_pc_biosdisk.o grub_emu-fs_fat.o grub_emu-fs_ext2.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_arg.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_getroot.o
MOSTLYCLEANFILES += pupa_emu-kern_main.d pupa_emu-kern_device.d pupa_emu-kern_disk.d pupa_emu-kern_dl.d pupa_emu-kern_file.d pupa_emu-kern_fs.d pupa_emu-kern_err.d pupa_emu-kern_misc.d pupa_emu-kern_loader.d pupa_emu-kern_rescue.d pupa_emu-kern_term.d pupa_emu-disk_i386_pc_partition.d pupa_emu-kern_env.d pupa_emu-commands_ls.d pupa_emu-commands_terminal.d pupa_emu-commands_boot.d pupa_emu-commands_cmp.d pupa_emu-commands_cat.d pupa_emu-util_i386_pc_biosdisk.d pupa_emu-fs_fat.d pupa_emu-fs_ext2.d pupa_emu-normal_cmdline.d pupa_emu-normal_command.d pupa_emu-normal_main.d pupa_emu-normal_menu.d pupa_emu-normal_arg.d pupa_emu-util_console.d pupa_emu-util_pupa_emu.d pupa_emu-util_misc.d pupa_emu-util_i386_pc_getroot.d MOSTLYCLEANFILES += grub_emu-kern_main.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_err.d grub_emu-kern_misc.d grub_emu-kern_loader.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-disk_i386_pc_partition.d grub_emu-kern_env.d grub_emu-commands_ls.d grub_emu-commands_terminal.d grub_emu-commands_boot.d grub_emu-commands_cmp.d grub_emu-commands_cat.d grub_emu-util_i386_pc_biosdisk.d grub_emu-fs_fat.d grub_emu-fs_ext2.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_arg.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_getroot.d
pupa-emu: pupa_emu-kern_main.o pupa_emu-kern_device.o pupa_emu-kern_disk.o pupa_emu-kern_dl.o pupa_emu-kern_file.o pupa_emu-kern_fs.o pupa_emu-kern_err.o pupa_emu-kern_misc.o pupa_emu-kern_loader.o pupa_emu-kern_rescue.o pupa_emu-kern_term.o pupa_emu-disk_i386_pc_partition.o pupa_emu-kern_env.o pupa_emu-commands_ls.o pupa_emu-commands_terminal.o pupa_emu-commands_boot.o pupa_emu-commands_cmp.o pupa_emu-commands_cat.o pupa_emu-util_i386_pc_biosdisk.o pupa_emu-fs_fat.o pupa_emu-fs_ext2.o pupa_emu-normal_cmdline.o pupa_emu-normal_command.o pupa_emu-normal_main.o pupa_emu-normal_menu.o pupa_emu-normal_arg.o pupa_emu-util_console.o pupa_emu-util_pupa_emu.o pupa_emu-util_misc.o pupa_emu-util_i386_pc_getroot.o grub-emu: grub_emu-kern_main.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_err.o grub_emu-kern_misc.o grub_emu-kern_loader.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-disk_i386_pc_partition.o grub_emu-kern_env.o grub_emu-commands_ls.o grub_emu-commands_terminal.o grub_emu-commands_boot.o grub_emu-commands_cmp.o grub_emu-commands_cat.o grub_emu-util_i386_pc_biosdisk.o grub_emu-fs_fat.o grub_emu-fs_ext2.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_arg.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_getroot.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(pupa_emu_LDFLAGS) $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_emu_LDFLAGS)
pupa_emu-kern_main.o: kern/main.c grub_emu-kern_main.o: kern/main.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_main.d: kern/main.c grub_emu-kern_main.d: kern/main.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,main\.o[ :]*,pupa_emu-kern_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,main\.o[ :]*,grub_emu-kern_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_main.d -include grub_emu-kern_main.d
pupa_emu-kern_device.o: kern/device.c grub_emu-kern_device.o: kern/device.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_device.d: kern/device.c grub_emu-kern_device.d: kern/device.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,device\.o[ :]*,pupa_emu-kern_device.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,device\.o[ :]*,grub_emu-kern_device.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_device.d -include grub_emu-kern_device.d
pupa_emu-kern_disk.o: kern/disk.c grub_emu-kern_disk.o: kern/disk.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_disk.d: kern/disk.c grub_emu-kern_disk.d: kern/disk.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,disk\.o[ :]*,pupa_emu-kern_disk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,disk\.o[ :]*,grub_emu-kern_disk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_disk.d -include grub_emu-kern_disk.d
pupa_emu-kern_dl.o: kern/dl.c grub_emu-kern_dl.o: kern/dl.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_dl.d: kern/dl.c grub_emu-kern_dl.d: kern/dl.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,dl\.o[ :]*,pupa_emu-kern_dl.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,dl\.o[ :]*,grub_emu-kern_dl.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_dl.d -include grub_emu-kern_dl.d
pupa_emu-kern_file.o: kern/file.c grub_emu-kern_file.o: kern/file.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_file.d: kern/file.c grub_emu-kern_file.d: kern/file.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,file\.o[ :]*,pupa_emu-kern_file.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,file\.o[ :]*,grub_emu-kern_file.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_file.d -include grub_emu-kern_file.d
pupa_emu-kern_fs.o: kern/fs.c grub_emu-kern_fs.o: kern/fs.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_fs.d: kern/fs.c grub_emu-kern_fs.d: kern/fs.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,fs\.o[ :]*,pupa_emu-kern_fs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,fs\.o[ :]*,grub_emu-kern_fs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_fs.d -include grub_emu-kern_fs.d
pupa_emu-kern_err.o: kern/err.c grub_emu-kern_err.o: kern/err.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_err.d: kern/err.c grub_emu-kern_err.d: kern/err.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,err\.o[ :]*,pupa_emu-kern_err.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,err\.o[ :]*,grub_emu-kern_err.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_err.d -include grub_emu-kern_err.d
pupa_emu-kern_misc.o: kern/misc.c grub_emu-kern_misc.o: kern/misc.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_misc.d: kern/misc.c grub_emu-kern_misc.d: kern/misc.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,misc\.o[ :]*,pupa_emu-kern_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,misc\.o[ :]*,grub_emu-kern_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_misc.d -include grub_emu-kern_misc.d
pupa_emu-kern_loader.o: kern/loader.c grub_emu-kern_loader.o: kern/loader.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_loader.d: kern/loader.c grub_emu-kern_loader.d: kern/loader.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,loader\.o[ :]*,pupa_emu-kern_loader.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,loader\.o[ :]*,grub_emu-kern_loader.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_loader.d -include grub_emu-kern_loader.d
pupa_emu-kern_rescue.o: kern/rescue.c grub_emu-kern_rescue.o: kern/rescue.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_rescue.d: kern/rescue.c grub_emu-kern_rescue.d: kern/rescue.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,rescue\.o[ :]*,pupa_emu-kern_rescue.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,rescue\.o[ :]*,grub_emu-kern_rescue.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_rescue.d -include grub_emu-kern_rescue.d
pupa_emu-kern_term.o: kern/term.c grub_emu-kern_term.o: kern/term.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_term.d: kern/term.c grub_emu-kern_term.d: kern/term.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,term\.o[ :]*,pupa_emu-kern_term.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,term\.o[ :]*,grub_emu-kern_term.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_term.d -include grub_emu-kern_term.d
pupa_emu-disk_i386_pc_partition.o: disk/i386/pc/partition.c grub_emu-disk_i386_pc_partition.o: disk/i386/pc/partition.c
$(BUILD_CC) -Idisk/i386/pc -I$(srcdir)/disk/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Idisk/i386/pc -I$(srcdir)/disk/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-disk_i386_pc_partition.d: disk/i386/pc/partition.c grub_emu-disk_i386_pc_partition.d: disk/i386/pc/partition.c
set -e; $(BUILD_CC) -Idisk/i386/pc -I$(srcdir)/disk/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,partition\.o[ :]*,pupa_emu-disk_i386_pc_partition.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Idisk/i386/pc -I$(srcdir)/disk/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,partition\.o[ :]*,grub_emu-disk_i386_pc_partition.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-disk_i386_pc_partition.d -include grub_emu-disk_i386_pc_partition.d
pupa_emu-kern_env.o: kern/env.c grub_emu-kern_env.o: kern/env.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_env.d: kern/env.c grub_emu-kern_env.d: kern/env.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,env\.o[ :]*,pupa_emu-kern_env.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,env\.o[ :]*,grub_emu-kern_env.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_env.d -include grub_emu-kern_env.d
pupa_emu-commands_ls.o: commands/ls.c grub_emu-commands_ls.o: commands/ls.c
$(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-commands_ls.d: commands/ls.c grub_emu-commands_ls.d: commands/ls.c
set -e; $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,ls\.o[ :]*,pupa_emu-commands_ls.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,ls\.o[ :]*,grub_emu-commands_ls.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-commands_ls.d -include grub_emu-commands_ls.d
pupa_emu-commands_terminal.o: commands/terminal.c grub_emu-commands_terminal.o: commands/terminal.c
$(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-commands_terminal.d: commands/terminal.c grub_emu-commands_terminal.d: commands/terminal.c
set -e; $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,terminal\.o[ :]*,pupa_emu-commands_terminal.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,terminal\.o[ :]*,grub_emu-commands_terminal.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-commands_terminal.d -include grub_emu-commands_terminal.d
pupa_emu-commands_boot.o: commands/boot.c grub_emu-commands_boot.o: commands/boot.c
$(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-commands_boot.d: commands/boot.c grub_emu-commands_boot.d: commands/boot.c
set -e; $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,boot\.o[ :]*,pupa_emu-commands_boot.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,boot\.o[ :]*,grub_emu-commands_boot.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-commands_boot.d -include grub_emu-commands_boot.d
pupa_emu-commands_cmp.o: commands/cmp.c grub_emu-commands_cmp.o: commands/cmp.c
$(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-commands_cmp.d: commands/cmp.c grub_emu-commands_cmp.d: commands/cmp.c
set -e; $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,cmp\.o[ :]*,pupa_emu-commands_cmp.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,cmp\.o[ :]*,grub_emu-commands_cmp.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-commands_cmp.d -include grub_emu-commands_cmp.d
pupa_emu-commands_cat.o: commands/cat.c grub_emu-commands_cat.o: commands/cat.c
$(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-commands_cat.d: commands/cat.c grub_emu-commands_cat.d: commands/cat.c
set -e; $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,cat\.o[ :]*,pupa_emu-commands_cat.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,cat\.o[ :]*,grub_emu-commands_cat.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-commands_cat.d -include grub_emu-commands_cat.d
pupa_emu-util_i386_pc_biosdisk.o: util/i386/pc/biosdisk.c grub_emu-util_i386_pc_biosdisk.o: util/i386/pc/biosdisk.c
$(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-util_i386_pc_biosdisk.d: util/i386/pc/biosdisk.c grub_emu-util_i386_pc_biosdisk.d: util/i386/pc/biosdisk.c
set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,biosdisk\.o[ :]*,pupa_emu-util_i386_pc_biosdisk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,biosdisk\.o[ :]*,grub_emu-util_i386_pc_biosdisk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-util_i386_pc_biosdisk.d -include grub_emu-util_i386_pc_biosdisk.d
pupa_emu-fs_fat.o: fs/fat.c grub_emu-fs_fat.o: fs/fat.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-fs_fat.d: fs/fat.c grub_emu-fs_fat.d: fs/fat.c
set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,fat\.o[ :]*,pupa_emu-fs_fat.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,fat\.o[ :]*,grub_emu-fs_fat.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-fs_fat.d -include grub_emu-fs_fat.d
pupa_emu-fs_ext2.o: fs/ext2.c grub_emu-fs_ext2.o: fs/ext2.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-fs_ext2.d: fs/ext2.c grub_emu-fs_ext2.d: fs/ext2.c
set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,ext2\.o[ :]*,pupa_emu-fs_ext2.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,ext2\.o[ :]*,grub_emu-fs_ext2.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-fs_ext2.d -include grub_emu-fs_ext2.d
pupa_emu-normal_cmdline.o: normal/cmdline.c grub_emu-normal_cmdline.o: normal/cmdline.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-normal_cmdline.d: normal/cmdline.c grub_emu-normal_cmdline.d: normal/cmdline.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,cmdline\.o[ :]*,pupa_emu-normal_cmdline.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,cmdline\.o[ :]*,grub_emu-normal_cmdline.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-normal_cmdline.d -include grub_emu-normal_cmdline.d
pupa_emu-normal_command.o: normal/command.c grub_emu-normal_command.o: normal/command.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-normal_command.d: normal/command.c grub_emu-normal_command.d: normal/command.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,command\.o[ :]*,pupa_emu-normal_command.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,command\.o[ :]*,grub_emu-normal_command.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-normal_command.d -include grub_emu-normal_command.d
pupa_emu-normal_main.o: normal/main.c grub_emu-normal_main.o: normal/main.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-normal_main.d: normal/main.c grub_emu-normal_main.d: normal/main.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,main\.o[ :]*,pupa_emu-normal_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,main\.o[ :]*,grub_emu-normal_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-normal_main.d -include grub_emu-normal_main.d
pupa_emu-normal_menu.o: normal/menu.c grub_emu-normal_menu.o: normal/menu.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-normal_menu.d: normal/menu.c grub_emu-normal_menu.d: normal/menu.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,menu\.o[ :]*,pupa_emu-normal_menu.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,menu\.o[ :]*,grub_emu-normal_menu.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-normal_menu.d -include grub_emu-normal_menu.d
pupa_emu-normal_arg.o: normal/arg.c grub_emu-normal_arg.o: normal/arg.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-normal_arg.d: normal/arg.c grub_emu-normal_arg.d: normal/arg.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,arg\.o[ :]*,pupa_emu-normal_arg.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,arg\.o[ :]*,grub_emu-normal_arg.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-normal_arg.d -include grub_emu-normal_arg.d
pupa_emu-util_console.o: util/console.c grub_emu-util_console.o: util/console.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-util_console.d: util/console.c grub_emu-util_console.d: util/console.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,console\.o[ :]*,pupa_emu-util_console.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,console\.o[ :]*,grub_emu-util_console.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-util_console.d -include grub_emu-util_console.d
pupa_emu-util_pupa_emu.o: util/pupa-emu.c grub_emu-util_grub_emu.o: util/grub-emu.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-util_pupa_emu.d: util/pupa-emu.c grub_emu-util_grub_emu.d: util/grub-emu.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,pupa\-emu\.o[ :]*,pupa_emu-util_pupa_emu.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,grub\-emu\.o[ :]*,grub_emu-util_grub_emu.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-util_pupa_emu.d -include grub_emu-util_grub_emu.d
pupa_emu-util_misc.o: util/misc.c grub_emu-util_misc.o: util/misc.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-util_misc.d: util/misc.c grub_emu-util_misc.d: util/misc.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,misc\.o[ :]*,pupa_emu-util_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,misc\.o[ :]*,grub_emu-util_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-util_misc.d -include grub_emu-util_misc.d
pupa_emu-util_i386_pc_getroot.o: util/i386/pc/getroot.c grub_emu-util_i386_pc_getroot.o: util/i386/pc/getroot.c
$(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-util_i386_pc_getroot.d: util/i386/pc/getroot.c grub_emu-util_i386_pc_getroot.d: util/i386/pc/getroot.c
set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,getroot\.o[ :]*,pupa_emu-util_i386_pc_getroot.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,getroot\.o[ :]*,grub_emu-util_i386_pc_getroot.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-util_i386_pc_getroot.d -include grub_emu-util_i386_pc_getroot.d
pupa_emu_LDFLAGS = -lncurses grub_emu_LDFLAGS = -lncurses
# For genmoddep. # For genmoddep.
genmoddep_SOURCES = util/genmoddep.c genmoddep_SOURCES = util/genmoddep.c
@ -675,10 +675,10 @@ genmoddep: genmoddep-util_genmoddep.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(genmoddep_LDFLAGS) $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(genmoddep_LDFLAGS)
genmoddep-util_genmoddep.o: util/genmoddep.c genmoddep-util_genmoddep.o: util/genmoddep.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(genmoddep_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(genmoddep_CFLAGS) -c -o $@ $<
genmoddep-util_genmoddep.d: util/genmoddep.c genmoddep-util_genmoddep.d: util/genmoddep.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(genmoddep_CFLAGS) -M $< | sed 's,genmoddep\.o[ :]*,genmoddep-util_genmoddep.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(genmoddep_CFLAGS) -M $< | sed 's,genmoddep\.o[ :]*,genmoddep-util_genmoddep.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include genmoddep-util_genmoddep.d -include genmoddep-util_genmoddep.d
@ -697,7 +697,7 @@ UNDSYMFILES += und-_chain.lst
_chain.mod: pre-_chain.o mod-_chain.o _chain.mod: pre-_chain.o mod-_chain.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-_chain.o: _chain_mod-loader_i386_pc_chainloader.o pre-_chain.o: _chain_mod-loader_i386_pc_chainloader.o
-rm -f $@ -rm -f $@
@ -736,7 +736,7 @@ UNDSYMFILES += und-fat.lst
fat.mod: pre-fat.o mod-fat.o fat.mod: pre-fat.o mod-fat.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-fat.o: fat_mod-fs_fat.o pre-fat.o: fat_mod-fs_fat.o
-rm -f $@ -rm -f $@
@ -775,7 +775,7 @@ UNDSYMFILES += und-ext2.lst
ext2.mod: pre-ext2.o mod-ext2.o ext2.mod: pre-ext2.o mod-ext2.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-ext2.o: ext2_mod-fs_ext2.o pre-ext2.o: ext2_mod-fs_ext2.o
-rm -f $@ -rm -f $@
@ -814,7 +814,7 @@ UNDSYMFILES += und-_linux.lst
_linux.mod: pre-_linux.o mod-_linux.o _linux.mod: pre-_linux.o mod-_linux.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-_linux.o: _linux_mod-loader_i386_pc_linux.o pre-_linux.o: _linux_mod-loader_i386_pc_linux.o
-rm -f $@ -rm -f $@
@ -854,7 +854,7 @@ UNDSYMFILES += und-normal.lst
normal.mod: pre-normal.o mod-normal.o normal.mod: pre-normal.o mod-normal.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-normal.o: normal_mod-normal_cmdline.o normal_mod-normal_command.o normal_mod-normal_main.o normal_mod-normal_menu.o normal_mod-normal_arg.o normal_mod-normal_i386_setjmp.o pre-normal.o: normal_mod-normal_cmdline.o normal_mod-normal_command.o normal_mod-normal_main.o normal_mod-normal_menu.o normal_mod-normal_arg.o normal_mod-normal_i386_setjmp.o
-rm -f $@ -rm -f $@
@ -934,7 +934,7 @@ UNDSYMFILES += und-hello.lst
hello.mod: pre-hello.o mod-hello.o hello.mod: pre-hello.o mod-hello.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-hello.o: hello_mod-hello_hello.o pre-hello.o: hello_mod-hello_hello.o
-rm -f $@ -rm -f $@
@ -973,7 +973,7 @@ UNDSYMFILES += und-boot.lst
boot.mod: pre-boot.o mod-boot.o boot.mod: pre-boot.o mod-boot.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-boot.o: boot_mod-commands_boot.o pre-boot.o: boot_mod-commands_boot.o
-rm -f $@ -rm -f $@
@ -1012,7 +1012,7 @@ UNDSYMFILES += und-terminal.lst
terminal.mod: pre-terminal.o mod-terminal.o terminal.mod: pre-terminal.o mod-terminal.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-terminal.o: terminal_mod-commands_terminal.o pre-terminal.o: terminal_mod-commands_terminal.o
-rm -f $@ -rm -f $@
@ -1051,7 +1051,7 @@ UNDSYMFILES += und-ls.lst
ls.mod: pre-ls.o mod-ls.o ls.mod: pre-ls.o mod-ls.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-ls.o: ls_mod-commands_ls.o pre-ls.o: ls_mod-commands_ls.o
-rm -f $@ -rm -f $@
@ -1090,7 +1090,7 @@ UNDSYMFILES += und-cmp.lst
cmp.mod: pre-cmp.o mod-cmp.o cmp.mod: pre-cmp.o mod-cmp.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-cmp.o: cmp_mod-commands_cmp.o pre-cmp.o: cmp_mod-commands_cmp.o
-rm -f $@ -rm -f $@
@ -1129,7 +1129,7 @@ UNDSYMFILES += und-cat.lst
cat.mod: pre-cat.o mod-cat.o cat.mod: pre-cat.o mod-cat.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-cat.o: cat_mod-commands_cat.o pre-cat.o: cat_mod-commands_cat.o
-rm -f $@ -rm -f $@
@ -1168,7 +1168,7 @@ UNDSYMFILES += und-vga.lst
vga.mod: pre-vga.o mod-vga.o vga.mod: pre-vga.o mod-vga.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-vga.o: vga_mod-term_i386_pc_vga.o pre-vga.o: vga_mod-term_i386_pc_vga.o
-rm -f $@ -rm -f $@
@ -1207,7 +1207,7 @@ UNDSYMFILES += und-font.lst
font.mod: pre-font.o mod-font.o font.mod: pre-font.o mod-font.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-font.o: font_mod-font_manager.o pre-font.o: font_mod-font_manager.o
-rm -f $@ -rm -f $@
@ -1246,7 +1246,7 @@ UNDSYMFILES += und-_multiboot.lst
_multiboot.mod: pre-_multiboot.o mod-_multiboot.o _multiboot.mod: pre-_multiboot.o mod-_multiboot.o
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-_multiboot.o: _multiboot_mod-loader_i386_pc_multiboot.o pre-_multiboot.o: _multiboot_mod-loader_i386_pc_multiboot.o
-rm -f $@ -rm -f $@

View file

@ -36,38 +36,38 @@ kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,8200
MOSTLYCLEANFILES += symlist.c kernel_syms.lst MOSTLYCLEANFILES += symlist.c kernel_syms.lst
DEFSYMFILES += kernel_syms.lst DEFSYMFILES += kernel_syms.lst
symlist.c: $(addprefix include/pupa/,$(kernel_img_HEADERS)) gensymlist.sh symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) gensymlist.sh
sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@ sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@
kernel_syms.lst: $(addprefix include/pupa/,$(kernel_img_HEADERS)) genkernsyms.sh kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) genkernsyms.sh
sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@ sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@
# Utilities. # Utilities.
bin_UTILITIES = pupa-mkimage bin_UTILITIES = grub-mkimage
sbin_UTILITIES = pupa-setup pupa-emu sbin_UTILITIES = grub-setup grub-emu
noinst_UTILITIES = genmoddep noinst_UTILITIES = genmoddep
# For pupa-mkimage. # For grub-mkimage.
pupa_mkimage_SOURCES = util/i386/pc/pupa-mkimage.c util/misc.c \ grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \
util/resolve.c util/resolve.c
pupa_mkimage_LDFLAGS = -llzo grub_mkimage_LDFLAGS = -llzo
# For pupa-setup. # For grub-setup.
pupa_setup_SOURCES = util/i386/pc/pupa-setup.c util/i386/pc/biosdisk.c \ grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \
util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \ util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \
kern/err.c kern/misc.c disk/i386/pc/partition.c fs/fat.c fs/ext2.c \ kern/err.c kern/misc.c disk/i386/pc/partition.c fs/fat.c fs/ext2.c \
kern/file.c kern/fs.c kern/env.c kern/file.c kern/fs.c kern/env.c
# For pupa # For grub
pupa_emu_SOURCES = kern/main.c kern/device.c \ grub_emu_SOURCES = kern/main.c kern/device.c \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
kern/misc.c kern/loader.c kern/rescue.c kern/term.c \ kern/misc.c kern/loader.c kern/rescue.c kern/term.c \
disk/i386/pc/partition.c kern/env.c commands/ls.c \ disk/i386/pc/partition.c kern/env.c commands/ls.c \
commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c \ commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c \
util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c \ util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c \
normal/cmdline.c normal/command.c normal/main.c normal/menu.c normal/arg.c \ normal/cmdline.c normal/command.c normal/main.c normal/menu.c normal/arg.c \
util/console.c util/pupa-emu.c util/misc.c util/i386/pc/getroot.c util/console.c util/grub-emu.c util/misc.c util/i386/pc/getroot.c
pupa_emu_LDFLAGS = -lncurses grub_emu_LDFLAGS = -lncurses
# For genmoddep. # For genmoddep.
genmoddep_SOURCES = util/genmoddep.c genmoddep_SOURCES = util/genmoddep.c

View file

@ -9,227 +9,227 @@ COMMON_CFLAGS = -fno-builtin -D__ASSEMBLY__
MOSTLYCLEANFILES += symlist.c kernel_syms.lst MOSTLYCLEANFILES += symlist.c kernel_syms.lst
DEFSYMFILES += kernel_syms.lst DEFSYMFILES += kernel_syms.lst
symlist.c: $(addprefix include/pupa/,$(kernel_img_HEADERS)) gensymlist.sh symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) gensymlist.sh
sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@ sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@
kernel_syms.lst: $(addprefix include/pupa/,$(kernel_img_HEADERS)) genkernsyms.sh kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) genkernsyms.sh
sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@ sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@
# Utilities. # Utilities.
sbin_UTILITIES = pupaof sbin_UTILITIES = grubof
bin_UTILITIES = pupa-emu bin_UTILITIES = grub-emu
noinst_UTILITIES = genmoddep noinst_UTILITIES = genmoddep
# For pupa-emu # For grub-emu
pupa_emu_SOURCES = kern/main.c kern/device.c \ grub_emu_SOURCES = kern/main.c kern/device.c \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
kern/misc.c kern/loader.c kern/rescue.c kern/term.c \ kern/misc.c kern/loader.c kern/rescue.c kern/term.c \
disk/powerpc/ieee1275/partition.c \ disk/powerpc/ieee1275/partition.c \
util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c \ util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c \
normal/cmdline.c normal/command.c normal/main.c normal/menu.c \ normal/cmdline.c normal/command.c normal/main.c normal/menu.c \
util/console.c util/pupa-emu.c util/misc.c util/i386/pc/getroot.c \ util/console.c util/grub-emu.c util/misc.c util/i386/pc/getroot.c \
kern/env.c kern/env.c
CLEANFILES += pupa-emu pupa_emu-kern_main.o pupa_emu-kern_device.o pupa_emu-kern_disk.o pupa_emu-kern_dl.o pupa_emu-kern_file.o pupa_emu-kern_fs.o pupa_emu-kern_err.o pupa_emu-kern_misc.o pupa_emu-kern_loader.o pupa_emu-kern_rescue.o pupa_emu-kern_term.o pupa_emu-disk_powerpc_ieee1275_partition.o pupa_emu-util_i386_pc_biosdisk.o pupa_emu-fs_fat.o pupa_emu-fs_ext2.o pupa_emu-normal_cmdline.o pupa_emu-normal_command.o pupa_emu-normal_main.o pupa_emu-normal_menu.o pupa_emu-util_console.o pupa_emu-util_pupa_emu.o pupa_emu-util_misc.o pupa_emu-util_i386_pc_getroot.o pupa_emu-kern_env.o CLEANFILES += grub-emu grub_emu-kern_main.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_err.o grub_emu-kern_misc.o grub_emu-kern_loader.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-disk_powerpc_ieee1275_partition.o grub_emu-util_i386_pc_biosdisk.o grub_emu-fs_fat.o grub_emu-fs_ext2.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_getroot.o grub_emu-kern_env.o
MOSTLYCLEANFILES += pupa_emu-kern_main.d pupa_emu-kern_device.d pupa_emu-kern_disk.d pupa_emu-kern_dl.d pupa_emu-kern_file.d pupa_emu-kern_fs.d pupa_emu-kern_err.d pupa_emu-kern_misc.d pupa_emu-kern_loader.d pupa_emu-kern_rescue.d pupa_emu-kern_term.d pupa_emu-disk_powerpc_ieee1275_partition.d pupa_emu-util_i386_pc_biosdisk.d pupa_emu-fs_fat.d pupa_emu-fs_ext2.d pupa_emu-normal_cmdline.d pupa_emu-normal_command.d pupa_emu-normal_main.d pupa_emu-normal_menu.d pupa_emu-util_console.d pupa_emu-util_pupa_emu.d pupa_emu-util_misc.d pupa_emu-util_i386_pc_getroot.d pupa_emu-kern_env.d MOSTLYCLEANFILES += grub_emu-kern_main.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_err.d grub_emu-kern_misc.d grub_emu-kern_loader.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-disk_powerpc_ieee1275_partition.d grub_emu-util_i386_pc_biosdisk.d grub_emu-fs_fat.d grub_emu-fs_ext2.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_getroot.d grub_emu-kern_env.d
pupa-emu: pupa_emu-kern_main.o pupa_emu-kern_device.o pupa_emu-kern_disk.o pupa_emu-kern_dl.o pupa_emu-kern_file.o pupa_emu-kern_fs.o pupa_emu-kern_err.o pupa_emu-kern_misc.o pupa_emu-kern_loader.o pupa_emu-kern_rescue.o pupa_emu-kern_term.o pupa_emu-disk_powerpc_ieee1275_partition.o pupa_emu-util_i386_pc_biosdisk.o pupa_emu-fs_fat.o pupa_emu-fs_ext2.o pupa_emu-normal_cmdline.o pupa_emu-normal_command.o pupa_emu-normal_main.o pupa_emu-normal_menu.o pupa_emu-util_console.o pupa_emu-util_pupa_emu.o pupa_emu-util_misc.o pupa_emu-util_i386_pc_getroot.o pupa_emu-kern_env.o grub-emu: grub_emu-kern_main.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_err.o grub_emu-kern_misc.o grub_emu-kern_loader.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-disk_powerpc_ieee1275_partition.o grub_emu-util_i386_pc_biosdisk.o grub_emu-fs_fat.o grub_emu-fs_ext2.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_getroot.o grub_emu-kern_env.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(pupa_emu_LDFLAGS) $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_emu_LDFLAGS)
pupa_emu-kern_main.o: kern/main.c grub_emu-kern_main.o: kern/main.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_main.d: kern/main.c grub_emu-kern_main.d: kern/main.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,main\.o[ :]*,pupa_emu-kern_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,main\.o[ :]*,grub_emu-kern_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_main.d -include grub_emu-kern_main.d
pupa_emu-kern_device.o: kern/device.c grub_emu-kern_device.o: kern/device.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_device.d: kern/device.c grub_emu-kern_device.d: kern/device.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,device\.o[ :]*,pupa_emu-kern_device.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,device\.o[ :]*,grub_emu-kern_device.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_device.d -include grub_emu-kern_device.d
pupa_emu-kern_disk.o: kern/disk.c grub_emu-kern_disk.o: kern/disk.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_disk.d: kern/disk.c grub_emu-kern_disk.d: kern/disk.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,disk\.o[ :]*,pupa_emu-kern_disk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,disk\.o[ :]*,grub_emu-kern_disk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_disk.d -include grub_emu-kern_disk.d
pupa_emu-kern_dl.o: kern/dl.c grub_emu-kern_dl.o: kern/dl.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_dl.d: kern/dl.c grub_emu-kern_dl.d: kern/dl.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,dl\.o[ :]*,pupa_emu-kern_dl.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,dl\.o[ :]*,grub_emu-kern_dl.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_dl.d -include grub_emu-kern_dl.d
pupa_emu-kern_file.o: kern/file.c grub_emu-kern_file.o: kern/file.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_file.d: kern/file.c grub_emu-kern_file.d: kern/file.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,file\.o[ :]*,pupa_emu-kern_file.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,file\.o[ :]*,grub_emu-kern_file.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_file.d -include grub_emu-kern_file.d
pupa_emu-kern_fs.o: kern/fs.c grub_emu-kern_fs.o: kern/fs.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_fs.d: kern/fs.c grub_emu-kern_fs.d: kern/fs.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,fs\.o[ :]*,pupa_emu-kern_fs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,fs\.o[ :]*,grub_emu-kern_fs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_fs.d -include grub_emu-kern_fs.d
pupa_emu-kern_err.o: kern/err.c grub_emu-kern_err.o: kern/err.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_err.d: kern/err.c grub_emu-kern_err.d: kern/err.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,err\.o[ :]*,pupa_emu-kern_err.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,err\.o[ :]*,grub_emu-kern_err.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_err.d -include grub_emu-kern_err.d
pupa_emu-kern_misc.o: kern/misc.c grub_emu-kern_misc.o: kern/misc.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_misc.d: kern/misc.c grub_emu-kern_misc.d: kern/misc.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,misc\.o[ :]*,pupa_emu-kern_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,misc\.o[ :]*,grub_emu-kern_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_misc.d -include grub_emu-kern_misc.d
pupa_emu-kern_loader.o: kern/loader.c grub_emu-kern_loader.o: kern/loader.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_loader.d: kern/loader.c grub_emu-kern_loader.d: kern/loader.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,loader\.o[ :]*,pupa_emu-kern_loader.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,loader\.o[ :]*,grub_emu-kern_loader.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_loader.d -include grub_emu-kern_loader.d
pupa_emu-kern_rescue.o: kern/rescue.c grub_emu-kern_rescue.o: kern/rescue.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_rescue.d: kern/rescue.c grub_emu-kern_rescue.d: kern/rescue.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,rescue\.o[ :]*,pupa_emu-kern_rescue.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,rescue\.o[ :]*,grub_emu-kern_rescue.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_rescue.d -include grub_emu-kern_rescue.d
pupa_emu-kern_term.o: kern/term.c grub_emu-kern_term.o: kern/term.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_term.d: kern/term.c grub_emu-kern_term.d: kern/term.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,term\.o[ :]*,pupa_emu-kern_term.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,term\.o[ :]*,grub_emu-kern_term.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_term.d -include grub_emu-kern_term.d
pupa_emu-disk_powerpc_ieee1275_partition.o: disk/powerpc/ieee1275/partition.c grub_emu-disk_powerpc_ieee1275_partition.o: disk/powerpc/ieee1275/partition.c
$(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-disk_powerpc_ieee1275_partition.d: disk/powerpc/ieee1275/partition.c grub_emu-disk_powerpc_ieee1275_partition.d: disk/powerpc/ieee1275/partition.c
set -e; $(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,partition\.o[ :]*,pupa_emu-disk_powerpc_ieee1275_partition.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,partition\.o[ :]*,grub_emu-disk_powerpc_ieee1275_partition.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-disk_powerpc_ieee1275_partition.d -include grub_emu-disk_powerpc_ieee1275_partition.d
pupa_emu-util_i386_pc_biosdisk.o: util/i386/pc/biosdisk.c grub_emu-util_i386_pc_biosdisk.o: util/i386/pc/biosdisk.c
$(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-util_i386_pc_biosdisk.d: util/i386/pc/biosdisk.c grub_emu-util_i386_pc_biosdisk.d: util/i386/pc/biosdisk.c
set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,biosdisk\.o[ :]*,pupa_emu-util_i386_pc_biosdisk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,biosdisk\.o[ :]*,grub_emu-util_i386_pc_biosdisk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-util_i386_pc_biosdisk.d -include grub_emu-util_i386_pc_biosdisk.d
pupa_emu-fs_fat.o: fs/fat.c grub_emu-fs_fat.o: fs/fat.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-fs_fat.d: fs/fat.c grub_emu-fs_fat.d: fs/fat.c
set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,fat\.o[ :]*,pupa_emu-fs_fat.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,fat\.o[ :]*,grub_emu-fs_fat.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-fs_fat.d -include grub_emu-fs_fat.d
pupa_emu-fs_ext2.o: fs/ext2.c grub_emu-fs_ext2.o: fs/ext2.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-fs_ext2.d: fs/ext2.c grub_emu-fs_ext2.d: fs/ext2.c
set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,ext2\.o[ :]*,pupa_emu-fs_ext2.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,ext2\.o[ :]*,grub_emu-fs_ext2.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-fs_ext2.d -include grub_emu-fs_ext2.d
pupa_emu-normal_cmdline.o: normal/cmdline.c grub_emu-normal_cmdline.o: normal/cmdline.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-normal_cmdline.d: normal/cmdline.c grub_emu-normal_cmdline.d: normal/cmdline.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,cmdline\.o[ :]*,pupa_emu-normal_cmdline.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,cmdline\.o[ :]*,grub_emu-normal_cmdline.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-normal_cmdline.d -include grub_emu-normal_cmdline.d
pupa_emu-normal_command.o: normal/command.c grub_emu-normal_command.o: normal/command.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-normal_command.d: normal/command.c grub_emu-normal_command.d: normal/command.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,command\.o[ :]*,pupa_emu-normal_command.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,command\.o[ :]*,grub_emu-normal_command.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-normal_command.d -include grub_emu-normal_command.d
pupa_emu-normal_main.o: normal/main.c grub_emu-normal_main.o: normal/main.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-normal_main.d: normal/main.c grub_emu-normal_main.d: normal/main.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,main\.o[ :]*,pupa_emu-normal_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,main\.o[ :]*,grub_emu-normal_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-normal_main.d -include grub_emu-normal_main.d
pupa_emu-normal_menu.o: normal/menu.c grub_emu-normal_menu.o: normal/menu.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-normal_menu.d: normal/menu.c grub_emu-normal_menu.d: normal/menu.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,menu\.o[ :]*,pupa_emu-normal_menu.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,menu\.o[ :]*,grub_emu-normal_menu.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-normal_menu.d -include grub_emu-normal_menu.d
pupa_emu-util_console.o: util/console.c grub_emu-util_console.o: util/console.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-util_console.d: util/console.c grub_emu-util_console.d: util/console.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,console\.o[ :]*,pupa_emu-util_console.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,console\.o[ :]*,grub_emu-util_console.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-util_console.d -include grub_emu-util_console.d
pupa_emu-util_pupa_emu.o: util/pupa-emu.c grub_emu-util_grub_emu.o: util/grub-emu.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-util_pupa_emu.d: util/pupa-emu.c grub_emu-util_grub_emu.d: util/grub-emu.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,pupa\-emu\.o[ :]*,pupa_emu-util_pupa_emu.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,grub\-emu\.o[ :]*,grub_emu-util_grub_emu.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-util_pupa_emu.d -include grub_emu-util_grub_emu.d
pupa_emu-util_misc.o: util/misc.c grub_emu-util_misc.o: util/misc.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-util_misc.d: util/misc.c grub_emu-util_misc.d: util/misc.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,misc\.o[ :]*,pupa_emu-util_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,misc\.o[ :]*,grub_emu-util_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-util_misc.d -include grub_emu-util_misc.d
pupa_emu-util_i386_pc_getroot.o: util/i386/pc/getroot.c grub_emu-util_i386_pc_getroot.o: util/i386/pc/getroot.c
$(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-util_i386_pc_getroot.d: util/i386/pc/getroot.c grub_emu-util_i386_pc_getroot.d: util/i386/pc/getroot.c
set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,getroot\.o[ :]*,pupa_emu-util_i386_pc_getroot.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,getroot\.o[ :]*,grub_emu-util_i386_pc_getroot.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-util_i386_pc_getroot.d -include grub_emu-util_i386_pc_getroot.d
pupa_emu-kern_env.o: kern/env.c grub_emu-kern_env.o: kern/env.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
pupa_emu-kern_env.d: kern/env.c grub_emu-kern_env.d: kern/env.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupa_emu_CFLAGS) -M $< | sed 's,env\.o[ :]*,pupa_emu-kern_env.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,env\.o[ :]*,grub_emu-kern_env.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupa_emu-kern_env.d -include grub_emu-kern_env.d
pupa_emu_LDFLAGS = -lncurses grub_emu_LDFLAGS = -lncurses
pupaof_SOURCES = boot/powerpc/ieee1275/cmain.c boot/powerpc/ieee1275/ieee1275.c \ grubof_SOURCES = boot/powerpc/ieee1275/cmain.c boot/powerpc/ieee1275/ieee1275.c \
boot/powerpc/ieee1275/crt0.S kern/main.c kern/device.c \ boot/powerpc/ieee1275/crt0.S kern/main.c kern/device.c \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \ kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \
@ -238,232 +238,232 @@ pupaof_SOURCES = boot/powerpc/ieee1275/cmain.c boot/powerpc/ieee1275/ieee1275.c
normal/command.c normal/main.c normal/menu.c \ normal/command.c normal/main.c normal/menu.c \
disk/powerpc/ieee1275/ofdisk.c disk/powerpc/ieee1275/partition.c \ disk/powerpc/ieee1275/ofdisk.c disk/powerpc/ieee1275/partition.c \
kern/env.c normal/arg.c kern/env.c normal/arg.c
CLEANFILES += pupaof pupaof-boot_powerpc_ieee1275_cmain.o pupaof-boot_powerpc_ieee1275_ieee1275.o pupaof-boot_powerpc_ieee1275_crt0.o pupaof-kern_main.o pupaof-kern_device.o pupaof-kern_disk.o pupaof-kern_dl.o pupaof-kern_file.o pupaof-kern_fs.o pupaof-kern_err.o pupaof-kern_misc.o pupaof-kern_mm.o pupaof-kern_loader.o pupaof-kern_rescue.o pupaof-kern_term.o pupaof-kern_powerpc_ieee1275_init.o pupaof-term_powerpc_ieee1275_ofconsole.o pupaof-kern_powerpc_ieee1275_openfw.o pupaof-fs_ext2.o pupaof-normal_cmdline.o pupaof-normal_command.o pupaof-normal_main.o pupaof-normal_menu.o pupaof-disk_powerpc_ieee1275_ofdisk.o pupaof-disk_powerpc_ieee1275_partition.o pupaof-kern_env.o pupaof-normal_arg.o CLEANFILES += grubof grubof-boot_powerpc_ieee1275_cmain.o grubof-boot_powerpc_ieee1275_ieee1275.o grubof-boot_powerpc_ieee1275_crt0.o grubof-kern_main.o grubof-kern_device.o grubof-kern_disk.o grubof-kern_dl.o grubof-kern_file.o grubof-kern_fs.o grubof-kern_err.o grubof-kern_misc.o grubof-kern_mm.o grubof-kern_loader.o grubof-kern_rescue.o grubof-kern_term.o grubof-kern_powerpc_ieee1275_init.o grubof-term_powerpc_ieee1275_ofconsole.o grubof-kern_powerpc_ieee1275_openfw.o grubof-fs_ext2.o grubof-normal_cmdline.o grubof-normal_command.o grubof-normal_main.o grubof-normal_menu.o grubof-disk_powerpc_ieee1275_ofdisk.o grubof-disk_powerpc_ieee1275_partition.o grubof-kern_env.o grubof-normal_arg.o
MOSTLYCLEANFILES += pupaof-boot_powerpc_ieee1275_cmain.d pupaof-boot_powerpc_ieee1275_ieee1275.d pupaof-boot_powerpc_ieee1275_crt0.d pupaof-kern_main.d pupaof-kern_device.d pupaof-kern_disk.d pupaof-kern_dl.d pupaof-kern_file.d pupaof-kern_fs.d pupaof-kern_err.d pupaof-kern_misc.d pupaof-kern_mm.d pupaof-kern_loader.d pupaof-kern_rescue.d pupaof-kern_term.d pupaof-kern_powerpc_ieee1275_init.d pupaof-term_powerpc_ieee1275_ofconsole.d pupaof-kern_powerpc_ieee1275_openfw.d pupaof-fs_ext2.d pupaof-normal_cmdline.d pupaof-normal_command.d pupaof-normal_main.d pupaof-normal_menu.d pupaof-disk_powerpc_ieee1275_ofdisk.d pupaof-disk_powerpc_ieee1275_partition.d pupaof-kern_env.d pupaof-normal_arg.d MOSTLYCLEANFILES += grubof-boot_powerpc_ieee1275_cmain.d grubof-boot_powerpc_ieee1275_ieee1275.d grubof-boot_powerpc_ieee1275_crt0.d grubof-kern_main.d grubof-kern_device.d grubof-kern_disk.d grubof-kern_dl.d grubof-kern_file.d grubof-kern_fs.d grubof-kern_err.d grubof-kern_misc.d grubof-kern_mm.d grubof-kern_loader.d grubof-kern_rescue.d grubof-kern_term.d grubof-kern_powerpc_ieee1275_init.d grubof-term_powerpc_ieee1275_ofconsole.d grubof-kern_powerpc_ieee1275_openfw.d grubof-fs_ext2.d grubof-normal_cmdline.d grubof-normal_command.d grubof-normal_main.d grubof-normal_menu.d grubof-disk_powerpc_ieee1275_ofdisk.d grubof-disk_powerpc_ieee1275_partition.d grubof-kern_env.d grubof-normal_arg.d
pupaof: pupaof-boot_powerpc_ieee1275_cmain.o pupaof-boot_powerpc_ieee1275_ieee1275.o pupaof-boot_powerpc_ieee1275_crt0.o pupaof-kern_main.o pupaof-kern_device.o pupaof-kern_disk.o pupaof-kern_dl.o pupaof-kern_file.o pupaof-kern_fs.o pupaof-kern_err.o pupaof-kern_misc.o pupaof-kern_mm.o pupaof-kern_loader.o pupaof-kern_rescue.o pupaof-kern_term.o pupaof-kern_powerpc_ieee1275_init.o pupaof-term_powerpc_ieee1275_ofconsole.o pupaof-kern_powerpc_ieee1275_openfw.o pupaof-fs_ext2.o pupaof-normal_cmdline.o pupaof-normal_command.o pupaof-normal_main.o pupaof-normal_menu.o pupaof-disk_powerpc_ieee1275_ofdisk.o pupaof-disk_powerpc_ieee1275_partition.o pupaof-kern_env.o pupaof-normal_arg.o grubof: grubof-boot_powerpc_ieee1275_cmain.o grubof-boot_powerpc_ieee1275_ieee1275.o grubof-boot_powerpc_ieee1275_crt0.o grubof-kern_main.o grubof-kern_device.o grubof-kern_disk.o grubof-kern_dl.o grubof-kern_file.o grubof-kern_fs.o grubof-kern_err.o grubof-kern_misc.o grubof-kern_mm.o grubof-kern_loader.o grubof-kern_rescue.o grubof-kern_term.o grubof-kern_powerpc_ieee1275_init.o grubof-term_powerpc_ieee1275_ofconsole.o grubof-kern_powerpc_ieee1275_openfw.o grubof-fs_ext2.o grubof-normal_cmdline.o grubof-normal_command.o grubof-normal_main.o grubof-normal_menu.o grubof-disk_powerpc_ieee1275_ofdisk.o grubof-disk_powerpc_ieee1275_partition.o grubof-kern_env.o grubof-normal_arg.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(pupaof_LDFLAGS) $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grubof_LDFLAGS)
pupaof-boot_powerpc_ieee1275_cmain.o: boot/powerpc/ieee1275/cmain.c grubof-boot_powerpc_ieee1275_cmain.o: boot/powerpc/ieee1275/cmain.c
$(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-boot_powerpc_ieee1275_cmain.d: boot/powerpc/ieee1275/cmain.c grubof-boot_powerpc_ieee1275_cmain.d: boot/powerpc/ieee1275/cmain.c
set -e; $(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,cmain\.o[ :]*,pupaof-boot_powerpc_ieee1275_cmain.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,cmain\.o[ :]*,grubof-boot_powerpc_ieee1275_cmain.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-boot_powerpc_ieee1275_cmain.d -include grubof-boot_powerpc_ieee1275_cmain.d
pupaof-boot_powerpc_ieee1275_ieee1275.o: boot/powerpc/ieee1275/ieee1275.c grubof-boot_powerpc_ieee1275_ieee1275.o: boot/powerpc/ieee1275/ieee1275.c
$(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-boot_powerpc_ieee1275_ieee1275.d: boot/powerpc/ieee1275/ieee1275.c grubof-boot_powerpc_ieee1275_ieee1275.d: boot/powerpc/ieee1275/ieee1275.c
set -e; $(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,ieee1275\.o[ :]*,pupaof-boot_powerpc_ieee1275_ieee1275.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,ieee1275\.o[ :]*,grubof-boot_powerpc_ieee1275_ieee1275.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-boot_powerpc_ieee1275_ieee1275.d -include grubof-boot_powerpc_ieee1275_ieee1275.d
pupaof-boot_powerpc_ieee1275_crt0.o: boot/powerpc/ieee1275/crt0.S grubof-boot_powerpc_ieee1275_crt0.o: boot/powerpc/ieee1275/crt0.S
$(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-boot_powerpc_ieee1275_crt0.d: boot/powerpc/ieee1275/crt0.S grubof-boot_powerpc_ieee1275_crt0.d: boot/powerpc/ieee1275/crt0.S
set -e; $(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,crt0\.o[ :]*,pupaof-boot_powerpc_ieee1275_crt0.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iboot/powerpc/ieee1275 -I$(srcdir)/boot/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,crt0\.o[ :]*,grubof-boot_powerpc_ieee1275_crt0.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-boot_powerpc_ieee1275_crt0.d -include grubof-boot_powerpc_ieee1275_crt0.d
pupaof-kern_main.o: kern/main.c grubof-kern_main.o: kern/main.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_main.d: kern/main.c grubof-kern_main.d: kern/main.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,main\.o[ :]*,pupaof-kern_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,main\.o[ :]*,grubof-kern_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_main.d -include grubof-kern_main.d
pupaof-kern_device.o: kern/device.c grubof-kern_device.o: kern/device.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_device.d: kern/device.c grubof-kern_device.d: kern/device.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,device\.o[ :]*,pupaof-kern_device.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,device\.o[ :]*,grubof-kern_device.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_device.d -include grubof-kern_device.d
pupaof-kern_disk.o: kern/disk.c grubof-kern_disk.o: kern/disk.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_disk.d: kern/disk.c grubof-kern_disk.d: kern/disk.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,disk\.o[ :]*,pupaof-kern_disk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,disk\.o[ :]*,grubof-kern_disk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_disk.d -include grubof-kern_disk.d
pupaof-kern_dl.o: kern/dl.c grubof-kern_dl.o: kern/dl.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_dl.d: kern/dl.c grubof-kern_dl.d: kern/dl.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,dl\.o[ :]*,pupaof-kern_dl.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,dl\.o[ :]*,grubof-kern_dl.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_dl.d -include grubof-kern_dl.d
pupaof-kern_file.o: kern/file.c grubof-kern_file.o: kern/file.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_file.d: kern/file.c grubof-kern_file.d: kern/file.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,file\.o[ :]*,pupaof-kern_file.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,file\.o[ :]*,grubof-kern_file.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_file.d -include grubof-kern_file.d
pupaof-kern_fs.o: kern/fs.c grubof-kern_fs.o: kern/fs.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_fs.d: kern/fs.c grubof-kern_fs.d: kern/fs.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,fs\.o[ :]*,pupaof-kern_fs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,fs\.o[ :]*,grubof-kern_fs.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_fs.d -include grubof-kern_fs.d
pupaof-kern_err.o: kern/err.c grubof-kern_err.o: kern/err.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_err.d: kern/err.c grubof-kern_err.d: kern/err.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,err\.o[ :]*,pupaof-kern_err.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,err\.o[ :]*,grubof-kern_err.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_err.d -include grubof-kern_err.d
pupaof-kern_misc.o: kern/misc.c grubof-kern_misc.o: kern/misc.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_misc.d: kern/misc.c grubof-kern_misc.d: kern/misc.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,misc\.o[ :]*,pupaof-kern_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,misc\.o[ :]*,grubof-kern_misc.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_misc.d -include grubof-kern_misc.d
pupaof-kern_mm.o: kern/mm.c grubof-kern_mm.o: kern/mm.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_mm.d: kern/mm.c grubof-kern_mm.d: kern/mm.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,mm\.o[ :]*,pupaof-kern_mm.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,mm\.o[ :]*,grubof-kern_mm.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_mm.d -include grubof-kern_mm.d
pupaof-kern_loader.o: kern/loader.c grubof-kern_loader.o: kern/loader.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_loader.d: kern/loader.c grubof-kern_loader.d: kern/loader.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,loader\.o[ :]*,pupaof-kern_loader.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,loader\.o[ :]*,grubof-kern_loader.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_loader.d -include grubof-kern_loader.d
pupaof-kern_rescue.o: kern/rescue.c grubof-kern_rescue.o: kern/rescue.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_rescue.d: kern/rescue.c grubof-kern_rescue.d: kern/rescue.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,rescue\.o[ :]*,pupaof-kern_rescue.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,rescue\.o[ :]*,grubof-kern_rescue.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_rescue.d -include grubof-kern_rescue.d
pupaof-kern_term.o: kern/term.c grubof-kern_term.o: kern/term.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_term.d: kern/term.c grubof-kern_term.d: kern/term.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,term\.o[ :]*,pupaof-kern_term.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,term\.o[ :]*,grubof-kern_term.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_term.d -include grubof-kern_term.d
pupaof-kern_powerpc_ieee1275_init.o: kern/powerpc/ieee1275/init.c grubof-kern_powerpc_ieee1275_init.o: kern/powerpc/ieee1275/init.c
$(BUILD_CC) -Ikern/powerpc/ieee1275 -I$(srcdir)/kern/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern/powerpc/ieee1275 -I$(srcdir)/kern/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_powerpc_ieee1275_init.d: kern/powerpc/ieee1275/init.c grubof-kern_powerpc_ieee1275_init.d: kern/powerpc/ieee1275/init.c
set -e; $(BUILD_CC) -Ikern/powerpc/ieee1275 -I$(srcdir)/kern/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,init\.o[ :]*,pupaof-kern_powerpc_ieee1275_init.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern/powerpc/ieee1275 -I$(srcdir)/kern/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,init\.o[ :]*,grubof-kern_powerpc_ieee1275_init.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_powerpc_ieee1275_init.d -include grubof-kern_powerpc_ieee1275_init.d
pupaof-term_powerpc_ieee1275_ofconsole.o: term/powerpc/ieee1275/ofconsole.c grubof-term_powerpc_ieee1275_ofconsole.o: term/powerpc/ieee1275/ofconsole.c
$(BUILD_CC) -Iterm/powerpc/ieee1275 -I$(srcdir)/term/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iterm/powerpc/ieee1275 -I$(srcdir)/term/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-term_powerpc_ieee1275_ofconsole.d: term/powerpc/ieee1275/ofconsole.c grubof-term_powerpc_ieee1275_ofconsole.d: term/powerpc/ieee1275/ofconsole.c
set -e; $(BUILD_CC) -Iterm/powerpc/ieee1275 -I$(srcdir)/term/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,ofconsole\.o[ :]*,pupaof-term_powerpc_ieee1275_ofconsole.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iterm/powerpc/ieee1275 -I$(srcdir)/term/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,ofconsole\.o[ :]*,grubof-term_powerpc_ieee1275_ofconsole.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-term_powerpc_ieee1275_ofconsole.d -include grubof-term_powerpc_ieee1275_ofconsole.d
pupaof-kern_powerpc_ieee1275_openfw.o: kern/powerpc/ieee1275/openfw.c grubof-kern_powerpc_ieee1275_openfw.o: kern/powerpc/ieee1275/openfw.c
$(BUILD_CC) -Ikern/powerpc/ieee1275 -I$(srcdir)/kern/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern/powerpc/ieee1275 -I$(srcdir)/kern/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_powerpc_ieee1275_openfw.d: kern/powerpc/ieee1275/openfw.c grubof-kern_powerpc_ieee1275_openfw.d: kern/powerpc/ieee1275/openfw.c
set -e; $(BUILD_CC) -Ikern/powerpc/ieee1275 -I$(srcdir)/kern/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,openfw\.o[ :]*,pupaof-kern_powerpc_ieee1275_openfw.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern/powerpc/ieee1275 -I$(srcdir)/kern/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,openfw\.o[ :]*,grubof-kern_powerpc_ieee1275_openfw.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_powerpc_ieee1275_openfw.d -include grubof-kern_powerpc_ieee1275_openfw.d
pupaof-fs_ext2.o: fs/ext2.c grubof-fs_ext2.o: fs/ext2.c
$(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-fs_ext2.d: fs/ext2.c grubof-fs_ext2.d: fs/ext2.c
set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,ext2\.o[ :]*,pupaof-fs_ext2.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ifs -I$(srcdir)/fs $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,ext2\.o[ :]*,grubof-fs_ext2.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-fs_ext2.d -include grubof-fs_ext2.d
pupaof-normal_cmdline.o: normal/cmdline.c grubof-normal_cmdline.o: normal/cmdline.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-normal_cmdline.d: normal/cmdline.c grubof-normal_cmdline.d: normal/cmdline.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,cmdline\.o[ :]*,pupaof-normal_cmdline.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,cmdline\.o[ :]*,grubof-normal_cmdline.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-normal_cmdline.d -include grubof-normal_cmdline.d
pupaof-normal_command.o: normal/command.c grubof-normal_command.o: normal/command.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-normal_command.d: normal/command.c grubof-normal_command.d: normal/command.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,command\.o[ :]*,pupaof-normal_command.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,command\.o[ :]*,grubof-normal_command.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-normal_command.d -include grubof-normal_command.d
pupaof-normal_main.o: normal/main.c grubof-normal_main.o: normal/main.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-normal_main.d: normal/main.c grubof-normal_main.d: normal/main.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,main\.o[ :]*,pupaof-normal_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,main\.o[ :]*,grubof-normal_main.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-normal_main.d -include grubof-normal_main.d
pupaof-normal_menu.o: normal/menu.c grubof-normal_menu.o: normal/menu.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-normal_menu.d: normal/menu.c grubof-normal_menu.d: normal/menu.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,menu\.o[ :]*,pupaof-normal_menu.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,menu\.o[ :]*,grubof-normal_menu.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-normal_menu.d -include grubof-normal_menu.d
pupaof-disk_powerpc_ieee1275_ofdisk.o: disk/powerpc/ieee1275/ofdisk.c grubof-disk_powerpc_ieee1275_ofdisk.o: disk/powerpc/ieee1275/ofdisk.c
$(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-disk_powerpc_ieee1275_ofdisk.d: disk/powerpc/ieee1275/ofdisk.c grubof-disk_powerpc_ieee1275_ofdisk.d: disk/powerpc/ieee1275/ofdisk.c
set -e; $(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,ofdisk\.o[ :]*,pupaof-disk_powerpc_ieee1275_ofdisk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,ofdisk\.o[ :]*,grubof-disk_powerpc_ieee1275_ofdisk.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-disk_powerpc_ieee1275_ofdisk.d -include grubof-disk_powerpc_ieee1275_ofdisk.d
pupaof-disk_powerpc_ieee1275_partition.o: disk/powerpc/ieee1275/partition.c grubof-disk_powerpc_ieee1275_partition.o: disk/powerpc/ieee1275/partition.c
$(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-disk_powerpc_ieee1275_partition.d: disk/powerpc/ieee1275/partition.c grubof-disk_powerpc_ieee1275_partition.d: disk/powerpc/ieee1275/partition.c
set -e; $(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,partition\.o[ :]*,pupaof-disk_powerpc_ieee1275_partition.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Idisk/powerpc/ieee1275 -I$(srcdir)/disk/powerpc/ieee1275 $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,partition\.o[ :]*,grubof-disk_powerpc_ieee1275_partition.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-disk_powerpc_ieee1275_partition.d -include grubof-disk_powerpc_ieee1275_partition.d
pupaof-kern_env.o: kern/env.c grubof-kern_env.o: kern/env.c
$(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-kern_env.d: kern/env.c grubof-kern_env.d: kern/env.c
set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,env\.o[ :]*,pupaof-kern_env.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Ikern -I$(srcdir)/kern $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,env\.o[ :]*,grubof-kern_env.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-kern_env.d -include grubof-kern_env.d
pupaof-normal_arg.o: normal/arg.c grubof-normal_arg.o: normal/arg.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -c -o $@ $< $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -c -o $@ $<
pupaof-normal_arg.d: normal/arg.c grubof-normal_arg.d: normal/arg.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(pupaof_CFLAGS) -M $< | sed 's,arg\.o[ :]*,pupaof-normal_arg.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grubof_CFLAGS) -M $< | sed 's,arg\.o[ :]*,grubof-normal_arg.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include pupaof-normal_arg.d -include grubof-normal_arg.d
pupaof_HEADERS = pupa/powerpc/ieee1275/ieee1275.h grubof_HEADERS = grub/powerpc/ieee1275/ieee1275.h
pupaof_CFLAGS = $(COMMON_CFLAGS) grubof_CFLAGS = $(COMMON_CFLAGS)
pupaof_ASFLAGS = $(COMMON_ASFLAGS) grubof_ASFLAGS = $(COMMON_ASFLAGS)
pupaof_LDFLAGS = -Wl,-Ttext,0x200000,-Bstatic grubof_LDFLAGS = -Wl,-Ttext,0x200000,-Bstatic
# For genmoddep. # For genmoddep.
genmoddep_SOURCES = util/genmoddep.c genmoddep_SOURCES = util/genmoddep.c
@ -474,10 +474,10 @@ genmoddep: genmoddep-util_genmoddep.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(genmoddep_LDFLAGS) $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(genmoddep_LDFLAGS)
genmoddep-util_genmoddep.o: util/genmoddep.c genmoddep-util_genmoddep.o: util/genmoddep.c
$(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(genmoddep_CFLAGS) -c -o $@ $< $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(genmoddep_CFLAGS) -c -o $@ $<
genmoddep-util_genmoddep.d: util/genmoddep.c genmoddep-util_genmoddep.d: util/genmoddep.c
set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(genmoddep_CFLAGS) -M $< | sed 's,genmoddep\.o[ :]*,genmoddep-util_genmoddep.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@ set -e; $(BUILD_CC) -Iutil -I$(srcdir)/util $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(genmoddep_CFLAGS) -M $< | sed 's,genmoddep\.o[ :]*,genmoddep-util_genmoddep.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include genmoddep-util_genmoddep.d -include genmoddep-util_genmoddep.d

View file

@ -9,29 +9,29 @@ COMMON_CFLAGS = -fno-builtin -D__ASSEMBLY__
MOSTLYCLEANFILES += symlist.c kernel_syms.lst MOSTLYCLEANFILES += symlist.c kernel_syms.lst
DEFSYMFILES += kernel_syms.lst DEFSYMFILES += kernel_syms.lst
symlist.c: $(addprefix include/pupa/,$(kernel_img_HEADERS)) gensymlist.sh symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) gensymlist.sh
sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@ sh $(srcdir)/gensymlist.sh $(filter %.h,$^) > $@
kernel_syms.lst: $(addprefix include/pupa/,$(kernel_img_HEADERS)) genkernsyms.sh kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) genkernsyms.sh
sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@ sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@
# Utilities. # Utilities.
sbin_UTILITIES = pupaof sbin_UTILITIES = grubof
bin_UTILITIES = pupa-emu bin_UTILITIES = grub-emu
noinst_UTILITIES = genmoddep noinst_UTILITIES = genmoddep
# For pupa-emu # For grub-emu
pupa_emu_SOURCES = kern/main.c kern/device.c \ grub_emu_SOURCES = kern/main.c kern/device.c \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
kern/misc.c kern/loader.c kern/rescue.c kern/term.c \ kern/misc.c kern/loader.c kern/rescue.c kern/term.c \
disk/powerpc/ieee1275/partition.c \ disk/powerpc/ieee1275/partition.c \
util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c \ util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c \
normal/cmdline.c normal/command.c normal/main.c normal/menu.c \ normal/cmdline.c normal/command.c normal/main.c normal/menu.c \
util/console.c util/pupa-emu.c util/misc.c util/i386/pc/getroot.c \ util/console.c util/grub-emu.c util/misc.c util/i386/pc/getroot.c \
kern/env.c kern/env.c
pupa_emu_LDFLAGS = -lncurses grub_emu_LDFLAGS = -lncurses
pupaof_SOURCES = boot/powerpc/ieee1275/cmain.c boot/powerpc/ieee1275/ieee1275.c \ grubof_SOURCES = boot/powerpc/ieee1275/cmain.c boot/powerpc/ieee1275/ieee1275.c \
boot/powerpc/ieee1275/crt0.S kern/main.c kern/device.c \ boot/powerpc/ieee1275/crt0.S kern/main.c kern/device.c \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \ kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \
@ -40,10 +40,10 @@ pupaof_SOURCES = boot/powerpc/ieee1275/cmain.c boot/powerpc/ieee1275/ieee1275.c
normal/command.c normal/main.c normal/menu.c \ normal/command.c normal/main.c normal/menu.c \
disk/powerpc/ieee1275/ofdisk.c disk/powerpc/ieee1275/partition.c \ disk/powerpc/ieee1275/ofdisk.c disk/powerpc/ieee1275/partition.c \
kern/env.c normal/arg.c kern/env.c normal/arg.c
pupaof_HEADERS = pupa/powerpc/ieee1275/ieee1275.h grubof_HEADERS = grub/powerpc/ieee1275/ieee1275.h
pupaof_CFLAGS = $(COMMON_CFLAGS) grubof_CFLAGS = $(COMMON_CFLAGS)
pupaof_ASFLAGS = $(COMMON_ASFLAGS) grubof_ASFLAGS = $(COMMON_ASFLAGS)
pupaof_LDFLAGS = -Wl,-Ttext,0x200000,-Bstatic grubof_LDFLAGS = -Wl,-Ttext,0x200000,-Bstatic
# For genmoddep. # For genmoddep.
genmoddep_SOURCES = util/genmoddep.c genmoddep_SOURCES = util/genmoddep.c

182
configure vendored
View file

@ -272,7 +272,7 @@ PACKAGE_VERSION='1.90'
PACKAGE_STRING='GRUB 1.90' PACKAGE_STRING='GRUB 1.90'
PACKAGE_BUGREPORT='bug-grub@gnu.org' PACKAGE_BUGREPORT='bug-grub@gnu.org'
ac_unique_file="include/pupa/dl.h" ac_unique_file="include/grub/dl.h"
# Factoring default headers for most tests. # Factoring default headers for most tests.
ac_includes_default="\ ac_includes_default="\
#include <stdio.h> #include <stdio.h>
@ -2693,7 +2693,7 @@ fi
echo "$as_me:$LINENO: checking if C symbols get an underscore after compilation" >&5 echo "$as_me:$LINENO: checking if C symbols get an underscore after compilation" >&5
echo $ECHO_N "checking if C symbols get an underscore after compilation... $ECHO_C" >&6 echo $ECHO_N "checking if C symbols get an underscore after compilation... $ECHO_C" >&6
if test "${pupa_cv_asm_uscore+set}" = set; then if test "${grub_cv_asm_uscore+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat > conftest.c <<\EOF cat > conftest.c <<\EOF
@ -2719,31 +2719,31 @@ echo "$as_me: error: ${CC-cc} failed to produce assembly code" >&2;}
fi fi
if grep _func conftest.s >/dev/null 2>&1; then if grep _func conftest.s >/dev/null 2>&1; then
pupa_cv_asm_uscore=yes grub_cv_asm_uscore=yes
else else
pupa_cv_asm_uscore=no grub_cv_asm_uscore=no
fi fi
rm -f conftest* rm -f conftest*
fi fi
if test "x$pupa_cv_asm_uscore" = xyes; then if test "x$grub_cv_asm_uscore" = xyes; then
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define HAVE_ASM_USCORE $pupa_cv_asm_uscore #define HAVE_ASM_USCORE $grub_cv_asm_uscore
_ACEOF _ACEOF
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_asm_uscore" >&5 echo "$as_me:$LINENO: result: $grub_cv_asm_uscore" >&5
echo "${ECHO_T}$pupa_cv_asm_uscore" >&6 echo "${ECHO_T}$grub_cv_asm_uscore" >&6
if test "x$host_cpu" = xi386; then if test "x$host_cpu" = xi386; then
echo "$as_me:$LINENO: checking if start is defined by the compiler" >&5 echo "$as_me:$LINENO: checking if start is defined by the compiler" >&5
echo $ECHO_N "checking if start is defined by the compiler... $ECHO_C" >&6 echo $ECHO_N "checking if start is defined by the compiler... $ECHO_C" >&6
if test "${pupa_cv_check_start_symbol+set}" = set; then if test "${grub_cv_check_start_symbol+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
@ -2774,23 +2774,23 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
pupa_cv_check_start_symbol=yes grub_cv_check_start_symbol=yes
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
pupa_cv_check_start_symbol=no grub_cv_check_start_symbol=no
fi fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_check_start_symbol" >&5 echo "$as_me:$LINENO: result: $grub_cv_check_start_symbol" >&5
echo "${ECHO_T}$pupa_cv_check_start_symbol" >&6 echo "${ECHO_T}$grub_cv_check_start_symbol" >&6
echo "$as_me:$LINENO: checking if _start is defined by the compiler" >&5 echo "$as_me:$LINENO: checking if _start is defined by the compiler" >&5
echo $ECHO_N "checking if _start is defined by the compiler... $ECHO_C" >&6 echo $ECHO_N "checking if _start is defined by the compiler... $ECHO_C" >&6
if test "${pupa_cv_check_uscore_start_symbol+set}" = set; then if test "${grub_cv_check_uscore_start_symbol+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
@ -2821,29 +2821,29 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
pupa_cv_check_uscore_start_symbol=yes grub_cv_check_uscore_start_symbol=yes
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
pupa_cv_check_uscore_start_symbol=no grub_cv_check_uscore_start_symbol=no
fi fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_check_uscore_start_symbol" >&5 echo "$as_me:$LINENO: result: $grub_cv_check_uscore_start_symbol" >&5
echo "${ECHO_T}$pupa_cv_check_uscore_start_symbol" >&6 echo "${ECHO_T}$grub_cv_check_uscore_start_symbol" >&6
if test "x$pupa_cv_check_start_symbol" = xyes; then if test "x$grub_cv_check_start_symbol" = xyes; then
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
#define START_SYMBOL start #define START_SYMBOL start
_ACEOF _ACEOF
elif test "x$pupa_cv_check_uscore_start_symbol" = xyes; then elif test "x$grub_cv_check_uscore_start_symbol" = xyes; then
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
#define START_SYMBOL _start #define START_SYMBOL _start
_ACEOF _ACEOF
@ -2857,7 +2857,7 @@ fi
echo "$as_me:$LINENO: checking if __bss_start is defined by the compiler" >&5 echo "$as_me:$LINENO: checking if __bss_start is defined by the compiler" >&5
echo $ECHO_N "checking if __bss_start is defined by the compiler... $ECHO_C" >&6 echo $ECHO_N "checking if __bss_start is defined by the compiler... $ECHO_C" >&6
if test "${pupa_cv_check_uscore_uscore_bss_start_symbol+set}" = set; then if test "${grub_cv_check_uscore_uscore_bss_start_symbol+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
@ -2888,23 +2888,23 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
pupa_cv_check_uscore_uscore_bss_start_symbol=yes grub_cv_check_uscore_uscore_bss_start_symbol=yes
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
pupa_cv_check_uscore_uscore_bss_start_symbol=no grub_cv_check_uscore_uscore_bss_start_symbol=no
fi fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_check_uscore_uscore_bss_start_symbol" >&5 echo "$as_me:$LINENO: result: $grub_cv_check_uscore_uscore_bss_start_symbol" >&5
echo "${ECHO_T}$pupa_cv_check_uscore_uscore_bss_start_symbol" >&6 echo "${ECHO_T}$grub_cv_check_uscore_uscore_bss_start_symbol" >&6
echo "$as_me:$LINENO: checking if edata is defined by the compiler" >&5 echo "$as_me:$LINENO: checking if edata is defined by the compiler" >&5
echo $ECHO_N "checking if edata is defined by the compiler... $ECHO_C" >&6 echo $ECHO_N "checking if edata is defined by the compiler... $ECHO_C" >&6
if test "${pupa_cv_check_edata_symbol+set}" = set; then if test "${grub_cv_check_edata_symbol+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
@ -2935,23 +2935,23 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
pupa_cv_check_edata_symbol=yes grub_cv_check_edata_symbol=yes
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
pupa_cv_check_edata_symbol=no grub_cv_check_edata_symbol=no
fi fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_check_edata_symbol" >&5 echo "$as_me:$LINENO: result: $grub_cv_check_edata_symbol" >&5
echo "${ECHO_T}$pupa_cv_check_edata_symbol" >&6 echo "${ECHO_T}$grub_cv_check_edata_symbol" >&6
echo "$as_me:$LINENO: checking if _edata is defined by the compiler" >&5 echo "$as_me:$LINENO: checking if _edata is defined by the compiler" >&5
echo $ECHO_N "checking if _edata is defined by the compiler... $ECHO_C" >&6 echo $ECHO_N "checking if _edata is defined by the compiler... $ECHO_C" >&6
if test "${pupa_cv_check_uscore_edata_symbol+set}" = set; then if test "${grub_cv_check_uscore_edata_symbol+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
@ -2982,34 +2982,34 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
pupa_cv_check_uscore_edata_symbol=yes grub_cv_check_uscore_edata_symbol=yes
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
pupa_cv_check_uscore_edata_symbol=no grub_cv_check_uscore_edata_symbol=no
fi fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_check_uscore_edata_symbol" >&5 echo "$as_me:$LINENO: result: $grub_cv_check_uscore_edata_symbol" >&5
echo "${ECHO_T}$pupa_cv_check_uscore_edata_symbol" >&6 echo "${ECHO_T}$grub_cv_check_uscore_edata_symbol" >&6
if test "x$pupa_cv_check_uscore_uscore_bss_start_symbol" = xyes; then if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" = xyes; then
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
#define BSS_START_SYMBOL __bss_start #define BSS_START_SYMBOL __bss_start
_ACEOF _ACEOF
elif test "x$pupa_cv_check_edata_symbol" = xyes; then elif test "x$grub_cv_check_edata_symbol" = xyes; then
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
#define BSS_START_SYMBOL edata #define BSS_START_SYMBOL edata
_ACEOF _ACEOF
elif test "x$pupa_cv_check_uscore_edata_symbol" = xyes; then elif test "x$grub_cv_check_uscore_edata_symbol" = xyes; then
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
#define BSS_START_SYMBOL _edata #define BSS_START_SYMBOL _edata
_ACEOF _ACEOF
@ -3023,7 +3023,7 @@ fi
echo "$as_me:$LINENO: checking if end is defined by the compiler" >&5 echo "$as_me:$LINENO: checking if end is defined by the compiler" >&5
echo $ECHO_N "checking if end is defined by the compiler... $ECHO_C" >&6 echo $ECHO_N "checking if end is defined by the compiler... $ECHO_C" >&6
if test "${pupa_cv_check_end_symbol+set}" = set; then if test "${grub_cv_check_end_symbol+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
@ -3054,23 +3054,23 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
pupa_cv_check_end_symbol=yes grub_cv_check_end_symbol=yes
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
pupa_cv_check_end_symbol=no grub_cv_check_end_symbol=no
fi fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_check_end_symbol" >&5 echo "$as_me:$LINENO: result: $grub_cv_check_end_symbol" >&5
echo "${ECHO_T}$pupa_cv_check_end_symbol" >&6 echo "${ECHO_T}$grub_cv_check_end_symbol" >&6
echo "$as_me:$LINENO: checking if _end is defined by the compiler" >&5 echo "$as_me:$LINENO: checking if _end is defined by the compiler" >&5
echo $ECHO_N "checking if _end is defined by the compiler... $ECHO_C" >&6 echo $ECHO_N "checking if _end is defined by the compiler... $ECHO_C" >&6
if test "${pupa_cv_check_uscore_end_symbol+set}" = set; then if test "${grub_cv_check_uscore_end_symbol+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
@ -3101,29 +3101,29 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
pupa_cv_check_uscore_end_symbol=yes grub_cv_check_uscore_end_symbol=yes
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
pupa_cv_check_uscore_end_symbol=no grub_cv_check_uscore_end_symbol=no
fi fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_check_uscore_end_symbol" >&5 echo "$as_me:$LINENO: result: $grub_cv_check_uscore_end_symbol" >&5
echo "${ECHO_T}$pupa_cv_check_uscore_end_symbol" >&6 echo "${ECHO_T}$grub_cv_check_uscore_end_symbol" >&6
if test "x$pupa_cv_check_end_symbol" = xyes; then if test "x$grub_cv_check_end_symbol" = xyes; then
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
#define END_SYMBOL end #define END_SYMBOL end
_ACEOF _ACEOF
elif test "x$pupa_cv_check_uscore_end_symbol" = xyes; then elif test "x$grub_cv_check_uscore_end_symbol" = xyes; then
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
#define END_SYMBOL _end #define END_SYMBOL _end
_ACEOF _ACEOF
@ -3140,7 +3140,7 @@ if test "x$host_cpu" = xi386; then
echo "$as_me:$LINENO: checking whether addr32 must be in the same line as the instruction" >&5 echo "$as_me:$LINENO: checking whether addr32 must be in the same line as the instruction" >&5
echo $ECHO_N "checking whether addr32 must be in the same line as the instruction... $ECHO_C" >&6 echo $ECHO_N "checking whether addr32 must be in the same line as the instruction... $ECHO_C" >&6
if test "${pupa_cv_i386_asm_prefix_requirement+set}" = set; then if test "${grub_cv_i386_asm_prefix_requirement+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat > conftest.s <<\EOF cat > conftest.s <<\EOF
@ -3154,41 +3154,41 @@ if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } && test -s conftest.o; then (exit $ac_status); }; } && test -s conftest.o; then
pupa_cv_i386_asm_prefix_requirement=yes grub_cv_i386_asm_prefix_requirement=yes
else else
pupa_cv_i386_asm_prefix_requirement=no grub_cv_i386_asm_prefix_requirement=no
fi fi
rm -f conftest* rm -f conftest*
fi fi
if test "x$pupa_cv_i386_asm_prefix_requirement" = xyes; then if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then
pupa_tmp_addr32="addr32" grub_tmp_addr32="addr32"
pupa_tmp_data32="data32" grub_tmp_data32="data32"
else else
pupa_tmp_addr32="addr32;" grub_tmp_addr32="addr32;"
pupa_tmp_data32="data32;" grub_tmp_data32="data32;"
fi fi
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define ADDR32 $pupa_tmp_addr32 #define ADDR32 $grub_tmp_addr32
_ACEOF _ACEOF
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define DATA32 $pupa_tmp_data32 #define DATA32 $grub_tmp_data32
_ACEOF _ACEOF
echo "$as_me:$LINENO: result: $pupa_cv_i386_asm_prefix_requirement" >&5 echo "$as_me:$LINENO: result: $grub_cv_i386_asm_prefix_requirement" >&5
echo "${ECHO_T}$pupa_cv_i386_asm_prefix_requirement" >&6 echo "${ECHO_T}$grub_cv_i386_asm_prefix_requirement" >&6
echo "$as_me:$LINENO: checking for .code16 addr32 assembler support" >&5 echo "$as_me:$LINENO: checking for .code16 addr32 assembler support" >&5
echo $ECHO_N "checking for .code16 addr32 assembler support... $ECHO_C" >&6 echo $ECHO_N "checking for .code16 addr32 assembler support... $ECHO_C" >&6
if test "${pupa_cv_i386_asm_addr32+set}" = set; then if test "${grub_cv_i386_asm_addr32+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat > conftest.s.in <<\EOF cat > conftest.s.in <<\EOF
@ -3196,7 +3196,7 @@ else
l1: @ADDR32@ movb %al, l1 l1: @ADDR32@ movb %al, l1
EOF EOF
if test "x$pupa_cv_i386_asm_prefix_requirement" = xyes; then if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then
sed -e s/@ADDR32@/addr32/ < conftest.s.in > conftest.s sed -e s/@ADDR32@/addr32/ < conftest.s.in > conftest.s
else else
sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s
@ -3208,21 +3208,21 @@ if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } && test -s conftest.o; then (exit $ac_status); }; } && test -s conftest.o; then
pupa_cv_i386_asm_addr32=yes grub_cv_i386_asm_addr32=yes
else else
pupa_cv_i386_asm_addr32=no grub_cv_i386_asm_addr32=no
fi fi
rm -f conftest* rm -f conftest*
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_i386_asm_addr32" >&5 echo "$as_me:$LINENO: result: $grub_cv_i386_asm_addr32" >&5
echo "${ECHO_T}$pupa_cv_i386_asm_addr32" >&6 echo "${ECHO_T}$grub_cv_i386_asm_addr32" >&6
echo "$as_me:$LINENO: checking whether an absolute indirect call/jump must not be prefixed with an asterisk" >&5 echo "$as_me:$LINENO: checking whether an absolute indirect call/jump must not be prefixed with an asterisk" >&5
echo $ECHO_N "checking whether an absolute indirect call/jump must not be prefixed with an asterisk... $ECHO_C" >&6 echo $ECHO_N "checking whether an absolute indirect call/jump must not be prefixed with an asterisk... $ECHO_C" >&6
if test "${pupa_cv_i386_asm_absolute_without_asterisk+set}" = set; then if test "${grub_cv_i386_asm_absolute_without_asterisk+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat > conftest.s <<\EOF cat > conftest.s <<\EOF
@ -3238,16 +3238,16 @@ if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } && test -s conftest.o; then (exit $ac_status); }; } && test -s conftest.o; then
pupa_cv_i386_asm_absolute_without_asterisk=no grub_cv_i386_asm_absolute_without_asterisk=no
else else
pupa_cv_i386_asm_absolute_without_asterisk=yes grub_cv_i386_asm_absolute_without_asterisk=yes
fi fi
rm -f conftest* rm -f conftest*
fi fi
if test "x$pupa_cv_i386_asm_absolute_without_asterisk" = xyes; then if test "x$grub_cv_i386_asm_absolute_without_asterisk" = xyes; then
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
#define ABSOLUTE_WITHOUT_ASTERISK 1 #define ABSOLUTE_WITHOUT_ASTERISK 1
@ -3255,12 +3255,12 @@ _ACEOF
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_i386_asm_absolute_without_asterisk" >&5 echo "$as_me:$LINENO: result: $grub_cv_i386_asm_absolute_without_asterisk" >&5
echo "${ECHO_T}$pupa_cv_i386_asm_absolute_without_asterisk" >&6 echo "${ECHO_T}$grub_cv_i386_asm_absolute_without_asterisk" >&6
echo "$as_me:$LINENO: checking if GCC has the regparm=3 bug" >&5 echo "$as_me:$LINENO: checking if GCC has the regparm=3 bug" >&5
echo $ECHO_N "checking if GCC has the regparm=3 bug... $ECHO_C" >&6 echo $ECHO_N "checking if GCC has the regparm=3 bug... $ECHO_C" >&6
if test "${pupa_cv_i386_check_nested_functions+set}" = set; then if test "${grub_cv_i386_check_nested_functions+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
if test "$cross_compiling" = yes; then if test "$cross_compiling" = yes; then
@ -3305,24 +3305,24 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
pupa_cv_i386_check_nested_functions=yes grub_cv_i386_check_nested_functions=yes
else else
echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status ) ( exit $ac_status )
pupa_cv_i386_check_nested_functions=no grub_cv_i386_check_nested_functions=no
fi fi
rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi fi
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_i386_check_nested_functions" >&5 echo "$as_me:$LINENO: result: $grub_cv_i386_check_nested_functions" >&5
echo "${ECHO_T}$pupa_cv_i386_check_nested_functions" >&6 echo "${ECHO_T}$grub_cv_i386_check_nested_functions" >&6
if test "x$pupa_cv_i386_check_nested_functions" = xyes; then if test "x$grub_cv_i386_check_nested_functions" = xyes; then
cat >>confdefs.h <<\_ACEOF cat >>confdefs.h <<\_ACEOF
#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (2))) #define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (2)))
@ -3531,7 +3531,7 @@ fi
echo "$as_me:$LINENO: checking whether ${OBJCOPY} works for absolute addresses" >&5 echo "$as_me:$LINENO: checking whether ${OBJCOPY} works for absolute addresses" >&5
echo $ECHO_N "checking whether ${OBJCOPY} works for absolute addresses... $ECHO_C" >&6 echo $ECHO_N "checking whether ${OBJCOPY} works for absolute addresses... $ECHO_C" >&6
if test "${pupa_cv_prog_objcopy_absolute+set}" = set; then if test "${grub_cv_prog_objcopy_absolute+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat > conftest.c <<\EOF cat > conftest.c <<\EOF
@ -3552,7 +3552,7 @@ else
echo "$as_me: error: ${CC-cc} cannot compile C source code" >&2;} echo "$as_me: error: ${CC-cc} cannot compile C source code" >&2;}
{ (exit 1); exit 1; }; } { (exit 1); exit 1; }; }
fi fi
pupa_cv_prog_objcopy_absolute=yes grub_cv_prog_objcopy_absolute=yes
for link_addr in 2000 8000 7C00; do for link_addr in 2000 8000 7C00; do
if { ac_try='${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec' if { ac_try='${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
@ -3584,19 +3584,19 @@ echo "$as_me: error: ${OBJCOPY-objcopy} cannot create binary files" >&2;}
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
mv -f conftest conftest.old mv -f conftest conftest.old
else else
pupa_cv_prog_objcopy_absolute=no grub_cv_prog_objcopy_absolute=no
break break
fi fi
done done
rm -f conftest* rm -f conftest*
fi fi
echo "$as_me:$LINENO: result: $pupa_cv_prog_objcopy_absolute" >&5 echo "$as_me:$LINENO: result: $grub_cv_prog_objcopy_absolute" >&5
echo "${ECHO_T}$pupa_cv_prog_objcopy_absolute" >&6 echo "${ECHO_T}$grub_cv_prog_objcopy_absolute" >&6
if test "x$pupa_cv_prog_objcopy_absolute" = xno; then if test "x$grub_cv_prog_objcopy_absolute" = xno; then
{ { echo "$as_me:$LINENO: error: PUPA requires a working absolute objcopy; upgrade your binutils" >&5 { { echo "$as_me:$LINENO: error: GRUB requires a working absolute objcopy; upgrade your binutils" >&5
echo "$as_me: error: PUPA requires a working absolute objcopy; upgrade your binutils" >&2;} echo "$as_me: error: GRUB requires a working absolute objcopy; upgrade your binutils" >&2;}
{ (exit 1); exit 1; }; } { (exit 1); exit 1; }; }
fi fi
@ -5495,7 +5495,7 @@ CFLAGS="$tmp_CFLAGS"
CPPFLAGS="$tmp_CPPFLAGS" CPPFLAGS="$tmp_CPPFLAGS"
# Output files. # Output files.
ac_config_links="$ac_config_links include/pupa/cpu:include/pupa/$host_cpu include/pupa/machine:include/pupa/$host_cpu/$host_vendor" ac_config_links="$ac_config_links include/grub/cpu:include/grub/$host_cpu include/grub/machine:include/grub/$host_cpu/$host_vendor"
ac_config_files="$ac_config_files Makefile" ac_config_files="$ac_config_files Makefile"
@ -6030,8 +6030,8 @@ do
# Handling of arguments. # Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"stamp-h" ) CONFIG_FILES="$CONFIG_FILES stamp-h" ;; "stamp-h" ) CONFIG_FILES="$CONFIG_FILES stamp-h" ;;
"include/pupa/cpu" ) CONFIG_LINKS="$CONFIG_LINKS include/pupa/cpu:include/pupa/$host_cpu" ;; "include/grub/cpu" ) CONFIG_LINKS="$CONFIG_LINKS include/grub/cpu:include/grub/$host_cpu" ;;
"include/pupa/machine" ) CONFIG_LINKS="$CONFIG_LINKS include/pupa/machine:include/pupa/$host_cpu/$host_vendor" ;; "include/grub/machine" ) CONFIG_LINKS="$CONFIG_LINKS include/grub/machine:include/grub/$host_cpu/$host_vendor" ;;
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;} echo "$as_me: error: invalid argument: $ac_config_target" >&2;}

View file

@ -13,7 +13,7 @@
AC_INIT(GRUB, 1.90, [bug-grub@gnu.org]) AC_INIT(GRUB, 1.90, [bug-grub@gnu.org])
AC_PREREQ(2.53) AC_PREREQ(2.53)
AC_CONFIG_SRCDIR([include/pupa/dl.h]) AC_CONFIG_SRCDIR([include/grub/dl.h])
AC_CONFIG_HEADER([config.h]) AC_CONFIG_HEADER([config.h])
# Checks for build and host systems. # Checks for build and host systems.
@ -81,18 +81,18 @@ fi
AC_SUBST(CFLAGS) AC_SUBST(CFLAGS)
# Defined in aclocal.m4. # Defined in aclocal.m4.
pupa_ASM_USCORE grub_ASM_USCORE
if test "x$host_cpu" = xi386; then if test "x$host_cpu" = xi386; then
pupa_CHECK_START_SYMBOL grub_CHECK_START_SYMBOL
pupa_CHECK_BSS_START_SYMBOL grub_CHECK_BSS_START_SYMBOL
pupa_CHECK_END_SYMBOL grub_CHECK_END_SYMBOL
fi fi
if test "x$host_cpu" = xi386; then if test "x$host_cpu" = xi386; then
pupa_I386_ASM_PREFIX_REQUIREMENT grub_I386_ASM_PREFIX_REQUIREMENT
pupa_I386_ASM_ADDR32 grub_I386_ASM_ADDR32
pupa_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
pupa_I386_CHECK_REGPARM_BUG grub_I386_CHECK_REGPARM_BUG
else else
AC_DEFINE([NESTED_FUNC_ATTR], [],[Catch gcc bug]) AC_DEFINE([NESTED_FUNC_ATTR], [],[Catch gcc bug])
fi fi
@ -100,7 +100,7 @@ fi
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_CHECK_TOOL(OBJCOPY, objcopy) AC_CHECK_TOOL(OBJCOPY, objcopy)
pupa_PROG_OBJCOPY_ABSOLUTE grub_PROG_OBJCOPY_ABSOLUTE
AC_CHECK_TOOL(STRIP, strip) AC_CHECK_TOOL(STRIP, strip)
AC_CHECK_TOOL(NM, nm) AC_CHECK_TOOL(NM, nm)
AC_CHECK_TOOL(LD, ld) AC_CHECK_TOOL(LD, ld)
@ -143,8 +143,8 @@ CFLAGS="$tmp_CFLAGS"
CPPFLAGS="$tmp_CPPFLAGS" CPPFLAGS="$tmp_CPPFLAGS"
# Output files. # Output files.
AC_CONFIG_LINKS([include/pupa/cpu:include/pupa/$host_cpu AC_CONFIG_LINKS([include/grub/cpu:include/grub/$host_cpu
include/pupa/machine:include/pupa/$host_cpu/$host_vendor]) include/grub/machine:include/grub/$host_cpu/$host_vendor])
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
AC_OUTPUT AC_OUTPUT

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,69 +13,69 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/machine/biosdisk.h> #include <grub/machine/biosdisk.h>
#include <pupa/machine/memory.h> #include <grub/machine/memory.h>
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/term.h> #include <grub/term.h>
/* Drive Parameters. */ /* Drive Parameters. */
struct pupa_biosdisk_drp struct grub_biosdisk_drp
{ {
pupa_uint16_t size; grub_uint16_t size;
pupa_uint16_t flags; grub_uint16_t flags;
pupa_uint32_t cylinders; grub_uint32_t cylinders;
pupa_uint32_t heads; grub_uint32_t heads;
pupa_uint32_t sectors; grub_uint32_t sectors;
pupa_uint64_t total_sectors; grub_uint64_t total_sectors;
pupa_uint16_t bytes_per_sector; grub_uint16_t bytes_per_sector;
/* ver 2.0 or higher */ /* ver 2.0 or higher */
pupa_uint32_t EDD_configuration_parameters; grub_uint32_t EDD_configuration_parameters;
/* ver 3.0 or higher */ /* ver 3.0 or higher */
pupa_uint16_t signature_dpi; grub_uint16_t signature_dpi;
pupa_uint8_t length_dpi; grub_uint8_t length_dpi;
pupa_uint8_t reserved[3]; grub_uint8_t reserved[3];
pupa_uint8_t name_of_host_bus[4]; grub_uint8_t name_of_host_bus[4];
pupa_uint8_t name_of_interface_type[8]; grub_uint8_t name_of_interface_type[8];
pupa_uint8_t interface_path[8]; grub_uint8_t interface_path[8];
pupa_uint8_t device_path[8]; grub_uint8_t device_path[8];
pupa_uint8_t reserved2; grub_uint8_t reserved2;
pupa_uint8_t checksum; grub_uint8_t checksum;
/* XXX: This is necessary, because the BIOS of Thinkpad X20 /* XXX: This is necessary, because the BIOS of Thinkpad X20
writes a garbage to the tail of drive parameters, writes a garbage to the tail of drive parameters,
regardless of a size specified in a caller. */ regardless of a size specified in a caller. */
pupa_uint8_t dummy[16]; grub_uint8_t dummy[16];
} __attribute__ ((packed)); } __attribute__ ((packed));
/* Disk Address Packet. */ /* Disk Address Packet. */
struct pupa_biosdisk_dap struct grub_biosdisk_dap
{ {
pupa_uint8_t length; grub_uint8_t length;
pupa_uint8_t reserved; grub_uint8_t reserved;
pupa_uint16_t blocks; grub_uint16_t blocks;
pupa_uint32_t buffer; grub_uint32_t buffer;
pupa_uint64_t block; grub_uint64_t block;
} __attribute__ ((packed)); } __attribute__ ((packed));
static int static int
pupa_biosdisk_get_drive (const char *name) grub_biosdisk_get_drive (const char *name)
{ {
unsigned long drive; unsigned long drive;
if ((name[0] != 'f' && name[0] != 'h') || name[1] != 'd') if ((name[0] != 'f' && name[0] != 'h') || name[1] != 'd')
goto fail; goto fail;
drive = pupa_strtoul (name + 2, 0, 10); drive = grub_strtoul (name + 2, 0, 10);
if (pupa_errno != PUPA_ERR_NONE) if (grub_errno != GRUB_ERR_NONE)
goto fail; goto fail;
if (name[0] == 'h') if (name[0] == 'h')
@ -84,62 +84,62 @@ pupa_biosdisk_get_drive (const char *name)
return (int) drive ; return (int) drive ;
fail: fail:
pupa_error (PUPA_ERR_UNKNOWN_DEVICE, "not a biosdisk"); grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a biosdisk");
return -1; return -1;
} }
static int static int
pupa_biosdisk_call_hook (int (*hook) (const char *name), int drive) grub_biosdisk_call_hook (int (*hook) (const char *name), int drive)
{ {
char name[10]; char name[10];
pupa_sprintf (name, (drive & 0x80) ? "hd%d" : "fd%d", drive & (~0x80)); grub_sprintf (name, (drive & 0x80) ? "hd%d" : "fd%d", drive & (~0x80));
return hook (name); return hook (name);
} }
static int static int
pupa_biosdisk_iterate (int (*hook) (const char *name)) grub_biosdisk_iterate (int (*hook) (const char *name))
{ {
int drive; int drive;
int num_floppies; int num_floppies;
/* For floppy disks, we can get the number safely. */ /* For floppy disks, we can get the number safely. */
num_floppies = pupa_biosdisk_get_num_floppies (); num_floppies = grub_biosdisk_get_num_floppies ();
for (drive = 0; drive < num_floppies; drive++) for (drive = 0; drive < num_floppies; drive++)
if (pupa_biosdisk_call_hook (hook, drive)) if (grub_biosdisk_call_hook (hook, drive))
return 1; return 1;
/* For hard disks, attempt to read the MBR. */ /* For hard disks, attempt to read the MBR. */
for (drive = 0x80; drive < 0x90; drive++) for (drive = 0x80; drive < 0x90; drive++)
{ {
if (pupa_biosdisk_rw_standard (0x02, drive, 0, 0, 1, 1, if (grub_biosdisk_rw_standard (0x02, drive, 0, 0, 1, 1,
PUPA_MEMORY_MACHINE_SCRATCH_SEG) != 0) GRUB_MEMORY_MACHINE_SCRATCH_SEG) != 0)
break; break;
if (pupa_biosdisk_call_hook (hook, drive)) if (grub_biosdisk_call_hook (hook, drive))
return 1; return 1;
} }
return 0; return 0;
} }
static pupa_err_t static grub_err_t
pupa_biosdisk_open (const char *name, pupa_disk_t disk) grub_biosdisk_open (const char *name, grub_disk_t disk)
{ {
unsigned long total_sectors = 0; unsigned long total_sectors = 0;
int drive; int drive;
struct pupa_biosdisk_data *data; struct grub_biosdisk_data *data;
drive = pupa_biosdisk_get_drive (name); drive = grub_biosdisk_get_drive (name);
if (drive < 0) if (drive < 0)
return pupa_errno; return grub_errno;
disk->has_partitions = (drive & 0x80); disk->has_partitions = (drive & 0x80);
disk->id = drive; disk->id = drive;
data = (struct pupa_biosdisk_data *) pupa_malloc (sizeof (*data)); data = (struct grub_biosdisk_data *) grub_malloc (sizeof (*data));
if (! data) if (! data)
return pupa_errno; return grub_errno;
data->drive = drive; data->drive = drive;
data->flags = 0; data->flags = 0;
@ -149,18 +149,18 @@ pupa_biosdisk_open (const char *name, pupa_disk_t disk)
/* HDD */ /* HDD */
int version; int version;
version = pupa_biosdisk_check_int13_extensions (drive); version = grub_biosdisk_check_int13_extensions (drive);
if (version) if (version)
{ {
struct pupa_biosdisk_drp *drp struct grub_biosdisk_drp *drp
= (struct pupa_biosdisk_drp *) PUPA_MEMORY_MACHINE_SCRATCH_ADDR; = (struct grub_biosdisk_drp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
/* Clear out the DRP. */ /* Clear out the DRP. */
pupa_memset (drp, 0, sizeof (*drp)); grub_memset (drp, 0, sizeof (*drp));
drp->size = sizeof (*drp); drp->size = sizeof (*drp);
if (!pupa_biosdisk_get_diskinfo_int13_extensions (drive, drp)) if (!grub_biosdisk_get_diskinfo_int13_extensions (drive, drp))
{ {
data->flags = PUPA_BIOSDISK_FLAG_LBA; data->flags = GRUB_BIOSDISK_FLAG_LBA;
/* FIXME: 2TB limit. */ /* FIXME: 2TB limit. */
if (drp->total_sectors) if (drp->total_sectors)
@ -174,13 +174,13 @@ pupa_biosdisk_open (const char *name, pupa_disk_t disk)
} }
} }
if (pupa_biosdisk_get_diskinfo_standard (drive, if (grub_biosdisk_get_diskinfo_standard (drive,
&data->cylinders, &data->cylinders,
&data->heads, &data->heads,
&data->sectors) != 0) &data->sectors) != 0)
{ {
pupa_free (data); grub_free (data);
return pupa_error (PUPA_ERR_BAD_DEVICE, "cannot get C/H/S values"); return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values");
} }
if (! total_sectors) if (! total_sectors)
@ -189,45 +189,45 @@ pupa_biosdisk_open (const char *name, pupa_disk_t disk)
disk->total_sectors = total_sectors; disk->total_sectors = total_sectors;
disk->data = data; disk->data = data;
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
static void static void
pupa_biosdisk_close (pupa_disk_t disk) grub_biosdisk_close (grub_disk_t disk)
{ {
pupa_free (disk->data); grub_free (disk->data);
} }
/* For readability. */ /* For readability. */
#define PUPA_BIOSDISK_READ 0 #define GRUB_BIOSDISK_READ 0
#define PUPA_BIOSDISK_WRITE 1 #define GRUB_BIOSDISK_WRITE 1
static pupa_err_t static grub_err_t
pupa_biosdisk_rw (int cmd, pupa_disk_t disk, grub_biosdisk_rw (int cmd, grub_disk_t disk,
unsigned long sector, unsigned long size, unsigned long sector, unsigned long size,
unsigned segment) unsigned segment)
{ {
struct pupa_biosdisk_data *data = disk->data; struct grub_biosdisk_data *data = disk->data;
if (data->flags & PUPA_BIOSDISK_FLAG_LBA) if (data->flags & GRUB_BIOSDISK_FLAG_LBA)
{ {
struct pupa_biosdisk_dap *dap; struct grub_biosdisk_dap *dap;
dap = (struct pupa_biosdisk_dap *) (PUPA_MEMORY_MACHINE_SCRATCH_ADDR dap = (struct grub_biosdisk_dap *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR
+ (data->sectors + (data->sectors
<< PUPA_DISK_SECTOR_BITS)); << GRUB_DISK_SECTOR_BITS));
dap->length = sizeof (*dap); dap->length = sizeof (*dap);
dap->reserved = 0; dap->reserved = 0;
dap->blocks = size; dap->blocks = size;
dap->buffer = segment << 16; /* The format SEGMENT:ADDRESS. */ dap->buffer = segment << 16; /* The format SEGMENT:ADDRESS. */
dap->block = sector; dap->block = sector;
if (pupa_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap)) if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap))
{ {
/* Fall back to the CHS mode. */ /* Fall back to the CHS mode. */
data->flags &= ~PUPA_BIOSDISK_FLAG_LBA; data->flags &= ~GRUB_BIOSDISK_FLAG_LBA;
disk->total_sectors = data->cylinders * data->heads * data->sectors; disk->total_sectors = data->cylinders * data->heads * data->sectors;
return pupa_biosdisk_rw (cmd, disk, sector, size, segment); return grub_biosdisk_rw (cmd, disk, sector, size, segment);
} }
} }
else else
@ -241,29 +241,29 @@ pupa_biosdisk_rw (int cmd, pupa_disk_t disk,
coff = head / data->heads; coff = head / data->heads;
if (coff >= data->cylinders) if (coff >= data->cylinders)
return pupa_error (PUPA_ERR_OUT_OF_RANGE, "out of disk"); return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
if (pupa_biosdisk_rw_standard (cmd + 0x02, data->drive, if (grub_biosdisk_rw_standard (cmd + 0x02, data->drive,
coff, hoff, soff, size, segment)) coff, hoff, soff, size, segment))
{ {
switch (cmd) switch (cmd)
{ {
case PUPA_BIOSDISK_READ: case GRUB_BIOSDISK_READ:
return pupa_error (PUPA_ERR_READ_ERROR, "biosdisk read error"); return grub_error (GRUB_ERR_READ_ERROR, "biosdisk read error");
case PUPA_BIOSDISK_WRITE: case GRUB_BIOSDISK_WRITE:
return pupa_error (PUPA_ERR_WRITE_ERROR, "biosdisk write error"); return grub_error (GRUB_ERR_WRITE_ERROR, "biosdisk write error");
} }
} }
} }
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
static pupa_err_t static grub_err_t
pupa_biosdisk_read (pupa_disk_t disk, unsigned long sector, grub_biosdisk_read (grub_disk_t disk, unsigned long sector,
unsigned long size, char *buf) unsigned long size, char *buf)
{ {
struct pupa_biosdisk_data *data = disk->data; struct grub_biosdisk_data *data = disk->data;
while (size) while (size)
{ {
@ -273,25 +273,25 @@ pupa_biosdisk_read (pupa_disk_t disk, unsigned long sector,
if (len > size) if (len > size)
len = size; len = size;
if (pupa_biosdisk_rw (PUPA_BIOSDISK_READ, disk, sector, len, if (grub_biosdisk_rw (GRUB_BIOSDISK_READ, disk, sector, len,
PUPA_MEMORY_MACHINE_SCRATCH_SEG)) GRUB_MEMORY_MACHINE_SCRATCH_SEG))
return pupa_errno; return grub_errno;
pupa_memcpy (buf, (void *) PUPA_MEMORY_MACHINE_SCRATCH_ADDR, grub_memcpy (buf, (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR,
len << PUPA_DISK_SECTOR_BITS); len << GRUB_DISK_SECTOR_BITS);
buf += len << PUPA_DISK_SECTOR_BITS; buf += len << GRUB_DISK_SECTOR_BITS;
sector += len; sector += len;
size -= len; size -= len;
} }
return pupa_errno; return grub_errno;
} }
static pupa_err_t static grub_err_t
pupa_biosdisk_write (pupa_disk_t disk, unsigned long sector, grub_biosdisk_write (grub_disk_t disk, unsigned long sector,
unsigned long size, const char *buf) unsigned long size, const char *buf)
{ {
struct pupa_biosdisk_data *data = disk->data; struct grub_biosdisk_data *data = disk->data;
while (size) while (size)
{ {
@ -301,34 +301,34 @@ pupa_biosdisk_write (pupa_disk_t disk, unsigned long sector,
if (len > size) if (len > size)
len = size; len = size;
pupa_memcpy ((void *) PUPA_MEMORY_MACHINE_SCRATCH_ADDR, buf, grub_memcpy ((void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR, buf,
len << PUPA_DISK_SECTOR_BITS); len << GRUB_DISK_SECTOR_BITS);
if (pupa_biosdisk_rw (PUPA_BIOSDISK_WRITE, disk, sector, len, if (grub_biosdisk_rw (GRUB_BIOSDISK_WRITE, disk, sector, len,
PUPA_MEMORY_MACHINE_SCRATCH_SEG)) GRUB_MEMORY_MACHINE_SCRATCH_SEG))
return pupa_errno; return grub_errno;
buf += len << PUPA_DISK_SECTOR_BITS; buf += len << GRUB_DISK_SECTOR_BITS;
sector += len; sector += len;
size -= len; size -= len;
} }
return pupa_errno; return grub_errno;
} }
static struct pupa_disk_dev pupa_biosdisk_dev = static struct grub_disk_dev grub_biosdisk_dev =
{ {
.name = "biosdisk", .name = "biosdisk",
.iterate = pupa_biosdisk_iterate, .iterate = grub_biosdisk_iterate,
.open = pupa_biosdisk_open, .open = grub_biosdisk_open,
.close = pupa_biosdisk_close, .close = grub_biosdisk_close,
.read = pupa_biosdisk_read, .read = grub_biosdisk_read,
.write = pupa_biosdisk_write, .write = grub_biosdisk_write,
.next = 0 .next = 0
}; };
void void
pupa_biosdisk_init (void) grub_biosdisk_init (void)
{ {
pupa_disk_dev_register (&pupa_biosdisk_dev); grub_disk_dev_register (&grub_biosdisk_dev);
} }

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,23 +13,23 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/machine/partition.h> #include <grub/machine/partition.h>
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/misc.h> #include <grub/misc.h>
/* Parse the partition representation in STR and return a partition. */ /* Parse the partition representation in STR and return a partition. */
static pupa_partition_t static grub_partition_t
pupa_partition_parse (const char *str) grub_partition_parse (const char *str)
{ {
pupa_partition_t p; grub_partition_t p;
char *s = (char *) str; char *s = (char *) str;
p = (pupa_partition_t) pupa_malloc (sizeof (*p)); p = (grub_partition_t) grub_malloc (sizeof (*p));
if (! p) if (! p)
return 0; return 0;
@ -37,13 +37,13 @@ pupa_partition_parse (const char *str)
p->bsd_part = p->dos_type = p->bsd_type = p->index = -1; p->bsd_part = p->dos_type = p->bsd_type = p->index = -1;
/* Get the DOS partition number. */ /* Get the DOS partition number. */
p->dos_part = pupa_strtoul (s, &s, 0); p->dos_part = grub_strtoul (s, &s, 0);
if (pupa_errno) if (grub_errno)
{ {
/* Not found. Maybe only a BSD label is specified. */ /* Not found. Maybe only a BSD label is specified. */
p->dos_part = -1; p->dos_part = -1;
pupa_errno = PUPA_ERR_NONE; grub_errno = GRUB_ERR_NONE;
} }
else if (*s == ',') else if (*s == ',')
s++; s++;
@ -66,19 +66,19 @@ pupa_partition_parse (const char *str)
return p; return p;
fail: fail:
pupa_free (p); grub_free (p);
pupa_error (PUPA_ERR_BAD_FILENAME, "invalid partition"); grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
return 0; return 0;
} }
pupa_err_t grub_err_t
pupa_partition_iterate (pupa_disk_t disk, grub_partition_iterate (grub_disk_t disk,
int (*hook) (const pupa_partition_t partition)) int (*hook) (const grub_partition_t partition))
{ {
struct pupa_partition p; struct grub_partition p;
struct pupa_partition_mbr mbr; struct grub_partition_mbr mbr;
struct pupa_partition_disk_label label; struct grub_partition_disk_label label;
struct pupa_disk raw; struct grub_disk raw;
/* Enforce raw disk access. */ /* Enforce raw disk access. */
raw = *disk; raw = *disk;
@ -91,30 +91,30 @@ pupa_partition_iterate (pupa_disk_t disk,
while (1) while (1)
{ {
int i; int i;
struct pupa_partition_entry *e; struct grub_partition_entry *e;
/* Read the MBR. */ /* Read the MBR. */
if (pupa_disk_read (&raw, p.offset, 0, sizeof (mbr), (char *) &mbr)) if (grub_disk_read (&raw, p.offset, 0, sizeof (mbr), (char *) &mbr))
goto finish; goto finish;
/* Check if it is valid. */ /* Check if it is valid. */
if (mbr.signature != pupa_cpu_to_le16 (PUPA_PARTITION_SIGNATURE)) if (mbr.signature != grub_cpu_to_le16 (GRUB_PARTITION_SIGNATURE))
return pupa_error (PUPA_ERR_BAD_PART_TABLE, "no signature"); return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
/* Analyze DOS partitions. */ /* Analyze DOS partitions. */
for (p.index = 0; p.index < 4; p.index++) for (p.index = 0; p.index < 4; p.index++)
{ {
e = mbr.entries + p.index; e = mbr.entries + p.index;
p.start = p.offset + pupa_le_to_cpu32 (e->start); p.start = p.offset + grub_le_to_cpu32 (e->start);
p.len = pupa_le_to_cpu32 (e->length); p.len = grub_le_to_cpu32 (e->length);
p.bsd_part = -1; p.bsd_part = -1;
p.dos_type = e->type; p.dos_type = e->type;
p.bsd_type = -1; p.bsd_type = -1;
/* If this partition is a normal one, call the hook. */ /* If this partition is a normal one, call the hook. */
if (! pupa_partition_is_empty (e->type) if (! grub_partition_is_empty (e->type)
&& ! pupa_partition_is_extended (e->type)) && ! grub_partition_is_extended (e->type))
{ {
p.dos_part++; p.dos_part++;
@ -122,17 +122,17 @@ pupa_partition_iterate (pupa_disk_t disk,
goto finish; goto finish;
/* Check if this is a BSD partition. */ /* Check if this is a BSD partition. */
if (pupa_partition_is_bsd (e->type)) if (grub_partition_is_bsd (e->type))
{ {
/* Check if the BSD label is within the DOS partition. */ /* Check if the BSD label is within the DOS partition. */
if (p.len <= PUPA_PARTITION_BSD_LABEL_SECTOR) if (p.len <= GRUB_PARTITION_BSD_LABEL_SECTOR)
return pupa_error (PUPA_ERR_BAD_PART_TABLE, return grub_error (GRUB_ERR_BAD_PART_TABLE,
"no space for disk label"); "no space for disk label");
/* Read the BSD label. */ /* Read the BSD label. */
if (pupa_disk_read (&raw, if (grub_disk_read (&raw,
(p.start (p.start
+ PUPA_PARTITION_BSD_LABEL_SECTOR), + GRUB_PARTITION_BSD_LABEL_SECTOR),
0, 0,
sizeof (label), sizeof (label),
(char *) &label)) (char *) &label))
@ -140,22 +140,22 @@ pupa_partition_iterate (pupa_disk_t disk,
/* Check if it is valid. */ /* Check if it is valid. */
if (label.magic if (label.magic
!= pupa_cpu_to_le32 (PUPA_PARTITION_BSD_LABEL_MAGIC)) != grub_cpu_to_le32 (GRUB_PARTITION_BSD_LABEL_MAGIC))
return pupa_error (PUPA_ERR_BAD_PART_TABLE, return grub_error (GRUB_ERR_BAD_PART_TABLE,
"invalid disk label magic"); "invalid disk label magic");
for (p.bsd_part = 0; for (p.bsd_part = 0;
p.bsd_part < pupa_cpu_to_le16 (label.num_partitions); p.bsd_part < grub_cpu_to_le16 (label.num_partitions);
p.bsd_part++) p.bsd_part++)
{ {
struct pupa_partition_bsd_entry *be struct grub_partition_bsd_entry *be
= label.entries + p.bsd_part; = label.entries + p.bsd_part;
p.start = pupa_le_to_cpu32 (be->offset); p.start = grub_le_to_cpu32 (be->offset);
p.len = pupa_le_to_cpu32 (be->size); p.len = grub_le_to_cpu32 (be->size);
p.bsd_type = be->fs_type; p.bsd_type = be->fs_type;
if (be->fs_type != PUPA_PARTITION_BSD_TYPE_UNUSED) if (be->fs_type != GRUB_PARTITION_BSD_TYPE_UNUSED)
if (hook (&p)) if (hook (&p))
goto finish; goto finish;
} }
@ -172,9 +172,9 @@ pupa_partition_iterate (pupa_disk_t disk,
{ {
e = mbr.entries + i; e = mbr.entries + i;
if (pupa_partition_is_extended (e->type)) if (grub_partition_is_extended (e->type))
{ {
p.offset = p.ext_offset + pupa_le_to_cpu32 (e->start); p.offset = p.ext_offset + grub_le_to_cpu32 (e->start);
if (! p.ext_offset) if (! p.ext_offset)
p.ext_offset = p.offset; p.ext_offset = p.offset;
@ -188,61 +188,61 @@ pupa_partition_iterate (pupa_disk_t disk,
} }
finish: finish:
return pupa_errno; return grub_errno;
} }
pupa_partition_t grub_partition_t
pupa_partition_probe (pupa_disk_t disk, const char *str) grub_partition_probe (grub_disk_t disk, const char *str)
{ {
pupa_partition_t p; grub_partition_t p;
auto int find_func (const pupa_partition_t partition); auto int find_func (const grub_partition_t partition);
int find_func (const pupa_partition_t partition) int find_func (const grub_partition_t partition)
{ {
if ((p->dos_part == partition->dos_part || p->dos_part == -1) if ((p->dos_part == partition->dos_part || p->dos_part == -1)
&& p->bsd_part == partition->bsd_part) && p->bsd_part == partition->bsd_part)
{ {
pupa_memcpy (p, partition, sizeof (*p)); grub_memcpy (p, partition, sizeof (*p));
return 1; return 1;
} }
return 0; return 0;
} }
p = pupa_partition_parse (str); p = grub_partition_parse (str);
if (! p) if (! p)
return 0; return 0;
if (pupa_partition_iterate (disk, find_func)) if (grub_partition_iterate (disk, find_func))
goto fail; goto fail;
if (p->index < 0) if (p->index < 0)
{ {
pupa_error (PUPA_ERR_BAD_DEVICE, "no such partition"); grub_error (GRUB_ERR_BAD_DEVICE, "no such partition");
goto fail; goto fail;
} }
return p; return p;
fail: fail:
pupa_free (p); grub_free (p);
return 0; return 0;
} }
char * char *
pupa_partition_get_name (const pupa_partition_t p) grub_partition_get_name (const grub_partition_t p)
{ {
char *name; char *name;
name = pupa_malloc (13); name = grub_malloc (13);
if (! name) if (! name)
return 0; return 0;
if (p->bsd_part < 0) if (p->bsd_part < 0)
pupa_sprintf (name, "%d", p->dos_part); grub_sprintf (name, "%d", p->dos_part);
else else
pupa_sprintf (name, "%d,%c", p->dos_part, p->bsd_part + 'a'); grub_sprintf (name, "%d,%c", p->dos_part, p->bsd_part + 'a');
return name; return name;
} }

View file

@ -1,6 +1,6 @@
/* ofdisk.c - Open Firmware disk access. */ /* ofdisk.c - Open Firmware disk access. */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2004 Free Software Foundation, Inc. * Copyright (C) 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,70 +18,70 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/machine/ieee1275.h> #include <grub/machine/ieee1275.h>
static int static int
pupa_ofdisk_iterate (int (*hook) (const char *name)) grub_ofdisk_iterate (int (*hook) (const char *name))
{ {
int dev_iterate (struct pupa_ieee1275_devalias *alias) int dev_iterate (struct grub_ieee1275_devalias *alias)
{ {
if (! pupa_strcmp (alias->type, "block")) if (! grub_strcmp (alias->type, "block"))
hook (alias->name); hook (alias->name);
return 0; return 0;
} }
pupa_devalias_iterate (dev_iterate); grub_devalias_iterate (dev_iterate);
return 0; return 0;
} }
static pupa_err_t static grub_err_t
pupa_ofdisk_open (const char *name, pupa_disk_t disk) grub_ofdisk_open (const char *name, grub_disk_t disk)
{ {
pupa_ieee1275_phandle_t devalias; grub_ieee1275_phandle_t devalias;
pupa_ieee1275_phandle_t dev; grub_ieee1275_phandle_t dev;
pupa_ieee1275_ihandle_t dev_ihandle = 0; grub_ieee1275_ihandle_t dev_ihandle = 0;
char *devpath = 0; char *devpath = 0;
/* XXX: This should be large enough for any possible case. */ /* XXX: This should be large enough for any possible case. */
char prop[64]; char prop[64];
pupa_size_t pathlen; grub_size_t pathlen;
int actual; int actual;
if (pupa_ieee1275_finddevice ("/aliases", &devalias)) if (grub_ieee1275_finddevice ("/aliases", &devalias))
return pupa_error (PUPA_ERR_UNKNOWN_DEVICE, "Can't read the aliases"); return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read the aliases");
pupa_ieee1275_get_property_length (devalias, name, &pathlen); grub_ieee1275_get_property_length (devalias, name, &pathlen);
devpath = pupa_malloc (pathlen); devpath = grub_malloc (pathlen);
if (! devpath) if (! devpath)
return pupa_errno; return grub_errno;
if (pupa_ieee1275_get_property (devalias, name, devpath, pathlen, &actual)) if (grub_ieee1275_get_property (devalias, name, devpath, pathlen, &actual))
return pupa_error (PUPA_ERR_UNKNOWN_DEVICE, "No such device alias"); return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "No such device alias");
/* To access the complete disk add `:0'. */ /* To access the complete disk add `:0'. */
pupa_strcat (devpath, ":0"); grub_strcat (devpath, ":0");
pupa_ieee1275_open (devpath, &dev_ihandle); grub_ieee1275_open (devpath, &dev_ihandle);
if (! dev_ihandle) if (! dev_ihandle)
return pupa_error (PUPA_ERR_UNKNOWN_DEVICE, "Can't open device"); return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
if (pupa_ieee1275_finddevice (devpath, &dev)) if (grub_ieee1275_finddevice (devpath, &dev))
{ {
pupa_error (PUPA_ERR_UNKNOWN_DEVICE, "Can't read device properties"); grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read device properties");
goto fail; goto fail;
} }
if (pupa_ieee1275_get_property (dev, "device_type", prop, sizeof (prop), if (grub_ieee1275_get_property (dev, "device_type", prop, sizeof (prop),
&actual)) &actual))
{ {
pupa_error (PUPA_ERR_BAD_DEVICE, "Can't read the device type"); grub_error (GRUB_ERR_BAD_DEVICE, "Can't read the device type");
goto fail; goto fail;
} }
if (pupa_strcmp (prop, "block")) if (grub_strcmp (prop, "block"))
{ {
pupa_error (PUPA_ERR_BAD_DEVICE, "Not a block device"); grub_error (GRUB_ERR_BAD_DEVICE, "Not a block device");
goto fail; goto fail;
} }
@ -99,20 +99,20 @@ pupa_ofdisk_open (const char *name, pupa_disk_t disk)
disk->data = (void *) dev_ihandle; disk->data = (void *) dev_ihandle;
fail: fail:
if (pupa_errno) if (grub_errno)
pupa_ieee1275_close (dev_ihandle); grub_ieee1275_close (dev_ihandle);
pupa_free (devpath); grub_free (devpath);
return pupa_errno; return grub_errno;
} }
static void static void
pupa_ofdisk_close (pupa_disk_t disk) grub_ofdisk_close (grub_disk_t disk)
{ {
pupa_ieee1275_close ((pupa_ieee1275_ihandle_t) disk->data); grub_ieee1275_close ((grub_ieee1275_ihandle_t) disk->data);
} }
static pupa_err_t static grub_err_t
pupa_ofdisk_read (pupa_disk_t disk, unsigned long sector, grub_ofdisk_read (grub_disk_t disk, unsigned long sector,
unsigned long size, char *buf) unsigned long size, char *buf)
{ {
int status; int status;
@ -121,41 +121,41 @@ pupa_ofdisk_read (pupa_disk_t disk, unsigned long sector,
pos = (unsigned long long) sector * 512UL; pos = (unsigned long long) sector * 512UL;
pupa_ieee1275_seek ((pupa_ieee1275_ihandle_t) disk->data, (int) (pos >> 32), grub_ieee1275_seek ((grub_ieee1275_ihandle_t) disk->data, (int) (pos >> 32),
(int) pos & 0xFFFFFFFFUL, &status); (int) pos & 0xFFFFFFFFUL, &status);
if (status != 0) if (status != 0)
return pupa_error (PUPA_ERR_READ_ERROR, return grub_error (GRUB_ERR_READ_ERROR,
"Seek error, can't seek block %d", sector); "Seek error, can't seek block %d", sector);
pupa_ieee1275_read ((pupa_ieee1275_ihandle_t) disk->data, buf, grub_ieee1275_read ((grub_ieee1275_ihandle_t) disk->data, buf,
size * 512UL, &actual); size * 512UL, &actual);
if (actual != actual) if (actual != actual)
return pupa_error (PUPA_ERR_READ_ERROR, "Read error on block: %d", sector); return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %d", sector);
return 0; return 0;
} }
static pupa_err_t static grub_err_t
pupa_ofdisk_write (pupa_disk_t disk __attribute ((unused)), grub_ofdisk_write (grub_disk_t disk __attribute ((unused)),
unsigned long sector __attribute ((unused)), unsigned long sector __attribute ((unused)),
unsigned long size __attribute ((unused)), unsigned long size __attribute ((unused)),
const char *buf __attribute ((unused))) const char *buf __attribute ((unused)))
{ {
return PUPA_ERR_NOT_IMPLEMENTED_YET; return GRUB_ERR_NOT_IMPLEMENTED_YET;
} }
static struct pupa_disk_dev pupa_ofdisk_dev = static struct grub_disk_dev grub_ofdisk_dev =
{ {
.name = "ofdisk", .name = "ofdisk",
.iterate = pupa_ofdisk_iterate, .iterate = grub_ofdisk_iterate,
.open = pupa_ofdisk_open, .open = grub_ofdisk_open,
.close = pupa_ofdisk_close, .close = grub_ofdisk_close,
.read = pupa_ofdisk_read, .read = grub_ofdisk_read,
.write = pupa_ofdisk_write, .write = grub_ofdisk_write,
.next = 0 .next = 0
}; };
void void
pupa_ofdisk_init (void) grub_ofdisk_init (void)
{ {
pupa_disk_dev_register (&pupa_ofdisk_dev); grub_disk_dev_register (&grub_ofdisk_dev);
} }

View file

@ -1,6 +1,6 @@
/* partiton.c - Read macintosh partition tables. */ /* partiton.c - Read macintosh partition tables. */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2004 Free Software Foundation, Inc. * Copyright (C) 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,20 +18,20 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/machine/partition.h> #include <grub/machine/partition.h>
pupa_err_t grub_err_t
pupa_partition_iterate (pupa_disk_t disk, grub_partition_iterate (grub_disk_t disk,
int (*hook) (const pupa_partition_t partition)) int (*hook) (const grub_partition_t partition))
{ {
struct pupa_partition part; struct grub_partition part;
struct pupa_apple_part apart; struct grub_apple_part apart;
struct pupa_disk raw; struct grub_disk raw;
int partno = 0; int partno = 0;
int pos = PUPA_DISK_SECTOR_SIZE * 2; int pos = GRUB_DISK_SECTOR_SIZE * 2;
/* Enforce raw disk access. */ /* Enforce raw disk access. */
raw = *disk; raw = *disk;
@ -39,12 +39,12 @@ pupa_partition_iterate (pupa_disk_t disk,
for (;;) for (;;)
{ {
if (pupa_disk_read (&raw, pos / PUPA_DISK_SECTOR_SIZE, if (grub_disk_read (&raw, pos / GRUB_DISK_SECTOR_SIZE,
pos % PUPA_DISK_SECTOR_SIZE, pos % GRUB_DISK_SECTOR_SIZE,
sizeof (struct pupa_apple_part), (char *) &apart)) sizeof (struct grub_apple_part), (char *) &apart))
return pupa_errno; return grub_errno;
if (apart.magic != PUPA_APPLE_PART_MAGIC) if (apart.magic != GRUB_APPLE_PART_MAGIC)
break; break;
part.start = apart.first_phys_block; part.start = apart.first_phys_block;
@ -53,34 +53,34 @@ pupa_partition_iterate (pupa_disk_t disk,
part.index = partno; part.index = partno;
if (hook (&part)) if (hook (&part))
return pupa_errno; return grub_errno;
if (apart.first_phys_block == PUPA_DISK_SECTOR_SIZE * 2) if (apart.first_phys_block == GRUB_DISK_SECTOR_SIZE * 2)
return 0; return 0;
pos += sizeof (struct pupa_apple_part); pos += sizeof (struct grub_apple_part);
partno++; partno++;
} }
return 0; return 0;
} }
pupa_partition_t grub_partition_t
pupa_partition_probe (pupa_disk_t disk, const char *str) grub_partition_probe (grub_disk_t disk, const char *str)
{ {
pupa_partition_t p; grub_partition_t p;
int partnum = 0; int partnum = 0;
char *s = (char *) str; char *s = (char *) str;
int find_func (const pupa_partition_t partition) int find_func (const grub_partition_t partition)
{ {
if (partnum == partition->index) if (partnum == partition->index)
{ {
p = (pupa_partition_t) pupa_malloc (sizeof (*p)); p = (grub_partition_t) grub_malloc (sizeof (*p));
if (! p) if (! p)
return 1; return 1;
pupa_memcpy (p, partition, sizeof (*p)); grub_memcpy (p, partition, sizeof (*p));
return 1; return 1;
} }
@ -88,33 +88,33 @@ pupa_partition_probe (pupa_disk_t disk, const char *str)
} }
/* Get the partition number. */ /* Get the partition number. */
partnum = pupa_strtoul (s, &s, 0); partnum = grub_strtoul (s, &s, 0);
if (pupa_errno) if (grub_errno)
{ {
pupa_error (PUPA_ERR_BAD_FILENAME, "invalid partition"); grub_error (GRUB_ERR_BAD_FILENAME, "invalid partition");
return 0; return 0;
} }
if (pupa_partition_iterate (disk, find_func)) if (grub_partition_iterate (disk, find_func))
goto fail; goto fail;
return p; return p;
fail: fail:
pupa_free (p); grub_free (p);
return 0; return 0;
} }
char * char *
pupa_partition_get_name (const pupa_partition_t p) grub_partition_get_name (const grub_partition_t p)
{ {
char *name; char *name;
name = pupa_malloc (13); name = grub_malloc (13);
if (! name) if (! name)
return 0; return 0;
pupa_sprintf (name, "%d", p->index); grub_sprintf (name, "%d", p->index);
return name; return name;
} }

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,25 +17,25 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/file.h> #include <grub/file.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/normal.h> #include <grub/normal.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/font.h> #include <grub/font.h>
struct entry struct entry
{ {
pupa_uint32_t code; grub_uint32_t code;
pupa_uint32_t offset; grub_uint32_t offset;
}; };
struct font struct font
{ {
struct font *next; struct font *next;
pupa_file_t file; grub_file_t file;
pupa_uint32_t num; grub_uint32_t num;
struct entry table[0]; struct entry table[0];
}; };
@ -44,29 +44,29 @@ static struct font *font_list;
static int static int
add_font (const char *filename) add_font (const char *filename)
{ {
pupa_file_t file = 0; grub_file_t file = 0;
char magic[4]; char magic[4];
pupa_uint32_t num, i; grub_uint32_t num, i;
struct font *font = 0; struct font *font = 0;
file = pupa_file_open (filename); file = grub_file_open (filename);
if (! file) if (! file)
goto fail; goto fail;
if (pupa_file_read (file, magic, 4) != 4) if (grub_file_read (file, magic, 4) != 4)
goto fail; goto fail;
if (pupa_memcmp (magic, PUPA_FONT_MAGIC, 4) != 0) if (grub_memcmp (magic, GRUB_FONT_MAGIC, 4) != 0)
{ {
pupa_error (PUPA_ERR_BAD_FONT, "invalid font magic"); grub_error (GRUB_ERR_BAD_FONT, "invalid font magic");
goto fail; goto fail;
} }
if (pupa_file_read (file, (char *) &num, 4) != 4) if (grub_file_read (file, (char *) &num, 4) != 4)
goto fail; goto fail;
num = pupa_le_to_cpu32 (num); num = grub_le_to_cpu32 (num);
font = (struct font *) pupa_malloc (sizeof (struct font) font = (struct font *) grub_malloc (sizeof (struct font)
+ sizeof (struct entry) * num); + sizeof (struct entry) * num);
if (! font) if (! font)
goto fail; goto fail;
@ -76,16 +76,16 @@ add_font (const char *filename)
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
{ {
pupa_uint32_t code, offset; grub_uint32_t code, offset;
if (pupa_file_read (file, (char *) &code, 4) != 4) if (grub_file_read (file, (char *) &code, 4) != 4)
goto fail; goto fail;
if (pupa_file_read (file, (char *) &offset, 4) != 4) if (grub_file_read (file, (char *) &offset, 4) != 4)
goto fail; goto fail;
font->table[i].code = pupa_le_to_cpu32 (code); font->table[i].code = grub_le_to_cpu32 (code);
font->table[i].offset = pupa_le_to_cpu32 (offset); font->table[i].offset = grub_le_to_cpu32 (offset);
} }
font->next = font_list; font->next = font_list;
@ -95,10 +95,10 @@ add_font (const char *filename)
fail: fail:
if (font) if (font)
pupa_free (font); grub_free (font);
if (file) if (file)
pupa_file_close (file); grub_file_close (file);
return 0; return 0;
} }
@ -113,8 +113,8 @@ remove_font (struct font *font)
{ {
*p = q->next; *p = q->next;
pupa_file_close (font->file); grub_file_close (font->file);
pupa_free (font); grub_free (font);
break; break;
} }
@ -122,11 +122,11 @@ remove_font (struct font *font)
/* Return the offset of the glyph corresponding to the codepoint CODE /* Return the offset of the glyph corresponding to the codepoint CODE
in the font FONT. If no found, return zero. */ in the font FONT. If no found, return zero. */
static pupa_uint32_t static grub_uint32_t
find_glyph (const struct font *font, pupa_uint32_t code) find_glyph (const struct font *font, grub_uint32_t code)
{ {
pupa_uint32_t start = 0; grub_uint32_t start = 0;
pupa_uint32_t end = font->num - 1; grub_uint32_t end = font->num - 1;
struct entry *table = font->table; struct entry *table = font->table;
/* This shouldn't happen. */ /* This shouldn't happen. */
@ -136,7 +136,7 @@ find_glyph (const struct font *font, pupa_uint32_t code)
/* Do a binary search. */ /* Do a binary search. */
while (start <= end) while (start <= end)
{ {
pupa_uint32_t i = (start + end) / 2; grub_uint32_t i = (start + end) / 2;
if (table[i].code < code) if (table[i].code < code)
start = i + 1; start = i + 1;
@ -167,7 +167,7 @@ fill_with_default_glyph (unsigned char bitmap[32], unsigned *width)
/* Get a glyph corresponding to the codepoint CODE. Always fill BITMAP /* Get a glyph corresponding to the codepoint CODE. Always fill BITMAP
and WIDTH with something, even if no glyph is found. */ and WIDTH with something, even if no glyph is found. */
int int
pupa_font_get_glyph (pupa_uint32_t code, grub_font_get_glyph (grub_uint32_t code,
unsigned char bitmap[32], unsigned *width) unsigned char bitmap[32], unsigned *width)
{ {
struct font *font; struct font *font;
@ -177,31 +177,31 @@ pupa_font_get_glyph (pupa_uint32_t code,
restart: restart:
for (font = font_list; font; font = font->next) for (font = font_list; font; font = font->next)
{ {
pupa_uint32_t offset; grub_uint32_t offset;
offset = find_glyph (font, code); offset = find_glyph (font, code);
if (offset) if (offset)
{ {
pupa_uint32_t w; grub_uint32_t w;
pupa_file_seek (font->file, offset); grub_file_seek (font->file, offset);
if (pupa_file_read (font->file, (char *) &w, 4) != 4) if (grub_file_read (font->file, (char *) &w, 4) != 4)
{ {
remove_font (font); remove_font (font);
goto restart; goto restart;
} }
w = pupa_le_to_cpu32 (w); w = grub_le_to_cpu32 (w);
if (w != 1 && w != 2) if (w != 1 && w != 2)
{ {
/* pupa_error (PUPA_ERR_BAD_FONT, "invalid width"); */ /* grub_error (GRUB_ERR_BAD_FONT, "invalid width"); */
remove_font (font); remove_font (font);
goto restart; goto restart;
} }
if (bitmap if (bitmap
&& (pupa_file_read (font->file, bitmap, w * 16) && (grub_file_read (font->file, bitmap, w * 16)
!= (pupa_ssize_t) w * 16)) != (grub_ssize_t) w * 16))
{ {
remove_font (font); remove_font (font);
goto restart; goto restart;
@ -217,13 +217,13 @@ pupa_font_get_glyph (pupa_uint32_t code,
return 0; return 0;
} }
static pupa_err_t static grub_err_t
font_command (struct pupa_arg_list *state __attribute__ ((unused)), font_command (struct grub_arg_list *state __attribute__ ((unused)),
int argc __attribute__ ((unused)), int argc __attribute__ ((unused)),
char **args __attribute__ ((unused))) char **args __attribute__ ((unused)))
{ {
if (argc == 0) if (argc == 0)
return pupa_error (PUPA_ERR_BAD_ARGUMENT, "no font specified"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "no font specified");
while (argc--) while (argc--)
if (! add_font (*args++)) if (! add_font (*args++))
@ -232,14 +232,14 @@ font_command (struct pupa_arg_list *state __attribute__ ((unused)),
return 0; return 0;
} }
PUPA_MOD_INIT GRUB_MOD_INIT
{ {
(void) mod; /* Stop warning. */ (void) mod; /* Stop warning. */
pupa_register_command ("font", font_command, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("font", font_command, GRUB_COMMAND_FLAG_BOTH,
"font FILE...", "Specify a font file to display.", 0); "font FILE...", "Specify a font file to display.", 0);
} }
PUPA_MOD_FINI GRUB_MOD_FINI
{ {
pupa_unregister_command ("font"); grub_unregister_command ("font");
} }

518
fs/ext2.c
View file

@ -1,6 +1,6 @@
/* ext2.c - Second Extended filesystem */ /* ext2.c - Second Extended filesystem */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 2004 Free Software Foundation, Inc. * Copyright (C) 2003, 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -31,139 +31,139 @@
#define FILETYPE_DIRECTORY 2 #define FILETYPE_DIRECTORY 2
#define FILETYPE_SYMLINK 7 #define FILETYPE_SYMLINK 7
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/file.h> #include <grub/file.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/types.h> #include <grub/types.h>
/* Log2 size of ext2 block in 512 blocks. */ /* Log2 size of ext2 block in 512 blocks. */
#define LOG2_EXT2_BLOCK_SIZE(data) \ #define LOG2_EXT2_BLOCK_SIZE(data) \
(pupa_le_to_cpu32 (data->sblock.log2_block_size) + 1) (grub_le_to_cpu32 (data->sblock.log2_block_size) + 1)
/* Log2 size of ext2 block in bytes. */ /* Log2 size of ext2 block in bytes. */
#define LOG2_BLOCK_SIZE(data) \ #define LOG2_BLOCK_SIZE(data) \
(pupa_le_to_cpu32 (data->sblock.log2_block_size) + 10) (grub_le_to_cpu32 (data->sblock.log2_block_size) + 10)
/* The size of an ext2 block in bytes. */ /* The size of an ext2 block in bytes. */
#define EXT2_BLOCK_SIZE(data) (1 << LOG2_BLOCK_SIZE(data)) #define EXT2_BLOCK_SIZE(data) (1 << LOG2_BLOCK_SIZE(data))
/* The ext2 superblock. */ /* The ext2 superblock. */
struct pupa_ext_sblock struct grub_ext_sblock
{ {
pupa_uint32_t total_inodes; grub_uint32_t total_inodes;
pupa_uint32_t total_blocks; grub_uint32_t total_blocks;
pupa_uint32_t reserved_blocks; grub_uint32_t reserved_blocks;
pupa_uint32_t free_blocks; grub_uint32_t free_blocks;
pupa_uint32_t free_inodes; grub_uint32_t free_inodes;
pupa_uint32_t first_data_block; grub_uint32_t first_data_block;
pupa_uint32_t log2_block_size; grub_uint32_t log2_block_size;
pupa_uint32_t log2_fragment_size; grub_uint32_t log2_fragment_size;
pupa_uint32_t blocks_per_group; grub_uint32_t blocks_per_group;
pupa_uint32_t fragments_per_group; grub_uint32_t fragments_per_group;
pupa_uint32_t inodes_per_group; grub_uint32_t inodes_per_group;
pupa_uint32_t mtime; grub_uint32_t mtime;
pupa_uint32_t utime; grub_uint32_t utime;
pupa_uint16_t mnt_count; grub_uint16_t mnt_count;
pupa_uint16_t max_mnt_count; grub_uint16_t max_mnt_count;
pupa_uint16_t magic; grub_uint16_t magic;
pupa_uint16_t fs_state; grub_uint16_t fs_state;
pupa_uint16_t error_handling; grub_uint16_t error_handling;
pupa_uint16_t minor_revision_level; grub_uint16_t minor_revision_level;
pupa_uint32_t lastcheck; grub_uint32_t lastcheck;
pupa_uint32_t checkinterval; grub_uint32_t checkinterval;
pupa_uint32_t creator_os; grub_uint32_t creator_os;
pupa_uint32_t revision_level; grub_uint32_t revision_level;
pupa_uint16_t uid_reserved; grub_uint16_t uid_reserved;
pupa_uint16_t gid_reserved; grub_uint16_t gid_reserved;
pupa_uint32_t first_inode; grub_uint32_t first_inode;
pupa_uint16_t inode_size; grub_uint16_t inode_size;
pupa_uint16_t block_group_number; grub_uint16_t block_group_number;
pupa_uint32_t feature_compatibility; grub_uint32_t feature_compatibility;
pupa_uint32_t feature_incompat; grub_uint32_t feature_incompat;
pupa_uint32_t feature_ro_compat; grub_uint32_t feature_ro_compat;
pupa_uint32_t unique_id[4]; grub_uint32_t unique_id[4];
char volume_name[16]; char volume_name[16];
char last_mounted_on[64]; char last_mounted_on[64];
pupa_uint32_t compression_info; grub_uint32_t compression_info;
}; };
/* The ext2 blockgroup. */ /* The ext2 blockgroup. */
struct ext2_block_group struct ext2_block_group
{ {
pupa_uint32_t block_id; grub_uint32_t block_id;
pupa_uint32_t inode_id; grub_uint32_t inode_id;
pupa_uint32_t inode_table_id; grub_uint32_t inode_table_id;
pupa_uint16_t free_blocks; grub_uint16_t free_blocks;
pupa_uint16_t free_inodes; grub_uint16_t free_inodes;
pupa_uint16_t pad; grub_uint16_t pad;
pupa_uint32_t reserved[3]; grub_uint32_t reserved[3];
}; };
/* The ext2 inode. */ /* The ext2 inode. */
struct pupa_ext2_inode struct grub_ext2_inode
{ {
pupa_uint16_t mode; grub_uint16_t mode;
pupa_uint16_t uid; grub_uint16_t uid;
pupa_uint32_t size; grub_uint32_t size;
pupa_uint32_t atime; grub_uint32_t atime;
pupa_uint32_t ctime; grub_uint32_t ctime;
pupa_uint32_t mtime; grub_uint32_t mtime;
pupa_uint32_t dtime; grub_uint32_t dtime;
pupa_uint16_t gid; grub_uint16_t gid;
pupa_uint16_t nlinks; grub_uint16_t nlinks;
pupa_uint32_t blockcnt; /* Blocks of 512 bytes!! */ grub_uint32_t blockcnt; /* Blocks of 512 bytes!! */
pupa_uint32_t flags; grub_uint32_t flags;
pupa_uint32_t osd1; grub_uint32_t osd1;
union union
{ {
struct datablocks struct datablocks
{ {
pupa_uint32_t dir_blocks[INDIRECT_BLOCKS]; grub_uint32_t dir_blocks[INDIRECT_BLOCKS];
pupa_uint32_t indir_block; grub_uint32_t indir_block;
pupa_uint32_t double_indir_block; grub_uint32_t double_indir_block;
pupa_uint32_t tripple_indir_block; grub_uint32_t tripple_indir_block;
} blocks; } blocks;
char symlink[60]; char symlink[60];
}; };
pupa_uint32_t version; grub_uint32_t version;
pupa_uint32_t acl; grub_uint32_t acl;
pupa_uint32_t dir_acl; grub_uint32_t dir_acl;
pupa_uint32_t fragment_addr; grub_uint32_t fragment_addr;
pupa_uint32_t osd2[3]; grub_uint32_t osd2[3];
}; };
/* The header of an ext2 directory entry. */ /* The header of an ext2 directory entry. */
struct ext2_dirent struct ext2_dirent
{ {
pupa_uint32_t inode; grub_uint32_t inode;
pupa_uint16_t direntlen; grub_uint16_t direntlen;
pupa_uint8_t namelen; grub_uint8_t namelen;
pupa_uint8_t filetype; grub_uint8_t filetype;
}; };
/* Information about a "mounted" ext2 filesystem. */ /* Information about a "mounted" ext2 filesystem. */
struct pupa_ext2_data struct grub_ext2_data
{ {
struct pupa_ext_sblock sblock; struct grub_ext_sblock sblock;
pupa_disk_t disk; grub_disk_t disk;
struct pupa_ext2_inode inode; struct grub_ext2_inode inode;
}; };
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
static pupa_dl_t my_mod; static grub_dl_t my_mod;
#endif #endif
/* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of /* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of
the mounted filesystem DATA. */ the mounted filesystem DATA. */
inline static pupa_err_t inline static grub_err_t
pupa_ext2_blockgroup (struct pupa_ext2_data *data, int group, grub_ext2_blockgroup (struct grub_ext2_data *data, int group,
struct ext2_block_group *blkgrp) struct ext2_block_group *blkgrp)
{ {
return pupa_disk_read (data->disk, return grub_disk_read (data->disk,
((pupa_le_to_cpu32 (data->sblock.first_data_block) + 1) ((grub_le_to_cpu32 (data->sblock.first_data_block) + 1)
<< LOG2_EXT2_BLOCK_SIZE (data)), << LOG2_EXT2_BLOCK_SIZE (data)),
group * sizeof (struct ext2_block_group), group * sizeof (struct ext2_block_group),
sizeof (struct ext2_block_group), (char *) blkgrp); sizeof (struct ext2_block_group), (char *) blkgrp);
@ -172,28 +172,28 @@ pupa_ext2_blockgroup (struct pupa_ext2_data *data, int group,
/* Return in BLOCK the on disk block number of block FILEBLOCK in the /* Return in BLOCK the on disk block number of block FILEBLOCK in the
opened file descibed by DATA. If this block is not stored on disk opened file descibed by DATA. If this block is not stored on disk
in case of a sparse file return 0. */ in case of a sparse file return 0. */
static pupa_err_t static grub_err_t
pupa_ext2_get_file_block (struct pupa_ext2_data *data, grub_ext2_get_file_block (struct grub_ext2_data *data,
int fileblock, int *block) int fileblock, int *block)
{ {
int blknr; int blknr;
struct pupa_ext2_inode *inode = &data->inode; struct grub_ext2_inode *inode = &data->inode;
/* Direct blocks. */ /* Direct blocks. */
if (fileblock < INDIRECT_BLOCKS) if (fileblock < INDIRECT_BLOCKS)
blknr = pupa_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]); blknr = grub_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]);
/* Indirect. */ /* Indirect. */
else if (fileblock < INDIRECT_BLOCKS + EXT2_BLOCK_SIZE (data) / 4) else if (fileblock < INDIRECT_BLOCKS + EXT2_BLOCK_SIZE (data) / 4)
{ {
pupa_uint32_t indir[EXT2_BLOCK_SIZE (data) / 4]; grub_uint32_t indir[EXT2_BLOCK_SIZE (data) / 4];
if (pupa_disk_read (data->disk, if (grub_disk_read (data->disk,
pupa_le_to_cpu32 (inode->blocks.indir_block) grub_le_to_cpu32 (inode->blocks.indir_block)
<< LOG2_EXT2_BLOCK_SIZE (data), << LOG2_EXT2_BLOCK_SIZE (data),
0, EXT2_BLOCK_SIZE (data), (char *) indir)) 0, EXT2_BLOCK_SIZE (data), (char *) indir))
return pupa_errno; return grub_errno;
blknr = pupa_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]); blknr = grub_le_to_cpu32 (indir[fileblock - INDIRECT_BLOCKS]);
} }
/* Double indirect. */ /* Double indirect. */
else if (fileblock < INDIRECT_BLOCKS + EXT2_BLOCK_SIZE (data) / 4 else if (fileblock < INDIRECT_BLOCKS + EXT2_BLOCK_SIZE (data) / 4
@ -202,29 +202,29 @@ pupa_ext2_get_file_block (struct pupa_ext2_data *data,
unsigned int perblock = EXT2_BLOCK_SIZE (data) / 4; unsigned int perblock = EXT2_BLOCK_SIZE (data) / 4;
unsigned int rblock = fileblock - (INDIRECT_BLOCKS unsigned int rblock = fileblock - (INDIRECT_BLOCKS
+ EXT2_BLOCK_SIZE (data) / 4); + EXT2_BLOCK_SIZE (data) / 4);
pupa_uint32_t indir[EXT2_BLOCK_SIZE (data) / 4]; grub_uint32_t indir[EXT2_BLOCK_SIZE (data) / 4];
if (pupa_disk_read (data->disk, if (grub_disk_read (data->disk,
pupa_le_to_cpu32 (inode->blocks.double_indir_block) grub_le_to_cpu32 (inode->blocks.double_indir_block)
<< LOG2_EXT2_BLOCK_SIZE (data), << LOG2_EXT2_BLOCK_SIZE (data),
0, EXT2_BLOCK_SIZE (data), (char *) indir)) 0, EXT2_BLOCK_SIZE (data), (char *) indir))
return pupa_errno; return grub_errno;
if (pupa_disk_read (data->disk, if (grub_disk_read (data->disk,
pupa_le_to_cpu32 (indir[rblock / perblock]) grub_le_to_cpu32 (indir[rblock / perblock])
<< LOG2_EXT2_BLOCK_SIZE (data), << LOG2_EXT2_BLOCK_SIZE (data),
0, EXT2_BLOCK_SIZE (data), (char *) indir)) 0, EXT2_BLOCK_SIZE (data), (char *) indir))
return pupa_errno; return grub_errno;
blknr = pupa_le_to_cpu32 (indir[rblock % perblock]); blknr = grub_le_to_cpu32 (indir[rblock % perblock]);
} }
/* Tripple indirect. */ /* Tripple indirect. */
else else
{ {
pupa_error (PUPA_ERR_NOT_IMPLEMENTED_YET, grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"ext2fs doesn't support tripple indirect blocks"); "ext2fs doesn't support tripple indirect blocks");
return pupa_errno; return grub_errno;
} }
*block = blknr; *block = blknr;
@ -234,8 +234,8 @@ pupa_ext2_get_file_block (struct pupa_ext2_data *data,
/* Read LEN bytes from the file described by DATA starting with byte /* Read LEN bytes from the file described by DATA starting with byte
POS. Return the amount of read bytes in READ. */ POS. Return the amount of read bytes in READ. */
static pupa_ssize_t static grub_ssize_t
pupa_ext2_read_file (struct pupa_ext2_data *data, grub_ext2_read_file (struct grub_ext2_data *data,
void (*read_hook) (unsigned long sector, void (*read_hook) (unsigned long sector,
unsigned offset, unsigned length), unsigned offset, unsigned length),
int pos, unsigned int len, char *buf) int pos, unsigned int len, char *buf)
@ -244,8 +244,8 @@ pupa_ext2_read_file (struct pupa_ext2_data *data,
int blockcnt; int blockcnt;
/* Adjust len so it we can't read past the end of the file. */ /* Adjust len so it we can't read past the end of the file. */
if (len > pupa_le_to_cpu32 (data->inode.size)) if (len > grub_le_to_cpu32 (data->inode.size))
len = pupa_le_to_cpu32 (data->inode.size); len = grub_le_to_cpu32 (data->inode.size);
blockcnt = ((len + pos) blockcnt = ((len + pos)
+ EXT2_BLOCK_SIZE (data) - 1) / EXT2_BLOCK_SIZE (data); + EXT2_BLOCK_SIZE (data) - 1) / EXT2_BLOCK_SIZE (data);
@ -258,8 +258,8 @@ pupa_ext2_read_file (struct pupa_ext2_data *data,
int skipfirst = 0; int skipfirst = 0;
pupa_ext2_get_file_block (data, i, &blknr); grub_ext2_get_file_block (data, i, &blknr);
if (pupa_errno) if (grub_errno)
return -1; return -1;
blknr = blknr << LOG2_EXT2_BLOCK_SIZE (data); blknr = blknr << LOG2_EXT2_BLOCK_SIZE (data);
@ -286,14 +286,14 @@ pupa_ext2_read_file (struct pupa_ext2_data *data,
if (blknr) if (blknr)
{ {
data->disk->read_hook = read_hook; data->disk->read_hook = read_hook;
pupa_disk_read (data->disk, blknr, skipfirst, grub_disk_read (data->disk, blknr, skipfirst,
blockend, buf); blockend, buf);
data->disk->read_hook = 0; data->disk->read_hook = 0;
if (pupa_errno) if (grub_errno)
return -1; return -1;
} }
else else
pupa_memset (buf, EXT2_BLOCK_SIZE (data) - skipfirst, 0); grub_memset (buf, EXT2_BLOCK_SIZE (data) - skipfirst, 0);
buf += EXT2_BLOCK_SIZE (data) - skipfirst; buf += EXT2_BLOCK_SIZE (data) - skipfirst;
} }
@ -303,12 +303,12 @@ pupa_ext2_read_file (struct pupa_ext2_data *data,
/* Read the inode INO for the file described by DATA into INODE. */ /* Read the inode INO for the file described by DATA into INODE. */
static pupa_err_t static grub_err_t
pupa_ext2_read_inode (struct pupa_ext2_data *data, grub_ext2_read_inode (struct grub_ext2_data *data,
int ino, struct pupa_ext2_inode *inode) int ino, struct grub_ext2_inode *inode)
{ {
struct ext2_block_group blkgrp; struct ext2_block_group blkgrp;
struct pupa_ext_sblock *sblock = &data->sblock; struct grub_ext_sblock *sblock = &data->sblock;
int inodes_per_block; int inodes_per_block;
unsigned int blkno; unsigned int blkno;
@ -317,76 +317,76 @@ pupa_ext2_read_inode (struct pupa_ext2_data *data,
/* It is easier to calculate if the first inode is 0. */ /* It is easier to calculate if the first inode is 0. */
ino--; ino--;
pupa_ext2_blockgroup (data, ino / pupa_le_to_cpu32 (sblock->inodes_per_group), grub_ext2_blockgroup (data, ino / grub_le_to_cpu32 (sblock->inodes_per_group),
&blkgrp); &blkgrp);
if (pupa_errno) if (grub_errno)
return pupa_errno; return grub_errno;
inodes_per_block = EXT2_BLOCK_SIZE (data) / 128; inodes_per_block = EXT2_BLOCK_SIZE (data) / 128;
blkno = (ino % pupa_le_to_cpu32 (sblock->inodes_per_group)) blkno = (ino % grub_le_to_cpu32 (sblock->inodes_per_group))
/ inodes_per_block; / inodes_per_block;
blkoff = (ino % pupa_le_to_cpu32 (sblock->inodes_per_group)) blkoff = (ino % grub_le_to_cpu32 (sblock->inodes_per_group))
% inodes_per_block; % inodes_per_block;
/* Read the inode. */ /* Read the inode. */
if (pupa_disk_read (data->disk, if (grub_disk_read (data->disk,
((pupa_le_to_cpu32 (blkgrp.inode_table_id) + blkno) ((grub_le_to_cpu32 (blkgrp.inode_table_id) + blkno)
<< LOG2_EXT2_BLOCK_SIZE (data)), << LOG2_EXT2_BLOCK_SIZE (data)),
sizeof (struct pupa_ext2_inode) * blkoff, sizeof (struct grub_ext2_inode) * blkoff,
sizeof (struct pupa_ext2_inode), (char *) inode)) sizeof (struct grub_ext2_inode), (char *) inode))
return pupa_errno; return grub_errno;
return 0; return 0;
} }
static struct pupa_ext2_data * static struct grub_ext2_data *
pupa_ext2_mount (pupa_disk_t disk) grub_ext2_mount (grub_disk_t disk)
{ {
struct pupa_ext2_data *data; struct grub_ext2_data *data;
data = pupa_malloc (sizeof (struct pupa_ext2_data)); data = grub_malloc (sizeof (struct grub_ext2_data));
if (!data) if (!data)
return 0; return 0;
/* Read the superblock. */ /* Read the superblock. */
pupa_disk_read (disk, 1 * 2, 0, sizeof (struct pupa_ext_sblock), grub_disk_read (disk, 1 * 2, 0, sizeof (struct grub_ext_sblock),
(char *) &data->sblock); (char *) &data->sblock);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
/* Make sure this is an ext2 filesystem. */ /* Make sure this is an ext2 filesystem. */
if (pupa_le_to_cpu16 (data->sblock.magic) != EXT2_MAGIC) if (grub_le_to_cpu16 (data->sblock.magic) != EXT2_MAGIC)
goto fail; goto fail;
data->disk = disk; data->disk = disk;
return data; return data;
fail: fail:
pupa_error (PUPA_ERR_BAD_FS, "not an ext2 filesystem"); grub_error (GRUB_ERR_BAD_FS, "not an ext2 filesystem");
pupa_free (data); grub_free (data);
return 0; return 0;
} }
/* Find the file with the pathname PATH on the filesystem described by /* Find the file with the pathname PATH on the filesystem described by
DATA. Return its inode number in INO. */ DATA. Return its inode number in INO. */
static pupa_err_t static grub_err_t
pupa_ext2_find_file (struct pupa_ext2_data *data, const char *path, int *ino) grub_ext2_find_file (struct grub_ext2_data *data, const char *path, int *ino)
{ {
int blocksize = EXT2_BLOCK_SIZE (data) int blocksize = EXT2_BLOCK_SIZE (data)
<< pupa_le_to_cpu32 (data->sblock.log2_block_size); << grub_le_to_cpu32 (data->sblock.log2_block_size);
struct pupa_ext2_inode *inode = &data->inode; struct grub_ext2_inode *inode = &data->inode;
int currinode = 2; int currinode = 2;
int symlinkcnt = 0; int symlinkcnt = 0;
char fpath[EXT2_PATH_MAX]; char fpath[EXT2_PATH_MAX];
char *name = fpath; char *name = fpath;
pupa_strncpy (fpath, path, EXT2_PATH_MAX); grub_strncpy (fpath, path, EXT2_PATH_MAX);
if (!name || name[0] != '/') if (!name || name[0] != '/')
{ {
pupa_error (PUPA_ERR_BAD_FILENAME, "bad filename"); grub_error (GRUB_ERR_BAD_FILENAME, "bad filename");
return pupa_errno; return grub_errno;
} }
/* Skip the first slash. */ /* Skip the first slash. */
@ -398,8 +398,8 @@ pupa_ext2_find_file (struct pupa_ext2_data *data, const char *path, int *ino)
} }
/* Remove trailing "/". */ /* Remove trailing "/". */
if (name[pupa_strlen (name) - 1] =='/') if (name[grub_strlen (name) - 1] =='/')
name[pupa_strlen (name) - 1] = '\0'; name[grub_strlen (name) - 1] = '\0';
while (*name) while (*name)
{ {
@ -408,29 +408,29 @@ pupa_ext2_find_file (struct pupa_ext2_data *data, const char *path, int *ino)
int namesize; int namesize;
/* Extract the actual part from the pathname. */ /* Extract the actual part from the pathname. */
next = pupa_strchr (name, '/'); next = grub_strchr (name, '/');
if (next) if (next)
{ {
next[0] = '\0'; next[0] = '\0';
next++; next++;
} }
namesize = pupa_strlen (name); namesize = grub_strlen (name);
/* Open the file. */ /* Open the file. */
pupa_ext2_read_inode (data, currinode, inode); grub_ext2_read_inode (data, currinode, inode);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
/* Search the file. */ /* Search the file. */
while (fpos < pupa_le_to_cpu32 (inode->size)) while (fpos < grub_le_to_cpu32 (inode->size))
{ {
struct ext2_dirent dirent; struct ext2_dirent dirent;
/* Read the directory entry. */ /* Read the directory entry. */
pupa_ext2_read_file (data, 0, fpos, sizeof (struct ext2_dirent), grub_ext2_read_file (data, 0, fpos, sizeof (struct ext2_dirent),
(char *) &dirent); (char *) &dirent);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
if (dirent.namelen != 0) if (dirent.namelen != 0)
@ -438,10 +438,10 @@ pupa_ext2_find_file (struct pupa_ext2_data *data, const char *path, int *ino)
char filename[dirent.namelen + 1]; char filename[dirent.namelen + 1];
/* Read the filename part of this directory entry. */ /* Read the filename part of this directory entry. */
pupa_ext2_read_file (data, 0, fpos grub_ext2_read_file (data, 0, fpos
+ sizeof (struct ext2_dirent), + sizeof (struct ext2_dirent),
dirent.namelen, filename); dirent.namelen, filename);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
filename[dirent.namelen] = '\0'; filename[dirent.namelen] = '\0';
@ -449,7 +449,7 @@ pupa_ext2_find_file (struct pupa_ext2_data *data, const char *path, int *ino)
/* Check if the current directory entry described the /* Check if the current directory entry described the
file we are looking for. */ file we are looking for. */
if (dirent.namelen == namesize if (dirent.namelen == namesize
&& !pupa_strncmp (name, filename, namesize)) && !grub_strncmp (name, filename, namesize))
{ {
/* If this is a symlink, follow it. */ /* If this is a symlink, follow it. */
if (dirent.filetype == FILETYPE_SYMLINK) if (dirent.filetype == FILETYPE_SYMLINK)
@ -459,38 +459,38 @@ pupa_ext2_find_file (struct pupa_ext2_data *data, const char *path, int *ino)
if (++symlinkcnt == EXT2_MAX_SYMLINKCNT) if (++symlinkcnt == EXT2_MAX_SYMLINKCNT)
{ {
pupa_error (PUPA_ERR_SYMLINK_LOOP, grub_error (GRUB_ERR_SYMLINK_LOOP,
"too deep nesting of symlinks"); "too deep nesting of symlinks");
goto fail; goto fail;
} }
/* Read the symlink. */ /* Read the symlink. */
pupa_ext2_read_inode (data, grub_ext2_read_inode (data,
pupa_le_to_cpu32 (dirent.inode), grub_le_to_cpu32 (dirent.inode),
inode); inode);
/* If the filesize of the symlink is bigger than /* If the filesize of the symlink is bigger than
60 the symlink is stored in a separate block, 60 the symlink is stored in a separate block,
otherwise it is stored in the inode. */ otherwise it is stored in the inode. */
if (pupa_le_to_cpu32 (inode->size) <= 60) if (grub_le_to_cpu32 (inode->size) <= 60)
pupa_strncpy (symlink, grub_strncpy (symlink,
inode->symlink, inode->symlink,
pupa_le_to_cpu32 (inode->size)); grub_le_to_cpu32 (inode->size));
else else
{ {
pupa_ext2_read_file (data, 0, 0, grub_ext2_read_file (data, 0, 0,
pupa_le_to_cpu32 (inode->size), grub_le_to_cpu32 (inode->size),
symlink); symlink);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
} }
symlink[pupa_le_to_cpu32 (inode->size)] = '\0'; symlink[grub_le_to_cpu32 (inode->size)] = '\0';
/* Check if the symlink is absolute or relative. */ /* Check if the symlink is absolute or relative. */
if (symlink[0] == '/') if (symlink[0] == '/')
{ {
pupa_strncpy (fpath, symlink, EXT2_PATH_MAX); grub_strncpy (fpath, symlink, EXT2_PATH_MAX);
name = fpath; name = fpath;
currinode = 2; currinode = 2;
} }
@ -500,20 +500,20 @@ pupa_ext2_find_file (struct pupa_ext2_data *data, const char *path, int *ino)
if (next) if (next)
{ {
bak = pupa_strdup (next); bak = grub_strdup (next);
if (!bak) if (!bak)
goto fail; goto fail;
} }
/* Relative symlink, construct the new path. */ /* Relative symlink, construct the new path. */
pupa_strcpy (fpath, symlink); grub_strcpy (fpath, symlink);
name = fpath; name = fpath;
if (next) if (next)
{ {
pupa_strcat (name, "/"); grub_strcat (name, "/");
pupa_strcat (name, bak); grub_strcat (name, bak);
pupa_free (bak); grub_free (bak);
} }
} }
@ -523,12 +523,12 @@ pupa_ext2_find_file (struct pupa_ext2_data *data, const char *path, int *ino)
if (next) if (next)
{ {
currinode = pupa_le_to_cpu32 (dirent.inode); currinode = grub_le_to_cpu32 (dirent.inode);
name = next; name = next;
if (dirent.filetype != FILETYPE_DIRECTORY) if (dirent.filetype != FILETYPE_DIRECTORY)
{ {
pupa_error (PUPA_ERR_BAD_FILE_TYPE, grub_error (GRUB_ERR_BAD_FILE_TYPE,
"not a directory"); "not a directory");
goto fail; goto fail;
} }
@ -536,59 +536,59 @@ pupa_ext2_find_file (struct pupa_ext2_data *data, const char *path, int *ino)
} }
else /* Found it! */ else /* Found it! */
{ {
*ino = pupa_le_to_cpu32 (dirent.inode); *ino = grub_le_to_cpu32 (dirent.inode);
return 0; return 0;
} }
} }
} }
/* Move to next directory entry. */ /* Move to next directory entry. */
fpos += pupa_le_to_cpu16 (dirent.direntlen); fpos += grub_le_to_cpu16 (dirent.direntlen);
} }
/* The complete directory was read and no matching file was /* The complete directory was read and no matching file was
found. */ found. */
if (fpos >= pupa_le_to_cpu32 (inode->size)) if (fpos >= grub_le_to_cpu32 (inode->size))
{ {
pupa_error (PUPA_ERR_FILE_NOT_FOUND, "file not found"); grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
goto fail; goto fail;
} }
} }
fail: fail:
return pupa_errno; return grub_errno;
} }
/* Open a file named NAME and initialize FILE. */ /* Open a file named NAME and initialize FILE. */
static pupa_err_t static grub_err_t
pupa_ext2_open (struct pupa_file *file, const char *name) grub_ext2_open (struct grub_file *file, const char *name)
{ {
struct pupa_ext2_data *data; struct grub_ext2_data *data;
int ino; int ino;
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_ref (my_mod); grub_dl_ref (my_mod);
#endif #endif
data = pupa_ext2_mount (file->device->disk); data = grub_ext2_mount (file->device->disk);
if (!data) if (!data)
goto fail; goto fail;
pupa_ext2_find_file (data, name, &ino); grub_ext2_find_file (data, name, &ino);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
pupa_ext2_read_inode (data, ino, &data->inode); grub_ext2_read_inode (data, ino, &data->inode);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
if (!(pupa_le_to_cpu16 (data->inode.mode) & 0100000)) if (!(grub_le_to_cpu16 (data->inode.mode) & 0100000))
{ {
pupa_error (PUPA_ERR_BAD_FILE_TYPE, "not a regular file"); grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a regular file");
goto fail; goto fail;
} }
file->size = pupa_le_to_cpu32 (data->inode.size); file->size = grub_le_to_cpu32 (data->inode.size);
file->data = data; file->data = data;
file->offset = 0; file->offset = 0;
@ -596,86 +596,86 @@ pupa_ext2_open (struct pupa_file *file, const char *name)
fail: fail:
pupa_free (data); grub_free (data);
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_unref (my_mod); grub_dl_unref (my_mod);
#endif #endif
return pupa_errno; return grub_errno;
} }
static pupa_err_t static grub_err_t
pupa_ext2_close (pupa_file_t file) grub_ext2_close (grub_file_t file)
{ {
pupa_free (file->data); grub_free (file->data);
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_unref (my_mod); grub_dl_unref (my_mod);
#endif #endif
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
/* Read LEN bytes data from FILE into BUF. */ /* Read LEN bytes data from FILE into BUF. */
static pupa_ssize_t static grub_ssize_t
pupa_ext2_read (pupa_file_t file, char *buf, pupa_ssize_t len) grub_ext2_read (grub_file_t file, char *buf, grub_ssize_t len)
{ {
struct pupa_ext2_data *data = struct grub_ext2_data *data =
(struct pupa_ext2_data *) file->data; (struct grub_ext2_data *) file->data;
return pupa_ext2_read_file (data, file->read_hook, file->offset, len, buf); return grub_ext2_read_file (data, file->read_hook, file->offset, len, buf);
} }
static pupa_err_t static grub_err_t
pupa_ext2_dir (pupa_device_t device, const char *path, grub_ext2_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename, int dir)) int (*hook) (const char *filename, int dir))
{ {
struct pupa_ext2_data *data = 0;; struct grub_ext2_data *data = 0;;
int ino; int ino;
unsigned int fpos = 0; unsigned int fpos = 0;
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_ref (my_mod); grub_dl_ref (my_mod);
#endif #endif
data = pupa_ext2_mount (device->disk); data = grub_ext2_mount (device->disk);
if (!data) if (!data)
goto fail; goto fail;
pupa_ext2_find_file (data, (char *) path, &ino); grub_ext2_find_file (data, (char *) path, &ino);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
pupa_ext2_read_inode (data, ino, &data->inode); grub_ext2_read_inode (data, ino, &data->inode);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
if (!(pupa_le_to_cpu16 (data->inode.mode) & 040000)) if (!(grub_le_to_cpu16 (data->inode.mode) & 040000))
{ {
pupa_error (PUPA_ERR_BAD_FILE_TYPE, "not a directory"); grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
goto fail; goto fail;
} }
/* Search the file. */ /* Search the file. */
while (fpos < pupa_le_to_cpu32 (data->inode.size)) while (fpos < grub_le_to_cpu32 (data->inode.size))
{ {
struct ext2_dirent dirent; struct ext2_dirent dirent;
pupa_ext2_read_file (data, 0, fpos, sizeof (struct ext2_dirent), grub_ext2_read_file (data, 0, fpos, sizeof (struct ext2_dirent),
(char *) &dirent); (char *) &dirent);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
if (dirent.namelen != 0) if (dirent.namelen != 0)
{ {
char filename[dirent.namelen + 1]; char filename[dirent.namelen + 1];
pupa_ext2_read_file (data, 0, fpos + sizeof (struct ext2_dirent), grub_ext2_read_file (data, 0, fpos + sizeof (struct ext2_dirent),
dirent.namelen, filename); dirent.namelen, filename);
if (pupa_errno) if (grub_errno)
goto fail; goto fail;
filename[dirent.namelen] = '\0'; filename[dirent.namelen] = '\0';
@ -683,78 +683,78 @@ pupa_ext2_dir (pupa_device_t device, const char *path,
hook (filename, dirent.filetype == FILETYPE_DIRECTORY); hook (filename, dirent.filetype == FILETYPE_DIRECTORY);
} }
fpos += pupa_le_to_cpu16 (dirent.direntlen); fpos += grub_le_to_cpu16 (dirent.direntlen);
} }
fail: fail:
pupa_free (data); grub_free (data);
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_unref (my_mod); grub_dl_unref (my_mod);
#endif #endif
return pupa_errno; return grub_errno;
} }
static pupa_err_t static grub_err_t
pupa_ext2_label (pupa_device_t device, char **label) grub_ext2_label (grub_device_t device, char **label)
{ {
struct pupa_ext2_data *data; struct grub_ext2_data *data;
pupa_disk_t disk = device->disk; grub_disk_t disk = device->disk;
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_ref (my_mod); grub_dl_ref (my_mod);
#endif #endif
data = pupa_ext2_mount (disk); data = grub_ext2_mount (disk);
if (data) if (data)
*label = pupa_strndup (data->sblock.volume_name, 14); *label = grub_strndup (data->sblock.volume_name, 14);
else else
*label = 0; *label = 0;
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_unref (my_mod); grub_dl_unref (my_mod);
#endif #endif
pupa_free (data); grub_free (data);
return pupa_errno; return grub_errno;
} }
static struct pupa_fs pupa_ext2_fs = static struct grub_fs grub_ext2_fs =
{ {
.name = "ext2", .name = "ext2",
.dir = pupa_ext2_dir, .dir = grub_ext2_dir,
.open = pupa_ext2_open, .open = grub_ext2_open,
.read = pupa_ext2_read, .read = grub_ext2_read,
.close = pupa_ext2_close, .close = grub_ext2_close,
.label = pupa_ext2_label, .label = grub_ext2_label,
.next = 0 .next = 0
}; };
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
void void
pupa_ext2_init (void) grub_ext2_init (void)
{ {
pupa_fs_register (&pupa_ext2_fs); grub_fs_register (&grub_ext2_fs);
} }
void void
pupa_ext2_fini (void) grub_ext2_fini (void)
{ {
pupa_fs_unregister (&pupa_ext2_fs); grub_fs_unregister (&grub_ext2_fs);
} }
#else /* ! PUPA_UTIL */ #else /* ! GRUB_UTIL */
PUPA_MOD_INIT GRUB_MOD_INIT
{ {
pupa_fs_register (&pupa_ext2_fs); grub_fs_register (&grub_ext2_fs);
my_mod = mod; my_mod = mod;
} }
PUPA_MOD_FINI GRUB_MOD_FINI
{ {
pupa_fs_unregister (&pupa_ext2_fs); grub_fs_unregister (&grub_ext2_fs);
} }
#endif /* ! PUPA_UTIL */ #endif /* ! GRUB_UTIL */

500
fs/fat.c
View file

@ -1,6 +1,6 @@
/* fat.c - FAT filesystem */ /* fat.c - FAT filesystem */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2000,2001,2002,2003,2004 Free Software Foundation, Inc. * Copyright (C) 2000,2001,2002,2003,2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,115 +18,115 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/fs.h> #include <grub/fs.h>
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/file.h> #include <grub/file.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/dl.h> #include <grub/dl.h>
#define PUPA_FAT_DIR_ENTRY_SIZE 32 #define GRUB_FAT_DIR_ENTRY_SIZE 32
#define PUPA_FAT_ATTR_READ_ONLY 0x01 #define GRUB_FAT_ATTR_READ_ONLY 0x01
#define PUPA_FAT_ATTR_HIDDEN 0x02 #define GRUB_FAT_ATTR_HIDDEN 0x02
#define PUPA_FAT_ATTR_SYSTEM 0x04 #define GRUB_FAT_ATTR_SYSTEM 0x04
#define PUPA_FAT_ATTR_VOLUME_ID 0x08 #define GRUB_FAT_ATTR_VOLUME_ID 0x08
#define PUPA_FAT_ATTR_DIRECTORY 0x10 #define GRUB_FAT_ATTR_DIRECTORY 0x10
#define PUPA_FAT_ATTR_ARCHIVE 0x20 #define GRUB_FAT_ATTR_ARCHIVE 0x20
#define PUPA_FAT_ATTR_LONG_NAME (PUPA_FAT_ATTR_READ_ONLY \ #define GRUB_FAT_ATTR_LONG_NAME (GRUB_FAT_ATTR_READ_ONLY \
| PUPA_FAT_ATTR_HIDDEN \ | GRUB_FAT_ATTR_HIDDEN \
| PUPA_FAT_ATTR_SYSTEM \ | GRUB_FAT_ATTR_SYSTEM \
| PUPA_FAT_ATTR_VOLUME_ID) | GRUB_FAT_ATTR_VOLUME_ID)
#define PUPA_FAT_ATTR_VALID (PUPA_FAT_ATTR_READ_ONLY \ #define GRUB_FAT_ATTR_VALID (GRUB_FAT_ATTR_READ_ONLY \
| PUPA_FAT_ATTR_HIDDEN \ | GRUB_FAT_ATTR_HIDDEN \
| PUPA_FAT_ATTR_SYSTEM \ | GRUB_FAT_ATTR_SYSTEM \
| PUPA_FAT_ATTR_DIRECTORY \ | GRUB_FAT_ATTR_DIRECTORY \
| PUPA_FAT_ATTR_ARCHIVE) | GRUB_FAT_ATTR_ARCHIVE)
struct pupa_fat_bpb struct grub_fat_bpb
{ {
pupa_uint8_t jmp_boot[3]; grub_uint8_t jmp_boot[3];
pupa_uint8_t oem_name[8]; grub_uint8_t oem_name[8];
pupa_uint16_t bytes_per_sector; grub_uint16_t bytes_per_sector;
pupa_uint8_t sectors_per_cluster; grub_uint8_t sectors_per_cluster;
pupa_uint16_t num_reserved_sectors; grub_uint16_t num_reserved_sectors;
pupa_uint8_t num_fats; grub_uint8_t num_fats;
pupa_uint16_t num_root_entries; grub_uint16_t num_root_entries;
pupa_uint16_t num_total_sectors_16; grub_uint16_t num_total_sectors_16;
pupa_uint8_t media; grub_uint8_t media;
pupa_uint16_t sectors_per_fat_16; grub_uint16_t sectors_per_fat_16;
pupa_uint16_t sectors_per_track; grub_uint16_t sectors_per_track;
pupa_uint16_t num_heads; grub_uint16_t num_heads;
pupa_uint32_t num_hidden_sectors; grub_uint32_t num_hidden_sectors;
pupa_uint32_t num_total_sectors_32; grub_uint32_t num_total_sectors_32;
/* The following fields are only used by FAT32. */ /* The following fields are only used by FAT32. */
pupa_uint32_t sectors_per_fat_32; grub_uint32_t sectors_per_fat_32;
pupa_uint16_t extended_flags; grub_uint16_t extended_flags;
pupa_uint16_t fs_version; grub_uint16_t fs_version;
pupa_uint32_t root_cluster; grub_uint32_t root_cluster;
pupa_uint16_t fs_info; grub_uint16_t fs_info;
pupa_uint16_t backup_boot_sector; grub_uint16_t backup_boot_sector;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct pupa_fat_dir_entry struct grub_fat_dir_entry
{ {
pupa_uint8_t name[11]; grub_uint8_t name[11];
pupa_uint8_t attr; grub_uint8_t attr;
pupa_uint8_t nt_reserved; grub_uint8_t nt_reserved;
pupa_uint8_t c_time_tenth; grub_uint8_t c_time_tenth;
pupa_uint16_t c_time; grub_uint16_t c_time;
pupa_uint16_t c_date; grub_uint16_t c_date;
pupa_uint16_t a_date; grub_uint16_t a_date;
pupa_uint16_t first_cluster_high; grub_uint16_t first_cluster_high;
pupa_uint16_t w_time; grub_uint16_t w_time;
pupa_uint16_t w_date; grub_uint16_t w_date;
pupa_uint16_t first_cluster_low; grub_uint16_t first_cluster_low;
pupa_uint32_t file_size; grub_uint32_t file_size;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct pupa_fat_long_name_entry struct grub_fat_long_name_entry
{ {
pupa_uint8_t id; grub_uint8_t id;
pupa_uint16_t name1[5]; grub_uint16_t name1[5];
pupa_uint8_t attr; grub_uint8_t attr;
pupa_uint8_t reserved; grub_uint8_t reserved;
pupa_uint8_t checksum; grub_uint8_t checksum;
pupa_uint16_t name2[6]; grub_uint16_t name2[6];
pupa_uint16_t first_cluster; grub_uint16_t first_cluster;
pupa_uint16_t name3[2]; grub_uint16_t name3[2];
} __attribute__ ((packed)); } __attribute__ ((packed));
struct pupa_fat_data struct grub_fat_data
{ {
int logical_sector_bits; int logical_sector_bits;
pupa_uint32_t num_sectors; grub_uint32_t num_sectors;
pupa_uint16_t fat_sector; grub_uint16_t fat_sector;
pupa_uint32_t sectors_per_fat; grub_uint32_t sectors_per_fat;
int fat_size; int fat_size;
pupa_uint32_t root_cluster; grub_uint32_t root_cluster;
pupa_uint32_t root_sector; grub_uint32_t root_sector;
pupa_uint32_t num_root_sectors; grub_uint32_t num_root_sectors;
int cluster_bits; int cluster_bits;
pupa_uint32_t cluster_eof_mark; grub_uint32_t cluster_eof_mark;
pupa_uint32_t cluster_sector; grub_uint32_t cluster_sector;
pupa_uint32_t num_clusters; grub_uint32_t num_clusters;
pupa_uint8_t attr; grub_uint8_t attr;
pupa_ssize_t file_size; grub_ssize_t file_size;
pupa_uint32_t file_cluster; grub_uint32_t file_cluster;
pupa_uint32_t cur_cluster_num; grub_uint32_t cur_cluster_num;
pupa_uint32_t cur_cluster; grub_uint32_t cur_cluster;
}; };
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
static pupa_dl_t my_mod; static grub_dl_t my_mod;
#endif #endif
static int static int
@ -146,30 +146,30 @@ fat_log2 (unsigned x)
return i; return i;
} }
static struct pupa_fat_data * static struct grub_fat_data *
pupa_fat_mount (pupa_disk_t disk) grub_fat_mount (grub_disk_t disk)
{ {
struct pupa_fat_bpb bpb; struct grub_fat_bpb bpb;
struct pupa_fat_data *data = 0; struct grub_fat_data *data = 0;
pupa_uint32_t first_fat, magic; grub_uint32_t first_fat, magic;
if (! disk) if (! disk)
goto fail; goto fail;
data = (struct pupa_fat_data *) pupa_malloc (sizeof (*data)); data = (struct grub_fat_data *) grub_malloc (sizeof (*data));
if (! data) if (! data)
goto fail; goto fail;
/* Read the BPB. */ /* Read the BPB. */
if (pupa_disk_read (disk, 0, 0, sizeof (bpb), (char *) &bpb)) if (grub_disk_read (disk, 0, 0, sizeof (bpb), (char *) &bpb))
goto fail; goto fail;
/* Get the sizes of logical sectors and clusters. */ /* Get the sizes of logical sectors and clusters. */
data->logical_sector_bits = data->logical_sector_bits =
fat_log2 (pupa_le_to_cpu16 (bpb.bytes_per_sector)); fat_log2 (grub_le_to_cpu16 (bpb.bytes_per_sector));
if (data->logical_sector_bits < PUPA_DISK_SECTOR_BITS) if (data->logical_sector_bits < GRUB_DISK_SECTOR_BITS)
goto fail; goto fail;
data->logical_sector_bits -= PUPA_DISK_SECTOR_BITS; data->logical_sector_bits -= GRUB_DISK_SECTOR_BITS;
data->cluster_bits = fat_log2 (bpb.sectors_per_cluster); data->cluster_bits = fat_log2 (bpb.sectors_per_cluster);
if (data->cluster_bits < 0) if (data->cluster_bits < 0)
@ -177,22 +177,22 @@ pupa_fat_mount (pupa_disk_t disk)
data->cluster_bits += data->logical_sector_bits; data->cluster_bits += data->logical_sector_bits;
/* Get information about FATs. */ /* Get information about FATs. */
data->fat_sector = (pupa_le_to_cpu16 (bpb.num_reserved_sectors) data->fat_sector = (grub_le_to_cpu16 (bpb.num_reserved_sectors)
<< data->logical_sector_bits); << data->logical_sector_bits);
if (data->fat_sector == 0) if (data->fat_sector == 0)
goto fail; goto fail;
data->sectors_per_fat = ((bpb.sectors_per_fat_16 data->sectors_per_fat = ((bpb.sectors_per_fat_16
? pupa_le_to_cpu16 (bpb.sectors_per_fat_16) ? grub_le_to_cpu16 (bpb.sectors_per_fat_16)
: pupa_le_to_cpu32 (bpb.sectors_per_fat_32)) : grub_le_to_cpu32 (bpb.sectors_per_fat_32))
<< data->logical_sector_bits); << data->logical_sector_bits);
if (data->sectors_per_fat == 0) if (data->sectors_per_fat == 0)
goto fail; goto fail;
/* Get the number of sectors in this volume. */ /* Get the number of sectors in this volume. */
data->num_sectors = ((bpb.num_total_sectors_16 data->num_sectors = ((bpb.num_total_sectors_16
? pupa_le_to_cpu16 (bpb.num_total_sectors_16) ? grub_le_to_cpu16 (bpb.num_total_sectors_16)
: pupa_le_to_cpu32 (bpb.num_total_sectors_32)) : grub_le_to_cpu32 (bpb.num_total_sectors_32))
<< data->logical_sector_bits); << data->logical_sector_bits);
if (data->num_sectors == 0) if (data->num_sectors == 0)
goto fail; goto fail;
@ -203,10 +203,10 @@ pupa_fat_mount (pupa_disk_t disk)
data->root_sector = data->fat_sector + bpb.num_fats * data->sectors_per_fat; data->root_sector = data->fat_sector + bpb.num_fats * data->sectors_per_fat;
data->num_root_sectors data->num_root_sectors
= ((((pupa_uint32_t) pupa_le_to_cpu16 (bpb.num_root_entries) = ((((grub_uint32_t) grub_le_to_cpu16 (bpb.num_root_entries)
* PUPA_FAT_DIR_ENTRY_SIZE * GRUB_FAT_DIR_ENTRY_SIZE
+ pupa_le_to_cpu16 (bpb.bytes_per_sector) - 1) + grub_le_to_cpu16 (bpb.bytes_per_sector) - 1)
>> (data->logical_sector_bits + PUPA_DISK_SECTOR_BITS)) >> (data->logical_sector_bits + GRUB_DISK_SECTOR_BITS))
<< (data->logical_sector_bits)); << (data->logical_sector_bits));
data->cluster_sector = data->root_sector + data->num_root_sectors; data->cluster_sector = data->root_sector + data->num_root_sectors;
@ -220,9 +220,9 @@ pupa_fat_mount (pupa_disk_t disk)
if (! bpb.sectors_per_fat_16) if (! bpb.sectors_per_fat_16)
{ {
/* FAT32. */ /* FAT32. */
pupa_uint16_t flags = pupa_le_to_cpu16 (bpb.extended_flags); grub_uint16_t flags = grub_le_to_cpu16 (bpb.extended_flags);
data->root_cluster = pupa_le_to_cpu32 (bpb.root_cluster); data->root_cluster = grub_le_to_cpu32 (bpb.root_cluster);
data->fat_size = 32; data->fat_size = 32;
data->cluster_eof_mark = 0x0ffffff8; data->cluster_eof_mark = 0x0ffffff8;
@ -263,14 +263,14 @@ pupa_fat_mount (pupa_disk_t disk)
if (data->num_sectors <= data->fat_sector) if (data->num_sectors <= data->fat_sector)
goto fail; goto fail;
if (pupa_disk_read (disk, if (grub_disk_read (disk,
data->fat_sector, data->fat_sector,
0, 0,
sizeof (first_fat), sizeof (first_fat),
(char *) &first_fat)) (char *) &first_fat))
goto fail; goto fail;
first_fat = pupa_le_to_cpu32 (first_fat); first_fat = grub_le_to_cpu32 (first_fat);
if (data->fat_size == 32) if (data->fat_size == 32)
{ {
@ -294,26 +294,26 @@ pupa_fat_mount (pupa_disk_t disk)
/* Start from the root directory. */ /* Start from the root directory. */
data->file_cluster = data->root_cluster; data->file_cluster = data->root_cluster;
data->cur_cluster_num = ~0UL; data->cur_cluster_num = ~0UL;
data->attr = PUPA_FAT_ATTR_DIRECTORY; data->attr = GRUB_FAT_ATTR_DIRECTORY;
return data; return data;
fail: fail:
pupa_free (data); grub_free (data);
pupa_error (PUPA_ERR_BAD_FS, "not a fat filesystem"); grub_error (GRUB_ERR_BAD_FS, "not a fat filesystem");
return 0; return 0;
} }
/* Convert UTF-16 (little endian) to UTF8. */ /* Convert UTF-16 (little endian) to UTF8. */
static pupa_uint8_t * static grub_uint8_t *
pupa_fat_utf16_to_utf8 (pupa_uint8_t *dest, pupa_uint16_t *src, grub_fat_utf16_to_utf8 (grub_uint8_t *dest, grub_uint16_t *src,
pupa_size_t size) grub_size_t size)
{ {
pupa_uint32_t code_high = 0; grub_uint32_t code_high = 0;
while (size--) while (size--)
{ {
pupa_uint32_t code = pupa_le_to_cpu16 (*src++); grub_uint32_t code = grub_le_to_cpu16 (*src++);
if (code_high) if (code_high)
{ {
@ -366,27 +366,27 @@ pupa_fat_utf16_to_utf8 (pupa_uint8_t *dest, pupa_uint16_t *src,
return dest; return dest;
} }
static pupa_ssize_t static grub_ssize_t
pupa_fat_read_data (pupa_disk_t disk, struct pupa_fat_data *data, grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
void (*read_hook) (unsigned long sector, void (*read_hook) (unsigned long sector,
unsigned offset, unsigned length), unsigned offset, unsigned length),
pupa_ssize_t offset, pupa_ssize_t len, char *buf) grub_ssize_t offset, grub_ssize_t len, char *buf)
{ {
pupa_ssize_t size; grub_ssize_t size;
pupa_uint32_t logical_cluster; grub_uint32_t logical_cluster;
unsigned logical_cluster_bits; unsigned logical_cluster_bits;
pupa_ssize_t ret = 0; grub_ssize_t ret = 0;
unsigned long sector; unsigned long sector;
/* This is a special case. FAT12 and FAT16 doesn't have the root directory /* This is a special case. FAT12 and FAT16 doesn't have the root directory
in clusters. */ in clusters. */
if (data->file_cluster == ~0UL) if (data->file_cluster == ~0UL)
{ {
size = (data->num_root_sectors << PUPA_DISK_SECTOR_BITS) - offset; size = (data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset;
if (size > len) if (size > len)
size = len; size = len;
if (pupa_disk_read (disk, data->root_sector, offset, size, buf)) if (grub_disk_read (disk, data->root_sector, offset, size, buf))
return -1; return -1;
return size; return size;
@ -395,7 +395,7 @@ pupa_fat_read_data (pupa_disk_t disk, struct pupa_fat_data *data,
/* Calculate the logical cluster number and offset. */ /* Calculate the logical cluster number and offset. */
logical_cluster_bits = (data->cluster_bits logical_cluster_bits = (data->cluster_bits
+ data->logical_sector_bits + data->logical_sector_bits
+ PUPA_DISK_SECTOR_BITS); + GRUB_DISK_SECTOR_BITS);
logical_cluster = offset >> logical_cluster_bits; logical_cluster = offset >> logical_cluster_bits;
offset &= (1 << logical_cluster_bits) - 1; offset &= (1 << logical_cluster_bits) - 1;
@ -410,7 +410,7 @@ pupa_fat_read_data (pupa_disk_t disk, struct pupa_fat_data *data,
while (logical_cluster > data->cur_cluster_num) while (logical_cluster > data->cur_cluster_num)
{ {
/* Find next cluster. */ /* Find next cluster. */
pupa_uint32_t next_cluster; grub_uint32_t next_cluster;
unsigned long fat_offset; unsigned long fat_offset;
switch (data->fat_size) switch (data->fat_size)
@ -428,12 +428,12 @@ pupa_fat_read_data (pupa_disk_t disk, struct pupa_fat_data *data,
} }
/* Read the FAT. */ /* Read the FAT. */
if (pupa_disk_read (disk, data->fat_sector, fat_offset, if (grub_disk_read (disk, data->fat_sector, fat_offset,
(data->fat_size + 7) >> 3, (data->fat_size + 7) >> 3,
(char *) &next_cluster)) (char *) &next_cluster))
return -1; return -1;
next_cluster = pupa_le_to_cpu32 (next_cluster); next_cluster = grub_le_to_cpu32 (next_cluster);
switch (data->fat_size) switch (data->fat_size)
{ {
case 16: case 16:
@ -448,7 +448,7 @@ pupa_fat_read_data (pupa_disk_t disk, struct pupa_fat_data *data,
} }
#if 0 #if 0
pupa_printf ("%s:%d: fat_size=%d, next_cluster=%u\n", grub_printf ("%s:%d: fat_size=%d, next_cluster=%u\n",
__FILE__, __LINE__, data->fat_size, next_cluster); __FILE__, __LINE__, data->fat_size, next_cluster);
#endif #endif
@ -458,7 +458,7 @@ pupa_fat_read_data (pupa_disk_t disk, struct pupa_fat_data *data,
if (next_cluster < 2 || next_cluster >= data->num_clusters) if (next_cluster < 2 || next_cluster >= data->num_clusters)
{ {
pupa_error (PUPA_ERR_BAD_FS, "invalid cluster %u", grub_error (GRUB_ERR_BAD_FS, "invalid cluster %u",
next_cluster); next_cluster);
return -1; return -1;
} }
@ -476,9 +476,9 @@ pupa_fat_read_data (pupa_disk_t disk, struct pupa_fat_data *data,
size = len; size = len;
disk->read_hook = read_hook; disk->read_hook = read_hook;
pupa_disk_read (disk, sector, offset, size, buf); grub_disk_read (disk, sector, offset, size, buf);
disk->read_hook = 0; disk->read_hook = 0;
if (pupa_errno) if (grub_errno)
return -1; return -1;
len -= size; len -= size;
@ -495,22 +495,22 @@ pupa_fat_read_data (pupa_disk_t disk, struct pupa_fat_data *data,
next path. If there is no next path or an error occurs, return NULL. next path. If there is no next path or an error occurs, return NULL.
If HOOK is specified, call it with each file name. */ If HOOK is specified, call it with each file name. */
static char * static char *
pupa_fat_find_dir (pupa_disk_t disk, struct pupa_fat_data *data, grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
const char *path, const char *path,
int (*hook) (const char *filename, int dir)) int (*hook) (const char *filename, int dir))
{ {
struct pupa_fat_dir_entry dir; struct grub_fat_dir_entry dir;
char *dirname, *dirp; char *dirname, *dirp;
char *filename, *filep = 0; char *filename, *filep = 0;
pupa_uint16_t *unibuf; grub_uint16_t *unibuf;
int slot = -1, slots = -1; int slot = -1, slots = -1;
int checksum = -1; int checksum = -1;
pupa_ssize_t offset = -sizeof(dir); grub_ssize_t offset = -sizeof(dir);
int call_hook; int call_hook;
if (! (data->attr & PUPA_FAT_ATTR_DIRECTORY)) if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
{ {
pupa_error (PUPA_ERR_BAD_FILE_TYPE, "not a directory"); grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
return 0; return 0;
} }
@ -518,32 +518,32 @@ pupa_fat_find_dir (pupa_disk_t disk, struct pupa_fat_data *data,
while (*path == '/') while (*path == '/')
path++; path++;
dirp = pupa_strchr (path, '/'); dirp = grub_strchr (path, '/');
if (dirp) if (dirp)
{ {
unsigned len = dirp - path; unsigned len = dirp - path;
dirname = pupa_malloc (len + 1); dirname = grub_malloc (len + 1);
if (! dirname) if (! dirname)
return 0; return 0;
pupa_memcpy (dirname, path, len); grub_memcpy (dirname, path, len);
dirname[len] = '\0'; dirname[len] = '\0';
} }
else else
/* This is actually a file. */ /* This is actually a file. */
dirname = pupa_strdup (path); dirname = grub_strdup (path);
call_hook = (! dirp && hook); call_hook = (! dirp && hook);
/* Allocate space enough to hold a long name. */ /* Allocate space enough to hold a long name. */
filename = pupa_malloc (0x40 * 13 * 4 + 1); filename = grub_malloc (0x40 * 13 * 4 + 1);
unibuf = (pupa_uint16_t *) pupa_malloc (0x40 * 13 * 2); unibuf = (grub_uint16_t *) grub_malloc (0x40 * 13 * 2);
if (! filename || ! unibuf) if (! filename || ! unibuf)
{ {
pupa_free (filename); grub_free (filename);
pupa_free (unibuf); grub_free (unibuf);
pupa_free (dirname); grub_free (dirname);
return 0; return 0;
} }
@ -555,23 +555,23 @@ pupa_fat_find_dir (pupa_disk_t disk, struct pupa_fat_data *data,
offset += sizeof (dir); offset += sizeof (dir);
/* Read a directory entry. */ /* Read a directory entry. */
if ((pupa_fat_read_data (disk, data, 0, if ((grub_fat_read_data (disk, data, 0,
offset, sizeof (dir), (char *) &dir) offset, sizeof (dir), (char *) &dir)
!= sizeof (dir)) != sizeof (dir))
|| dir.name[0] == 0) || dir.name[0] == 0)
{ {
if (pupa_errno == PUPA_ERR_NONE && ! call_hook) if (grub_errno == GRUB_ERR_NONE && ! call_hook)
pupa_error (PUPA_ERR_FILE_NOT_FOUND, "file not found"); grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
break; break;
} }
/* Handle long name entries. */ /* Handle long name entries. */
if (dir.attr == PUPA_FAT_ATTR_LONG_NAME) if (dir.attr == GRUB_FAT_ATTR_LONG_NAME)
{ {
struct pupa_fat_long_name_entry *long_name struct grub_fat_long_name_entry *long_name
= (struct pupa_fat_long_name_entry *) &dir; = (struct grub_fat_long_name_entry *) &dir;
pupa_uint8_t id = long_name->id; grub_uint8_t id = long_name->id;
if (id & 0x40) if (id & 0x40)
{ {
@ -587,14 +587,14 @@ pupa_fat_find_dir (pupa_disk_t disk, struct pupa_fat_data *data,
} }
slot--; slot--;
pupa_memcpy (unibuf + slot * 13, long_name->name1, 5 * 2); grub_memcpy (unibuf + slot * 13, long_name->name1, 5 * 2);
pupa_memcpy (unibuf + slot * 13 + 5, long_name->name2, 6 * 2); grub_memcpy (unibuf + slot * 13 + 5, long_name->name2, 6 * 2);
pupa_memcpy (unibuf + slot * 13 + 11, long_name->name3, 2 * 2); grub_memcpy (unibuf + slot * 13 + 11, long_name->name3, 2 * 2);
continue; continue;
} }
/* Check if this entry is valid. */ /* Check if this entry is valid. */
if (dir.name[0] == 0xe5 || (dir.attr & ~PUPA_FAT_ATTR_VALID)) if (dir.name[0] == 0xe5 || (dir.attr & ~GRUB_FAT_ATTR_VALID))
continue; continue;
/* This is a workaround for Japanese. */ /* This is a workaround for Japanese. */
@ -603,28 +603,28 @@ pupa_fat_find_dir (pupa_disk_t disk, struct pupa_fat_data *data,
if (checksum != -1 && slot == 0) if (checksum != -1 && slot == 0)
{ {
pupa_uint8_t sum; grub_uint8_t sum;
for (sum = 0, i = 0; i < sizeof (dir.name); i++) for (sum = 0, i = 0; i < sizeof (dir.name); i++)
sum = ((sum >> 1) | (sum << 7)) + dir.name[i]; sum = ((sum >> 1) | (sum << 7)) + dir.name[i];
if (sum == checksum) if (sum == checksum)
{ {
*pupa_fat_utf16_to_utf8 (filename, unibuf, slots * 13) = '\0'; *grub_fat_utf16_to_utf8 (filename, unibuf, slots * 13) = '\0';
if (*dirname == '\0' && call_hook) if (*dirname == '\0' && call_hook)
{ {
if (hook (filename, dir.attr & PUPA_FAT_ATTR_DIRECTORY)) if (hook (filename, dir.attr & GRUB_FAT_ATTR_DIRECTORY))
break; break;
checksum = -1; checksum = -1;
continue; continue;
} }
if (pupa_strcmp (dirname, filename) == 0) if (grub_strcmp (dirname, filename) == 0)
{ {
if (call_hook) if (call_hook)
hook (filename, dir.attr & PUPA_FAT_ATTR_DIRECTORY); hook (filename, dir.attr & GRUB_FAT_ATTR_DIRECTORY);
break; break;
} }
@ -636,13 +636,13 @@ pupa_fat_find_dir (pupa_disk_t disk, struct pupa_fat_data *data,
/* Convert the 8.3 file name. */ /* Convert the 8.3 file name. */
filep = filename; filep = filename;
for (i = 0; i < 8 && dir.name[i] && ! pupa_isspace (dir.name[i]); i++) for (i = 0; i < 8 && dir.name[i] && ! grub_isspace (dir.name[i]); i++)
*filep++ = pupa_tolower (dir.name[i]); *filep++ = grub_tolower (dir.name[i]);
*filep = '.'; *filep = '.';
for (i = 8; i < 11 && dir.name[i] && ! pupa_isspace (dir.name[i]); i++) for (i = 8; i < 11 && dir.name[i] && ! grub_isspace (dir.name[i]); i++)
*++filep = pupa_tolower (dir.name[i]); *++filep = grub_tolower (dir.name[i]);
if (*filep != '.') if (*filep != '.')
filep++; filep++;
@ -651,174 +651,174 @@ pupa_fat_find_dir (pupa_disk_t disk, struct pupa_fat_data *data,
if (*dirname == '\0' && call_hook) if (*dirname == '\0' && call_hook)
{ {
if (hook (filename, dir.attr & PUPA_FAT_ATTR_DIRECTORY)) if (hook (filename, dir.attr & GRUB_FAT_ATTR_DIRECTORY))
break; break;
} }
else if (pupa_strcmp (dirname, filename) == 0) else if (grub_strcmp (dirname, filename) == 0)
{ {
if (call_hook) if (call_hook)
hook (filename, dir.attr & PUPA_FAT_ATTR_DIRECTORY); hook (filename, dir.attr & GRUB_FAT_ATTR_DIRECTORY);
break; break;
} }
} }
pupa_free (filename); grub_free (filename);
pupa_free (dirname); grub_free (dirname);
data->attr = dir.attr; data->attr = dir.attr;
data->file_size = pupa_le_to_cpu32 (dir.file_size); data->file_size = grub_le_to_cpu32 (dir.file_size);
data->file_cluster = ((pupa_le_to_cpu16 (dir.first_cluster_high) << 16) data->file_cluster = ((grub_le_to_cpu16 (dir.first_cluster_high) << 16)
| pupa_le_to_cpu16 (dir.first_cluster_low)); | grub_le_to_cpu16 (dir.first_cluster_low));
data->cur_cluster_num = ~0UL; data->cur_cluster_num = ~0UL;
return dirp; return dirp;
} }
static pupa_err_t static grub_err_t
pupa_fat_dir (pupa_device_t device, const char *path, grub_fat_dir (grub_device_t device, const char *path,
int (*hook) (const char *filename, int dir)) int (*hook) (const char *filename, int dir))
{ {
struct pupa_fat_data *data = 0; struct grub_fat_data *data = 0;
pupa_disk_t disk = device->disk; grub_disk_t disk = device->disk;
char *p = (char *) path; char *p = (char *) path;
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_ref (my_mod); grub_dl_ref (my_mod);
#endif #endif
data = pupa_fat_mount (disk); data = grub_fat_mount (disk);
if (! data) if (! data)
goto fail; goto fail;
do do
{ {
p = pupa_fat_find_dir (disk, data, p, hook); p = grub_fat_find_dir (disk, data, p, hook);
} }
while (p && pupa_errno == PUPA_ERR_NONE); while (p && grub_errno == GRUB_ERR_NONE);
fail: fail:
pupa_free (data); grub_free (data);
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_unref (my_mod); grub_dl_unref (my_mod);
#endif #endif
return pupa_errno; return grub_errno;
} }
static pupa_err_t static grub_err_t
pupa_fat_open (pupa_file_t file, const char *name) grub_fat_open (grub_file_t file, const char *name)
{ {
struct pupa_fat_data *data = 0; struct grub_fat_data *data = 0;
char *p = (char *) name; char *p = (char *) name;
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_ref (my_mod); grub_dl_ref (my_mod);
#endif #endif
data = pupa_fat_mount (file->device->disk); data = grub_fat_mount (file->device->disk);
if (! data) if (! data)
goto fail; goto fail;
do do
{ {
p = pupa_fat_find_dir (file->device->disk, data, p, 0); p = grub_fat_find_dir (file->device->disk, data, p, 0);
if (pupa_errno != PUPA_ERR_NONE) if (grub_errno != GRUB_ERR_NONE)
goto fail; goto fail;
} }
while (p); while (p);
if (data->attr & PUPA_FAT_ATTR_DIRECTORY) if (data->attr & GRUB_FAT_ATTR_DIRECTORY)
{ {
pupa_error (PUPA_ERR_BAD_FILE_TYPE, "not a file"); grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a file");
goto fail; goto fail;
} }
file->data = data; file->data = data;
file->size = data->file_size; file->size = data->file_size;
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
fail: fail:
pupa_free (data); grub_free (data);
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_unref (my_mod); grub_dl_unref (my_mod);
#endif #endif
return pupa_errno; return grub_errno;
} }
static pupa_ssize_t static grub_ssize_t
pupa_fat_read (pupa_file_t file, char *buf, pupa_ssize_t len) grub_fat_read (grub_file_t file, char *buf, grub_ssize_t len)
{ {
return pupa_fat_read_data (file->device->disk, file->data, file->read_hook, return grub_fat_read_data (file->device->disk, file->data, file->read_hook,
file->offset, len, buf); file->offset, len, buf);
} }
static pupa_err_t static grub_err_t
pupa_fat_close (pupa_file_t file) grub_fat_close (grub_file_t file)
{ {
pupa_free (file->data); grub_free (file->data);
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_unref (my_mod); grub_dl_unref (my_mod);
#endif #endif
return pupa_errno; return grub_errno;
} }
static pupa_err_t static grub_err_t
pupa_fat_label (pupa_device_t device, char **label) grub_fat_label (grub_device_t device, char **label)
{ {
struct pupa_fat_data *data; struct grub_fat_data *data;
pupa_disk_t disk = device->disk; grub_disk_t disk = device->disk;
pupa_ssize_t offset = -sizeof(struct pupa_fat_dir_entry); grub_ssize_t offset = -sizeof(struct grub_fat_dir_entry);
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_ref (my_mod); grub_dl_ref (my_mod);
#endif #endif
data = pupa_fat_mount (disk); data = grub_fat_mount (disk);
if (! data) if (! data)
goto fail; goto fail;
if (! (data->attr & PUPA_FAT_ATTR_DIRECTORY)) if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
{ {
pupa_error (PUPA_ERR_BAD_FILE_TYPE, "not a directory"); grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
return 0; return 0;
} }
while (1) while (1)
{ {
struct pupa_fat_dir_entry dir; struct grub_fat_dir_entry dir;
/* Adjust the offset. */ /* Adjust the offset. */
offset += sizeof (dir); offset += sizeof (dir);
/* Read a directory entry. */ /* Read a directory entry. */
if ((pupa_fat_read_data (disk, data, 0, if ((grub_fat_read_data (disk, data, 0,
offset, sizeof (dir), (char *) &dir) offset, sizeof (dir), (char *) &dir)
!= sizeof (dir)) != sizeof (dir))
|| dir.name[0] == 0) || dir.name[0] == 0)
{ {
if (pupa_errno != PUPA_ERR_NONE) if (grub_errno != GRUB_ERR_NONE)
goto fail; goto fail;
else else
{ {
*label = 0; *label = 0;
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
} }
if (dir.attr == PUPA_FAT_ATTR_VOLUME_ID) if (dir.attr == GRUB_FAT_ATTR_VOLUME_ID)
{ {
*label = pupa_strndup (dir.name, 11); *label = grub_strndup (dir.name, 11);
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
} }
@ -826,47 +826,47 @@ pupa_fat_label (pupa_device_t device, char **label)
fail: fail:
#ifndef PUPA_UTIL #ifndef GRUB_UTIL
pupa_dl_unref (my_mod); grub_dl_unref (my_mod);
#endif #endif
pupa_free (data); grub_free (data);
return pupa_errno; return grub_errno;
} }
static struct pupa_fs pupa_fat_fs = static struct grub_fs grub_fat_fs =
{ {
.name = "fat", .name = "fat",
.dir = pupa_fat_dir, .dir = grub_fat_dir,
.open = pupa_fat_open, .open = grub_fat_open,
.read = pupa_fat_read, .read = grub_fat_read,
.close = pupa_fat_close, .close = grub_fat_close,
.label = pupa_fat_label, .label = grub_fat_label,
.next = 0 .next = 0
}; };
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
void void
pupa_fat_init (void) grub_fat_init (void)
{ {
pupa_fs_register (&pupa_fat_fs); grub_fs_register (&grub_fat_fs);
} }
void void
pupa_fat_fini (void) grub_fat_fini (void)
{ {
pupa_fs_unregister (&pupa_fat_fs); grub_fs_unregister (&grub_fat_fs);
} }
#else /* ! PUPA_UTIL */ #else /* ! GRUB_UTIL */
PUPA_MOD_INIT GRUB_MOD_INIT
{ {
pupa_fs_register (&pupa_fat_fs); grub_fs_register (&grub_fat_fs);
my_mod = mod; my_mod = mod;
} }
PUPA_MOD_FINI GRUB_MOD_FINI
{ {
pupa_fs_unregister (&pupa_fat_fs); grub_fs_unregister (&grub_fat_fs);
} }
#endif /* ! PUPA_UTIL */ #endif /* ! GRUB_UTIL */

View file

@ -118,7 +118,7 @@ UNDSYMFILES += #{undsym}
#{@name}: #{pre_obj} #{mod_obj} #{@name}: #{pre_obj} #{mod_obj}
-rm -f $@ -rm -f $@
$(LD) -r -o $@ $^ $(LD) -r -o $@ $^
$(STRIP) --strip-unneeded -K pupa_mod_init -K pupa_mod_fini -R .note -R .comment $@ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
#{pre_obj}: #{objs_str} #{pre_obj}: #{objs_str}
-rm -f $@ -rm -f $@
@ -190,11 +190,11 @@ MOSTLYCLEANFILES += #{deps_str}
dir = File.dirname(src) dir = File.dirname(src)
"#{obj}: #{src} "#{obj}: #{src}
$(BUILD_CC) -I#{dir} -I$(srcdir)/#{dir} $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(#{prefix}_CFLAGS) -c -o $@ $< $(BUILD_CC) -I#{dir} -I$(srcdir)/#{dir} $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -c -o $@ $<
#{dep}: #{src} #{dep}: #{src}
set -e; \ set -e; \
$(BUILD_CC) -I#{dir} -I$(srcdir)/#{dir} $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DPUPA_UTIL=1 $(#{prefix}_CFLAGS) -M $< \ $(BUILD_CC) -I#{dir} -I$(srcdir)/#{dir} $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -M $< \
| sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \ | sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
[ -s $@ ] || rm -f $@ [ -s $@ ] || rm -f $@

View file

@ -19,10 +19,10 @@ deps="$2"
cat <<EOF cat <<EOF
/* This file is automatically generated by genmodsrc.sh. DO NOT EDIT! */ /* This file is automatically generated by genmodsrc.sh. DO NOT EDIT! */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -33,16 +33,16 @@ cat <<EOF
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/dl.h> #include <grub/dl.h>
EOF EOF
echo "PUPA_MOD_NAME(${mod_name});" echo "GRUB_MOD_NAME(${mod_name});"
for mod in `grep "^${mod_name}:" ${deps} | sed 's/^[^:]*://'`; do for mod in `grep "^${mod_name}:" ${deps} | sed 's/^[^:]*://'`; do
echo "PUPA_MOD_DEP(${mod});" echo "GRUB_MOD_DEP(${mod});"
done done

View file

@ -14,10 +14,10 @@
cat <<EOF cat <<EOF
/* This file is automatically generated by gensymlist.sh. DO NOT EDIT! */ /* This file is automatically generated by gensymlist.sh. DO NOT EDIT! */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -28,7 +28,7 @@ cat <<EOF
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
@ -41,7 +41,7 @@ done
cat <<EOF cat <<EOF
void void
pupa_register_exported_symbols (void) grub_register_exported_symbols (void)
{ {
EOF EOF
@ -60,6 +60,6 @@ cat <<EOF
}; };
for (p = tab; p->name; p++) for (p = tab; p->name; p++)
pupa_dl_register_symbol (p->name, p->addr, 0); grub_dl_register_symbol (p->name, p->addr, 0);
} }
EOF EOF

View file

@ -1,6 +1,6 @@
/* hello.c - test module for dynamic loading */ /* hello.c - test module for dynamic loading */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* Copyright (C) 2003 NIIBE Yutaka <gniibe@m17n.org> * Copyright (C) 2003 NIIBE Yutaka <gniibe@m17n.org>
* *
@ -19,30 +19,30 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/normal.h> #include <grub/normal.h>
static pupa_err_t static grub_err_t
pupa_cmd_hello (struct pupa_arg_list *state __attribute__ ((unused)), grub_cmd_hello (struct grub_arg_list *state __attribute__ ((unused)),
int argc __attribute__ ((unused)), int argc __attribute__ ((unused)),
char **args __attribute__ ((unused))) char **args __attribute__ ((unused)))
{ {
pupa_printf ("Hello World\n"); grub_printf ("Hello World\n");
return 0; return 0;
} }
PUPA_MOD_INIT GRUB_MOD_INIT
{ {
(void)mod; /* To stop warning. */ (void)mod; /* To stop warning. */
pupa_register_command ("hello", pupa_cmd_hello, PUPA_COMMAND_FLAG_BOTH, grub_register_command ("hello", grub_cmd_hello, GRUB_COMMAND_FLAG_BOTH,
"hello", "Say hello", 0); "hello", "Say hello", 0);
} }
PUPA_MOD_FINI GRUB_MOD_FINI
{ {
pupa_unregister_command ("hello"); grub_unregister_command ("hello");
} }

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,18 +13,18 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_ARG_HEADER #ifndef GRUB_ARG_HEADER
#define PUPA_ARG_HEADER 1 #define GRUB_ARG_HEADER 1
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/types.h> #include <grub/types.h>
enum pupa_arg_type enum grub_arg_type
{ {
ARG_TYPE_NONE, ARG_TYPE_NONE,
ARG_TYPE_STRING, ARG_TYPE_STRING,
@ -35,32 +35,32 @@ enum pupa_arg_type
ARG_TYPE_PATHNAME ARG_TYPE_PATHNAME
}; };
typedef enum pupa_arg_type pupa_arg_type_t; typedef enum grub_arg_type grub_arg_type_t;
/* Flags for the option field op pupa_arg_option. */ /* Flags for the option field op grub_arg_option. */
#define PUPA_ARG_OPTION_OPTIONAL 1 << 1 #define GRUB_ARG_OPTION_OPTIONAL 1 << 1
enum pupa_key_type enum grub_key_type
{ {
PUPA_KEY_ARG = -1, GRUB_KEY_ARG = -1,
PUPA_KEY_END = -2 GRUB_KEY_END = -2
}; };
typedef enum pupa_key_type pupa_arg_key_type_t; typedef enum grub_key_type grub_arg_key_type_t;
struct pupa_arg_option struct grub_arg_option
{ {
char *longarg; char *longarg;
char shortarg; char shortarg;
int flags; int flags;
char *doc; char *doc;
char *arg; char *arg;
pupa_arg_type_t type; grub_arg_type_t type;
}; };
struct pupa_arg_list struct grub_arg_list
{ {
int set; int set;
char *arg; char *arg;
}; };
#endif /* ! PUPA_ARG_HEADER */ #endif /* ! GRUB_ARG_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,12 +17,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_BOOT_HEADER #ifndef GRUB_BOOT_HEADER
#define PUPA_BOOT_HEADER 1 #define GRUB_BOOT_HEADER 1
#define PUPA_BOOT_VERSION_MAJOR 4 #define GRUB_BOOT_VERSION_MAJOR 4
#define PUPA_BOOT_VERSION_MINOR 0 #define GRUB_BOOT_VERSION_MINOR 0
#define PUPA_BOOT_VERSION ((PUPA_BOOT_VERSION_MINOR << 8) \ #define GRUB_BOOT_VERSION ((GRUB_BOOT_VERSION_MINOR << 8) \
| PUPA_BOOT_VERSION_MAJOR) | GRUB_BOOT_VERSION_MAJOR)
#endif /* ! PUPA_BOOT_HEADER */ #endif /* ! GRUB_BOOT_HEADER */

View file

@ -1,9 +1,9 @@
/* device.h - device manager */ /* device.h - device manager */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,31 +14,31 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_DEVICE_HEADER #ifndef GRUB_DEVICE_HEADER
#define PUPA_DEVICE_HEADER 1 #define GRUB_DEVICE_HEADER 1
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/err.h> #include <grub/err.h>
struct pupa_disk; struct grub_disk;
struct pupa_net; struct grub_net;
struct pupa_fs; struct grub_fs;
struct pupa_device struct grub_device
{ {
struct pupa_disk *disk; struct grub_disk *disk;
struct pupa_net *net; struct grub_net *net;
}; };
typedef struct pupa_device *pupa_device_t; typedef struct grub_device *grub_device_t;
pupa_device_t EXPORT_FUNC(pupa_device_open) (const char *name); grub_device_t EXPORT_FUNC(grub_device_open) (const char *name);
pupa_err_t EXPORT_FUNC(pupa_device_close) (pupa_device_t device); grub_err_t EXPORT_FUNC(grub_device_close) (grub_device_t device);
pupa_err_t EXPORT_FUNC(pupa_device_set_root) (const char *name); grub_err_t EXPORT_FUNC(grub_device_set_root) (const char *name);
const char *EXPORT_FUNC(pupa_device_get_root) (void); const char *EXPORT_FUNC(grub_device_get_root) (void);
#endif /* ! PUPA_DEVICE_HEADER */ #endif /* ! GRUB_DEVICE_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2003 Free Software Foundation, Inc. * Copyright (C) 2002, 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,22 +13,22 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_DISK_HEADER #ifndef GRUB_DISK_HEADER
#define PUPA_DISK_HEADER 1 #define GRUB_DISK_HEADER 1
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/device.h> #include <grub/device.h>
struct pupa_disk; struct grub_disk;
/* Disk device. */ /* Disk device. */
struct pupa_disk_dev struct grub_disk_dev
{ {
/* The device name. */ /* The device name. */
const char *name; const char *name;
@ -37,34 +37,34 @@ struct pupa_disk_dev
int (*iterate) (int (*hook) (const char *name)); int (*iterate) (int (*hook) (const char *name));
/* Open the device named NAME, and set up DISK. */ /* Open the device named NAME, and set up DISK. */
pupa_err_t (*open) (const char *name, struct pupa_disk *disk); grub_err_t (*open) (const char *name, struct grub_disk *disk);
/* Close the disk DISK. */ /* Close the disk DISK. */
void (*close) (struct pupa_disk *disk); void (*close) (struct grub_disk *disk);
/* Read SIZE sectors from the sector SECTOR of the disk DISK into BUF. */ /* Read SIZE sectors from the sector SECTOR of the disk DISK into BUF. */
pupa_err_t (*read) (struct pupa_disk *disk, unsigned long sector, grub_err_t (*read) (struct grub_disk *disk, unsigned long sector,
unsigned long size, char *buf); unsigned long size, char *buf);
/* Write SIZE sectors from BUF into the sector SECTOR of the disk DISK. */ /* Write SIZE sectors from BUF into the sector SECTOR of the disk DISK. */
pupa_err_t (*write) (struct pupa_disk *disk, unsigned long sector, grub_err_t (*write) (struct grub_disk *disk, unsigned long sector,
unsigned long size, const char *buf); unsigned long size, const char *buf);
/* The next disk device. */ /* The next disk device. */
struct pupa_disk_dev *next; struct grub_disk_dev *next;
}; };
typedef struct pupa_disk_dev *pupa_disk_dev_t; typedef struct grub_disk_dev *grub_disk_dev_t;
struct pupa_partition; struct grub_partition;
/* Disk. */ /* Disk. */
struct pupa_disk struct grub_disk
{ {
/* The disk name. */ /* The disk name. */
const char *name; const char *name;
/* The underlying disk device. */ /* The underlying disk device. */
pupa_disk_dev_t dev; grub_disk_dev_t dev;
/* The total number of sectors. */ /* The total number of sectors. */
unsigned long total_sectors; unsigned long total_sectors;
@ -76,7 +76,7 @@ struct pupa_disk
unsigned long id; unsigned long id;
/* The partition information. This is machine-specific. */ /* The partition information. This is machine-specific. */
struct pupa_partition *partition; struct grub_partition *partition;
/* Called when a sector was read. */ /* Called when a sector was read. */
void (*read_hook) (unsigned long sector, unsigned offset, unsigned length); void (*read_hook) (unsigned long sector, unsigned offset, unsigned length);
@ -84,40 +84,40 @@ struct pupa_disk
/* Device-specific data. */ /* Device-specific data. */
void *data; void *data;
}; };
typedef struct pupa_disk *pupa_disk_t; typedef struct grub_disk *grub_disk_t;
/* The sector size. */ /* The sector size. */
#define PUPA_DISK_SECTOR_SIZE 0x200 #define GRUB_DISK_SECTOR_SIZE 0x200
#define PUPA_DISK_SECTOR_BITS 9 #define GRUB_DISK_SECTOR_BITS 9
/* The maximum number of disk caches. */ /* The maximum number of disk caches. */
#define PUPA_DISK_CACHE_NUM 1021 #define GRUB_DISK_CACHE_NUM 1021
/* The size of a disk cache in sector units. */ /* The size of a disk cache in sector units. */
#define PUPA_DISK_CACHE_SIZE 8 #define GRUB_DISK_CACHE_SIZE 8
#define PUPA_DISK_CACHE_BITS 3 #define GRUB_DISK_CACHE_BITS 3
/* This is called from the memory manager. */ /* This is called from the memory manager. */
void pupa_disk_cache_invalidate_all (void); void grub_disk_cache_invalidate_all (void);
void EXPORT_FUNC(pupa_disk_dev_register) (pupa_disk_dev_t dev); void EXPORT_FUNC(grub_disk_dev_register) (grub_disk_dev_t dev);
void EXPORT_FUNC(pupa_disk_dev_unregister) (pupa_disk_dev_t dev); void EXPORT_FUNC(grub_disk_dev_unregister) (grub_disk_dev_t dev);
void EXPORT_FUNC(pupa_disk_dev_iterate) (int (*hook) (const char *name)); void EXPORT_FUNC(grub_disk_dev_iterate) (int (*hook) (const char *name));
pupa_disk_t EXPORT_FUNC(pupa_disk_open) (const char *name); grub_disk_t EXPORT_FUNC(grub_disk_open) (const char *name);
void EXPORT_FUNC(pupa_disk_close) (pupa_disk_t disk); void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk);
pupa_err_t EXPORT_FUNC(pupa_disk_read) (pupa_disk_t disk, grub_err_t EXPORT_FUNC(grub_disk_read) (grub_disk_t disk,
unsigned long sector, unsigned long sector,
unsigned long offset, unsigned long offset,
unsigned long size, unsigned long size,
char *buf); char *buf);
pupa_err_t EXPORT_FUNC(pupa_disk_write) (pupa_disk_t disk, grub_err_t EXPORT_FUNC(grub_disk_write) (grub_disk_t disk,
unsigned long sector, unsigned long sector,
unsigned long offset, unsigned long offset,
unsigned long size, unsigned long size,
const char *buf); const char *buf);
pupa_err_t EXPORT_FUNC(pupa_print_partinfo) (pupa_device_t disk, grub_err_t EXPORT_FUNC(grub_print_partinfo) (grub_device_t disk,
char *partname); char *partname);
#endif /* ! PUPA_DISK_HEADER */ #endif /* ! GRUB_DISK_HEADER */

View file

@ -1,9 +1,9 @@
/* dl.h - types and prototypes for loadable module support */ /* dl.h - types and prototypes for loadable module support */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,77 +14,77 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_DL_H #ifndef GRUB_DL_H
#define PUPA_DL_H 1 #define GRUB_DL_H 1
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/types.h> #include <grub/types.h>
#define PUPA_MOD_INIT \ #define GRUB_MOD_INIT \
static void pupa_mod_init (pupa_dl_t mod) __attribute__ ((unused)); \ static void grub_mod_init (grub_dl_t mod) __attribute__ ((unused)); \
static void \ static void \
pupa_mod_init (pupa_dl_t mod) grub_mod_init (grub_dl_t mod)
#define PUPA_MOD_FINI \ #define GRUB_MOD_FINI \
static void pupa_mod_fini (void) __attribute__ ((unused)); \ static void grub_mod_fini (void) __attribute__ ((unused)); \
static void \ static void \
pupa_mod_fini (void) grub_mod_fini (void)
#define PUPA_MOD_NAME(name) \ #define GRUB_MOD_NAME(name) \
__asm__ (".section .modname,\"S\"\n.string \"" #name "\"\n.previous") __asm__ (".section .modname,\"S\"\n.string \"" #name "\"\n.previous")
#define PUPA_MOD_DEP(name) \ #define GRUB_MOD_DEP(name) \
__asm__ (".section .moddeps,\"S\"\n.string \"" #name "\"\n.previous") __asm__ (".section .moddeps,\"S\"\n.string \"" #name "\"\n.previous")
struct pupa_dl_segment struct grub_dl_segment
{ {
struct pupa_dl_segment *next; struct grub_dl_segment *next;
void *addr; void *addr;
pupa_size_t size; grub_size_t size;
unsigned section; unsigned section;
}; };
typedef struct pupa_dl_segment *pupa_dl_segment_t; typedef struct grub_dl_segment *grub_dl_segment_t;
struct pupa_dl; struct grub_dl;
struct pupa_dl_dep struct grub_dl_dep
{ {
struct pupa_dl_dep *next; struct grub_dl_dep *next;
struct pupa_dl *mod; struct grub_dl *mod;
}; };
typedef struct pupa_dl_dep *pupa_dl_dep_t; typedef struct grub_dl_dep *grub_dl_dep_t;
struct pupa_dl struct grub_dl
{ {
char *name; char *name;
int ref_count; int ref_count;
pupa_dl_dep_t dep; grub_dl_dep_t dep;
pupa_dl_segment_t segment; grub_dl_segment_t segment;
void (*init) (struct pupa_dl *mod); void (*init) (struct grub_dl *mod);
void (*fini) (void); void (*fini) (void);
}; };
typedef struct pupa_dl *pupa_dl_t; typedef struct grub_dl *grub_dl_t;
pupa_dl_t EXPORT_FUNC(pupa_dl_load_file) (const char *filename); grub_dl_t EXPORT_FUNC(grub_dl_load_file) (const char *filename);
pupa_dl_t EXPORT_FUNC(pupa_dl_load) (const char *name); grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name);
pupa_dl_t pupa_dl_load_core (void *addr, pupa_size_t size); grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
int EXPORT_FUNC(pupa_dl_unload) (pupa_dl_t mod); int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
void pupa_dl_unload_unneeded (void); void grub_dl_unload_unneeded (void);
void pupa_dl_unload_all (void); void grub_dl_unload_all (void);
int EXPORT_FUNC(pupa_dl_ref) (pupa_dl_t mod); int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
int EXPORT_FUNC(pupa_dl_unref) (pupa_dl_t mod); int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
void EXPORT_FUNC(pupa_dl_iterate) (int (*hook) (pupa_dl_t mod)); void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod));
pupa_dl_t EXPORT_FUNC(pupa_dl_get) (const char *name); grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
pupa_err_t EXPORT_FUNC(pupa_dl_register_symbol) (const char *name, void *addr, grub_err_t EXPORT_FUNC(grub_dl_register_symbol) (const char *name, void *addr,
pupa_dl_t mod); grub_dl_t mod);
void *EXPORT_FUNC(pupa_dl_resolve_symbol) (const char *name); void *EXPORT_FUNC(grub_dl_resolve_symbol) (const char *name);
int pupa_arch_dl_check_header (void *ehdr, pupa_size_t size); int grub_arch_dl_check_header (void *ehdr, grub_size_t size);
pupa_err_t pupa_arch_dl_relocate_symbols (pupa_dl_t mod, void *ehdr); grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
#endif /* ! PUPA_DL_H */ #endif /* ! GRUB_DL_H */

View file

@ -17,40 +17,40 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */ 02111-1307 USA. */
#ifndef PUPA_ELF_H #ifndef GRUB_ELF_H
#define PUPA_ELF_H 1 #define GRUB_ELF_H 1
/* Standard ELF types. */ /* Standard ELF types. */
#include <pupa/types.h> #include <grub/types.h>
/* Type for a 16-bit quantity. */ /* Type for a 16-bit quantity. */
typedef pupa_uint16_t Elf32_Half; typedef grub_uint16_t Elf32_Half;
typedef pupa_uint16_t Elf64_Half; typedef grub_uint16_t Elf64_Half;
/* Types for signed and unsigned 32-bit quantities. */ /* Types for signed and unsigned 32-bit quantities. */
typedef pupa_uint32_t Elf32_Word; typedef grub_uint32_t Elf32_Word;
typedef pupa_int32_t Elf32_Sword; typedef grub_int32_t Elf32_Sword;
typedef pupa_uint32_t Elf64_Word; typedef grub_uint32_t Elf64_Word;
typedef pupa_int32_t Elf64_Sword; typedef grub_int32_t Elf64_Sword;
/* Types for signed and unsigned 64-bit quantities. */ /* Types for signed and unsigned 64-bit quantities. */
typedef pupa_uint64_t Elf32_Xword; typedef grub_uint64_t Elf32_Xword;
typedef pupa_int64_t Elf32_Sxword; typedef grub_int64_t Elf32_Sxword;
typedef pupa_uint64_t Elf64_Xword; typedef grub_uint64_t Elf64_Xword;
typedef pupa_int64_t Elf64_Sxword; typedef grub_int64_t Elf64_Sxword;
/* Type of addresses. */ /* Type of addresses. */
typedef pupa_uint32_t Elf32_Addr; typedef grub_uint32_t Elf32_Addr;
typedef pupa_uint64_t Elf64_Addr; typedef grub_uint64_t Elf64_Addr;
/* Type of file offsets. */ /* Type of file offsets. */
typedef pupa_uint32_t Elf32_Off; typedef grub_uint32_t Elf32_Off;
typedef pupa_uint64_t Elf64_Off; typedef grub_uint64_t Elf64_Off;
/* Type for section indices, which are 16-bit quantities. */ /* Type for section indices, which are 16-bit quantities. */
typedef pupa_uint16_t Elf32_Section; typedef grub_uint16_t Elf32_Section;
typedef pupa_uint16_t Elf64_Section; typedef grub_uint16_t Elf64_Section;
/* Type for version symbol information. */ /* Type for version symbol information. */
typedef Elf32_Half Elf32_Versym; typedef Elf32_Half Elf32_Versym;
@ -2310,4 +2310,4 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_X86_64_NUM 24 #define R_X86_64_NUM 24
#endif /* ! PUPA_ELF_H */ #endif /* ! GRUB_ELF_H */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,37 +13,37 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_ENV_HEADER #ifndef GRUB_ENV_HEADER
#define PUPA_ENV_HEADER 1 #define GRUB_ENV_HEADER 1
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/types.h> #include <grub/types.h>
struct pupa_env_var struct grub_env_var
{ {
char *name; char *name;
char *value; char *value;
pupa_err_t (*read_hook) (struct pupa_env_var *var, char **val); grub_err_t (*read_hook) (struct grub_env_var *var, char **val);
pupa_err_t (*write_hook) (struct pupa_env_var *var); grub_err_t (*write_hook) (struct grub_env_var *var);
struct pupa_env_var *next; struct grub_env_var *next;
struct pupa_env_var **prevp; struct grub_env_var **prevp;
struct pupa_env_var *sort_next; struct grub_env_var *sort_next;
struct pupa_env_var **sort_prevp; struct grub_env_var **sort_prevp;
}; };
pupa_err_t EXPORT_FUNC(pupa_env_set) (const char *var, const char *val); grub_err_t EXPORT_FUNC(grub_env_set) (const char *var, const char *val);
char *EXPORT_FUNC(pupa_env_get) (const char *name); char *EXPORT_FUNC(grub_env_get) (const char *name);
void EXPORT_FUNC(pupa_env_unset) (const char *name); void EXPORT_FUNC(grub_env_unset) (const char *name);
void EXPORT_FUNC(pupa_env_iterate) (int (* func) (struct pupa_env_var *var)); void EXPORT_FUNC(grub_env_iterate) (int (* func) (struct grub_env_var *var));
pupa_err_t EXPORT_FUNC(pupa_register_variable_hook) (const char *var, grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *var,
pupa_err_t (*read_hook) grub_err_t (*read_hook)
(struct pupa_env_var *var, char **val), (struct grub_env_var *var, char **val),
pupa_err_t (*write_hook) grub_err_t (*write_hook)
(struct pupa_env_var *var)); (struct grub_env_var *var));
#endif /* ! PUPA_ENV_HEADER */ #endif /* ! GRUB_ENV_HEADER */

View file

@ -1,9 +1,9 @@
/* err.h - error numbers and prototypes */ /* err.h - error numbers and prototypes */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,49 +14,49 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_ERR_HEADER #ifndef GRUB_ERR_HEADER
#define PUPA_ERR_HEADER 1 #define GRUB_ERR_HEADER 1
#include <pupa/symbol.h> #include <grub/symbol.h>
typedef enum typedef enum
{ {
PUPA_ERR_NONE = 0, GRUB_ERR_NONE = 0,
PUPA_ERR_BAD_MODULE, GRUB_ERR_BAD_MODULE,
PUPA_ERR_OUT_OF_MEMORY, GRUB_ERR_OUT_OF_MEMORY,
PUPA_ERR_BAD_FILE_TYPE, GRUB_ERR_BAD_FILE_TYPE,
PUPA_ERR_FILE_NOT_FOUND, GRUB_ERR_FILE_NOT_FOUND,
PUPA_ERR_FILE_READ_ERROR, GRUB_ERR_FILE_READ_ERROR,
PUPA_ERR_BAD_FILENAME, GRUB_ERR_BAD_FILENAME,
PUPA_ERR_UNKNOWN_FS, GRUB_ERR_UNKNOWN_FS,
PUPA_ERR_BAD_FS, GRUB_ERR_BAD_FS,
PUPA_ERR_BAD_NUMBER, GRUB_ERR_BAD_NUMBER,
PUPA_ERR_OUT_OF_RANGE, GRUB_ERR_OUT_OF_RANGE,
PUPA_ERR_UNKNOWN_DEVICE, GRUB_ERR_UNKNOWN_DEVICE,
PUPA_ERR_BAD_DEVICE, GRUB_ERR_BAD_DEVICE,
PUPA_ERR_READ_ERROR, GRUB_ERR_READ_ERROR,
PUPA_ERR_WRITE_ERROR, GRUB_ERR_WRITE_ERROR,
PUPA_ERR_UNKNOWN_COMMAND, GRUB_ERR_UNKNOWN_COMMAND,
PUPA_ERR_BAD_ARGUMENT, GRUB_ERR_BAD_ARGUMENT,
PUPA_ERR_BAD_PART_TABLE, GRUB_ERR_BAD_PART_TABLE,
PUPA_ERR_UNKNOWN_OS, GRUB_ERR_UNKNOWN_OS,
PUPA_ERR_BAD_OS, GRUB_ERR_BAD_OS,
PUPA_ERR_NO_KERNEL, GRUB_ERR_NO_KERNEL,
PUPA_ERR_BAD_FONT, GRUB_ERR_BAD_FONT,
PUPA_ERR_NOT_IMPLEMENTED_YET, GRUB_ERR_NOT_IMPLEMENTED_YET,
PUPA_ERR_SYMLINK_LOOP GRUB_ERR_SYMLINK_LOOP
} }
pupa_err_t; grub_err_t;
extern pupa_err_t EXPORT_VAR(pupa_errno); extern grub_err_t EXPORT_VAR(grub_errno);
extern char EXPORT_VAR(pupa_errmsg)[]; extern char EXPORT_VAR(grub_errmsg)[];
pupa_err_t EXPORT_FUNC(pupa_error) (pupa_err_t n, const char *fmt, ...); grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...);
void EXPORT_FUNC(pupa_fatal) (const char *fmt, ...) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn));
void EXPORT_FUNC(pupa_print_error) (void); void EXPORT_FUNC(grub_print_error) (void);
#endif /* ! PUPA_ERR_HEADER */ #endif /* ! GRUB_ERR_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,32 +13,32 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_FILE_HEADER #ifndef GRUB_FILE_HEADER
#define PUPA_FILE_HEADER 1 #define GRUB_FILE_HEADER 1
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/device.h> #include <grub/device.h>
#include <pupa/fs.h> #include <grub/fs.h>
/* File description. */ /* File description. */
struct pupa_file struct grub_file
{ {
/* The underlying device. */ /* The underlying device. */
pupa_device_t device; grub_device_t device;
/* The underlying filesystem. */ /* The underlying filesystem. */
pupa_fs_t fs; grub_fs_t fs;
/* The current offset. */ /* The current offset. */
pupa_ssize_t offset; grub_ssize_t offset;
/* The file size. */ /* The file size. */
pupa_ssize_t size; grub_ssize_t size;
/* Filesystem-specific data. */ /* Filesystem-specific data. */
void *data; void *data;
@ -46,28 +46,28 @@ struct pupa_file
/* This is called when a sector is read. Used only for a disk device. */ /* This is called when a sector is read. Used only for a disk device. */
void (*read_hook) (unsigned long sector, unsigned offset, unsigned length); void (*read_hook) (unsigned long sector, unsigned offset, unsigned length);
}; };
typedef struct pupa_file *pupa_file_t; typedef struct grub_file *grub_file_t;
/* Get a device name from NAME. */ /* Get a device name from NAME. */
char *EXPORT_FUNC(pupa_file_get_device_name) (const char *name); char *EXPORT_FUNC(grub_file_get_device_name) (const char *name);
pupa_file_t EXPORT_FUNC(pupa_file_open) (const char *name); grub_file_t EXPORT_FUNC(grub_file_open) (const char *name);
pupa_ssize_t EXPORT_FUNC(pupa_file_read) (pupa_file_t file, char *buf, grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, char *buf,
pupa_ssize_t len); grub_ssize_t len);
pupa_ssize_t EXPORT_FUNC(pupa_file_seek) (pupa_file_t file, grub_ssize_t EXPORT_FUNC(grub_file_seek) (grub_file_t file,
pupa_ssize_t offset); grub_ssize_t offset);
pupa_err_t EXPORT_FUNC(pupa_file_close) (pupa_file_t file); grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file);
static inline pupa_ssize_t static inline grub_ssize_t
pupa_file_size (const pupa_file_t file) grub_file_size (const grub_file_t file)
{ {
return file->size; return file->size;
} }
static inline pupa_ssize_t static inline grub_ssize_t
pupa_file_tell (const pupa_file_t file) grub_file_tell (const grub_file_t file)
{ {
return file->offset; return file->offset;
} }
#endif /* ! PUPA_FILE_HEADER */ #endif /* ! GRUB_FILE_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,14 +17,14 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_FONT_HEADER #ifndef GRUB_FONT_HEADER
#define PUPA_FONT_HEADER 1 #define GRUB_FONT_HEADER 1
#include <pupa/types.h> #include <grub/types.h>
#define PUPA_FONT_MAGIC "PPF\x7f" #define GRUB_FONT_MAGIC "PPF\x7f"
int pupa_font_get_glyph (pupa_uint32_t code, int grub_font_get_glyph (grub_uint32_t code,
unsigned char bitmap[32], unsigned *width); unsigned char bitmap[32], unsigned *width);
#endif /* ! PUPA_FONT_HEADER */ #endif /* ! GRUB_FONT_HEADER */

View file

@ -1,9 +1,9 @@
/* fs.h - filesystem manager */ /* fs.h - filesystem manager */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,62 +14,62 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_FS_HEADER #ifndef GRUB_FS_HEADER
#define PUPA_FS_HEADER 1 #define GRUB_FS_HEADER 1
#include <pupa/device.h> #include <grub/device.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/types.h> #include <grub/types.h>
/* Forward declaration is required, because of mutual reference. */ /* Forward declaration is required, because of mutual reference. */
struct pupa_file; struct grub_file;
/* Filesystem descriptor. */ /* Filesystem descriptor. */
struct pupa_fs struct grub_fs
{ {
/* My name. */ /* My name. */
const char *name; const char *name;
/* Call HOOK with each file under DIR. */ /* Call HOOK with each file under DIR. */
pupa_err_t (*dir) (pupa_device_t device, const char *path, grub_err_t (*dir) (grub_device_t device, const char *path,
int (*hook) (const char *filename, int dir)); int (*hook) (const char *filename, int dir));
/* Open a file named NAME and initialize FILE. */ /* Open a file named NAME and initialize FILE. */
pupa_err_t (*open) (struct pupa_file *file, const char *name); grub_err_t (*open) (struct grub_file *file, const char *name);
/* Read LEN bytes data from FILE into BUF. */ /* Read LEN bytes data from FILE into BUF. */
pupa_ssize_t (*read) (struct pupa_file *file, char *buf, pupa_ssize_t len); grub_ssize_t (*read) (struct grub_file *file, char *buf, grub_ssize_t len);
/* Close the file FILE. */ /* Close the file FILE. */
pupa_err_t (*close) (struct pupa_file *file); grub_err_t (*close) (struct grub_file *file);
/* Return the label of the device DEVICE in LABEL. The label is /* Return the label of the device DEVICE in LABEL. The label is
returned in a pupa_malloc'ed buffer and should be freed by the returned in a grub_malloc'ed buffer and should be freed by the
caller. */ caller. */
pupa_err_t (*label) (pupa_device_t device, char **label); grub_err_t (*label) (grub_device_t device, char **label);
/* The next filesystem. */ /* The next filesystem. */
struct pupa_fs *next; struct grub_fs *next;
}; };
typedef struct pupa_fs *pupa_fs_t; typedef struct grub_fs *grub_fs_t;
/* This is special, because block lists are not files in usual sense. */ /* This is special, because block lists are not files in usual sense. */
extern struct pupa_fs pupa_fs_blocklist; extern struct grub_fs grub_fs_blocklist;
void EXPORT_FUNC(pupa_fs_register) (pupa_fs_t fs); void EXPORT_FUNC(grub_fs_register) (grub_fs_t fs);
void EXPORT_FUNC(pupa_fs_unregister) (pupa_fs_t fs); void EXPORT_FUNC(grub_fs_unregister) (grub_fs_t fs);
void EXPORT_FUNC(pupa_fs_iterate) (int (*hook) (const pupa_fs_t fs)); void EXPORT_FUNC(grub_fs_iterate) (int (*hook) (const grub_fs_t fs));
pupa_fs_t EXPORT_FUNC(pupa_fs_probe) (pupa_device_t device); grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device);
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
void pupa_fat_init (void); void grub_fat_init (void);
void pupa_fat_fini (void); void grub_fat_fini (void);
void pupa_ext2_init (void); void grub_ext2_init (void);
void pupa_ext2_fini (void); void grub_ext2_fini (void);
#endif /* PUPA_UTIL */ #endif /* GRUB_UTIL */
#endif /* ! PUPA_FS_HEADER */ #endif /* ! GRUB_FS_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,16 +13,16 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_BIOSDISK_MACHINE_HEADER #ifndef GRUB_BIOSDISK_MACHINE_HEADER
#define PUPA_BIOSDISK_MACHINE_HEADER 1 #define GRUB_BIOSDISK_MACHINE_HEADER 1
#define PUPA_BIOSDISK_FLAG_LBA 1 #define GRUB_BIOSDISK_FLAG_LBA 1
struct pupa_biosdisk_data struct grub_biosdisk_data
{ {
int drive; int drive;
unsigned long cylinders; unsigned long cylinders;
@ -31,17 +31,17 @@ struct pupa_biosdisk_data
unsigned long flags; unsigned long flags;
}; };
int pupa_biosdisk_rw_int13_extensions (int ah, int drive, void *dap); int grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap);
int pupa_biosdisk_rw_standard (int ah, int drive, int coff, int hoff, int grub_biosdisk_rw_standard (int ah, int drive, int coff, int hoff,
int soff, int nsec, int segment); int soff, int nsec, int segment);
int pupa_biosdisk_check_int13_extensions (int drive); int grub_biosdisk_check_int13_extensions (int drive);
int pupa_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp); int grub_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp);
int pupa_biosdisk_get_diskinfo_standard (int drive, int grub_biosdisk_get_diskinfo_standard (int drive,
unsigned long *cylinders, unsigned long *cylinders,
unsigned long *heads, unsigned long *heads,
unsigned long *sectors); unsigned long *sectors);
int pupa_biosdisk_get_num_floppies (void); int grub_biosdisk_get_num_floppies (void);
void pupa_biosdisk_init (void); void grub_biosdisk_init (void);
#endif /* ! PUPA_BIOSDISK_MACHINE_HEADER */ #endif /* ! GRUB_BIOSDISK_MACHINE_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2002 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2002 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,69 +17,69 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_BOOT_MACHINE_HEADER #ifndef GRUB_BOOT_MACHINE_HEADER
#define PUPA_BOOT_MACHINE_HEADER 1 #define GRUB_BOOT_MACHINE_HEADER 1
/* The signature for bootloader. */ /* The signature for bootloader. */
#define PUPA_BOOT_MACHINE_SIGNATURE 0xaa55 #define GRUB_BOOT_MACHINE_SIGNATURE 0xaa55
/* The offset of the start of BPB (BIOS Parameter Block). */ /* The offset of the start of BPB (BIOS Parameter Block). */
#define PUPA_BOOT_MACHINE_BPB_START 0x3 #define GRUB_BOOT_MACHINE_BPB_START 0x3
/* The offset of the end of BPB (BIOS Parameter Block). */ /* The offset of the end of BPB (BIOS Parameter Block). */
#define PUPA_BOOT_MACHINE_BPB_END 0x3e #define GRUB_BOOT_MACHINE_BPB_END 0x3e
/* The offset of the major version. */ /* The offset of the major version. */
#define PUPA_BOOT_MACHINE_VER_MAJ 0x3e #define GRUB_BOOT_MACHINE_VER_MAJ 0x3e
/* The offset of BOOT_DRIVE. */ /* The offset of BOOT_DRIVE. */
#define PUPA_BOOT_MACHINE_BOOT_DRIVE 0x40 #define GRUB_BOOT_MACHINE_BOOT_DRIVE 0x40
/* The offset of FORCE_LBA. */ /* The offset of FORCE_LBA. */
#define PUPA_BOOT_MACHINE_FORCE_LBA 0x41 #define GRUB_BOOT_MACHINE_FORCE_LBA 0x41
/* The offset of KERNEL_ADDRESS. */ /* The offset of KERNEL_ADDRESS. */
#define PUPA_BOOT_MACHINE_KERNEL_ADDRESS 0x42 #define GRUB_BOOT_MACHINE_KERNEL_ADDRESS 0x42
/* The offset of KERNEL_SECTOR. */ /* The offset of KERNEL_SECTOR. */
#define PUPA_BOOT_MACHINE_KERNEL_SECTOR 0x44 #define GRUB_BOOT_MACHINE_KERNEL_SECTOR 0x44
/* The offset of KERNEL_SEGMENT. */ /* The offset of KERNEL_SEGMENT. */
#define PUPA_BOOT_MACHINE_KERNEL_SEGMENT 0x48 #define GRUB_BOOT_MACHINE_KERNEL_SEGMENT 0x48
/* The offset of a magic number used by Windows NT. */ /* The offset of a magic number used by Windows NT. */
#define PUPA_BOOT_MACHINE_WINDOWS_NT_MAGIC 0x1b8 #define GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC 0x1b8
/* The offset of the start of the partition table. */ /* The offset of the start of the partition table. */
#define PUPA_BOOT_MACHINE_PART_START 0x1be #define GRUB_BOOT_MACHINE_PART_START 0x1be
/* The offset of the end of the partition table. */ /* The offset of the end of the partition table. */
#define PUPA_BOOT_MACHINE_PART_END 0x1fe #define GRUB_BOOT_MACHINE_PART_END 0x1fe
/* The stack segment. */ /* The stack segment. */
#define PUPA_BOOT_MACHINE_STACK_SEG 0x2000 #define GRUB_BOOT_MACHINE_STACK_SEG 0x2000
/* The segment of disk buffer. The disk buffer MUST be 32K long and /* The segment of disk buffer. The disk buffer MUST be 32K long and
cannot straddle a 64K boundary. */ cannot straddle a 64K boundary. */
#define PUPA_BOOT_MACHINE_BUFFER_SEG 0x7000 #define GRUB_BOOT_MACHINE_BUFFER_SEG 0x7000
/* The address of drive parameters. */ /* The address of drive parameters. */
#define PUPA_BOOT_MACHINE_DRP_ADDR 0x7f00 #define GRUB_BOOT_MACHINE_DRP_ADDR 0x7f00
/* The size of drive parameters. */ /* The size of drive parameters. */
#define PUPA_BOOT_MACHINE_DRP_SIZE 0x42 #define GRUB_BOOT_MACHINE_DRP_SIZE 0x42
/* The flag for BIOS drive number to designate a hard disk vs. a /* The flag for BIOS drive number to designate a hard disk vs. a
floppy. */ floppy. */
#define PUPA_BOOT_MACHINE_BIOS_HD_FLAG 0x80 #define GRUB_BOOT_MACHINE_BIOS_HD_FLAG 0x80
/* The segment where the kernel is loaded. */ /* The segment where the kernel is loaded. */
#define PUPA_BOOT_MACHINE_KERNEL_SEG 0x800 #define GRUB_BOOT_MACHINE_KERNEL_SEG 0x800
/* The address where the kernel is loaded. */ /* The address where the kernel is loaded. */
#define PUPA_BOOT_MACHINE_KERNEL_ADDR (PUPA_BOOT_MACHINE_KERNEL_SEG << 4) #define GRUB_BOOT_MACHINE_KERNEL_ADDR (GRUB_BOOT_MACHINE_KERNEL_SEG << 4)
/* The size of a block list used in the kernel startup code. */ /* The size of a block list used in the kernel startup code. */
#define PUPA_BOOT_MACHINE_LIST_SIZE 8 #define GRUB_BOOT_MACHINE_LIST_SIZE 8
#endif /* ! BOOT_MACHINE_HEADER */ #endif /* ! BOOT_MACHINE_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,40 +17,40 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_CONSOLE_MACHINE_HEADER #ifndef GRUB_CONSOLE_MACHINE_HEADER
#define PUPA_CONSOLE_MACHINE_HEADER 1 #define GRUB_CONSOLE_MACHINE_HEADER 1
/* Define scan codes. */ /* Define scan codes. */
#define PUPA_CONSOLE_KEY_LEFT 0x4B00 #define GRUB_CONSOLE_KEY_LEFT 0x4B00
#define PUPA_CONSOLE_KEY_RIGHT 0x4D00 #define GRUB_CONSOLE_KEY_RIGHT 0x4D00
#define PUPA_CONSOLE_KEY_UP 0x4800 #define GRUB_CONSOLE_KEY_UP 0x4800
#define PUPA_CONSOLE_KEY_DOWN 0x5000 #define GRUB_CONSOLE_KEY_DOWN 0x5000
#define PUPA_CONSOLE_KEY_IC 0x5200 #define GRUB_CONSOLE_KEY_IC 0x5200
#define PUPA_CONSOLE_KEY_DC 0x5300 #define GRUB_CONSOLE_KEY_DC 0x5300
#define PUPA_CONSOLE_KEY_BACKSPACE 0x0008 #define GRUB_CONSOLE_KEY_BACKSPACE 0x0008
#define PUPA_CONSOLE_KEY_HOME 0x4700 #define GRUB_CONSOLE_KEY_HOME 0x4700
#define PUPA_CONSOLE_KEY_END 0x4F00 #define GRUB_CONSOLE_KEY_END 0x4F00
#define PUPA_CONSOLE_KEY_NPAGE 0x4900 #define GRUB_CONSOLE_KEY_NPAGE 0x4900
#define PUPA_CONSOLE_KEY_PPAGE 0x5100 #define GRUB_CONSOLE_KEY_PPAGE 0x5100
#ifndef ASM_FILE #ifndef ASM_FILE
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
/* These are global to share code between C and asm. */ /* These are global to share code between C and asm. */
extern pupa_uint8_t pupa_console_cur_color; extern grub_uint8_t grub_console_cur_color;
void pupa_console_real_putchar (int c); void grub_console_real_putchar (int c);
int EXPORT_FUNC(pupa_console_checkkey) (void); int EXPORT_FUNC(grub_console_checkkey) (void);
int EXPORT_FUNC(pupa_console_getkey) (void); int EXPORT_FUNC(grub_console_getkey) (void);
pupa_uint16_t pupa_console_getxy (void); grub_uint16_t grub_console_getxy (void);
void pupa_console_gotoxy (pupa_uint8_t x, pupa_uint8_t y); void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y);
void pupa_console_cls (void); void grub_console_cls (void);
void pupa_console_setcursor (int on); void grub_console_setcursor (int on);
/* Initialize the console system. */ /* Initialize the console system. */
void pupa_console_init (void); void grub_console_init (void);
#endif #endif
#endif /* ! PUPA_CONSOLE_MACHINE_HEADER */ #endif /* ! GRUB_CONSOLE_MACHINE_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,38 +17,38 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_INIT_MACHINE_HEADER #ifndef GRUB_INIT_MACHINE_HEADER
#define PUPA_INIT_MACHINE_HEADER 1 #define GRUB_INIT_MACHINE_HEADER 1
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
/* FIXME: Should these be declared in memory.h? */ /* FIXME: Should these be declared in memory.h? */
extern pupa_size_t EXPORT_VAR(pupa_lower_mem); extern grub_size_t EXPORT_VAR(grub_lower_mem);
extern pupa_size_t EXPORT_VAR(pupa_upper_mem); extern grub_size_t EXPORT_VAR(grub_upper_mem);
/* Get the memory size in KB. If EXTENDED is zero, return conventional /* Get the memory size in KB. If EXTENDED is zero, return conventional
memory, otherwise return extended memory. */ memory, otherwise return extended memory. */
pupa_uint16_t pupa_get_memsize (int extended); grub_uint16_t grub_get_memsize (int extended);
/* Get a packed EISA memory map. Lower 16 bits are between 1MB and 16MB /* Get a packed EISA memory map. Lower 16 bits are between 1MB and 16MB
in 1KB parts, and upper 16 bits are above 16MB in 64KB parts. */ in 1KB parts, and upper 16 bits are above 16MB in 64KB parts. */
pupa_uint32_t pupa_get_eisa_mmap (void); grub_uint32_t grub_get_eisa_mmap (void);
struct pupa_machine_mmap_entry struct grub_machine_mmap_entry
{ {
pupa_uint32_t size; grub_uint32_t size;
pupa_uint64_t addr; grub_uint64_t addr;
pupa_uint64_t len; grub_uint64_t len;
pupa_uint32_t type; grub_uint32_t type;
}; };
/* Get a memory map entry. Return next continuation value. Zero means /* Get a memory map entry. Return next continuation value. Zero means
the end. */ the end. */
pupa_uint32_t pupa_get_mmap_entry (struct pupa_machine_mmap_entry *entry, grub_uint32_t grub_get_mmap_entry (struct grub_machine_mmap_entry *entry,
pupa_uint32_t cont); grub_uint32_t cont);
/* Turn on/off Gate A20. */ /* Turn on/off Gate A20. */
void pupa_gate_a20 (int on); void grub_gate_a20 (int on);
#endif /* ! PUPA_INIT_MACHINE_HEADER */ #endif /* ! GRUB_INIT_MACHINE_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -20,43 +20,43 @@
#ifndef KERNEL_MACHINE_HEADER #ifndef KERNEL_MACHINE_HEADER
#define KERNEL_MACHINE_HEADER 1 #define KERNEL_MACHINE_HEADER 1
/* The offset of PUPA_TOTAL_MODULE_SIZE. */ /* The offset of GRUB_TOTAL_MODULE_SIZE. */
#define PUPA_KERNEL_MACHINE_TOTAL_MODULE_SIZE 0x8 #define GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE 0x8
/* The offset of PUPA_KERNEL_IMAGE_SIZE. */ /* The offset of GRUB_KERNEL_IMAGE_SIZE. */
#define PUPA_KERNEL_MACHINE_KERNEL_IMAGE_SIZE 0xc #define GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE 0xc
/* The offset of PUPA_COMPRESSED_SIZE. */ /* The offset of GRUB_COMPRESSED_SIZE. */
#define PUPA_KERNEL_MACHINE_COMPRESSED_SIZE 0x10 #define GRUB_KERNEL_MACHINE_COMPRESSED_SIZE 0x10
/* The offset of PUPA_INSTALL_DOS_PART. */ /* The offset of GRUB_INSTALL_DOS_PART. */
#define PUPA_KERNEL_MACHINE_INSTALL_DOS_PART 0x14 #define GRUB_KERNEL_MACHINE_INSTALL_DOS_PART 0x14
/* The offset of PUPA_INSTALL_BSD_PART. */ /* The offset of GRUB_INSTALL_BSD_PART. */
#define PUPA_KERNEL_MACHINE_INSTALL_BSD_PART 0x18 #define GRUB_KERNEL_MACHINE_INSTALL_BSD_PART 0x18
/* The offset of PUPA_PREFIX. */ /* The offset of GRUB_PREFIX. */
#define PUPA_KERNEL_MACHINE_PREFIX 0x1c #define GRUB_KERNEL_MACHINE_PREFIX 0x1c
/* The size of the first region which won't be compressed. */ /* The size of the first region which won't be compressed. */
#define PUPA_KERNEL_MACHINE_RAW_SIZE 0x400 #define GRUB_KERNEL_MACHINE_RAW_SIZE 0x400
#ifndef ASM_FILE #ifndef ASM_FILE
#include <pupa/types.h> #include <grub/types.h>
/* The DOS partition number of the installed partition. */ /* The DOS partition number of the installed partition. */
extern pupa_int32_t pupa_install_dos_part; extern grub_int32_t grub_install_dos_part;
/* The BSD partition number of the installed partition. */ /* The BSD partition number of the installed partition. */
extern pupa_int32_t pupa_install_bsd_part; extern grub_int32_t grub_install_bsd_part;
/* The prefix which points to the directory where PUPA modules and its /* The prefix which points to the directory where GRUB modules and its
configuration file are located. */ configuration file are located. */
extern char pupa_prefix[]; extern char grub_prefix[];
/* The boot BIOS drive number. */ /* The boot BIOS drive number. */
extern pupa_int32_t pupa_boot_drive; extern grub_int32_t grub_boot_drive;
#endif /* ! ASM_FILE */ #endif /* ! ASM_FILE */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,70 +17,70 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_LINUX_MACHINE_HEADER #ifndef GRUB_LINUX_MACHINE_HEADER
#define PUPA_LINUX_MACHINE_HEADER 1 #define GRUB_LINUX_MACHINE_HEADER 1
#define PUPA_LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ #define GRUB_LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */
#define PUPA_LINUX_DEFAULT_SETUP_SECTS 4 #define GRUB_LINUX_DEFAULT_SETUP_SECTS 4
#define PUPA_LINUX_FLAG_CAN_USE_HEAP 0x80 #define GRUB_LINUX_FLAG_CAN_USE_HEAP 0x80
#define PUPA_LINUX_INITRD_MAX_ADDRESS 0x37FFFFFF #define GRUB_LINUX_INITRD_MAX_ADDRESS 0x37FFFFFF
#define PUPA_LINUX_MAX_SETUP_SECTS 64 #define GRUB_LINUX_MAX_SETUP_SECTS 64
#define PUPA_LINUX_BOOT_LOADER_TYPE 0x72 #define GRUB_LINUX_BOOT_LOADER_TYPE 0x72
#define PUPA_LINUX_HEAP_END_OFFSET (0x9000 - 0x200) #define GRUB_LINUX_HEAP_END_OFFSET (0x9000 - 0x200)
#define PUPA_LINUX_BZIMAGE_ADDR 0x100000 #define GRUB_LINUX_BZIMAGE_ADDR 0x100000
#define PUPA_LINUX_ZIMAGE_ADDR 0x10000 #define GRUB_LINUX_ZIMAGE_ADDR 0x10000
#define PUPA_LINUX_OLD_REAL_MODE_ADDR 0x90000 #define GRUB_LINUX_OLD_REAL_MODE_ADDR 0x90000
#define PUPA_LINUX_SETUP_STACK 0x9000 #define GRUB_LINUX_SETUP_STACK 0x9000
#define PUPA_LINUX_FLAG_BIG_KERNEL 0x1 #define GRUB_LINUX_FLAG_BIG_KERNEL 0x1
/* Linux's video mode selection support. Actually I hate it! */ /* Linux's video mode selection support. Actually I hate it! */
#define PUPA_LINUX_VID_MODE_NORMAL 0xFFFF #define GRUB_LINUX_VID_MODE_NORMAL 0xFFFF
#define PUPA_LINUX_VID_MODE_EXTENDED 0xFFFE #define GRUB_LINUX_VID_MODE_EXTENDED 0xFFFE
#define PUPA_LINUX_VID_MODE_ASK 0xFFFD #define GRUB_LINUX_VID_MODE_ASK 0xFFFD
#define PUPA_LINUX_CL_OFFSET 0x9000 #define GRUB_LINUX_CL_OFFSET 0x9000
#define PUPA_LINUX_CL_END_OFFSET 0x90FF #define GRUB_LINUX_CL_END_OFFSET 0x90FF
#define PUPA_LINUX_SETUP_MOVE_SIZE 0x9100 #define GRUB_LINUX_SETUP_MOVE_SIZE 0x9100
#define PUPA_LINUX_CL_MAGIC 0xA33F #define GRUB_LINUX_CL_MAGIC 0xA33F
#ifndef ASM_FILE #ifndef ASM_FILE
/* For the Linux/i386 boot protocol version 2.03. */ /* For the Linux/i386 boot protocol version 2.03. */
struct linux_kernel_header struct linux_kernel_header
{ {
pupa_uint8_t code1[0x0020]; grub_uint8_t code1[0x0020];
pupa_uint16_t cl_magic; /* Magic number 0xA33F */ grub_uint16_t cl_magic; /* Magic number 0xA33F */
pupa_uint16_t cl_offset; /* The offset of command line */ grub_uint16_t cl_offset; /* The offset of command line */
pupa_uint8_t code2[0x01F1 - 0x0020 - 2 - 2]; grub_uint8_t code2[0x01F1 - 0x0020 - 2 - 2];
pupa_uint8_t setup_sects; /* The size of the setup in sectors */ grub_uint8_t setup_sects; /* The size of the setup in sectors */
pupa_uint16_t root_flags; /* If the root is mounted readonly */ grub_uint16_t root_flags; /* If the root is mounted readonly */
pupa_uint16_t syssize; /* obsolete */ grub_uint16_t syssize; /* obsolete */
pupa_uint16_t swap_dev; /* obsolete */ grub_uint16_t swap_dev; /* obsolete */
pupa_uint16_t ram_size; /* obsolete */ grub_uint16_t ram_size; /* obsolete */
pupa_uint16_t vid_mode; /* Video mode control */ grub_uint16_t vid_mode; /* Video mode control */
pupa_uint16_t root_dev; /* Default root device number */ grub_uint16_t root_dev; /* Default root device number */
pupa_uint16_t boot_flag; /* 0xAA55 magic number */ grub_uint16_t boot_flag; /* 0xAA55 magic number */
pupa_uint16_t jump; /* Jump instruction */ grub_uint16_t jump; /* Jump instruction */
pupa_uint32_t header; /* Magic signature "HdrS" */ grub_uint32_t header; /* Magic signature "HdrS" */
pupa_uint16_t version; /* Boot protocol version supported */ grub_uint16_t version; /* Boot protocol version supported */
pupa_uint32_t realmode_swtch; /* Boot loader hook */ grub_uint32_t realmode_swtch; /* Boot loader hook */
pupa_uint16_t start_sys; /* The load-low segment (obsolete) */ grub_uint16_t start_sys; /* The load-low segment (obsolete) */
pupa_uint16_t kernel_version; /* Points to kernel version string */ grub_uint16_t kernel_version; /* Points to kernel version string */
pupa_uint8_t type_of_loader; /* Boot loader identifier */ grub_uint8_t type_of_loader; /* Boot loader identifier */
pupa_uint8_t loadflags; /* Boot protocol option flags */ grub_uint8_t loadflags; /* Boot protocol option flags */
pupa_uint16_t setup_move_size; /* Move to high memory size */ grub_uint16_t setup_move_size; /* Move to high memory size */
pupa_uint32_t code32_start; /* Boot loader hook */ grub_uint32_t code32_start; /* Boot loader hook */
pupa_uint32_t ramdisk_image; /* initrd load address */ grub_uint32_t ramdisk_image; /* initrd load address */
pupa_uint32_t ramdisk_size; /* initrd size */ grub_uint32_t ramdisk_size; /* initrd size */
pupa_uint32_t bootsect_kludge; /* obsolete */ grub_uint32_t bootsect_kludge; /* obsolete */
pupa_uint16_t heap_end_ptr; /* Free memory after setup end */ grub_uint16_t heap_end_ptr; /* Free memory after setup end */
pupa_uint16_t pad1; /* Unused */ grub_uint16_t pad1; /* Unused */
char *cmd_line_ptr; /* Points to the kernel command line */ char *cmd_line_ptr; /* Points to the kernel command line */
pupa_uint32_t initrd_addr_max; /* Highest address for initrd */ grub_uint32_t initrd_addr_max; /* Highest address for initrd */
} __attribute__ ((packed)); } __attribute__ ((packed));
#endif /* ! ASM_FILE */ #endif /* ! ASM_FILE */
#endif /* ! PUPA_LINUX_MACHINE_HEADER */ #endif /* ! GRUB_LINUX_MACHINE_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,34 +17,34 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_LOADER_MACHINE_HEADER #ifndef GRUB_LOADER_MACHINE_HEADER
#define PUPA_LOADER_MACHINE_HEADER 1 #define GRUB_LOADER_MACHINE_HEADER 1
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/machine/multiboot.h> #include <grub/machine/multiboot.h>
extern pupa_uint32_t EXPORT_VAR(pupa_linux_prot_size); extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size);
extern char *EXPORT_VAR(pupa_linux_tmp_addr); extern char *EXPORT_VAR(grub_linux_tmp_addr);
extern char *EXPORT_VAR(pupa_linux_real_addr); extern char *EXPORT_VAR(grub_linux_real_addr);
void EXPORT_FUNC(pupa_linux_boot_zimage) (void) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_linux_boot_zimage) (void) __attribute__ ((noreturn));
void EXPORT_FUNC(pupa_linux_boot_bzimage) (void) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_linux_boot_bzimage) (void) __attribute__ ((noreturn));
/* This is an asm part of the chainloader. */ /* This is an asm part of the chainloader. */
void EXPORT_FUNC(pupa_chainloader_real_boot) (int drive, void *part_addr) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_chainloader_real_boot) (int drive, void *part_addr) __attribute__ ((noreturn));
/* The asm part of the multiboot loader. */ /* The asm part of the multiboot loader. */
void EXPORT_FUNC(pupa_multiboot_real_boot) (pupa_addr_t entry, void EXPORT_FUNC(grub_multiboot_real_boot) (grub_addr_t entry,
struct pupa_multiboot_info *mbi) struct grub_multiboot_info *mbi)
__attribute__ ((noreturn)); __attribute__ ((noreturn));
/* It is necessary to export these functions, because normal mode commands /* It is necessary to export these functions, because normal mode commands
reuse rescue mode commands. */ reuse rescue mode commands. */
void pupa_rescue_cmd_chainloader (int argc, char *argv[]); void grub_rescue_cmd_chainloader (int argc, char *argv[]);
void pupa_rescue_cmd_linux (int argc, char *argv[]); void grub_rescue_cmd_linux (int argc, char *argv[]);
void pupa_rescue_cmd_initrd (int argc, char *argv[]); void grub_rescue_cmd_initrd (int argc, char *argv[]);
void pupa_rescue_cmd_multiboot (int argc, char *argv[]); void grub_rescue_cmd_multiboot (int argc, char *argv[]);
void pupa_rescue_cmd_module (int argc, char *argv[]); void grub_rescue_cmd_module (int argc, char *argv[]);
#endif /* ! PUPA_LOADER_MACHINE_HEADER */ #endif /* ! GRUB_LOADER_MACHINE_HEADER */

View file

@ -1,6 +1,6 @@
/* memory.h - describe the memory map */ /* memory.h - describe the memory map */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,50 +18,50 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_MEMORY_MACHINE_HEADER #ifndef GRUB_MEMORY_MACHINE_HEADER
#define PUPA_MEMORY_MACHINE_HEADER 1 #define GRUB_MEMORY_MACHINE_HEADER 1
/* The scratch buffer used in real mode code. */ /* The scratch buffer used in real mode code. */
#define PUPA_MEMORY_MACHINE_SCRATCH_ADDR 0x68000 #define GRUB_MEMORY_MACHINE_SCRATCH_ADDR 0x68000
#define PUPA_MEMORY_MACHINE_SCRATCH_SEG (PUPA_MEMORY_MACHINE_SCRATCH_ADDR >> 4) #define GRUB_MEMORY_MACHINE_SCRATCH_SEG (GRUB_MEMORY_MACHINE_SCRATCH_ADDR >> 4)
#define PUPA_MEMORY_MACHINE_SCRATCH_SIZE 0x10000 #define GRUB_MEMORY_MACHINE_SCRATCH_SIZE 0x10000
/* The real mode stack. */ /* The real mode stack. */
#define PUPA_MEMORY_MACHINE_REAL_STACK (0x2000 - 0x10) #define GRUB_MEMORY_MACHINE_REAL_STACK (0x2000 - 0x10)
/* The size of the protect mode stack. */ /* The size of the protect mode stack. */
#define PUPA_MEMORY_MACHINE_PROT_STACK_SIZE 0x8000 #define GRUB_MEMORY_MACHINE_PROT_STACK_SIZE 0x8000
/* The protected mode stack. */ /* The protected mode stack. */
#define PUPA_MEMORY_MACHINE_PROT_STACK \ #define GRUB_MEMORY_MACHINE_PROT_STACK \
(PUPA_MEMORY_MACHINE_SCRATCH_ADDR + PUPA_MEMORY_MACHINE_SCRATCH_SIZE \ (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + GRUB_MEMORY_MACHINE_SCRATCH_SIZE \
+ PUPA_MEMORY_MACHINE_PROT_STACK_SIZE - 0x10) + GRUB_MEMORY_MACHINE_PROT_STACK_SIZE - 0x10)
/* The memory area where PUPA uses its own purpose. */ /* The memory area where GRUB uses its own purpose. */
#define PUPA_MEMORY_MACHINE_RESERVED_START \ #define GRUB_MEMORY_MACHINE_RESERVED_START \
PUPA_MEMORY_MACHINE_SCRATCH_ADDR GRUB_MEMORY_MACHINE_SCRATCH_ADDR
#define PUPA_MEMORY_MACHINE_RESERVED_END \ #define GRUB_MEMORY_MACHINE_RESERVED_END \
(PUPA_MEMORY_MACHINE_PROT_STACK + 0x10) (GRUB_MEMORY_MACHINE_PROT_STACK + 0x10)
/* The address of a partition table passed to another boot loader. */ /* The address of a partition table passed to another boot loader. */
#define PUPA_MEMORY_MACHINE_PART_TABLE_ADDR 0x7be #define GRUB_MEMORY_MACHINE_PART_TABLE_ADDR 0x7be
/* The address where another boot loader is loaded. */ /* The address where another boot loader is loaded. */
#define PUPA_MEMORY_MACHINE_BOOT_LOADER_ADDR 0x7c00 #define GRUB_MEMORY_MACHINE_BOOT_LOADER_ADDR 0x7c00
/* The flag for protected mode. */ /* The flag for protected mode. */
#define PUPA_MEMORY_MACHINE_CR0_PE_ON 0x1 #define GRUB_MEMORY_MACHINE_CR0_PE_ON 0x1
/* The code segment of the protected mode. */ /* The code segment of the protected mode. */
#define PUPA_MEMORY_MACHINE_PROT_MODE_CSEG 0x8 #define GRUB_MEMORY_MACHINE_PROT_MODE_CSEG 0x8
/* The data segment of the protected mode. */ /* The data segment of the protected mode. */
#define PUPA_MEMORY_MACHINE_PROT_MODE_DSEG 0x10 #define GRUB_MEMORY_MACHINE_PROT_MODE_DSEG 0x10
/* The code segment of the pseudo real mode. */ /* The code segment of the pseudo real mode. */
#define PUPA_MEMORY_MACHINE_PSEUDO_REAL_CSEG 0x18 #define GRUB_MEMORY_MACHINE_PSEUDO_REAL_CSEG 0x18
/* The data segment of the pseudo real mode. */ /* The data segment of the pseudo real mode. */
#define PUPA_MEMORY_MACHINE_PSEUDO_REAL_DSEG 0x20 #define GRUB_MEMORY_MACHINE_PSEUDO_REAL_DSEG 0x20
#endif /* ! PUPA_MEMORY_MACHINE_HEADER */ #endif /* ! GRUB_MEMORY_MACHINE_HEADER */

View file

@ -1,6 +1,6 @@
/* multiboot.h - multiboot header file. */ /* multiboot.h - multiboot header file. */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,167 +18,167 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_MULTIBOOT_MACHINE_HEADER #ifndef GRUB_MULTIBOOT_MACHINE_HEADER
#define PUPA_MULTIBOOT_MACHINE_HEADER 1 #define GRUB_MULTIBOOT_MACHINE_HEADER 1
/* How many bytes from the start of the file we search for the header. */ /* How many bytes from the start of the file we search for the header. */
#define PUPA_MB_SEARCH 8192 #define GRUB_MB_SEARCH 8192
/* The magic field should contain this. */ /* The magic field should contain this. */
#define PUPA_MB_MAGIC 0x1BADB002 #define GRUB_MB_MAGIC 0x1BADB002
/* This should be in %eax. */ /* This should be in %eax. */
#define PUPA_MB_MAGIC2 0x2BADB002 #define GRUB_MB_MAGIC2 0x2BADB002
/* The bits in the required part of flags field we don't support. */ /* The bits in the required part of flags field we don't support. */
#define PUPA_MB_UNSUPPORTED 0x0000fffc #define GRUB_MB_UNSUPPORTED 0x0000fffc
/* Alignment of multiboot modules. */ /* Alignment of multiboot modules. */
#define PUPA_MB_MOD_ALIGN 0x00001000 #define GRUB_MB_MOD_ALIGN 0x00001000
/* /*
* Flags set in the 'flags' member of the multiboot header. * Flags set in the 'flags' member of the multiboot header.
*/ */
/* Align all boot modules on i386 page (4KB) boundaries. */ /* Align all boot modules on i386 page (4KB) boundaries. */
#define PUPA_MB_PAGE_ALIGN 0x00000001 #define GRUB_MB_PAGE_ALIGN 0x00000001
/* Must pass memory information to OS. */ /* Must pass memory information to OS. */
#define PUPA_MB_MEMORY_INFO 0x00000002 #define GRUB_MB_MEMORY_INFO 0x00000002
/* Must pass video information to OS. */ /* Must pass video information to OS. */
#define PUPA_MB_VIDEO_MODE 0x00000004 #define GRUB_MB_VIDEO_MODE 0x00000004
/* This flag indicates the use of the address fields in the header. */ /* This flag indicates the use of the address fields in the header. */
#define PUPA_MB_AOUT_KLUDGE 0x00010000 #define GRUB_MB_AOUT_KLUDGE 0x00010000
/* /*
* Flags to be set in the 'flags' member of the multiboot info structure. * Flags to be set in the 'flags' member of the multiboot info structure.
*/ */
/* is there basic lower/upper memory information? */ /* is there basic lower/upper memory information? */
#define PUPA_MB_INFO_MEMORY 0x00000001 #define GRUB_MB_INFO_MEMORY 0x00000001
/* is there a boot device set? */ /* is there a boot device set? */
#define PUPA_MB_INFO_BOOTDEV 0x00000002 #define GRUB_MB_INFO_BOOTDEV 0x00000002
/* is the command-line defined? */ /* is the command-line defined? */
#define PUPA_MB_INFO_CMDLINE 0x00000004 #define GRUB_MB_INFO_CMDLINE 0x00000004
/* are there modules to do something with? */ /* are there modules to do something with? */
#define PUPA_MB_INFO_MODS 0x00000008 #define GRUB_MB_INFO_MODS 0x00000008
/* These next two are mutually exclusive */ /* These next two are mutually exclusive */
/* is there a symbol table loaded? */ /* is there a symbol table loaded? */
#define PUPA_MB_INFO_AOUT_SYMS 0x00000010 #define GRUB_MB_INFO_AOUT_SYMS 0x00000010
/* is there an ELF section header table? */ /* is there an ELF section header table? */
#define PUPA_MB_INFO_ELF_SHDR 0x00000020 #define GRUB_MB_INFO_ELF_SHDR 0x00000020
/* is there a full memory map? */ /* is there a full memory map? */
#define PUPA_MB_INFO_MEM_MAP 0x00000040 #define GRUB_MB_INFO_MEM_MAP 0x00000040
/* Is there drive info? */ /* Is there drive info? */
#define PUPA_MB_INFO_DRIVE_INFO 0x00000080 #define GRUB_MB_INFO_DRIVE_INFO 0x00000080
/* Is there a config table? */ /* Is there a config table? */
#define PUPA_MB_INFO_CONFIG_TABLE 0x00000100 #define GRUB_MB_INFO_CONFIG_TABLE 0x00000100
/* Is there a boot loader name? */ /* Is there a boot loader name? */
#define PUPA_MB_INFO_BOOT_LOADER_NAME 0x00000200 #define GRUB_MB_INFO_BOOT_LOADER_NAME 0x00000200
/* Is there a APM table? */ /* Is there a APM table? */
#define PUPA_MB_INFO_APM_TABLE 0x00000400 #define GRUB_MB_INFO_APM_TABLE 0x00000400
/* Is there video information? */ /* Is there video information? */
#define PUPA_MB_INFO_VIDEO_INFO 0x00000800 #define GRUB_MB_INFO_VIDEO_INFO 0x00000800
#ifndef ASM_FILE #ifndef ASM_FILE
#include <pupa/types.h> #include <grub/types.h>
struct pupa_multiboot_header struct grub_multiboot_header
{ {
/* Must be PUPA_MB_MAGIC - see above. */ /* Must be GRUB_MB_MAGIC - see above. */
pupa_uint32_t magic; grub_uint32_t magic;
/* Feature flags. */ /* Feature flags. */
pupa_uint32_t flags; grub_uint32_t flags;
/* The above fields plus this one must equal 0 mod 2^32. */ /* The above fields plus this one must equal 0 mod 2^32. */
pupa_uint32_t checksum; grub_uint32_t checksum;
/* These are only valid if PUPA_MB_AOUT_KLUDGE is set. */ /* These are only valid if GRUB_MB_AOUT_KLUDGE is set. */
pupa_uint32_t header_addr; grub_uint32_t header_addr;
pupa_uint32_t load_addr; grub_uint32_t load_addr;
pupa_uint32_t load_end_addr; grub_uint32_t load_end_addr;
pupa_uint32_t bss_end_addr; grub_uint32_t bss_end_addr;
pupa_uint32_t entry_addr; grub_uint32_t entry_addr;
/* These are only valid if PUPA_MB_VIDEO_MODE is set. */ /* These are only valid if GRUB_MB_VIDEO_MODE is set. */
pupa_uint32_t mode_type; grub_uint32_t mode_type;
pupa_uint32_t width; grub_uint32_t width;
pupa_uint32_t height; grub_uint32_t height;
pupa_uint32_t depth; grub_uint32_t depth;
}; };
struct pupa_multiboot_info struct grub_multiboot_info
{ {
/* MultiBoot info version number */ /* MultiBoot info version number */
pupa_uint32_t flags; grub_uint32_t flags;
/* Available memory from BIOS */ /* Available memory from BIOS */
pupa_uint32_t mem_lower; grub_uint32_t mem_lower;
pupa_uint32_t mem_upper; grub_uint32_t mem_upper;
/* "root" partition */ /* "root" partition */
pupa_uint32_t boot_device; grub_uint32_t boot_device;
/* Kernel command line */ /* Kernel command line */
pupa_uint32_t cmdline; grub_uint32_t cmdline;
/* Boot-Module list */ /* Boot-Module list */
pupa_uint32_t mods_count; grub_uint32_t mods_count;
pupa_uint32_t mods_addr; grub_uint32_t mods_addr;
pupa_uint32_t syms[4]; grub_uint32_t syms[4];
/* Memory Mapping buffer */ /* Memory Mapping buffer */
pupa_uint32_t mmap_length; grub_uint32_t mmap_length;
pupa_uint32_t mmap_addr; grub_uint32_t mmap_addr;
/* Drive Info buffer */ /* Drive Info buffer */
pupa_uint32_t drives_length; grub_uint32_t drives_length;
pupa_uint32_t drives_addr; grub_uint32_t drives_addr;
/* ROM configuration table */ /* ROM configuration table */
pupa_uint32_t config_table; grub_uint32_t config_table;
/* Boot Loader Name */ /* Boot Loader Name */
pupa_uint32_t boot_loader_name; grub_uint32_t boot_loader_name;
/* APM table */ /* APM table */
pupa_uint32_t apm_table; grub_uint32_t apm_table;
/* Video */ /* Video */
pupa_uint32_t vbe_control_info; grub_uint32_t vbe_control_info;
pupa_uint32_t vbe_mode_info; grub_uint32_t vbe_mode_info;
pupa_uint16_t vbe_mode; grub_uint16_t vbe_mode;
pupa_uint16_t vbe_interface_seg; grub_uint16_t vbe_interface_seg;
pupa_uint16_t vbe_interface_off; grub_uint16_t vbe_interface_off;
pupa_uint16_t vbe_interface_len; grub_uint16_t vbe_interface_len;
}; };
struct pupa_mod_list struct grub_mod_list
{ {
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
pupa_uint32_t mod_start; grub_uint32_t mod_start;
pupa_uint32_t mod_end; grub_uint32_t mod_end;
/* Module command line */ /* Module command line */
pupa_uint32_t cmdline; grub_uint32_t cmdline;
/* padding to take it to 16 bytes (must be zero) */ /* padding to take it to 16 bytes (must be zero) */
pupa_uint32_t pad; grub_uint32_t pad;
}; };
#endif /* ! ASM_FILE */ #endif /* ! ASM_FILE */
#endif /* ! PUPA_MULTIBOOT_MACHINE_HEADER */ #endif /* ! GRUB_MULTIBOOT_MACHINE_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,160 +13,160 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_PARTITION_HEADER #ifndef GRUB_PARTITION_HEADER
#define PUPA_PARTITION_HEADER 1 #define GRUB_PARTITION_HEADER 1
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/err.h> #include <grub/err.h>
/* The signature. */ /* The signature. */
#define PUPA_PARTITION_SIGNATURE 0xaa55 #define GRUB_PARTITION_SIGNATURE 0xaa55
/* This is not a flag actually, but used as if it were a flag. */ /* This is not a flag actually, but used as if it were a flag. */
#define PUPA_PARTITION_TYPE_HIDDEN_FLAG 0x10 #define GRUB_PARTITION_TYPE_HIDDEN_FLAG 0x10
/* DOS partition types. */ /* DOS partition types. */
#define PUPA_PARTITION_TYPE_NONE 0 #define GRUB_PARTITION_TYPE_NONE 0
#define PUPA_PARTITION_TYPE_FAT12 1 #define GRUB_PARTITION_TYPE_FAT12 1
#define PUPA_PARTITION_TYPE_FAT16_LT32M 4 #define GRUB_PARTITION_TYPE_FAT16_LT32M 4
#define PUPA_PARTITION_TYPE_EXTENDED 5 #define GRUB_PARTITION_TYPE_EXTENDED 5
#define PUPA_PARTITION_TYPE_FAT16_GT32M 6 #define GRUB_PARTITION_TYPE_FAT16_GT32M 6
#define PUPA_PARTITION_TYPE_FAT32 0xb #define GRUB_PARTITION_TYPE_FAT32 0xb
#define PUPA_PARTITION_TYPE_FAT32_LBA 0xc #define GRUB_PARTITION_TYPE_FAT32_LBA 0xc
#define PUPA_PARTITION_TYPE_FAT16_LBA 0xe #define GRUB_PARTITION_TYPE_FAT16_LBA 0xe
#define PUPA_PARTITION_TYPE_WIN95_EXTENDED 0xf #define GRUB_PARTITION_TYPE_WIN95_EXTENDED 0xf
#define PUPA_PARTITION_TYPE_EZD 0x55 #define GRUB_PARTITION_TYPE_EZD 0x55
#define PUPA_PARTITION_TYPE_MINIX 0x80 #define GRUB_PARTITION_TYPE_MINIX 0x80
#define PUPA_PARTITION_TYPE_LINUX_MINIX 0x81 #define GRUB_PARTITION_TYPE_LINUX_MINIX 0x81
#define PUPA_PARTITION_TYPE_EXT2FS 0x83 #define GRUB_PARTITION_TYPE_EXT2FS 0x83
#define PUPA_PARTITION_TYPE_LINUX_EXTENDED 0x85 #define GRUB_PARTITION_TYPE_LINUX_EXTENDED 0x85
#define PUPA_PARTITION_TYPE_VSTAFS 0x9e #define GRUB_PARTITION_TYPE_VSTAFS 0x9e
#define PUPA_PARTITION_TYPE_FREEBSD 0xa5 #define GRUB_PARTITION_TYPE_FREEBSD 0xa5
#define PUPA_PARTITION_TYPE_OPENBSD 0xa6 #define GRUB_PARTITION_TYPE_OPENBSD 0xa6
#define PUPA_PARTITION_TYPE_NETBSD 0xa9 #define GRUB_PARTITION_TYPE_NETBSD 0xa9
#define PUPA_PARTITION_TYPE_LINUX_RAID 0xfd #define GRUB_PARTITION_TYPE_LINUX_RAID 0xfd
/* Constants for BSD disk label. */ /* Constants for BSD disk label. */
#define PUPA_PARTITION_BSD_LABEL_SECTOR 1 #define GRUB_PARTITION_BSD_LABEL_SECTOR 1
#define PUPA_PARTITION_BSD_LABEL_MAGIC 0x82564557 #define GRUB_PARTITION_BSD_LABEL_MAGIC 0x82564557
#define PUPA_PARTITION_BSD_MAX_ENTRIES 8 #define GRUB_PARTITION_BSD_MAX_ENTRIES 8
/* BSD partition types. */ /* BSD partition types. */
#define PUPA_PARTITION_BSD_TYPE_UNUSED 0 #define GRUB_PARTITION_BSD_TYPE_UNUSED 0
#define PUPA_PARTITION_BSD_TYPE_SWAP 1 #define GRUB_PARTITION_BSD_TYPE_SWAP 1
#define PUPA_PARTITION_BSD_TYPE_V6 2 #define GRUB_PARTITION_BSD_TYPE_V6 2
#define PUPA_PARTITION_BSD_TYPE_V7 3 #define GRUB_PARTITION_BSD_TYPE_V7 3
#define PUPA_PARTITION_BSD_TYPE_SYSV 4 #define GRUB_PARTITION_BSD_TYPE_SYSV 4
#define PUPA_PARTITION_BSD_TYPE_V71K 5 #define GRUB_PARTITION_BSD_TYPE_V71K 5
#define PUPA_PARTITION_BSD_TYPE_V8 6 #define GRUB_PARTITION_BSD_TYPE_V8 6
#define PUPA_PARTITION_BSD_TYPE_BSDFFS 7 #define GRUB_PARTITION_BSD_TYPE_BSDFFS 7
#define PUPA_PARTITION_BSD_TYPE_MSDOS 8 #define GRUB_PARTITION_BSD_TYPE_MSDOS 8
#define PUPA_PARTITION_BSD_TYPE_BSDLFS 9 #define GRUB_PARTITION_BSD_TYPE_BSDLFS 9
#define PUPA_PARTITION_BSD_TYPE_OTHER 10 #define GRUB_PARTITION_BSD_TYPE_OTHER 10
#define PUPA_PARTITION_BSD_TYPE_HPFS 11 #define GRUB_PARTITION_BSD_TYPE_HPFS 11
#define PUPA_PARTITION_BSD_TYPE_ISO9660 12 #define GRUB_PARTITION_BSD_TYPE_ISO9660 12
#define PUPA_PARTITION_BSD_TYPE_BOOT 13 #define GRUB_PARTITION_BSD_TYPE_BOOT 13
/* FreeBSD-specific types. */ /* FreeBSD-specific types. */
#define PUPA_PARTITION_FREEBSD_TYPE_VINUM 14 #define GRUB_PARTITION_FREEBSD_TYPE_VINUM 14
#define PUPA_PARTITION_FREEBSD_TYPE_RAID 15 #define GRUB_PARTITION_FREEBSD_TYPE_RAID 15
#define PUPA_PARTITION_FREEBSD_TYPE_JFS2 21 #define GRUB_PARTITION_FREEBSD_TYPE_JFS2 21
/* NetBSD-specific types. */ /* NetBSD-specific types. */
#define PUPA_PARTITION_NETBSD_TYPE_ADOS 14 #define GRUB_PARTITION_NETBSD_TYPE_ADOS 14
#define PUPA_PARTITION_NETBSD_TYPE_HFS 15 #define GRUB_PARTITION_NETBSD_TYPE_HFS 15
#define PUPA_PARTITION_NETBSD_TYPE_FILECORE 16 #define GRUB_PARTITION_NETBSD_TYPE_FILECORE 16
#define PUPA_PARTITION_NETBSD_TYPE_EXT2FS 17 #define GRUB_PARTITION_NETBSD_TYPE_EXT2FS 17
#define PUPA_PARTITION_NETBSD_TYPE_NTFS 18 #define GRUB_PARTITION_NETBSD_TYPE_NTFS 18
#define PUPA_PARTITION_NETBSD_TYPE_RAID 19 #define GRUB_PARTITION_NETBSD_TYPE_RAID 19
#define PUPA_PARTITION_NETBSD_TYPE_CCD 20 #define GRUB_PARTITION_NETBSD_TYPE_CCD 20
#define PUPA_PARTITION_NETBSD_TYPE_JFS2 21 #define GRUB_PARTITION_NETBSD_TYPE_JFS2 21
#define PUPA_PARTITION_NETBSD_TYPE_APPLEUFS 22 #define GRUB_PARTITION_NETBSD_TYPE_APPLEUFS 22
/* OpenBSD-specific types. */ /* OpenBSD-specific types. */
#define PUPA_PARTITION_OPENBSD_TYPE_ADOS 14 #define GRUB_PARTITION_OPENBSD_TYPE_ADOS 14
#define PUPA_PARTITION_OPENBSD_TYPE_HFS 15 #define GRUB_PARTITION_OPENBSD_TYPE_HFS 15
#define PUPA_PARTITION_OPENBSD_TYPE_FILECORE 16 #define GRUB_PARTITION_OPENBSD_TYPE_FILECORE 16
#define PUPA_PARTITION_OPENBSD_TYPE_EXT2FS 17 #define GRUB_PARTITION_OPENBSD_TYPE_EXT2FS 17
#define PUPA_PARTITION_OPENBSD_TYPE_NTFS 18 #define GRUB_PARTITION_OPENBSD_TYPE_NTFS 18
#define PUPA_PARTITION_OPENBSD_TYPE_RAID 19 #define GRUB_PARTITION_OPENBSD_TYPE_RAID 19
/* The BSD partition entry. */ /* The BSD partition entry. */
struct pupa_partition_bsd_entry struct grub_partition_bsd_entry
{ {
pupa_uint32_t size; grub_uint32_t size;
pupa_uint32_t offset; grub_uint32_t offset;
pupa_uint32_t fragment_size; grub_uint32_t fragment_size;
pupa_uint8_t fs_type; grub_uint8_t fs_type;
pupa_uint8_t fs_fragments; grub_uint8_t fs_fragments;
pupa_uint16_t fs_cylinders; grub_uint16_t fs_cylinders;
} __attribute__ ((packed)); } __attribute__ ((packed));
/* The BSD disk label. Only define members useful for PUPA. */ /* The BSD disk label. Only define members useful for GRUB. */
struct pupa_partition_disk_label struct grub_partition_disk_label
{ {
pupa_uint32_t magic; grub_uint32_t magic;
pupa_uint8_t padding[128]; grub_uint8_t padding[128];
pupa_uint32_t magic2; grub_uint32_t magic2;
pupa_uint16_t checksum; grub_uint16_t checksum;
pupa_uint16_t num_partitions; grub_uint16_t num_partitions;
pupa_uint32_t boot_size; grub_uint32_t boot_size;
pupa_uint32_t superblock_size; grub_uint32_t superblock_size;
struct pupa_partition_bsd_entry entries[PUPA_PARTITION_BSD_MAX_ENTRIES]; struct grub_partition_bsd_entry entries[GRUB_PARTITION_BSD_MAX_ENTRIES];
} __attribute__ ((packed)); } __attribute__ ((packed));
/* The partition entry. */ /* The partition entry. */
struct pupa_partition_entry struct grub_partition_entry
{ {
/* If active, 0x80, otherwise, 0x00. */ /* If active, 0x80, otherwise, 0x00. */
pupa_uint8_t flag; grub_uint8_t flag;
/* The head of the start. */ /* The head of the start. */
pupa_uint8_t start_head; grub_uint8_t start_head;
/* (S | ((C >> 2) & 0xC0)) where S is the sector of the start and C /* (S | ((C >> 2) & 0xC0)) where S is the sector of the start and C
is the cylinder of the start. Note that S is counted from one. */ is the cylinder of the start. Note that S is counted from one. */
pupa_uint8_t start_sector; grub_uint8_t start_sector;
/* (C & 0xFF) where C is the cylinder of the start. */ /* (C & 0xFF) where C is the cylinder of the start. */
pupa_uint8_t start_cylinder; grub_uint8_t start_cylinder;
/* The partition type. */ /* The partition type. */
pupa_uint8_t type; grub_uint8_t type;
/* The end versions of start_head, start_sector and start_cylinder, /* The end versions of start_head, start_sector and start_cylinder,
respectively. */ respectively. */
pupa_uint8_t end_head; grub_uint8_t end_head;
pupa_uint8_t end_sector; grub_uint8_t end_sector;
pupa_uint8_t end_cylinder; grub_uint8_t end_cylinder;
/* The start sector. Note that this is counted from zero. */ /* The start sector. Note that this is counted from zero. */
pupa_uint32_t start; grub_uint32_t start;
/* The length in sector units. */ /* The length in sector units. */
pupa_uint32_t length; grub_uint32_t length;
} __attribute__ ((packed)); } __attribute__ ((packed));
/* The structure of MBR. */ /* The structure of MBR. */
struct pupa_partition_mbr struct grub_partition_mbr
{ {
/* The code area (actually, including BPB). */ /* The code area (actually, including BPB). */
pupa_uint8_t code[446]; grub_uint8_t code[446];
/* Four partition entries. */ /* Four partition entries. */
struct pupa_partition_entry entries[4]; struct grub_partition_entry entries[4];
/* The signature 0xaa55. */ /* The signature 0xaa55. */
pupa_uint16_t signature; grub_uint16_t signature;
} __attribute__ ((packed)); } __attribute__ ((packed));
/* Partition description. */ /* Partition description. */
struct pupa_partition struct grub_partition
{ {
/* The start sector. */ /* The start sector. */
unsigned long start; unsigned long start;
@ -195,48 +195,48 @@ struct pupa_partition
/* The BSD partition type. */ /* The BSD partition type. */
int bsd_type; int bsd_type;
}; };
typedef struct pupa_partition *pupa_partition_t; typedef struct grub_partition *grub_partition_t;
struct pupa_disk; struct grub_disk;
pupa_partition_t EXPORT_FUNC(pupa_partition_probe) (struct pupa_disk *disk, grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk,
const char *str); const char *str);
pupa_err_t EXPORT_FUNC(pupa_partition_iterate) (struct pupa_disk *disk, grub_err_t EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
int (*hook) (const pupa_partition_t partition)); int (*hook) (const grub_partition_t partition));
char *EXPORT_FUNC(pupa_partition_get_name) (const pupa_partition_t partition); char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
static inline unsigned long static inline unsigned long
pupa_partition_get_start (const pupa_partition_t p) grub_partition_get_start (const grub_partition_t p)
{ {
return p->start; return p->start;
} }
static inline unsigned long static inline unsigned long
pupa_partition_get_len (const pupa_partition_t p) grub_partition_get_len (const grub_partition_t p)
{ {
return p->len; return p->len;
} }
static inline int static inline int
pupa_partition_is_empty (int type) grub_partition_is_empty (int type)
{ {
return (type == PUPA_PARTITION_TYPE_NONE); return (type == GRUB_PARTITION_TYPE_NONE);
} }
static inline int static inline int
pupa_partition_is_extended (int type) grub_partition_is_extended (int type)
{ {
return (type == PUPA_PARTITION_TYPE_EXTENDED return (type == GRUB_PARTITION_TYPE_EXTENDED
|| type == PUPA_PARTITION_TYPE_WIN95_EXTENDED || type == GRUB_PARTITION_TYPE_WIN95_EXTENDED
|| type == PUPA_PARTITION_TYPE_LINUX_EXTENDED); || type == GRUB_PARTITION_TYPE_LINUX_EXTENDED);
} }
static inline int static inline int
pupa_partition_is_bsd (int type) grub_partition_is_bsd (int type)
{ {
return (type == PUPA_PARTITION_TYPE_FREEBSD return (type == GRUB_PARTITION_TYPE_FREEBSD
|| type == PUPA_PARTITION_TYPE_OPENBSD || type == GRUB_PARTITION_TYPE_OPENBSD
|| type == PUPA_PARTITION_TYPE_NETBSD); || type == GRUB_PARTITION_TYPE_NETBSD);
} }
#endif /* ! PUPA_PARTITION_HEADER */ #endif /* ! GRUB_PARTITION_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -20,14 +20,14 @@
#ifndef KERNEL_TIME_HEADER #ifndef KERNEL_TIME_HEADER
#define KERNEL_TIME_HEADER 1 #define KERNEL_TIME_HEADER 1
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
# include <time.h> # include <time.h>
# define PUPA_TICKS_PER_SECOND CLOCKS_PER_SEC # define GRUB_TICKS_PER_SECOND CLOCKS_PER_SEC
#else #else
# define PUPA_TICKS_PER_SECOND 18 # define GRUB_TICKS_PER_SECOND 18
#endif #endif
/* Return the real time in ticks. */ /* Return the real time in ticks. */
pupa_uint32_t pupa_get_rtc (void); grub_uint32_t grub_get_rtc (void);
#endif /* ! KERNEL_TIME_HEADER */ #endif /* ! KERNEL_TIME_HEADER */

View file

@ -1,9 +1,9 @@
/* biosdisk.h - emulate biosdisk */ /* biosdisk.h - emulate biosdisk */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,15 +14,15 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_BIOSDISK_MACHINE_UTIL_HEADER #ifndef GRUB_BIOSDISK_MACHINE_UTIL_HEADER
#define PUPA_BIOSDISK_MACHINE_UTIL_HEADER 1 #define GRUB_BIOSDISK_MACHINE_UTIL_HEADER 1
void pupa_util_biosdisk_init (const char *dev_map); void grub_util_biosdisk_init (const char *dev_map);
void pupa_util_biosdisk_fini (void); void grub_util_biosdisk_fini (void);
char *pupa_util_biosdisk_get_pupa_dev (const char *os_dev); char *grub_util_biosdisk_get_grub_dev (const char *os_dev);
#endif /* ! PUPA_BIOSDISK_MACHINE_UTIL_HEADER */ #endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,15 +17,15 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_VGA_MACHINE_HEADER #ifndef GRUB_VGA_MACHINE_HEADER
#define PUPA_VGA_MACHINE_HEADER 1 #define GRUB_VGA_MACHINE_HEADER 1
#include <pupa/symbol.h> #include <grub/symbol.h>
/* Set the video mode to MODE and return the previous mode. */ /* Set the video mode to MODE and return the previous mode. */
unsigned char EXPORT_FUNC(pupa_vga_set_mode) (unsigned char mode); unsigned char EXPORT_FUNC(grub_vga_set_mode) (unsigned char mode);
/* Return a pointer to the ROM font table. */ /* Return a pointer to the ROM font table. */
unsigned char *EXPORT_FUNC(pupa_vga_get_font) (void); unsigned char *EXPORT_FUNC(grub_vga_get_font) (void);
#endif /* ! PUPA_VGA_MACHINE_HEADER */ #endif /* ! GRUB_VGA_MACHINE_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,9 +17,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_SETJMP_CPU_HEADER #ifndef GRUB_SETJMP_CPU_HEADER
#define PUPA_SETJMP_CPU_HEADER 1 #define GRUB_SETJMP_CPU_HEADER 1
typedef unsigned long pupa_jmp_buf[6]; typedef unsigned long grub_jmp_buf[6];
#endif /* ! PUPA_SETJMP_CPU_HEADER */ #endif /* ! GRUB_SETJMP_CPU_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,20 +13,20 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_TYPES_CPU_HEADER #ifndef GRUB_TYPES_CPU_HEADER
#define PUPA_TYPES_CPU_HEADER 1 #define GRUB_TYPES_CPU_HEADER 1
/* The size of void *. */ /* The size of void *. */
#define PUPA_HOST_SIZEOF_VOID_P 4 #define GRUB_HOST_SIZEOF_VOID_P 4
/* The size of long. */ /* The size of long. */
#define PUPA_HOST_SIZEOF_LONG 4 #define GRUB_HOST_SIZEOF_LONG 4
/* i386 is little-endian. */ /* i386 is little-endian. */
#undef PUPA_HOST_WORDS_BIGENDIAN #undef GRUB_HOST_WORDS_BIGENDIAN
#endif /* ! PUPA_TYPES_CPU_HEADER */ #endif /* ! GRUB_TYPES_CPU_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,42 +17,42 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_KERNEL_HEADER #ifndef GRUB_KERNEL_HEADER
#define PUPA_KERNEL_HEADER 1 #define GRUB_KERNEL_HEADER 1
#include <pupa/types.h> #include <grub/types.h>
/* The module header. */ /* The module header. */
struct pupa_module_header struct grub_module_header
{ {
/* The offset of object code. */ /* The offset of object code. */
pupa_off_t offset; grub_off_t offset;
/* The size of object code plus this header. */ /* The size of object code plus this header. */
pupa_size_t size; grub_size_t size;
}; };
/* The start address of the kernel. */ /* The start address of the kernel. */
extern pupa_addr_t pupa_start_addr; extern grub_addr_t grub_start_addr;
/* The end address of the kernel. */ /* The end address of the kernel. */
extern pupa_addr_t pupa_end_addr; extern grub_addr_t grub_end_addr;
/* The total size of modules including their headers. */ /* The total size of modules including their headers. */
extern pupa_size_t pupa_total_module_size; extern grub_size_t grub_total_module_size;
/* The size of the kernel image. */ /* The size of the kernel image. */
extern pupa_size_t pupa_kernel_image_size; extern grub_size_t grub_kernel_image_size;
/* The start point of the C code. */ /* The start point of the C code. */
void pupa_main (void); void grub_main (void);
/* The machine-specific initialization. This must initialize memory. */ /* The machine-specific initialization. This must initialize memory. */
void pupa_machine_init (void); void grub_machine_init (void);
/* Return the end address of the core image. */ /* Return the end address of the core image. */
pupa_addr_t pupa_get_end_addr (void); grub_addr_t grub_get_end_addr (void);
/* Register all the exported symbols. This is automatically generated. */ /* Register all the exported symbols. This is automatically generated. */
void pupa_register_exported_symbols (void); void grub_register_exported_symbols (void);
#endif /* ! PUPA_KERNEL_HEADER */ #endif /* ! GRUB_KERNEL_HEADER */

View file

@ -1,6 +1,6 @@
/* loader.h - OS loaders */ /* loader.h - OS loaders */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,21 +18,21 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_LOADER_HEADER #ifndef GRUB_LOADER_HEADER
#define PUPA_LOADER_HEADER 1 #define GRUB_LOADER_HEADER 1
#include <pupa/file.h> #include <grub/file.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/types.h> #include <grub/types.h>
extern pupa_addr_t EXPORT_VAR(pupa_os_area_addr); extern grub_addr_t EXPORT_VAR(grub_os_area_addr);
extern pupa_size_t EXPORT_VAR(pupa_os_area_size); extern grub_size_t EXPORT_VAR(grub_os_area_size);
void EXPORT_FUNC(pupa_loader_set) (pupa_err_t (*boot) (void), void EXPORT_FUNC(grub_loader_set) (grub_err_t (*boot) (void),
pupa_err_t (*unload) (void)); grub_err_t (*unload) (void));
void EXPORT_FUNC(pupa_loader_unset) (void); void EXPORT_FUNC(grub_loader_unset) (void);
pupa_err_t EXPORT_FUNC(pupa_loader_boot) (void); grub_err_t EXPORT_FUNC(grub_loader_boot) (void);
#endif /* ! PUPA_LOADER_HEADER */ #endif /* ! GRUB_LOADER_HEADER */

View file

@ -1,9 +1,9 @@
/* misc.h - prototypes for misc functions */ /* misc.h - prototypes for misc functions */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,51 +14,51 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_MISC_HEADER #ifndef GRUB_MISC_HEADER
#define PUPA_MISC_HEADER 1 #define GRUB_MISC_HEADER 1
#include <stdarg.h> #include <stdarg.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/err.h> #include <grub/err.h>
/* XXX: If pupa_memmove is too slow, we must implement pupa_memcpy. */ /* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
#define pupa_memcpy(d,s,n) pupa_memmove ((d), (s), (n)) #define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n))
void *EXPORT_FUNC(pupa_memmove) (void *dest, const void *src, pupa_size_t n); void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n);
char *EXPORT_FUNC(pupa_strcpy) (char *dest, const char *src); char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src);
char *EXPORT_FUNC(pupa_strncpy) (char *dest, const char *src, int c); char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c);
char *EXPORT_FUNC(pupa_stpcpy) (char *dest, const char *src); char *EXPORT_FUNC(grub_stpcpy) (char *dest, const char *src);
char *EXPORT_FUNC(pupa_strcat) (char *dest, const char *src); char *EXPORT_FUNC(grub_strcat) (char *dest, const char *src);
int EXPORT_FUNC(pupa_memcmp) (const void *s1, const void *s2, pupa_size_t n); int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n);
int EXPORT_FUNC(pupa_strcmp) (const char *s1, const char *s2); int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2);
int EXPORT_FUNC(pupa_strncmp) (const char *s1, const char *s2, int c); int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, int c);
char *EXPORT_FUNC(pupa_strchr) (const char *s, int c); char *EXPORT_FUNC(grub_strchr) (const char *s, int c);
char *EXPORT_FUNC(pupa_strrchr) (const char *s, int c); char *EXPORT_FUNC(grub_strrchr) (const char *s, int c);
int EXPORT_FUNC(pupa_isspace) (int c); int EXPORT_FUNC(grub_isspace) (int c);
int EXPORT_FUNC(pupa_isprint) (int c); int EXPORT_FUNC(grub_isprint) (int c);
int EXPORT_FUNC(pupa_isalpha) (int c); int EXPORT_FUNC(grub_isalpha) (int c);
int EXPORT_FUNC(pupa_isgraph) (int c); int EXPORT_FUNC(grub_isgraph) (int c);
int EXPORT_FUNC(pupa_isdigit) (int c); int EXPORT_FUNC(grub_isdigit) (int c);
int EXPORT_FUNC(pupa_tolower) (int c); int EXPORT_FUNC(grub_tolower) (int c);
unsigned long EXPORT_FUNC(pupa_strtoul) (const char *str, char **end, int base); unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base);
char *EXPORT_FUNC(pupa_strdup) (const char *s); char *EXPORT_FUNC(grub_strdup) (const char *s);
char *EXPORT_FUNC(pupa_strndup) (const char *s, pupa_size_t n); char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n);
void *EXPORT_FUNC(pupa_memset) (void *s, int c, pupa_size_t n); void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n);
pupa_size_t EXPORT_FUNC(pupa_strlen) (const char *s); grub_size_t EXPORT_FUNC(grub_strlen) (const char *s);
int EXPORT_FUNC(pupa_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
int EXPORT_FUNC(pupa_vprintf) (const char *fmt, va_list args); int EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args);
int EXPORT_FUNC(pupa_sprintf) (char *str, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); int EXPORT_FUNC(grub_sprintf) (char *str, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
int EXPORT_FUNC(pupa_vsprintf) (char *str, const char *fmt, va_list args); int EXPORT_FUNC(grub_vsprintf) (char *str, const char *fmt, va_list args);
void EXPORT_FUNC(pupa_stop) (void) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_stop) (void) __attribute__ ((noreturn));
pupa_err_t EXPORT_FUNC(pupa_split_cmdline) (const char *str, grub_err_t EXPORT_FUNC(grub_split_cmdline) (const char *str,
pupa_err_t (* getline) (char **), grub_err_t (* getline) (char **),
int *argc, char ***argv); int *argc, char ***argv);
#endif /* ! PUPA_MISC_HEADER */ #endif /* ! GRUB_MISC_HEADER */

View file

@ -1,9 +1,9 @@
/* mm.h - prototypes and declarations for memory manager */ /* mm.h - prototypes and declarations for memory manager */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,26 +14,26 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_MM_H #ifndef GRUB_MM_H
#define PUPA_MM_H 1 #define GRUB_MM_H 1
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
void pupa_mm_init_region (void *addr, unsigned size); void grub_mm_init_region (void *addr, unsigned size);
void *EXPORT_FUNC(pupa_malloc) (unsigned size); void *EXPORT_FUNC(grub_malloc) (unsigned size);
void EXPORT_FUNC(pupa_free) (void *ptr); void EXPORT_FUNC(grub_free) (void *ptr);
void *EXPORT_FUNC(pupa_realloc) (void *ptr, unsigned size); void *EXPORT_FUNC(grub_realloc) (void *ptr, unsigned size);
void *EXPORT_FUNC(pupa_memalign) (unsigned align, unsigned size); void *EXPORT_FUNC(grub_memalign) (unsigned align, unsigned size);
/* For debugging. */ /* For debugging. */
#define MM_DEBUG 1 #define MM_DEBUG 1
#if MM_DEBUG #if MM_DEBUG
void pupa_mm_dump (unsigned lineno); void grub_mm_dump (unsigned lineno);
#endif #endif
#endif /* ! PUPA_MM_H */ #endif /* ! GRUB_MM_H */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,49 +13,49 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_NET_HEADER #ifndef GRUB_NET_HEADER
#define PUPA_NET_HEADER 1 #define GRUB_NET_HEADER 1
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/types.h> #include <grub/types.h>
struct pupa_net; struct grub_net;
struct pupa_net_dev struct grub_net_dev
{ {
/* The device name. */ /* The device name. */
const char *name; const char *name;
/* FIXME: Just a template. */ /* FIXME: Just a template. */
int (*probe) (struct pupa_net *net, const void *addr); int (*probe) (struct grub_net *net, const void *addr);
void (*reset) (struct pupa_net *net); void (*reset) (struct grub_net *net);
int (*poll) (struct pupa_net *net); int (*poll) (struct grub_net *net);
void (*transmit) (struct pupa_net *net, const void *destip, void (*transmit) (struct grub_net *net, const void *destip,
unsigned srcsock, unsigned destsock, const void *packet); unsigned srcsock, unsigned destsock, const void *packet);
void (*disable) (struct pupa_net *net); void (*disable) (struct grub_net *net);
/* The next net device. */ /* The next net device. */
struct pupa_net_dev *next; struct grub_net_dev *next;
}; };
typedef struct pupa_net_dev *pupa_net_dev_t; typedef struct grub_net_dev *grub_net_dev_t;
struct pupa_fs; struct grub_fs;
struct pupa_net struct grub_net
{ {
/* The net name. */ /* The net name. */
const char *name; const char *name;
/* The underlying disk device. */ /* The underlying disk device. */
pupa_net_dev_t dev; grub_net_dev_t dev;
/* The binding filesystem. */ /* The binding filesystem. */
struct pupa_fs *fs; struct grub_fs *fs;
/* FIXME: More data would be required, such as an IP address, a mask, /* FIXME: More data would be required, such as an IP address, a mask,
a gateway, etc. */ a gateway, etc. */
@ -63,11 +63,11 @@ struct pupa_net
/* Device-specific data. */ /* Device-specific data. */
void *data; void *data;
}; };
typedef struct pupa_net *pupa_net_t; typedef struct grub_net *grub_net_t;
/* FIXME: How to abstract networks? More consideration is necessary. */ /* FIXME: How to abstract networks? More consideration is necessary. */
/* Note: Networks are very different from disks, because networks must /* Note: Networks are very different from disks, because networks must
be initialized before used, and the status is persistent. */ be initialized before used, and the status is persistent. */
#endif /* ! PUPA_NET_HEADER */ #endif /* ! GRUB_NET_HEADER */

View file

@ -1,6 +1,6 @@
/* normal.h - prototypes for the normal mode */ /* normal.h - prototypes for the normal mode */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,36 +18,36 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_NORMAL_HEADER #ifndef GRUB_NORMAL_HEADER
#define PUPA_NORMAL_HEADER 1 #define GRUB_NORMAL_HEADER 1
#include <pupa/setjmp.h> #include <grub/setjmp.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/arg.h> #include <grub/arg.h>
/* The maximum size of a command-line. */ /* The maximum size of a command-line. */
#define PUPA_MAX_CMDLINE 1600 #define GRUB_MAX_CMDLINE 1600
/* Can be run in the command-line. */ /* Can be run in the command-line. */
#define PUPA_COMMAND_FLAG_CMDLINE 0x1 #define GRUB_COMMAND_FLAG_CMDLINE 0x1
/* Can be run in the menu. */ /* Can be run in the menu. */
#define PUPA_COMMAND_FLAG_MENU 0x2 #define GRUB_COMMAND_FLAG_MENU 0x2
/* Can be run in both interfaces. */ /* Can be run in both interfaces. */
#define PUPA_COMMAND_FLAG_BOTH 0x3 #define GRUB_COMMAND_FLAG_BOTH 0x3
/* Only for the command title. */ /* Only for the command title. */
#define PUPA_COMMAND_FLAG_TITLE 0x4 #define GRUB_COMMAND_FLAG_TITLE 0x4
/* Don't print the command on booting. */ /* Don't print the command on booting. */
#define PUPA_COMMAND_FLAG_NO_ECHO 0x8 #define GRUB_COMMAND_FLAG_NO_ECHO 0x8
/* The command description. */ /* The command description. */
struct pupa_command struct grub_command
{ {
/* The name. */ /* The name. */
const char *name; const char *name;
/* The callback function. */ /* The callback function. */
pupa_err_t (*func) (struct pupa_arg_list *state, int argc, char **args); grub_err_t (*func) (struct grub_arg_list *state, int argc, char **args);
/* The flags. */ /* The flags. */
unsigned flags; unsigned flags;
@ -59,26 +59,26 @@ struct pupa_command
const char *description; const char *description;
/* The argument parser optionlist. */ /* The argument parser optionlist. */
const struct pupa_arg_option *options; const struct grub_arg_option *options;
/* The next element. */ /* The next element. */
struct pupa_command *next; struct grub_command *next;
}; };
typedef struct pupa_command *pupa_command_t; typedef struct grub_command *grub_command_t;
/* The command list. */ /* The command list. */
struct pupa_command_list struct grub_command_list
{ {
/* The string of a command. */ /* The string of a command. */
const char *command; const char *command;
/* The next element. */ /* The next element. */
struct pupa_command_list *next; struct grub_command_list *next;
}; };
typedef struct pupa_command_list *pupa_command_list_t; typedef struct grub_command_list *grub_command_list_t;
/* The menu entry. */ /* The menu entry. */
struct pupa_menu_entry struct grub_menu_entry
{ {
/* The title name. */ /* The title name. */
const char *title; const char *title;
@ -87,15 +87,15 @@ struct pupa_menu_entry
int num; int num;
/* The list of commands. */ /* The list of commands. */
pupa_command_list_t command_list; grub_command_list_t command_list;
/* The next element. */ /* The next element. */
struct pupa_menu_entry *next; struct grub_menu_entry *next;
}; };
typedef struct pupa_menu_entry *pupa_menu_entry_t; typedef struct grub_menu_entry *grub_menu_entry_t;
/* The menu. */ /* The menu. */
struct pupa_menu struct grub_menu
{ {
/* The default entry number. */ /* The default entry number. */
int default_entry; int default_entry;
@ -110,52 +110,52 @@ struct pupa_menu
int size; int size;
/* The list of menu entries. */ /* The list of menu entries. */
pupa_menu_entry_t entry_list; grub_menu_entry_t entry_list;
}; };
typedef struct pupa_menu *pupa_menu_t; typedef struct grub_menu *grub_menu_t;
/* To exit from the normal mode. */ /* To exit from the normal mode. */
extern pupa_jmp_buf pupa_exit_env; extern grub_jmp_buf grub_exit_env;
void pupa_enter_normal_mode (const char *config); void grub_enter_normal_mode (const char *config);
void pupa_normal_execute (const char *config, int nested); void grub_normal_execute (const char *config, int nested);
void pupa_menu_run (pupa_menu_t menu, int nested); void grub_menu_run (grub_menu_t menu, int nested);
void pupa_cmdline_run (int nested); void grub_cmdline_run (int nested);
int pupa_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len,
int echo_char, int readline); int echo_char, int readline);
void EXPORT_FUNC(pupa_register_command) (const char *name, void EXPORT_FUNC(grub_register_command) (const char *name,
pupa_err_t (*func) (struct pupa_arg_list *state, grub_err_t (*func) (struct grub_arg_list *state,
int argc, char **args), int argc, char **args),
unsigned flags, unsigned flags,
const char *summary, const char *summary,
const char *description, const char *description,
const struct pupa_arg_option *parser); const struct grub_arg_option *parser);
void EXPORT_FUNC(pupa_unregister_command) (const char *name); void EXPORT_FUNC(grub_unregister_command) (const char *name);
pupa_command_t pupa_command_find (char *cmdline); grub_command_t grub_command_find (char *cmdline);
pupa_err_t pupa_set_history (int newsize); grub_err_t grub_set_history (int newsize);
int pupa_iterate_commands (int (*iterate) (pupa_command_t)); int grub_iterate_commands (int (*iterate) (grub_command_t));
int pupa_command_execute (char *cmdline); int grub_command_execute (char *cmdline);
void pupa_command_init (void); void grub_command_init (void);
void pupa_normal_init_page (void); void grub_normal_init_page (void);
int pupa_arg_parse (pupa_command_t parser, int argc, char **argv, int grub_arg_parse (grub_command_t parser, int argc, char **argv,
struct pupa_arg_list *usr, char ***args, int *argnum); struct grub_arg_list *usr, char ***args, int *argnum);
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
void pupa_normal_init (void); void grub_normal_init (void);
void pupa_normal_fini (void); void grub_normal_fini (void);
void pupa_hello_init (void); void grub_hello_init (void);
void pupa_hello_fini (void); void grub_hello_fini (void);
void pupa_ls_init (void); void grub_ls_init (void);
void pupa_ls_fini (void); void grub_ls_fini (void);
void pupa_cat_init (void); void grub_cat_init (void);
void pupa_cat_fini (void); void grub_cat_fini (void);
void pupa_boot_init (void); void grub_boot_init (void);
void pupa_boot_fini (void); void grub_boot_fini (void);
void pupa_cmp_init (void); void grub_cmp_init (void);
void pupa_cmp_fini (void); void grub_cmp_fini (void);
void pupa_terminal_init (void); void grub_terminal_init (void);
void pupa_terminal_fini (void); void grub_terminal_fini (void);
#endif #endif
#endif /* ! PUPA_NORMAL_HEADER */ #endif /* ! GRUB_NORMAL_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2004 Free Software Foundation, Inc. * Copyright (C) 2002, 2004 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,16 +13,16 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_BIOSDISK_MACHINE_HEADER #ifndef GRUB_BIOSDISK_MACHINE_HEADER
#define PUPA_BIOSDISK_MACHINE_HEADER 1 #define GRUB_BIOSDISK_MACHINE_HEADER 1
#define PUPA_BIOSDISK_FLAG_LBA 1 #define GRUB_BIOSDISK_FLAG_LBA 1
struct pupa_biosdisk_data struct grub_biosdisk_data
{ {
int drive; int drive;
unsigned long cylinders; unsigned long cylinders;
@ -31,17 +31,17 @@ struct pupa_biosdisk_data
unsigned long flags; unsigned long flags;
}; };
int pupa_biosdisk_rw_int13_extensions (int ah, int drive, void *dap); int grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap);
int pupa_biosdisk_rw_standard (int ah, int drive, int coff, int hoff, int grub_biosdisk_rw_standard (int ah, int drive, int coff, int hoff,
int soff, int nsec, int segment); int soff, int nsec, int segment);
int pupa_biosdisk_check_int13_extensions (int drive); int grub_biosdisk_check_int13_extensions (int drive);
int pupa_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp); int grub_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp);
int pupa_biosdisk_get_diskinfo_standard (int drive, int grub_biosdisk_get_diskinfo_standard (int drive,
unsigned long *cylinders, unsigned long *cylinders,
unsigned long *heads, unsigned long *heads,
unsigned long *sectors); unsigned long *sectors);
int pupa_biosdisk_get_num_floppies (void); int grub_biosdisk_get_num_floppies (void);
void pupa_biosdisk_init (void); void grub_biosdisk_init (void);
#endif /* ! PUPA_BIOSDISK_MACHINE_HEADER */ #endif /* ! GRUB_BIOSDISK_MACHINE_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2004 Free Software Foundation, Inc. * Copyright (C) 2002, 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,40 +17,40 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_CONSOLE_MACHINE_HEADER #ifndef GRUB_CONSOLE_MACHINE_HEADER
#define PUPA_CONSOLE_MACHINE_HEADER 1 #define GRUB_CONSOLE_MACHINE_HEADER 1
/* Define scan codes. */ /* Define scan codes. */
#define PUPA_CONSOLE_KEY_LEFT 0x4B00 #define GRUB_CONSOLE_KEY_LEFT 0x4B00
#define PUPA_CONSOLE_KEY_RIGHT 0x4D00 #define GRUB_CONSOLE_KEY_RIGHT 0x4D00
#define PUPA_CONSOLE_KEY_UP 0x4800 #define GRUB_CONSOLE_KEY_UP 0x4800
#define PUPA_CONSOLE_KEY_DOWN 0x5000 #define GRUB_CONSOLE_KEY_DOWN 0x5000
#define PUPA_CONSOLE_KEY_IC 0x5200 #define GRUB_CONSOLE_KEY_IC 0x5200
#define PUPA_CONSOLE_KEY_DC 0x5300 #define GRUB_CONSOLE_KEY_DC 0x5300
#define PUPA_CONSOLE_KEY_BACKSPACE 0x0008 #define GRUB_CONSOLE_KEY_BACKSPACE 0x0008
#define PUPA_CONSOLE_KEY_HOME 0x4700 #define GRUB_CONSOLE_KEY_HOME 0x4700
#define PUPA_CONSOLE_KEY_END 0x4F00 #define GRUB_CONSOLE_KEY_END 0x4F00
#define PUPA_CONSOLE_KEY_NPAGE 0x4900 #define GRUB_CONSOLE_KEY_NPAGE 0x4900
#define PUPA_CONSOLE_KEY_PPAGE 0x5100 #define GRUB_CONSOLE_KEY_PPAGE 0x5100
#ifndef ASM_FILE #ifndef ASM_FILE
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
/* These are global to share code between C and asm. */ /* These are global to share code between C and asm. */
extern pupa_uint8_t pupa_console_cur_color; extern grub_uint8_t grub_console_cur_color;
void pupa_console_real_putchar (int c); void grub_console_real_putchar (int c);
int EXPORT_FUNC(pupa_console_checkkey) (void); int EXPORT_FUNC(grub_console_checkkey) (void);
int EXPORT_FUNC(pupa_console_getkey) (void); int EXPORT_FUNC(grub_console_getkey) (void);
pupa_uint16_t pupa_console_getxy (void); grub_uint16_t grub_console_getxy (void);
void pupa_console_gotoxy (pupa_uint8_t x, pupa_uint8_t y); void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y);
void pupa_console_cls (void); void grub_console_cls (void);
void pupa_console_setcursor (int on); void grub_console_setcursor (int on);
/* Initialize the console system. */ /* Initialize the console system. */
void pupa_console_init (void); void grub_console_init (void);
#endif #endif
#endif /* ! PUPA_CONSOLE_MACHINE_HEADER */ #endif /* ! GRUB_CONSOLE_MACHINE_HEADER */

View file

@ -1,6 +1,6 @@
/* ieee1275.h - Access the Open Firmware client interface. */ /* ieee1275.h - Access the Open Firmware client interface. */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 2004 Free Software Foundation, Inc. * Copyright (C) 2003, 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,82 +18,82 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_IEEE1275_MACHINE_HEADER #ifndef GRUB_IEEE1275_MACHINE_HEADER
#define PUPA_IEEE1275_MACHINE_HEADER 1 #define GRUB_IEEE1275_MACHINE_HEADER 1
#include <stdint.h> #include <stdint.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/types.h> #include <grub/types.h>
/* Maps a device alias to a pathname. */ /* Maps a device alias to a pathname. */
struct pupa_ieee1275_devalias struct grub_ieee1275_devalias
{ {
char *name; char *name;
char *path; char *path;
char *type; char *type;
}; };
struct pupa_ieee1275_mem_region struct grub_ieee1275_mem_region
{ {
unsigned int start; unsigned int start;
unsigned int size; unsigned int size;
}; };
/* FIXME jrydberg: is this correct cell types? */ /* FIXME jrydberg: is this correct cell types? */
typedef intptr_t pupa_ieee1275_ihandle_t; typedef intptr_t grub_ieee1275_ihandle_t;
typedef intptr_t pupa_ieee1275_phandle_t; typedef intptr_t grub_ieee1275_phandle_t;
extern intptr_t (*pupa_ieee1275_entry_fn) (void *); extern intptr_t (*grub_ieee1275_entry_fn) (void *);
uint32_t EXPORT_FUNC(pupa_ieee1275_decode_int_4) (unsigned char *p); uint32_t EXPORT_FUNC(grub_ieee1275_decode_int_4) (unsigned char *p);
int EXPORT_FUNC(pupa_ieee1275_finddevice) (char *name, int EXPORT_FUNC(grub_ieee1275_finddevice) (char *name,
pupa_ieee1275_phandle_t *phandlep); grub_ieee1275_phandle_t *phandlep);
int EXPORT_FUNC(pupa_ieee1275_get_property) (int handle, const char *property, int EXPORT_FUNC(grub_ieee1275_get_property) (int handle, const char *property,
void *buf, pupa_size_t size, void *buf, grub_size_t size,
pupa_size_t *actual); grub_size_t *actual);
int EXPORT_FUNC(pupa_ieee1275_next_property) (int handle, char *prev_prop, int EXPORT_FUNC(grub_ieee1275_next_property) (int handle, char *prev_prop,
char *prop, int *flags); char *prop, int *flags);
int EXPORT_FUNC(pupa_ieee1275_get_property_length) int EXPORT_FUNC(grub_ieee1275_get_property_length)
(pupa_ieee1275_phandle_t handle, const char *prop, pupa_size_t *length); (grub_ieee1275_phandle_t handle, const char *prop, grub_size_t *length);
int EXPORT_FUNC(pupa_ieee1275_instance_to_package) int EXPORT_FUNC(grub_ieee1275_instance_to_package)
(pupa_ieee1275_ihandle_t ihandle, pupa_ieee1275_phandle_t *phandlep); (grub_ieee1275_ihandle_t ihandle, grub_ieee1275_phandle_t *phandlep);
int EXPORT_FUNC(pupa_ieee1275_package_to_path) (pupa_ieee1275_phandle_t phandle, int EXPORT_FUNC(grub_ieee1275_package_to_path) (grub_ieee1275_phandle_t phandle,
char *path, pupa_size_t len, char *path, grub_size_t len,
pupa_size_t *actual); grub_size_t *actual);
int EXPORT_FUNC(pupa_ieee1275_instance_to_path) int EXPORT_FUNC(grub_ieee1275_instance_to_path)
(pupa_ieee1275_ihandle_t ihandle, char *path, pupa_size_t len, (grub_ieee1275_ihandle_t ihandle, char *path, grub_size_t len,
pupa_size_t *actual); grub_size_t *actual);
int EXPORT_FUNC(pupa_ieee1275_write) (pupa_ieee1275_ihandle_t ihandle, int EXPORT_FUNC(grub_ieee1275_write) (grub_ieee1275_ihandle_t ihandle,
void *buffer, pupa_size_t len, void *buffer, grub_size_t len,
pupa_size_t *actualp); grub_size_t *actualp);
int EXPORT_FUNC(pupa_ieee1275_read) (pupa_ieee1275_ihandle_t ihandle, int EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle,
void *buffer, pupa_size_t len, void *buffer, grub_size_t len,
pupa_size_t *actualp); grub_size_t *actualp);
int EXPORT_FUNC(pupa_ieee1275_seek) (pupa_ieee1275_ihandle_t ihandle, int EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle,
int pos_hi, int pos_lo, int *result); int pos_hi, int pos_lo, int *result);
int EXPORT_FUNC(pupa_ieee1275_peer) (pupa_ieee1275_phandle_t node, int EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node,
pupa_ieee1275_phandle_t *result); grub_ieee1275_phandle_t *result);
int EXPORT_FUNC(pupa_ieee1275_child) (pupa_ieee1275_phandle_t node, int EXPORT_FUNC(grub_ieee1275_child) (grub_ieee1275_phandle_t node,
pupa_ieee1275_phandle_t *result); grub_ieee1275_phandle_t *result);
int EXPORT_FUNC(pupa_ieee1275_parent) (pupa_ieee1275_phandle_t node, int EXPORT_FUNC(grub_ieee1275_parent) (grub_ieee1275_phandle_t node,
pupa_ieee1275_phandle_t *result); grub_ieee1275_phandle_t *result);
int EXPORT_FUNC(pupa_ieee1275_exit) (void); int EXPORT_FUNC(grub_ieee1275_exit) (void);
int EXPORT_FUNC(pupa_ieee1275_open) (char *node, int EXPORT_FUNC(grub_ieee1275_open) (char *node,
pupa_ieee1275_ihandle_t *result); grub_ieee1275_ihandle_t *result);
int EXPORT_FUNC(pupa_ieee1275_close) (pupa_ieee1275_ihandle_t ihandle); int EXPORT_FUNC(grub_ieee1275_close) (grub_ieee1275_ihandle_t ihandle);
int EXPORT_FUNC(pupa_ieee1275_claim) (void *p, pupa_size_t size, unsigned int align, int EXPORT_FUNC(grub_ieee1275_claim) (void *p, grub_size_t size, unsigned int align,
void **result); void **result);
int EXPORT_FUNC(pupa_ieee1275_set_property) (pupa_ieee1275_phandle_t phandle, int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle,
const char *propname, void *buf, const char *propname, void *buf,
pupa_size_t size, grub_size_t size,
pupa_size_t *actual); grub_size_t *actual);
int EXPORT_FUNC(pupa_ieee1275_set_color) (pupa_ieee1275_ihandle_t ihandle, int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle,
int index, int r, int g, int b); int index, int r, int g, int b);
pupa_err_t EXPORT_FUNC(pupa_devalias_iterate) grub_err_t EXPORT_FUNC(grub_devalias_iterate)
(int (*hook) (struct pupa_ieee1275_devalias *alias)); (int (*hook) (struct grub_ieee1275_devalias *alias));
#endif /* ! PUPA_IEEE1275_MACHINE_HEADER */ #endif /* ! GRUB_IEEE1275_MACHINE_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org> * Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
* Copyright (C) 2003 Jeroen Dekkers <jeroen@dekkers.cx> * Copyright (C) 2003 Jeroen Dekkers <jeroen@dekkers.cx>
* *
@ -18,34 +18,34 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_LOADER_MACHINE_HEADER #ifndef GRUB_LOADER_MACHINE_HEADER
#define PUPA_LOADER_MACHINE_HEADER 1 #define GRUB_LOADER_MACHINE_HEADER 1
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/machine/multiboot.h> #include <grub/machine/multiboot.h>
extern pupa_uint32_t EXPORT_VAR(pupa_linux_prot_size); extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size);
extern char *EXPORT_VAR(pupa_linux_tmp_addr); extern char *EXPORT_VAR(grub_linux_tmp_addr);
extern char *EXPORT_VAR(pupa_linux_real_addr); extern char *EXPORT_VAR(grub_linux_real_addr);
void EXPORT_FUNC(pupa_linux_boot_zimage) (void) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_linux_boot_zimage) (void) __attribute__ ((noreturn));
void EXPORT_FUNC(pupa_linux_boot_bzimage) (void) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_linux_boot_bzimage) (void) __attribute__ ((noreturn));
/* This is an asm part of the chainloader. */ /* This is an asm part of the chainloader. */
void EXPORT_FUNC(pupa_chainloader_real_boot) (int drive, void *part_addr) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_chainloader_real_boot) (int drive, void *part_addr) __attribute__ ((noreturn));
/* The asm part of the multiboot loader. */ /* The asm part of the multiboot loader. */
void EXPORT_FUNC(pupa_multiboot_real_boot) (pupa_addr_t entry, void EXPORT_FUNC(grub_multiboot_real_boot) (grub_addr_t entry,
struct pupa_multiboot_info *mbi) struct grub_multiboot_info *mbi)
__attribute__ ((noreturn)); __attribute__ ((noreturn));
/* It is necessary to export these functions, because normal mode commands /* It is necessary to export these functions, because normal mode commands
reuse rescue mode commands. */ reuse rescue mode commands. */
void pupa_rescue_cmd_chainloader (int argc, char *argv[]); void grub_rescue_cmd_chainloader (int argc, char *argv[]);
void pupa_rescue_cmd_linux (int argc, char *argv[]); void grub_rescue_cmd_linux (int argc, char *argv[]);
void pupa_rescue_cmd_initrd (int argc, char *argv[]); void grub_rescue_cmd_initrd (int argc, char *argv[]);
void pupa_rescue_cmd_multiboot (int argc, char *argv[]); void grub_rescue_cmd_multiboot (int argc, char *argv[]);
void pupa_rescue_cmd_module (int argc, char *argv[]); void grub_rescue_cmd_module (int argc, char *argv[]);
#endif /* ! PUPA_LOADER_MACHINE_HEADER */ #endif /* ! GRUB_LOADER_MACHINE_HEADER */

View file

@ -1,6 +1,6 @@
/* multiboot.h - multiboot header file. */ /* multiboot.h - multiboot header file. */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 2004 Free Software Foundation, Inc. * Copyright (C) 2003, 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,167 +18,167 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_MULTIBOOT_MACHINE_HEADER #ifndef GRUB_MULTIBOOT_MACHINE_HEADER
#define PUPA_MULTIBOOT_MACHINE_HEADER 1 #define GRUB_MULTIBOOT_MACHINE_HEADER 1
/* How many bytes from the start of the file we search for the header. */ /* How many bytes from the start of the file we search for the header. */
#define PUPA_MB_SEARCH 8192 #define GRUB_MB_SEARCH 8192
/* The magic field should contain this. */ /* The magic field should contain this. */
#define PUPA_MB_MAGIC 0x1BADB002 #define GRUB_MB_MAGIC 0x1BADB002
/* This should be in %eax. */ /* This should be in %eax. */
#define PUPA_MB_MAGIC2 0x2BADB002 #define GRUB_MB_MAGIC2 0x2BADB002
/* The bits in the required part of flags field we don't support. */ /* The bits in the required part of flags field we don't support. */
#define PUPA_MB_UNSUPPORTED 0x0000fffc #define GRUB_MB_UNSUPPORTED 0x0000fffc
/* Alignment of multiboot modules. */ /* Alignment of multiboot modules. */
#define PUPA_MB_MOD_ALIGN 0x00001000 #define GRUB_MB_MOD_ALIGN 0x00001000
/* /*
* Flags set in the 'flags' member of the multiboot header. * Flags set in the 'flags' member of the multiboot header.
*/ */
/* Align all boot modules on i386 page (4KB) boundaries. */ /* Align all boot modules on i386 page (4KB) boundaries. */
#define PUPA_MB_PAGE_ALIGN 0x00000001 #define GRUB_MB_PAGE_ALIGN 0x00000001
/* Must pass memory information to OS. */ /* Must pass memory information to OS. */
#define PUPA_MB_MEMORY_INFO 0x00000002 #define GRUB_MB_MEMORY_INFO 0x00000002
/* Must pass video information to OS. */ /* Must pass video information to OS. */
#define PUPA_MB_VIDEO_MODE 0x00000004 #define GRUB_MB_VIDEO_MODE 0x00000004
/* This flag indicates the use of the address fields in the header. */ /* This flag indicates the use of the address fields in the header. */
#define PUPA_MB_AOUT_KLUDGE 0x00010000 #define GRUB_MB_AOUT_KLUDGE 0x00010000
/* /*
* Flags to be set in the 'flags' member of the multiboot info structure. * Flags to be set in the 'flags' member of the multiboot info structure.
*/ */
/* is there basic lower/upper memory information? */ /* is there basic lower/upper memory information? */
#define PUPA_MB_INFO_MEMORY 0x00000001 #define GRUB_MB_INFO_MEMORY 0x00000001
/* is there a boot device set? */ /* is there a boot device set? */
#define PUPA_MB_INFO_BOOTDEV 0x00000002 #define GRUB_MB_INFO_BOOTDEV 0x00000002
/* is the command-line defined? */ /* is the command-line defined? */
#define PUPA_MB_INFO_CMDLINE 0x00000004 #define GRUB_MB_INFO_CMDLINE 0x00000004
/* are there modules to do something with? */ /* are there modules to do something with? */
#define PUPA_MB_INFO_MODS 0x00000008 #define GRUB_MB_INFO_MODS 0x00000008
/* These next two are mutually exclusive */ /* These next two are mutually exclusive */
/* is there a symbol table loaded? */ /* is there a symbol table loaded? */
#define PUPA_MB_INFO_AOUT_SYMS 0x00000010 #define GRUB_MB_INFO_AOUT_SYMS 0x00000010
/* is there an ELF section header table? */ /* is there an ELF section header table? */
#define PUPA_MB_INFO_ELF_SHDR 0x00000020 #define GRUB_MB_INFO_ELF_SHDR 0x00000020
/* is there a full memory map? */ /* is there a full memory map? */
#define PUPA_MB_INFO_MEM_MAP 0x00000040 #define GRUB_MB_INFO_MEM_MAP 0x00000040
/* Is there drive info? */ /* Is there drive info? */
#define PUPA_MB_INFO_DRIVE_INFO 0x00000080 #define GRUB_MB_INFO_DRIVE_INFO 0x00000080
/* Is there a config table? */ /* Is there a config table? */
#define PUPA_MB_INFO_CONFIG_TABLE 0x00000100 #define GRUB_MB_INFO_CONFIG_TABLE 0x00000100
/* Is there a boot loader name? */ /* Is there a boot loader name? */
#define PUPA_MB_INFO_BOOT_LOADER_NAME 0x00000200 #define GRUB_MB_INFO_BOOT_LOADER_NAME 0x00000200
/* Is there a APM table? */ /* Is there a APM table? */
#define PUPA_MB_INFO_APM_TABLE 0x00000400 #define GRUB_MB_INFO_APM_TABLE 0x00000400
/* Is there video information? */ /* Is there video information? */
#define PUPA_MB_INFO_VIDEO_INFO 0x00000800 #define GRUB_MB_INFO_VIDEO_INFO 0x00000800
#ifndef ASM_FILE #ifndef ASM_FILE
#include <pupa/types.h> #include <grub/types.h>
struct pupa_multiboot_header struct grub_multiboot_header
{ {
/* Must be PUPA_MB_MAGIC - see above. */ /* Must be GRUB_MB_MAGIC - see above. */
pupa_uint32_t magic; grub_uint32_t magic;
/* Feature flags. */ /* Feature flags. */
pupa_uint32_t flags; grub_uint32_t flags;
/* The above fields plus this one must equal 0 mod 2^32. */ /* The above fields plus this one must equal 0 mod 2^32. */
pupa_uint32_t checksum; grub_uint32_t checksum;
/* These are only valid if PUPA_MB_AOUT_KLUDGE is set. */ /* These are only valid if GRUB_MB_AOUT_KLUDGE is set. */
pupa_uint32_t header_addr; grub_uint32_t header_addr;
pupa_uint32_t load_addr; grub_uint32_t load_addr;
pupa_uint32_t load_end_addr; grub_uint32_t load_end_addr;
pupa_uint32_t bss_end_addr; grub_uint32_t bss_end_addr;
pupa_uint32_t entry_addr; grub_uint32_t entry_addr;
/* These are only valid if PUPA_MB_VIDEO_MODE is set. */ /* These are only valid if GRUB_MB_VIDEO_MODE is set. */
pupa_uint32_t mode_type; grub_uint32_t mode_type;
pupa_uint32_t width; grub_uint32_t width;
pupa_uint32_t height; grub_uint32_t height;
pupa_uint32_t depth; grub_uint32_t depth;
}; };
struct pupa_multiboot_info struct grub_multiboot_info
{ {
/* MultiBoot info version number */ /* MultiBoot info version number */
pupa_uint32_t flags; grub_uint32_t flags;
/* Available memory from BIOS */ /* Available memory from BIOS */
pupa_uint32_t mem_lower; grub_uint32_t mem_lower;
pupa_uint32_t mem_upper; grub_uint32_t mem_upper;
/* "root" partition */ /* "root" partition */
pupa_uint32_t boot_device; grub_uint32_t boot_device;
/* Kernel command line */ /* Kernel command line */
pupa_uint32_t cmdline; grub_uint32_t cmdline;
/* Boot-Module list */ /* Boot-Module list */
pupa_uint32_t mods_count; grub_uint32_t mods_count;
pupa_uint32_t mods_addr; grub_uint32_t mods_addr;
pupa_uint32_t syms[4]; grub_uint32_t syms[4];
/* Memory Mapping buffer */ /* Memory Mapping buffer */
pupa_uint32_t mmap_length; grub_uint32_t mmap_length;
pupa_uint32_t mmap_addr; grub_uint32_t mmap_addr;
/* Drive Info buffer */ /* Drive Info buffer */
pupa_uint32_t drives_length; grub_uint32_t drives_length;
pupa_uint32_t drives_addr; grub_uint32_t drives_addr;
/* ROM configuration table */ /* ROM configuration table */
pupa_uint32_t config_table; grub_uint32_t config_table;
/* Boot Loader Name */ /* Boot Loader Name */
pupa_uint32_t boot_loader_name; grub_uint32_t boot_loader_name;
/* APM table */ /* APM table */
pupa_uint32_t apm_table; grub_uint32_t apm_table;
/* Video */ /* Video */
pupa_uint32_t vbe_control_info; grub_uint32_t vbe_control_info;
pupa_uint32_t vbe_mode_info; grub_uint32_t vbe_mode_info;
pupa_uint16_t vbe_mode; grub_uint16_t vbe_mode;
pupa_uint16_t vbe_interface_seg; grub_uint16_t vbe_interface_seg;
pupa_uint16_t vbe_interface_off; grub_uint16_t vbe_interface_off;
pupa_uint16_t vbe_interface_len; grub_uint16_t vbe_interface_len;
}; };
struct pupa_mod_list struct grub_mod_list
{ {
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
pupa_uint32_t mod_start; grub_uint32_t mod_start;
pupa_uint32_t mod_end; grub_uint32_t mod_end;
/* Module command line */ /* Module command line */
pupa_uint32_t cmdline; grub_uint32_t cmdline;
/* padding to take it to 16 bytes (must be zero) */ /* padding to take it to 16 bytes (must be zero) */
pupa_uint32_t pad; grub_uint32_t pad;
}; };
#endif /* ! ASM_FILE */ #endif /* ! ASM_FILE */
#endif /* ! PUPA_MULTIBOOT_MACHINE_HEADER */ #endif /* ! GRUB_MULTIBOOT_MACHINE_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2004 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2001,2002,2004 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,36 +13,36 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_PARTITION_HEADER #ifndef GRUB_PARTITION_HEADER
#define PUPA_PARTITION_HEADER 1 #define GRUB_PARTITION_HEADER 1
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/err.h> #include <grub/err.h>
#define PUPA_APPLE_PART_MAGIC 0x504D #define GRUB_APPLE_PART_MAGIC 0x504D
struct pupa_apple_part struct grub_apple_part
{ {
/* The magic number to idenify this as a partition, it should have /* The magic number to idenify this as a partition, it should have
the value `0x504D'. */ the value `0x504D'. */
pupa_uint16_t magic; grub_uint16_t magic;
/* Reserved. */ /* Reserved. */
pupa_uint16_t reserved; grub_uint16_t reserved;
/* The size of the partition map in blocks. */ /* The size of the partition map in blocks. */
pupa_uint32_t partmap_size; grub_uint32_t partmap_size;
/* The first physical block of the partition. */ /* The first physical block of the partition. */
pupa_uint32_t first_phys_block; grub_uint32_t first_phys_block;
/* The amount of blocks. */ /* The amount of blocks. */
pupa_uint32_t blockcnt; grub_uint32_t blockcnt;
/* The partition name. */ /* The partition name. */
char partname[32]; char partname[32];
@ -51,44 +51,44 @@ struct pupa_apple_part
char parttype[32]; char parttype[32];
/* The first datablock of the partition. */ /* The first datablock of the partition. */
pupa_uint32_t datablocks_first; grub_uint32_t datablocks_first;
/* The amount datablocks. */ /* The amount datablocks. */
pupa_uint32_t datablocks_count; grub_uint32_t datablocks_count;
/* The status of the partition. (???) */ /* The status of the partition. (???) */
pupa_uint32_t status; grub_uint32_t status;
/* The first block on which the bootcode can be found. */ /* The first block on which the bootcode can be found. */
pupa_uint32_t bootcode_pos; grub_uint32_t bootcode_pos;
/* The size of the bootcode in bytes. */ /* The size of the bootcode in bytes. */
pupa_uint32_t bootcode_size; grub_uint32_t bootcode_size;
/* The load address of the bootcode. */ /* The load address of the bootcode. */
pupa_uint32_t bootcode_loadaddr; grub_uint32_t bootcode_loadaddr;
/* Reserved. */ /* Reserved. */
pupa_uint32_t reserved2; grub_uint32_t reserved2;
/* The entrypoint of the bootcode. */ /* The entrypoint of the bootcode. */
pupa_uint32_t bootcode_entrypoint; grub_uint32_t bootcode_entrypoint;
/* Reserved. */ /* Reserved. */
pupa_uint32_t reserved3; grub_uint32_t reserved3;
/* A checksum of the bootcode. */ /* A checksum of the bootcode. */
pupa_uint32_t bootcode_checksum; grub_uint32_t bootcode_checksum;
/* The processor type. */ /* The processor type. */
char processor[16]; char processor[16];
/* Padding. */ /* Padding. */
pupa_uint16_t pad[187]; grub_uint16_t pad[187];
}; };
/* Partition description. */ /* Partition description. */
struct pupa_partition struct grub_partition
{ {
/* The start sector. */ /* The start sector. */
unsigned long start; unsigned long start;
@ -114,27 +114,27 @@ struct pupa_partition
/* The BSD partition type. */ /* The BSD partition type. */
int bsd_type; int bsd_type;
}; };
typedef struct pupa_partition *pupa_partition_t; typedef struct grub_partition *grub_partition_t;
struct pupa_disk; struct grub_disk;
pupa_partition_t EXPORT_FUNC(pupa_partition_probe) (struct pupa_disk *disk, grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk,
const char *str); const char *str);
pupa_err_t EXPORT_FUNC(pupa_partition_iterate) (struct pupa_disk *disk, grub_err_t EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
int (*hook) (const pupa_partition_t partition)); int (*hook) (const grub_partition_t partition));
char *EXPORT_FUNC(pupa_partition_get_name) (const pupa_partition_t partition); char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
static inline unsigned long static inline unsigned long
pupa_partition_get_start (const pupa_partition_t p) grub_partition_get_start (const grub_partition_t p)
{ {
return p->start; return p->start;
} }
static inline unsigned long static inline unsigned long
pupa_partition_get_len (const pupa_partition_t p) grub_partition_get_len (const grub_partition_t p)
{ {
return p->len; return p->len;
} }
#endif /* ! PUPA_PARTITION_HEADER */ #endif /* ! GRUB_PARTITION_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Marco Gerards <metgerards@student.han.nl> * Copyright (C) 2003 Marco Gerards <metgerards@student.han.nl>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -20,14 +20,14 @@
#ifndef KERNEL_TIME_HEADER #ifndef KERNEL_TIME_HEADER
#define KERNEL_TIME_HEADER 1 #define KERNEL_TIME_HEADER 1
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
# include <time.h> # include <time.h>
# define PUPA_TICKS_PER_SECOND CLOCKS_PER_SEC # define GRUB_TICKS_PER_SECOND CLOCKS_PER_SEC
#else #else
# define PUPA_TICKS_PER_SECOND 18 # define GRUB_TICKS_PER_SECOND 18
#endif #endif
/* Return the real time in ticks. */ /* Return the real time in ticks. */
pupa_uint32_t pupa_get_rtc (void); grub_uint32_t grub_get_rtc (void);
#endif /* ! KERNEL_TIME_HEADER */ #endif /* ! KERNEL_TIME_HEADER */

View file

@ -1,9 +1,9 @@
/* biosdisk.h - emulate biosdisk */ /* biosdisk.h - emulate biosdisk */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2004 Free Software Foundation, Inc. * Copyright (C) 2002, 2004 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,15 +14,15 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_BIOSDISK_MACHINE_UTIL_HEADER #ifndef GRUB_BIOSDISK_MACHINE_UTIL_HEADER
#define PUPA_BIOSDISK_MACHINE_UTIL_HEADER 1 #define GRUB_BIOSDISK_MACHINE_UTIL_HEADER 1
void pupa_util_biosdisk_init (const char *dev_map); void grub_util_biosdisk_init (const char *dev_map);
void pupa_util_biosdisk_fini (void); void grub_util_biosdisk_fini (void);
char *pupa_util_biosdisk_get_pupa_dev (const char *os_dev); char *grub_util_biosdisk_get_grub_dev (const char *os_dev);
#endif /* ! PUPA_BIOSDISK_MACHINE_UTIL_HEADER */ #endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2004 Free Software Foundation, Inc. * Copyright (C) 2002, 2004 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,9 +17,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_SETJMP_CPU_HEADER #ifndef GRUB_SETJMP_CPU_HEADER
#define PUPA_SETJMP_CPU_HEADER 1 #define GRUB_SETJMP_CPU_HEADER 1
typedef unsigned long pupa_jmp_buf[6]; typedef unsigned long grub_jmp_buf[6];
#endif /* ! PUPA_SETJMP_CPU_HEADER */ #endif /* ! GRUB_SETJMP_CPU_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2004 Free Software Foundation, Inc. * Copyright (C) 2002, 2004 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,20 +13,20 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_TYPES_CPU_HEADER #ifndef GRUB_TYPES_CPU_HEADER
#define PUPA_TYPES_CPU_HEADER 1 #define GRUB_TYPES_CPU_HEADER 1
/* The size of void *. */ /* The size of void *. */
#define PUPA_HOST_SIZEOF_VOID_P 4 #define GRUB_HOST_SIZEOF_VOID_P 4
/* The size of long. */ /* The size of long. */
#define PUPA_HOST_SIZEOF_LONG 4 #define GRUB_HOST_SIZEOF_LONG 4
/* powerpc is little-endian. */ /* powerpc is little-endian. */
#undef PUPA_HOST_WORDS_LITTLEENDIAN #undef GRUB_HOST_WORDS_LITTLEENDIAN
#endif /* ! PUPA_TYPES_CPU_HEADER */ #endif /* ! GRUB_TYPES_CPU_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,21 +17,21 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_RESCUE_HEADER #ifndef GRUB_RESCUE_HEADER
#define PUPA_RESCUE_HEADER 1 #define GRUB_RESCUE_HEADER 1
#include <pupa/symbol.h> #include <grub/symbol.h>
/* Enter rescue mode. */ /* Enter rescue mode. */
void pupa_enter_rescue_mode (void); void grub_enter_rescue_mode (void);
/* Register a rescue mode command. */ /* Register a rescue mode command. */
void EXPORT_FUNC(pupa_rescue_register_command) (const char *name, void EXPORT_FUNC(grub_rescue_register_command) (const char *name,
void (*func) (int argc, void (*func) (int argc,
char *argv[]), char *argv[]),
const char *message); const char *message);
/* Unregister a rescue mode command. */ /* Unregister a rescue mode command. */
void EXPORT_FUNC(pupa_rescue_unregister_command) (const char *name); void EXPORT_FUNC(grub_rescue_unregister_command) (const char *name);
#endif /* ! PUPA_RESCUE_HEADER */ #endif /* ! GRUB_RESCUE_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,20 +17,20 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_SETJMP_HEADER #ifndef GRUB_SETJMP_HEADER
#define PUPA_SETJMP_HEADER 1 #define GRUB_SETJMP_HEADER 1
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
#include <setjmp.h> #include <setjmp.h>
typedef jmp_buf pupa_jmp_buf; typedef jmp_buf grub_jmp_buf;
#define pupa_setjmp setjmp #define grub_setjmp setjmp
#define pupa_longjmp longjmp #define grub_longjmp longjmp
#else #else
/* This must define pupa_jmp_buf. */ /* This must define grub_jmp_buf. */
#include <pupa/cpu/setjmp.h> #include <grub/cpu/setjmp.h>
int pupa_setjmp (pupa_jmp_buf env); int grub_setjmp (grub_jmp_buf env);
void pupa_longjmp (pupa_jmp_buf env, int val) __attribute__ ((noreturn)); void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));
#endif #endif
#endif /* ! PUPA_SETJMP_HEADER */ #endif /* ! GRUB_SETJMP_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,12 +13,12 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_SYMBOL_HEADER #ifndef GRUB_SYMBOL_HEADER
#define PUPA_SYMBOL_HEADER 1 #define GRUB_SYMBOL_HEADER 1
#include <config.h> #include <config.h>
@ -36,4 +36,4 @@
#define EXPORT_FUNC(x) x #define EXPORT_FUNC(x) x
#define EXPORT_VAR(x) x #define EXPORT_VAR(x) x
#endif /* ! PUPA_SYMBOL_HEADER */ #endif /* ! GRUB_SYMBOL_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,29 +13,29 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_TERM_HEADER #ifndef GRUB_TERM_HEADER
#define PUPA_TERM_HEADER 1 #define GRUB_TERM_HEADER 1
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/types.h> #include <grub/types.h>
/* These are used to represent the various color states we use. */ /* These are used to represent the various color states we use. */
typedef enum typedef enum
{ {
/* The color used to display all text that does not use the /* The color used to display all text that does not use the
user defined colors below. */ user defined colors below. */
PUPA_TERM_COLOR_STANDARD, GRUB_TERM_COLOR_STANDARD,
/* The user defined colors for normal text. */ /* The user defined colors for normal text. */
PUPA_TERM_COLOR_NORMAL, GRUB_TERM_COLOR_NORMAL,
/* The user defined colors for highlighted text. */ /* The user defined colors for highlighted text. */
PUPA_TERM_COLOR_HIGHLIGHT GRUB_TERM_COLOR_HIGHLIGHT
} }
pupa_term_color_state; grub_term_color_state;
/* Flags for representing the capabilities of a terminal. */ /* Flags for representing the capabilities of a terminal. */
/* Some notes about the flags: /* Some notes about the flags:
@ -47,27 +47,27 @@ pupa_term_color_state;
to NULL. */ to NULL. */
/* Set when input characters shouldn't be echoed back. */ /* Set when input characters shouldn't be echoed back. */
#define PUPA_TERM_NO_ECHO (1 << 0) #define GRUB_TERM_NO_ECHO (1 << 0)
/* Set when the editing feature should be disabled. */ /* Set when the editing feature should be disabled. */
#define PUPA_TERM_NO_EDIT (1 << 1) #define GRUB_TERM_NO_EDIT (1 << 1)
/* Set when the terminal cannot do fancy things. */ /* Set when the terminal cannot do fancy things. */
#define PUPA_TERM_DUMB (1 << 2) #define GRUB_TERM_DUMB (1 << 2)
/* Set when the terminal needs to be initialized. */ /* Set when the terminal needs to be initialized. */
#define PUPA_TERM_NEED_INIT (1 << 16) #define GRUB_TERM_NEED_INIT (1 << 16)
struct pupa_term struct grub_term
{ {
/* The terminal name. */ /* The terminal name. */
const char *name; const char *name;
/* Initialize the terminal. */ /* Initialize the terminal. */
pupa_err_t (*init) (void); grub_err_t (*init) (void);
/* Clean up the terminal. */ /* Clean up the terminal. */
pupa_err_t (*fini) (void); grub_err_t (*fini) (void);
/* Put a character. C is encoded in Unicode. */ /* Put a character. C is encoded in Unicode. */
void (*putchar) (pupa_uint32_t c); void (*putchar) (grub_uint32_t c);
/* Check if any input character is available. */ /* Check if any input character is available. */
int (*checkkey) (void); int (*checkkey) (void);
@ -76,20 +76,20 @@ struct pupa_term
int (*getkey) (void); int (*getkey) (void);
/* Get the cursor position. The return value is ((X << 8) | Y). */ /* Get the cursor position. The return value is ((X << 8) | Y). */
pupa_uint16_t (*getxy) (void); grub_uint16_t (*getxy) (void);
/* Go to the position (X, Y). */ /* Go to the position (X, Y). */
void (*gotoxy) (pupa_uint8_t x, pupa_uint8_t y); void (*gotoxy) (grub_uint8_t x, grub_uint8_t y);
/* Clear the screen. */ /* Clear the screen. */
void (*cls) (void); void (*cls) (void);
/* Set the current color to be used */ /* Set the current color to be used */
void (*setcolorstate) (pupa_term_color_state state); void (*setcolorstate) (grub_term_color_state state);
/* Set the normal color and the highlight color. The format of each /* Set the normal color and the highlight color. The format of each
color is VGA's. */ color is VGA's. */
void (*setcolor) (pupa_uint8_t normal_color, pupa_uint8_t highlight_color); void (*setcolor) (grub_uint8_t normal_color, grub_uint8_t highlight_color);
/* Turn on/off the cursor. */ /* Turn on/off the cursor. */
void (*setcursor) (int on); void (*setcursor) (int on);
@ -98,35 +98,35 @@ struct pupa_term
void (*refresh) (void); void (*refresh) (void);
/* The feature flags defined above. */ /* The feature flags defined above. */
pupa_uint32_t flags; grub_uint32_t flags;
/* The next terminal. */ /* The next terminal. */
struct pupa_term *next; struct grub_term *next;
}; };
typedef struct pupa_term *pupa_term_t; typedef struct grub_term *grub_term_t;
void EXPORT_FUNC(pupa_term_register) (pupa_term_t term); void EXPORT_FUNC(grub_term_register) (grub_term_t term);
void EXPORT_FUNC(pupa_term_unregister) (pupa_term_t term); void EXPORT_FUNC(grub_term_unregister) (grub_term_t term);
void EXPORT_FUNC(pupa_term_iterate) (int (*hook) (pupa_term_t term)); void EXPORT_FUNC(grub_term_iterate) (int (*hook) (grub_term_t term));
pupa_err_t EXPORT_FUNC(pupa_term_set_current) (pupa_term_t term); grub_err_t EXPORT_FUNC(grub_term_set_current) (grub_term_t term);
pupa_term_t EXPORT_FUNC(pupa_term_get_current) (void); grub_term_t EXPORT_FUNC(grub_term_get_current) (void);
void EXPORT_FUNC(pupa_putchar) (int c); void EXPORT_FUNC(grub_putchar) (int c);
void EXPORT_FUNC(pupa_putcode) (pupa_uint32_t code); void EXPORT_FUNC(grub_putcode) (grub_uint32_t code);
int EXPORT_FUNC(pupa_getkey) (void); int EXPORT_FUNC(grub_getkey) (void);
int EXPORT_FUNC(pupa_checkkey) (void); int EXPORT_FUNC(grub_checkkey) (void);
pupa_uint16_t EXPORT_FUNC(pupa_getxy) (void); grub_uint16_t EXPORT_FUNC(grub_getxy) (void);
void EXPORT_FUNC(pupa_gotoxy) (pupa_uint8_t x, pupa_uint8_t y); void EXPORT_FUNC(grub_gotoxy) (grub_uint8_t x, grub_uint8_t y);
void EXPORT_FUNC(pupa_cls) (void); void EXPORT_FUNC(grub_cls) (void);
void EXPORT_FUNC(pupa_setcolorstate) (pupa_term_color_state state); void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state);
void EXPORT_FUNC(pupa_setcolor) (pupa_uint8_t normal_color, void EXPORT_FUNC(grub_setcolor) (grub_uint8_t normal_color,
pupa_uint8_t highlight_color); grub_uint8_t highlight_color);
int EXPORT_FUNC(pupa_setcursor) (int on); int EXPORT_FUNC(grub_setcursor) (int on);
void EXPORT_FUNC(pupa_refresh) (void); void EXPORT_FUNC(grub_refresh) (void);
void EXPORT_FUNC(pupa_set_more) (int onoff); void EXPORT_FUNC(grub_set_more) (int onoff);
/* For convenience. */ /* For convenience. */
#define PUPA_TERM_ASCII_CHAR(c) ((c) & 0xff) #define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff)
#endif /* ! PUPA_TERM_HEADER */ #endif /* ! GRUB_TERM_HEADER */

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,125 +17,125 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_TYPES_HEADER #ifndef GRUB_TYPES_HEADER
#define PUPA_TYPES_HEADER 1 #define GRUB_TYPES_HEADER 1
#include <config.h> #include <config.h>
#include <pupa/cpu/types.h> #include <grub/cpu/types.h>
#ifdef PUPA_UTIL #ifdef GRUB_UTIL
# define PUPA_CPU_SIZEOF_VOID_P SIZEOF_VOID_P # define GRUB_CPU_SIZEOF_VOID_P SIZEOF_VOID_P
# define PUPA_CPU_SIZEOF_LONG SIZEOF_LONG # define GRUB_CPU_SIZEOF_LONG SIZEOF_LONG
# ifdef WORDS_BIGENDIAN # ifdef WORDS_BIGENDIAN
# define PUPA_CPU_WORDS_BIGENDIAN 1 # define GRUB_CPU_WORDS_BIGENDIAN 1
# else # else
# undef PUPA_CPU_WORDS_BIGENDIAN # undef GRUB_CPU_WORDS_BIGENDIAN
# endif # endif
#else /* ! PUPA_UTIL */ #else /* ! GRUB_UTIL */
# define PUPA_CPU_SIZEOF_VOID_P PUPA_HOST_SIZEOF_VOID_P # define GRUB_CPU_SIZEOF_VOID_P GRUB_HOST_SIZEOF_VOID_P
# define PUPA_CPU_SIZEOF_LONG PUPA_HOST_SIZEOF_LONG # define GRUB_CPU_SIZEOF_LONG GRUB_HOST_SIZEOF_LONG
# ifdef PUPA_HOST_WORDS_BIGENDIAN # ifdef GRUB_HOST_WORDS_BIGENDIAN
# define PUPA_CPU_WORDS_BIGENDIAN 1 # define GRUB_CPU_WORDS_BIGENDIAN 1
# else # else
# undef PUPA_CPU_WORDS_BIGENDIAN # undef GRUB_CPU_WORDS_BIGENDIAN
# endif # endif
#endif /* ! PUPA_UTIL */ #endif /* ! GRUB_UTIL */
#if PUPA_CPU_SIZEOF_VOID_P != PUPA_CPU_SIZEOF_LONG #if GRUB_CPU_SIZEOF_VOID_P != GRUB_CPU_SIZEOF_LONG
# error "This architecture is not supported because sizeof(void *) != sizeof(long)" # error "This architecture is not supported because sizeof(void *) != sizeof(long)"
#endif #endif
#if PUPA_CPU_SIZEOF_VOID_P != 4 && PUPA_CPU_SIZEOF_VOID_P != 8 #if GRUB_CPU_SIZEOF_VOID_P != 4 && GRUB_CPU_SIZEOF_VOID_P != 8
# error "This architecture is not supported because sizeof(void *) != 4 and sizeof(void *) != 8" # error "This architecture is not supported because sizeof(void *) != 4 and sizeof(void *) != 8"
#endif #endif
/* Define various wide integers. */ /* Define various wide integers. */
typedef signed char pupa_int8_t; typedef signed char grub_int8_t;
typedef short pupa_int16_t; typedef short grub_int16_t;
typedef int pupa_int32_t; typedef int grub_int32_t;
#if PUPA_CPU_SIZEOF_VOID_P == 8 #if GRUB_CPU_SIZEOF_VOID_P == 8
typedef long pupa_int64_t; typedef long grub_int64_t;
#else #else
typedef long long pupa_int64_t; typedef long long grub_int64_t;
#endif #endif
typedef unsigned char pupa_uint8_t; typedef unsigned char grub_uint8_t;
typedef unsigned short pupa_uint16_t; typedef unsigned short grub_uint16_t;
typedef unsigned pupa_uint32_t; typedef unsigned grub_uint32_t;
#if PUPA_CPU_SIZEOF_VOID_P == 8 #if GRUB_CPU_SIZEOF_VOID_P == 8
typedef unsigned long pupa_uint64_t; typedef unsigned long grub_uint64_t;
#else #else
typedef unsigned long long pupa_uint64_t; typedef unsigned long long grub_uint64_t;
#endif #endif
/* Misc types. */ /* Misc types. */
#if PUPA_HOST_SIZEOF_VOID_P == 8 #if GRUB_HOST_SIZEOF_VOID_P == 8
typedef pupa_uint64_t pupa_addr_t; typedef grub_uint64_t grub_addr_t;
typedef pupa_uint64_t pupa_off_t; typedef grub_uint64_t grub_off_t;
typedef pupa_uint64_t pupa_size_t; typedef grub_uint64_t grub_size_t;
typedef pupa_int64_t pupa_ssize_t; typedef grub_int64_t grub_ssize_t;
#else #else
typedef pupa_uint32_t pupa_addr_t; typedef grub_uint32_t grub_addr_t;
typedef pupa_uint32_t pupa_off_t; typedef grub_uint32_t grub_off_t;
typedef pupa_uint32_t pupa_size_t; typedef grub_uint32_t grub_size_t;
typedef pupa_int32_t pupa_ssize_t; typedef grub_int32_t grub_ssize_t;
#endif #endif
/* Byte-orders. */ /* Byte-orders. */
#define pupa_swap_bytes16(x) \ #define grub_swap_bytes16(x) \
({ \ ({ \
pupa_uint16_t _x = (x); \ grub_uint16_t _x = (x); \
(pupa_uint16_t) ((_x << 8) | (_x >> 8)); \ (grub_uint16_t) ((_x << 8) | (_x >> 8)); \
}) })
#define pupa_swap_bytes32(x) \ #define grub_swap_bytes32(x) \
({ \ ({ \
pupa_uint32_t _x = (x); \ grub_uint32_t _x = (x); \
(pupa_uint32_t) ((_x << 24) \ (grub_uint32_t) ((_x << 24) \
| ((_x & (pupa_uint32_t) 0xFF00UL) << 8) \ | ((_x & (grub_uint32_t) 0xFF00UL) << 8) \
| ((_x & (pupa_uint32_t) 0xFF0000UL) >> 8) \ | ((_x & (grub_uint32_t) 0xFF0000UL) >> 8) \
| (_x >> 24)); \ | (_x >> 24)); \
}) })
#define pupa_swap_bytes64(x) \ #define grub_swap_bytes64(x) \
({ \ ({ \
pupa_uint64_t _x = (x); \ grub_uint64_t _x = (x); \
(pupa_uint64_t) ((_x << 56) \ (grub_uint64_t) ((_x << 56) \
| ((_x & (pupa_uint64_t) 0xFF00ULL) << 40) \ | ((_x & (grub_uint64_t) 0xFF00ULL) << 40) \
| ((_x & (pupa_uint64_t) 0xFF0000ULL) << 24) \ | ((_x & (grub_uint64_t) 0xFF0000ULL) << 24) \
| ((_x & (pupa_uint64_t) 0xFF000000ULL) << 8) \ | ((_x & (grub_uint64_t) 0xFF000000ULL) << 8) \
| ((_x & (pupa_uint64_t) 0xFF00000000ULL) >> 8) \ | ((_x & (grub_uint64_t) 0xFF00000000ULL) >> 8) \
| ((_x & (pupa_uint64_t) 0xFF0000000000ULL) >> 24) \ | ((_x & (grub_uint64_t) 0xFF0000000000ULL) >> 24) \
| ((_x & (pupa_uint64_t) 0xFF000000000000ULL) >> 40) \ | ((_x & (grub_uint64_t) 0xFF000000000000ULL) >> 40) \
| (_x >> 56)); \ | (_x >> 56)); \
}) })
#ifdef PUPA_CPU_WORDS_BIGENDIAN #ifdef GRUB_CPU_WORDS_BIGENDIAN
# define pupa_cpu_to_le16(x) pupa_swap_bytes16(x) # define grub_cpu_to_le16(x) grub_swap_bytes16(x)
# define pupa_cpu_to_le32(x) pupa_swap_bytes32(x) # define grub_cpu_to_le32(x) grub_swap_bytes32(x)
# define pupa_cpu_to_le64(x) pupa_swap_bytes64(x) # define grub_cpu_to_le64(x) grub_swap_bytes64(x)
# define pupa_le_to_cpu16(x) pupa_swap_bytes16(x) # define grub_le_to_cpu16(x) grub_swap_bytes16(x)
# define pupa_le_to_cpu32(x) pupa_swap_bytes32(x) # define grub_le_to_cpu32(x) grub_swap_bytes32(x)
# define pupa_le_to_cpu64(x) pupa_swap_bytes64(x) # define grub_le_to_cpu64(x) grub_swap_bytes64(x)
# define pupa_cpu_to_be16(x) ((pupa_uint16_t) (x)) # define grub_cpu_to_be16(x) ((grub_uint16_t) (x))
# define pupa_cpu_to_be32(x) ((pupa_uint32_t) (x)) # define grub_cpu_to_be32(x) ((grub_uint32_t) (x))
# define pupa_cpu_to_be64(x) ((pupa_uint64_t) (x)) # define grub_cpu_to_be64(x) ((grub_uint64_t) (x))
# define pupa_be_to_cpu16(x) ((pupa_uint16_t) (x)) # define grub_be_to_cpu16(x) ((grub_uint16_t) (x))
# define pupa_be_to_cpu32(x) ((pupa_uint32_t) (x)) # define grub_be_to_cpu32(x) ((grub_uint32_t) (x))
# define pupa_be_to_cpu64(x) ((pupa_uint64_t) (x)) # define grub_be_to_cpu64(x) ((grub_uint64_t) (x))
#else /* ! WORDS_BIGENDIAN */ #else /* ! WORDS_BIGENDIAN */
# define pupa_cpu_to_le16(x) ((pupa_uint16_t) (x)) # define grub_cpu_to_le16(x) ((grub_uint16_t) (x))
# define pupa_cpu_to_le32(x) ((pupa_uint32_t) (x)) # define grub_cpu_to_le32(x) ((grub_uint32_t) (x))
# define pupa_cpu_to_le64(x) ((pupa_uint64_t) (x)) # define grub_cpu_to_le64(x) ((grub_uint64_t) (x))
# define pupa_le_to_cpu16(x) ((pupa_uint16_t) (x)) # define grub_le_to_cpu16(x) ((grub_uint16_t) (x))
# define pupa_le_to_cpu32(x) ((pupa_uint32_t) (x)) # define grub_le_to_cpu32(x) ((grub_uint32_t) (x))
# define pupa_le_to_cpu64(x) ((pupa_uint64_t) (x)) # define grub_le_to_cpu64(x) ((grub_uint64_t) (x))
# define pupa_cpu_to_be16(x) pupa_swap_bytes16(x) # define grub_cpu_to_be16(x) grub_swap_bytes16(x)
# define pupa_cpu_to_be32(x) pupa_swap_bytes32(x) # define grub_cpu_to_be32(x) grub_swap_bytes32(x)
# define pupa_cpu_to_be64(x) pupa_swap_bytes64(x) # define grub_cpu_to_be64(x) grub_swap_bytes64(x)
# define pupa_be_to_cpu16(x) pupa_swap_bytes16(x) # define grub_be_to_cpu16(x) grub_swap_bytes16(x)
# define pupa_be_to_cpu32(x) pupa_swap_bytes32(x) # define grub_be_to_cpu32(x) grub_swap_bytes32(x)
# define pupa_be_to_cpu64(x) pupa_swap_bytes64(x) # define grub_be_to_cpu64(x) grub_swap_bytes64(x)
#endif /* ! WORDS_BIGENDIAN */ #endif /* ! WORDS_BIGENDIAN */
#endif /* ! PUPA_TYPES_HEADER */ #endif /* ! GRUB_TYPES_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,14 +13,14 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_UTIL_GETROOT_HEADER #ifndef GRUB_UTIL_GETROOT_HEADER
#define PUPA_UTIL_GETROOT_HEADER 1 #define GRUB_UTIL_GETROOT_HEADER 1
char *pupa_guess_root_device (const char *dir); char *grub_guess_root_device (const char *dir);
char *pupa_get_prefix (const char *dir); char *grub_get_prefix (const char *dir);
#endif /* ! PUPA_UTIL_GETROOT_HEADER */ #endif /* ! GRUB_UTIL_GETROOT_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,12 +13,12 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_UTIL_MISC_HEADER #ifndef GRUB_UTIL_MISC_HEADER
#define PUPA_UTIL_MISC_HEADER 1 #define GRUB_UTIL_MISC_HEADER 1
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -26,17 +26,17 @@
extern char *progname; extern char *progname;
extern int verbosity; extern int verbosity;
void pupa_util_info (const char *fmt, ...); void grub_util_info (const char *fmt, ...);
void pupa_util_error (const char *fmt, ...) __attribute__ ((noreturn)); void grub_util_error (const char *fmt, ...) __attribute__ ((noreturn));
void *xmalloc (size_t size); void *xmalloc (size_t size);
void *xrealloc (void *ptr, size_t size); void *xrealloc (void *ptr, size_t size);
char *xstrdup (const char *str); char *xstrdup (const char *str);
char *pupa_util_get_path (const char *dir, const char *file); char *grub_util_get_path (const char *dir, const char *file);
size_t pupa_util_get_image_size (const char *path); size_t grub_util_get_image_size (const char *path);
char *pupa_util_read_image (const char *path); char *grub_util_read_image (const char *path);
void pupa_util_load_image (const char *path, char *buf); void grub_util_load_image (const char *path, char *buf);
void pupa_util_write_image (const char *img, size_t size, FILE *out); void grub_util_write_image (const char *img, size_t size, FILE *out);
#endif /* ! PUPA_UTIL_MISC_HEADER */ #endif /* ! GRUB_UTIL_MISC_HEADER */

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,24 +13,24 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef PUPA_UTIL_RESOLVE_HEADER #ifndef GRUB_UTIL_RESOLVE_HEADER
#define PUPA_UTIL_RESOLVE_HEADER 1 #define GRUB_UTIL_RESOLVE_HEADER 1
struct pupa_util_path_list struct grub_util_path_list
{ {
const char *name; const char *name;
struct pupa_util_path_list *next; struct grub_util_path_list *next;
}; };
/* Resolve the dependencies of the modules MODULES using the information /* Resolve the dependencies of the modules MODULES using the information
in the file DEP_LIST_FILE. The directory PREFIX is used to find files. */ in the file DEP_LIST_FILE. The directory PREFIX is used to find files. */
struct pupa_util_path_list * struct grub_util_path_list *
pupa_util_resolve_dependencies (const char *prefix, grub_util_resolve_dependencies (const char *prefix,
const char *dep_list_file, const char *dep_list_file,
char *modules[]); char *modules[]);
#endif /* ! PUPA_UTIL_RESOLVE_HEADER */ #endif /* ! GRUB_UTIL_RESOLVE_HEADER */

View file

@ -1,9 +1,9 @@
/* device.c - device manager */ /* device.c - device manager */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,62 +14,62 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/device.h> #include <grub/device.h>
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/net.h> #include <grub/net.h>
#include <pupa/fs.h> #include <grub/fs.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/misc.h> #include <grub/misc.h>
static char *pupa_device_root; static char *grub_device_root;
pupa_err_t grub_err_t
pupa_device_set_root (const char *name) grub_device_set_root (const char *name)
{ {
pupa_free (pupa_device_root); grub_free (grub_device_root);
pupa_device_root = pupa_strdup (name); grub_device_root = grub_strdup (name);
return pupa_errno; return grub_errno;
} }
const char * const char *
pupa_device_get_root (void) grub_device_get_root (void)
{ {
if (! pupa_device_root) if (! grub_device_root)
pupa_error (PUPA_ERR_BAD_DEVICE, "no root device"); grub_error (GRUB_ERR_BAD_DEVICE, "no root device");
return pupa_device_root; return grub_device_root;
} }
pupa_device_t grub_device_t
pupa_device_open (const char *name) grub_device_open (const char *name)
{ {
pupa_disk_t disk = 0; grub_disk_t disk = 0;
pupa_device_t dev = 0; grub_device_t dev = 0;
if (! name) if (! name)
{ {
if (! pupa_device_root) if (! grub_device_root)
{ {
pupa_error (PUPA_ERR_BAD_DEVICE, "no device is set"); grub_error (GRUB_ERR_BAD_DEVICE, "no device is set");
goto fail; goto fail;
} }
name = pupa_device_root; name = grub_device_root;
} }
dev = pupa_malloc (sizeof (*dev)); dev = grub_malloc (sizeof (*dev));
if (! dev) if (! dev)
goto fail; goto fail;
/* Try to open a disk. */ /* Try to open a disk. */
disk = pupa_disk_open (name); disk = grub_disk_open (name);
if (! disk) if (! disk)
{ {
pupa_error (PUPA_ERR_BAD_DEVICE, "unknown device"); grub_error (GRUB_ERR_BAD_DEVICE, "unknown device");
goto fail; goto fail;
} }
@ -80,20 +80,20 @@ pupa_device_open (const char *name)
fail: fail:
if (disk) if (disk)
pupa_disk_close (disk); grub_disk_close (disk);
pupa_free (dev); grub_free (dev);
return 0; return 0;
} }
pupa_err_t grub_err_t
pupa_device_close (pupa_device_t device) grub_device_close (grub_device_t device)
{ {
if (device->disk) if (device->disk)
pupa_disk_close (device->disk); grub_disk_close (device->disk);
pupa_free (device); grub_free (device);
return pupa_errno; return grub_errno;
} }

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,27 +13,27 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/machine/partition.h> #include <grub/machine/partition.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/machine/time.h> #include <grub/machine/time.h>
#include <pupa/file.h> #include <grub/file.h>
#define PUPA_CACHE_TIMEOUT 2 #define GRUB_CACHE_TIMEOUT 2
/* The last time the disk was used. */ /* The last time the disk was used. */
static unsigned long pupa_last_time = 0; static unsigned long grub_last_time = 0;
/* Disk cache. */ /* Disk cache. */
struct pupa_disk_cache struct grub_disk_cache
{ {
unsigned long id; unsigned long id;
unsigned long sector; unsigned long sector;
@ -41,142 +41,142 @@ struct pupa_disk_cache
int lock; int lock;
}; };
static struct pupa_disk_cache pupa_disk_cache_table[PUPA_DISK_CACHE_NUM]; static struct grub_disk_cache grub_disk_cache_table[GRUB_DISK_CACHE_NUM];
#if 0 #if 0
static unsigned long pupa_disk_cache_hits; static unsigned long grub_disk_cache_hits;
static unsigned long pupa_disk_cache_misses; static unsigned long grub_disk_cache_misses;
void void
pupa_disk_cache_get_performance (unsigned long *hits, unsigned long *misses) grub_disk_cache_get_performance (unsigned long *hits, unsigned long *misses)
{ {
*hits = pupa_disk_cache_hits; *hits = grub_disk_cache_hits;
*misses = pupa_disk_cache_misses; *misses = grub_disk_cache_misses;
} }
#endif #endif
static unsigned static unsigned
pupa_disk_cache_get_index (unsigned long id, unsigned long sector) grub_disk_cache_get_index (unsigned long id, unsigned long sector)
{ {
return ((id * 2606459 + (sector >> PUPA_DISK_CACHE_BITS)) return ((id * 2606459 + (sector >> GRUB_DISK_CACHE_BITS))
% PUPA_DISK_CACHE_NUM); % GRUB_DISK_CACHE_NUM);
} }
static void static void
pupa_disk_cache_invalidate (unsigned long id, unsigned long sector) grub_disk_cache_invalidate (unsigned long id, unsigned long sector)
{ {
unsigned index; unsigned index;
struct pupa_disk_cache *cache; struct grub_disk_cache *cache;
sector &= ~(PUPA_DISK_CACHE_SIZE - 1); sector &= ~(GRUB_DISK_CACHE_SIZE - 1);
index = pupa_disk_cache_get_index (id, sector); index = grub_disk_cache_get_index (id, sector);
cache = pupa_disk_cache_table + index; cache = grub_disk_cache_table + index;
if (cache->id == id && cache->sector == sector && cache->data) if (cache->id == id && cache->sector == sector && cache->data)
{ {
cache->lock = 1; cache->lock = 1;
pupa_free (cache->data); grub_free (cache->data);
cache->data = 0; cache->data = 0;
cache->lock = 0; cache->lock = 0;
} }
} }
void void
pupa_disk_cache_invalidate_all (void) grub_disk_cache_invalidate_all (void)
{ {
unsigned i; unsigned i;
for (i = 0; i < PUPA_DISK_CACHE_NUM; i++) for (i = 0; i < GRUB_DISK_CACHE_NUM; i++)
{ {
struct pupa_disk_cache *cache = pupa_disk_cache_table + i; struct grub_disk_cache *cache = grub_disk_cache_table + i;
if (cache->data && ! cache->lock) if (cache->data && ! cache->lock)
{ {
pupa_free (cache->data); grub_free (cache->data);
cache->data = 0; cache->data = 0;
} }
} }
} }
static char * static char *
pupa_disk_cache_fetch (unsigned long id, unsigned long sector) grub_disk_cache_fetch (unsigned long id, unsigned long sector)
{ {
struct pupa_disk_cache *cache; struct grub_disk_cache *cache;
unsigned index; unsigned index;
index = pupa_disk_cache_get_index (id, sector); index = grub_disk_cache_get_index (id, sector);
cache = pupa_disk_cache_table + index; cache = grub_disk_cache_table + index;
if (cache->id == id && cache->sector == sector) if (cache->id == id && cache->sector == sector)
{ {
cache->lock = 1; cache->lock = 1;
#if 0 #if 0
pupa_disk_cache_hits++; grub_disk_cache_hits++;
#endif #endif
return cache->data; return cache->data;
} }
#if 0 #if 0
pupa_disk_cache_misses++; grub_disk_cache_misses++;
#endif #endif
return 0; return 0;
} }
static void static void
pupa_disk_cache_unlock (unsigned long id, unsigned long sector) grub_disk_cache_unlock (unsigned long id, unsigned long sector)
{ {
struct pupa_disk_cache *cache; struct grub_disk_cache *cache;
unsigned index; unsigned index;
index = pupa_disk_cache_get_index (id, sector); index = grub_disk_cache_get_index (id, sector);
cache = pupa_disk_cache_table + index; cache = grub_disk_cache_table + index;
if (cache->id == id && cache->sector == sector) if (cache->id == id && cache->sector == sector)
cache->lock = 0; cache->lock = 0;
} }
static pupa_err_t static grub_err_t
pupa_disk_cache_store (unsigned long id, unsigned long sector, grub_disk_cache_store (unsigned long id, unsigned long sector,
const char *data) const char *data)
{ {
unsigned index; unsigned index;
struct pupa_disk_cache *cache; struct grub_disk_cache *cache;
pupa_disk_cache_invalidate (id, sector); grub_disk_cache_invalidate (id, sector);
index = pupa_disk_cache_get_index (id, sector); index = grub_disk_cache_get_index (id, sector);
cache = pupa_disk_cache_table + index; cache = grub_disk_cache_table + index;
cache->data = pupa_malloc (PUPA_DISK_SECTOR_SIZE << PUPA_DISK_CACHE_BITS); cache->data = grub_malloc (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
if (! cache->data) if (! cache->data)
return pupa_errno; return grub_errno;
pupa_memcpy (cache->data, data, grub_memcpy (cache->data, data,
PUPA_DISK_SECTOR_SIZE << PUPA_DISK_CACHE_BITS); GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
cache->id = id; cache->id = id;
cache->sector = sector; cache->sector = sector;
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
static pupa_disk_dev_t pupa_disk_dev_list; static grub_disk_dev_t grub_disk_dev_list;
void void
pupa_disk_dev_register (pupa_disk_dev_t dev) grub_disk_dev_register (grub_disk_dev_t dev)
{ {
dev->next = pupa_disk_dev_list; dev->next = grub_disk_dev_list;
pupa_disk_dev_list = dev; grub_disk_dev_list = dev;
} }
void void
pupa_disk_dev_unregister (pupa_disk_dev_t dev) grub_disk_dev_unregister (grub_disk_dev_t dev)
{ {
pupa_disk_dev_t *p, q; grub_disk_dev_t *p, q;
for (p = &pupa_disk_dev_list, q = *p; q; p = &(q->next), q = q->next) for (p = &grub_disk_dev_list, q = *p; q; p = &(q->next), q = q->next)
if (q == dev) if (q == dev)
{ {
*p = q->next; *p = q->next;
@ -185,25 +185,25 @@ pupa_disk_dev_unregister (pupa_disk_dev_t dev)
} }
void void
pupa_disk_dev_iterate (int (*hook) (const char *name)) grub_disk_dev_iterate (int (*hook) (const char *name))
{ {
pupa_disk_dev_t p; grub_disk_dev_t p;
for (p = pupa_disk_dev_list; p; p = p->next) for (p = grub_disk_dev_list; p; p = p->next)
if ((p->iterate) (hook)) if ((p->iterate) (hook))
break; break;
} }
pupa_disk_t grub_disk_t
pupa_disk_open (const char *name) grub_disk_open (const char *name)
{ {
char *p; char *p;
pupa_disk_t disk; grub_disk_t disk;
pupa_disk_dev_t dev; grub_disk_dev_t dev;
char *raw = (char *) name; char *raw = (char *) name;
unsigned long current_time; unsigned long current_time;
disk = (pupa_disk_t) pupa_malloc (sizeof (*disk)); disk = (grub_disk_t) grub_malloc (sizeof (*disk));
if (! disk) if (! disk)
return 0; return 0;
@ -211,67 +211,67 @@ pupa_disk_open (const char *name)
disk->read_hook = 0; disk->read_hook = 0;
disk->partition = 0; disk->partition = 0;
disk->data = 0; disk->data = 0;
disk->name = pupa_strdup (name); disk->name = grub_strdup (name);
if (! disk->name) if (! disk->name)
goto fail; goto fail;
p = pupa_strchr (name, ','); p = grub_strchr (name, ',');
if (p) if (p)
{ {
pupa_size_t len = p - name; grub_size_t len = p - name;
raw = pupa_malloc (len + 1); raw = grub_malloc (len + 1);
if (! raw) if (! raw)
goto fail; goto fail;
pupa_memcpy (raw, name, len); grub_memcpy (raw, name, len);
raw[len] = '\0'; raw[len] = '\0';
} }
for (dev = pupa_disk_dev_list; dev; dev = dev->next) for (dev = grub_disk_dev_list; dev; dev = dev->next)
{ {
if ((dev->open) (raw, disk) == PUPA_ERR_NONE) if ((dev->open) (raw, disk) == GRUB_ERR_NONE)
break; break;
else if (pupa_errno == PUPA_ERR_UNKNOWN_DEVICE) else if (grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
pupa_errno = PUPA_ERR_NONE; grub_errno = GRUB_ERR_NONE;
else else
goto fail; goto fail;
} }
if (! dev) if (! dev)
{ {
pupa_error (PUPA_ERR_UNKNOWN_DEVICE, "no such disk"); grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such disk");
goto fail; goto fail;
} }
if (p && ! disk->has_partitions) if (p && ! disk->has_partitions)
{ {
pupa_error (PUPA_ERR_BAD_DEVICE, "no partition on this disk"); grub_error (GRUB_ERR_BAD_DEVICE, "no partition on this disk");
goto fail; goto fail;
} }
disk->dev = dev; disk->dev = dev;
if (p) if (p)
disk->partition = pupa_partition_probe (disk, p + 1); disk->partition = grub_partition_probe (disk, p + 1);
/* The cache will be invalidated about 2 seconds after a device was /* The cache will be invalidated about 2 seconds after a device was
closed. */ closed. */
current_time = pupa_get_rtc (); current_time = grub_get_rtc ();
if (current_time > pupa_last_time + PUPA_CACHE_TIMEOUT * PUPA_TICKS_PER_SECOND) if (current_time > grub_last_time + GRUB_CACHE_TIMEOUT * GRUB_TICKS_PER_SECOND)
pupa_disk_cache_invalidate_all (); grub_disk_cache_invalidate_all ();
pupa_last_time = current_time; grub_last_time = current_time;
fail: fail:
if (raw && raw != name) if (raw && raw != name)
pupa_free (raw); grub_free (raw);
if (pupa_errno != PUPA_ERR_NONE) if (grub_errno != GRUB_ERR_NONE)
{ {
pupa_disk_close (disk); grub_disk_close (disk);
return 0; return 0;
} }
@ -279,64 +279,64 @@ pupa_disk_open (const char *name)
} }
void void
pupa_disk_close (pupa_disk_t disk) grub_disk_close (grub_disk_t disk)
{ {
if (disk->dev && disk->dev->close) if (disk->dev && disk->dev->close)
(disk->dev->close) (disk); (disk->dev->close) (disk);
/* Reset the timer. */ /* Reset the timer. */
pupa_last_time = pupa_get_rtc (); grub_last_time = grub_get_rtc ();
pupa_free (disk->partition); grub_free (disk->partition);
pupa_free ((void *) disk->name); grub_free ((void *) disk->name);
pupa_free (disk); grub_free (disk);
} }
static pupa_err_t static grub_err_t
pupa_disk_check_range (pupa_disk_t disk, unsigned long *sector, grub_disk_check_range (grub_disk_t disk, unsigned long *sector,
unsigned long *offset, pupa_ssize_t size) unsigned long *offset, grub_ssize_t size)
{ {
*sector += *offset >> PUPA_DISK_SECTOR_BITS; *sector += *offset >> GRUB_DISK_SECTOR_BITS;
*offset &= PUPA_DISK_SECTOR_SIZE - 1; *offset &= GRUB_DISK_SECTOR_SIZE - 1;
if (disk->partition) if (disk->partition)
{ {
unsigned long start, len; unsigned long start, len;
start = pupa_partition_get_start (disk->partition); start = grub_partition_get_start (disk->partition);
len = pupa_partition_get_len (disk->partition); len = grub_partition_get_len (disk->partition);
if (*sector >= len if (*sector >= len
|| len - *sector < ((*offset + size + PUPA_DISK_SECTOR_SIZE - 1) || len - *sector < ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
>> PUPA_DISK_SECTOR_BITS)) >> GRUB_DISK_SECTOR_BITS))
return pupa_error (PUPA_ERR_OUT_OF_RANGE, "out of partition"); return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of partition");
*sector += start; *sector += start;
} }
if (disk->total_sectors <= *sector if (disk->total_sectors <= *sector
|| ((*offset + size + PUPA_DISK_SECTOR_SIZE - 1) || ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
>> PUPA_DISK_SECTOR_BITS) > disk->total_sectors - *sector) >> GRUB_DISK_SECTOR_BITS) > disk->total_sectors - *sector)
return pupa_error (PUPA_ERR_OUT_OF_RANGE, "out of disk"); return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
/* Read data from the disk. */ /* Read data from the disk. */
pupa_err_t grub_err_t
pupa_disk_read (pupa_disk_t disk, unsigned long sector, grub_disk_read (grub_disk_t disk, unsigned long sector,
unsigned long offset, unsigned long size, char *buf) unsigned long offset, unsigned long size, char *buf)
{ {
char *tmp_buf; char *tmp_buf;
/* First of all, check if the region is within the disk. */ /* First of all, check if the region is within the disk. */
if (pupa_disk_check_range (disk, &sector, &offset, size) != PUPA_ERR_NONE) if (grub_disk_check_range (disk, &sector, &offset, size) != GRUB_ERR_NONE)
return pupa_errno; return grub_errno;
/* Allocate a temporary buffer. */ /* Allocate a temporary buffer. */
tmp_buf = pupa_malloc (PUPA_DISK_SECTOR_SIZE << PUPA_DISK_CACHE_BITS); tmp_buf = grub_malloc (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS);
if (! tmp_buf) if (! tmp_buf)
return pupa_errno; return grub_errno;
/* Until SIZE is zero... */ /* Until SIZE is zero... */
while (size) while (size)
@ -347,54 +347,54 @@ pupa_disk_read (pupa_disk_t disk, unsigned long sector,
unsigned long pos; unsigned long pos;
/* For reading bulk data. */ /* For reading bulk data. */
start_sector = sector & ~(PUPA_DISK_CACHE_SIZE - 1); start_sector = sector & ~(GRUB_DISK_CACHE_SIZE - 1);
pos = (sector - start_sector) << PUPA_DISK_SECTOR_BITS; pos = (sector - start_sector) << GRUB_DISK_SECTOR_BITS;
len = (PUPA_DISK_SECTOR_SIZE << PUPA_DISK_CACHE_BITS) - pos - offset; len = (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS) - pos - offset;
if (len > size) if (len > size)
len = size; len = size;
/* Fetch the cache. */ /* Fetch the cache. */
data = pupa_disk_cache_fetch (disk->id, start_sector); data = grub_disk_cache_fetch (disk->id, start_sector);
if (data) if (data)
{ {
/* Just copy it! */ /* Just copy it! */
pupa_memcpy (buf, data + pos + offset, len); grub_memcpy (buf, data + pos + offset, len);
pupa_disk_cache_unlock (disk->id, start_sector); grub_disk_cache_unlock (disk->id, start_sector);
} }
else else
{ {
/* Otherwise read data from the disk actually. */ /* Otherwise read data from the disk actually. */
if ((disk->dev->read) (disk, start_sector, if ((disk->dev->read) (disk, start_sector,
PUPA_DISK_CACHE_SIZE, tmp_buf) GRUB_DISK_CACHE_SIZE, tmp_buf)
!= PUPA_ERR_NONE) != GRUB_ERR_NONE)
{ {
/* Uggh... Failed. Instead, just read necessary data. */ /* Uggh... Failed. Instead, just read necessary data. */
unsigned num; unsigned num;
pupa_errno = PUPA_ERR_NONE; grub_errno = GRUB_ERR_NONE;
/* If more data is required, no way. */ /* If more data is required, no way. */
if (pos + size if (pos + size
>= (PUPA_DISK_SECTOR_SIZE << PUPA_DISK_CACHE_BITS)) >= (GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS))
goto finish; goto finish;
num = ((size + PUPA_DISK_SECTOR_SIZE - 1) num = ((size + GRUB_DISK_SECTOR_SIZE - 1)
>> PUPA_DISK_SECTOR_BITS); >> GRUB_DISK_SECTOR_BITS);
if ((disk->dev->read) (disk, sector, num, tmp_buf)) if ((disk->dev->read) (disk, sector, num, tmp_buf))
goto finish; goto finish;
pupa_memcpy (buf, tmp_buf + offset, size); grub_memcpy (buf, tmp_buf + offset, size);
/* Call the read hook, if any. */ /* Call the read hook, if any. */
if (disk->read_hook) if (disk->read_hook)
while (size) while (size)
{ {
(disk->read_hook) (sector, offset, (disk->read_hook) (sector, offset,
((size > PUPA_DISK_SECTOR_SIZE) ((size > GRUB_DISK_SECTOR_SIZE)
? PUPA_DISK_SECTOR_SIZE ? GRUB_DISK_SECTOR_SIZE
: size)); : size));
sector++; sector++;
size -= PUPA_DISK_SECTOR_SIZE - offset; size -= GRUB_DISK_SECTOR_SIZE - offset;
offset = 0; offset = 0;
} }
@ -403,8 +403,8 @@ pupa_disk_read (pupa_disk_t disk, unsigned long sector,
} }
/* Copy it and store it in the disk cache. */ /* Copy it and store it in the disk cache. */
pupa_memcpy (buf, tmp_buf + pos + offset, len); grub_memcpy (buf, tmp_buf + pos + offset, len);
pupa_disk_cache_store (disk->id, start_sector, tmp_buf); grub_disk_cache_store (disk->id, start_sector, tmp_buf);
} }
/* Call the read hook, if any. */ /* Call the read hook, if any. */
@ -416,20 +416,20 @@ pupa_disk_read (pupa_disk_t disk, unsigned long sector,
while (l) while (l)
{ {
(disk->read_hook) (s, offset, (disk->read_hook) (s, offset,
((l > PUPA_DISK_SECTOR_SIZE) ((l > GRUB_DISK_SECTOR_SIZE)
? PUPA_DISK_SECTOR_SIZE ? GRUB_DISK_SECTOR_SIZE
: l)); : l));
if (l < PUPA_DISK_SECTOR_SIZE - offset) if (l < GRUB_DISK_SECTOR_SIZE - offset)
break; break;
s++; s++;
l -= PUPA_DISK_SECTOR_SIZE - offset; l -= GRUB_DISK_SECTOR_SIZE - offset;
offset = 0; offset = 0;
} }
} }
sector = start_sector + PUPA_DISK_CACHE_SIZE; sector = start_sector + GRUB_DISK_CACHE_SIZE;
buf += len; buf += len;
size -= len; size -= len;
offset = 0; offset = 0;
@ -437,38 +437,38 @@ pupa_disk_read (pupa_disk_t disk, unsigned long sector,
finish: finish:
pupa_free (tmp_buf); grub_free (tmp_buf);
return pupa_errno; return grub_errno;
} }
pupa_err_t grub_err_t
pupa_disk_write (pupa_disk_t disk, unsigned long sector, grub_disk_write (grub_disk_t disk, unsigned long sector,
unsigned long offset, unsigned long size, const char *buf) unsigned long offset, unsigned long size, const char *buf)
{ {
if (pupa_disk_check_range (disk, &sector, &offset, size) != PUPA_ERR_NONE) if (grub_disk_check_range (disk, &sector, &offset, size) != GRUB_ERR_NONE)
return -1; return -1;
while (size) while (size)
{ {
if (offset != 0 || (size < PUPA_DISK_SECTOR_SIZE && size != 0)) if (offset != 0 || (size < GRUB_DISK_SECTOR_SIZE && size != 0))
{ {
char tmp_buf[PUPA_DISK_SECTOR_SIZE]; char tmp_buf[GRUB_DISK_SECTOR_SIZE];
unsigned long len; unsigned long len;
if (pupa_disk_read (disk, sector, 0, PUPA_DISK_SECTOR_SIZE, tmp_buf) if (grub_disk_read (disk, sector, 0, GRUB_DISK_SECTOR_SIZE, tmp_buf)
!= PUPA_ERR_NONE) != GRUB_ERR_NONE)
goto finish; goto finish;
len = PUPA_DISK_SECTOR_SIZE - offset; len = GRUB_DISK_SECTOR_SIZE - offset;
if (len > size) if (len > size)
len = size; len = size;
pupa_memcpy (tmp_buf + offset, buf, len); grub_memcpy (tmp_buf + offset, buf, len);
pupa_disk_cache_invalidate (disk->id, sector); grub_disk_cache_invalidate (disk->id, sector);
if ((disk->dev->write) (disk, sector, 1, tmp_buf) != PUPA_ERR_NONE) if ((disk->dev->write) (disk, sector, 1, tmp_buf) != GRUB_ERR_NONE)
goto finish; goto finish;
sector++; sector++;
@ -481,14 +481,14 @@ pupa_disk_write (pupa_disk_t disk, unsigned long sector,
unsigned long len; unsigned long len;
unsigned long n; unsigned long n;
len = size & ~(PUPA_DISK_SECTOR_SIZE - 1); len = size & ~(GRUB_DISK_SECTOR_SIZE - 1);
n = size >> PUPA_DISK_SECTOR_BITS; n = size >> GRUB_DISK_SECTOR_BITS;
if ((disk->dev->write) (disk, sector, n, buf) != PUPA_ERR_NONE) if ((disk->dev->write) (disk, sector, n, buf) != GRUB_ERR_NONE)
goto finish; goto finish;
while (n--) while (n--)
pupa_disk_cache_invalidate (disk->id, sector++); grub_disk_cache_invalidate (disk->id, sector++);
buf += len; buf += len;
size -= len; size -= len;
@ -497,46 +497,46 @@ pupa_disk_write (pupa_disk_t disk, unsigned long sector,
finish: finish:
return pupa_errno; return grub_errno;
} }
pupa_err_t grub_err_t
pupa_print_partinfo (pupa_device_t disk, char *partname) grub_print_partinfo (grub_device_t disk, char *partname)
{ {
pupa_fs_t fs = 0; grub_fs_t fs = 0;
pupa_device_t part; grub_device_t part;
char devname[20]; char devname[20];
pupa_sprintf (devname, "%s,%s", disk->disk->name, partname); grub_sprintf (devname, "%s,%s", disk->disk->name, partname);
part = pupa_device_open (devname); part = grub_device_open (devname);
if (!part) if (!part)
pupa_printf ("\tPartition num:%s, Filesystem cannot be accessed", grub_printf ("\tPartition num:%s, Filesystem cannot be accessed",
partname); partname);
else else
{ {
char *label; char *label;
fs = pupa_fs_probe (part); fs = grub_fs_probe (part);
/* Ignore all errors. */ /* Ignore all errors. */
pupa_errno = 0; grub_errno = 0;
pupa_printf ("\tPartition num:%s, Filesystem type %s", grub_printf ("\tPartition num:%s, Filesystem type %s",
partname, fs ? fs->name : "Unknown"); partname, fs ? fs->name : "Unknown");
if (fs) if (fs)
{ {
(fs->label) (part, &label); (fs->label) (part, &label);
if (pupa_errno == PUPA_ERR_NONE) if (grub_errno == GRUB_ERR_NONE)
{ {
if (label && pupa_strlen (label)) if (label && grub_strlen (label))
pupa_printf (", Label: %s", label); grub_printf (", Label: %s", label);
pupa_free (label); grub_free (label);
} }
pupa_errno = PUPA_ERR_NONE; grub_errno = GRUB_ERR_NONE;
} }
pupa_device_close (part); grub_device_close (part);
} }
pupa_printf ("\n"); grub_printf ("\n");
return pupa_errno; return grub_errno;
} }

382
kern/dl.c
View file

@ -1,9 +1,9 @@
/* dl.c - loadable module support */ /* dl.c - loadable module support */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2003 Free Software Foundation, Inc. * Copyright (C) 2002, 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,22 +14,22 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <config.h> #include <config.h>
#include <pupa/elf.h> #include <grub/elf.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/file.h> #include <grub/file.h>
#include <pupa/env.h> #include <grub/env.h>
#if PUPA_HOST_SIZEOF_VOID_P == 4 #if GRUB_HOST_SIZEOF_VOID_P == 4
typedef Elf32_Word Elf_Word; typedef Elf32_Word Elf_Word;
typedef Elf32_Addr Elf_Addr; typedef Elf32_Addr Elf_Addr;
@ -40,7 +40,7 @@ typedef Elf32_Sym Elf_Sym;
# define ELF_ST_BIND(val) ELF32_ST_BIND (val) # define ELF_ST_BIND(val) ELF32_ST_BIND (val)
# define ELF_ST_TYPE(val) ELF32_ST_TYPE (val) # define ELF_ST_TYPE(val) ELF32_ST_TYPE (val)
#elif PUPA_HOST_SIZEOF_VOID_P == 8 #elif GRUB_HOST_SIZEOF_VOID_P == 8
typedef Elf64_Word Elf_Word; typedef Elf64_Word Elf_Word;
typedef Elf64_Addr Elf_Addr; typedef Elf64_Addr Elf_Addr;
@ -55,132 +55,132 @@ typedef Elf64_Sym Elf_Sym;
struct pupa_dl_list struct grub_dl_list
{ {
struct pupa_dl_list *next; struct grub_dl_list *next;
pupa_dl_t mod; grub_dl_t mod;
}; };
typedef struct pupa_dl_list *pupa_dl_list_t; typedef struct grub_dl_list *grub_dl_list_t;
static pupa_dl_list_t pupa_dl_head; static grub_dl_list_t grub_dl_head;
static pupa_err_t static grub_err_t
pupa_dl_add (pupa_dl_t mod) grub_dl_add (grub_dl_t mod)
{ {
pupa_dl_list_t l; grub_dl_list_t l;
if (pupa_dl_get (mod->name)) if (grub_dl_get (mod->name))
return pupa_error (PUPA_ERR_BAD_MODULE, return grub_error (GRUB_ERR_BAD_MODULE,
"`%s' is already loaded", mod->name); "`%s' is already loaded", mod->name);
l = (pupa_dl_list_t) pupa_malloc (sizeof (*l)); l = (grub_dl_list_t) grub_malloc (sizeof (*l));
if (! l) if (! l)
return pupa_errno; return grub_errno;
l->mod = mod; l->mod = mod;
l->next = pupa_dl_head; l->next = grub_dl_head;
pupa_dl_head = l; grub_dl_head = l;
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
static void static void
pupa_dl_remove (pupa_dl_t mod) grub_dl_remove (grub_dl_t mod)
{ {
pupa_dl_list_t *p, q; grub_dl_list_t *p, q;
for (p = &pupa_dl_head, q = *p; q; p = &q->next, q = *p) for (p = &grub_dl_head, q = *p; q; p = &q->next, q = *p)
if (q->mod == mod) if (q->mod == mod)
{ {
*p = q->next; *p = q->next;
pupa_free (q); grub_free (q);
return; return;
} }
} }
pupa_dl_t grub_dl_t
pupa_dl_get (const char *name) grub_dl_get (const char *name)
{ {
pupa_dl_list_t l; grub_dl_list_t l;
for (l = pupa_dl_head; l; l = l->next) for (l = grub_dl_head; l; l = l->next)
if (pupa_strcmp (name, l->mod->name) == 0) if (grub_strcmp (name, l->mod->name) == 0)
return l->mod; return l->mod;
return 0; return 0;
} }
void void
pupa_dl_iterate (int (*hook) (pupa_dl_t mod)) grub_dl_iterate (int (*hook) (grub_dl_t mod))
{ {
pupa_dl_list_t l; grub_dl_list_t l;
for (l = pupa_dl_head; l; l = l->next) for (l = grub_dl_head; l; l = l->next)
if (hook (l->mod)) if (hook (l->mod))
break; break;
} }
struct pupa_symbol struct grub_symbol
{ {
struct pupa_symbol *next; struct grub_symbol *next;
const char *name; const char *name;
void *addr; void *addr;
pupa_dl_t mod; /* The module to which this symbol belongs. */ grub_dl_t mod; /* The module to which this symbol belongs. */
}; };
typedef struct pupa_symbol *pupa_symbol_t; typedef struct grub_symbol *grub_symbol_t;
/* The size of the symbol table. */ /* The size of the symbol table. */
#define PUPA_SYMTAB_SIZE 509 #define GRUB_SYMTAB_SIZE 509
/* The symbol table (using an open-hash). */ /* The symbol table (using an open-hash). */
static struct pupa_symbol *pupa_symtab[PUPA_SYMTAB_SIZE]; static struct grub_symbol *grub_symtab[GRUB_SYMTAB_SIZE];
/* Simple hash function. */ /* Simple hash function. */
static unsigned static unsigned
pupa_symbol_hash (const char *s) grub_symbol_hash (const char *s)
{ {
unsigned key = 0; unsigned key = 0;
while (*s) while (*s)
key = key * 65599 + *s++; key = key * 65599 + *s++;
return (key + (key >> 5)) % PUPA_SYMTAB_SIZE; return (key + (key >> 5)) % GRUB_SYMTAB_SIZE;
} }
/* Resolve the symbol name NAME and return the address. /* Resolve the symbol name NAME and return the address.
Return NULL, if not found. */ Return NULL, if not found. */
void * void *
pupa_dl_resolve_symbol (const char *name) grub_dl_resolve_symbol (const char *name)
{ {
pupa_symbol_t sym; grub_symbol_t sym;
for (sym = pupa_symtab[pupa_symbol_hash (name)]; sym; sym = sym->next) for (sym = grub_symtab[grub_symbol_hash (name)]; sym; sym = sym->next)
if (pupa_strcmp (sym->name, name) == 0) if (grub_strcmp (sym->name, name) == 0)
return sym->addr; return sym->addr;
return 0; return 0;
} }
/* Register a symbol with the name NAME and the address ADDR. */ /* Register a symbol with the name NAME and the address ADDR. */
pupa_err_t grub_err_t
pupa_dl_register_symbol (const char *name, void *addr, pupa_dl_t mod) grub_dl_register_symbol (const char *name, void *addr, grub_dl_t mod)
{ {
pupa_symbol_t sym; grub_symbol_t sym;
unsigned k; unsigned k;
sym = (pupa_symbol_t) pupa_malloc (sizeof (*sym)); sym = (grub_symbol_t) grub_malloc (sizeof (*sym));
if (! sym) if (! sym)
return pupa_errno; return grub_errno;
if (mod) if (mod)
{ {
sym->name = pupa_strdup (name); sym->name = grub_strdup (name);
if (! sym->name) if (! sym->name)
{ {
pupa_free (sym); grub_free (sym);
return pupa_errno; return grub_errno;
} }
} }
else else
@ -189,34 +189,34 @@ pupa_dl_register_symbol (const char *name, void *addr, pupa_dl_t mod)
sym->addr = addr; sym->addr = addr;
sym->mod = mod; sym->mod = mod;
k = pupa_symbol_hash (name); k = grub_symbol_hash (name);
sym->next = pupa_symtab[k]; sym->next = grub_symtab[k];
pupa_symtab[k] = sym; grub_symtab[k] = sym;
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
/* Unregister all the symbols defined in the module MOD. */ /* Unregister all the symbols defined in the module MOD. */
static void static void
pupa_dl_unregister_symbols (pupa_dl_t mod) grub_dl_unregister_symbols (grub_dl_t mod)
{ {
unsigned i; unsigned i;
if (! mod) if (! mod)
pupa_fatal ("core symbols cannot be unregistered"); grub_fatal ("core symbols cannot be unregistered");
for (i = 0; i < PUPA_SYMTAB_SIZE; i++) for (i = 0; i < GRUB_SYMTAB_SIZE; i++)
{ {
pupa_symbol_t sym, *p, q; grub_symbol_t sym, *p, q;
for (p = &pupa_symtab[i], sym = *p; sym; sym = q) for (p = &grub_symtab[i], sym = *p; sym; sym = q)
{ {
q = sym->next; q = sym->next;
if (sym->mod == mod) if (sym->mod == mod)
{ {
*p = q; *p = q;
pupa_free ((void *) sym->name); grub_free ((void *) sym->name);
pupa_free (sym); grub_free (sym);
} }
else else
p = &sym->next; p = &sym->next;
@ -226,9 +226,9 @@ pupa_dl_unregister_symbols (pupa_dl_t mod)
/* Return the address of a section whose index is N. */ /* Return the address of a section whose index is N. */
static void * static void *
pupa_dl_get_section_addr (pupa_dl_t mod, unsigned n) grub_dl_get_section_addr (grub_dl_t mod, unsigned n)
{ {
pupa_dl_segment_t seg; grub_dl_segment_t seg;
for (seg = mod->segment; seg; seg = seg->next) for (seg = mod->segment; seg; seg = seg->next)
if (seg->section == n) if (seg->section == n)
@ -238,8 +238,8 @@ pupa_dl_get_section_addr (pupa_dl_t mod, unsigned n)
} }
/* Load all segments from memory specified by E. */ /* Load all segments from memory specified by E. */
static pupa_err_t static grub_err_t
pupa_dl_load_segments (pupa_dl_t mod, const Elf_Ehdr *e) grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
{ {
unsigned i; unsigned i;
Elf_Shdr *s; Elf_Shdr *s;
@ -250,30 +250,30 @@ pupa_dl_load_segments (pupa_dl_t mod, const Elf_Ehdr *e)
{ {
if (s->sh_flags & SHF_ALLOC) if (s->sh_flags & SHF_ALLOC)
{ {
pupa_dl_segment_t seg; grub_dl_segment_t seg;
seg = (pupa_dl_segment_t) pupa_malloc (sizeof (*seg)); seg = (grub_dl_segment_t) grub_malloc (sizeof (*seg));
if (! seg) if (! seg)
return pupa_errno; return grub_errno;
if (s->sh_size) if (s->sh_size)
{ {
void *addr; void *addr;
addr = pupa_memalign (s->sh_addralign, s->sh_size); addr = grub_memalign (s->sh_addralign, s->sh_size);
if (! addr) if (! addr)
{ {
pupa_free (seg); grub_free (seg);
return pupa_errno; return grub_errno;
} }
switch (s->sh_type) switch (s->sh_type)
{ {
case SHT_PROGBITS: case SHT_PROGBITS:
pupa_memcpy (addr, (char *) e + s->sh_offset, s->sh_size); grub_memcpy (addr, (char *) e + s->sh_offset, s->sh_size);
break; break;
case SHT_NOBITS: case SHT_NOBITS:
pupa_memset (addr, 0, s->sh_size); grub_memset (addr, 0, s->sh_size);
break; break;
} }
@ -289,11 +289,11 @@ pupa_dl_load_segments (pupa_dl_t mod, const Elf_Ehdr *e)
} }
} }
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
static pupa_err_t static grub_err_t
pupa_dl_resolve_symbols (pupa_dl_t mod, Elf_Ehdr *e) grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
{ {
unsigned i; unsigned i;
Elf_Shdr *s; Elf_Shdr *s;
@ -308,7 +308,7 @@ pupa_dl_resolve_symbols (pupa_dl_t mod, Elf_Ehdr *e)
break; break;
if (i == e->e_shnum) if (i == e->e_shnum)
return pupa_error (PUPA_ERR_BAD_MODULE, "no symbol table"); return grub_error (GRUB_ERR_BAD_MODULE, "no symbol table");
sym = (Elf_Sym *) ((char *) e + s->sh_offset); sym = (Elf_Sym *) ((char *) e + s->sh_offset);
size = s->sh_size; size = s->sh_size;
@ -331,9 +331,9 @@ pupa_dl_resolve_symbols (pupa_dl_t mod, Elf_Ehdr *e)
/* Resolve a global symbol. */ /* Resolve a global symbol. */
if (sym->st_name != 0 && sym->st_shndx == 0) if (sym->st_name != 0 && sym->st_shndx == 0)
{ {
sym->st_value = (Elf_Addr) pupa_dl_resolve_symbol (name); sym->st_value = (Elf_Addr) grub_dl_resolve_symbol (name);
if (! sym->st_value) if (! sym->st_value)
return pupa_error (PUPA_ERR_BAD_MODULE, return grub_error (GRUB_ERR_BAD_MODULE,
"the symbol `%s' not found", name); "the symbol `%s' not found", name);
} }
else else
@ -341,28 +341,28 @@ pupa_dl_resolve_symbols (pupa_dl_t mod, Elf_Ehdr *e)
break; break;
case STT_OBJECT: case STT_OBJECT:
sym->st_value += (Elf_Addr) pupa_dl_get_section_addr (mod, sym->st_value += (Elf_Addr) grub_dl_get_section_addr (mod,
sym->st_shndx); sym->st_shndx);
if (bind != STB_LOCAL) if (bind != STB_LOCAL)
if (pupa_dl_register_symbol (name, (void *) sym->st_value, mod)) if (grub_dl_register_symbol (name, (void *) sym->st_value, mod))
return pupa_errno; return grub_errno;
break; break;
case STT_FUNC: case STT_FUNC:
sym->st_value += (Elf_Addr) pupa_dl_get_section_addr (mod, sym->st_value += (Elf_Addr) grub_dl_get_section_addr (mod,
sym->st_shndx); sym->st_shndx);
if (bind != STB_LOCAL) if (bind != STB_LOCAL)
if (pupa_dl_register_symbol (name, (void *) sym->st_value, mod)) if (grub_dl_register_symbol (name, (void *) sym->st_value, mod))
return pupa_errno; return grub_errno;
if (pupa_strcmp (name, "pupa_mod_init") == 0) if (grub_strcmp (name, "grub_mod_init") == 0)
mod->init = (void (*) (pupa_dl_t)) sym->st_value; mod->init = (void (*) (grub_dl_t)) sym->st_value;
else if (pupa_strcmp (name, "pupa_mod_fini") == 0) else if (grub_strcmp (name, "grub_mod_fini") == 0)
mod->fini = (void (*) (void)) sym->st_value; mod->fini = (void (*) (void)) sym->st_value;
break; break;
case STT_SECTION: case STT_SECTION:
sym->st_value = (Elf_Addr) pupa_dl_get_section_addr (mod, sym->st_value = (Elf_Addr) grub_dl_get_section_addr (mod,
sym->st_shndx); sym->st_shndx);
break; break;
@ -371,23 +371,23 @@ pupa_dl_resolve_symbols (pupa_dl_t mod, Elf_Ehdr *e)
break; break;
default: default:
return pupa_error (PUPA_ERR_BAD_MODULE, return grub_error (GRUB_ERR_BAD_MODULE,
"unknown symbol type `%d'", (int) type); "unknown symbol type `%d'", (int) type);
} }
} }
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
static void static void
pupa_dl_call_init (pupa_dl_t mod) grub_dl_call_init (grub_dl_t mod)
{ {
if (mod->init) if (mod->init)
(mod->init) (mod); (mod->init) (mod);
} }
static pupa_err_t static grub_err_t
pupa_dl_resolve_name (pupa_dl_t mod, Elf_Ehdr *e) grub_dl_resolve_name (grub_dl_t mod, Elf_Ehdr *e)
{ {
Elf_Shdr *s; Elf_Shdr *s;
const char *str; const char *str;
@ -399,22 +399,22 @@ pupa_dl_resolve_name (pupa_dl_t mod, Elf_Ehdr *e)
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum; i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (pupa_strcmp (str + s->sh_name, ".modname") == 0) if (grub_strcmp (str + s->sh_name, ".modname") == 0)
{ {
mod->name = pupa_strdup ((char *) e + s->sh_offset); mod->name = grub_strdup ((char *) e + s->sh_offset);
if (! mod->name) if (! mod->name)
return pupa_errno; return grub_errno;
break; break;
} }
if (i == e->e_shnum) if (i == e->e_shnum)
return pupa_error (PUPA_ERR_BAD_MODULE, "no module name found"); return grub_error (GRUB_ERR_BAD_MODULE, "no module name found");
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
static pupa_err_t static grub_err_t
pupa_dl_resolve_dependencies (pupa_dl_t mod, Elf_Ehdr *e) grub_dl_resolve_dependencies (grub_dl_t mod, Elf_Ehdr *e)
{ {
Elf_Shdr *s; Elf_Shdr *s;
const char *str; const char *str;
@ -426,74 +426,74 @@ pupa_dl_resolve_dependencies (pupa_dl_t mod, Elf_Ehdr *e)
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum; i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (pupa_strcmp (str + s->sh_name, ".moddeps") == 0) if (grub_strcmp (str + s->sh_name, ".moddeps") == 0)
{ {
const char *name = (char *) e + s->sh_offset; const char *name = (char *) e + s->sh_offset;
const char *max = name + s->sh_size; const char *max = name + s->sh_size;
while (name < max) while (name < max)
{ {
pupa_dl_t m; grub_dl_t m;
pupa_dl_dep_t dep; grub_dl_dep_t dep;
m = pupa_dl_load (name); m = grub_dl_load (name);
if (! m) if (! m)
return pupa_errno; return grub_errno;
pupa_dl_ref (m); grub_dl_ref (m);
dep = (pupa_dl_dep_t) pupa_malloc (sizeof (*dep)); dep = (grub_dl_dep_t) grub_malloc (sizeof (*dep));
if (! dep) if (! dep)
return pupa_errno; return grub_errno;
dep->mod = m; dep->mod = m;
dep->next = mod->dep; dep->next = mod->dep;
mod->dep = dep; mod->dep = dep;
name += pupa_strlen (name) + 1; name += grub_strlen (name) + 1;
} }
} }
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }
int int
pupa_dl_ref (pupa_dl_t mod) grub_dl_ref (grub_dl_t mod)
{ {
pupa_dl_dep_t dep; grub_dl_dep_t dep;
for (dep = mod->dep; dep; dep = dep->next) for (dep = mod->dep; dep; dep = dep->next)
pupa_dl_ref (dep->mod); grub_dl_ref (dep->mod);
return ++mod->ref_count; return ++mod->ref_count;
} }
int int
pupa_dl_unref (pupa_dl_t mod) grub_dl_unref (grub_dl_t mod)
{ {
pupa_dl_dep_t dep; grub_dl_dep_t dep;
for (dep = mod->dep; dep; dep = dep->next) for (dep = mod->dep; dep; dep = dep->next)
pupa_dl_unref (dep->mod); grub_dl_unref (dep->mod);
return --mod->ref_count; return --mod->ref_count;
} }
/* Load a module from core memory. */ /* Load a module from core memory. */
pupa_dl_t grub_dl_t
pupa_dl_load_core (void *addr, pupa_size_t size) grub_dl_load_core (void *addr, grub_size_t size)
{ {
Elf_Ehdr *e; Elf_Ehdr *e;
pupa_dl_t mod; grub_dl_t mod;
e = addr; e = addr;
if (! pupa_arch_dl_check_header (e, size)) if (! grub_arch_dl_check_header (e, size))
{ {
pupa_error (PUPA_ERR_BAD_MODULE, "invalid ELF header"); grub_error (GRUB_ERR_BAD_MODULE, "invalid ELF header");
return 0; return 0;
} }
mod = (pupa_dl_t) pupa_malloc (sizeof (*mod)); mod = (grub_dl_t) grub_malloc (sizeof (*mod));
if (! mod) if (! mod)
return 0; return 0;
@ -504,22 +504,22 @@ pupa_dl_load_core (void *addr, pupa_size_t size)
mod->init = 0; mod->init = 0;
mod->fini = 0; mod->fini = 0;
if (pupa_dl_resolve_name (mod, e) if (grub_dl_resolve_name (mod, e)
|| pupa_dl_resolve_dependencies (mod, e) || grub_dl_resolve_dependencies (mod, e)
|| pupa_dl_load_segments (mod, e) || grub_dl_load_segments (mod, e)
|| pupa_dl_resolve_symbols (mod, e) || grub_dl_resolve_symbols (mod, e)
|| pupa_arch_dl_relocate_symbols (mod, e)) || grub_arch_dl_relocate_symbols (mod, e))
{ {
mod->fini = 0; mod->fini = 0;
pupa_dl_unload (mod); grub_dl_unload (mod);
return 0; return 0;
} }
pupa_dl_call_init (mod); grub_dl_call_init (mod);
if (pupa_dl_add (mod)) if (grub_dl_add (mod))
{ {
pupa_dl_unload (mod); grub_dl_unload (mod);
return 0; return 0;
} }
@ -527,75 +527,75 @@ pupa_dl_load_core (void *addr, pupa_size_t size)
} }
/* Load a module from the file FILENAME. */ /* Load a module from the file FILENAME. */
pupa_dl_t grub_dl_t
pupa_dl_load_file (const char *filename) grub_dl_load_file (const char *filename)
{ {
pupa_file_t file; grub_file_t file;
pupa_ssize_t size; grub_ssize_t size;
void *core = 0; void *core = 0;
pupa_dl_t mod = 0; grub_dl_t mod = 0;
file = pupa_file_open (filename); file = grub_file_open (filename);
if (! file) if (! file)
return 0; return 0;
size = pupa_file_size (file); size = grub_file_size (file);
core = pupa_malloc (size); core = grub_malloc (size);
if (! core) if (! core)
goto failed; goto failed;
if (pupa_file_read (file, core, size) != (int) size) if (grub_file_read (file, core, size) != (int) size)
goto failed; goto failed;
mod = pupa_dl_load_core (core, size); mod = grub_dl_load_core (core, size);
mod->ref_count = 0; mod->ref_count = 0;
failed: failed:
pupa_file_close (file); grub_file_close (file);
pupa_free (core); grub_free (core);
return mod; return mod;
} }
/* Load a module using a symbolic name. */ /* Load a module using a symbolic name. */
pupa_dl_t grub_dl_t
pupa_dl_load (const char *name) grub_dl_load (const char *name)
{ {
char *filename; char *filename;
pupa_dl_t mod; grub_dl_t mod;
char *pupa_dl_dir = pupa_env_get ("prefix"); char *grub_dl_dir = grub_env_get ("prefix");
mod = pupa_dl_get (name); mod = grub_dl_get (name);
if (mod) if (mod)
return mod; return mod;
if (! pupa_dl_dir) if (! grub_dl_dir)
pupa_fatal ("module dir is not initialized yet"); grub_fatal ("module dir is not initialized yet");
filename = (char *) pupa_malloc (pupa_strlen (pupa_dl_dir) + 1 filename = (char *) grub_malloc (grub_strlen (grub_dl_dir) + 1
+ pupa_strlen (name) + 4 + 1); + grub_strlen (name) + 4 + 1);
if (! filename) if (! filename)
return 0; return 0;
pupa_sprintf (filename, "%s/%s.mod", pupa_dl_dir, name); grub_sprintf (filename, "%s/%s.mod", grub_dl_dir, name);
mod = pupa_dl_load_file (filename); mod = grub_dl_load_file (filename);
pupa_free (filename); grub_free (filename);
if (! mod) if (! mod)
return 0; return 0;
if (pupa_strcmp (mod->name, name) != 0) if (grub_strcmp (mod->name, name) != 0)
pupa_error (PUPA_ERR_BAD_MODULE, "mismatched names"); grub_error (GRUB_ERR_BAD_MODULE, "mismatched names");
return mod; return mod;
} }
/* Unload the module MOD. */ /* Unload the module MOD. */
int int
pupa_dl_unload (pupa_dl_t mod) grub_dl_unload (grub_dl_t mod)
{ {
pupa_dl_dep_t dep, depn; grub_dl_dep_t dep, depn;
pupa_dl_segment_t seg, segn; grub_dl_segment_t seg, segn;
if (mod->ref_count > 0) if (mod->ref_count > 0)
return 0; return 0;
@ -603,44 +603,44 @@ pupa_dl_unload (pupa_dl_t mod)
if (mod->fini) if (mod->fini)
(mod->fini) (); (mod->fini) ();
pupa_dl_remove (mod); grub_dl_remove (mod);
pupa_dl_unregister_symbols (mod); grub_dl_unregister_symbols (mod);
for (dep = mod->dep; dep; dep = depn) for (dep = mod->dep; dep; dep = depn)
{ {
depn = dep->next; depn = dep->next;
if (! pupa_dl_unref (dep->mod)) if (! grub_dl_unref (dep->mod))
pupa_dl_unload (dep->mod); grub_dl_unload (dep->mod);
pupa_free (dep); grub_free (dep);
} }
for (seg = mod->segment; seg; seg = segn) for (seg = mod->segment; seg; seg = segn)
{ {
segn = seg->next; segn = seg->next;
pupa_free (seg->addr); grub_free (seg->addr);
pupa_free (seg); grub_free (seg);
} }
pupa_free (mod->name); grub_free (mod->name);
pupa_free (mod); grub_free (mod);
return 1; return 1;
} }
/* Unload unneeded modules. */ /* Unload unneeded modules. */
void void
pupa_dl_unload_unneeded (void) grub_dl_unload_unneeded (void)
{ {
/* Because pupa_dl_remove modifies the list of modules, this /* Because grub_dl_remove modifies the list of modules, this
implementation is tricky. */ implementation is tricky. */
pupa_dl_list_t p = pupa_dl_head; grub_dl_list_t p = grub_dl_head;
while (p) while (p)
{ {
if (pupa_dl_unload (p->mod)) if (grub_dl_unload (p->mod))
{ {
p = pupa_dl_head; p = grub_dl_head;
continue; continue;
} }
@ -650,17 +650,17 @@ pupa_dl_unload_unneeded (void)
/* Unload all modules. */ /* Unload all modules. */
void void
pupa_dl_unload_all (void) grub_dl_unload_all (void)
{ {
while (pupa_dl_head) while (grub_dl_head)
{ {
pupa_dl_list_t p; grub_dl_list_t p;
pupa_dl_unload_unneeded (); grub_dl_unload_unneeded ();
/* Force to decrement the ref count. This will purge pre-loaded /* Force to decrement the ref count. This will purge pre-loaded
modules and manually inserted modules. */ modules and manually inserted modules. */
for (p = pupa_dl_head; p; p = p->next) for (p = grub_dl_head; p; p = p->next)
p->mod->ref_count--; p->mod->ref_count--;
} }
} }

View file

@ -1,9 +1,9 @@
/* env.c - Environment variables */ /* env.c - Environment variables */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,25 +14,25 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/env.h> #include <grub/env.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/mm.h> #include <grub/mm.h>
/* XXX: What would be a good size for the hashtable? */ /* XXX: What would be a good size for the hashtable? */
#define HASHSZ 123 #define HASHSZ 123
/* A hashtable for quick lookup of variables. */ /* A hashtable for quick lookup of variables. */
static struct pupa_env_var *pupa_env[HASHSZ]; static struct grub_env_var *grub_env[HASHSZ];
/* The variables in a sorted list. */ /* The variables in a sorted list. */
static struct pupa_env_var *pupa_env_sorted; static struct grub_env_var *grub_env_sorted;
/* Return the hash representation of the string S. */ /* Return the hash representation of the string S. */
static unsigned int pupa_env_hashval (const char *s) static unsigned int grub_env_hashval (const char *s)
{ {
unsigned int i = 0; unsigned int i = 0;
@ -43,73 +43,73 @@ static unsigned int pupa_env_hashval (const char *s)
return i % HASHSZ; return i % HASHSZ;
} }
static struct pupa_env_var * static struct grub_env_var *
pupa_env_find (const char *name) grub_env_find (const char *name)
{ {
struct pupa_env_var *var; struct grub_env_var *var;
int idx = pupa_env_hashval (name); int idx = grub_env_hashval (name);
for (var = pupa_env[idx]; var; var = var->next) for (var = grub_env[idx]; var; var = var->next)
if (! pupa_strcmp (var->name, name)) if (! grub_strcmp (var->name, name))
return var; return var;
return 0; return 0;
} }
pupa_err_t grub_err_t
pupa_env_set (const char *var, const char *val) grub_env_set (const char *var, const char *val)
{ {
int idx = pupa_env_hashval (var); int idx = grub_env_hashval (var);
struct pupa_env_var *env; struct grub_env_var *env;
struct pupa_env_var *sort; struct grub_env_var *sort;
struct pupa_env_var **sortp; struct grub_env_var **sortp;
/* If the variable does already exist, just update the variable. */ /* If the variable does already exist, just update the variable. */
env = pupa_env_find (var); env = grub_env_find (var);
if (env) if (env)
{ {
char *old = env->value; char *old = env->value;
env->value = pupa_strdup (val); env->value = grub_strdup (val);
if (! env->name) if (! env->name)
{ {
env->value = old; env->value = old;
return pupa_errno; return grub_errno;
} }
if (env->write_hook) if (env->write_hook)
(env->write_hook) (env); (env->write_hook) (env);
pupa_free (old); grub_free (old);
return 0; return 0;
} }
/* The variable does not exist, create it. */ /* The variable does not exist, create it. */
env = pupa_malloc (sizeof (struct pupa_env_var)); env = grub_malloc (sizeof (struct grub_env_var));
if (! env) if (! env)
return pupa_errno; return grub_errno;
pupa_memset (env, 0, sizeof (struct pupa_env_var)); grub_memset (env, 0, sizeof (struct grub_env_var));
env->name = pupa_strdup (var); env->name = grub_strdup (var);
if (! env->name) if (! env->name)
goto fail; goto fail;
env->value = pupa_strdup (val); env->value = grub_strdup (val);
if (! env->name) if (! env->name)
goto fail; goto fail;
/* Insert it in the hashtable. */ /* Insert it in the hashtable. */
env->prevp = &pupa_env[idx]; env->prevp = &grub_env[idx];
env->next = pupa_env[idx]; env->next = grub_env[idx];
if (pupa_env[idx]) if (grub_env[idx])
pupa_env[idx]->prevp = &env->next; grub_env[idx]->prevp = &env->next;
pupa_env[idx] = env; grub_env[idx] = env;
/* Insert it in the sorted list. */ /* Insert it in the sorted list. */
sortp = &pupa_env_sorted; sortp = &grub_env_sorted;
sort = pupa_env_sorted; sort = grub_env_sorted;
while (sort) while (sort)
{ {
if (pupa_strcmp (sort->name, var) > 0) if (grub_strcmp (sort->name, var) > 0)
break; break;
sortp = &sort->sort_next; sortp = &sort->sort_next;
@ -122,21 +122,21 @@ pupa_env_set (const char *var, const char *val)
*sortp = env; *sortp = env;
fail: fail:
if (pupa_errno) if (grub_errno)
{ {
pupa_free (env->name); grub_free (env->name);
pupa_free (env->value); grub_free (env->value);
pupa_free (env); grub_free (env);
} }
return 0; return 0;
} }
char * char *
pupa_env_get (const char *name) grub_env_get (const char *name)
{ {
struct pupa_env_var *env; struct grub_env_var *env;
env = pupa_env_find (name); env = grub_env_find (name);
if (! env) if (! env)
return 0; return 0;
@ -152,10 +152,10 @@ pupa_env_get (const char *name)
} }
void void
pupa_env_unset (const char *name) grub_env_unset (const char *name)
{ {
struct pupa_env_var *env; struct grub_env_var *env;
env = pupa_env_find (name); env = grub_env_find (name);
if (! env) if (! env)
return; return;
@ -172,38 +172,38 @@ pupa_env_unset (const char *name)
if (env->sort_next) if (env->sort_next)
env->sort_next->sort_prevp = env->sort_prevp; env->sort_next->sort_prevp = env->sort_prevp;
pupa_free (env->name); grub_free (env->name);
pupa_free (env->value); grub_free (env->value);
pupa_free (env); grub_free (env);
return; return;
} }
void void
pupa_env_iterate (int (* func) (struct pupa_env_var *var)) grub_env_iterate (int (* func) (struct grub_env_var *var))
{ {
struct pupa_env_var *env; struct grub_env_var *env;
for (env = pupa_env_sorted; env; env = env->sort_next) for (env = grub_env_sorted; env; env = env->sort_next)
if (func (env)) if (func (env))
return; return;
} }
pupa_err_t grub_err_t
pupa_register_variable_hook (const char *var, grub_register_variable_hook (const char *var,
pupa_err_t (*read_hook) (struct pupa_env_var *var, char **), grub_err_t (*read_hook) (struct grub_env_var *var, char **),
pupa_err_t (*write_hook) (struct pupa_env_var *var)) grub_err_t (*write_hook) (struct grub_env_var *var))
{ {
struct pupa_env_var *env = pupa_env_find (var); struct grub_env_var *env = grub_env_find (var);
if (! env) if (! env)
if (pupa_env_set (var, "") != PUPA_ERR_NONE) if (grub_env_set (var, "") != GRUB_ERR_NONE)
return pupa_errno; return grub_errno;
env = pupa_env_find (var); env = grub_env_find (var);
/* XXX Insert an assertion? */ /* XXX Insert an assertion? */
env->read_hook = read_hook; env->read_hook = read_hook;
env->write_hook = write_hook; env->write_hook = write_hook;
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }

View file

@ -1,9 +1,9 @@
/* err.c - error handling routines */ /* err.c - error handling routines */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,48 +14,48 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <stdarg.h> #include <stdarg.h>
#define PUPA_MAX_ERRMSG 256 #define GRUB_MAX_ERRMSG 256
pupa_err_t pupa_errno; grub_err_t grub_errno;
char pupa_errmsg[PUPA_MAX_ERRMSG]; char grub_errmsg[GRUB_MAX_ERRMSG];
pupa_err_t grub_err_t
pupa_error (pupa_err_t n, const char *fmt, ...) grub_error (grub_err_t n, const char *fmt, ...)
{ {
va_list ap; va_list ap;
pupa_errno = n; grub_errno = n;
va_start (ap, fmt); va_start (ap, fmt);
pupa_vsprintf (pupa_errmsg, fmt, ap); grub_vsprintf (grub_errmsg, fmt, ap);
va_end (ap); va_end (ap);
return n; return n;
} }
void void
pupa_fatal (const char *fmt, ...) grub_fatal (const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start (ap, fmt); va_start (ap, fmt);
pupa_vprintf (fmt, ap); grub_vprintf (fmt, ap);
va_end (ap); va_end (ap);
pupa_stop (); grub_stop ();
} }
void void
pupa_print_error (void) grub_print_error (void)
{ {
if (pupa_errno != PUPA_ERR_NONE) if (grub_errno != GRUB_ERR_NONE)
pupa_printf ("error: %s\n", pupa_errmsg); grub_printf ("error: %s\n", grub_errmsg);
} }

View file

@ -1,9 +1,9 @@
/* file.c - file I/O functions */ /* file.c - file I/O functions */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,37 +14,37 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/file.h> #include <grub/file.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/fs.h> #include <grub/fs.h>
#include <pupa/device.h> #include <grub/device.h>
/* Get the device part of the filename NAME. It is enclosed by parentheses. */ /* Get the device part of the filename NAME. It is enclosed by parentheses. */
char * char *
pupa_file_get_device_name (const char *name) grub_file_get_device_name (const char *name)
{ {
if (name[0] == '(') if (name[0] == '(')
{ {
char *p = pupa_strchr (name, ')'); char *p = grub_strchr (name, ')');
char *ret; char *ret;
if (! p) if (! p)
{ {
pupa_error (PUPA_ERR_BAD_FILENAME, "missing `)'"); grub_error (GRUB_ERR_BAD_FILENAME, "missing `)'");
return 0; return 0;
} }
ret = (char *) pupa_malloc (p - name); ret = (char *) grub_malloc (p - name);
if (! ret) if (! ret)
return 0; return 0;
pupa_memcpy (ret, name + 1, p - name - 1); grub_memcpy (ret, name + 1, p - name - 1);
ret[p - name - 1] = '\0'; ret[p - name - 1] = '\0';
return ret; return ret;
} }
@ -52,31 +52,31 @@ pupa_file_get_device_name (const char *name)
return 0; return 0;
} }
pupa_file_t grub_file_t
pupa_file_open (const char *name) grub_file_open (const char *name)
{ {
pupa_device_t device; grub_device_t device;
pupa_file_t file = 0; grub_file_t file = 0;
char *device_name; char *device_name;
char *file_name; char *file_name;
device_name = pupa_file_get_device_name (name); device_name = grub_file_get_device_name (name);
if (pupa_errno) if (grub_errno)
return 0; return 0;
/* Get the file part of NAME. */ /* Get the file part of NAME. */
file_name = pupa_strchr (name, ')'); file_name = grub_strchr (name, ')');
if (file_name) if (file_name)
file_name++; file_name++;
else else
file_name = (char *) name; file_name = (char *) name;
device = pupa_device_open (device_name); device = grub_device_open (device_name);
pupa_free (device_name); grub_free (device_name);
if (! device) if (! device)
goto fail; goto fail;
file = (pupa_file_t) pupa_malloc (sizeof (*file)); file = (grub_file_t) grub_malloc (sizeof (*file));
if (! file) if (! file)
goto fail; goto fail;
@ -87,34 +87,34 @@ pupa_file_open (const char *name)
if (device->disk && file_name[0] != '/') if (device->disk && file_name[0] != '/')
/* This is a block list. */ /* This is a block list. */
file->fs = &pupa_fs_blocklist; file->fs = &grub_fs_blocklist;
else else
{ {
file->fs = pupa_fs_probe (device); file->fs = grub_fs_probe (device);
if (! file->fs) if (! file->fs)
goto fail; goto fail;
} }
if ((file->fs->open) (file, file_name) != PUPA_ERR_NONE) if ((file->fs->open) (file, file_name) != GRUB_ERR_NONE)
goto fail; goto fail;
return file; return file;
fail: fail:
if (device) if (device)
pupa_device_close (device); grub_device_close (device);
/* if (net) pupa_net_close (net); */ /* if (net) grub_net_close (net); */
pupa_free (file); grub_free (file);
return 0; return 0;
} }
pupa_ssize_t grub_ssize_t
pupa_file_read (pupa_file_t file, char *buf, pupa_ssize_t len) grub_file_read (grub_file_t file, char *buf, grub_ssize_t len)
{ {
pupa_ssize_t res; grub_ssize_t res;
if (len == 0 || len > file->size - file->offset) if (len == 0 || len > file->size - file->offset)
len = file->size - file->offset; len = file->size - file->offset;
@ -129,25 +129,25 @@ pupa_file_read (pupa_file_t file, char *buf, pupa_ssize_t len)
return res; return res;
} }
pupa_err_t grub_err_t
pupa_file_close (pupa_file_t file) grub_file_close (grub_file_t file)
{ {
if (file->fs->close) if (file->fs->close)
(file->fs->close) (file); (file->fs->close) (file);
pupa_device_close (file->device); grub_device_close (file->device);
pupa_free (file); grub_free (file);
return pupa_errno; return grub_errno;
} }
pupa_ssize_t grub_ssize_t
pupa_file_seek (pupa_file_t file, pupa_ssize_t offset) grub_file_seek (grub_file_t file, grub_ssize_t offset)
{ {
pupa_ssize_t old; grub_ssize_t old;
if (offset < 0 || offset >= file->size) if (offset < 0 || offset >= file->size)
{ {
pupa_error (PUPA_ERR_OUT_OF_RANGE, grub_error (GRUB_ERR_OUT_OF_RANGE,
"attempt to seek outside of the file"); "attempt to seek outside of the file");
return -1; return -1;
} }

132
kern/fs.c
View file

@ -1,9 +1,9 @@
/* fs.c - filesystem manager */ /* fs.c - filesystem manager */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,35 +14,35 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/net.h> #include <grub/net.h>
#include <pupa/fs.h> #include <grub/fs.h>
#include <pupa/file.h> #include <grub/file.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/term.h> #include <grub/term.h>
static pupa_fs_t pupa_fs_list; static grub_fs_t grub_fs_list;
void void
pupa_fs_register (pupa_fs_t fs) grub_fs_register (grub_fs_t fs)
{ {
fs->next = pupa_fs_list; fs->next = grub_fs_list;
pupa_fs_list = fs; grub_fs_list = fs;
} }
void void
pupa_fs_unregister (pupa_fs_t fs) grub_fs_unregister (grub_fs_t fs)
{ {
pupa_fs_t *p, q; grub_fs_t *p, q;
for (p = &pupa_fs_list, q = *p; q; p = &(q->next), q = q->next) for (p = &grub_fs_list, q = *p; q; p = &(q->next), q = q->next)
if (q == fs) if (q == fs)
{ {
*p = q->next; *p = q->next;
@ -51,19 +51,19 @@ pupa_fs_unregister (pupa_fs_t fs)
} }
void void
pupa_fs_iterate (int (*hook) (const pupa_fs_t fs)) grub_fs_iterate (int (*hook) (const grub_fs_t fs))
{ {
pupa_fs_t p; grub_fs_t p;
for (p = pupa_fs_list; p; p = p->next) for (p = grub_fs_list; p; p = p->next)
if (hook (p)) if (hook (p))
break; break;
} }
pupa_fs_t grub_fs_t
pupa_fs_probe (pupa_device_t device) grub_fs_probe (grub_device_t device)
{ {
pupa_fs_t p; grub_fs_t p;
auto int dummy_func (const char *filename, int dir); auto int dummy_func (const char *filename, int dir);
int dummy_func (const char *filename __attribute__ ((unused)), int dummy_func (const char *filename __attribute__ ((unused)),
@ -74,22 +74,22 @@ pupa_fs_probe (pupa_device_t device)
if (device->disk) if (device->disk)
{ {
for (p = pupa_fs_list; p; p = p->next) for (p = grub_fs_list; p; p = p->next)
{ {
(p->dir) (device, "/", dummy_func); (p->dir) (device, "/", dummy_func);
if (pupa_errno == PUPA_ERR_NONE) if (grub_errno == GRUB_ERR_NONE)
return p; return p;
if (pupa_errno != PUPA_ERR_BAD_FS) if (grub_errno != GRUB_ERR_BAD_FS)
return 0; return 0;
pupa_errno = PUPA_ERR_NONE; grub_errno = GRUB_ERR_NONE;
} }
} }
else if (device->net->fs) else if (device->net->fs)
return device->net->fs; return device->net->fs;
pupa_error (PUPA_ERR_UNKNOWN_FS, "unknown filesystem"); grub_error (GRUB_ERR_UNKNOWN_FS, "unknown filesystem");
return 0; return 0;
} }
@ -97,31 +97,31 @@ pupa_fs_probe (pupa_device_t device)
/* Block list support routines. */ /* Block list support routines. */
struct pupa_fs_block struct grub_fs_block
{ {
unsigned long offset; unsigned long offset;
unsigned long length; unsigned long length;
}; };
static pupa_err_t static grub_err_t
pupa_fs_blocklist_open (pupa_file_t file, const char *name) grub_fs_blocklist_open (grub_file_t file, const char *name)
{ {
char *p = (char *) name; char *p = (char *) name;
unsigned num = 0; unsigned num = 0;
unsigned i; unsigned i;
pupa_disk_t disk = file->device->disk; grub_disk_t disk = file->device->disk;
struct pupa_fs_block *blocks; struct grub_fs_block *blocks;
/* First, count the number of blocks. */ /* First, count the number of blocks. */
do do
{ {
num++; num++;
p = pupa_strchr (p, ','); p = grub_strchr (p, ',');
} }
while (p); while (p);
/* Allocate a block list. */ /* Allocate a block list. */
blocks = pupa_malloc (sizeof (struct pupa_fs_block) * (num + 1)); blocks = grub_malloc (sizeof (struct grub_fs_block) * (num + 1));
if (! blocks) if (! blocks)
return 0; return 0;
@ -131,10 +131,10 @@ pupa_fs_blocklist_open (pupa_file_t file, const char *name)
{ {
if (*p != '+') if (*p != '+')
{ {
blocks[i].offset = pupa_strtoul (p, &p, 0); blocks[i].offset = grub_strtoul (p, &p, 0);
if (pupa_errno != PUPA_ERR_NONE || *p != '+') if (grub_errno != GRUB_ERR_NONE || *p != '+')
{ {
pupa_error (PUPA_ERR_BAD_FILENAME, grub_error (GRUB_ERR_BAD_FILENAME,
"invalid file name `%s'", name); "invalid file name `%s'", name);
goto fail; goto fail;
} }
@ -143,68 +143,68 @@ pupa_fs_blocklist_open (pupa_file_t file, const char *name)
blocks[i].offset = 0; blocks[i].offset = 0;
p++; p++;
blocks[i].length = pupa_strtoul (p, &p, 0); blocks[i].length = grub_strtoul (p, &p, 0);
if (pupa_errno != PUPA_ERR_NONE if (grub_errno != GRUB_ERR_NONE
|| blocks[i].length == 0 || blocks[i].length == 0
|| (*p && *p != ',' && ! pupa_isspace (*p))) || (*p && *p != ',' && ! grub_isspace (*p)))
{ {
pupa_error (PUPA_ERR_BAD_FILENAME, grub_error (GRUB_ERR_BAD_FILENAME,
"invalid file name `%s'", name); "invalid file name `%s'", name);
goto fail; goto fail;
} }
if (disk->total_sectors < blocks[i].offset + blocks[i].length) if (disk->total_sectors < blocks[i].offset + blocks[i].length)
{ {
pupa_error (PUPA_ERR_BAD_FILENAME, "beyond the total sectors"); grub_error (GRUB_ERR_BAD_FILENAME, "beyond the total sectors");
goto fail; goto fail;
} }
file->size += (blocks[i].length << PUPA_DISK_SECTOR_BITS); file->size += (blocks[i].length << GRUB_DISK_SECTOR_BITS);
p++; p++;
} }
blocks[i].length = 0; blocks[i].length = 0;
file->data = blocks; file->data = blocks;
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
fail: fail:
pupa_free (blocks); grub_free (blocks);
return pupa_errno; return grub_errno;
} }
static pupa_ssize_t static grub_ssize_t
pupa_fs_blocklist_read (pupa_file_t file, char *buf, pupa_ssize_t len) grub_fs_blocklist_read (grub_file_t file, char *buf, grub_ssize_t len)
{ {
struct pupa_fs_block *p; struct grub_fs_block *p;
unsigned long sector; unsigned long sector;
unsigned long offset; unsigned long offset;
pupa_ssize_t ret = 0; grub_ssize_t ret = 0;
if (len > file->size - file->offset) if (len > file->size - file->offset)
len = file->size - file->offset; len = file->size - file->offset;
sector = (file->offset >> PUPA_DISK_SECTOR_BITS); sector = (file->offset >> GRUB_DISK_SECTOR_BITS);
offset = (file->offset & (PUPA_DISK_SECTOR_SIZE - 1)); offset = (file->offset & (GRUB_DISK_SECTOR_SIZE - 1));
for (p = file->data; p->length && len > 0; p++) for (p = file->data; p->length && len > 0; p++)
{ {
if (sector < p->length) if (sector < p->length)
{ {
pupa_ssize_t size; grub_ssize_t size;
size = len; size = len;
if (((size + offset + PUPA_DISK_SECTOR_SIZE - 1) if (((size + offset + GRUB_DISK_SECTOR_SIZE - 1)
>> PUPA_DISK_SECTOR_BITS) > p->length - sector) >> GRUB_DISK_SECTOR_BITS) > p->length - sector)
size = ((p->length - sector) << PUPA_DISK_SECTOR_BITS) - offset; size = ((p->length - sector) << GRUB_DISK_SECTOR_BITS) - offset;
if (pupa_disk_read (file->device->disk, p->offset + sector, offset, if (grub_disk_read (file->device->disk, p->offset + sector, offset,
size, buf) != PUPA_ERR_NONE) size, buf) != GRUB_ERR_NONE)
return -1; return -1;
ret += size; ret += size;
len -= size; len -= size;
sector -= ((size + offset) >> PUPA_DISK_SECTOR_BITS); sector -= ((size + offset) >> GRUB_DISK_SECTOR_BITS);
offset = ((size + offset) & (PUPA_DISK_SECTOR_SIZE - 1)); offset = ((size + offset) & (GRUB_DISK_SECTOR_SIZE - 1));
} }
else else
sector -= p->length; sector -= p->length;
@ -213,12 +213,12 @@ pupa_fs_blocklist_read (pupa_file_t file, char *buf, pupa_ssize_t len)
return ret; return ret;
} }
struct pupa_fs pupa_fs_blocklist = struct grub_fs grub_fs_blocklist =
{ {
.name = "blocklist", .name = "blocklist",
.dir = 0, .dir = 0,
.open = pupa_fs_blocklist_open, .open = grub_fs_blocklist_open,
.read = pupa_fs_blocklist_read, .read = grub_fs_blocklist_read,
.close = 0, .close = 0,
.next = 0 .next = 0
}; };

View file

@ -1,9 +1,9 @@
/* dl-386.c - arch-dependent part of loadable module support */ /* dl-386.c - arch-dependent part of loadable module support */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,18 +14,18 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/elf.h> #include <grub/elf.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/err.h> #include <grub/err.h>
/* Check if EHDR is a valid ELF header. */ /* Check if EHDR is a valid ELF header. */
int int
pupa_arch_dl_check_header (void *ehdr, unsigned size) grub_arch_dl_check_header (void *ehdr, unsigned size)
{ {
Elf32_Ehdr *e = ehdr; Elf32_Ehdr *e = ehdr;
@ -53,8 +53,8 @@ pupa_arch_dl_check_header (void *ehdr, unsigned size)
} }
/* Relocate symbols. */ /* Relocate symbols. */
pupa_err_t grub_err_t
pupa_arch_dl_relocate_symbols (pupa_dl_t mod, void *ehdr) grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{ {
Elf32_Ehdr *e = ehdr; Elf32_Ehdr *e = ehdr;
Elf32_Shdr *s; Elf32_Shdr *s;
@ -70,7 +70,7 @@ pupa_arch_dl_relocate_symbols (pupa_dl_t mod, void *ehdr)
break; break;
if (i == e->e_shnum) if (i == e->e_shnum)
return pupa_error (PUPA_ERR_BAD_MODULE, "no symtab found"); return grub_error (GRUB_ERR_BAD_MODULE, "no symtab found");
symtab = (Elf32_Sym *) ((char *) e + s->sh_offset); symtab = (Elf32_Sym *) ((char *) e + s->sh_offset);
entsize = s->sh_entsize; entsize = s->sh_entsize;
@ -80,7 +80,7 @@ pupa_arch_dl_relocate_symbols (pupa_dl_t mod, void *ehdr)
i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize)) i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_REL) if (s->sh_type == SHT_REL)
{ {
pupa_dl_segment_t seg; grub_dl_segment_t seg;
/* Find the target segment. */ /* Find the target segment. */
for (seg = mod->segment; seg; seg = seg->next) for (seg = mod->segment; seg; seg = seg->next)
@ -100,7 +100,7 @@ pupa_arch_dl_relocate_symbols (pupa_dl_t mod, void *ehdr)
Elf32_Sym *sym; Elf32_Sym *sym;
if (seg->size < rel->r_offset) if (seg->size < rel->r_offset)
return pupa_error (PUPA_ERR_BAD_MODULE, return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment"); "reloc offset is out of the segment");
addr = (Elf32_Word *) ((char *) seg->addr + rel->r_offset); addr = (Elf32_Word *) ((char *) seg->addr + rel->r_offset);
@ -122,5 +122,5 @@ pupa_arch_dl_relocate_symbols (pupa_dl_t mod, void *ehdr)
} }
} }
return PUPA_ERR_NONE; return GRUB_ERR_NONE;
} }

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2003 Free Software Foundation, Inc. * Copyright (C) 2002, 2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,24 +17,24 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/kernel.h> #include <grub/kernel.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/machine/init.h> #include <grub/machine/init.h>
#include <pupa/machine/memory.h> #include <grub/machine/memory.h>
#include <pupa/machine/console.h> #include <grub/machine/console.h>
#include <pupa/machine/biosdisk.h> #include <grub/machine/biosdisk.h>
#include <pupa/machine/kernel.h> #include <grub/machine/kernel.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/loader.h> #include <grub/loader.h>
#include <pupa/env.h> #include <grub/env.h>
struct mem_region struct mem_region
{ {
pupa_addr_t addr; grub_addr_t addr;
pupa_size_t size; grub_size_t size;
}; };
#define MAX_REGIONS 32 #define MAX_REGIONS 32
@ -42,9 +42,9 @@ struct mem_region
static struct mem_region mem_regions[MAX_REGIONS]; static struct mem_region mem_regions[MAX_REGIONS];
static int num_regions; static int num_regions;
pupa_addr_t pupa_os_area_addr; grub_addr_t grub_os_area_addr;
pupa_size_t pupa_os_area_size; grub_size_t grub_os_area_size;
pupa_size_t pupa_lower_mem, pupa_upper_mem; grub_size_t grub_lower_mem, grub_upper_mem;
static char * static char *
make_install_device (void) make_install_device (void)
@ -52,25 +52,25 @@ make_install_device (void)
/* XXX: This should be enough. */ /* XXX: This should be enough. */
char dev[100]; char dev[100];
pupa_sprintf (dev, "(%cd%u", grub_sprintf (dev, "(%cd%u",
(pupa_boot_drive & 0x80) ? 'h' : 'f', (grub_boot_drive & 0x80) ? 'h' : 'f',
pupa_boot_drive & 0x7f); grub_boot_drive & 0x7f);
if (pupa_install_dos_part >= 0) if (grub_install_dos_part >= 0)
pupa_sprintf (dev + pupa_strlen (dev), ",%u", pupa_install_dos_part); grub_sprintf (dev + grub_strlen (dev), ",%u", grub_install_dos_part);
if (pupa_install_bsd_part >= 0) if (grub_install_bsd_part >= 0)
pupa_sprintf (dev + pupa_strlen (dev), ",%c", pupa_install_bsd_part + 'a'); grub_sprintf (dev + grub_strlen (dev), ",%c", grub_install_bsd_part + 'a');
pupa_sprintf (dev + pupa_strlen (dev), ")%s", pupa_prefix); grub_sprintf (dev + grub_strlen (dev), ")%s", grub_prefix);
pupa_strcpy (pupa_prefix, dev); grub_strcpy (grub_prefix, dev);
return pupa_prefix; return grub_prefix;
} }
/* Add a memory region. */ /* Add a memory region. */
static void static void
add_mem_region (pupa_addr_t addr, pupa_size_t size) add_mem_region (grub_addr_t addr, grub_size_t size)
{ {
if (num_regions == MAX_REGIONS) if (num_regions == MAX_REGIONS)
/* Ignore. */ /* Ignore. */
@ -108,44 +108,44 @@ compact_mem_regions (void)
mem_regions[i].size = (mem_regions[j].addr + mem_regions[j].size mem_regions[i].size = (mem_regions[j].addr + mem_regions[j].size
- mem_regions[i].addr); - mem_regions[i].addr);
pupa_memmove (mem_regions + j, mem_regions + j + 1, grub_memmove (mem_regions + j, mem_regions + j + 1,
(num_regions - j - 1) * sizeof (struct mem_region)); (num_regions - j - 1) * sizeof (struct mem_region));
i--; i--;
} }
} }
void void
pupa_machine_init (void) grub_machine_init (void)
{ {
pupa_uint32_t cont; grub_uint32_t cont;
struct pupa_machine_mmap_entry *entry struct grub_machine_mmap_entry *entry
= (struct pupa_machine_mmap_entry *) PUPA_MEMORY_MACHINE_SCRATCH_ADDR; = (struct grub_machine_mmap_entry *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
pupa_addr_t end_addr = pupa_get_end_addr (); grub_addr_t end_addr = grub_get_end_addr ();
int i; int i;
/* Initialize the console as early as possible. */ /* Initialize the console as early as possible. */
pupa_console_init (); grub_console_init ();
pupa_lower_mem = pupa_get_memsize (0) << 10; grub_lower_mem = grub_get_memsize (0) << 10;
/* Sanity check. */ /* Sanity check. */
if (pupa_lower_mem < PUPA_MEMORY_MACHINE_RESERVED_END) if (grub_lower_mem < GRUB_MEMORY_MACHINE_RESERVED_END)
pupa_fatal ("too small memory"); grub_fatal ("too small memory");
#if 0 #if 0
/* Turn on Gate A20 to access >1MB. */ /* Turn on Gate A20 to access >1MB. */
pupa_gate_a20 (1); grub_gate_a20 (1);
#endif #endif
/* Add the lower memory into free memory. */ /* Add the lower memory into free memory. */
if (pupa_lower_mem >= PUPA_MEMORY_MACHINE_RESERVED_END) if (grub_lower_mem >= GRUB_MEMORY_MACHINE_RESERVED_END)
add_mem_region (PUPA_MEMORY_MACHINE_RESERVED_END, add_mem_region (GRUB_MEMORY_MACHINE_RESERVED_END,
pupa_lower_mem - PUPA_MEMORY_MACHINE_RESERVED_END); grub_lower_mem - GRUB_MEMORY_MACHINE_RESERVED_END);
add_mem_region (end_addr, PUPA_MEMORY_MACHINE_RESERVED_START - end_addr); add_mem_region (end_addr, GRUB_MEMORY_MACHINE_RESERVED_START - end_addr);
/* Check if pupa_get_mmap_entry works. */ /* Check if grub_get_mmap_entry works. */
cont = pupa_get_mmap_entry (entry, 0); cont = grub_get_mmap_entry (entry, 0);
if (entry->size) if (entry->size)
do do
@ -163,13 +163,13 @@ pupa_machine_init (void)
/* Ignore >4GB. */ /* Ignore >4GB. */
if (entry->addr <= 0xFFFFFFFF && entry->type == 1) if (entry->addr <= 0xFFFFFFFF && entry->type == 1)
{ {
pupa_addr_t addr; grub_addr_t addr;
pupa_size_t len; grub_size_t len;
addr = (pupa_addr_t) entry->addr; addr = (grub_addr_t) entry->addr;
len = ((addr + entry->len > 0xFFFFFFFF) len = ((addr + entry->len > 0xFFFFFFFF)
? 0xFFFFFFFF - addr ? 0xFFFFFFFF - addr
: (pupa_size_t) entry->len); : (grub_size_t) entry->len);
add_mem_region (addr, len); add_mem_region (addr, len);
} }
@ -177,12 +177,12 @@ pupa_machine_init (void)
if (! cont) if (! cont)
break; break;
cont = pupa_get_mmap_entry (entry, cont); cont = grub_get_mmap_entry (entry, cont);
} }
while (entry->size); while (entry->size);
else else
{ {
pupa_uint32_t eisa_mmap = pupa_get_eisa_mmap (); grub_uint32_t eisa_mmap = grub_get_eisa_mmap ();
if (eisa_mmap) if (eisa_mmap)
{ {
@ -195,7 +195,7 @@ pupa_machine_init (void)
} }
} }
else else
add_mem_region (0x100000, pupa_get_memsize (1) << 10); add_mem_region (0x100000, grub_get_memsize (1) << 10);
} }
compact_mem_regions (); compact_mem_regions ();
@ -206,24 +206,24 @@ pupa_machine_init (void)
for (i = 0; i < num_regions; i++) for (i = 0; i < num_regions; i++)
if (mem_regions[i].addr == 0x100000) if (mem_regions[i].addr == 0x100000)
{ {
pupa_size_t quarter = mem_regions[i].size >> 2; grub_size_t quarter = mem_regions[i].size >> 2;
pupa_upper_mem = mem_regions[i].size; grub_upper_mem = mem_regions[i].size;
pupa_os_area_addr = mem_regions[i].addr; grub_os_area_addr = mem_regions[i].addr;
pupa_os_area_size = mem_regions[i].size - quarter; grub_os_area_size = mem_regions[i].size - quarter;
pupa_mm_init_region ((void *) (pupa_os_area_addr + pupa_os_area_size), grub_mm_init_region ((void *) (grub_os_area_addr + grub_os_area_size),
quarter); quarter);
} }
else else
pupa_mm_init_region ((void *) mem_regions[i].addr, mem_regions[i].size); grub_mm_init_region ((void *) mem_regions[i].addr, mem_regions[i].size);
if (! pupa_os_area_addr) if (! grub_os_area_addr)
pupa_fatal ("no upper memory"); grub_fatal ("no upper memory");
/* The memory system was initialized, thus register built-in devices. */ /* The memory system was initialized, thus register built-in devices. */
pupa_biosdisk_init (); grub_biosdisk_init ();
/* Initialize the prefix. */ /* Initialize the prefix. */
pupa_env_set ("prefix", make_install_device ()); grub_env_set ("prefix", make_install_device ());
} }

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer * Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
@ -21,7 +21,7 @@
/* /*
* This code was stolen from the files enter.sh, leave.sh, lzo1x_d.sh, * This code was stolen from the files enter.sh, leave.sh, lzo1x_d.sh,
* lzo1x_f.s and lzo_asm.h in LZO version 1.08, and was heavily modified * lzo1x_f.s and lzo_asm.h in LZO version 1.08, and was heavily modified
* to adapt it to PUPA's requirement. * to adapt it to GRUB's requirement.
* *
* See <http://www.oberhumer.com/opensource/lzo/>, for more information * See <http://www.oberhumer.com/opensource/lzo/>, for more information
* about LZO. * about LZO.

View file

@ -1,5 +1,5 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -35,7 +35,7 @@
*/ */
/* /*
* Note: PUPA is compiled with the options -mrtd and -mregparm=3. * Note: GRUB is compiled with the options -mrtd and -mregparm=3.
* So the first three arguments are passed in %eax, %edx, and %ecx, * So the first three arguments are passed in %eax, %edx, and %ecx,
* respectively, and if a function has a fixed number of arguments * respectively, and if a function has a fixed number of arguments
* and the number if greater than three, the function must return * and the number if greater than three, the function must return
@ -43,16 +43,16 @@
*/ */
#include <config.h> #include <config.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/boot.h> #include <grub/boot.h>
#include <pupa/machine/boot.h> #include <grub/machine/boot.h>
#include <pupa/machine/memory.h> #include <grub/machine/memory.h>
#include <pupa/machine/console.h> #include <grub/machine/console.h>
#include <pupa/machine/linux.h> #include <grub/machine/linux.h>
#include <pupa/machine/kernel.h> #include <grub/machine/kernel.h>
#include <pupa/machine/multiboot.h> #include <grub/machine/multiboot.h>
#define ABS(x) ((x) - EXT_C(start) + PUPA_BOOT_MACHINE_KERNEL_ADDR + 0x200) #define ABS(x) ((x) - EXT_C(start) + GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
.file "startup.S" .file "startup.S"
@ -77,7 +77,7 @@ _start:
* DO NOT MOVE !!! * DO NOT MOVE !!!
*/ */
. = EXT_C(start) + 0x6 . = EXT_C(start) + 0x6
.byte PUPA_BOOT_VERSION_MAJOR, PUPA_BOOT_VERSION_MINOR .byte GRUB_BOOT_VERSION_MAJOR, GRUB_BOOT_VERSION_MINOR
/* /*
* This is a special data area 8 bytes from the beginning. * This is a special data area 8 bytes from the beginning.
@ -85,18 +85,18 @@ _start:
. = EXT_C(start) + 0x8 . = EXT_C(start) + 0x8
VARIABLE(pupa_total_module_size) VARIABLE(grub_total_module_size)
.long 0 .long 0
VARIABLE(pupa_kernel_image_size) VARIABLE(grub_kernel_image_size)
.long 0 .long 0
VARIABLE(pupa_compressed_size) VARIABLE(grub_compressed_size)
.long 0 .long 0
VARIABLE(pupa_install_dos_part) VARIABLE(grub_install_dos_part)
.long 0xFFFFFFFF .long 0xFFFFFFFF
VARIABLE(pupa_install_bsd_part) VARIABLE(grub_install_bsd_part)
.long 0xFFFFFFFF .long 0xFFFFFFFF
VARIABLE(pupa_prefix) VARIABLE(grub_prefix)
.string "/boot/pupa" .string "/boot/grub"
/* /*
* Leave some breathing room for the prefix. * Leave some breathing room for the prefix.
@ -115,13 +115,13 @@ codestart:
movw %ax, %es movw %ax, %es
/* set up the real mode/BIOS stack */ /* set up the real mode/BIOS stack */
movl $PUPA_MEMORY_MACHINE_REAL_STACK, %ebp movl $GRUB_MEMORY_MACHINE_REAL_STACK, %ebp
movl %ebp, %esp movl %ebp, %esp
sti /* we're safe again */ sti /* we're safe again */
/* save boot drive reference */ /* save boot drive reference */
ADDR32 movb %dl, EXT_C(pupa_boot_drive) ADDR32 movb %dl, EXT_C(grub_boot_drive)
/* reset disk system (%ah = 0) */ /* reset disk system (%ah = 0) */
int $0x13 int $0x13
@ -133,14 +133,14 @@ codestart:
.code32 .code32
incl %eax incl %eax
call EXT_C(pupa_gate_a20) call EXT_C(grub_gate_a20)
/* decompress the compressed part and put the result at 1MB */ /* decompress the compressed part and put the result at 1MB */
movl $0x100000, %esi movl $0x100000, %esi
movl $(START_SYMBOL + PUPA_KERNEL_MACHINE_RAW_SIZE), %edi movl $(START_SYMBOL + GRUB_KERNEL_MACHINE_RAW_SIZE), %edi
pushl %esi pushl %esi
pushl EXT_C(pupa_compressed_size) pushl EXT_C(grub_compressed_size)
pushl %edi pushl %edi
call lzo1x_decompress call lzo1x_decompress
addl $12, %esp addl $12, %esp
@ -152,8 +152,8 @@ codestart:
movsb movsb
/* copy modules before cleaning out the bss */ /* copy modules before cleaning out the bss */
movl EXT_C(pupa_total_module_size), %ecx movl EXT_C(grub_total_module_size), %ecx
movl EXT_C(pupa_kernel_image_size), %esi movl EXT_C(grub_kernel_image_size), %esi
addl %ecx, %esi addl %ecx, %esi
addl $START_SYMBOL, %esi addl $START_SYMBOL, %esi
decl %esi decl %esi
@ -180,7 +180,7 @@ codestart:
/* /*
* Call the start of main body of C code. * Call the start of main body of C code.
*/ */
call EXT_C(pupa_main) call EXT_C(grub_main)
/* /*
@ -190,18 +190,18 @@ codestart:
.p2align 2 /* force 4-byte alignment */ .p2align 2 /* force 4-byte alignment */
protstack: protstack:
.long PUPA_MEMORY_MACHINE_PROT_STACK .long GRUB_MEMORY_MACHINE_PROT_STACK
VARIABLE(pupa_boot_drive) VARIABLE(grub_boot_drive)
.long 0 .long 0
VARIABLE(pupa_start_addr) VARIABLE(grub_start_addr)
.long START_SYMBOL .long START_SYMBOL
VARIABLE(pupa_end_addr) VARIABLE(grub_end_addr)
.long END_SYMBOL .long END_SYMBOL
VARIABLE(pupa_apm_bios_info) VARIABLE(grub_apm_bios_info)
.word 0 /* version */ .word 0 /* version */
.word 0 /* cseg */ .word 0 /* cseg */
.long 0 /* offset */ .long 0 /* offset */
@ -275,16 +275,16 @@ real_to_prot:
/* turn on protected mode */ /* turn on protected mode */
movl %cr0, %eax movl %cr0, %eax
orl $PUPA_MEMORY_MACHINE_CR0_PE_ON, %eax orl $GRUB_MEMORY_MACHINE_CR0_PE_ON, %eax
movl %eax, %cr0 movl %eax, %cr0
/* jump to relocation, flush prefetch queue, and reload %cs */ /* jump to relocation, flush prefetch queue, and reload %cs */
DATA32 ljmp $PUPA_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg DATA32 ljmp $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg
.code32 .code32
protcseg: protcseg:
/* reload other segment registers */ /* reload other segment registers */
movw $PUPA_MEMORY_MACHINE_PROT_MODE_DSEG, %ax movw $GRUB_MEMORY_MACHINE_PROT_MODE_DSEG, %ax
movw %ax, %ds movw %ax, %ds
movw %ax, %es movw %ax, %es
movw %ax, %fs movw %ax, %fs
@ -293,7 +293,7 @@ protcseg:
/* put the return address in a known safe location */ /* put the return address in a known safe location */
movl (%esp), %eax movl (%esp), %eax
movl %eax, PUPA_MEMORY_MACHINE_REAL_STACK movl %eax, GRUB_MEMORY_MACHINE_REAL_STACK
/* get protected mode stack */ /* get protected mode stack */
movl protstack, %eax movl protstack, %eax
@ -301,7 +301,7 @@ protcseg:
movl %eax, %ebp movl %eax, %ebp
/* get return address onto the right stack */ /* get return address onto the right stack */
movl PUPA_MEMORY_MACHINE_REAL_STACK, %eax movl GRUB_MEMORY_MACHINE_REAL_STACK, %eax
movl %eax, (%esp) movl %eax, (%esp)
/* zero %eax */ /* zero %eax */
@ -321,15 +321,15 @@ prot_to_real:
/* get the return address */ /* get the return address */
movl (%esp), %eax movl (%esp), %eax
movl %eax, PUPA_MEMORY_MACHINE_REAL_STACK movl %eax, GRUB_MEMORY_MACHINE_REAL_STACK
/* set up new stack */ /* set up new stack */
movl $PUPA_MEMORY_MACHINE_REAL_STACK, %eax movl $GRUB_MEMORY_MACHINE_REAL_STACK, %eax
movl %eax, %esp movl %eax, %esp
movl %eax, %ebp movl %eax, %ebp
/* set up segment limits */ /* set up segment limits */
movw $PUPA_MEMORY_MACHINE_PSEUDO_REAL_DSEG, %ax movw $GRUB_MEMORY_MACHINE_PSEUDO_REAL_DSEG, %ax
movw %ax, %ds movw %ax, %ds
movw %ax, %es movw %ax, %es
movw %ax, %fs movw %ax, %fs
@ -338,14 +338,14 @@ prot_to_real:
/* this might be an extra step */ /* this might be an extra step */
/* jump to a 16 bit segment */ /* jump to a 16 bit segment */
ljmp $PUPA_MEMORY_MACHINE_PSEUDO_REAL_CSEG, $tmpcseg ljmp $GRUB_MEMORY_MACHINE_PSEUDO_REAL_CSEG, $tmpcseg
tmpcseg: tmpcseg:
.code16 .code16
/* clear the PE bit of CR0 */ /* clear the PE bit of CR0 */
movl %cr0, %eax movl %cr0, %eax
andl $(~PUPA_MEMORY_MACHINE_CR0_PE_ON), %eax andl $(~GRUB_MEMORY_MACHINE_CR0_PE_ON), %eax
movl %eax, %cr0 movl %eax, %cr0
/* flush prefetch queue, reload %cs */ /* flush prefetch queue, reload %cs */
@ -374,7 +374,7 @@ realcseg:
/* /*
* pupa_gate_a20(int on) * grub_gate_a20(int on)
* *
* Gate address-line 20 for high memory. * Gate address-line 20 for high memory.
* *
@ -383,7 +383,7 @@ realcseg:
* It also eats any keystrokes in the keyboard buffer. :-( * It also eats any keystrokes in the keyboard buffer. :-(
*/ */
FUNCTION(pupa_gate_a20) FUNCTION(grub_gate_a20)
movl %eax, %ecx movl %eax, %ecx
call gloop1 call gloop1
@ -437,7 +437,7 @@ gloop2ret:
* hang at this point! * hang at this point!
*/ */
FUNCTION(pupa_stop) FUNCTION(grub_stop)
call prot_to_real call prot_to_real
/* /*
@ -446,29 +446,29 @@ FUNCTION(pupa_stop)
* mode, so think about it before changing it. * mode, so think about it before changing it.
*/ */
FUNCTION(pupa_hard_stop) FUNCTION(grub_hard_stop)
hlt hlt
jmp EXT_C(pupa_hard_stop) jmp EXT_C(grub_hard_stop)
/* /*
* pupa_stop_floppy() * grub_stop_floppy()
* *
* Stop the floppy drive from spinning, so that other software is * Stop the floppy drive from spinning, so that other software is
* jumped to with a known state. * jumped to with a known state.
*/ */
FUNCTION(pupa_stop_floppy) FUNCTION(grub_stop_floppy)
movw $0x3F2, %dx movw $0x3F2, %dx
xorb %al, %al xorb %al, %al
outb %al, %dx outb %al, %dx
ret ret
/* /*
* pupa_reboot() * grub_reboot()
* *
* Reboot the system. At the moment, rely on BIOS. * Reboot the system. At the moment, rely on BIOS.
*/ */
FUNCTION(pupa_reboot) FUNCTION(grub_reboot)
call prot_to_real call prot_to_real
.code16 .code16
/* cold boot */ /* cold boot */
@ -478,15 +478,15 @@ FUNCTION(pupa_reboot)
.code32 .code32
/* /*
* pupa_halt(int no_apm) * grub_halt(int no_apm)
* *
* Halt the system, using APM if possible. If NO_APM is true, don't use * Halt the system, using APM if possible. If NO_APM is true, don't use
* APM even if it is available. * APM even if it is available.
*/ */
FUNCTION(pupa_halt) FUNCTION(grub_halt)
/* see if zero */ /* see if zero */
testl %eax, %eax testl %eax, %eax
jnz EXT_C(pupa_stop) jnz EXT_C(grub_stop)
call prot_to_real call prot_to_real
.code16 .code16
@ -495,7 +495,7 @@ FUNCTION(pupa_halt)
movw $0x5300, %ax movw $0x5300, %ax
xorw %bx, %bx xorw %bx, %bx
int $0x15 int $0x15
jc EXT_C(pupa_hard_stop) jc EXT_C(grub_hard_stop)
/* don't check %bx for buggy BIOSes... */ /* don't check %bx for buggy BIOSes... */
/* disconnect APM first */ /* disconnect APM first */
@ -507,14 +507,14 @@ FUNCTION(pupa_halt)
movw $0x5301, %ax movw $0x5301, %ax
xorw %bx, %bx xorw %bx, %bx
int $0x15 int $0x15
jc EXT_C(pupa_hard_stop) jc EXT_C(grub_hard_stop)
/* set APM protocol level - 1.1 or bust. (this covers APM 1.2 also) */ /* set APM protocol level - 1.1 or bust. (this covers APM 1.2 also) */
movw $0x530E, %ax movw $0x530E, %ax
xorw %bx, %bx xorw %bx, %bx
movw $0x0101, %cx movw $0x0101, %cx
int $0x15 int $0x15
jc EXT_C(pupa_hard_stop) jc EXT_C(grub_hard_stop)
/* set the power state to off */ /* set the power state to off */
movw $0x5307, %ax movw $0x5307, %ax
@ -523,21 +523,21 @@ FUNCTION(pupa_halt)
int $0x15 int $0x15
/* shouldn't reach here */ /* shouldn't reach here */
jmp EXT_C(pupa_hard_stop) jmp EXT_C(grub_hard_stop)
.code32 .code32
/* /*
* void pupa_chainloader_real_boot (int drive, void *part_addr) * void grub_chainloader_real_boot (int drive, void *part_addr)
* *
* This starts another boot loader. * This starts another boot loader.
*/ */
FUNCTION(pupa_chainloader_real_boot) FUNCTION(grub_chainloader_real_boot)
pushl %edx pushl %edx
pushl %eax pushl %eax
call EXT_C(pupa_dl_unload_all) call EXT_C(grub_dl_unload_all)
/* set up to pass boot drive */ /* set up to pass boot drive */
popl %edx popl %edx
@ -547,44 +547,44 @@ FUNCTION(pupa_chainloader_real_boot)
/* Turn off Gate A20 */ /* Turn off Gate A20 */
xorl %eax, %eax xorl %eax, %eax
call EXT_C(pupa_gate_a20) call EXT_C(grub_gate_a20)
call prot_to_real call prot_to_real
.code16 .code16
ljmp $0, $PUPA_MEMORY_MACHINE_BOOT_LOADER_ADDR ljmp $0, $GRUB_MEMORY_MACHINE_BOOT_LOADER_ADDR
.code32 .code32
/* /*
* void pupa_linux_boot_zimage (void) * void grub_linux_boot_zimage (void)
*/ */
VARIABLE(pupa_linux_prot_size) VARIABLE(grub_linux_prot_size)
.long 0 .long 0
VARIABLE(pupa_linux_tmp_addr) VARIABLE(grub_linux_tmp_addr)
.long 0 .long 0
VARIABLE(pupa_linux_real_addr) VARIABLE(grub_linux_real_addr)
.long 0 .long 0
FUNCTION(pupa_linux_boot_zimage) FUNCTION(grub_linux_boot_zimage)
/* copy the kernel */ /* copy the kernel */
movl EXT_C(pupa_linux_prot_size), %ecx movl EXT_C(grub_linux_prot_size), %ecx
addl $3, %ecx addl $3, %ecx
shrl $2, %ecx shrl $2, %ecx
movl $PUPA_LINUX_BZIMAGE_ADDR, %esi movl $GRUB_LINUX_BZIMAGE_ADDR, %esi
movl $PUPA_LINUX_ZIMAGE_ADDR, %edi movl $GRUB_LINUX_ZIMAGE_ADDR, %edi
cld cld
rep rep
movsl movsl
FUNCTION(pupa_linux_boot_bzimage) FUNCTION(grub_linux_boot_bzimage)
call EXT_C(pupa_dl_unload_all) call EXT_C(grub_dl_unload_all)
movl EXT_C(pupa_linux_real_addr), %ebx movl EXT_C(grub_linux_real_addr), %ebx
/* copy the real mode code */ /* copy the real mode code */
movl EXT_C(pupa_linux_tmp_addr), %esi movl EXT_C(grub_linux_tmp_addr), %esi
movl %ebx, %edi movl %ebx, %edi
movl $PUPA_LINUX_SETUP_MOVE_SIZE, %ecx movl $GRUB_LINUX_SETUP_MOVE_SIZE, %ecx
cld cld
rep rep
movsb movsb
@ -597,7 +597,7 @@ FUNCTION(pupa_linux_boot_bzimage)
/* XXX new stack pointer in safe area for calling functions */ /* XXX new stack pointer in safe area for calling functions */
movl $0x4000, %esp movl $0x4000, %esp
call EXT_C(pupa_stop_floppy) call EXT_C(grub_stop_floppy)
/* final setup for linux boot */ /* final setup for linux boot */
call prot_to_real call prot_to_real
@ -605,7 +605,7 @@ FUNCTION(pupa_linux_boot_bzimage)
cli cli
movw %bx, %ss movw %bx, %ss
movw $PUPA_LINUX_SETUP_STACK, %sp movw $GRUB_LINUX_SETUP_STACK, %sp
movw %bx, %ds movw %bx, %ds
movw %bx, %es movw %bx, %es
@ -624,34 +624,34 @@ linux_setup_seg:
* This starts the multiboot kernel. * This starts the multiboot kernel.
*/ */
FUNCTION(pupa_multiboot_real_boot) FUNCTION(grub_multiboot_real_boot)
/* Push the entry address on the stack. */ /* Push the entry address on the stack. */
pushl %eax pushl %eax
/* Move the address of the multiboot information structure to ebx. */ /* Move the address of the multiboot information structure to ebx. */
movl %edx,%ebx movl %edx,%ebx
/* Unload all modules and stop the floppy driver. */ /* Unload all modules and stop the floppy driver. */
call EXT_C(pupa_dl_unload_all) call EXT_C(grub_dl_unload_all)
call EXT_C(pupa_stop_floppy) call EXT_C(grub_stop_floppy)
/* Interrupts should be disabled. */ /* Interrupts should be disabled. */
cli cli
/* Move the magic value into eax and jump to the kernel. */ /* Move the magic value into eax and jump to the kernel. */
movl $PUPA_MB_MAGIC2,%eax movl $GRUB_MB_MAGIC2,%eax
popl %ecx popl %ecx
jmp *%ecx jmp *%ecx
/* /*
* int pupa_biosdisk_rw_int13_extensions (int ah, int drive, void *dap) * int grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap)
* *
* Call IBM/MS INT13 Extensions (int 13 %ah=AH) for DRIVE. DAP * Call IBM/MS INT13 Extensions (int 13 %ah=AH) for DRIVE. DAP
* is passed for disk address packet. If an error occurs, return * is passed for disk address packet. If an error occurs, return
* non-zero, otherwise zero. * non-zero, otherwise zero.
*/ */
FUNCTION(pupa_biosdisk_rw_int13_extensions) FUNCTION(grub_biosdisk_rw_int13_extensions)
pushl %ebp pushl %ebp
pushl %esi pushl %esi
@ -685,7 +685,7 @@ FUNCTION(pupa_biosdisk_rw_int13_extensions)
ret ret
/* /*
* int pupa_biosdisk_rw_standard (int ah, int drive, int coff, int hoff, * int grub_biosdisk_rw_standard (int ah, int drive, int coff, int hoff,
* int soff, int nsec, int segment) * int soff, int nsec, int segment)
* *
* Call standard and old INT13 (int 13 %ah=AH) for DRIVE. Read/write * Call standard and old INT13 (int 13 %ah=AH) for DRIVE. Read/write
@ -693,7 +693,7 @@ FUNCTION(pupa_biosdisk_rw_int13_extensions)
* return non-zero, otherwise zero. * return non-zero, otherwise zero.
*/ */
FUNCTION(pupa_biosdisk_rw_standard) FUNCTION(grub_biosdisk_rw_standard)
pushl %ebp pushl %ebp
movl %esp, %ebp movl %esp, %ebp
@ -759,13 +759,13 @@ FUNCTION(pupa_biosdisk_rw_standard)
/* /*
* int pupa_biosdisk_check_int13_extensions (int drive) * int grub_biosdisk_check_int13_extensions (int drive)
* *
* Check if LBA is supported for DRIVE. If it is supported, then return * Check if LBA is supported for DRIVE. If it is supported, then return
* the major version of extensions, otherwise zero. * the major version of extensions, otherwise zero.
*/ */
FUNCTION(pupa_biosdisk_check_int13_extensions) FUNCTION(grub_biosdisk_check_int13_extensions)
pushl %ebp pushl %ebp
pushl %ebx pushl %ebx
@ -806,13 +806,13 @@ FUNCTION(pupa_biosdisk_check_int13_extensions)
/* /*
* int pupa_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp) * int grub_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp)
* *
* Return the geometry of DRIVE in a drive parameters, DRP. If an error * Return the geometry of DRIVE in a drive parameters, DRP. If an error
* occurs, then return non-zero, otherwise zero. * occurs, then return non-zero, otherwise zero.
*/ */
FUNCTION(pupa_biosdisk_get_diskinfo_int13_extensions) FUNCTION(grub_biosdisk_get_diskinfo_int13_extensions)
pushl %ebp pushl %ebp
pushl %ebx pushl %ebx
pushl %esi pushl %esi
@ -849,7 +849,7 @@ FUNCTION(pupa_biosdisk_get_diskinfo_int13_extensions)
/* /*
* int pupa_biosdisk_get_diskinfo_standard (int drive, * int grub_biosdisk_get_diskinfo_standard (int drive,
* unsigned long *cylinders, * unsigned long *cylinders,
* unsigned long *heads, * unsigned long *heads,
* unsigned long *sectors) * unsigned long *sectors)
@ -858,7 +858,7 @@ FUNCTION(pupa_biosdisk_get_diskinfo_int13_extensions)
* error occurs, then return non-zero, otherwise zero. * error occurs, then return non-zero, otherwise zero.
*/ */
FUNCTION(pupa_biosdisk_get_diskinfo_standard) FUNCTION(grub_biosdisk_get_diskinfo_standard)
pushl %ebp pushl %ebp
pushl %ebx pushl %ebx
pushl %edi pushl %edi
@ -922,9 +922,9 @@ FUNCTION(pupa_biosdisk_get_diskinfo_standard)
/* /*
* int pupa_biosdisk_get_num_floppies (void) * int grub_biosdisk_get_num_floppies (void)
*/ */
FUNCTION(pupa_biosdisk_get_num_floppies) FUNCTION(grub_biosdisk_get_num_floppies)
pushl %ebp pushl %ebp
xorl %edx, %edx xorl %edx, %edx
@ -960,7 +960,7 @@ FUNCTION(pupa_biosdisk_get_num_floppies)
/* /*
* *
* pupa_get_memsize(i) : return the memory size in KB. i == 0 for conventional * grub_get_memsize(i) : return the memory size in KB. i == 0 for conventional
* memory, i == 1 for extended memory * memory, i == 1 for extended memory
* BIOS call "INT 12H" to get conventional memory size * BIOS call "INT 12H" to get conventional memory size
* BIOS call "INT 15H, AH=88H" to get extended memory size * BIOS call "INT 15H, AH=88H" to get extended memory size
@ -968,7 +968,7 @@ FUNCTION(pupa_biosdisk_get_num_floppies)
* *
*/ */
FUNCTION(pupa_get_memsize) FUNCTION(grub_get_memsize)
pushl %ebp pushl %ebp
movl %eax, %edx movl %eax, %edx
@ -1000,7 +1000,7 @@ xdone:
/* /*
* *
* pupa_get_eisa_mmap() : return packed EISA memory map, lower 16 bits is * grub_get_eisa_mmap() : return packed EISA memory map, lower 16 bits is
* memory between 1M and 16M in 1K parts, upper 16 bits is * memory between 1M and 16M in 1K parts, upper 16 bits is
* memory above 16M in 64K parts. If error, return zero. * memory above 16M in 64K parts. If error, return zero.
* BIOS call "INT 15H, AH=E801H" to get EISA memory map, * BIOS call "INT 15H, AH=E801H" to get EISA memory map,
@ -1009,7 +1009,7 @@ xdone:
* *
*/ */
FUNCTION(pupa_get_eisa_mmap) FUNCTION(grub_get_eisa_mmap)
pushl %ebp pushl %ebp
pushl %ebx pushl %ebx
@ -1037,7 +1037,7 @@ xnoteisa:
/* /*
* *
* pupa_get_mmap_entry(addr, cont) : address and old continuation value (zero to * grub_get_mmap_entry(addr, cont) : address and old continuation value (zero to
* start), for the Query System Address Map BIOS call. * start), for the Query System Address Map BIOS call.
* *
* Sets the first 4-byte int value of "addr" to the size returned by * Sets the first 4-byte int value of "addr" to the size returned by
@ -1046,7 +1046,7 @@ xnoteisa:
* Returns: new (non-zero) continuation value, 0 if done. * Returns: new (non-zero) continuation value, 0 if done.
*/ */
FUNCTION(pupa_get_mmap_entry) FUNCTION(grub_get_mmap_entry)
pushl %ebp pushl %ebp
pushl %ebx pushl %ebx
pushl %edi pushl %edi
@ -1113,7 +1113,7 @@ xsmap:
/* /*
* void pupa_console_real_putchar (int c) * void grub_console_real_putchar (int c)
* *
* Put the character C on the console. Because GRUB wants to write a * Put the character C on the console. Because GRUB wants to write a
* character with an attribute, this implementation is a bit tricky. * character with an attribute, this implementation is a bit tricky.
@ -1126,10 +1126,10 @@ xsmap:
* get the height of the screen, and the TELETYPE OUPUT BIOS call doesn't * get the height of the screen, and the TELETYPE OUPUT BIOS call doesn't
* support setting a background attribute. * support setting a background attribute.
*/ */
FUNCTION(pupa_console_real_putchar) FUNCTION(grub_console_real_putchar)
movl %eax, %edx movl %eax, %edx
pusha pusha
movb EXT_C(pupa_console_cur_color), %bl movb EXT_C(grub_console_cur_color), %bl
call prot_to_real call prot_to_real
.code16 .code16
@ -1197,7 +1197,7 @@ FUNCTION(pupa_console_real_putchar)
/* /*
* int pupa_console_getkey (void) * int grub_console_getkey (void)
* BIOS call "INT 16H Function 00H" to read character from keyboard * BIOS call "INT 16H Function 00H" to read character from keyboard
* Call with %ah = 0x0 * Call with %ah = 0x0
* Return: %ah = keyboard scan code * Return: %ah = keyboard scan code
@ -1206,16 +1206,16 @@ FUNCTION(pupa_console_real_putchar)
/* this table is used in translate_keycode below */ /* this table is used in translate_keycode below */
translation_table: translation_table:
.word PUPA_CONSOLE_KEY_LEFT, 2 .word GRUB_CONSOLE_KEY_LEFT, 2
.word PUPA_CONSOLE_KEY_RIGHT, 6 .word GRUB_CONSOLE_KEY_RIGHT, 6
.word PUPA_CONSOLE_KEY_UP, 16 .word GRUB_CONSOLE_KEY_UP, 16
.word PUPA_CONSOLE_KEY_DOWN, 14 .word GRUB_CONSOLE_KEY_DOWN, 14
.word PUPA_CONSOLE_KEY_HOME, 1 .word GRUB_CONSOLE_KEY_HOME, 1
.word PUPA_CONSOLE_KEY_END, 5 .word GRUB_CONSOLE_KEY_END, 5
.word PUPA_CONSOLE_KEY_DC, 4 .word GRUB_CONSOLE_KEY_DC, 4
.word PUPA_CONSOLE_KEY_BACKSPACE, 8 .word GRUB_CONSOLE_KEY_BACKSPACE, 8
.word PUPA_CONSOLE_KEY_PPAGE, 7 .word GRUB_CONSOLE_KEY_PPAGE, 7
.word PUPA_CONSOLE_KEY_NPAGE, 3 .word GRUB_CONSOLE_KEY_NPAGE, 3
.word 0 .word 0
/* /*
@ -1248,7 +1248,7 @@ translate_keycode:
.code32 .code32
FUNCTION(pupa_console_getkey) FUNCTION(grub_console_getkey)
pushl %ebp pushl %ebp
call prot_to_real call prot_to_real
@ -1269,7 +1269,7 @@ FUNCTION(pupa_console_getkey)
/* /*
* int pupa_console_checkkey (void) * int grub_console_checkkey (void)
* if there is a character pending, return it; otherwise return -1 * if there is a character pending, return it; otherwise return -1
* BIOS call "INT 16H Function 01H" to check whether a character is pending * BIOS call "INT 16H Function 01H" to check whether a character is pending
* Call with %ah = 0x1 * Call with %ah = 0x1
@ -1281,7 +1281,7 @@ FUNCTION(pupa_console_getkey)
* else * else
* Zero flag = set * Zero flag = set
*/ */
FUNCTION(pupa_console_checkkey) FUNCTION(grub_console_checkkey)
pushl %ebp pushl %ebp
xorl %edx, %edx xorl %edx, %edx
@ -1310,7 +1310,7 @@ pending:
/* /*
* pupa_uint16_t pupa_console_getxy (void) * grub_uint16_t grub_console_getxy (void)
* BIOS call "INT 10H Function 03h" to get cursor position * BIOS call "INT 10H Function 03h" to get cursor position
* Call with %ah = 0x03 * Call with %ah = 0x03
* %bh = page * %bh = page
@ -1321,7 +1321,7 @@ pending:
*/ */
FUNCTION(pupa_console_getxy) FUNCTION(grub_console_getxy)
pushl %ebp pushl %ebp
pushl %ebx /* save EBX */ pushl %ebx /* save EBX */
@ -1344,7 +1344,7 @@ FUNCTION(pupa_console_getxy)
/* /*
* void pupa_console_gotoxy(pupa_uint8_t x, pupa_uint8_t y) * void grub_console_gotoxy(grub_uint8_t x, grub_uint8_t y)
* BIOS call "INT 10H Function 02h" to set cursor position * BIOS call "INT 10H Function 02h" to set cursor position
* Call with %ah = 0x02 * Call with %ah = 0x02
* %bh = page * %bh = page
@ -1353,7 +1353,7 @@ FUNCTION(pupa_console_getxy)
*/ */
FUNCTION(pupa_console_gotoxy) FUNCTION(grub_console_gotoxy)
pushl %ebp pushl %ebp
pushl %ebx /* save EBX */ pushl %ebx /* save EBX */
@ -1376,7 +1376,7 @@ FUNCTION(pupa_console_gotoxy)
/* /*
* void pupa_console_cls (void) * void grub_console_cls (void)
* BIOS call "INT 10H Function 09h" to write character and attribute * BIOS call "INT 10H Function 09h" to write character and attribute
* Call with %ah = 0x09 * Call with %ah = 0x09
* %al = (character) * %al = (character)
@ -1385,7 +1385,7 @@ FUNCTION(pupa_console_gotoxy)
* %cx = (number of times) * %cx = (number of times)
*/ */
FUNCTION(pupa_console_cls) FUNCTION(grub_console_cls)
pushl %ebp pushl %ebp
pushl %ebx /* save EBX */ pushl %ebx /* save EBX */
@ -1417,7 +1417,7 @@ FUNCTION(pupa_console_cls)
/* /*
* void pupa_console_setcursor (int on) * void grub_console_setcursor (int on)
* BIOS call "INT 10H Function 01h" to set cursor type * BIOS call "INT 10H Function 01h" to set cursor type
* Call with %ah = 0x01 * Call with %ah = 0x01
* %ch = cursor starting scanline * %ch = cursor starting scanline
@ -1429,7 +1429,7 @@ console_cursor_state:
console_cursor_shape: console_cursor_shape:
.word 0 .word 0
FUNCTION(pupa_console_setcursor) FUNCTION(grub_console_setcursor)
pushl %ebp pushl %ebp
pushl %ebx pushl %ebx
@ -1474,7 +1474,7 @@ FUNCTION(pupa_console_setcursor)
ret ret
/* /*
* pupa_getrtsecs() * grub_getrtsecs()
* if a seconds value can be read, read it and return it (BCD), * if a seconds value can be read, read it and return it (BCD),
* otherwise return 0xFF * otherwise return 0xFF
* BIOS call "INT 1AH Function 02H" to check whether a character is pending * BIOS call "INT 1AH Function 02H" to check whether a character is pending
@ -1491,7 +1491,7 @@ FUNCTION(pupa_console_setcursor)
* (this indicates that the clock is updating, or * (this indicates that the clock is updating, or
* that it isn't running) * that it isn't running)
*/ */
FUNCTION(pupa_getrtsecs) FUNCTION(grub_getrtsecs)
pushl %ebp pushl %ebp
call prot_to_real /* enter real mode */ call prot_to_real /* enter real mode */
@ -1515,11 +1515,11 @@ gottime:
/* /*
* pupa_get_rtc() * grub_get_rtc()
* return the real time in ticks, of which there are about * return the real time in ticks, of which there are about
* 18-20 per second * 18-20 per second
*/ */
FUNCTION(pupa_get_rtc) FUNCTION(grub_get_rtc)
pushl %ebp pushl %ebp
call prot_to_real /* enter real mode */ call prot_to_real /* enter real mode */
@ -1540,9 +1540,9 @@ FUNCTION(pupa_get_rtc)
/* /*
* unsigned char pupa_vga_set_mode (unsigned char mode) * unsigned char grub_vga_set_mode (unsigned char mode)
*/ */
FUNCTION(pupa_vga_set_mode) FUNCTION(grub_vga_set_mode)
pushl %ebp pushl %ebp
pushl %ebx pushl %ebx
movl %eax, %ecx movl %eax, %ecx
@ -1570,9 +1570,9 @@ FUNCTION(pupa_vga_set_mode)
/* /*
* unsigned char *pupa_vga_get_font (void) * unsigned char *grub_vga_get_font (void)
*/ */
FUNCTION(pupa_vga_get_font) FUNCTION(grub_vga_get_font)
pushl %ebp pushl %ebp
pushl %ebx pushl %ebx

View file

@ -1,8 +1,8 @@
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc. * Copyright (C) 2002,2003 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -13,51 +13,51 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/loader.h> #include <grub/loader.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/err.h> #include <grub/err.h>
static pupa_err_t (*pupa_loader_boot_func) (void); static grub_err_t (*grub_loader_boot_func) (void);
static pupa_err_t (*pupa_loader_unload_func) (void); static grub_err_t (*grub_loader_unload_func) (void);
static int pupa_loader_loaded; static int grub_loader_loaded;
void void
pupa_loader_set (pupa_err_t (*boot) (void), grub_loader_set (grub_err_t (*boot) (void),
pupa_err_t (*unload) (void)) grub_err_t (*unload) (void))
{ {
if (pupa_loader_loaded && pupa_loader_unload_func) if (grub_loader_loaded && grub_loader_unload_func)
pupa_loader_unload_func (); grub_loader_unload_func ();
pupa_loader_boot_func = boot; grub_loader_boot_func = boot;
pupa_loader_unload_func = unload; grub_loader_unload_func = unload;
pupa_loader_loaded = 1; grub_loader_loaded = 1;
} }
void void
pupa_loader_unset(void) grub_loader_unset(void)
{ {
if (pupa_loader_loaded && pupa_loader_unload_func) if (grub_loader_loaded && grub_loader_unload_func)
pupa_loader_unload_func (); grub_loader_unload_func ();
pupa_loader_boot_func = 0; grub_loader_boot_func = 0;
pupa_loader_unload_func = 0; grub_loader_unload_func = 0;
pupa_loader_loaded = 0; grub_loader_loaded = 0;
} }
pupa_err_t grub_err_t
pupa_loader_boot (void) grub_loader_boot (void)
{ {
if (! pupa_loader_loaded) if (! grub_loader_loaded)
return pupa_error (PUPA_ERR_NO_KERNEL, "no loaded kernel"); return grub_error (GRUB_ERR_NO_KERNEL, "no loaded kernel");
return (pupa_loader_boot_func) (); return (grub_loader_boot_func) ();
} }

View file

@ -1,6 +1,6 @@
/* main.c - the kernel main routine */ /* main.c - the kernel main routine */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2003 Free Software Foundation, Inc. * Copyright (C) 2002, 2003 Free Software Foundation, Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,104 +18,104 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/kernel.h> #include <grub/kernel.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/symbol.h> #include <grub/symbol.h>
#include <pupa/dl.h> #include <grub/dl.h>
#include <pupa/term.h> #include <grub/term.h>
#include <pupa/rescue.h> #include <grub/rescue.h>
#include <pupa/file.h> #include <grub/file.h>
#include <pupa/device.h> #include <grub/device.h>
#include <pupa/env.h> #include <grub/env.h>
/* Return the end of the core image. */ /* Return the end of the core image. */
pupa_addr_t grub_addr_t
pupa_get_end_addr (void) grub_get_end_addr (void)
{ {
return pupa_total_module_size + pupa_end_addr; return grub_total_module_size + grub_end_addr;
} }
/* Load all modules in core. */ /* Load all modules in core. */
static void static void
pupa_load_modules (void) grub_load_modules (void)
{ {
struct pupa_module_header *header; struct grub_module_header *header;
for (header = (struct pupa_module_header *) pupa_end_addr; for (header = (struct grub_module_header *) grub_end_addr;
header < (struct pupa_module_header *) pupa_get_end_addr (); header < (struct grub_module_header *) grub_get_end_addr ();
header = (struct pupa_module_header *) ((char *) header + header->size)) header = (struct grub_module_header *) ((char *) header + header->size))
{ {
if (! pupa_dl_load_core ((char *) header + header->offset, if (! grub_dl_load_core ((char *) header + header->offset,
(header->size - header->offset))) (header->size - header->offset)))
pupa_fatal ("%s", pupa_errmsg); grub_fatal ("%s", grub_errmsg);
} }
} }
/* Add the region where modules reside into dynamic memory. */ /* Add the region where modules reside into dynamic memory. */
static void static void
pupa_add_unused_region (void) grub_add_unused_region (void)
{ {
if (pupa_total_module_size) if (grub_total_module_size)
pupa_mm_init_region ((void *) pupa_end_addr, pupa_total_module_size); grub_mm_init_region ((void *) grub_end_addr, grub_total_module_size);
} }
/* Set the root device according to the dl prefix. */ /* Set the root device according to the dl prefix. */
static void static void
pupa_set_root_dev (void) grub_set_root_dev (void)
{ {
const char *prefix; const char *prefix;
prefix = pupa_env_get ("prefix"); prefix = grub_env_get ("prefix");
if (prefix) if (prefix)
{ {
char *dev; char *dev;
dev = pupa_file_get_device_name (prefix); dev = grub_file_get_device_name (prefix);
if (dev) if (dev)
{ {
pupa_device_set_root (dev); grub_device_set_root (dev);
pupa_free (dev); grub_free (dev);
} }
} }
} }
/* Load the normal mode module and execute the normal mode if possible. */ /* Load the normal mode module and execute the normal mode if possible. */
static void static void
pupa_load_normal_mode (void) grub_load_normal_mode (void)
{ {
/* Load the module. */ /* Load the module. */
pupa_dl_load ("normal"); grub_dl_load ("normal");
/* Ignore any error, because we have the rescue mode anyway. */ /* Ignore any error, because we have the rescue mode anyway. */
pupa_errno = PUPA_ERR_NONE; grub_errno = GRUB_ERR_NONE;
} }
/* The main routine. */ /* The main routine. */
void void
pupa_main (void) grub_main (void)
{ {
/* First of all, initialize the machine. */ /* First of all, initialize the machine. */
pupa_machine_init (); grub_machine_init ();
/* Hello. */ /* Hello. */
pupa_setcolorstate (PUPA_TERM_COLOR_HIGHLIGHT); grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
pupa_printf ("Welcome to PUPA!\n\n"); grub_printf ("Welcome to GRUB!\n\n");
pupa_setcolorstate (PUPA_TERM_COLOR_STANDARD); grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
/* It is better to set the root device as soon as possible, /* It is better to set the root device as soon as possible,
for convenience. */ for convenience. */
pupa_set_root_dev (); grub_set_root_dev ();
/* Load pre-loaded modules and free the space. */ /* Load pre-loaded modules and free the space. */
pupa_register_exported_symbols (); grub_register_exported_symbols ();
pupa_load_modules (); grub_load_modules ();
pupa_add_unused_region (); grub_add_unused_region ();
/* Load the normal mode module. */ /* Load the normal mode module. */
pupa_load_normal_mode (); grub_load_normal_mode ();
/* Enter the rescue mode. */ /* Enter the rescue mode. */
pupa_enter_rescue_mode (); grub_enter_rescue_mode ();
} }

View file

@ -1,9 +1,9 @@
/* misc.c - definitions of misc functions */ /* misc.c - definitions of misc functions */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,19 +14,19 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <stdarg.h> #include <stdarg.h>
#include <pupa/term.h> #include <grub/term.h>
#include <pupa/env.h> #include <grub/env.h>
void * void *
pupa_memmove (void *dest, const void *src, pupa_size_t n) grub_memmove (void *dest, const void *src, grub_size_t n)
{ {
char *d = (char *) dest; char *d = (char *) dest;
const char *s = (const char *) src; const char *s = (const char *) src;
@ -46,11 +46,11 @@ pupa_memmove (void *dest, const void *src, pupa_size_t n)
return dest; return dest;
} }
/* GCC emits references to memcpy() for struct copies etc. */ /* GCC emits references to memcpy() for struct copies etc. */
void *memcpy (void *dest, const void *src, pupa_size_t n) void *memcpy (void *dest, const void *src, grub_size_t n)
__attribute__ ((alias ("pupa_memmove"))); __attribute__ ((alias ("grub_memmove")));
char * char *
pupa_strcpy (char *dest, const char *src) grub_strcpy (char *dest, const char *src)
{ {
char *p = dest; char *p = dest;
@ -61,7 +61,7 @@ pupa_strcpy (char *dest, const char *src)
} }
char * char *
pupa_strncpy (char *dest, const char *src, int c) grub_strncpy (char *dest, const char *src, int c)
{ {
char *p = dest; char *p = dest;
int pos = 0; int pos = 0;
@ -73,7 +73,7 @@ pupa_strncpy (char *dest, const char *src, int c)
} }
char * char *
pupa_stpcpy (char *dest, const char *src) grub_stpcpy (char *dest, const char *src)
{ {
char *d = dest; char *d = dest;
const char *s = src; const char *s = src;
@ -86,7 +86,7 @@ pupa_stpcpy (char *dest, const char *src)
} }
char * char *
pupa_strcat (char *dest, const char *src) grub_strcat (char *dest, const char *src)
{ {
char *p = dest; char *p = dest;
@ -100,26 +100,26 @@ pupa_strcat (char *dest, const char *src)
} }
int int
pupa_printf (const char *fmt, ...) grub_printf (const char *fmt, ...)
{ {
va_list ap; va_list ap;
int ret; int ret;
va_start (ap, fmt); va_start (ap, fmt);
ret = pupa_vprintf (fmt, ap); ret = grub_vprintf (fmt, ap);
va_end (ap); va_end (ap);
return ret; return ret;
} }
int int
pupa_vprintf (const char *fmt, va_list args) grub_vprintf (const char *fmt, va_list args)
{ {
return pupa_vsprintf (0, fmt, args); return grub_vsprintf (0, fmt, args);
} }
int int
pupa_memcmp (const void *s1, const void *s2, pupa_size_t n) grub_memcmp (const void *s1, const void *s2, grub_size_t n)
{ {
const char *t1 = s1; const char *t1 = s1;
const char *t2 = s2; const char *t2 = s2;
@ -137,7 +137,7 @@ pupa_memcmp (const void *s1, const void *s2, pupa_size_t n)
} }
int int
pupa_strcmp (const char *s1, const char *s2) grub_strcmp (const char *s1, const char *s2)
{ {
while (*s1 && *s2) while (*s1 && *s2)
{ {
@ -152,7 +152,7 @@ pupa_strcmp (const char *s1, const char *s2)
} }
int int
pupa_strncmp (const char *s1, const char *s2, int c) grub_strncmp (const char *s1, const char *s2, int c)
{ {
int p = 1; int p = 1;
@ -170,7 +170,7 @@ pupa_strncmp (const char *s1, const char *s2, int c)
} }
char * char *
pupa_strchr (const char *s, int c) grub_strchr (const char *s, int c)
{ {
while (*s) while (*s)
{ {
@ -183,7 +183,7 @@ pupa_strchr (const char *s, int c)
} }
char * char *
pupa_strrchr (const char *s, int c) grub_strrchr (const char *s, int c)
{ {
char *p = 0; char *p = 0;
@ -198,37 +198,37 @@ pupa_strrchr (const char *s, int c)
} }
int int
pupa_isspace (int c) grub_isspace (int c)
{ {
return (c == '\n' || c == '\r' || c == ' ' || c == '\t'); return (c == '\n' || c == '\r' || c == ' ' || c == '\t');
} }
int int
pupa_isprint (int c) grub_isprint (int c)
{ {
return (c >= ' ' && c <= '~'); return (c >= ' ' && c <= '~');
} }
int int
pupa_isalpha (int c) grub_isalpha (int c)
{ {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
} }
int int
pupa_isdigit (int c) grub_isdigit (int c)
{ {
return (c >= '0' && c <= '9'); return (c >= '0' && c <= '9');
} }
int int
pupa_isgraph (int c) grub_isgraph (int c)
{ {
return (c >= '!' && c <= '~'); return (c >= '!' && c <= '~');
} }
int int
pupa_tolower (int c) grub_tolower (int c)
{ {
if (c >= 'A' && c <= 'Z') if (c >= 'A' && c <= 'Z')
return c - 'A' + 'a'; return c - 'A' + 'a';
@ -237,13 +237,13 @@ pupa_tolower (int c)
} }
unsigned long unsigned long
pupa_strtoul (const char *str, char **end, int base) grub_strtoul (const char *str, char **end, int base)
{ {
unsigned long num = 0; unsigned long num = 0;
int found = 0; int found = 0;
/* Skip white spaces. */ /* Skip white spaces. */
while (*str && pupa_isspace (*str)) while (*str && grub_isspace (*str))
str++; str++;
/* Guess the base, if not specified. The prefix `0x' means 16, and /* Guess the base, if not specified. The prefix `0x' means 16, and
@ -269,7 +269,7 @@ pupa_strtoul (const char *str, char **end, int base)
{ {
unsigned long digit; unsigned long digit;
digit = pupa_tolower (*str) - '0'; digit = grub_tolower (*str) - '0';
if (digit > 9) if (digit > 9)
{ {
digit += '0' - 'a' + 10; digit += '0' - 'a' + 10;
@ -281,7 +281,7 @@ pupa_strtoul (const char *str, char **end, int base)
if (num > (~0UL - digit) / base) if (num > (~0UL - digit) / base)
{ {
pupa_error (PUPA_ERR_OUT_OF_RANGE, "overflow is detected"); grub_error (GRUB_ERR_OUT_OF_RANGE, "overflow is detected");
return 0; return 0;
} }
@ -291,7 +291,7 @@ pupa_strtoul (const char *str, char **end, int base)
if (! found) if (! found)
{ {
pupa_error (PUPA_ERR_BAD_NUMBER, "unrecognized number"); grub_error (GRUB_ERR_BAD_NUMBER, "unrecognized number");
return 0; return 0;
} }
@ -302,38 +302,38 @@ pupa_strtoul (const char *str, char **end, int base)
} }
char * char *
pupa_strdup (const char *s) grub_strdup (const char *s)
{ {
pupa_size_t len; grub_size_t len;
char *p; char *p;
len = pupa_strlen (s) + 1; len = grub_strlen (s) + 1;
p = (char *) pupa_malloc (len); p = (char *) grub_malloc (len);
if (! p) if (! p)
return 0; return 0;
return pupa_memcpy (p, s, len); return grub_memcpy (p, s, len);
} }
char * char *
pupa_strndup (const char *s, pupa_size_t n) grub_strndup (const char *s, grub_size_t n)
{ {
pupa_size_t len = 0; grub_size_t len = 0;
char *p = (char *) s; char *p = (char *) s;
while (*(p++) && len < n) while (*(p++) && len < n)
len++; len++;
len = pupa_strlen (s) + 1; len = grub_strlen (s) + 1;
p = (char *) pupa_malloc (len); p = (char *) grub_malloc (len);
if (! p) if (! p)
return 0; return 0;
return pupa_memcpy (p, s, len); return grub_memcpy (p, s, len);
} }
void * void *
pupa_memset (void *s, int c, pupa_size_t n) grub_memset (void *s, int c, grub_size_t n)
{ {
unsigned char *p = (unsigned char *) s; unsigned char *p = (unsigned char *) s;
@ -343,8 +343,8 @@ pupa_memset (void *s, int c, pupa_size_t n)
return s; return s;
} }
pupa_size_t grub_size_t
pupa_strlen (const char *s) grub_strlen (const char *s)
{ {
const char *p = s; const char *p = s;
@ -355,9 +355,9 @@ pupa_strlen (const char *s)
} }
static inline void static inline void
pupa_reverse (char *str) grub_reverse (char *str)
{ {
char *p = str + pupa_strlen (str) - 1; char *p = str + grub_strlen (str) - 1;
while (str < p) while (str < p)
{ {
@ -372,7 +372,7 @@ pupa_reverse (char *str)
} }
static char * static char *
pupa_itoa (char *str, int c, unsigned n) grub_itoa (char *str, int c, unsigned n)
{ {
unsigned base = (c == 'x') ? 16 : 10; unsigned base = (c == 'x') ? 16 : 10;
char *p; char *p;
@ -392,12 +392,12 @@ pupa_itoa (char *str, int c, unsigned n)
while (n /= base); while (n /= base);
*p = 0; *p = 0;
pupa_reverse (str); grub_reverse (str);
return p; return p;
} }
static char * static char *
pupa_ftoa (char *str, double f, int round) grub_ftoa (char *str, double f, int round)
{ {
unsigned int intp; unsigned int intp;
unsigned int fractp; unsigned int fractp;
@ -410,12 +410,12 @@ pupa_ftoa (char *str, double f, int round)
intp = f; intp = f;
fractp = (f - (float) intp) * power; fractp = (f - (float) intp) * power;
pupa_sprintf (str, "%d.%d", intp, fractp); grub_sprintf (str, "%d.%d", intp, fractp);
return str; return str;
} }
int int
pupa_vsprintf (char *str, const char *fmt, va_list args) grub_vsprintf (char *str, const char *fmt, va_list args)
{ {
char c; char c;
int count = 0; int count = 0;
@ -428,7 +428,7 @@ pupa_vsprintf (char *str, const char *fmt, va_list args)
if (str) if (str)
*str++ = ch; *str++ = ch;
else else
pupa_putchar (ch); grub_putchar (ch);
count++; count++;
} }
@ -468,29 +468,29 @@ pupa_vsprintf (char *str, const char *fmt, va_list args)
p = (char *) fmt; p = (char *) fmt;
/* Read formatting parameters. */ /* Read formatting parameters. */
while (*p && pupa_isdigit (*p)) while (*p && grub_isdigit (*p))
p++; p++;
if (p > fmt) if (p > fmt)
{ {
char s[p - fmt]; char s[p - fmt];
pupa_strncpy (s, fmt, p - fmt); grub_strncpy (s, fmt, p - fmt);
if (s[0] == '0') if (s[0] == '0')
zerofill = '0'; zerofill = '0';
format1 = pupa_strtoul (s, 0, 10); format1 = grub_strtoul (s, 0, 10);
fmt = p; fmt = p;
if (*p && *p == '.') if (*p && *p == '.')
{ {
p++; p++;
fmt++; fmt++;
while (*p && pupa_isdigit (*p)) while (*p && grub_isdigit (*p))
p++; p++;
if (p > fmt) if (p > fmt)
{ {
char fstr[p - fmt]; char fstr[p - fmt];
pupa_strncpy (fstr, fmt, p - fmt); grub_strncpy (fstr, fmt, p - fmt);
format2 = pupa_strtoul (fstr, 0, 10); format2 = grub_strtoul (fstr, 0, 10);
fmt = p; fmt = p;
} }
} }
@ -508,12 +508,12 @@ pupa_vsprintf (char *str, const char *fmt, va_list args)
case 'u': case 'u':
case 'd': case 'd':
n = va_arg (args, int); n = va_arg (args, int);
pupa_itoa (tmp, c, n); grub_itoa (tmp, c, n);
if (!rightfill && pupa_strlen (tmp) < format1) if (!rightfill && grub_strlen (tmp) < format1)
write_fill (zerofill, format1 - pupa_strlen (tmp)); write_fill (zerofill, format1 - grub_strlen (tmp));
write_str (tmp); write_str (tmp);
if (rightfill && pupa_strlen (tmp) < format1) if (rightfill && grub_strlen (tmp) < format1)
write_fill (zerofill, format1 - pupa_strlen (tmp)); write_fill (zerofill, format1 - grub_strlen (tmp));
break; break;
case 'c': case 'c':
@ -525,18 +525,18 @@ pupa_vsprintf (char *str, const char *fmt, va_list args)
{ {
float f; float f;
f = va_arg (args, double); f = va_arg (args, double);
pupa_ftoa (tmp, f, format2); grub_ftoa (tmp, f, format2);
if (!rightfill && pupa_strlen (tmp) < format1) if (!rightfill && grub_strlen (tmp) < format1)
write_fill (zerofill, format1 - pupa_strlen (tmp)); write_fill (zerofill, format1 - grub_strlen (tmp));
write_str (tmp); write_str (tmp);
if (rightfill && pupa_strlen (tmp) < format1) if (rightfill && grub_strlen (tmp) < format1)
write_fill (zerofill, format1 - pupa_strlen (tmp)); write_fill (zerofill, format1 - grub_strlen (tmp));
break; break;
} }
case 'C': case 'C':
{ {
pupa_uint32_t code = va_arg (args, pupa_uint32_t); grub_uint32_t code = va_arg (args, grub_uint32_t);
int shift; int shift;
unsigned mask; unsigned mask;
@ -588,13 +588,13 @@ pupa_vsprintf (char *str, const char *fmt, va_list args)
p = va_arg (args, char *); p = va_arg (args, char *);
if (p) if (p)
{ {
if (!rightfill && pupa_strlen (p) < format1) if (!rightfill && grub_strlen (p) < format1)
write_fill (zerofill, format1 - pupa_strlen (p)); write_fill (zerofill, format1 - grub_strlen (p));
write_str (p); write_str (p);
if (rightfill && pupa_strlen (p) < format1) if (rightfill && grub_strlen (p) < format1)
write_fill (zerofill, format1 - pupa_strlen (p)); write_fill (zerofill, format1 - grub_strlen (p));
} }
else else
write_str ("(null)"); write_str ("(null)");
@ -612,26 +612,26 @@ pupa_vsprintf (char *str, const char *fmt, va_list args)
*str = '\0'; *str = '\0';
if (count && !str) if (count && !str)
pupa_refresh (); grub_refresh ();
return count; return count;
} }
int int
pupa_sprintf (char *str, const char *fmt, ...) grub_sprintf (char *str, const char *fmt, ...)
{ {
va_list ap; va_list ap;
int ret; int ret;
va_start (ap, fmt); va_start (ap, fmt);
ret = pupa_vsprintf (str, fmt, ap); ret = grub_vsprintf (str, fmt, ap);
va_end (ap); va_end (ap);
return ret; return ret;
} }
pupa_err_t grub_err_t
pupa_split_cmdline (const char *cmdline, pupa_err_t (* getline) (char **), int *argc, char ***argv) grub_split_cmdline (const char *cmdline, grub_err_t (* getline) (char **), int *argc, char ***argv)
{ {
/* XXX: Fixed size buffer, perhaps this buffer should be dynamically /* XXX: Fixed size buffer, perhaps this buffer should be dynamically
allocated. */ allocated. */
@ -651,7 +651,7 @@ pupa_split_cmdline (const char *cmdline, pupa_err_t (* getline) (char **), int *
/* Get one character from the commandline. If the caller reads /* Get one character from the commandline. If the caller reads
beyond the end of the string a new line will be read. This beyond the end of the string a new line will be read. This
function will not chech for errors, the caller has to check for function will not chech for errors, the caller has to check for
pupa_errno. */ grub_errno. */
char getchar (void) char getchar (void)
{ {
int c; int c;
@ -703,7 +703,7 @@ pupa_split_cmdline (const char *cmdline, pupa_err_t (* getline) (char **), int *
{ {
/* XXX: An env. variable can have characters and digits in /* XXX: An env. variable can have characters and digits in
its name, are more characters allowed here? */ its name, are more characters allowed here? */
while (c && (pupa_isalpha (c) || pupa_isdigit (c))) while (c && (grub_isalpha (c) || grub_isdigit (c)))
{ {
*(p++) = c; *(p++) = c;
c = getchar (); c = getchar ();
@ -713,7 +713,7 @@ pupa_split_cmdline (const char *cmdline, pupa_err_t (* getline) (char **), int *
*p = '\0'; *p = '\0';
/* The variable does not exist. */ /* The variable does not exist. */
val = pupa_env_get (varname); val = grub_env_get (varname);
if (! val) if (! val)
return; return;
@ -724,7 +724,7 @@ pupa_split_cmdline (const char *cmdline, pupa_err_t (* getline) (char **), int *
/* Read one argument. Return 1 if no variables can be read anymore, /* Read one argument. Return 1 if no variables can be read anymore,
otherwise return 0. If there is an error, return 1, the caller otherwise return 0. If there is an error, return 1, the caller
has to check pupa_errno. */ has to check grub_errno. */
int getarg (void) int getarg (void)
{ {
char c; char c;
@ -741,7 +741,7 @@ pupa_split_cmdline (const char *cmdline, pupa_err_t (* getline) (char **), int *
/* Double quote. */ /* Double quote. */
while ((c = getchar ())) while ((c = getchar ()))
{ {
if (pupa_errno) if (grub_errno)
return 1; return 1;
/* Read in an escaped character. */ /* Read in an escaped character. */
if (c == '\\') if (c == '\\')
@ -766,7 +766,7 @@ pupa_split_cmdline (const char *cmdline, pupa_err_t (* getline) (char **), int *
/* Single quote. */ /* Single quote. */
while ((c = getchar ()) != '\'') while ((c = getchar ()) != '\'')
{ {
if (pupa_errno) if (grub_errno)
return 1; return 1;
*(bp++) = c; *(bp++) = c;
@ -779,8 +779,8 @@ pupa_split_cmdline (const char *cmdline, pupa_err_t (* getline) (char **), int *
default: default:
/* A normal option. */ /* A normal option. */
while (c && (pupa_isalpha (c) while (c && (grub_isalpha (c)
|| pupa_isdigit (c) || pupa_isgraph (c))) || grub_isdigit (c) || grub_isgraph (c)))
{ {
/* Read in an escaped character. */ /* Read in an escaped character. */
if (c == '\\') if (c == '\\')
@ -804,7 +804,7 @@ pupa_split_cmdline (const char *cmdline, pupa_err_t (* getline) (char **), int *
break; break;
} }
} while (! pupa_isspace (c) && c != '\'' && c != '"'); } while (! grub_isspace (c) && c != '\'' && c != '"');
return 0; return 0;
} }
@ -820,20 +820,20 @@ pupa_split_cmdline (const char *cmdline, pupa_err_t (* getline) (char **), int *
} }
/* Check if there were no errors. */ /* Check if there were no errors. */
if (pupa_errno) if (grub_errno)
return pupa_errno; return grub_errno;
/* Reserve memory for the return values. */ /* Reserve memory for the return values. */
args = pupa_malloc (bp - buffer); args = grub_malloc (bp - buffer);
if (! args) if (! args)
return pupa_errno; return grub_errno;
pupa_memcpy (args, buffer, bp - buffer); grub_memcpy (args, buffer, bp - buffer);
*argv = pupa_malloc (sizeof (char *) * (*argc + 1)); *argv = grub_malloc (sizeof (char *) * (*argc + 1));
if (! *argv) if (! *argv)
{ {
pupa_free (args); grub_free (args);
return pupa_errno; return grub_errno;
} }
/* The arguments are separated with 0's, setup argv so it points to /* The arguments are separated with 0's, setup argv so it points to

210
kern/mm.c
View file

@ -1,9 +1,9 @@
/* mm.c - functions for memory manager */ /* mm.c - functions for memory manager */
/* /*
* PUPA -- Preliminary Universal Programming Architecture for GRUB * GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc. * Copyright (C) 2002 Free Software Foundation, Inc.
* *
* PUPA is free software; you can redistribute it and/or modify * GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -14,66 +14,66 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PUPA; if not, write to the Free Software * along with GRUB; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <config.h> #include <config.h>
#include <pupa/mm.h> #include <grub/mm.h>
#include <pupa/misc.h> #include <grub/misc.h>
#include <pupa/err.h> #include <grub/err.h>
#include <pupa/types.h> #include <grub/types.h>
#include <pupa/disk.h> #include <grub/disk.h>
#include <pupa/dl.h> #include <grub/dl.h>
/* Magic words. */ /* Magic words. */
#define PUPA_MM_FREE_MAGIC 0x2d3c2808 #define GRUB_MM_FREE_MAGIC 0x2d3c2808
#define PUPA_MM_ALLOC_MAGIC 0x6db08fa4 #define GRUB_MM_ALLOC_MAGIC 0x6db08fa4
typedef struct pupa_mm_header typedef struct grub_mm_header
{ {
struct pupa_mm_header *next; struct grub_mm_header *next;
pupa_size_t size; grub_size_t size;
pupa_size_t magic; grub_size_t magic;
#if PUPA_CPU_SIZEOF_VOID_P == 4 #if GRUB_CPU_SIZEOF_VOID_P == 4
char padding[4]; char padding[4];
#elif PUPA_CPU_SIZEOF_VOID_P == 8 #elif GRUB_CPU_SIZEOF_VOID_P == 8
char padding[8]; char padding[8];
#else #else
# error "unknown word size" # error "unknown word size"
#endif #endif
} }
*pupa_mm_header_t; *grub_mm_header_t;
#if PUPA_CPU_SIZEOF_VOID_P == 4 #if GRUB_CPU_SIZEOF_VOID_P == 4
# define PUPA_MM_ALIGN_LOG2 4 # define GRUB_MM_ALIGN_LOG2 4
#elif PUPA_CPU_SIZEOF_VOID_P == 8 #elif GRUB_CPU_SIZEOF_VOID_P == 8
# define PUPA_MM_ALIGN_LOG2 8 # define GRUB_MM_ALIGN_LOG2 8
#endif #endif
#define PUPA_MM_ALIGN (1 << PUPA_MM_ALIGN_LOG2) #define GRUB_MM_ALIGN (1 << GRUB_MM_ALIGN_LOG2)
typedef struct pupa_mm_region typedef struct grub_mm_region
{ {
struct pupa_mm_header *first; struct grub_mm_header *first;
struct pupa_mm_region *next; struct grub_mm_region *next;
pupa_addr_t addr; grub_addr_t addr;
pupa_size_t size; grub_size_t size;
} }
*pupa_mm_region_t; *grub_mm_region_t;
static pupa_mm_region_t base; static grub_mm_region_t base;
/* Get a header from the pointer PTR, and set *P and *R to a pointer /* Get a header from the pointer PTR, and set *P and *R to a pointer
to the header and a pointer to its region, respectively. PTR must to the header and a pointer to its region, respectively. PTR must
be allocated. */ be allocated. */
static void static void
get_header_from_pointer (void *ptr, pupa_mm_header_t *p, pupa_mm_region_t *r) get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r)
{ {
if ((unsigned) ptr & (PUPA_MM_ALIGN - 1)) if ((unsigned) ptr & (GRUB_MM_ALIGN - 1))
pupa_fatal ("unaligned pointer %p", ptr); grub_fatal ("unaligned pointer %p", ptr);
for (*r = base; *r; *r = (*r)->next) for (*r = base; *r; *r = (*r)->next)
if ((unsigned) ptr > (*r)->addr if ((unsigned) ptr > (*r)->addr
@ -81,42 +81,42 @@ get_header_from_pointer (void *ptr, pupa_mm_header_t *p, pupa_mm_region_t *r)
break; break;
if (! *r) if (! *r)
pupa_fatal ("out of range pointer %p", ptr); grub_fatal ("out of range pointer %p", ptr);
*p = (pupa_mm_header_t) ptr - 1; *p = (grub_mm_header_t) ptr - 1;
if ((*p)->magic != PUPA_MM_ALLOC_MAGIC) if ((*p)->magic != GRUB_MM_ALLOC_MAGIC)
pupa_fatal ("alloc magic is broken at %p", *p); grub_fatal ("alloc magic is broken at %p", *p);
} }
/* Initialize a region starting from ADDR and whose size is SIZE, /* Initialize a region starting from ADDR and whose size is SIZE,
to use it as free space. */ to use it as free space. */
void void
pupa_mm_init_region (void *addr, pupa_size_t size) grub_mm_init_region (void *addr, grub_size_t size)
{ {
pupa_mm_header_t h; grub_mm_header_t h;
pupa_mm_region_t r, *p, q; grub_mm_region_t r, *p, q;
#if 0 #if 0
pupa_printf ("%s:%d: addr=%p, size=%u\n", __FILE__, __LINE__, addr, size); grub_printf ("%s:%d: addr=%p, size=%u\n", __FILE__, __LINE__, addr, size);
#endif #endif
/* If this region is too small, ignore it. */ /* If this region is too small, ignore it. */
if (size < PUPA_MM_ALIGN * 2) if (size < GRUB_MM_ALIGN * 2)
return; return;
/* Allocate a region from the head. */ /* Allocate a region from the head. */
r = (pupa_mm_region_t) (((pupa_addr_t) addr + PUPA_MM_ALIGN - 1) r = (grub_mm_region_t) (((grub_addr_t) addr + GRUB_MM_ALIGN - 1)
& (~(PUPA_MM_ALIGN - 1))); & (~(GRUB_MM_ALIGN - 1)));
size -= (char *) r - (char *) addr + sizeof (*r); size -= (char *) r - (char *) addr + sizeof (*r);
h = (pupa_mm_header_t) ((char *) r + PUPA_MM_ALIGN); h = (grub_mm_header_t) ((char *) r + GRUB_MM_ALIGN);
h->next = h; h->next = h;
h->magic = PUPA_MM_FREE_MAGIC; h->magic = GRUB_MM_FREE_MAGIC;
h->size = (size >> PUPA_MM_ALIGN_LOG2); h->size = (size >> GRUB_MM_ALIGN_LOG2);
r->first = h; r->first = h;
r->addr = (pupa_addr_t) h; r->addr = (grub_addr_t) h;
r->size = (h->size << PUPA_MM_ALIGN_LOG2); r->size = (h->size << GRUB_MM_ALIGN_LOG2);
/* Find where to insert this region. Put a smaller one before bigger ones, /* Find where to insert this region. Put a smaller one before bigger ones,
to prevent fragmentations. */ to prevent fragmentations. */
@ -132,47 +132,47 @@ pupa_mm_init_region (void *addr, pupa_size_t size)
buffer starting from *FIRST. ALIGN must be a power of two. Return a buffer starting from *FIRST. ALIGN must be a power of two. Return a
non-NULL if successful, otherwise return NULL. */ non-NULL if successful, otherwise return NULL. */
static void * static void *
pupa_real_malloc (pupa_mm_header_t *first, pupa_size_t n, pupa_size_t align) grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
{ {
pupa_mm_header_t p, q; grub_mm_header_t p, q;
if ((*first)->magic == PUPA_MM_ALLOC_MAGIC) if ((*first)->magic == GRUB_MM_ALLOC_MAGIC)
return 0; return 0;
for (q = *first, p = q->next; ; q = p, p = p->next) for (q = *first, p = q->next; ; q = p, p = p->next)
{ {
pupa_off_t extra; grub_off_t extra;
extra = ((pupa_addr_t) (p + 1) >> PUPA_MM_ALIGN_LOG2) % align; extra = ((grub_addr_t) (p + 1) >> GRUB_MM_ALIGN_LOG2) % align;
if (extra) if (extra)
extra = align - extra; extra = align - extra;
if (! p) if (! p)
pupa_fatal ("null in the ring"); grub_fatal ("null in the ring");
if (p->magic != PUPA_MM_FREE_MAGIC) if (p->magic != GRUB_MM_FREE_MAGIC)
pupa_fatal ("free magic is broken at %p: 0x%x", p, p->magic); grub_fatal ("free magic is broken at %p: 0x%x", p, p->magic);
if (p->size >= n + extra) if (p->size >= n + extra)
{ {
if (extra == 0 && p->size == n) if (extra == 0 && p->size == n)
{ {
q->next = p->next; q->next = p->next;
p->magic = PUPA_MM_ALLOC_MAGIC; p->magic = GRUB_MM_ALLOC_MAGIC;
} }
else if (extra == 0 || p->size == n + extra) else if (extra == 0 || p->size == n + extra)
{ {
p->size -= n; p->size -= n;
p += p->size; p += p->size;
p->size = n; p->size = n;
p->magic = PUPA_MM_ALLOC_MAGIC; p->magic = GRUB_MM_ALLOC_MAGIC;
} }
else else
{ {
pupa_mm_header_t r; grub_mm_header_t r;
r = p + extra + n; r = p + extra + n;
r->magic = PUPA_MM_FREE_MAGIC; r->magic = GRUB_MM_FREE_MAGIC;
r->size = p->size - extra - n; r->size = p->size - extra - n;
r->next = p->next; r->next = p->next;
@ -180,7 +180,7 @@ pupa_real_malloc (pupa_mm_header_t *first, pupa_size_t n, pupa_size_t align)
p->next = r; p->next = r;
p += extra; p += extra;
p->size = n; p->size = n;
p->magic = PUPA_MM_ALLOC_MAGIC; p->magic = GRUB_MM_ALLOC_MAGIC;
} }
*first = q; *first = q;
@ -197,13 +197,13 @@ pupa_real_malloc (pupa_mm_header_t *first, pupa_size_t n, pupa_size_t align)
/* Allocate SIZE bytes with the alignment ALIGN and return the pointer. */ /* Allocate SIZE bytes with the alignment ALIGN and return the pointer. */
void * void *
pupa_memalign (pupa_size_t align, pupa_size_t size) grub_memalign (grub_size_t align, grub_size_t size)
{ {
pupa_mm_region_t r; grub_mm_region_t r;
pupa_size_t n = ((size + PUPA_MM_ALIGN - 1) >> PUPA_MM_ALIGN_LOG2) + 1; grub_size_t n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
int count = 0; int count = 0;
align = (align >> PUPA_MM_ALIGN_LOG2); align = (align >> GRUB_MM_ALIGN_LOG2);
if (align == 0) if (align == 0)
align = 1; align = 1;
@ -213,7 +213,7 @@ pupa_memalign (pupa_size_t align, pupa_size_t size)
{ {
void *p; void *p;
p = pupa_real_malloc (&(r->first), n, align); p = grub_real_malloc (&(r->first), n, align);
if (p) if (p)
return p; return p;
} }
@ -223,13 +223,13 @@ pupa_memalign (pupa_size_t align, pupa_size_t size)
{ {
case 0: case 0:
/* Invalidate disk caches. */ /* Invalidate disk caches. */
pupa_disk_cache_invalidate_all (); grub_disk_cache_invalidate_all ();
count++; count++;
goto again; goto again;
case 1: case 1:
/* Unload unneeded modules. */ /* Unload unneeded modules. */
pupa_dl_unload_unneeded (); grub_dl_unload_unneeded ();
count++; count++;
goto again; goto again;
@ -237,43 +237,43 @@ pupa_memalign (pupa_size_t align, pupa_size_t size)
break; break;
} }
pupa_error (PUPA_ERR_OUT_OF_MEMORY, "out of memory"); grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
return 0; return 0;
} }
/* Allocate SIZE bytes and return the pointer. */ /* Allocate SIZE bytes and return the pointer. */
void * void *
pupa_malloc (pupa_size_t size) grub_malloc (grub_size_t size)
{ {
return pupa_memalign (0, size); return grub_memalign (0, size);
} }
/* Deallocate the pointer PTR. */ /* Deallocate the pointer PTR. */
void void
pupa_free (void *ptr) grub_free (void *ptr)
{ {
pupa_mm_header_t p; grub_mm_header_t p;
pupa_mm_region_t r; grub_mm_region_t r;
if (! ptr) if (! ptr)
return; return;
get_header_from_pointer (ptr, &p, &r); get_header_from_pointer (ptr, &p, &r);
if (r->first->magic == PUPA_MM_ALLOC_MAGIC) if (r->first->magic == GRUB_MM_ALLOC_MAGIC)
{ {
p->magic = PUPA_MM_FREE_MAGIC; p->magic = GRUB_MM_FREE_MAGIC;
r->first = p->next = p; r->first = p->next = p;
} }
else else
{ {
pupa_mm_header_t q; grub_mm_header_t q;
#if 0 #if 0
q = r->first; q = r->first;
do do
{ {
pupa_printf ("%s:%d: q=%p, q->size=0x%x, q->magic=0x%x\n", grub_printf ("%s:%d: q=%p, q->size=0x%x, q->magic=0x%x\n",
__FILE__, __LINE__, q, q->size, q->magic); __FILE__, __LINE__, q, q->size, q->magic);
q = q->next; q = q->next;
} }
@ -282,14 +282,14 @@ pupa_free (void *ptr)
for (q = r->first; q >= p || q->next <= p; q = q->next) for (q = r->first; q >= p || q->next <= p; q = q->next)
{ {
if (q->magic != PUPA_MM_FREE_MAGIC) if (q->magic != GRUB_MM_FREE_MAGIC)
pupa_fatal ("free magic is broken at %p: 0x%x", q, q->magic); grub_fatal ("free magic is broken at %p: 0x%x", q, q->magic);
if (q >= q->next && (q < p || q->next > p)) if (q >= q->next && (q < p || q->next > p))
break; break;
} }
p->magic = PUPA_MM_FREE_MAGIC; p->magic = GRUB_MM_FREE_MAGIC;
p->next = q->next; p->next = q->next;
q->next = p; q->next = p;
@ -314,67 +314,67 @@ pupa_free (void *ptr)
/* Reallocate SIZE bytes and return the pointer. The contents will be /* Reallocate SIZE bytes and return the pointer. The contents will be
the same as that of PTR. */ the same as that of PTR. */
void * void *
pupa_realloc (void *ptr, pupa_size_t size) grub_realloc (void *ptr, grub_size_t size)
{ {
pupa_mm_header_t p; grub_mm_header_t p;
pupa_mm_region_t r; grub_mm_region_t r;
void *q; void *q;
pupa_size_t n; grub_size_t n;
if (! ptr) if (! ptr)
return pupa_malloc (size); return grub_malloc (size);
if (! size) if (! size)
{ {
pupa_free (ptr); grub_free (ptr);
return 0; return 0;
} }
/* FIXME: Not optimal. */ /* FIXME: Not optimal. */
n = ((size + PUPA_MM_ALIGN - 1) >> PUPA_MM_ALIGN_LOG2) + 1; n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1;
get_header_from_pointer (ptr, &p, &r); get_header_from_pointer (ptr, &p, &r);
if (p->size >= n) if (p->size >= n)
return p; return p;
q = pupa_malloc (size); q = grub_malloc (size);
if (! q) if (! q)
return q; return q;
pupa_memcpy (q, ptr, size); grub_memcpy (q, ptr, size);
pupa_free (ptr); grub_free (ptr);
return q; return q;
} }
#if MM_DEBUG #if MM_DEBUG
void void
pupa_mm_dump (unsigned lineno) grub_mm_dump (unsigned lineno)
{ {
pupa_mm_region_t r; grub_mm_region_t r;
pupa_printf ("called at line %u\n", lineno); grub_printf ("called at line %u\n", lineno);
for (r = base; r; r = r->next) for (r = base; r; r = r->next)
{ {
pupa_mm_header_t p; grub_mm_header_t p;
for (p = (pupa_mm_header_t) ((r->addr + PUPA_MM_ALIGN - 1) for (p = (grub_mm_header_t) ((r->addr + GRUB_MM_ALIGN - 1)
& (~(PUPA_MM_ALIGN - 1))); & (~(GRUB_MM_ALIGN - 1)));
(pupa_addr_t) p < r->addr + r->size; (grub_addr_t) p < r->addr + r->size;
p++) p++)
{ {
switch (p->magic) switch (p->magic)
{ {
case PUPA_MM_FREE_MAGIC: case GRUB_MM_FREE_MAGIC:
pupa_printf ("F:%p:%u:%p\n", grub_printf ("F:%p:%u:%p\n",
p, p->size << PUPA_MM_ALIGN_LOG2, p->next); p, p->size << GRUB_MM_ALIGN_LOG2, p->next);
break; break;
case PUPA_MM_ALLOC_MAGIC: case GRUB_MM_ALLOC_MAGIC:
pupa_printf ("A:%p:%u\n", p, p->size << PUPA_MM_ALIGN_LOG2); grub_printf ("A:%p:%u\n", p, p->size << GRUB_MM_ALIGN_LOG2);
break; break;
} }
} }
} }
pupa_printf ("\n"); grub_printf ("\n");
} }
#endif /* MM_DEBUG */ #endif /* MM_DEBUG */

Some files were not shown because too many files have changed in this diff Show more