Merge mainline into emu-mod

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-14 16:27:54 +01:00
commit dae79b6b05
89 changed files with 1882 additions and 893 deletions

505
ChangeLog
View File

@ -1,3 +1,508 @@
2010-03-14 Vladimir Serbinenko <phcoder@gmail.com>
* conf/powerpc-ieee1275.rmk (pkglib_MODULES): Add datetime.mod,
date.mod, datehook.mod.
(datetime_mod_SOURCES): New variable.
(datetime_mod_CFLAGS): Likewise.
(datetime_mod_LDFLAGS): Likewise.
(date_mod_SOURCES): Likewise.
(date_mod_CFLAGS): Likewise.
(date_mod_LDFLAGS): Likewise.
(datehook_mod_SOURCES): Likewise.
(datehook_mod_CFLAGS): Likewise.
(datehook_mod_LDFLAGS): Likewise.
* conf/sparc64-ieee1275.rmk: Likewise.
* lib/ieee1275/datetime.c: New file.
2010-03-14 Vladimir Serbinenko <phcoder@gmail.com>
* conf/powerpc-ieee1275.rmk (pkglib_MODULES): Add ieee1275_fb.mod.
(ieee1275_fb_mod_SOURCES): New variable.
(ieee1275_fb_mod_CFLAGS): Likewise.
(ieee1275_fb_mod_LDFLAGS): Likewise.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_devices_iterate):
New proto.
* kern/ieee1275/init.c (HEAP_MAX_SIZE): Increased.
(HEAP_MAX_ADDR): Likewise.
* kern/ieee1275/openfw.c (grub_children_iterate): Don't skip empty
type.
Correct stop condition.
(grub_ieee1275_devices_iterate): New function.
* video/ieee1275.c: New file.
2010-03-14 Vladimir Serbinenko <phcoder@gmail.com>
Merge sparc grub-mkimage into generic grub-mkimage and a.out support.
* boot/sparc64/ieee1275/boot.S (boot_continue): Use SCRATCH_PAD_BOOT
as scratch.
* boot/sparc64/ieee1275/diskboot.S (after_info_block): Use
SCRATCH_PAD_DISKBOOT as scratch.
(bootit): Pass Openfirmware pointer in %o4.
* conf/sparc64-ieee1275.rmk (kernel_img_LDFLAGS): Link at 0x4400 instead
of 0x200000.
(grub_mkimage_SOURCES): Replace util/sparc64/ieee1275/grub-mkimage.c
with util/grub-mkrawimage.c.
* configure.ac: Handle GRUB_MACHINE_SPARC64 and GRUB_MACHINE_MIPS.
* include/grub/aout.h (AOUT_MID_SUN): New definition.
(grub_aout_get_type) [GRUB_UTIL]: Removed.
(grub_aout_load) [GRUB_UTIL]: Likewise.
* include/grub/kernel.h (grub_modules_get_end): New proto.
* include/grub/sparc64/ieee1275/boot.h (SCRATCH_PAD): Removed.
(SCRATCH_PAD_BOOT): New definition.
(SCRATCH_PAD_DISKBOOT): Likewise.
(GRUB_BOOT_MACHINE_IMAGE_ADDRESS): Set to 0x4400.
* include/grub/sparc64/ieee1275/ieee1275.h
(grub_ieee1275_original_stack): New variable
* include/grub/sparc64/ieee1275/kernel.h (GRUB_KERNEL_MACHINE_RAW_SIZE):
New definition
(GRUB_KERNEL_MACHINE_STACK_SIZE): Likewise.
(GRUB_PLATFORM_IMAGE_FORMATS): Likewise.
(GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT): Likewise.
(GRUB_PLATFORM_IMAGE_DEFAULT): Likewise.
(GRUB_PLATFORM_IMAGE_RAW): Likewise.
(GRUB_PLATFORM_IMAGE_AOUT): Likewise.
(grub_platform_image_format_t): New type.
* kern/mips/yeeloong/init.c (grub_modules_get_end): Move from here ...
* kern/main.c (grub_modules_get_end)
[GRUB_MACHINE_MIPS_YEELOONG || GRUB_MACHINE_SPARC64]: ... here.
* kern/sparc64/ieee1275/crt0.S: Store firmware entry point in %o0.
(codestart): Switch stacks.
* kern/sparc64/ieee1275/init.c (grub_ieee1275_original_stack): New
variable.
(grub_heap_init): Use grub_modules_get_end.
* loader/sparc64/ieee1275/linux.c (grub_linux_boot): Restore original
stack.
* util/grub-mkrawimage.c (generate_image): Support sparc64.
(main): Likewise.
* util/sparc64/ieee1275/grub-mkimage.c: Removed.
2010-03-14 Thorsten Glaser <tg@mirbsd.org>
* util/grub-mkrescue.in: Base ISO UUID on UTC.
2010-03-08 Matt Kraai <kraai@ftbfs.org>
* util/i386/pc/grub-setup.c (setup): Fix a grammatical error (Debian
bug #559005).
2010-03-07 Vladimir Serbinenko <phcoder@gmail.com>
* genmoddep.awk: Output all missing symbols and not only first.
2010-03-06 Vladimir Serbinenko <phcoder@gmail.com>
* NEWS: Put the date of 1.98 release.
2010-03-06 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Update CPPFLAGS and not CFLAGS when checking for
ft2build.h.
2010-03-06 Vladimir Serbinenko <phcoder@gmail.com>
* normal/cmdline.c (grub_cmdline_get): Fix gabled line after
completition in the middle of string.
2010-03-06 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkrescue.in: Use mktemp with explicit template.
2010-03-06 Vladimir Serbinenko <phcoder@gmail.com>
* loader/i386/bsd.c (grub_bsd_get_device): Fix a memory leak.
2010-03-06 Vladimir Serbinenko <phcoder@gmail.com>
* loader/i386/multiboot_mbi.c (grub_multiboot_set_bootdev): Free the
right pointer.
2010-03-05 Vladimir Serbinenko <phcoder@gmail.com>
Fix FreeBSD compilation.
* Makefile.in (TARGET_CPPFLAGS): Remove -nostdinc -isystem.
* configure.ac: Add -nostdinc -isystem to TARGET_CPPFLAGS if it works.
2010-03-05 Vladimir Serbinenko <phcoder@gmail.com>
* util/import_gcry.py: Add autogenerated files to MAINTAINER_CLEANFILES.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* gettext/gettext.c (grub_gettext_init_ext): Fix a memory leak.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* disk/scsi.c (grub_scsi_iterate): Fix a memory leak.
2010-03-04 Robert Millan <rmh.grub@aybabtu.com>
Support relative image path in theme file.
* gfxmenu/gui_image.c (grub_gui_image): New member theme_dir.
(image_set_property): Handle theme_dir and relative path.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Alias amd64 to x86_64.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* NEWS: mention multiboot on EFI.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* kern/main.c (grub_load_modules): Handle errors from init functions of
embeded modules.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* normal/autofs.c (autoload_fs_module): Handle errors.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
Disable linux.mod on qemu-mips since it's not functional and leads
to compilation failure.
* conf/mips.rmk (pkglib_MODULES): Remove linux.mod.
* conf/mips-yeeloong.rmk (pkglib_MODULES): Add linux.mod.
* conf/mips.rmk (linux_mod_SOURCES): Move from here ...
* conf/mips-yeeloong.rmk (linux_mod_SOURCES): ... here
* conf/mips.rmk (linux_mod_CFLAGS): Move from here ...
* conf/mips-yeeloong.rmk (linux_mod_CFLAGS): ... here
* conf/mips.rmk (linux_mod_ASFLAGS): Move from here ...
* conf/mips-yeeloong.rmk (linux_mod_ASFLAGS): ... here
* conf/mips.rmk (linux_mod_LDFLAGS): Move from here ...
* conf/mips-yeeloong.rmk (linux_mod_LDFLAGS): ... here
Reported by: BVK Chaitanya
2010-03-04 Jordan Uggla <jordan.uggla@gmail.com>
* INSTALL: Add gettext as a dependency and add qemu to a new section
"Prerequisites for make-check".
2010-03-04 Christian Franke <franke@computer.org>
* util/grub-pe2elf.c: Add missing include "progname.h".
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* normal/crypto.c (read_crypto_list): Fix a typo.
Reported by: Seth Goldberg.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* Makefile.in (DISTCLEANFILES): Add stamp-h1.
Reported by: Seth Goldberg.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* Makefile.in (CLEANFILES) [FONT_SOURCE && grub_mkfont]: Add
ascii.bitmaps.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* genmk.rb: Remove terminal*.lst in make clean.
Reported by: Seth Goldberg.
2010-03-04 Vladimir Serbinenko <phcoder@gmail.com>
* util/i386/efi/grub-install.in: Copy gettext files.
2010-03-01 Vladimir Serbinenko <phcoder@gmail.com>
* fs/ext2.c (grub_ext2_read_block): Fix an integer overflow.
2010-03-01 Vladimir Serbinenko <phcoder@gmail.com>
Wait for user entry basing on presence of output rather than on errors.
* include/grub/normal.h (grub_normal_get_line_counter): New proto.
(grub_install_newline_hook): Likewise.
* normal/main.c (GRUB_MOD_INIT): Call grub_install_newline_hook.
* normal/menu.c (show_menu): Check line_counter to determine presence
of output.
* normal/term.c (grub_normal_line_counter): New variable.
(grub_normal_get_line_counter): New function.
(grub_install_newline_hook): Likewise.
2010-03-01 Vladimir Serbinenko <phcoder@gmail.com>
* commands/cat.c (grub_cmd_cat): Propagate grub_gzfile_open error.
2010-03-01 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Update version to 1.98.
2010-02-26 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub.d/10_linux.in (linux_entry): Don't default to
gfxpayload=keep if Linux doesn't support video handover.
2010-02-25 Vladimir Serbinenko <phcoder@gmail.com>
Don't compile video modules on yeeloong since video subsystem is part
of kernel.
* conf/common.rmk (pkglib_MODULES) [yeeloong]: Remove video.mod,
video_fb.mod, bitmap.mod, font.mod, gfxterm.mod and bufio.mod
* conf/mips-yeeloong.rmk (kernel_img_HEADERS): Add bitmap.h,
video.h, gfxterm.h, font.h, bitmap_scale.h and bufio.h.
* conf/mips.rmk (kernel_img_HEADERS): Add values instead of overwriting.
* include/grub/bitmap.h: Add EXPORT_FUNC and EXPORT_VAR.
* include/grub/bitmap_scale.h: Likewise.
* include/grub/bufio.h: Likewise.
* include/grub/font.h: Likewise.
* include/grub/gfxterm.h: Likewise.
* include/grub/video.h: Likewise.
* include/grub/vbe.h: Don't include video_fb.h.
* video/i386/pc/vbe.c: Include video_fb.h.
* commands/i386/pc/vbetest.c: Include video.h.
2010-02-25 Jordan Uggla <jordan.uggla@gmail.com>
* util/grub-mkconfig.in (GRUB_SAVEDEFAULT): Export new variable.
* util/grub-mkconfig_lib.in (save_default_entry): Only save a new
default entry if GRUB_SAVEDEFAULT=true. This allows using
GRUB_DEFAULT=saved on its own to let grub-reboot work, without
saving a new default on every boot.
2010-02-24 Vladimir Serbinenko <phcoder@gmail.com>
* normal/crypto.c (read_crypto_list): Fix a memory leak.
* normal/term.c (read_terminal_list): Likewise.
* normal/main.c (grub_normal_init_page): Likewise.
(grub_normal_read_line_real): Likewise.
2010-02-24 Vladimir Serbinenko <phcoder@gmail.com>
* loader/i386/multiboot_mbi.c (grub_multiboot_set_bootdev): Fix a
memory leak.
Reported by: Seth Goldberg.
2010-02-24 Joey Korkames <joey+lists@kidfixit.com>
* term/ieee1275/ofconsole.c (grub_ofconsole_readkey): Remove
duplicate declaration of `start'.
2010-02-20 Vladimir Serbinenko <phcoder@gmail.com>
* fs/iso9660.c (grub_iso9660_iterate_dir): Strip version from joliet
filename.
Reported by: Georgy Buranov
2010-02-20 Carles Pina i Estany <carles@pina.cat>
* util/grub-mkrawimage.c (usage): Change string formatting to
improve gettext.
2010-02-20 Manoel Rebelo Abranches <mrabran@br.ibm.com>
* term/ieee1275/ofconsole.c (grub_ofconsole_readkey): Add delete and
backspace keys.
2010-02-20 Vladimir Serbinenko <phcoder@gmail.com>
* video/fb/video_fb.c (grub_video_fb_scroll): Fix a pixel size bug.
Reported by: Michael Suchanek.
2010-02-18 Samuel Thibault <samuel.thibault@ens-lyon.org>
* util/grub-mkconfig.in: Export GRUB_INIT_TUNE.
* util/grub.d/00_header.in: Handle GRUB_INIT_TUNE.
2010-02-16 Vladimir Serbinenko <phcoder@gmail.com>
Remove any reference to non-free fonts.
* commands/videotest.c (grub_cmd_videotest): Use unifont by default.
* docs/gfxmenu-theme-example.txt: Removed. It's both outdated and
uses non-free components.
* font/font.c (grub_font_get_name): Remove example name.
* gfxmenu/gui_label.c (grub_gui_label_new): Use unifont by default.
* gfxmenu/gui_list.c (grub_gui_list_new): Likewise.
* gfxmenu/gui_progress_bar.c (grub_gui_progress_bar_new): Likewise.
* gfxmenu/view.c (grub_gfxmenu_view_new): Likewise.
2010-02-16 Georgy Buranov <gburanov@gmail.com>
* disk/efi/efidisk.c (grub_efidisk_get_device_name): Fix a typo.
2010-02-15 Vladimir Serbinenko <phcoder@gmail.com>
* term/serial.c (serial_get_divisor) [GRUB_MACHINE_MIPS_YEELOONG]:
Double divisor.
(serial_hw_init) [GRUB_MACHINE_MIPS_YEELOONG]: Don't enable advanced
features.
(GRUB_MOD_INIT) [GRUB_MACHINE_MIPS_YEELOONG]: Default to 115200.
2010-02-15 Vladimir Serbinenko <phcoder@gmail.com>
* gensymlist.sh.in: Use TARGET_CC instead of CC.
2010-02-14 Samuel Thibault <samuel.thibault@ens-lyon.org>
* commands/i386/pc/play.c (GRUB_MOD_INIT(play)): Fix help.
* docs/grub.texi (Command-line and menu entry commands): Document play
command.
2010-02-14 Samuel Thibault <samuel.thibault@ens-lyon.org>
* commands/i386/pc/play.c (grub_cmd_play): If grub_file_open fails,
parse arguments as inline tempo and notes. Move code for playing notes
to...
(play): ... new function.
2010-02-14 Samuel Thibault <samuel.thibault@ens-lyon.org>
* commands/i386/pc/play.c (T_REST, T_FINE, struct note, beep_on): Use
grub_uint16_t instead of short.
(grub_cmd_play): Use grub_uint32_t instead of int, convert data from
disk from little endian to cpu endianness.
2010-02-07 Samuel Thibault <samuel.thibault@ens-lyon.org>
* commands/i386/pc/play.c (BASE_TEMPO): Set to 60 *
GRUB_TICKS_PER_SECOND instead of 120.
2010-02-14 Vladimir Serbinenko <phcoder@gmail.com>
* term/ieee1275/ofconsole.c (grub_ofconsole_readkey): Wait for possible
escape sequence after \e.
2010-02-14 Vladimir Serbinenko <phcoder@gmail.com>
* term/ieee1275/ofconsole.c (grub_ofconsole_putchar): Don't output
non-ASCII characters.
2010-02-14 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Enclose
set root in single quotes to prevent \, from being unescaped.
2010-02-14 Vladimir Serbinenko <phcoder@gmail.com>
Prevent unknown commands from stopping menuentry execution.
* script/execute.c (grub_script_execute_cmdline): Print error after
unknown command.
2010-02-14 Vladimir Serbinenko <phcoder@gmail.com>
* fs/i386/pc/pxe.c (GRUB_MOD_INIT): Fix typo.
Reported by: Pavel Pisa.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
* io/gzio.c (grub_gzio_open): Use grub_zalloc.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
Merge grub_ieee1275_map_physical into grub_map and rename to
grub_ieee1275_map
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_map): New proto.
* include/grub/sparc64/ieee1275/ieee1275.h (grub_ieee1275_map_physical):
Remove.
* kern/ieee1275/openfw.c (grub_map): Rename to ...
(grub_ieee1275_map): ... this. All users updated. Add phys_lo when
necessary.
* kern/sparc64/ieee1275/ieee1275.c (grub_ieee1275_map_physical): Remove.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
* disk/ieee1275/ofdisk.c (grub_ofdisk_open): Check device type before
opening and not after.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
* term/ieee1275/ofconsole.c (grub_ofconsole_readkey): Macroify
constants.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
* loader/sparc64/ieee1275/linux.c (align_addr): Remove.
(alloc_phys): Use ALIGN_UP instead of align_addr.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
* loader/sparc64/ieee1275/linux.c (alloc_phys): Correct bounds checking.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
* kern/sparc64/ieee1275/crt0.S (codestart): Move modules backwards.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
* disk/ieee1275/ofdisk.c (grub_ofdisk_read): Remove excessively
verbose dprintf.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
Fix over-4GiB seek on sparc64.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_seek):
Replace pos_i and pos_lo with pos. All users updated.
* include/grub/powerpc/ieee1275/ieee1275.h (GRUB_IEEE1275_CELL_SIZEOF):
New constant.
* include/grub/sparc64/ieee1275/ieee1275.h (GRUB_IEEE1275_CELL_SIZEOF):
Likewise.
* kern/ieee1275/ieee1275.c (grub_ieee1275_seek): Split pos into pos_hi
and pos_lo.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkrawimage.c (main): Call set_program_name.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
Properly align 64-bit targets.
* util/grub-mkrawimage.c (ALIGN_ADDR): New macro.
(generate_image): Use ALIGN_ADDR.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
Properly create cross-endian images.
* include/grub/types.h (grub_host_to_target_addr): New macro
* util/grub-mkrawimage.c (generate_image): Add missing host_to_target.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkrawimage.c (generate_image): Add forgotten ALIGN_UP.
2010-02-10 Vladimir Serbinenko <phcoder@gmail.com>
Pass SIMPLE framebuffer size in bytes and not 64K blocks.
* loader/i386/efi/linux.c (grub_linux_setup_video): Don't divide by 64K.
* loader/i386/linux.c (grub_linux_setup_video): Likewise.
(grub_linux_boot): Divide by 64K when on VESA.
2010-02-10 Vladimir Serbinenko <phcoder@gmail.com>
Support GRUB_GFXPAYLOAD_LINUX.
* util/grub-mkconfig.in: Export GRUB_GFXPAYLOAD_LINUX.
* util/grub.d/10_linux.in (linux_entry): Handle GRUB_GFXPAYLOAD_LINUX.
2010-02-10 Vladimir Serbinenko <phcoder@gmail.com>
* script/execute.c (grub_script_execute_cmdline): Use grub_print_error
to show messages instead of discarding them.
Process errors after executing command and not before. Keep old method
too as precaution.
2010-02-09 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Check for ft2build.h.
2010-02-07 Vladimir Serbinenko <phcoder@gmail.com>
* kern/ieee1275/openfw.c (grub_halt): Try executing "poweroff".
2010-02-07 Vladimir Serbinenko <phcoder@gmail.com>
* genkernsyms.sh.in: Use TARGET_CC.

View File

@ -14,6 +14,7 @@ configuring the GRUB.
* GCC 4.1.3 or later
* GNU Make
* GNU Bison 2.3 or later
* GNU gettext 0.17 or later
* GNU binutils 2.9.1.0.23 or later
* Other standard GNU/Unix tools
@ -25,6 +26,10 @@ need the following.
* Autoconf 2.60 or later
* Automake 1.10.1 or later
Prerequisites for make-check:
* qemu, specifically the binary 'qemu-system-i386'
Configuring the GRUB
====================

View File

@ -89,10 +89,8 @@ TARGET_ASFLAGS = @TARGET_ASFLAGS@
TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
TARGET_APPLE_CC = @TARGET_APPLE_CC@
OBJCONV = @OBJCONV@
TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(srcdir)/include -I$(builddir) -I$(builddir)/include -Wall -W
ifneq ($(platform), emu)
TARGET_CPPFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include)
endif
TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
-Wall -W
TARGET_LDFLAGS = @TARGET_LDFLAGS@
TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
TARGET_IMG_LDFLAGS = @TARGET_IMG_LDFLAGS@
@ -149,7 +147,7 @@ INFOS = $(info_INFOS)
CLEANFILES =
MOSTLYCLEANFILES =
DISTCLEANFILES = config.status config.cache config.log config.h \
Makefile stamp-h include/grub/cpu include/grub/machine \
Makefile stamp-h stamp-h1 include/grub/cpu include/grub/machine \
gensymlist.sh genkernsyms.sh build_env.mk \
docs/grub.info docs/version.texi docs/stamp-vti
@ -243,6 +241,7 @@ else
ifeq ($(enable_grub_mkfont),yes)
pkgdata_DATA += unicode.pf2 ascii.pf2 ascii.h
CLEANFILES += ascii.bitmaps
# Arrows and lines are needed to draw the menu, so we always include them
UNICODE_ARROWS=0x2190-0x2193

4
NEWS
View File

@ -1,4 +1,6 @@
New in 1.98:
New in 1.98 - 2010-03-06:
* Multiboot on EFI support.
* Graphical menu support.

View File

@ -118,7 +118,7 @@ prom_call:
boot_continue:
mov %o7, PIC_REG /* PIC base */
sethi %hi(SCRATCH_PAD), %l1 /* OF argument slots */
sethi %hi(SCRATCH_PAD_BOOT), %l1 /* OF argument slots */
/* Find the /chosen node so we can fetch the stdout handle,
* and thus perform console output.

View File

@ -81,7 +81,7 @@ prom_call:
after_info_block:
sethi %hi(SCRATCH_PAD), %l1 /* OF argument slots */
sethi %hi(SCRATCH_PAD_DISKBOOT), %l1 /* OF argument slots */
GET_ABS(notification_string, %o2)
call console_write
@ -129,7 +129,7 @@ bootit:
mov NOTIFICATION_DONE_LEN, %o3
sethi %hi(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o2
jmpl %o2 + %lo(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o7
mov CIF_REG, %o0
mov CIF_REG, %o4
1: ba,a 1b
lastlist:

View File

@ -41,7 +41,7 @@ grub_cmd_cat (grub_command_t cmd __attribute__ ((unused)),
file = grub_gzfile_open (args[0], 1);
if (! file)
return 0;
return grub_errno;
while ((size = grub_file_read (file, buf, sizeof (buf))) > 0
&& key != GRUB_TERM_ESC)

View File

@ -29,7 +29,7 @@
#include <grub/command.h>
#include <grub/i18n.h>
#define BASE_TEMPO 120
#define BASE_TEMPO (60 * GRUB_TICKS_PER_SECOND)
/* The speaker port. */
#define SPEAKER 0x61
@ -101,13 +101,13 @@
#define PIT_CTRL_COUNT_BINARY 0x00 /* 16-bit binary counter. */
#define PIT_CTRL_COUNT_BCD 0x01 /* 4-decade BCD counter. */
#define T_REST ((short) 0)
#define T_FINE ((short) -1)
#define T_REST ((grub_uint16_t) 0)
#define T_FINE ((grub_uint16_t) -1)
struct note
{
short pitch;
short duration;
grub_uint16_t pitch;
grub_uint16_t duration;
};
static void
@ -120,7 +120,7 @@ beep_off (void)
}
static void
beep_on (short pitch)
beep_on (grub_uint16_t pitch)
{
unsigned char status;
unsigned int counter;
@ -143,60 +143,111 @@ beep_on (short pitch)
grub_outb (status | SPEAKER_TMR2 | SPEAKER_DATA, SPEAKER);
}
/* Returns whether playing should continue. */
static int
play (unsigned tempo, struct note *note)
{
unsigned int to;
if (note->pitch == T_FINE || grub_checkkey () >= 0)
return 1;
grub_dprintf ("play", "pitch = %d, duration = %d\n", note->pitch,
note->duration);
switch (note->pitch)
{
case T_REST:
beep_off ();
break;
default:
beep_on (note->pitch);
break;
}
to = grub_get_rtc () + BASE_TEMPO * note->duration / tempo;
while (((unsigned int) grub_get_rtc () <= to) && (grub_checkkey () < 0))
;
return 0;
}
static grub_err_t
grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
int argc, char **args)
{
grub_file_t file;
struct note buf;
int tempo;
unsigned int to;
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name or tempo and notes required");
file = grub_file_open (args[0]);
if (! file)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
if (grub_file_read (file, &tempo, sizeof(tempo)) != sizeof(tempo))
if (file)
{
grub_file_close (file);
return grub_error (GRUB_ERR_FILE_READ_ERROR,
"file doesn't even contains a full tempo record");
}
struct note buf;
grub_uint32_t tempo;
grub_dprintf ("play","tempo = %d\n", tempo);
while (grub_file_read (file, &buf,
sizeof (struct note)) == sizeof (struct note)
&& buf.pitch != T_FINE && grub_checkkey () < 0)
{
grub_dprintf ("play", "pitch = %d, duration = %d\n", buf.pitch,
buf.duration);
switch (buf.pitch)
if (grub_file_read (file, &tempo, sizeof (tempo)) != sizeof (tempo))
{
case T_REST:
beep_off ();
break;
grub_file_close (file);
return grub_error (GRUB_ERR_FILE_READ_ERROR,
"file doesn't even contains a full tempo record");
}
default:
beep_on (buf.pitch);
tempo = grub_le_to_cpu32 (tempo);
grub_dprintf ("play","tempo = %d\n", tempo);
while (grub_file_read (file, &buf,
sizeof (struct note)) == sizeof (struct note))
{
buf.pitch = grub_le_to_cpu16 (buf.pitch);
buf.duration = grub_le_to_cpu16 (buf.duration);
if (play (tempo, &buf))
break;
}
to = grub_get_rtc () + BASE_TEMPO * buf.duration / tempo;
while (((unsigned int) grub_get_rtc () <= to) && (grub_checkkey () < 0))
;
grub_file_close (file);
}
else
{
char *end;
unsigned tempo;
struct note note;
int i;
tempo = grub_strtoul (args[0], &end, 0);
if (*end)
/* Was not a number either, assume it was supposed to be a file name. */
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found");
grub_dprintf ("play","tempo = %d\n", tempo);
for (i = 1; i + 1 < argc; i += 2)
{
note.pitch = grub_strtoul (args[i], &end, 0);
if (*end)
{
grub_error (GRUB_ERR_BAD_NUMBER, "bogus pitch number");
break;
}
note.duration = grub_strtoul (args[i + 1], &end, 0);
if (*end)
{
grub_error (GRUB_ERR_BAD_NUMBER, "bogus duration number");
break;
}
if (play (tempo, &note))
break;
}
}
beep_off ();
grub_file_close (file);
while (grub_checkkey () > 0)
grub_getkey ();
@ -208,7 +259,8 @@ static grub_command_t cmd;
GRUB_MOD_INIT(play)
{
cmd = grub_register_command ("play", grub_cmd_play,
N_("FILE"), N_("Play a tune."));
N_("FILE | TEMPO [PITCH1 DURATION1] [PITCH2 DURATION2] ... "),
N_("Play a tune."));
}
GRUB_MOD_FINI(play)

View File

@ -24,6 +24,7 @@
#include <grub/term.h>
#include <grub/machine/init.h>
#include <grub/machine/vbe.h>
#include <grub/video.h>
#include <grub/err.h>
#include <grub/i18n.h>

View File

@ -69,9 +69,9 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
color = grub_video_map_rgb (0, 255, 255);
grub_video_fill_rect (color, 100, 100, 100, 100);
sansbig = grub_font_get ("Helvetica Bold 24");
sans = grub_font_get ("Helvetica Bold 14");
sanssmall = grub_font_get ("Helvetica 8");
sansbig = grub_font_get ("Unknown Regular 16");
sans = grub_font_get ("Unknown Regular 16");
sanssmall = grub_font_get ("Unknown Regular 16");
fixed = grub_font_get ("Fixed 20");
if (! sansbig || ! sans || ! sanssmall || ! fixed)
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
@ -126,11 +126,6 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
grub_font_draw_string (str, fixed, color, 16, texty);
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
/* Some character don't exist in the Helvetica font, so the font engine
will fall back to using glyphs from another font that does contain them.
TODO The font engine should be smart about selecting a replacement font
and prioritize fonts with similar sizes. */
texty += grub_font_get_ascent(sansbig);
grub_font_draw_string (str, sansbig, color, 16, texty);
texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig);

View File

@ -621,26 +621,28 @@ sh_mod_SOURCES = script/main.c script/script.c script/execute.c \
sh_mod_CFLAGS = $(COMMON_CFLAGS)
sh_mod_LDFLAGS = $(COMMON_LDFLAGS)
ifneq (, $(FONT_SOURCE))
font/font.c_DEPENDENCIES = ascii.h
endif
# Common Video Subsystem specific modules.
pkglib_MODULES += video.mod videotest.mod bitmap.mod tga.mod jpeg.mod \
png.mod gfxterm.mod video_fb.mod
# On Yeeloong it's part of kernel
ifneq ($(platform), yeeloong)
# For video.mod.
pkglib_MODULES += video.mod
video_mod_SOURCES = video/video.c
video_mod_CFLAGS = $(COMMON_CFLAGS)
video_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += video_fb.mod
video_fb_mod_SOURCES = video/fb/video_fb.c video/fb/fbblit.c \
video/fb/fbfill.c video/fb/fbutil.c
video_fb_mod_CFLAGS = $(COMMON_CFLAGS)
video_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For videotest.mod.
videotest_mod_SOURCES = commands/videotest.c
videotest_mod_CFLAGS = $(COMMON_CFLAGS)
videotest_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For bitmap.mod
pkglib_MODULES += bitmap.mod
bitmap_mod_SOURCES = video/bitmap.c
bitmap_mod_CFLAGS = $(COMMON_CFLAGS)
bitmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
@ -651,36 +653,46 @@ bitmap_scale_mod_SOURCES = video/bitmap_scale.c
bitmap_scale_mod_CFLAGS = $(COMMON_CFLAGS)
bitmap_scale_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For tga.mod
tga_mod_SOURCES = video/readers/tga.c
tga_mod_CFLAGS = $(COMMON_CFLAGS)
tga_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For jpeg.mod.
jpeg_mod_SOURCES = video/readers/jpeg.c
jpeg_mod_CFLAGS = $(COMMON_CFLAGS)
jpeg_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For png.mod.
png_mod_SOURCES = video/readers/png.c
png_mod_CFLAGS = $(COMMON_CFLAGS)
png_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += font.mod
ifneq (, $(FONT_SOURCE))
font/font.c_DEPENDENCIES = ascii.h
endif
font_mod_SOURCES = font/font_cmd.c font/font.c
font_mod_CFLAGS = $(COMMON_CFLAGS)
font_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For gfxterm.mod.
pkglib_MODULES += gfxterm.mod
gfxterm_mod_SOURCES = term/gfxterm.c
gfxterm_mod_CFLAGS = $(COMMON_CFLAGS)
gfxterm_mod_LDFLAGS = $(COMMON_LDFLAGS)
endif
# For videotest.mod.
pkglib_MODULES += videotest.mod
videotest_mod_SOURCES = commands/videotest.c
videotest_mod_CFLAGS = $(COMMON_CFLAGS)
videotest_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For tga.mod
pkglib_MODULES += tga.mod
tga_mod_SOURCES = video/readers/tga.c
tga_mod_CFLAGS = $(COMMON_CFLAGS)
tga_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For jpeg.mod.
pkglib_MODULES += jpeg.mod
jpeg_mod_SOURCES = video/readers/jpeg.c
jpeg_mod_CFLAGS = $(COMMON_CFLAGS)
jpeg_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For png.mod.
pkglib_MODULES += png.mod
png_mod_SOURCES = video/readers/png.c
png_mod_CFLAGS = $(COMMON_CFLAGS)
png_mod_LDFLAGS = $(COMMON_LDFLAGS)
# Misc.
pkglib_MODULES += gzio.mod bufio.mod elf.mod
pkglib_MODULES += gzio.mod elf.mod
# For elf.mod.
elf_mod_SOURCES = kern/elf.c
@ -692,10 +704,14 @@ gzio_mod_SOURCES = io/gzio.c
gzio_mod_CFLAGS = $(COMMON_CFLAGS)
gzio_mod_LDFLAGS = $(COMMON_LDFLAGS)
# On Yeeloong it's part of kernel
ifneq ($(platform), yeeloong)
# For bufio.mod.
pkglib_MODULES += bufio.mod
bufio_mod_SOURCES = io/bufio.c
bufio_mod_CFLAGS = $(COMMON_CFLAGS)
bufio_mod_LDFLAGS = $(COMMON_LDFLAGS)
endif
# For gettext.mod.
pkglib_MODULES += gettext.mod

View File

@ -3,6 +3,9 @@ LINK_BASE = 0x80200000
target_machine=yeeloong
COMMON_CFLAGS += -march=mips3
COMMON_ASFLAGS += -march=mips3
kernel_img_HEADERS += bitmap.h video.h gfxterm.h font.h bitmap_scale.h bufio.h
include $(srcdir)/conf/mips.mk
pkglib_IMAGES = kernel.img
@ -73,6 +76,11 @@ datehook_mod_SOURCES = hook/datehook.c
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += linux.mod
linux_mod_SOURCES = loader/$(target_cpu)/linux.c
linux_mod_CFLAGS = $(COMMON_CFLAGS)
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
sbin_SCRIPTS += grub-install
grub_install_SOURCES = util/grub-install.in

View File

@ -13,7 +13,7 @@ script/lexer.c_DEPENDENCIES = grub_script.tab.h
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
DEFSYMFILES += kernel_syms.lst
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
kernel_img_HEADERS += boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
env.h err.h file.h fs.h kernel.h misc.h mm.h net.h parser.h reader.h \
symbol.h term.h time.h types.h loader.h partition.h \
msdos_partition.h machine/kernel.h handler.h list.h \
@ -73,10 +73,4 @@ relocator_mod_CFLAGS = $(COMMON_CFLAGS)
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += linux.mod
linux_mod_SOURCES = loader/$(target_cpu)/linux.c
linux_mod_CFLAGS = $(COMMON_CFLAGS)
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
include $(srcdir)/conf/common.mk

View File

@ -70,6 +70,11 @@ boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c
boot_mod_CFLAGS = $(COMMON_CFLAGS)
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += ieee1275_fb.mod
ieee1275_fb_mod_SOURCES = video/ieee1275.c
ieee1275_fb_mod_CFLAGS = $(COMMON_CFLAGS)
ieee1275_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For linux.mod.
linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c
linux_mod_CFLAGS = $(COMMON_CFLAGS)
@ -100,4 +105,21 @@ lsmmap_mod_SOURCES = commands/lsmmap.c
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += datetime.mod date.mod datehook.mod
# For datetime.mod
datetime_mod_SOURCES = lib/ieee1275/datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For date.mod
date_mod_SOURCES = commands/date.c
date_mod_CFLAGS = $(COMMON_CFLAGS)
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For datehook.mod
datehook_mod_SOURCES = hook/datehook.c
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
include $(srcdir)/conf/common.mk

View File

@ -48,7 +48,7 @@ kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
symlist.c kern/$(target_cpu)/cache.S
kernel_img_CFLAGS = $(COMMON_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic,-melf64_sparc -static-libgcc -lgcc
kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,0x4400,-Bstatic,-melf64_sparc -static-libgcc -lgcc
kernel_img_FORMAT = binary
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
@ -62,7 +62,7 @@ bin_UTILITIES = grub-mkimage
sbin_UTILITIES = grub-setup grub-ofpathname
# For grub-mkimage.
grub_mkimage_SOURCES = util/sparc64/ieee1275/grub-mkimage.c util/misc.c \
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
util/resolve.c gnulib/progname.c
# For grub-setup.
@ -133,4 +133,21 @@ lsmmap_mod_SOURCES = commands/lsmmap.c
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += datetime.mod date.mod datehook.mod
# For datetime.mod
datetime_mod_SOURCES = lib/ieee1275/datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For date.mod
date_mod_SOURCES = commands/date.c
date_mod_CFLAGS = $(COMMON_CFLAGS)
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For datehook.mod
datehook_mod_SOURCES = hook/datehook.c
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
include $(srcdir)/conf/common.mk

View File

@ -31,7 +31,7 @@ dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
dnl type.
AC_INIT([GRUB],[1.97],[bug-grub@gnu.org])
AC_INIT([GRUB],[1.98],[bug-grub@gnu.org])
AM_INIT_AUTOMAKE()
AC_PREREQ(2.60)
AC_CONFIG_SRCDIR([include/grub/dl.h])
@ -51,6 +51,7 @@ fi
case "$target_cpu" in
i[[3456]]86) target_cpu=i386 ;;
amd64) target_cpu=x86_64 ;;
sparc) target_cpu=sparc64 ;;
mipsel|mips64el)
target_cpu=mips;
@ -139,9 +140,14 @@ case "$platform" in
qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
esac
case "$target_cpu" in
mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;;
sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
esac
CFLAGS="$CFLAGS $machine_CFLAGS"
TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
@ -517,6 +523,21 @@ enable_efiemu=no
fi
AC_SUBST([enable_efiemu])
if test "$platform" != emu; then
AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
SAVED_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
int va_arg_func (int fixed, va_list args);]], [[]])],
[grub_cv_cc_isystem=yes],
[grub_cv_cc_isystem=no])
CPPFLAGS="$SAVED_CPPFLAGS"
])
if test x"$grub_cv_cc_isystem" = xyes ; then
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
fi
fi
# Restore the flags.
CC="$tmp_CC"
@ -680,6 +701,16 @@ if test x"$grub_mkfont_excuse" = x ; then
freetype_cflags=`freetype-config --cflags`
freetype_libs=`freetype-config --libs`
fi
if test x"$grub_mkfont_excuse" = x ; then
# Check for freetype libraries.
SAVED_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $freetype_cflags"
AC_CHECK_HEADERS([ft2build.h], [],
[grub_mkfont_excuse=["need freetype2 headers"]])
CPPFLAGS="$SAVED_CPPFLAGS"
fi
if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
fi

View File

@ -825,7 +825,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
if (! disk)
return 1;
if (disk->id == GRUB_DISK_DEVICE_EFIDISK_ID)
if (disk->dev->id == GRUB_DISK_DEVICE_EFIDISK_ID)
{
struct grub_efidisk_data *d;

View File

@ -172,16 +172,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
grub_dprintf ("disk", "Opening `%s'.\n", op->devpath);
grub_ieee1275_open (op->devpath, &dev_ihandle);
if (! dev_ihandle)
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
goto fail;
}
grub_dprintf ("disk", "Opened `%s' as handle %p.\n", op->devpath,
(void *) (unsigned long) dev_ihandle);
if (grub_ieee1275_finddevice (op->devpath, &dev))
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't read device properties");
@ -201,6 +191,16 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
goto fail;
}
grub_ieee1275_open (op->devpath, &dev_ihandle);
if (! dev_ihandle)
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
goto fail;
}
grub_dprintf ("disk", "Opened `%s' as handle %p.\n", op->devpath,
(void *) (unsigned long) dev_ihandle);
/* XXX: There is no property to read the number of blocks. There
should be a property `#blocks', but it is not there. Perhaps it
is possible to use seek for this. */
@ -234,14 +234,10 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_ssize_t status, actual;
unsigned long long pos;
grub_dprintf ("disk",
"Reading handle %p: sector 0x%llx, size 0x%lx, buf %p.\n",
(void *) disk->data, (long long) sector, (long) size, buf);
pos = sector * 512UL;
grub_ieee1275_seek ((grub_ieee1275_ihandle_t) (unsigned long) disk->data,
(int) (pos >> 32), (int) pos & 0xFFFFFFFFUL, &status);
pos, &status);
if (status < 0)
return grub_error (GRUB_ERR_READ_ERROR,
"seek error, can't seek block %llu",

View File

@ -208,12 +208,14 @@ grub_scsi_iterate (int (*hook) (const char *name))
for (i = 0; i < luns; i++)
{
char *sname;
int ret;
sname = grub_xasprintf ("%s%c", name, 'a' + i);
if (!sname)
return 1;
if (hook (sname))
return 1;
ret = hook (sname);
grub_free (sname);
if (ret)
return 1;
}
return 0;
}

View File

@ -1,128 +0,0 @@
# GRUB gfxmenu theme "winter".
# Uses background image from:
# http://www.cyberpunkcafe.com/e107_plugins/autogallery/autogallery.php?show=1.Open%20Source%20Wallpaper
# "without-leaves.png" was called "Without Leafs in Winter.png"
lua-script: "winter.lua"
title-text: ""
title-font: "Helvetica Bold 18"
status-font: "Helvetica 8"
terminal-font: "Fixed 9"
title-color: "40, 40, 40"
status-color: "#FFF"
status-bg-color: "0, 166, 183, 128"
desktop-image: "without-leaves.png"
desktop-color: "0, 154, 183"
terminal-box: "terminal_*.png"
+ boot_menu {
position = (120, 60)
preferred_size = (400, -1)
item_font = "Helvetica Bold 14"
selected_item_font = "Helvetica Bold 14"
item_color = "0, 0, 0"
selected_item_color = "203, 251, 255"
menu_pixmap_style = "menu_*.png"
selected_item_pixmap_style = "select_*.png"
icon_width = 44
icon_height = 44
item_height = 32
item_padding = 0
item_icon_space = 3
item_spacing = 11
}
# You can add text at arbitrary locations on the screen.
# The specification within the "+label {...}" block is free-form,
# so you can use as much or as little white space as you like.
+ label {
position = (170, 50)
font = "smoothansi 13"
color = "0,0,128"
text = "This is the Winter theme ... brought to you by GRUB!"
}
# Show the text alignment supported by labels.
+ vbox {
position = (220, 347)
preferred_size = (200, -1) # A preferred size of -1 means automatic.
+ label { text="Text alignment demo" align="center" font="aqui 11" }
+ label { text="Left" align="left" font="cure 11" }
+ label { text="Center" align="center" font="cure 11" }
+ label { text="Right" align="right" font="cure 11" }
}
+ vbox {
position = (580, 10)
+ label { text="GNU" font="gelly 11" color="0, 0, 0" }
+ label { text="GRUB" font="aqui 11" color="0, 0, 0" }
+ label { text="boot loader" font="cure 11" color="0, 0, 0" }
}
+ hbox {
position = (80, 10)
+ label { text="GNU" font="gelly 11" color="0, 0, 0" }
+ label { text="GRUB" font="aqui 11" color="0, 0, 0" }
+ label { text="boot loader" font="cure 11" color="0, 0, 0" }
}
# Demonstration of a compound layout: boxes within boxes.
+ hbox
{
position = (480, 3)
+ vbox
{
# Note: We can't just use 'size' to set the image's size,
# since the vbox will resize the component according to its
# preferred size, which for images is the native image size.
+ image { file="/boot/grub/themes/icons/ubuntu.png"
preferred_size = (20, 20) }
+ image { file="/boot/grub/themes/icons/gentoo.png"
preferred_size = (20, 20) }
}
+ vbox
{
+ label { text="GRand" font="cure 11" color=#99F }
+ label { text="Unified" font="cure 11" color=#BBF }
+ label { text="Bootloader" font="cure 11" color=#DDF }
}
}
# By defining a 'progress_bar' type component with an ID of '__timeout__',
# the progress bar will be used to display the time remaining before an
# the default entry is automatically booted.
+ progress_bar
{
id = "__timeout__"
position = (80, 393)
preferred_size = (500, 24)
font = "cure 11"
text_color = #000
fg_color = #CCF
bg_color = #66B
border_color = #006
show_text = false
}
# Although the progress_bar component is normally used to indicate the
# time remaining, it's also possible to create other components with an ID
# of '__timeout__'. All components with and ID of 'timeout_bar' will have
# the following properties set based on the timeout value:
# text, value, start, end, visible.
# In this case, we have set 'show_text=false' on the progress bar, and use
# the following label's 'text' property to display the message.
+ label
{
id = "__timeout__"
position = (80, 420)
preferred_size = (500, 24)
font = "lime 11"
color = #117
align = "center"
}

View File

@ -1126,6 +1126,7 @@ you forget a command, you can run the command @command{help}
* insmod:: Insert a module
* keystatus:: Check key modifier status
* ls:: List devices or files
* play:: Play a tune
* reboot:: Reboot your computer
* set:: Set an environment variable
* unset:: Unset an environment variable
@ -1364,6 +1365,24 @@ name syntax}), then list the contents of that directory.
@end deffn
@node play
@subsection play
@deffn Command play file | tempo [pitch1 duration1] [pitch2 duration2] ...
Plays a tune
If the argument is a file name (@pxref{File name syntax}), play the tune
recorded in it. The file format is first the tempo as an unsigned 32bit
little-endian number, then pairs of unsigned 16bit little-endian numbers for
pitch and duration pairs.
If the arguments are a series of numbers, play the inline tune.
The tempo is the base for all note durations. 60 gives a 1-second base, 120
gives a half-second base, etc. Pitches are Hz.
@end deffn
@node reboot
@subsection reboot

View File

@ -862,7 +862,7 @@ grub_font_get (const char *font_name)
return &null_font;
}
/* Get the full name of the font. For instance, "Helvetica Bold 12". */
/* Get the full name of the font. */
const char *
grub_font_get_name (grub_font_t font)
{

View File

@ -436,7 +436,8 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
grub_uint32_t indir[blksz / 4];
if (grub_disk_read (data->disk,
grub_le_to_cpu32 (inode->blocks.indir_block)
((grub_disk_addr_t)
grub_le_to_cpu32 (inode->blocks.indir_block))
<< log2_blksz,
0, blksz, indir))
return grub_errno;
@ -452,13 +453,15 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
grub_uint32_t indir[blksz / 4];
if (grub_disk_read (data->disk,
grub_le_to_cpu32 (inode->blocks.double_indir_block)
((grub_disk_addr_t)
grub_le_to_cpu32 (inode->blocks.double_indir_block))
<< log2_blksz,
0, blksz, indir))
return grub_errno;
if (grub_disk_read (data->disk,
grub_le_to_cpu32 (indir[rblock / perblock])
((grub_disk_addr_t)
grub_le_to_cpu32 (indir[rblock / perblock]))
<< log2_blksz,
0, blksz, indir))
return grub_errno;

View File

@ -568,21 +568,21 @@ GRUB_MOD_INIT(pxe)
buf = grub_xasprintf ("%d", grub_pxe_blksize);
if (buf)
grub_env_set ("net_pxe_blksize", buf);
grub_env_set ("pxe_blksize", buf);
grub_free (buf);
set_ip_env ("pxe_default_server", grub_pxe_default_server_ip);
set_ip_env ("pxe_default_gateway", grub_pxe_default_gateway_ip);
set_ip_env ("net_pxe_ip", grub_pxe_your_ip);
grub_register_variable_hook ("net_pxe_default_server", 0,
grub_register_variable_hook ("pxe_default_server", 0,
grub_env_write_pxe_default_server);
grub_register_variable_hook ("net_pxe_default_gateway", 0,
grub_register_variable_hook ("pxe_default_gateway", 0,
grub_env_write_pxe_default_gateway);
/* XXX: Is it possible to change IP in PXE? */
grub_register_variable_hook ("net_pxe_ip", 0,
grub_env_write_readonly);
grub_register_variable_hook ("net_pxe_blksize", 0,
grub_register_variable_hook ("pxe_blksize", 0,
grub_env_write_pxe_blocksize);
grub_disk_dev_register (&grub_pxe_dev);
grub_fs_register (&grub_pxefs_fs);

View File

@ -629,12 +629,16 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
if (dir->data->joliet)
{
char *oldname;
char *oldname, *semicolon;
oldname = filename;
filename = grub_iso9660_convert_string
((grub_uint16_t *) oldname, dirent.namelen >> 1);
semicolon = grub_strrchr (filename, ';');
if (semicolon)
*semicolon = '\0';
if (filename_alloc)
grub_free (oldname);

View File

@ -209,7 +209,7 @@ endif
-include #{dep}
clean-module-#{extra_target}.#{@rule_count}:
rm -f #{command} #{fs} #{partmap} #{handler} #{parttool} #{video}
rm -f #{command} #{fs} #{partmap} #{handler} #{parttool} #{video} #{terminal}
CLEAN_MODULE_TARGETS += clean-module-#{extra_target}.#{@rule_count}

View File

@ -32,13 +32,12 @@ FNR == 1 {
else if ($1 != "__gnu_local_gp") {
printf "%s in %s is not defined\n", $1, module >"/dev/stderr";
error++;
exit;
}
}
# Output the result.
END {
if (error == 1)
if (error >= 1)
exit 1;
for (mod in modtab) {

View File

@ -14,7 +14,7 @@
### The configure script will replace these variables.
: ${srcdir=@srcdir@}
: ${CC=@CC@}
: ${CC=@TARGET_CC@}
cat <<EOF

View File

@ -279,13 +279,6 @@ grub_gettext_init_ext (const char *lang)
/* mo_file e.g.: /boot/grub/locale/ca.mo */
mo_file =
grub_malloc (grub_strlen (locale_dir) + grub_strlen ("/") +
grub_strlen (lang) + grub_strlen (".mo") + 1);
/* Warning: if changing some paths in the below line, change the grub_malloc
contents below. */
mo_file = grub_xasprintf ("%s/%s.mo", locale_dir, lang);
if (!mo_file)
return;

View File

@ -31,6 +31,7 @@ struct grub_gui_image
grub_gui_container_t parent;
grub_video_rect_t bounds;
char *id;
char *theme_dir;
struct grub_video_bitmap *raw_bitmap;
struct grub_video_bitmap *bitmap;
};
@ -208,8 +209,28 @@ static grub_err_t
image_set_property (void *vself, const char *name, const char *value)
{
grub_gui_image_t self = vself;
if (grub_strcmp (name, "file") == 0)
return load_image (self, value);
if (grub_strcmp (name, "theme_dir") == 0)
{
grub_free (self->theme_dir);
self->theme_dir = grub_strdup (value);
}
else if (grub_strcmp (name, "file") == 0)
{
char *absvalue;
grub_err_t err;
/* Resolve to an absolute path. */
if (! self->theme_dir)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unspecified theme_dir");
absvalue = grub_resolve_relative_path (self->theme_dir, value);
if (! absvalue)
return grub_errno;
err = load_image (self, absvalue);
grub_free (absvalue);
return err;
}
else if (grub_strcmp (name, "id") == 0)
{
grub_free (self->id);

View File

@ -216,7 +216,7 @@ grub_gui_label_new (void)
label->comp.ops = &label_ops;
label->visible = 1;
label->text = grub_strdup ("");
label->font = grub_font_get ("Helvetica 10");
label->font = grub_font_get ("Unknown Regular 16");
label->color.red = 0;
label->color.green = 0;
label->color.blue = 0;

View File

@ -566,7 +566,7 @@ grub_gui_list_new (void)
self->visible = 1;
default_font = grub_font_get ("Helvetica 12");
default_font = grub_font_get ("Unknown Regular 16");
default_fg_color = grub_gui_color_rgb (0, 0, 0);
default_bg_color = grub_gui_color_rgb (255, 255, 255);

View File

@ -371,7 +371,7 @@ grub_gui_progress_bar_new (void)
self->progress.ops = &progress_bar_pb_ops;
self->progress.component.ops = &progress_bar_ops;
self->visible = 1;
self->font = grub_font_get ("Helvetica 10");
self->font = grub_font_get ("Unknown Regular 16");
grub_gui_color_t black = { .red = 0, .green = 0, .blue = 0, .alpha = 255 };
grub_gui_color_t gray = { .red = 128, .green = 128, .blue = 128, .alpha = 255 };
grub_gui_color_t lightgray = { .red = 200, .green = 200, .blue = 200, .alpha = 255 };

View File

@ -66,7 +66,7 @@ grub_gfxmenu_view_new (const char *theme_path,
view->screen.width = width;
view->screen.height = height;
default_font = grub_font_get ("Helvetica 12");
default_font = grub_font_get ("Unknown Regular 16");
default_fg_color = grub_gui_color_rgb (0, 0, 0);
default_bg_color = grub_gui_color_rgb (255, 255, 255);

View File

@ -102,6 +102,7 @@ union grub_aout_header
#define AOUT_MID_I386 134 /* i386 BSD binary */
#define AOUT_MID_SPARC 138 /* sparc */
#define AOUT_MID_HP200 200 /* hp200 (68010) BSD binary */
#define AOUT_MID_SUN 0x103
#define AOUT_MID_HP300 300 /* hp300 (68020+68881) BSD binary */
#define AOUT_MID_HPUX 0x20C /* hp200/300 HP-UX binary */
#define AOUT_MID_HPUX800 0x20B /* hp800 HP-UX binary */
@ -114,10 +115,14 @@ union grub_aout_header
#define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
#define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
#ifndef GRUB_UTIL
int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
grub_addr_t load_addr, int load_size,
grub_addr_t bss_end_addr);
#endif
#endif /* ! GRUB_AOUT_HEADER */

View File

@ -47,24 +47,24 @@ struct grub_video_bitmap_reader
};
typedef struct grub_video_bitmap_reader *grub_video_bitmap_reader_t;
void grub_video_bitmap_reader_register (grub_video_bitmap_reader_t reader);
void grub_video_bitmap_reader_unregister (grub_video_bitmap_reader_t reader);
void EXPORT_FUNC (grub_video_bitmap_reader_register) (grub_video_bitmap_reader_t reader);
void EXPORT_FUNC (grub_video_bitmap_reader_unregister) (grub_video_bitmap_reader_t reader);
grub_err_t grub_video_bitmap_create (struct grub_video_bitmap **bitmap,
unsigned int width, unsigned int height,
enum grub_video_blit_format blit_format);
grub_err_t EXPORT_FUNC (grub_video_bitmap_create) (struct grub_video_bitmap **bitmap,
unsigned int width, unsigned int height,
enum grub_video_blit_format blit_format);
grub_err_t grub_video_bitmap_destroy (struct grub_video_bitmap *bitmap);
grub_err_t EXPORT_FUNC (grub_video_bitmap_destroy) (struct grub_video_bitmap *bitmap);
grub_err_t grub_video_bitmap_load (struct grub_video_bitmap **bitmap,
const char *filename);
grub_err_t EXPORT_FUNC (grub_video_bitmap_load) (struct grub_video_bitmap **bitmap,
const char *filename);
unsigned int grub_video_bitmap_get_width (struct grub_video_bitmap *bitmap);
unsigned int grub_video_bitmap_get_height (struct grub_video_bitmap *bitmap);
unsigned int EXPORT_FUNC (grub_video_bitmap_get_width) (struct grub_video_bitmap *bitmap);
unsigned int EXPORT_FUNC (grub_video_bitmap_get_height) (struct grub_video_bitmap *bitmap);
void grub_video_bitmap_get_mode_info (struct grub_video_bitmap *bitmap,
struct grub_video_mode_info *mode_info);
void EXPORT_FUNC (grub_video_bitmap_get_mode_info) (struct grub_video_bitmap *bitmap,
struct grub_video_mode_info *mode_info);
void *grub_video_bitmap_get_data (struct grub_video_bitmap *bitmap);
void *EXPORT_FUNC (grub_video_bitmap_get_data) (struct grub_video_bitmap *bitmap);
#endif /* ! GRUB_BITMAP_HEADER */

View File

@ -39,10 +39,11 @@ enum grub_video_bitmap_scale_method
};
grub_err_t
grub_video_bitmap_create_scaled (struct grub_video_bitmap **dst,
int dst_width, int dst_height,
struct grub_video_bitmap *src,
enum
grub_video_bitmap_scale_method scale_method);
EXPORT_FUNC (grub_video_bitmap_create_scaled) (struct grub_video_bitmap **dst,
int dst_width, int dst_height,
struct grub_video_bitmap *src,
enum
grub_video_bitmap_scale_method
scale_method);
#endif /* ! GRUB_BITMAP_SCALE_HEADER */

View File

@ -22,7 +22,7 @@
#include <grub/file.h>
grub_file_t grub_bufio_open (grub_file_t io, int size);
grub_file_t grub_buffile_open (const char *name, int size);
grub_file_t EXPORT_FUNC (grub_bufio_open) (grub_file_t io, int size);
grub_file_t EXPORT_FUNC (grub_buffile_open) (const char *name, int size);
#endif /* ! GRUB_BUFIO_H */

View File

@ -81,36 +81,38 @@ int grub_font_load (const char *filename);
"Family Name Bold Italic 14", where Bold and Italic are optional.
If no font matches the name specified, the most recently loaded font
is returned as a fallback. */
grub_font_t grub_font_get (const char *font_name);
grub_font_t EXPORT_FUNC (grub_font_get) (const char *font_name);
const char *grub_font_get_name (grub_font_t font);
const char *EXPORT_FUNC (grub_font_get_name) (grub_font_t font);
int grub_font_get_max_char_width (grub_font_t font);
int EXPORT_FUNC (grub_font_get_max_char_width) (grub_font_t font);
int grub_font_get_max_char_height (grub_font_t font);
int EXPORT_FUNC (grub_font_get_max_char_height) (grub_font_t font);
int grub_font_get_ascent (grub_font_t font);
int EXPORT_FUNC (grub_font_get_ascent) (grub_font_t font);
int grub_font_get_descent (grub_font_t font);
int EXPORT_FUNC (grub_font_get_descent) (grub_font_t font);
int grub_font_get_leading (grub_font_t font);
int EXPORT_FUNC (grub_font_get_leading) (grub_font_t font);
int grub_font_get_height (grub_font_t font);
int EXPORT_FUNC (grub_font_get_height) (grub_font_t font);
int grub_font_get_string_width (grub_font_t font, const char *str);
int EXPORT_FUNC (grub_font_get_string_width) (grub_font_t font,
const char *str);
struct grub_font_glyph *grub_font_get_glyph (grub_font_t font,
grub_uint32_t code);
struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font,
grub_uint32_t code);
struct grub_font_glyph *grub_font_get_glyph_with_fallback (grub_font_t font,
grub_uint32_t code);
struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph_with_fallback) (grub_font_t font,
grub_uint32_t code);
grub_err_t grub_font_draw_glyph (struct grub_font_glyph *glyph,
grub_video_color_t color,
int left_x, int baseline_y);
grub_err_t EXPORT_FUNC (grub_font_draw_glyph) (struct grub_font_glyph *glyph,
grub_video_color_t color,
int left_x, int baseline_y);
grub_err_t grub_font_draw_string (const char *str, grub_font_t font,
grub_video_color_t color,
int left_x, int baseline_y);
grub_err_t EXPORT_FUNC (grub_font_draw_string) (const char *str,
grub_font_t font,
grub_video_color_t color,
int left_x, int baseline_y);
#endif /* ! GRUB_FONT_HEADER */

View File

@ -25,20 +25,20 @@
#include <grub/video.h>
grub_err_t
grub_gfxterm_set_window (struct grub_video_render_target *target,
int x, int y, int width, int height,
int double_repaint,
const char *font_name, int border_width);
EXPORT_FUNC (grub_gfxterm_set_window) (struct grub_video_render_target *target,
int x, int y, int width, int height,
int double_repaint,
const char *font_name, int border_width);
typedef void (*grub_gfxterm_repaint_callback_t)(int x, int y,
int width, int height);
void grub_gfxterm_set_repaint_callback (grub_gfxterm_repaint_callback_t func);
void grub_gfxterm_schedule_repaint (void);
void EXPORT_FUNC (grub_gfxterm_schedule_repaint) (void);
grub_err_t grub_gfxterm_fullscreen (void);
grub_err_t EXPORT_FUNC (grub_gfxterm_fullscreen) (void);
extern void (*grub_gfxterm_decorator_hook) (void);
extern void (*EXPORT_VAR (grub_gfxterm_decorator_hook)) (void);
#endif /* ! GRUB_GFXTERM_HEADER */

View File

@ -19,8 +19,6 @@
#ifndef GRUB_VBE_MACHINE_HEADER
#define GRUB_VBE_MACHINE_HEADER 1
#include <grub/video_fb.h>
/* Default video mode to be used. */
#define GRUB_VBE_DEFAULT_VIDEO_MODE 0x101

View File

@ -138,7 +138,7 @@ int EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle,
void *buffer, grub_size_t len,
grub_ssize_t *actualp);
int EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle,
int pos_hi, int pos_lo,
grub_disk_addr_t pos,
grub_ssize_t *result);
int EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node,
grub_ieee1275_phandle_t *result);
@ -173,7 +173,15 @@ grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
int
EXPORT_FUNC(grub_ieee1275_map) (grub_addr_t phys, grub_addr_t virt,
grub_size_t size, grub_uint32_t mode);
char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path);
char *EXPORT_FUNC(grub_ieee1275_get_filename) (const char *path);
int EXPORT_FUNC(grub_ieee1275_devices_iterate) (int (*hook)
(struct grub_ieee1275_devalias *
alias));
#endif /* ! GRUB_IEEE1275_HEADER */

View File

@ -59,6 +59,8 @@ extern grub_addr_t grub_arch_modules_addr (void);
extern void EXPORT_FUNC(grub_module_iterate) (int (*hook) (struct grub_module_header *));
grub_addr_t grub_modules_get_end (void);
/* The start point of the C code. */
void grub_main (void);

View File

@ -110,4 +110,7 @@ void read_terminal_list (void);
void grub_set_more (int onoff);
int grub_normal_get_line_counter (void);
void grub_install_newline_hook (void);
#endif /* ! GRUB_NORMAL_HEADER */

View File

@ -22,6 +22,7 @@
#include <grub/types.h>
#define GRUB_IEEE1275_CELL_SIZEOF 4
typedef grub_uint32_t grub_ieee1275_cell_t;
#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */

View File

@ -25,7 +25,8 @@
#define BOOTDEV_REG %l6
#define PIC_REG %l7
#define SCRATCH_PAD 0x10000
#define SCRATCH_PAD_BOOT 0x5000
#define SCRATCH_PAD_DISKBOOT 0x4000
#define GET_ABS(symbol, reg) \
add PIC_REG, (symbol - pic_base), reg
@ -51,7 +52,7 @@
#define GRUB_BOOT_MACHINE_LIST_SIZE 12
#define GRUB_BOOT_MACHINE_IMAGE_ADDRESS 0x200000
#define GRUB_BOOT_MACHINE_IMAGE_ADDRESS 0x4400
#define GRUB_BOOT_MACHINE_KERNEL_ADDR 0x4200

View File

@ -22,6 +22,7 @@
#include <grub/types.h>
#define GRUB_IEEE1275_CELL_SIZEOF 8
typedef grub_uint64_t grub_ieee1275_cell_t;
/* Encoding of 'mode' argument to grub_ieee1275_map_physical() */
@ -36,14 +37,12 @@ typedef grub_uint64_t grub_ieee1275_cell_t;
#define IEEE1275_MAP_DEFAULT (IEEE1275_MAP_WRITE | IEEE1275_MAP_READ | \
IEEE1275_MAP_EXEC | IEEE1275_MAP_CACHED)
extern int EXPORT_FUNC(grub_ieee1275_map_physical) (grub_addr_t paddr,
grub_addr_t vaddr,
grub_size_t size,
grub_uint32_t mode);
extern int EXPORT_FUNC(grub_ieee1275_claim_vaddr) (grub_addr_t vaddr,
grub_size_t size);
extern int EXPORT_FUNC(grub_ieee1275_alloc_physmem) (grub_addr_t *paddr,
grub_size_t size,
grub_uint32_t align);
extern grub_addr_t EXPORT_VAR (grub_ieee1275_original_stack);
#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */

View File

@ -39,8 +39,24 @@
/* End of the data section. */
#define GRUB_KERNEL_MACHINE_DATA_END 0x114
#define GRUB_KERNEL_MACHINE_RAW_SIZE 0
#define GRUB_KERNEL_MACHINE_STACK_SIZE 0x40000
#define GRUB_PLATFORM_IMAGE_FORMATS "raw, aout"
#define GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT "raw"
#define GRUB_PLATFORM_IMAGE_DEFAULT GRUB_PLATFORM_IMAGE_RAW
#ifndef ASM_FILE
typedef enum {
GRUB_PLATFORM_IMAGE_RAW,
GRUB_PLATFORM_IMAGE_AOUT
}
grub_platform_image_format_t;
#define GRUB_PLATFORM_IMAGE_RAW GRUB_PLATFORM_IMAGE_RAW
#define GRUB_PLATFORM_IMAGE_AOUT GRUB_PLATFORM_IMAGE_AOUT
#include <grub/symbol.h>
#include <grub/types.h>

View File

@ -223,4 +223,10 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x)
# endif
#endif /* ! WORDS_BIGENDIAN */
#if GRUB_TARGET_SIZEOF_VOID_P == 8
# define grub_host_to_target_addr(x) grub_host_to_target64(x)
#else
# define grub_host_to_target_addr(x) grub_host_to_target32(x)
#endif
#endif /* ! GRUB_TYPES_HEADER */

View File

@ -259,13 +259,13 @@ struct grub_video_adapter
};
typedef struct grub_video_adapter *grub_video_adapter_t;
void grub_video_register (grub_video_adapter_t adapter);
void EXPORT_FUNC (grub_video_register) (grub_video_adapter_t adapter);
void grub_video_unregister (grub_video_adapter_t adapter);
void grub_video_iterate (int (*hook) (grub_video_adapter_t adapter));
grub_err_t grub_video_restore (void);
grub_err_t EXPORT_FUNC (grub_video_restore) (void);
grub_err_t grub_video_get_info (struct grub_video_mode_info *mode_info);
grub_err_t EXPORT_FUNC (grub_video_get_info) (struct grub_video_mode_info *mode_info);
/* Framebuffer address may change as a part of normal operation
(e.g. double buffering). That's why you need to stop video subsystem to be
@ -283,57 +283,71 @@ grub_err_t grub_video_set_palette (unsigned int start, unsigned int count,
grub_err_t grub_video_get_palette (unsigned int start, unsigned int count,
struct grub_video_palette_data *palette_data);
grub_err_t grub_video_set_viewport (unsigned int x, unsigned int y,
unsigned int width, unsigned int height);
grub_err_t EXPORT_FUNC (grub_video_set_viewport) (unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height);
grub_err_t grub_video_get_viewport (unsigned int *x, unsigned int *y,
unsigned int *width, unsigned int *height);
grub_err_t EXPORT_FUNC (grub_video_get_viewport) (unsigned int *x,
unsigned int *y,
unsigned int *width,
unsigned int *height);
grub_video_color_t grub_video_map_color (grub_uint32_t color_name);
grub_video_color_t EXPORT_FUNC (grub_video_map_color) (grub_uint32_t color_name);
grub_video_color_t grub_video_map_rgb (grub_uint8_t red, grub_uint8_t green,
grub_uint8_t blue);
grub_video_color_t EXPORT_FUNC (grub_video_map_rgb) (grub_uint8_t red,
grub_uint8_t green,
grub_uint8_t blue);
grub_video_color_t grub_video_map_rgba (grub_uint8_t red, grub_uint8_t green,
grub_uint8_t blue, grub_uint8_t alpha);
grub_video_color_t EXPORT_FUNC (grub_video_map_rgba) (grub_uint8_t red,
grub_uint8_t green,
grub_uint8_t blue,
grub_uint8_t alpha);
grub_err_t grub_video_unmap_color (grub_video_color_t color,
grub_uint8_t *red, grub_uint8_t *green,
grub_uint8_t *blue, grub_uint8_t *alpha);
grub_err_t EXPORT_FUNC (grub_video_unmap_color) (grub_video_color_t color,
grub_uint8_t *red,
grub_uint8_t *green,
grub_uint8_t *blue,
grub_uint8_t *alpha);
grub_err_t grub_video_fill_rect (grub_video_color_t color, int x, int y,
unsigned int width, unsigned int height);
grub_err_t EXPORT_FUNC (grub_video_fill_rect) (grub_video_color_t color,
int x, int y,
unsigned int width,
unsigned int height);
grub_err_t grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
enum grub_video_blit_operators oper,
int x, int y, int offset_x, int offset_y,
unsigned int width, unsigned int height);
grub_err_t EXPORT_FUNC (grub_video_blit_bitmap) (struct grub_video_bitmap *bitmap,
enum grub_video_blit_operators oper,
int x, int y,
int offset_x, int offset_y,
unsigned int width,
unsigned int height);
grub_err_t grub_video_blit_render_target (struct grub_video_render_target *source,
enum grub_video_blit_operators oper,
int x, int y,
int offset_x, int offset_y,
unsigned int width,
unsigned int height);
grub_err_t EXPORT_FUNC (grub_video_blit_render_target) (struct grub_video_render_target *source,
enum grub_video_blit_operators oper,
int x, int y,
int offset_x,
int offset_y,
unsigned int width,
unsigned int height);
grub_err_t grub_video_scroll (grub_video_color_t color, int dx, int dy);
grub_err_t grub_video_swap_buffers (void);
grub_err_t EXPORT_FUNC (grub_video_swap_buffers) (void);
grub_err_t grub_video_create_render_target (struct grub_video_render_target **result,
unsigned int width,
unsigned int height,
unsigned int mode_type);
grub_err_t EXPORT_FUNC (grub_video_create_render_target) (struct grub_video_render_target **result,
unsigned int width,
unsigned int height,
unsigned int mode_type);
grub_err_t grub_video_delete_render_target (struct grub_video_render_target *target);
grub_err_t EXPORT_FUNC (grub_video_delete_render_target) (struct grub_video_render_target *target);
grub_err_t grub_video_set_active_render_target (struct grub_video_render_target *target);
grub_err_t EXPORT_FUNC (grub_video_set_active_render_target) (struct grub_video_render_target *target);
grub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target);
grub_err_t grub_video_set_mode (const char *modestring,
unsigned int modemask,
unsigned int modevalue);
grub_err_t EXPORT_FUNC (grub_video_set_mode) (const char *modestring,
unsigned int modemask,
unsigned int modevalue);
static inline int
grub_video_check_mode_flag (unsigned int flags, unsigned int mask,

View File

@ -1121,14 +1121,13 @@ grub_gzio_open (grub_file_t io, int transparent)
if (! file)
return 0;
gzio = grub_malloc (sizeof (*gzio));
gzio = grub_zalloc (sizeof (*gzio));
if (! gzio)
{
grub_free (file);
return 0;
}
grub_memset (gzio, 0, sizeof (*gzio));
gzio->file = io;
file->device = io->device;

View File

@ -152,7 +152,7 @@ grub_device_iterate (int (*hook) (const char *name))
grub_free (partition_name);
grub_free (p);
return 1;
}
}
grub_free (partition_name);
p->next = ents;

View File

@ -284,8 +284,8 @@ grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
}
int
grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi,
int pos_lo, grub_ssize_t *result)
grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, grub_disk_addr_t pos,
grub_ssize_t *result)
{
struct write_args
{
@ -299,8 +299,15 @@ grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi,
INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1);
args.ihandle = ihandle;
args.pos_hi = (grub_ieee1275_cell_t) pos_hi;
args.pos_lo = (grub_ieee1275_cell_t) pos_lo;
/* To prevent stupid gcc warning. */
#if GRUB_IEEE1275_CELL_SIZEOF >= 8
args.pos_hi = 0;
args.pos_lo = pos;
#else
args.pos_hi = (grub_ieee1275_cell_t) (pos >> (8 * GRUB_IEEE1275_CELL_SIZEOF));
args.pos_lo = (grub_ieee1275_cell_t)
(pos & ((1ULL << (8 * GRUB_IEEE1275_CELL_SIZEOF)) - 1));
#endif
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
return -1;

View File

@ -38,11 +38,11 @@
#define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024)
/* The maximum heap size we're going to claim */
#define HEAP_MAX_SIZE (unsigned long) (4 * 1024 * 1024)
#define HEAP_MAX_SIZE (unsigned long) (32 * 1024 * 1024)
/* If possible, we will avoid claiming heap above this address, because it
seems to cause relocation problems with OSes that link at 4 MiB */
#define HEAP_MAX_ADDR (unsigned long) (4 * 1024 * 1024)
#define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024)
extern char _start[];
extern char _end[];

View File

@ -68,11 +68,10 @@ grub_children_iterate (char *devpath,
{
struct grub_ieee1275_devalias alias;
grub_ssize_t actual;
char *fullname;
if (grub_ieee1275_get_property (child, "device_type", childtype,
IEEE1275_MAX_PROP_LEN, &actual))
continue;
childtype[0] = 0;
if (grub_ieee1275_package_to_path (child, childpath,
IEEE1275_MAX_PATH_LEN, &actual))
@ -82,24 +81,14 @@ grub_children_iterate (char *devpath,
IEEE1275_MAX_PROP_LEN, &actual))
continue;
fullname = grub_xasprintf ("%s/%s", devpath, childname);
if (!fullname)
{
grub_free (childname);
grub_free (childpath);
grub_free (childtype);
return 0;
}
alias.type = childtype;
alias.path = childpath;
alias.name = fullname;
alias.name = childname;
ret = hook (&alias);
grub_free (fullname);
if (ret)
break;
}
while (grub_ieee1275_peer (child, &child));
while (grub_ieee1275_peer (child, &child) != -1);
grub_free (childname);
grub_free (childpath);
@ -108,6 +97,20 @@ grub_children_iterate (char *devpath,
return ret;
}
int
grub_ieee1275_devices_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
{
auto int it_through (struct grub_ieee1275_devalias *alias);
int it_through (struct grub_ieee1275_devalias *alias)
{
if (hook (alias))
return 1;
return grub_children_iterate (alias->path, it_through);
}
return grub_children_iterate ("/", it_through);
}
/* Iterate through all device aliases. This function can be used to
find a device of a specific type. */
int
@ -199,9 +202,9 @@ nextprop:
}
/* Call the "map" method of /chosen/mmu. */
static int
grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size,
grub_uint8_t mode)
int
grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
grub_uint32_t mode)
{
struct map_args {
struct grub_ieee1275_common_hdr common;
@ -210,17 +213,30 @@ grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size,
grub_ieee1275_cell_t mode;
grub_ieee1275_cell_t size;
grub_ieee1275_cell_t virt;
grub_ieee1275_cell_t phys;
#ifdef GRUB_MACHINE_SPARC64
grub_ieee1275_cell_t phys_high;
#endif
grub_ieee1275_cell_t phys_low;
grub_ieee1275_cell_t catch_result;
} args;
INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
INIT_IEEE1275_COMMON (&args.common, "call-method",
#ifdef GRUB_MACHINE_SPARC64
7,
#else
6,
#endif
1);
args.method = (grub_ieee1275_cell_t) "map";
args.ihandle = grub_ieee1275_mmu;
args.phys = phys;
#ifdef GRUB_MACHINE_SPARC64
args.phys_high = 0;
#endif
args.phys_low = phys;
args.virt = virt;
args.size = size;
args.mode = mode; /* Format is WIMG0PP. */
args.catch_result = (grub_ieee1275_cell_t) -1;
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
return -1;
@ -235,7 +251,7 @@ grub_claimmap (grub_addr_t addr, grub_size_t size)
return -1;
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE)
&& grub_map (addr, addr, size, 0x00))
&& grub_ieee1275_map (addr, addr, size, 0x00))
{
grub_printf ("map failed: address 0x%llx, size 0x%llx\n",
(long long) addr, (long long) size);
@ -405,8 +421,9 @@ grub_reboot (void)
void
grub_halt (void)
{
/* Not standardized. We try both known commands. */
/* Not standardized. We try three known commands. */
grub_ieee1275_interpret ("shut-down", 0);
grub_ieee1275_interpret ("power-off", 0);
grub_ieee1275_interpret ("poweroff", 0);
}

View File

@ -53,6 +53,25 @@ grub_module_iterate (int (*hook) (struct grub_module_header *header))
}
}
/* This is actualy platform-independant but used only on yeeloong and sparc. */
#if defined (GRUB_MACHINE_MIPS_YEELOONG) || defined (GRUB_MACHINE_SPARC64)
grub_addr_t
grub_modules_get_end (void)
{
struct grub_module_info *modinfo;
grub_addr_t modbase;
modbase = grub_arch_modules_addr ();
modinfo = (struct grub_module_info *) modbase;
/* Check if there are any modules. */
if ((modinfo == 0) || modinfo->magic != GRUB_MODULE_MAGIC)
return modbase;
return modbase + modinfo->size;
}
#endif
/* Load all modules in core. */
static void
grub_load_modules (void)
@ -68,6 +87,9 @@ grub_load_modules (void)
(header->size - sizeof (struct grub_module_header))))
grub_fatal ("%s", grub_errmsg);
if (grub_errno)
grub_print_error ();
return 0;
}

View File

@ -63,35 +63,13 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
return GRUB_ERR_NONE;
}
static void *
get_modules_end (void)
{
struct grub_module_info *modinfo;
struct grub_module_header *header;
grub_addr_t modbase;
modbase = grub_arch_modules_addr ();
modinfo = (struct grub_module_info *) modbase;
/* Check if there are any modules. */
if ((modinfo == 0) || modinfo->magic != GRUB_MODULE_MAGIC)
return modinfo;
for (header = (struct grub_module_header *) (modbase + modinfo->offset);
header < (struct grub_module_header *) (modbase + modinfo->size);
header = (struct grub_module_header *) ((char *) header + header->size));
return header;
}
void
grub_machine_init (void)
{
void *modend;
modend = get_modules_end ();
grub_mm_init_region (modend, (grub_arch_memsize << 20)
- (((grub_addr_t) modend) - GRUB_ARCH_LOWMEMVSTART));
grub_addr_t modend;
modend = grub_modules_get_end ();
grub_mm_init_region ((void *) modend, (grub_arch_memsize << 20)
- (modend - GRUB_ARCH_LOWMEMVSTART));
/* FIXME: use upper memory as well. */
grub_install_get_time_ms (grub_rtc_get_time_ms);

View File

@ -24,7 +24,7 @@
.globl _start
_start:
ba codestart
nop
mov %o4, %o0
. = EXT_C(_start) + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
@ -53,12 +53,25 @@ codestart:
or %o3, %lo(_end), %o3
sethi %hi(grub_total_module_size), %o4
lduw [%o4 + %lo(grub_total_module_size)], %o4
add %o2, %o4, %o2
add %o3, %o4, %o3
/* Save ieee1275 stack for future use by booter. */
mov %o6, %o1
/* Our future stack. */
sethi %hi(GRUB_KERNEL_MACHINE_STACK_SIZE - 2047), %o5
or %o5, %lo(GRUB_KERNEL_MACHINE_STACK_SIZE - 2047), %o5
add %o3, %o5, %o6
sub %o2, 4, %o2
sub %o3, 4, %o3
1: lduw [%o2], %o5
stw %o5, [%o3]
subcc %o4, 4, %o4
add %o2, 4, %o2
sub %o2, 4, %o2
bne,pt %icc, 1b
add %o3, 4, %o3
sub %o3, 4, %o3
/* Now it's safe to clear out the BSS. */
sethi %hi(__bss_start), %o2
@ -70,8 +83,9 @@ codestart:
cmp %o2, %o3
blt,pt %xcc, 1b
nop
sethi %hi(grub_ieee1275_original_stack), %o2
stx %o1, [%o2 + %lo(grub_ieee1275_original_stack)]
sethi %hi(grub_ieee1275_entry_fn), %o2
stx %o0, [%o2 + %lo(grub_ieee1275_entry_fn)]
call grub_main
nop
stx %o0, [%o2 + %lo(grub_ieee1275_entry_fn)]
1: ba,a 1b

View File

@ -21,39 +21,6 @@
/* Sun specific ieee1275 interfaces used by GRUB. */
int
grub_ieee1275_map_physical (grub_addr_t paddr, grub_addr_t vaddr,
grub_size_t size, grub_uint32_t mode)
{
struct map_physical_args
{
struct grub_ieee1275_common_hdr common;
grub_ieee1275_cell_t method;
grub_ieee1275_cell_t ihandle;
grub_ieee1275_cell_t mode;
grub_ieee1275_cell_t size;
grub_ieee1275_cell_t virt;
grub_ieee1275_cell_t phys_high;
grub_ieee1275_cell_t phys_low;
grub_ieee1275_cell_t catch_result;
}
args;
INIT_IEEE1275_COMMON (&args.common, "call-method", 7, 1);
args.method = (grub_ieee1275_cell_t) "map";
args.ihandle = grub_ieee1275_mmu;
args.mode = mode;
args.size = size;
args.virt = vaddr;
args.phys_high = 0;
args.phys_low = paddr;
args.catch_result = (grub_ieee1275_cell_t) -1;
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
return -1;
return args.catch_result;
}
int
grub_ieee1275_claim_vaddr (grub_addr_t vaddr, grub_size_t size)
{

View File

@ -23,12 +23,15 @@
#include <grub/err.h>
#include <grub/misc.h>
#include <grub/time.h>
#include <grub/machine/boot.h>
#include <grub/machine/console.h>
#include <grub/machine/kernel.h>
#include <grub/machine/time.h>
#include <grub/ieee1275/ofdisk.h>
#include <grub/ieee1275/ieee1275.h>
grub_addr_t grub_ieee1275_original_stack;
void
grub_exit (void)
{
@ -104,7 +107,8 @@ grub_machine_set_prefix (void)
static void
grub_heap_init (void)
{
grub_mm_init_region ((void *)(long)0x4000UL, 0x200000 - 0x4000);
grub_mm_init_region ((void *) (grub_modules_get_end ()
+ GRUB_KERNEL_MACHINE_STACK_SIZE), 0x200000);
}
static void

142
lib/ieee1275/datetime.c Normal file
View File

@ -0,0 +1,142 @@
/* kern/cmos_datetime.c - CMOS datetime function.
*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008,2009 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/datetime.h>
#include <grub/ieee1275/ieee1275.h>
#include <grub/misc.h>
static char *rtc = 0;
static void
find_rtc (void)
{
auto int hook (struct grub_ieee1275_devalias *alias);
int hook (struct grub_ieee1275_devalias *alias)
{
if (grub_strcmp (alias->type, "rtc") == 0)
{
grub_dprintf ("datetime", "Found RTC %s\n", alias->path);
rtc = grub_strdup (alias->path);
return 1;
}
return 0;
}
grub_ieee1275_devices_iterate (hook);
}
grub_err_t
grub_get_datetime (struct grub_datetime *datetime)
{
struct get_time_args
{
struct grub_ieee1275_common_hdr common;
grub_ieee1275_cell_t method;
grub_ieee1275_cell_t device;
grub_ieee1275_cell_t catch_result;
grub_ieee1275_cell_t year;
grub_ieee1275_cell_t month;
grub_ieee1275_cell_t day;
grub_ieee1275_cell_t hour;
grub_ieee1275_cell_t minute;
grub_ieee1275_cell_t second;
}
args;
int status;
grub_ieee1275_ihandle_t ihandle;
if (!rtc)
find_rtc ();
if (!rtc)
return grub_error (GRUB_ERR_IO, "no RTC found");
status = grub_ieee1275_open (rtc, &ihandle);
if (status == -1)
return grub_error (GRUB_ERR_IO, "couldn't open RTC");
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 7);
args.device = (grub_ieee1275_cell_t) ihandle;
args.method = (grub_ieee1275_cell_t) "get-time";
status = IEEE1275_CALL_ENTRY_FN (&args);
grub_ieee1275_close (ihandle);
if (status == -1)
return grub_error (GRUB_ERR_IO, "get-time failed");
datetime->year = args.year;
datetime->month = args.month;
datetime->day = args.day;
datetime->hour = args.hour;
datetime->minute = args.minute;
datetime->second = args.second;
return GRUB_ERR_NONE;
}
grub_err_t
grub_set_datetime (struct grub_datetime *datetime)
{
struct set_time_args
{
struct grub_ieee1275_common_hdr common;
grub_ieee1275_cell_t method;
grub_ieee1275_cell_t device;
grub_ieee1275_cell_t year;
grub_ieee1275_cell_t month;
grub_ieee1275_cell_t day;
grub_ieee1275_cell_t hour;
grub_ieee1275_cell_t minute;
grub_ieee1275_cell_t second;
grub_ieee1275_cell_t catch_result;
}
args;
int status;
grub_ieee1275_ihandle_t ihandle;
if (!rtc)
find_rtc ();
if (!rtc)
return grub_error (GRUB_ERR_IO, "no RTC found");
status = grub_ieee1275_open (rtc, &ihandle);
if (status == -1)
return grub_error (GRUB_ERR_IO, "couldn't open RTC");
INIT_IEEE1275_COMMON (&args.common, "call-method", 8, 1);
args.device = (grub_ieee1275_cell_t) ihandle;
args.method = (grub_ieee1275_cell_t) "set-time";
args.year = datetime->year;
args.month = datetime->month;
args.day = datetime->day;
args.hour = datetime->hour;
args.minute = datetime->minute;
args.second = datetime->second;
status = IEEE1275_CALL_ENTRY_FN (&args);
grub_ieee1275_close (ihandle);
if (status == -1)
return grub_error (GRUB_ERR_IO, "set-time failed");
return GRUB_ERR_NONE;
}

View File

@ -154,8 +154,8 @@ grub_bsd_get_device (grub_uint32_t * biosdev,
dev = grub_device_open (0);
if (dev && dev->disk && dev->disk->partition)
{
p = dev->disk->partition->partmap->get_name (dev->disk->partition);
char *p0;
p0 = p = dev->disk->partition->partmap->get_name (dev->disk->partition);
if (p)
{
if ((p[0] >= '0') && (p[0] <= '9'))
@ -169,6 +169,7 @@ grub_bsd_get_device (grub_uint32_t * biosdev,
if ((p[0] >= 'a') && (p[0] <= 'z'))
*part = p[0] - 'a';
}
grub_free (p0);
}
if (dev)
grub_device_close (dev);

View File

@ -576,7 +576,7 @@ grub_linux_setup_video (struct linux_kernel_params *params)
params->lfb_line_len = line_len;
params->lfb_base = fb_base;
params->lfb_size = (line_len * params->lfb_height + 65535) >> 16;
params->lfb_size = ALIGN_UP (line_len * params->lfb_height, 65536);
params->red_mask_size = 8;
params->red_field_pos = 16;

View File

@ -410,7 +410,7 @@ grub_linux_setup_video (struct linux_kernel_params *params)
params->lfb_line_len = mode_info.pitch;
params->lfb_base = (grub_size_t) framebuffer;
params->lfb_size = (params->lfb_line_len * params->lfb_height + 65535) >> 16;
params->lfb_size = ALIGN_UP (params->lfb_line_len * params->lfb_height, 65536);
params->red_mask_size = mode_info.red_mask_size;
params->red_field_pos = mode_info.red_field_pos;
@ -543,6 +543,8 @@ grub_linux_boot (void)
/* Use generic framebuffer unless VESA is known to be supported. */
if (params->have_vga != GRUB_VIDEO_LINUX_TYPE_VESA)
params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE;
else
params->lfb_size >>= 16;
}
else
{

View File

@ -448,8 +448,8 @@ grub_multiboot_set_bootdev (void)
dev = grub_device_open (0);
if (dev && dev->disk && dev->disk->partition)
{
p = dev->disk->partition->partmap->get_name (dev->disk->partition);
char *p0;
p = p0 = dev->disk->partition->partmap->get_name (dev->disk->partition);
if (p)
{
if ((p[0] >= '0') && (p[0] <= '9'))
@ -463,6 +463,7 @@ grub_multiboot_set_bootdev (void)
if ((p[0] >= 'a') && (p[0] <= 'z'))
part = p[0] - 'a';
}
grub_free (p0);
}
if (dev)
grub_device_close (dev);

View File

@ -58,9 +58,6 @@ static grub_size_t linux_size;
static char *linux_args;
typedef void (*kernel_entry_t) (unsigned long, unsigned long,
unsigned long, unsigned long, int (void *));
struct linux_bootstr_info {
int len, valid;
char buf[];
@ -92,7 +89,6 @@ static grub_err_t
grub_linux_boot (void)
{
struct linux_bootstr_info *bp;
kernel_entry_t linuxmain;
struct linux_hdrs *hp;
grub_addr_t addr;
@ -141,8 +137,17 @@ grub_linux_boot (void)
grub_dprintf ("loader", "Jumping to Linux...\n");
/* Boot the kernel. */
linuxmain = (kernel_entry_t) linux_addr;
linuxmain (0, 0, 0, 0, grub_ieee1275_entry_fn);
asm volatile ("sethi %hi(grub_ieee1275_entry_fn), %o1\n"
"ldx [%o1 + %lo(grub_ieee1275_entry_fn)], %o4\n"
"sethi %hi(grub_ieee1275_original_stack), %o1\n"
"ldx [%o1 + %lo(grub_ieee1275_original_stack)], %o6\n"
"sethi %hi(linux_addr), %o1\n"
"ldx [%o1 + %lo(linux_addr)], %o5\n"
"mov %g0, %o0\n"
"mov %g0, %o2\n"
"mov %g0, %o3\n"
"jmp %o5\n"
"mov %g0, %o1\n");
return GRUB_ERR_NONE;
}
@ -173,12 +178,6 @@ grub_linux_unload (void)
#define FOUR_MB (4 * 1024 * 1024)
static grub_addr_t
align_addr(grub_addr_t val, grub_addr_t align)
{
return (val + (align - 1)) & ~(align - 1);
}
static grub_addr_t
alloc_phys (grub_addr_t size)
{
@ -192,39 +191,39 @@ alloc_phys (grub_addr_t size)
if (type != 1)
return 0;
addr = align_addr (addr, FOUR_MB);
if (addr >= end)
addr = ALIGN_UP (addr, FOUR_MB);
if (addr + size >= end)
return 0;
if (addr >= grub_phys_start && addr < grub_phys_end)
{
addr = align_addr (grub_phys_end, FOUR_MB);
if (addr >= end)
addr = ALIGN_UP (grub_phys_end, FOUR_MB);
if (addr + size >= end)
return 0;
}
if ((addr + size) >= grub_phys_start
&& (addr + size) < grub_phys_end)
{
addr = align_addr (grub_phys_end, FOUR_MB);
if (addr >= end)
addr = ALIGN_UP (grub_phys_end, FOUR_MB);
if (addr + size >= end)
return 0;
}
if (loaded)
{
grub_addr_t linux_end = align_addr (linux_paddr + linux_size, FOUR_MB);
grub_addr_t linux_end = ALIGN_UP (linux_paddr + linux_size, FOUR_MB);
if (addr >= linux_paddr && addr < linux_end)
{
addr = linux_end;
if (addr >= end)
if (addr + size >= end)
return 0;
}
if ((addr + size) >= linux_paddr
&& (addr + size) < linux_end)
{
addr = linux_end;
if (addr >= end)
if (addr + size >= end)
return 0;
}
}
@ -258,8 +257,8 @@ grub_linux_load64 (grub_elf_t elf)
if (paddr == (grub_addr_t) -1)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"couldn't allocate physical memory");
ret = grub_ieee1275_map_physical (paddr, linux_addr - off,
linux_size + off, IEEE1275_MAP_DEFAULT);
ret = grub_ieee1275_map (paddr, linux_addr - off,
linux_size + off, IEEE1275_MAP_DEFAULT);
if (ret)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"couldn't map physical memory");
@ -409,7 +408,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
"couldn't allocate physical memory");
goto fail;
}
ret = grub_ieee1275_map_physical (paddr, addr, size, IEEE1275_MAP_DEFAULT);
ret = grub_ieee1275_map (paddr, addr, size, IEEE1275_MAP_DEFAULT);
if (ret)
{
grub_error (GRUB_ERR_OUT_OF_MEMORY,

View File

@ -38,6 +38,9 @@ autoload_fs_module (void)
if (! grub_dl_get (p->name) && grub_dl_load (p->name))
return 1;
if (grub_errno)
grub_print_error ();
fs_module_list = p->next;
grub_free (p->name);
grub_free (p);

View File

@ -303,8 +303,9 @@ grub_cmdline_get (const char *prompt)
grub_memmove (buf + lpos, str, len * sizeof (grub_uint32_t));
llen += len;
cl_set_pos_all ();
cl_print_all (lpos, 0);
lpos += len;
cl_print_all (lpos - len, 0);
cl_set_pos_all ();
}
}
@ -473,7 +474,6 @@ grub_cmdline_get (const char *prompt)
if (t != 1)
cl_insert (insert);
lpos++;
cl_set_pos_all ();
}
else
{
@ -485,6 +485,7 @@ grub_cmdline_get (const char *prompt)
grub_free (insertu8);
grub_free (insert);
}
cl_set_pos_all ();
}
break;

View File

@ -88,13 +88,14 @@ read_crypto_list (void)
}
file = grub_file_open (filename);
grub_free (filename);
if (!file)
{
grub_errno = GRUB_ERR_NONE;
return;
}
/* Override previous commands.lst. */
/* Override previous crypto.lst. */
grub_crypto_spec_free ();
for (;; grub_free (buf))

View File

@ -418,6 +418,7 @@ grub_normal_init_page (struct grub_term_output *term)
msg_len = grub_utf8_to_ucs4_alloc (msg_formatted,
&unicode_msg, &last_position);
grub_free (msg_formatted);
if (msg_len < 0)
{
@ -582,10 +583,13 @@ grub_normal_read_line_real (char **line, int cont, int nested)
if (cont || nested)
{
grub_free (*line);
grub_free (prompt);
*line = 0;
return grub_errno;
}
}
grub_free (prompt);
return 0;
}
@ -650,6 +654,7 @@ GRUB_MOD_INIT(normal)
grub_set_history (GRUB_DEFAULT_HISTORY_SIZE);
grub_install_newline_hook ();
grub_register_variable_hook ("pager", 0, grub_env_write_pager);
/* Register a command "normal" for the rescue mode. */

View File

@ -559,14 +559,14 @@ show_menu (grub_menu_t menu, int nested)
}
else
{
int lines_before = grub_normal_get_line_counter ();
grub_errno = GRUB_ERR_NONE;
grub_menu_execute_entry (e);
if (grub_errno != GRUB_ERR_NONE)
{
grub_print_error ();
grub_errno = GRUB_ERR_NONE;
grub_wait_after_message ();
}
grub_print_error ();
grub_errno = GRUB_ERR_NONE;
if (lines_before != grub_normal_get_line_counter ())
grub_wait_after_message ();
}
}

View File

@ -30,6 +30,14 @@ static unsigned grub_more_lines;
/* If the more pager is active. */
static int grub_more;
static int grub_normal_line_counter = 0;
int
grub_normal_get_line_counter (void)
{
return grub_normal_line_counter;
}
static void
process_newline (void)
{
@ -41,6 +49,8 @@ process_newline (void)
height = grub_term_height (cur);
grub_more_lines++;
grub_normal_line_counter++;
if (grub_more && grub_more_lines >= height - 1)
{
char key;
@ -76,6 +86,11 @@ grub_set_more (int onoff)
grub_more--;
grub_more_lines = 0;
}
void
grub_install_newline_hook (void)
{
grub_newline_hook = process_newline;
}
@ -150,7 +165,6 @@ grub_terminal_autoload_free (void)
grub_term_output_autoload = NULL;
}
/* Read the file terminal.lst for auto-loading. */
void
read_terminal_list (void)
@ -175,6 +189,7 @@ read_terminal_list (void)
}
file = grub_file_open (filename);
grub_free (filename);
if (!file)
{
grub_errno = GRUB_ERR_NONE;

View File

@ -100,7 +100,6 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
grubcmd = grub_command_find (cmdname);
if (! grubcmd)
{
/* Ignore errors. */
grub_errno = GRUB_ERR_NONE;
/* It's not a GRUB command, try all functions. */
@ -126,6 +125,8 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
grub_snprintf (errnobuf, sizeof (errnobuf), "%d", grub_errno);
grub_env_set ("?", errnobuf);
grub_print_error ();
return 0;
}
}
@ -156,6 +157,11 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
grub_free (args[i]);
grub_free (args);
if (grub_errno == GRUB_ERR_TEST_FAILURE)
grub_errno = GRUB_ERR_NONE;
grub_print_error ();
grub_snprintf (errnobuf, sizeof (errnobuf), "%d", ret);
grub_env_set ("?", errnobuf);

View File

@ -21,6 +21,7 @@
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/time.h>
#include <grub/machine/console.h>
#include <grub/ieee1275/ieee1275.h>
@ -77,7 +78,52 @@ grub_ofconsole_writeesc (const char *str)
static void
grub_ofconsole_putchar (grub_uint32_t c)
{
char chr = c;
char chr;
if (c > 0x7F)
{
/* Better than nothing. */
switch (c)
{
case GRUB_TERM_DISP_LEFT:
c = '<';
break;
case GRUB_TERM_DISP_UP:
c = '^';
break;
case GRUB_TERM_DISP_RIGHT:
c = '>';
break;
case GRUB_TERM_DISP_DOWN:
c = 'v';
break;
case GRUB_TERM_DISP_HLINE:
c = '-';
break;
case GRUB_TERM_DISP_VLINE:
c = '|';
break;
case GRUB_TERM_DISP_UL:
case GRUB_TERM_DISP_UR:
case GRUB_TERM_DISP_LL:
case GRUB_TERM_DISP_LR:
c = '+';
break;
default:
c = '?';
break;
}
}
chr = c;
if (c == '\n')
{
grub_curr_y++;
@ -156,42 +202,81 @@ grub_ofconsole_readkey (int *key)
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual > 0 && c == '\e')
{
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual <= 0)
if (actual > 0)
switch(c)
{
case 0x7f:
/* Backspace: Ctrl-h. */
c = '\b';
break;
case '\e':
{
*key = '\e';
return 1;
grub_uint64_t start;
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
/* On 9600 we have to wait up to 12 milliseconds. */
start = grub_get_time_ms ();
while (actual <= 0 && grub_get_time_ms () - start < 12)
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual <= 0)
{
*key = '\e';
return 1;
}
if (c != '[')
return 0;
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
/* On 9600 we have to wait up to 12 milliseconds. */
start = grub_get_time_ms ();
while (actual <= 0 && grub_get_time_ms () - start < 12)
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual <= 0)
return 0;
switch (c)
{
case 'A':
/* Up: Ctrl-p. */
c = GRUB_TERM_UP;
break;
case 'B':
/* Down: Ctrl-n. */
c = GRUB_TERM_DOWN;
break;
case 'C':
/* Right: Ctrl-f. */
c = GRUB_TERM_RIGHT;
break;
case 'D':
/* Left: Ctrl-b. */
c = GRUB_TERM_LEFT;
break;
case '3':
{
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
/* On 9600 we have to wait up to 12 milliseconds. */
start = grub_get_time_ms ();
while (actual <= 0 && grub_get_time_ms () - start < 12)
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual <= 0)
return 0;
/* Delete: Ctrl-d. */
if (c == '~')
c = GRUB_TERM_DC;
else
return 0;
break;
}
break;
}
}
if (c != 91)
return 0;
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
if (actual <= 0)
return 0;
switch (c)
{
case 65:
/* Up: Ctrl-p. */
c = 16;
break;
case 66:
/* Down: Ctrl-n. */
c = 14;
break;
case 67:
/* Right: Ctrl-f. */
c = 6;
break;
case 68:
/* Left: Ctrl-b. */
c = 2;
break;
}
}
}
*key = c;
return actual > 0;

View File

@ -232,7 +232,12 @@ serial_get_divisor (unsigned int speed)
/* Set the baud rate. */
for (i = 0; i < sizeof (divisor_tab) / sizeof (divisor_tab[0]); i++)
if (divisor_tab[i].speed == speed)
/* UART in Yeeloong runs twice the usual rate. */
#ifdef GRUB_MACHINE_MIPS_YEELOONG
return 2 * divisor_tab[i].div;
#else
return divisor_tab[i].div;
#endif
return 0;
}
@ -292,11 +297,14 @@ serial_hw_init (void)
| serial_settings.stop_bits);
grub_outb (status, serial_settings.port + UART_LCR);
/* In Yeeloong serial port has only 3 wires. */
#ifndef GRUB_MACHINE_MIPS_YEELOONG
/* Enable the FIFO. */
grub_outb (UART_ENABLE_FIFO, serial_settings.port + UART_FCR);
/* Turn on DTR, RTS, and OUT2. */
grub_outb (UART_ENABLE_MODEM, serial_settings.port + UART_MCR);
#endif
/* Drain the input buffer. */
while (grub_serial_checkkey () != -1)
@ -613,7 +621,11 @@ GRUB_MOD_INIT(serial)
/* Set default settings. */
serial_settings.port = serial_hw_get_port (0);
#ifdef GRUB_MACHINE_MIPS_YEELOONG
serial_settings.divisor = serial_get_divisor (115200);
#else
serial_settings.divisor = serial_get_divisor (9600);
#endif
serial_settings.word_len = UART_8BITS_WORD;
serial_settings.parity = UART_NO_PARITY;
serial_settings.stop_bits = UART_1_STOP_BIT;

View File

@ -221,7 +221,10 @@ export GRUB_DEFAULT \
GRUB_DISABLE_LINUX_RECOVERY \
GRUB_GFXMODE \
GRUB_THEME \
GRUB_DISABLE_OS_PROBER
GRUB_GFXPAYLOAD_LINUX \
GRUB_DISABLE_OS_PROBER \
GRUB_INIT_TUNE \
GRUB_SAVEDEFAULT
if test "x${grub_cfg}" != "x"; then
rm -f ${grub_cfg}.new

View File

@ -96,7 +96,7 @@ convert_system_path_to_grub_path ()
save_default_entry ()
{
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then
if [ "x${GRUB_SAVEDEFAULT}" = "xtrue" ] ; then
cat << EOF
savedefault
EOF
@ -120,7 +120,7 @@ prepare_grub_to_access_device ()
# If there's a filesystem UUID that GRUB is capable of identifying, use it;
# otherwise set root as per value in device.map.
echo "set root=`${grub_probe} --device ${device} --target=drive`"
echo "set root='`${grub_probe} --device ${device} --target=drive`'"
if fs_uuid="`${grub_probe} --device ${device} --target=fs_uuid 2> /dev/null`" ; then
echo "search --no-floppy --fs-uuid --set ${fs_uuid}"
fi

View File

@ -23,6 +23,7 @@
#include <grub/machine/kernel.h>
#include <grub/machine/memory.h>
#include <grub/elf.h>
#include <grub/aout.h>
#include <grub/i18n.h>
#include <grub/kernel.h>
#include <grub/disk.h>
@ -41,6 +42,8 @@
#include "progname.h"
#define ALIGN_ADDR(x) (ALIGN_UP((x), GRUB_TARGET_SIZEOF_VOID_P))
#ifdef ENABLE_LZMA
#include <grub/lib/LzmaEnc.h>
@ -129,20 +132,20 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
if (font_path)
{
font_size = ALIGN_UP(grub_util_get_image_size (font_path), 4);
font_size = ALIGN_ADDR (grub_util_get_image_size (font_path));
total_module_size += font_size + sizeof (struct grub_module_header);
}
if (config_path)
{
config_size_pure = grub_util_get_image_size (config_path) + 1;
config_size = ALIGN_UP(config_size_pure, 4);
config_size = ALIGN_ADDR (config_size_pure);
grub_util_info ("the size of config file is 0x%x", config_size);
total_module_size += config_size + sizeof (struct grub_module_header);
}
for (p = path_list; p; p = p->next)
total_module_size += (grub_util_get_image_size (p->name)
total_module_size += (ALIGN_ADDR (grub_util_get_image_size (p->name))
+ sizeof (struct grub_module_header));
grub_util_info ("the total module size is 0x%x", total_module_size);
@ -157,9 +160,9 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
/* Fill in the grub_module_info structure. */
modinfo = (struct grub_module_info *) (kernel_img + kernel_size);
memset (modinfo, 0, sizeof (struct grub_module_info));
modinfo->magic = GRUB_MODULE_MAGIC;
modinfo->offset = sizeof (struct grub_module_info);
modinfo->size = total_module_size;
modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC);
modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info));
modinfo->size = grub_host_to_target_addr (total_module_size);
offset = kernel_size + sizeof (struct grub_module_info);
for (p = path_list; p; p = p->next)
@ -168,11 +171,11 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
size_t mod_size, orig_size;
orig_size = grub_util_get_image_size (p->name);
mod_size = ALIGN_UP(orig_size, 4);
mod_size = ALIGN_ADDR (orig_size);
header = (struct grub_module_header *) (kernel_img + offset);
memset (header, 0, sizeof (struct grub_module_header));
header->type = OBJ_TYPE_ELF;
header->type = grub_host_to_target32 (OBJ_TYPE_ELF);
header->size = grub_host_to_target32 (mod_size + sizeof (*header));
offset += sizeof (*header);
memset (kernel_img + offset + orig_size, 0, mod_size - orig_size);
@ -187,7 +190,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
header = (struct grub_module_header *) (kernel_img + offset);
memset (header, 0, sizeof (struct grub_module_header));
header->type = OBJ_TYPE_MEMDISK;
header->type = grub_host_to_target32 (OBJ_TYPE_MEMDISK);
header->size = grub_host_to_target32 (memdisk_size + sizeof (*header));
offset += sizeof (*header);
@ -201,7 +204,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
header = (struct grub_module_header *) (kernel_img + offset);
memset (header, 0, sizeof (struct grub_module_header));
header->type = OBJ_TYPE_FONT;
header->type = grub_host_to_target32 (OBJ_TYPE_FONT);
header->size = grub_host_to_target32 (font_size + sizeof (*header));
offset += sizeof (*header);
@ -215,7 +218,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
header = (struct grub_module_header *) (kernel_img + offset);
memset (header, 0, sizeof (struct grub_module_header));
header->type = OBJ_TYPE_CONFIG;
header->type = grub_host_to_target32 (OBJ_TYPE_CONFIG);
header->size = grub_host_to_target32 (config_size + sizeof (*header));
offset += sizeof (*header);
@ -230,6 +233,36 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
grub_util_info ("the core size is 0x%x", core_size);
#ifdef GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE))
= grub_host_to_target32 (total_module_size);
#endif
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE))
= grub_host_to_target32 (kernel_size);
#ifdef GRUB_KERNEL_MACHINE_COMPRESSED_SIZE
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE))
= grub_host_to_target32 (core_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
#endif
#if defined(GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) && defined(GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
/* If we included a drive in our prefix, let GRUB know it doesn't have to
prepend the drive told by BIOS. */
if (prefix[0] == '(')
{
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART))
= grub_host_to_target32 (-2);
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART))
= grub_host_to_target32 (-2);
}
#endif
#ifdef GRUB_MACHINE_PCBIOS
if (GRUB_KERNEL_MACHINE_LINK_ADDR + core_size > GRUB_MEMORY_MACHINE_UPPER)
grub_util_error (_("core image is too big (%p > %p)"),
GRUB_KERNEL_MACHINE_LINK_ADDR + core_size,
GRUB_MEMORY_MACHINE_UPPER);
#endif
#if defined(GRUB_MACHINE_PCBIOS)
{
unsigned num;
@ -298,39 +331,52 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
free (boot_img);
free (boot_path);
}
#endif
#ifdef GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE))
= grub_host_to_target32 (total_module_size);
#endif
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE))
= grub_host_to_target32 (kernel_size);
#ifdef GRUB_KERNEL_MACHINE_COMPRESSED_SIZE
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE))
= grub_host_to_target32 (core_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
#endif
#if defined(GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) && defined(GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
/* If we included a drive in our prefix, let GRUB know it doesn't have to
prepend the drive told by BIOS. */
if (prefix[0] == '(')
#elif defined (GRUB_MACHINE_SPARC64)
if (format == GRUB_PLATFORM_IMAGE_AOUT)
{
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART))
= grub_host_to_target32 (-2);
*((grub_int32_t *) (core_img + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART))
= grub_host_to_target32 (-2);
void *aout_img;
size_t aout_size;
struct grub_aout32_header *aout_head;
aout_size = core_size + sizeof (*aout_head);
aout_img = xmalloc (aout_size);
aout_head = aout_img;
aout_head->a_midmag = grub_host_to_target32 ((AOUT_MID_SUN << 16)
| AOUT32_OMAGIC);
aout_head->a_text = grub_host_to_target32 (core_size);
aout_head->a_entry
= grub_host_to_target32 (GRUB_BOOT_MACHINE_IMAGE_ADDRESS);
memcpy (aout_img + sizeof (*aout_head), core_img, core_size);
free (core_img);
core_img = aout_img;
core_size = aout_size;
}
#endif
else
{
unsigned int num;
char *boot_path, *boot_img;
size_t boot_size;
#ifdef GRUB_MACHINE_PCBIOS
if (GRUB_KERNEL_MACHINE_LINK_ADDR + core_size > GRUB_MEMORY_MACHINE_UPPER)
grub_util_error (_("core image is too big (%p > %p)"),
GRUB_KERNEL_MACHINE_LINK_ADDR + core_size,
GRUB_MEMORY_MACHINE_UPPER);
#endif
num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
num <<= GRUB_DISK_SECTOR_BITS;
#if defined(GRUB_MACHINE_MIPS)
boot_path = grub_util_get_path (dir, "diskboot.img");
boot_size = grub_util_get_image_size (boot_path);
if (boot_size != GRUB_DISK_SECTOR_SIZE)
grub_util_error ("diskboot.img is not one sector size");
boot_img = grub_util_read_image (boot_path);
*((grub_uint32_t *) (boot_img + GRUB_DISK_SECTOR_SIZE
- GRUB_BOOT_MACHINE_LIST_SIZE + 8))
= grub_host_to_target32 (num);
grub_util_write_image (boot_img, boot_size, out);
free (boot_img);
free (boot_path);
}
#elif defined(GRUB_MACHINE_MIPS)
if (format == GRUB_PLATFORM_IMAGE_ELF)
{
char *elf_img;
@ -339,7 +385,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
Elf32_Phdr *phdr;
grub_uint32_t target_addr;
program_size = ALIGN_UP (core_size, 4);
program_size = ALIGN_ADDR (core_size);
elf_img = xmalloc (program_size + sizeof (*ehdr) + sizeof (*phdr));
memset (elf_img, 0, program_size + sizeof (*ehdr) + sizeof (*phdr));
@ -444,10 +490,8 @@ Make a bootable image of GRUB.\n\
-o, --output=FILE output a generated image to FILE [default=stdout]\n"
#ifdef GRUB_PLATFORM_IMAGE_DEFAULT
"\
-O, --format=FORMAT generate an image in format [default="
GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT "]\n \
available formats: "
GRUB_PLATFORM_IMAGE_FORMATS "\n"
-O, --format=FORMAT generate an image in format [default=%s]\n\
available formats: %s\n"
#endif
"\
-h, --help display this message and exit\n\
@ -455,7 +499,12 @@ Make a bootable image of GRUB.\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
"), program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
"),
program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY,
#ifdef GRUB_PLATFORM_IMAGE_DEFAULT
GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT, GRUB_PLATFORM_IMAGE_FORMATS,
#endif
PACKAGE_BUGREPORT);
exit (status);
}
@ -474,6 +523,8 @@ main (int argc, char *argv[])
grub_platform_image_format_t format = GRUB_PLATFORM_IMAGE_DEFAULT;
#endif
set_program_name (argv[0]);
grub_util_init_nls ();
while (1)
@ -503,6 +554,11 @@ main (int argc, char *argv[])
if (strcmp (optarg, "elf") == 0)
format = GRUB_PLATFORM_IMAGE_ELF;
else
#endif
#ifdef GRUB_PLATFORM_IMAGE_AOUT
if (strcmp (optarg, "aout") == 0)
format = GRUB_PLATFORM_IMAGE_AOUT;
else
#endif
usage (1);
break;

View File

@ -86,7 +86,15 @@ if [ "x${output_image}" = x ] ; then
exit 1
fi
iso9660_dir=`mktemp -d`
if test "x$TMP" != x; then
MKTEMP_TEMPLATE="$TMP/grub-mkrescue.XXXXXXXXXX"
elif test "x$TEMP" != x; then
MKTEMP_TEMPLATE="$TEMP/grub-mkrescue.XXXXXXXXXX"
else
MKTEMP_TEMPLATE="/tmp/grub-mkrescue.XXXXXXXXXX"
fi
iso9660_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
mkdir -p ${iso9660_dir}/boot/grub
process_input_dir ()
@ -133,11 +141,11 @@ fi
# build coreboot core.img
if test -e "${coreboot_dir}" ; then
echo "Enabling coreboot support ..."
memdisk_img=`mktemp`
memdisk_dir=`mktemp -d`
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
mkdir -p ${memdisk_dir}/boot/grub
# obtain date-based UUID
iso_uuid=$(date +%Y-%m-%d-%H-%M-%S-00)
iso_uuid=$(date -u +%Y-%m-%d-%H-%M-%S-00)
modules="$(cat ${coreboot_dir}/partmap.lst) ${modules}"
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
@ -162,12 +170,12 @@ fi
# build BIOS core.img
if test -e "${pc_dir}" ; then
echo "Enabling BIOS support ..."
core_img=`mktemp`
core_img=`mktemp "$MKTEMP_TEMPLATE"`
grub-mkimage -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \
iso9660 biosdisk
cat ${pc_dir}/cdboot.img ${core_img} > ${iso9660_dir}/boot/grub/i386-pc/eltorito.img
embed_img=`mktemp`
embed_img=`mktemp "$MKTEMP_TEMPLATE"`
cat ${pc_dir}/boot.img ${core_img} > ${embed_img}
rm -f ${core_img}

View File

@ -29,6 +29,8 @@
#include <stdlib.h>
#include <getopt.h>
#include "progname.h"
static struct option options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},

View File

@ -158,3 +158,11 @@ else
set timeout=${GRUB_TIMEOUT}
EOF
fi
# Play an initial tune
if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
cat << EOF
insmod play
play ${GRUB_INIT_TUNE}
EOF
fi

View File

@ -65,9 +65,16 @@ linux_entry ()
# Use ELILO's generic "efifb" when it's known to be available.
# FIXME: We need an interface to select vesafb in case efifb can't be used.
if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null ; then
cat << EOF
if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then
if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null \
&& grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" /boot/config-${version} 2> /dev/null; then
cat << EOF
set gfxpayload=keep
EOF
fi
else
cat << EOF
set gfxpayload=$GRUB_GFXPAYLOAD_LINUX
EOF
fi

View File

@ -180,6 +180,14 @@ for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
cp -f $file ${grubdir} || exit 1
done
# Copy gettext files
mkdir -p ${grubdir}/locale/
for file in ${grubdir}/locale/*.mo ${pkglibdir}/locale/*.mo; do
if test -f "$file"; then
cp -f "$file" ${grubdir}/locale/
fi
done
if ! test -f ${grubdir}/grubenv; then
$grub_editenv ${grubdir}/grubenv create
fi

View File

@ -418,7 +418,7 @@ unable_to_embed:
grub_util_warn (_("Embedding is not possible. GRUB can only be installed in this "
"setup by using blocklists. However, blocklists are UNRELIABLE and "
"its use is discouraged."));
"their use is discouraged."));
if (! force)
grub_util_error (_("if you really want blocklists, use --force"));

View File

@ -62,6 +62,7 @@ mdblocksizes = {"_gcry_digest_spec_crc32" : 64,
"_gcry_digest_spec_whirlpool" : 64}
cryptolist = open (os.path.join (cipher_dir_out, "crypto.lst"), "w")
conf.write ("MAINTAINER_CLEANFILES += $(srcdir)/conf/gcry.rmk $(srcdir)/lib/libgcrypt-grub/cipher/ChangeLog $(srcdir)/lib/libgcrypt-grub/cipher/cipher.h $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst $(srcdir)/lib/libgcrypt-grub/cipher/g10lib.h $(srcdir)/lib/libgcrypt-grub/cipher/memory.h $(srcdir)/lib/libgcrypt-grub/cipher/types.h\n");
# rijndael is the only cipher using aliases. So no need for mangling, just
# hardcode it
@ -87,6 +88,7 @@ for cipher_file in cipher_files:
continue
nch = False
if re.match (".*\.[ch]$", cipher_file):
conf.write ("MAINTAINER_CLEANFILES += $(srcdir)/lib/libgcrypt-grub/cipher/" + cipher_file + "\n");
isc = re.match (".*\.c$", cipher_file)
f = open (infile, "r")
fw = open (outfile, "w")

View File

@ -1,300 +0,0 @@
/* grub-mkimage.c - make a bootable image */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008,2009,2010 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 <config.h>
#include <grub/types.h>
#include <grub/machine/boot.h>
#include <grub/machine/kernel.h>
#include <grub/kernel.h>
#include <grub/i18n.h>
#include <grub/disk.h>
#include <grub/util/misc.h>
#include <grub/util/resolve.h>
#include <grub/misc.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#define _GNU_SOURCE 1
#include <getopt.h>
#include "progname.h"
static void
compress_kernel (char *kernel_img, size_t kernel_size,
char **core_img, size_t *core_size)
{
/* No compression support yet. */
grub_util_info ("kernel_img=%p, kernel_size=0x%x", kernel_img, kernel_size);
*core_img = xmalloc (kernel_size);
memcpy (*core_img, kernel_img, kernel_size);
*core_size = kernel_size;
}
static void
generate_image (const char *dir, const char *prefix, FILE *out, char *mods[], char *memdisk_path)
{
size_t kernel_size, total_module_size, memdisk_size, core_size, boot_size, offset;
char *kernel_path, *kernel_img, *core_img, *boot_path, *boot_img;
struct grub_util_path_list *path_list, *p;
struct grub_module_info *modinfo;
grub_addr_t module_addr;
unsigned int num;
path_list = grub_util_resolve_dependencies (dir, "moddep.lst", mods);
kernel_path = grub_util_get_path (dir, "kernel.img");
kernel_size = grub_util_get_image_size (kernel_path);
total_module_size = sizeof (struct grub_module_info);
for (p = path_list; p; p = p->next)
total_module_size += (grub_util_get_image_size (p->name)
+ sizeof (struct grub_module_header));
memdisk_size = 0;
if (memdisk_path)
{
memdisk_size = ALIGN_UP(grub_util_get_image_size (memdisk_path), 512);
grub_util_info ("the size of memory disk is 0x%x", memdisk_size);
total_module_size += memdisk_size + sizeof (struct grub_module_header);
}
grub_util_info ("the total module size is 0x%x", total_module_size);
kernel_img = xmalloc (kernel_size + total_module_size);
grub_util_load_image (kernel_path, kernel_img);
if ((GRUB_KERNEL_MACHINE_PREFIX + strlen (prefix) + 1)
> GRUB_KERNEL_MACHINE_DATA_END)
grub_util_error ("prefix too long");
strcpy (kernel_img + GRUB_KERNEL_MACHINE_PREFIX, prefix);
/* Fill in the grub_module_info structure. */
modinfo = (struct grub_module_info *) (kernel_img + kernel_size);
modinfo->magic = GRUB_MODULE_MAGIC;
modinfo->offset = sizeof (struct grub_module_info);
modinfo->size = total_module_size;
offset = kernel_size + sizeof (struct grub_module_info);
for (p = path_list; p; p = p->next)
{
struct grub_module_header *header;
size_t mod_size;
mod_size = grub_util_get_image_size (p->name);
header = (struct grub_module_header *) (kernel_img + offset);
header->type = OBJ_TYPE_ELF;
header->size = grub_host_to_target32 (mod_size + sizeof (*header));
offset += sizeof (*header);
grub_util_load_image (p->name, kernel_img + offset);
offset += mod_size;
}
if (memdisk_path)
{
struct grub_module_header *header;
header = (struct grub_module_header *) (kernel_img + offset);
header->type = OBJ_TYPE_MEMDISK;
header->size = grub_host_to_target32 (memdisk_size + sizeof (*header));
offset += sizeof (*header);
grub_util_load_image (memdisk_path, kernel_img + offset);
offset += memdisk_size;
}
compress_kernel (kernel_img, kernel_size + total_module_size,
&core_img, &core_size);
grub_util_info ("the core size is 0x%x", core_size);
num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
num <<= GRUB_DISK_SECTOR_BITS;
boot_path = grub_util_get_path (dir, "diskboot.img");
boot_size = grub_util_get_image_size (boot_path);
if (boot_size != GRUB_DISK_SECTOR_SIZE)
grub_util_error ("diskboot.img is not one sector size");
boot_img = grub_util_read_image (boot_path);
/* sparc is a big endian architecture. */
*((grub_uint32_t *) (boot_img + GRUB_DISK_SECTOR_SIZE
- GRUB_BOOT_MACHINE_LIST_SIZE + 8))
= grub_cpu_to_be32 (num);
grub_util_write_image (boot_img, boot_size, out);
free (boot_img);
free (boot_path);
module_addr = (path_list
? (GRUB_BOOT_MACHINE_IMAGE_ADDRESS + kernel_size)
: 0);
grub_util_info ("the first module address is 0x%x", module_addr);
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE))
= grub_cpu_to_be32 (total_module_size);
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE))
= grub_cpu_to_be32 (kernel_size);
/* No compression support yet. */
*((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE))
= grub_cpu_to_be32 (0);
grub_util_write_image (core_img, core_size, out);
free (kernel_img);
free (core_img);
free (kernel_path);
while (path_list)
{
struct grub_util_path_list *next = path_list->next;
free ((void *) path_list->name);
free (path_list);
path_list = next;
}
}
static struct option options[] =
{
{"directory", required_argument, 0, 'd'},
{"prefix", required_argument, 0, 'p'},
{"memdisk", required_argument, 0, 'm'},
{"output", required_argument, 0, 'o'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"verbose", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
static void
usage (int status)
{
if (status)
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
else
printf ("\
Usage: %s [OPTION]... [MODULES]\n\
\n\
Make a bootable image of GRUB.\n\
\n\
-d, --directory=DIR use images and modules under DIR [default=%s]\n\
-p, --prefix=DIR set grub_prefix directory [default=%s]\n\
-m, --memdisk=FILE embed FILE as a memdisk image\n\
-o, --output=FILE output a generated image to FILE [default=stdout]\n\
-h, --help display this message and exit\n\
-V, --version print version information and exit\n\
-v, --verbose print verbose messages\n\
\n\
Report bugs to <%s>.\n\
", program_name, GRUB_LIBDIR, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
exit (status);
}
int
main (int argc, char *argv[])
{
char *output = NULL;
char *dir = NULL;
char *prefix = NULL;
char *memdisk = NULL;
FILE *fp = stdout;
set_program_name (argv[0]);
grub_util_init_nls ();
while (1)
{
int c = getopt_long (argc, argv, "d:p:m:o:hVv", options, 0);
if (c == -1)
break;
else
switch (c)
{
case 'o':
if (output)
free (output);
output = xstrdup (optarg);
break;
case 'd':
if (dir)
free (dir);
dir = xstrdup (optarg);
break;
case 'm':
if (memdisk)
free (memdisk);
memdisk = xstrdup (optarg);
if (prefix)
free (prefix);
prefix = xstrdup ("(memdisk)/boot/grub");
break;
case 'h':
usage (0);
break;
case 'p':
if (prefix)
free (prefix);
prefix = xstrdup (optarg);
break;
case 'V':
printf ("grub-mkimage (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
return 0;
case 'v':
verbosity++;
break;
default:
usage (1);
break;
}
}
if (output)
{
fp = fopen (output, "wb");
if (! fp)
grub_util_error ("cannot open %s", output);
}
generate_image (dir ? : GRUB_LIBDIR,
prefix ? : DEFAULT_DIRECTORY, fp,
argv + optind, memdisk);
fclose (fp);
if (dir)
free (dir);
return 0;
}

View File

@ -1006,11 +1006,13 @@ grub_video_fb_scroll (grub_video_color_t color, int dx, int dy)
{ \
/* 3b. Move data downwards. */ \
dst = (void *) grub_video_fb_get_video_ptr (&target, \
dst_x + width - 1, \
dst_x + width, \
dst_y + height - 1); \
src = (void *) grub_video_fb_get_video_ptr (&target, \
src_x + width - 1, \
src_x + width, \
src_y + height - 1); \
dst--; \
src--; \
for (j = 0; j < height; j++) \
{ \
for (i = 0; i < linelen; i++) \

View File

@ -22,6 +22,7 @@
#include <grub/machine/memory.h>
#include <grub/machine/vga.h>
#include <grub/machine/vbe.h>
#include <grub/video_fb.h>
#include <grub/types.h>
#include <grub/dl.h>
#include <grub/misc.h>

299
video/ieee1275.c Normal file
View File

@ -0,0 +1,299 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2006,2007,2008,2009 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/>.
*/
#define grub_video_render_target grub_video_fbrender_target
#include <grub/err.h>
#include <grub/types.h>
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/video.h>
#include <grub/video_fb.h>
#include <grub/ieee1275/ieee1275.h>
/* Only 8-bit indexed color is supported for now. */
static unsigned old_width, old_height;
static int restore_needed;
static char *display;
static struct
{
struct grub_video_mode_info mode_info;
struct grub_video_render_target *render_target;
grub_uint8_t *ptr;
} framebuffer;
static grub_err_t
grub_video_ieee1275_set_palette (unsigned int start, unsigned int count,
struct grub_video_palette_data *palette_data);
static void
set_video_mode (unsigned width __attribute__ ((unused)),
unsigned height __attribute__ ((unused)))
{
/* TODO */
}
static void
find_display (void)
{
auto int hook (struct grub_ieee1275_devalias *alias);
int hook (struct grub_ieee1275_devalias *alias)
{
if (grub_strcmp (alias->type, "display") == 0)
{
grub_dprintf ("video", "Found display %s\n", alias->path);
display = grub_strdup (alias->path);
return 1;
}
return 0;
}
grub_ieee1275_devices_iterate (hook);
}
static grub_err_t
grub_video_ieee1275_init (void)
{
grub_memset (&framebuffer, 0, sizeof(framebuffer));
return grub_video_fb_init ();
}
static grub_err_t
grub_video_ieee1275_fini (void)
{
if (restore_needed)
{
set_video_mode (old_width, old_height);
restore_needed = 0;
}
return grub_video_fb_fini ();
}
static grub_err_t
grub_video_ieee1275_fill_mode_info (grub_ieee1275_phandle_t dev,
struct grub_video_mode_info *out)
{
grub_uint32_t tmp;
grub_memset (out, 0, sizeof (*out));
if (grub_ieee1275_get_integer_property (dev, "width", &tmp,
sizeof (tmp), 0))
return grub_error (GRUB_ERR_IO, "Couldn't retrieve display width.");
out->width = tmp;
if (grub_ieee1275_get_integer_property (dev, "height", &tmp,
sizeof (tmp), 0))
return grub_error (GRUB_ERR_IO, "Couldn't retrieve display height.");
out->height = tmp;
if (grub_ieee1275_get_integer_property (dev, "linebytes", &tmp,
sizeof (tmp), 0))
return grub_error (GRUB_ERR_IO, "Couldn't retrieve display pitch.");
out->pitch = tmp;
out->mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
out->bpp = 8;
out->bytes_per_pixel = 1;
out->number_of_colors = 256;
out->blit_format = grub_video_get_blit_format (out);
return GRUB_ERR_NONE;
}
static grub_err_t
grub_video_ieee1275_setup (unsigned int width, unsigned int height,
unsigned int mode_type __attribute__ ((unused)),
unsigned int mode_mask __attribute__ ((unused)))
{
grub_uint32_t current_width, current_height, address;
grub_err_t err;
grub_ieee1275_phandle_t dev;
if (!display)
return grub_error (GRUB_ERR_IO, "Couldn't find display device.");
if (grub_ieee1275_finddevice (display, &dev))
return grub_error (GRUB_ERR_IO, "Couldn't open display device.");
if (grub_ieee1275_get_integer_property (dev, "width", &current_width,
sizeof (current_width), 0))
return grub_error (GRUB_ERR_IO, "Couldn't retrieve display width.");
if (grub_ieee1275_get_integer_property (dev, "height", &current_height,
sizeof (current_width), 0))
return grub_error (GRUB_ERR_IO, "Couldn't retrieve display height.");
if ((width == current_width && height == current_height)
|| (width == 0 && height == 0))
{
grub_dprintf ("video", "IEEE1275: keeping current mode %dx%d\n",
current_width, current_height);
}
else
{
grub_dprintf ("video", "IEEE1275: Setting mode %dx%d\n", width, height);
/* TODO. */
return grub_error (GRUB_ERR_IO, "can't set mode %dx%d", width, height);
}
err = grub_video_ieee1275_fill_mode_info (dev, &framebuffer.mode_info);
if (err)
{
grub_dprintf ("video", "IEEE1275: couldn't fill mode info\n");
return err;
}
if (grub_ieee1275_get_integer_property (dev, "address", &address,
sizeof (address), 0))
return grub_error (GRUB_ERR_IO, "Couldn't retrieve display address.");
framebuffer.ptr = (void *) address;
grub_video_ieee1275_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
grub_video_fbstd_colors);
grub_dprintf ("video", "IEEE1275: initialising FB @ %p %dx%dx%d\n",
framebuffer.ptr, framebuffer.mode_info.width,
framebuffer.mode_info.height, framebuffer.mode_info.bpp);
err = grub_video_fb_create_render_target_from_pointer
(&framebuffer.render_target, &framebuffer.mode_info, framebuffer.ptr);
if (err)
{
grub_dprintf ("video", "IEEE1275: Couldn't create FB target\n");
return err;
}
err = grub_video_fb_set_active_render_target (framebuffer.render_target);
if (err)
{
grub_dprintf ("video", "IEEE1275: Couldn't set FB target\n");
return err;
}
err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
grub_video_fbstd_colors);
if (err)
grub_dprintf ("video", "IEEE1275: Couldn't set palette\n");
else
grub_dprintf ("video", "IEEE1275: Success\n");
return err;
}
static grub_err_t
grub_video_ieee1275_swap_buffers (void)
{
/* TODO: Implement buffer swapping. */
return GRUB_ERR_NONE;
}
static grub_err_t
grub_video_ieee1275_set_active_render_target (struct grub_video_render_target *target)
{
if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
target = framebuffer.render_target;
return grub_video_fb_set_active_render_target (target);
}
static grub_err_t
grub_video_ieee1275_get_info_and_fini (struct grub_video_mode_info *mode_info,
void **framebuf)
{
grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
*framebuf = (char *) framebuffer.ptr;
grub_video_fb_fini ();
return GRUB_ERR_NONE;
}
static grub_err_t
grub_video_ieee1275_set_palette (unsigned int start, unsigned int count,
struct grub_video_palette_data *palette_data)
{
grub_err_t err;
struct grub_video_palette_data fb_palette_data[256];
err = grub_video_fb_set_palette (start, count, palette_data);
if (err)
return err;
grub_video_fb_get_palette (0, 256, fb_palette_data);
/* TODO. */
return GRUB_ERR_NONE;
}
static struct grub_video_adapter grub_video_ieee1275_adapter =
{
.name = "IEEE1275 video driver",
.init = grub_video_ieee1275_init,
.fini = grub_video_ieee1275_fini,
.setup = grub_video_ieee1275_setup,
.get_info = grub_video_fb_get_info,
.get_info_and_fini = grub_video_ieee1275_get_info_and_fini,
.set_palette = grub_video_ieee1275_set_palette,
.get_palette = grub_video_fb_get_palette,
.set_viewport = grub_video_fb_set_viewport,
.get_viewport = grub_video_fb_get_viewport,
.map_color = grub_video_fb_map_color,
.map_rgb = grub_video_fb_map_rgb,
.map_rgba = grub_video_fb_map_rgba,
.unmap_color = grub_video_fb_unmap_color,
.fill_rect = grub_video_fb_fill_rect,
.blit_bitmap = grub_video_fb_blit_bitmap,
.blit_render_target = grub_video_fb_blit_render_target,
.scroll = grub_video_fb_scroll,
.swap_buffers = grub_video_ieee1275_swap_buffers,
.create_render_target = grub_video_fb_create_render_target,
.delete_render_target = grub_video_fb_delete_render_target,
.set_active_render_target = grub_video_ieee1275_set_active_render_target,
.get_active_render_target = grub_video_fb_get_active_render_target,
.next = 0
};
GRUB_MOD_INIT(ieee1275_fb)
{
find_display ();
if (display)
grub_video_register (&grub_video_ieee1275_adapter);
}
GRUB_MOD_FINI(ieee1275_fb)
{
if (restore_needed)
{
set_video_mode (old_width, old_height);
restore_needed = 0;
}
if (display)
grub_video_unregister (&grub_video_ieee1275_adapter);
grub_free (display);
}