2008-04-25 Bean <bean123ch@gmail.com>
* Makefile.in (RMKFILES): Add missing arch i386-ieee1275 and i386-linuxbios. * commands/hexdump.c (grub_cmd_hexdump): Support dumping of device, change the buffer size to 4096 for cdrom device. * conf/i386-ieee1275.rmk (pkglib_MODULES): Add _linux.mod, linux.mod and nand.mod. (_linux_mod_SOURCES): New variable. (_linux_mod_CFLAGS): Likewise. (_linux_mod_LDFLAGS): Likewise. (linux_mod_SOURCES): Likewise. (linux_mod_CFLAGS): Likewise. (linux_mod_LDFLAGS): Likewise. (nand_mod_SOURCES): Likewise. (nand_mod_CFLAGS): Likewise. (nand_mod_LDFLAGS): Likewise. * disk/ieee1275/ofdisk.c (grub_ofdisk_open): Return GRUB_ERR_UNKNOWN_DEVICE instead of GRUB_ERR_BAD_DEVICE if no device type property. (nand device in olpc don't have this property) * include/grub/disk.h (grub_disk_dev_id): New macro GRUB_DISK_DEVICE_NAND_ID. * include/grub/i386/ieee1275/loader.h (grub_rescue_cmd_linux): New function prototype. (grub_rescue_cmd_initrd): Likewise. * include/grub/i386/linux.h (GRUB_LINUX_OFW_SIGNATURE): New macro. (linux_kernel_params): Add new member ofw_signature, ofw_num_items, ofw_cif_handler and ofw_idt, adjust padding number. * include/grub/i386/pc/memory.h (grub_upper_mem): Export it if GRUB_MACHINE_IEEE1275 is defined. * include/grub/ieee1275/ieee1275.h (grub_available_iterate): Use NESTED_FUNC_ATTR attribute on the hook parameter. * kern/powerpc/ieee1275/init.c (grub_claim_heap): Use NESTED_FUNC_ATTR on nested function heap_init. (grub_upper_mem): New variable for i386-ieee1275. (grub_get_extended_memory): New function for i386-ieee1275. (grub_machine_init): Call grub_get_extended_memory for i386-ieee1275. * kern/powerpc/ieee1275/openfw.c (grub_available_iterate): Use NESTED_FUNC_ATTR on the hook parameter. Don't quit if no device type property. * loader/i386/ieee1275/linux.c: New file. * loader/i386/ieee1275/linux_normal.c: New file. * disk/ieee1275/nand.c: New file.
This commit is contained in:
parent
e0c5dacbf4
commit
25f16ec1f6
17 changed files with 917 additions and 30 deletions
57
ChangeLog
57
ChangeLog
|
@ -1,3 +1,60 @@
|
|||
2008-04-25 Bean <bean123ch@gmail.com>
|
||||
|
||||
* Makefile.in (RMKFILES): Add missing arch i386-ieee1275 and
|
||||
i386-linuxbios.
|
||||
|
||||
* commands/hexdump.c (grub_cmd_hexdump): Support dumping of device,
|
||||
change the buffer size to 4096 for cdrom device.
|
||||
|
||||
* conf/i386-ieee1275.rmk (pkglib_MODULES): Add _linux.mod, linux.mod
|
||||
and nand.mod.
|
||||
(_linux_mod_SOURCES): New variable.
|
||||
(_linux_mod_CFLAGS): Likewise.
|
||||
(_linux_mod_LDFLAGS): Likewise.
|
||||
(linux_mod_SOURCES): Likewise.
|
||||
(linux_mod_CFLAGS): Likewise.
|
||||
(linux_mod_LDFLAGS): Likewise.
|
||||
(nand_mod_SOURCES): Likewise.
|
||||
(nand_mod_CFLAGS): Likewise.
|
||||
(nand_mod_LDFLAGS): Likewise.
|
||||
|
||||
* disk/ieee1275/ofdisk.c (grub_ofdisk_open): Return
|
||||
GRUB_ERR_UNKNOWN_DEVICE instead of GRUB_ERR_BAD_DEVICE if no device
|
||||
type property. (nand device in olpc don't have this property)
|
||||
|
||||
* include/grub/disk.h (grub_disk_dev_id): New macro
|
||||
GRUB_DISK_DEVICE_NAND_ID.
|
||||
|
||||
* include/grub/i386/ieee1275/loader.h (grub_rescue_cmd_linux): New
|
||||
function prototype.
|
||||
(grub_rescue_cmd_initrd): Likewise.
|
||||
|
||||
* include/grub/i386/linux.h (GRUB_LINUX_OFW_SIGNATURE): New macro.
|
||||
(linux_kernel_params): Add new member ofw_signature, ofw_num_items,
|
||||
ofw_cif_handler and ofw_idt, adjust padding number.
|
||||
|
||||
* include/grub/i386/pc/memory.h (grub_upper_mem): Export it if
|
||||
GRUB_MACHINE_IEEE1275 is defined.
|
||||
|
||||
* include/grub/ieee1275/ieee1275.h (grub_available_iterate):
|
||||
Use NESTED_FUNC_ATTR attribute on the hook parameter.
|
||||
|
||||
* kern/powerpc/ieee1275/init.c (grub_claim_heap): Use NESTED_FUNC_ATTR
|
||||
on nested function heap_init.
|
||||
(grub_upper_mem): New variable for i386-ieee1275.
|
||||
(grub_get_extended_memory): New function for i386-ieee1275.
|
||||
(grub_machine_init): Call grub_get_extended_memory for i386-ieee1275.
|
||||
|
||||
* kern/powerpc/ieee1275/openfw.c (grub_available_iterate): Use
|
||||
NESTED_FUNC_ATTR on the hook parameter. Don't quit if no device type
|
||||
property.
|
||||
|
||||
* loader/i386/ieee1275/linux.c: New file.
|
||||
|
||||
* loader/i386/ieee1275/linux_normal.c: New file.
|
||||
|
||||
* disk/ieee1275/nand.c: New file.
|
||||
|
||||
2008-04-18 Thomas Schwinge <tschwinge@gnu.org>
|
||||
|
||||
* util/i386/pc/grub-mkrescue.in (grub_mkimage): Don't overwrite correct
|
||||
|
|
|
@ -91,7 +91,7 @@ enable_grub_fstest = @enable_grub_fstest@
|
|||
### General variables.
|
||||
|
||||
RMKFILES = $(addprefix conf/,common.rmk i386-pc.rmk powerpc-ieee1275.rmk \
|
||||
sparc64-ieee1275.rmk i386-efi.rmk)
|
||||
sparc64-ieee1275.rmk i386-efi.rmk i386-ieee1275.rmk i386-linuxbios.rmk)
|
||||
MKFILES = $(patsubst %.rmk,%.mk,$(RMKFILES))
|
||||
|
||||
PKGLIB = $(pkglib_IMAGES) $(pkglib_MODULES) $(pkglib_PROGRAMS) \
|
||||
|
|
|
@ -82,26 +82,62 @@ hexdump (unsigned long bse, char *buf, int len)
|
|||
static grub_err_t
|
||||
grub_cmd_hexdump (struct grub_arg_list *state, int argc, char **args)
|
||||
{
|
||||
grub_file_t file;
|
||||
char buf[GRUB_DISK_SECTOR_SIZE];
|
||||
char buf[GRUB_DISK_SECTOR_SIZE * 4];
|
||||
grub_ssize_t size, length;
|
||||
unsigned long skip;
|
||||
int is_file;
|
||||
int namelen;
|
||||
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
||||
|
||||
namelen = grub_strlen (args[0]);
|
||||
skip = (state[0].set) ? grub_strtoul (state[0].arg, 0, 0) : 0;
|
||||
length = (state[1].set) ? grub_strtoul (state[1].arg, 0, 0) : 0;
|
||||
length = (state[1].set) ? grub_strtoul (state[1].arg, 0, 0) : 256;
|
||||
|
||||
is_file = (grub_strcmp (args[0], "(mem)"));
|
||||
if ((!is_file) && (!length))
|
||||
length = 256;
|
||||
|
||||
if (is_file)
|
||||
if (!grub_strcmp (args[0], "(mem)"))
|
||||
hexdump (skip, (char *) skip, length);
|
||||
else if ((args[0][0] == '(') && (args[0][namelen - 1] == ')'))
|
||||
{
|
||||
grub_disk_t disk;
|
||||
grub_disk_addr_t sector;
|
||||
grub_size_t ofs;
|
||||
|
||||
args[0][namelen - 1] = 0;
|
||||
disk = grub_disk_open (&args[0][1]);
|
||||
if (! disk)
|
||||
return 0;
|
||||
|
||||
sector = (skip >> (GRUB_DISK_SECTOR_BITS + 2)) * 4;
|
||||
ofs = skip & (GRUB_DISK_SECTOR_SIZE * 4 - 1);
|
||||
while (length)
|
||||
{
|
||||
grub_size_t len, n;
|
||||
|
||||
len = length;
|
||||
if (ofs + len > sizeof (buf))
|
||||
len = sizeof (buf) - ofs;
|
||||
|
||||
n = ((ofs + len + GRUB_DISK_SECTOR_SIZE - 1)
|
||||
>> GRUB_DISK_SECTOR_BITS);
|
||||
if (disk->dev->read (disk, sector, n, buf))
|
||||
break;
|
||||
|
||||
hexdump (skip, &buf[ofs], len);
|
||||
|
||||
ofs = 0;
|
||||
skip += len;
|
||||
length -= len;
|
||||
sector += 4;
|
||||
}
|
||||
|
||||
grub_disk_close (disk);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_file_t file;
|
||||
|
||||
file = grub_gzfile_open (args[0], 1);
|
||||
if (!file)
|
||||
if (! file)
|
||||
return 0;
|
||||
|
||||
file->offset = skip;
|
||||
|
@ -123,8 +159,6 @@ grub_cmd_hexdump (struct grub_arg_list *state, int argc, char **args)
|
|||
|
||||
grub_file_close (file);
|
||||
}
|
||||
else
|
||||
hexdump (skip, (char *) skip, length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -134,7 +168,7 @@ GRUB_MOD_INIT (hexdump)
|
|||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("hexdump", grub_cmd_hexdump, GRUB_COMMAND_FLAG_BOTH,
|
||||
"hexdump [ -s offset ] [-n length] { FILE | (mem) }",
|
||||
"hexdump [OPTIONS] FILE_OR_DEVICE",
|
||||
"Dump the contents of a file or memory.", options);
|
||||
}
|
||||
|
||||
|
|
|
@ -573,7 +573,8 @@ grub_emu_LDFLAGS = $(LIBCURSES)
|
|||
|
||||
# Modules.
|
||||
pkglib_MODULES = normal.mod halt.mod reboot.mod suspend.mod cpuid.mod \
|
||||
multiboot.mod _multiboot.mod aout.mod serial.mod
|
||||
multiboot.mod _multiboot.mod aout.mod serial.mod linux.mod \
|
||||
_linux.mod nand.mod
|
||||
|
||||
# For normal.mod.
|
||||
normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \
|
||||
|
@ -1390,4 +1391,172 @@ partmap-serial_mod-term_i386_pc_serial.lst: term/i386/pc/serial.c $(term/i386/pc
|
|||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For _linux.mod.
|
||||
_linux_mod_SOURCES = loader/i386/ieee1275/linux.c
|
||||
CLEANFILES += _linux.mod mod-_linux.o mod-_linux.c pre-_linux.o _linux_mod-loader_i386_ieee1275_linux.o und-_linux.lst
|
||||
ifneq ($(_linux_mod_EXPORTS),no)
|
||||
CLEANFILES += def-_linux.lst
|
||||
DEFSYMFILES += def-_linux.lst
|
||||
endif
|
||||
MOSTLYCLEANFILES += _linux_mod-loader_i386_ieee1275_linux.d
|
||||
UNDSYMFILES += und-_linux.lst
|
||||
|
||||
_linux.mod: pre-_linux.o mod-_linux.o
|
||||
-rm -f $@
|
||||
$(TARGET_CC) $(_linux_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
||||
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
|
||||
|
||||
pre-_linux.o: $(_linux_mod_DEPENDENCIES) _linux_mod-loader_i386_ieee1275_linux.o
|
||||
-rm -f $@
|
||||
$(TARGET_CC) $(_linux_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ _linux_mod-loader_i386_ieee1275_linux.o
|
||||
|
||||
mod-_linux.o: mod-_linux.c
|
||||
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_linux_mod_CFLAGS) -c -o $@ $<
|
||||
|
||||
mod-_linux.c: moddep.lst genmodsrc.sh
|
||||
sh $(srcdir)/genmodsrc.sh '_linux' $< > $@ || (rm -f $@; exit 1)
|
||||
|
||||
ifneq ($(_linux_mod_EXPORTS),no)
|
||||
def-_linux.lst: pre-_linux.o
|
||||
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 _linux/' > $@
|
||||
endif
|
||||
|
||||
und-_linux.lst: pre-_linux.o
|
||||
echo '_linux' > $@
|
||||
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||
|
||||
_linux_mod-loader_i386_ieee1275_linux.o: loader/i386/ieee1275/linux.c $(loader/i386/ieee1275/linux.c_DEPENDENCIES)
|
||||
$(TARGET_CC) -Iloader/i386/ieee1275 -I$(srcdir)/loader/i386/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_linux_mod_CFLAGS) -MD -c -o $@ $<
|
||||
-include _linux_mod-loader_i386_ieee1275_linux.d
|
||||
|
||||
CLEANFILES += cmd-_linux_mod-loader_i386_ieee1275_linux.lst fs-_linux_mod-loader_i386_ieee1275_linux.lst partmap-_linux_mod-loader_i386_ieee1275_linux.lst
|
||||
COMMANDFILES += cmd-_linux_mod-loader_i386_ieee1275_linux.lst
|
||||
FSFILES += fs-_linux_mod-loader_i386_ieee1275_linux.lst
|
||||
PARTMAPFILES += partmap-_linux_mod-loader_i386_ieee1275_linux.lst
|
||||
|
||||
cmd-_linux_mod-loader_i386_ieee1275_linux.lst: loader/i386/ieee1275/linux.c $(loader/i386/ieee1275/linux.c_DEPENDENCIES) gencmdlist.sh
|
||||
set -e; $(TARGET_CC) -Iloader/i386/ieee1275 -I$(srcdir)/loader/i386/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_linux_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _linux > $@ || (rm -f $@; exit 1)
|
||||
|
||||
fs-_linux_mod-loader_i386_ieee1275_linux.lst: loader/i386/ieee1275/linux.c $(loader/i386/ieee1275/linux.c_DEPENDENCIES) genfslist.sh
|
||||
set -e; $(TARGET_CC) -Iloader/i386/ieee1275 -I$(srcdir)/loader/i386/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_linux_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh _linux > $@ || (rm -f $@; exit 1)
|
||||
|
||||
partmap-_linux_mod-loader_i386_ieee1275_linux.lst: loader/i386/ieee1275/linux.c $(loader/i386/ieee1275/linux.c_DEPENDENCIES) genpartmaplist.sh
|
||||
set -e; $(TARGET_CC) -Iloader/i386/ieee1275 -I$(srcdir)/loader/i386/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_linux_mod_CFLAGS) -E $< | sh $(srcdir)/genpartmaplist.sh _linux > $@ || (rm -f $@; exit 1)
|
||||
|
||||
|
||||
_linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
_linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For linux.mod.
|
||||
linux_mod_SOURCES = loader/i386/ieee1275/linux_normal.c
|
||||
CLEANFILES += linux.mod mod-linux.o mod-linux.c pre-linux.o linux_mod-loader_i386_ieee1275_linux_normal.o und-linux.lst
|
||||
ifneq ($(linux_mod_EXPORTS),no)
|
||||
CLEANFILES += def-linux.lst
|
||||
DEFSYMFILES += def-linux.lst
|
||||
endif
|
||||
MOSTLYCLEANFILES += linux_mod-loader_i386_ieee1275_linux_normal.d
|
||||
UNDSYMFILES += und-linux.lst
|
||||
|
||||
linux.mod: pre-linux.o mod-linux.o
|
||||
-rm -f $@
|
||||
$(TARGET_CC) $(linux_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
||||
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
|
||||
|
||||
pre-linux.o: $(linux_mod_DEPENDENCIES) linux_mod-loader_i386_ieee1275_linux_normal.o
|
||||
-rm -f $@
|
||||
$(TARGET_CC) $(linux_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ linux_mod-loader_i386_ieee1275_linux_normal.o
|
||||
|
||||
mod-linux.o: mod-linux.c
|
||||
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(linux_mod_CFLAGS) -c -o $@ $<
|
||||
|
||||
mod-linux.c: moddep.lst genmodsrc.sh
|
||||
sh $(srcdir)/genmodsrc.sh 'linux' $< > $@ || (rm -f $@; exit 1)
|
||||
|
||||
ifneq ($(linux_mod_EXPORTS),no)
|
||||
def-linux.lst: pre-linux.o
|
||||
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 linux/' > $@
|
||||
endif
|
||||
|
||||
und-linux.lst: pre-linux.o
|
||||
echo 'linux' > $@
|
||||
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||
|
||||
linux_mod-loader_i386_ieee1275_linux_normal.o: loader/i386/ieee1275/linux_normal.c $(loader/i386/ieee1275/linux_normal.c_DEPENDENCIES)
|
||||
$(TARGET_CC) -Iloader/i386/ieee1275 -I$(srcdir)/loader/i386/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(linux_mod_CFLAGS) -MD -c -o $@ $<
|
||||
-include linux_mod-loader_i386_ieee1275_linux_normal.d
|
||||
|
||||
CLEANFILES += cmd-linux_mod-loader_i386_ieee1275_linux_normal.lst fs-linux_mod-loader_i386_ieee1275_linux_normal.lst partmap-linux_mod-loader_i386_ieee1275_linux_normal.lst
|
||||
COMMANDFILES += cmd-linux_mod-loader_i386_ieee1275_linux_normal.lst
|
||||
FSFILES += fs-linux_mod-loader_i386_ieee1275_linux_normal.lst
|
||||
PARTMAPFILES += partmap-linux_mod-loader_i386_ieee1275_linux_normal.lst
|
||||
|
||||
cmd-linux_mod-loader_i386_ieee1275_linux_normal.lst: loader/i386/ieee1275/linux_normal.c $(loader/i386/ieee1275/linux_normal.c_DEPENDENCIES) gencmdlist.sh
|
||||
set -e; $(TARGET_CC) -Iloader/i386/ieee1275 -I$(srcdir)/loader/i386/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(linux_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh linux > $@ || (rm -f $@; exit 1)
|
||||
|
||||
fs-linux_mod-loader_i386_ieee1275_linux_normal.lst: loader/i386/ieee1275/linux_normal.c $(loader/i386/ieee1275/linux_normal.c_DEPENDENCIES) genfslist.sh
|
||||
set -e; $(TARGET_CC) -Iloader/i386/ieee1275 -I$(srcdir)/loader/i386/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(linux_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh linux > $@ || (rm -f $@; exit 1)
|
||||
|
||||
partmap-linux_mod-loader_i386_ieee1275_linux_normal.lst: loader/i386/ieee1275/linux_normal.c $(loader/i386/ieee1275/linux_normal.c_DEPENDENCIES) genpartmaplist.sh
|
||||
set -e; $(TARGET_CC) -Iloader/i386/ieee1275 -I$(srcdir)/loader/i386/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(linux_mod_CFLAGS) -E $< | sh $(srcdir)/genpartmaplist.sh linux > $@ || (rm -f $@; exit 1)
|
||||
|
||||
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For nand.mod.
|
||||
nand_mod_SOURCES = disk/ieee1275/nand.c
|
||||
CLEANFILES += nand.mod mod-nand.o mod-nand.c pre-nand.o nand_mod-disk_ieee1275_nand.o und-nand.lst
|
||||
ifneq ($(nand_mod_EXPORTS),no)
|
||||
CLEANFILES += def-nand.lst
|
||||
DEFSYMFILES += def-nand.lst
|
||||
endif
|
||||
MOSTLYCLEANFILES += nand_mod-disk_ieee1275_nand.d
|
||||
UNDSYMFILES += und-nand.lst
|
||||
|
||||
nand.mod: pre-nand.o mod-nand.o
|
||||
-rm -f $@
|
||||
$(TARGET_CC) $(nand_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
|
||||
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
|
||||
|
||||
pre-nand.o: $(nand_mod_DEPENDENCIES) nand_mod-disk_ieee1275_nand.o
|
||||
-rm -f $@
|
||||
$(TARGET_CC) $(nand_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ nand_mod-disk_ieee1275_nand.o
|
||||
|
||||
mod-nand.o: mod-nand.c
|
||||
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(nand_mod_CFLAGS) -c -o $@ $<
|
||||
|
||||
mod-nand.c: moddep.lst genmodsrc.sh
|
||||
sh $(srcdir)/genmodsrc.sh 'nand' $< > $@ || (rm -f $@; exit 1)
|
||||
|
||||
ifneq ($(nand_mod_EXPORTS),no)
|
||||
def-nand.lst: pre-nand.o
|
||||
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 nand/' > $@
|
||||
endif
|
||||
|
||||
und-nand.lst: pre-nand.o
|
||||
echo 'nand' > $@
|
||||
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
|
||||
|
||||
nand_mod-disk_ieee1275_nand.o: disk/ieee1275/nand.c $(disk/ieee1275/nand.c_DEPENDENCIES)
|
||||
$(TARGET_CC) -Idisk/ieee1275 -I$(srcdir)/disk/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(nand_mod_CFLAGS) -MD -c -o $@ $<
|
||||
-include nand_mod-disk_ieee1275_nand.d
|
||||
|
||||
CLEANFILES += cmd-nand_mod-disk_ieee1275_nand.lst fs-nand_mod-disk_ieee1275_nand.lst partmap-nand_mod-disk_ieee1275_nand.lst
|
||||
COMMANDFILES += cmd-nand_mod-disk_ieee1275_nand.lst
|
||||
FSFILES += fs-nand_mod-disk_ieee1275_nand.lst
|
||||
PARTMAPFILES += partmap-nand_mod-disk_ieee1275_nand.lst
|
||||
|
||||
cmd-nand_mod-disk_ieee1275_nand.lst: disk/ieee1275/nand.c $(disk/ieee1275/nand.c_DEPENDENCIES) gencmdlist.sh
|
||||
set -e; $(TARGET_CC) -Idisk/ieee1275 -I$(srcdir)/disk/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(nand_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh nand > $@ || (rm -f $@; exit 1)
|
||||
|
||||
fs-nand_mod-disk_ieee1275_nand.lst: disk/ieee1275/nand.c $(disk/ieee1275/nand.c_DEPENDENCIES) genfslist.sh
|
||||
set -e; $(TARGET_CC) -Idisk/ieee1275 -I$(srcdir)/disk/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(nand_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh nand > $@ || (rm -f $@; exit 1)
|
||||
|
||||
partmap-nand_mod-disk_ieee1275_nand.lst: disk/ieee1275/nand.c $(disk/ieee1275/nand.c_DEPENDENCIES) genpartmaplist.sh
|
||||
set -e; $(TARGET_CC) -Idisk/ieee1275 -I$(srcdir)/disk/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(nand_mod_CFLAGS) -E $< | sh $(srcdir)/genpartmaplist.sh nand > $@ || (rm -f $@; exit 1)
|
||||
|
||||
|
||||
nand_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
nand_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
|
|
@ -97,7 +97,8 @@ grub_emu_LDFLAGS = $(LIBCURSES)
|
|||
|
||||
# Modules.
|
||||
pkglib_MODULES = normal.mod halt.mod reboot.mod suspend.mod cpuid.mod \
|
||||
multiboot.mod _multiboot.mod aout.mod serial.mod
|
||||
multiboot.mod _multiboot.mod aout.mod serial.mod linux.mod \
|
||||
_linux.mod nand.mod
|
||||
|
||||
# For normal.mod.
|
||||
normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \
|
||||
|
@ -151,4 +152,19 @@ serial_mod_SOURCES = term/i386/pc/serial.c
|
|||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For _linux.mod.
|
||||
_linux_mod_SOURCES = loader/i386/ieee1275/linux.c
|
||||
_linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
_linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For linux.mod.
|
||||
linux_mod_SOURCES = loader/i386/ieee1275/linux_normal.c
|
||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For nand.mod.
|
||||
nand_mod_SOURCES = disk/ieee1275/nand.c
|
||||
nand_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
nand_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
|
216
disk/ieee1275/nand.c
Normal file
216
disk/ieee1275/nand.c
Normal file
|
@ -0,0 +1,216 @@
|
|||
/* nand.c - NAND flash disk access. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/misc.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
|
||||
struct grub_nand_data
|
||||
{
|
||||
grub_ieee1275_ihandle_t handle;
|
||||
grub_uint32_t block_size;
|
||||
};
|
||||
|
||||
static int
|
||||
grub_nand_iterate (int (*hook) (const char *name))
|
||||
{
|
||||
auto int dev_iterate (struct grub_ieee1275_devalias *alias);
|
||||
int dev_iterate (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if (! grub_strcmp (alias->name, "nand"))
|
||||
{
|
||||
hook (alias->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_devalias_iterate (dev_iterate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, char *buf);
|
||||
|
||||
static grub_err_t
|
||||
grub_nand_open (const char *name, grub_disk_t disk)
|
||||
{
|
||||
grub_ieee1275_ihandle_t dev_ihandle = 0;
|
||||
struct grub_nand_data *data = 0;
|
||||
struct size_args
|
||||
{
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
char *method;
|
||||
grub_ieee1275_ihandle_t ihandle;
|
||||
grub_ieee1275_cell_t result;
|
||||
grub_ieee1275_cell_t size1;
|
||||
grub_ieee1275_cell_t size2;
|
||||
} args;
|
||||
|
||||
if (! grub_strstr (name, "nand"))
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Not a nand device");
|
||||
|
||||
data = grub_malloc (sizeof (*data));
|
||||
if (! data)
|
||||
goto fail;
|
||||
|
||||
grub_ieee1275_open (name, &dev_ihandle);
|
||||
if (! dev_ihandle)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
data->handle = dev_ihandle;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2);
|
||||
args.method = "block-size";
|
||||
args.ihandle = dev_ihandle;
|
||||
args.result = 1;
|
||||
|
||||
if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't get block size");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
data->block_size = (args.size1 >> GRUB_DISK_SECTOR_BITS);
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
|
||||
args.method = "size";
|
||||
args.ihandle = dev_ihandle;
|
||||
args.result = 1;
|
||||
|
||||
if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't get disk size");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
disk->total_sectors = args.size1;
|
||||
disk->total_sectors <<= 32;
|
||||
disk->total_sectors += args.size2;
|
||||
disk->total_sectors >>= GRUB_DISK_SECTOR_BITS;
|
||||
|
||||
disk->id = dev_ihandle;
|
||||
|
||||
disk->has_partitions = 0;
|
||||
disk->data = data;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (dev_ihandle)
|
||||
grub_ieee1275_close (dev_ihandle);
|
||||
grub_free (data);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_nand_close (grub_disk_t disk)
|
||||
{
|
||||
grub_ieee1275_close (((struct grub_nand_data *) disk->data)->handle);
|
||||
grub_free (disk->data);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, char *buf)
|
||||
{
|
||||
struct grub_nand_data *data = disk->data;
|
||||
grub_size_t bsize, ofs;
|
||||
|
||||
struct read_args
|
||||
{
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
char *method;
|
||||
grub_ieee1275_ihandle_t ihandle;
|
||||
grub_ieee1275_cell_t ofs;
|
||||
grub_ieee1275_cell_t page;
|
||||
grub_ieee1275_cell_t len;
|
||||
grub_ieee1275_cell_t buf;
|
||||
grub_ieee1275_cell_t result;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
|
||||
args.method = "pio-read";
|
||||
args.ihandle = data->handle;
|
||||
args.buf = (grub_ieee1275_cell_t) buf;
|
||||
args.page = (grub_ieee1275_cell_t) ((grub_size_t) sector / data->block_size);
|
||||
|
||||
ofs = ((grub_size_t) sector % data->block_size) << GRUB_DISK_SECTOR_BITS;
|
||||
size <<= GRUB_DISK_SECTOR_BITS;
|
||||
bsize = (data->block_size << GRUB_DISK_SECTOR_BITS);
|
||||
|
||||
do
|
||||
{
|
||||
grub_size_t len;
|
||||
|
||||
len = (ofs + size > bsize) ? (bsize - ofs) : size;
|
||||
|
||||
args.len = (grub_ieee1275_cell_t) len;
|
||||
args.ofs = (grub_ieee1275_cell_t) ofs;
|
||||
args.result = 1;
|
||||
|
||||
if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "Read error");
|
||||
|
||||
ofs = 0;
|
||||
size -= len;
|
||||
args.buf += len;
|
||||
args.page++;
|
||||
} while (size);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_nand_write (grub_disk_t disk __attribute ((unused)),
|
||||
grub_disk_addr_t sector __attribute ((unused)),
|
||||
grub_size_t size __attribute ((unused)),
|
||||
const char *buf __attribute ((unused)))
|
||||
{
|
||||
return GRUB_ERR_NOT_IMPLEMENTED_YET;
|
||||
}
|
||||
|
||||
static struct grub_disk_dev grub_nand_dev =
|
||||
{
|
||||
.name = "nand",
|
||||
.id = GRUB_DISK_DEVICE_NAND_ID,
|
||||
.iterate = grub_nand_iterate,
|
||||
.open = grub_nand_open,
|
||||
.close = grub_nand_close,
|
||||
.read = grub_nand_read,
|
||||
.write = grub_nand_write,
|
||||
.next = 0
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(nand)
|
||||
{
|
||||
grub_disk_dev_register (&grub_nand_dev);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(nand)
|
||||
{
|
||||
grub_disk_dev_unregister (&grub_nand_dev);
|
||||
}
|
|
@ -109,7 +109,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
if (grub_ieee1275_get_property (dev, "device_type", prop, sizeof (prop),
|
||||
&actual))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE, "Can't read the device type");
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read the device type");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ enum grub_disk_dev_id
|
|||
GRUB_DISK_DEVICE_HOST_ID,
|
||||
GRUB_DISK_DEVICE_ATA_ID,
|
||||
GRUB_DISK_DEVICE_MEMDISK_ID,
|
||||
GRUB_DISK_DEVICE_NAND_ID,
|
||||
};
|
||||
|
||||
struct grub_disk;
|
||||
|
|
|
@ -27,4 +27,7 @@ void EXPORT_FUNC(grub_multiboot2_real_boot) (grub_addr_t entry,
|
|||
struct grub_multiboot_info *mbi)
|
||||
__attribute__ ((noreturn));
|
||||
|
||||
void grub_rescue_cmd_linux (int argc, char *argv[]);
|
||||
void grub_rescue_cmd_initrd (int argc, char *argv[]);
|
||||
|
||||
#endif /* ! GRUB_LOADER_MACHINE_HEADER */
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
#define GRUB_LINUX_EFI_SIGNATURE \
|
||||
('E' << 24 | 'F' << 16 | 'I' << 8 | 'L')
|
||||
|
||||
#define GRUB_LINUX_OFW_SIGNATURE \
|
||||
(' ' << 24 | 'W' << 16 | 'F' << 8 | 'O')
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
/* For the Linux/i386 boot protocol version 2.03. */
|
||||
|
@ -154,7 +157,14 @@ struct linux_kernel_params
|
|||
grub_uint8_t hd1_drive_info[0x10]; /* 90 */
|
||||
grub_uint16_t rom_config_len; /* a0 */
|
||||
|
||||
grub_uint8_t padding6[0x1c0 - 0xa2];
|
||||
grub_uint8_t padding6[0xb0 - 0xa2];
|
||||
|
||||
grub_uint32_t ofw_signature; /* b0 */
|
||||
grub_uint32_t ofw_num_items; /* b4 */
|
||||
grub_uint32_t ofw_cif_handler; /* b8 */
|
||||
grub_uint32_t ofw_idt; /* bc */
|
||||
|
||||
grub_uint8_t padding7[0x1c0 - 0xc0];
|
||||
|
||||
grub_uint32_t efi_signature; /* 1c0 */
|
||||
grub_uint32_t efi_system_table; /* 1c4 */
|
||||
|
@ -163,15 +173,15 @@ struct linux_kernel_params
|
|||
grub_uint32_t efi_mmap; /* 1d0 */
|
||||
grub_uint32_t efi_mmap_size; /* 1d4 */
|
||||
|
||||
grub_uint8_t padding7[0x1e0 - 0x1d8];
|
||||
grub_uint8_t padding8[0x1e0 - 0x1d8];
|
||||
|
||||
grub_uint32_t alt_mem; /* 1e0 */
|
||||
|
||||
grub_uint8_t padding8[0x1e8 - 0x1e4];
|
||||
grub_uint8_t padding9[0x1e8 - 0x1e4];
|
||||
|
||||
grub_uint32_t mmap_size; /* 1e8 */
|
||||
|
||||
grub_uint8_t padding9[0x1ff - 0x1ec];
|
||||
grub_uint8_t padding10[0x1ff - 0x1ec];
|
||||
|
||||
grub_uint8_t ps_mouse; /* 1ff */
|
||||
} __attribute__ ((packed));
|
||||
|
|
|
@ -76,11 +76,14 @@
|
|||
/* The data segment of the pseudo real mode. */
|
||||
#define GRUB_MEMORY_MACHINE_PSEUDO_REAL_DSEG 0x20
|
||||
|
||||
#ifndef GRUB_MACHINE_IEEE1275
|
||||
#ifndef ASM_FILE
|
||||
|
||||
#ifndef GRUB_MACHINE_IEEE1275
|
||||
extern grub_size_t EXPORT_VAR(grub_lower_mem);
|
||||
extern grub_size_t EXPORT_VAR(grub_upper_mem);
|
||||
#endif
|
||||
|
||||
extern grub_size_t EXPORT_VAR(grub_upper_mem);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_MEMORY_MACHINE_HEADER */
|
||||
|
|
|
@ -159,7 +159,7 @@ grub_err_t EXPORT_FUNC(grub_devalias_iterate)
|
|||
grub_err_t EXPORT_FUNC(grub_children_iterate) (char *devpath,
|
||||
int (*hook) (struct grub_ieee1275_devalias *alias));
|
||||
grub_err_t EXPORT_FUNC(grub_available_iterate)
|
||||
(int (*hook) (grub_uint64_t, grub_uint64_t));
|
||||
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t));
|
||||
int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
|
||||
|
||||
char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path);
|
||||
|
|
|
@ -128,8 +128,8 @@ static void grub_claim_heap (void)
|
|||
{
|
||||
unsigned long total = 0;
|
||||
|
||||
auto int heap_init (grub_uint64_t addr, grub_uint64_t len);
|
||||
int heap_init (grub_uint64_t addr, grub_uint64_t len)
|
||||
auto int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len);
|
||||
int NESTED_FUNC_ATTR heap_init (grub_uint64_t addr, grub_uint64_t len)
|
||||
{
|
||||
len -= 1; /* Required for some firmware. */
|
||||
|
||||
|
@ -174,6 +174,31 @@ static void grub_claim_heap (void)
|
|||
grub_available_iterate (heap_init);
|
||||
}
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
grub_uint32_t grub_upper_mem;
|
||||
|
||||
/* We need to call this before grub_claim_memory. */
|
||||
static void
|
||||
grub_get_extended_memory (void)
|
||||
{
|
||||
auto int NESTED_FUNC_ATTR find_ext_mem (grub_uint64_t addr, grub_uint64_t len);
|
||||
int NESTED_FUNC_ATTR find_ext_mem (grub_uint64_t addr, grub_uint64_t len)
|
||||
{
|
||||
if (addr == 0x100000)
|
||||
{
|
||||
grub_upper_mem = len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_available_iterate (find_ext_mem);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
|
@ -184,6 +209,7 @@ grub_machine_init (void)
|
|||
|
||||
grub_console_init ();
|
||||
#ifdef __i386__
|
||||
grub_get_extended_memory ();
|
||||
grub_keyboard_controller_init ();
|
||||
#endif
|
||||
grub_claim_heap ();
|
||||
|
|
|
@ -131,8 +131,8 @@ grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
|
|||
if (grub_ieee1275_get_property (dev, "device_type", devtype,
|
||||
sizeof devtype, &actual))
|
||||
{
|
||||
grub_dprintf ("devalias", "get device type failed\n");
|
||||
goto nextprop;
|
||||
/* NAND device don't have device_type property. */
|
||||
devtype[0] = 0;
|
||||
}
|
||||
|
||||
alias.name = aliasname;
|
||||
|
@ -147,7 +147,7 @@ nextprop:
|
|||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t grub_available_iterate (int (*hook) (grub_uint64_t, grub_uint64_t))
|
||||
grub_err_t grub_available_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t))
|
||||
{
|
||||
grub_ieee1275_phandle_t root;
|
||||
grub_ieee1275_phandle_t memory;
|
||||
|
|
289
loader/i386/ieee1275/linux.c
Normal file
289
loader/i386/ieee1275/linux.c
Normal file
|
@ -0,0 +1,289 @@
|
|||
/* linux.c - boot Linux zImage or bzImage */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/loader.h>
|
||||
#include <grub/machine/loader.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/rescue.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/cpu/linux.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
|
||||
#define GRUB_OFW_LINUX_PARAMS_ADDR 0x90000
|
||||
#define GRUB_OFW_LINUX_KERNEL_ADDR 0x100000
|
||||
#define GRUB_OFW_LINUX_INITRD_ADDR 0x800000
|
||||
|
||||
#define GRUB_OFW_LINUX_CL_OFFSET 0x1e00
|
||||
#define GRUB_OFW_LINUX_CL_LENGTH 0x100
|
||||
|
||||
static grub_dl_t my_mod;
|
||||
|
||||
static grub_size_t kernel_size;
|
||||
static char *kernel_addr, *kernel_cmdline;
|
||||
static grub_size_t initrd_size;
|
||||
|
||||
static grub_err_t
|
||||
grub_linux_unload (void)
|
||||
{
|
||||
grub_free (kernel_cmdline);
|
||||
grub_free (kernel_addr);
|
||||
kernel_cmdline = 0;
|
||||
kernel_addr = 0;
|
||||
initrd_size = 0;
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/*
|
||||
static int
|
||||
grub_ieee1275_debug (void)
|
||||
{
|
||||
struct enter_args
|
||||
{
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
}
|
||||
args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "enter", 0, 0);
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
static void
|
||||
grub_set_bootpath (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_linux_boot (void)
|
||||
{
|
||||
struct linux_kernel_params *params;
|
||||
struct linux_kernel_header *lh;
|
||||
char *prot_code;
|
||||
char *bootpath;
|
||||
grub_ssize_t len;
|
||||
|
||||
bootpath = grub_env_get ("root");
|
||||
if (bootpath)
|
||||
grub_ieee1275_set_property (grub_ieee1275_chosen,
|
||||
"bootpath", bootpath,
|
||||
grub_strlen (bootpath) + 1,
|
||||
&len);
|
||||
|
||||
params = (struct linux_kernel_params *) GRUB_OFW_LINUX_PARAMS_ADDR;
|
||||
lh = (struct linux_kernel_header *) params;
|
||||
|
||||
grub_memset ((char *) params, 0, GRUB_OFW_LINUX_CL_OFFSET);
|
||||
|
||||
params->alt_mem = grub_upper_mem >> 10;
|
||||
params->ext_mem = params->alt_mem;
|
||||
|
||||
lh->cmd_line_ptr = (char *)
|
||||
(GRUB_OFW_LINUX_PARAMS_ADDR + GRUB_OFW_LINUX_CL_OFFSET);
|
||||
|
||||
params->cl_magic = GRUB_LINUX_CL_MAGIC;
|
||||
params->cl_offset = GRUB_OFW_LINUX_CL_OFFSET;
|
||||
|
||||
params->video_width = (grub_getwh () >> 8);
|
||||
params->video_height = (grub_getwh () & 0xff);
|
||||
params->font_size = 16;
|
||||
|
||||
params->ofw_signature = GRUB_LINUX_OFW_SIGNATURE;
|
||||
params->ofw_num_items = 1;
|
||||
params->ofw_cif_handler = (grub_uint32_t) grub_ieee1275_entry_fn;
|
||||
params->ofw_idt = 0;
|
||||
|
||||
if (initrd_size)
|
||||
{
|
||||
lh->type_of_loader = 1;
|
||||
lh->ramdisk_image = GRUB_OFW_LINUX_INITRD_ADDR;
|
||||
lh->ramdisk_size = initrd_size;
|
||||
}
|
||||
|
||||
if (kernel_cmdline)
|
||||
grub_strcpy (lh->cmd_line_ptr, kernel_cmdline);
|
||||
|
||||
prot_code = (char *) GRUB_OFW_LINUX_KERNEL_ADDR;
|
||||
grub_memcpy (prot_code, kernel_addr, kernel_size);
|
||||
|
||||
asm volatile ("movl %0, %%esi" : : "m" (params));
|
||||
asm volatile ("movl %%esi, %%esp" : : );
|
||||
asm volatile ("movl %0, %%ecx" : : "m" (prot_code));
|
||||
asm volatile ("xorl %%ebx, %%ebx" : : );
|
||||
asm volatile ("jmp *%%ecx" : : );
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
grub_rescue_cmd_linux (int argc, char *argv[])
|
||||
{
|
||||
grub_file_t file = 0;
|
||||
struct linux_kernel_header lh;
|
||||
grub_uint8_t setup_sects;
|
||||
grub_size_t real_size, prot_size;
|
||||
int i;
|
||||
char *dest;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "no kernel specified");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
||||
if (grub_file_read (file, (char *) &lh, sizeof (lh)) != sizeof (lh))
|
||||
{
|
||||
grub_error (GRUB_ERR_READ_ERROR, "cannot read the linux header");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((lh.boot_flag != grub_cpu_to_le16 (0xaa55)) ||
|
||||
(lh.header != grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE)))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_OS, "invalid magic number");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
setup_sects = lh.setup_sects;
|
||||
if (! setup_sects)
|
||||
setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS;
|
||||
|
||||
real_size = setup_sects << GRUB_DISK_SECTOR_BITS;
|
||||
prot_size = grub_file_size (file) - real_size - GRUB_DISK_SECTOR_SIZE;
|
||||
|
||||
grub_printf (" [Linux-%s, setup=0x%x, size=0x%x]\n",
|
||||
"bzImage", real_size, prot_size);
|
||||
|
||||
grub_file_seek (file, real_size + GRUB_DISK_SECTOR_SIZE);
|
||||
if (grub_errno)
|
||||
goto fail;
|
||||
|
||||
kernel_cmdline = grub_malloc (GRUB_OFW_LINUX_CL_LENGTH);
|
||||
if (! kernel_cmdline)
|
||||
goto fail;
|
||||
|
||||
dest = kernel_cmdline;
|
||||
for (i = 1;
|
||||
i < argc
|
||||
&& dest + grub_strlen (argv[i]) + 1 < (kernel_cmdline
|
||||
+ GRUB_OFW_LINUX_CL_LENGTH);
|
||||
i++)
|
||||
{
|
||||
*dest++ = ' ';
|
||||
dest = grub_stpcpy (dest, argv[i]);
|
||||
}
|
||||
|
||||
kernel_addr = grub_malloc (prot_size);
|
||||
if (! kernel_addr)
|
||||
goto fail;
|
||||
|
||||
kernel_size = prot_size;
|
||||
if (grub_file_read (file, kernel_addr, prot_size) != (int) prot_size)
|
||||
grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file");
|
||||
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
grub_loader_set (grub_linux_boot, grub_linux_unload, 1);
|
||||
|
||||
fail:
|
||||
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_free (kernel_cmdline);
|
||||
grub_free (kernel_addr);
|
||||
kernel_cmdline = 0;
|
||||
kernel_addr = 0;
|
||||
|
||||
grub_dl_unref (my_mod);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_rescue_cmd_initrd (int argc, char *argv[])
|
||||
{
|
||||
grub_file_t file = 0;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "No module specified");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (! kernel_addr)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "You need to load the kernel first.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0]);
|
||||
if (! file)
|
||||
goto fail;
|
||||
|
||||
initrd_size = grub_file_size (file);
|
||||
if (grub_file_read (file, (char *) GRUB_OFW_LINUX_INITRD_ADDR,
|
||||
initrd_size) != (int) initrd_size)
|
||||
{
|
||||
grub_error (GRUB_ERR_FILE_READ_ERROR, "Couldn't read file");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fail:
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT(linux)
|
||||
{
|
||||
grub_rescue_register_command ("linux",
|
||||
grub_rescue_cmd_linux,
|
||||
"load linux");
|
||||
grub_rescue_register_command ("initrd",
|
||||
grub_rescue_cmd_initrd,
|
||||
"load initrd");
|
||||
my_mod = mod;
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(linux)
|
||||
{
|
||||
grub_rescue_unregister_command ("linux");
|
||||
grub_rescue_unregister_command ("initrd");
|
||||
}
|
60
loader/i386/ieee1275/linux_normal.c
Normal file
60
loader/i386/ieee1275/linux_normal.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* linux_normal.c - boot another boot loader */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2004,2005,2007 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/machine/loader.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_normal_linux_command (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_rescue_cmd_linux (argc, args);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
static grub_err_t
|
||||
grub_normal_initrd_command (struct grub_arg_list *state __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_rescue_cmd_initrd (argc, args);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT(linux_normal)
|
||||
{
|
||||
(void) mod; /* To stop warning. */
|
||||
grub_register_command ("linux", grub_normal_linux_command,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"linux FILE [ARGS...]",
|
||||
"Load a linux kernel.", 0);
|
||||
|
||||
grub_register_command ("initrd", grub_normal_initrd_command,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"initrd FILE",
|
||||
"Load an initrd.", 0);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(linux_normal)
|
||||
{
|
||||
grub_unregister_command ("linux");
|
||||
grub_unregister_command ("initrd");
|
||||
}
|
|
@ -84,7 +84,10 @@ grub_ofconsole_putchar (grub_uint32_t c)
|
|||
{
|
||||
grub_curr_x++;
|
||||
if (grub_curr_x > grub_ofconsole_width)
|
||||
grub_putcode ('\n');
|
||||
{
|
||||
grub_putcode ('\n');
|
||||
grub_curr_x++;
|
||||
}
|
||||
}
|
||||
grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue