merge mainline into rescue-efi
This commit is contained in:
commit
918405fd8c
93 changed files with 2110 additions and 1525 deletions
351
ChangeLog
351
ChangeLog
|
@ -1,3 +1,352 @@
|
||||||
|
2010-05-17 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
|
Source tree is reorganized for emu build.
|
||||||
|
|
||||||
|
* include/grub/util/console.h: Move from here...
|
||||||
|
* include/grub/emu/console.h: ...to here.
|
||||||
|
* include/grub/util/getroot.h: Move from here...
|
||||||
|
* include/grub/emu/getroot.h: ...to here.
|
||||||
|
* include/grub/util/hostdisk.h: Move from here...
|
||||||
|
* include/grub/emu/hostdisk.h: ...to here.
|
||||||
|
* util/console.c: Move from here...
|
||||||
|
* kern/emu/console.c: ...to here.
|
||||||
|
* util/getroot.c: Move from here...
|
||||||
|
* kern/emu/getroot.c: ...to here.
|
||||||
|
* util/grub-emu.c: Move from here...
|
||||||
|
* kern/emu/main.c: ...to here.
|
||||||
|
* util/hostdisk.c: Move from here...
|
||||||
|
* kern/emu/hostdisk.c: ...to here.
|
||||||
|
* util/hostfs.c: Move from here...
|
||||||
|
* kern/emu/hostfs.c: ...to here.
|
||||||
|
* util/mm.c: Move from here...
|
||||||
|
* kern/emu/mm.c: ...to here.
|
||||||
|
* util/pci.c: Move from here...
|
||||||
|
* bus/emu/pci.c: ...to here.
|
||||||
|
* util/sdl.c: Move from here...
|
||||||
|
* video/emu/sdl.c: ...to here.
|
||||||
|
* util/time.c: Move from here...
|
||||||
|
* kern/emu/time.c: ...to here.
|
||||||
|
* util/usb.c: Move from here...
|
||||||
|
* bus/usb/emu/usb.c: ...to here.
|
||||||
|
|
||||||
|
* include/grub/emu/misc.h: New header for grub-emu functions.
|
||||||
|
* kern/emu/misc.c: grub-emu functions separated from util/misc.c
|
||||||
|
|
||||||
|
* conf/any-emu.rmk: Rule updates for above renames.
|
||||||
|
* conf/common.rmk: Likewise.
|
||||||
|
* conf/i386-pc.rmk: Likewise.
|
||||||
|
* conf/i386-qemu.rmk: Likewise.
|
||||||
|
* conf/mips.rmk: Likewise.
|
||||||
|
* conf/sparc64-ieee1275.rmk: Likewise.
|
||||||
|
* conf/x86-efi.rmk: Likewise.
|
||||||
|
|
||||||
|
* disk/lvm.h: #include updates for above renames.
|
||||||
|
* util/grub-mkrelpath.c: Likewise.
|
||||||
|
* util/grub-probe.c: Likewise.
|
||||||
|
* util/i386/pc/grub-setup.c: Likewise.
|
||||||
|
* util/sparc64/ieee1275/grub-setup.c: Likewise.
|
||||||
|
* kern/emu/console.c: Likewise.
|
||||||
|
* kern/emu/getroot.c: Likewise.
|
||||||
|
* kern/emu/hostdisk.c: Likewise.
|
||||||
|
* kern/emu/main.c: Likewise. (was grub-emu.c earlier)
|
||||||
|
|
||||||
|
* include/grub/dl.h: Remove grub_dl_{ref,unref}.
|
||||||
|
* include/grub/util/misc.h: Move grub-emu functions to emu/misc.h.
|
||||||
|
* kern/dl.c: Handle null mod in grub_dl_{ref,unref}.
|
||||||
|
* util/misc.c: Remove grub-emu functions.
|
||||||
|
|
||||||
|
2010-05-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Fix gfxmenu crash.
|
||||||
|
Reported by: Thorsten Grützmacher.
|
||||||
|
|
||||||
|
* gfxmenu/gui_circular_progress.c (circprog_destroy): Unregister
|
||||||
|
timeout hook.
|
||||||
|
(circprog_set_property): Register and unregister timeout hook.
|
||||||
|
* gfxmenu/gui_label.c (grub_gui_label): New fields template and value.
|
||||||
|
(label_destroy): Free template. and unregister hook.
|
||||||
|
(label_set_state): New function.
|
||||||
|
(label_set_property): Handle templates and hooks.
|
||||||
|
* gfxmenu/gui_progress_bar.c (progress_bar_destroy): Unregister
|
||||||
|
timeout hook.
|
||||||
|
(progress_bar_set_property): Register and unregister timeout hook.
|
||||||
|
* gfxmenu/view.c (TIMEOUT_COMPONENT_ID): Move from here ...
|
||||||
|
* include/grub/gui.h (GRUB_GFXMENU_TIMEOUT_COMPONENT_ID): ...to here
|
||||||
|
* gfxmenu/view.c (grub_gfxmenu_timeout_notifications): New variable.
|
||||||
|
(update_timeout_visit): Removed.
|
||||||
|
(update_timeouts): New function.
|
||||||
|
(redraw_timeouts): Likewise.
|
||||||
|
(grub_gfxmenu_print_timeout): Use update_timeouts and redraw_timeouts.
|
||||||
|
(grub_gfxmenu_clear_timeout): Likewise.
|
||||||
|
* include/grub/gui.h (grub_gfxmenu_set_state_t): New type.
|
||||||
|
(grub_gfxmenu_timeout_notify): Likewise.
|
||||||
|
(grub_gfxmenu_timeout_notifications): New external variable.
|
||||||
|
(grub_gfxmenu_timeout_register): New function.
|
||||||
|
(grub_gfxmenu_timeout_unregister): Likewise.
|
||||||
|
|
||||||
|
2010-05-09 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Transform (broken) vga terminal into (working) vga video driver.
|
||||||
|
|
||||||
|
* conf/i386-pc.rmk (vga_mod_SOURCES): Change term/i386/pc/vga.c to
|
||||||
|
video/i386/pc/vga.c.
|
||||||
|
* include/grub/video.h (grub_video_driver_id):
|
||||||
|
Add GRUB_VIDEO_DRIVER_VGA.
|
||||||
|
* term/i386/pc/vga.c: Renamed to ...
|
||||||
|
* video/i386/pc/vga.c: ...this
|
||||||
|
(DEBUG_VGA): Removed.
|
||||||
|
(CHAR_WIDTH): Likewise.
|
||||||
|
(CHAR_HEIGHT): Likewise.
|
||||||
|
(TEXT_WIDTH): Likewise.
|
||||||
|
(TEXT_HEIGHT): Likewise.
|
||||||
|
(DEFAULT_FG_COLOR): Likewise.
|
||||||
|
(DEFAULT_BG_COLOR): Likewise.
|
||||||
|
(colored_char): Likewise.
|
||||||
|
(xpos): Likewise.
|
||||||
|
(ypos): Likewise.
|
||||||
|
(cursor_state): Likewise.
|
||||||
|
(fg_color): Likewise.
|
||||||
|
(bg_color): Likewise.
|
||||||
|
(text_buf): Likewise.
|
||||||
|
(page): Likewise.
|
||||||
|
(font): Likewise.
|
||||||
|
(framebuffer): New variable.
|
||||||
|
(set_read_map): Disabled.
|
||||||
|
(setup): New variable.
|
||||||
|
(is_target): Likewise.
|
||||||
|
(grub_vga_mod_init): Likewise.
|
||||||
|
(grub_vga_mod_fini): Likewise.
|
||||||
|
(check_vga_mem): Likewise.
|
||||||
|
(write_char): Likewise.
|
||||||
|
(write_cursor): Likewise.
|
||||||
|
(scroll_up): Likewise.
|
||||||
|
(grub_vga_putchar): Likewise.
|
||||||
|
(grub_vga_getcharwidth): Likewise.
|
||||||
|
(grub_vga_getwh): Likewise.
|
||||||
|
(grub_vga_getxy): Likewise.
|
||||||
|
(grub_vga_gotoxy): Likewise.
|
||||||
|
(grub_vga_cls): Likewise.
|
||||||
|
(grub_vga_setcolorstate): Likewise.
|
||||||
|
(grub_vga_setcursor): Likewise.
|
||||||
|
(grub_video_vga_init): New function.
|
||||||
|
(grub_video_vga_setup): Likewise.
|
||||||
|
(grub_video_vga_fini): Likewise.
|
||||||
|
(update_target): Likewise.
|
||||||
|
(grub_video_vga_blit_bitmap): Likewise.
|
||||||
|
(grub_video_vga_blit_render_target): Likewise.
|
||||||
|
(grub_video_vga_set_active_render_target): Likewise.
|
||||||
|
(grub_video_vga_get_active_render_target): Likewise.
|
||||||
|
(grub_video_vga_swap_buffers): Likewise.
|
||||||
|
(grub_video_vga_set_palette): Likewise.
|
||||||
|
(grub_video_vga_get_info_and_fini): Likewise.
|
||||||
|
(grub_vga_term): Removed.
|
||||||
|
(grub_video_vga_adapter): New variable.
|
||||||
|
(GRUB_MOD_INIT): Register a video driver instead of terminal.
|
||||||
|
(GRUB_MOD_FINI): Unrefister a video driver instead of terminal.
|
||||||
|
|
||||||
|
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* video/readers/jpeg.c: Indented.
|
||||||
|
|
||||||
|
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Various jpeg cleanups.
|
||||||
|
|
||||||
|
* video/readers/jpeg.c (grub_jpeg_get_huff_code): Use ARRAY_SIZE.
|
||||||
|
(grub_jpeg_decode_quan_table): Use sizeof.
|
||||||
|
(grub_jpeg_decode_du): Use ARRAY_SIZE.
|
||||||
|
|
||||||
|
2010-05-05 Peter Hurley <No e-mail available> (tiny change)
|
||||||
|
|
||||||
|
* video/readers/jpeg.c (grub_jpeg_decode_huff_table): Loop over all
|
||||||
|
tables. Ignore non-last ac bit.
|
||||||
|
(grub_jpeg_decode_quan_table): Likewise.
|
||||||
|
|
||||||
|
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New value
|
||||||
|
GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM.
|
||||||
|
* kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set
|
||||||
|
GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM on qemu.
|
||||||
|
* kern/ieee1275/init.c (grub_claim_heap): Don0t allocate below
|
||||||
|
1.5MiB if GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM is set.
|
||||||
|
|
||||||
|
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* term/ieee1275/ofconsole.c (grub_ofconsole_getkey): Fix off-by-one
|
||||||
|
error.
|
||||||
|
|
||||||
|
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* term/ieee1275/ofconsole.c (grub_ofconsole_readkey): Support C0 code.
|
||||||
|
|
||||||
|
2010-05-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* commands/parttool.c (grub_cmd_parttool): Fix #if !GRUB_NO_MODULES
|
||||||
|
condition.
|
||||||
|
|
||||||
|
2010-05-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/mm.c (grub_real_malloc): Put magic and size assignment in common
|
||||||
|
part.
|
||||||
|
|
||||||
|
2010-05-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/mm.c (grub_mm_init_region): Check for region size after aligning
|
||||||
|
pointers.
|
||||||
|
|
||||||
|
2010-05-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/mm.c (grub_real_malloc): Fix size calculation when extra == 0.
|
||||||
|
|
||||||
|
2010-05-01 Christian Franke <franke@computer.org>
|
||||||
|
|
||||||
|
* util/grub-mkconfig_lib.in (make_system_path_relative_to_its_root):
|
||||||
|
Remove broken Cygwin path conversion.
|
||||||
|
* util/misc.c: [__CYGWIN__] Add include and define.
|
||||||
|
[__CYGWIN__] (get_win32_path): Copy function from getroot.c, modify
|
||||||
|
for Cygwin 1.7.
|
||||||
|
(make_system_path_relative_to_its_root): Simplify loop, replace early
|
||||||
|
return by break.
|
||||||
|
[__CYGWIN__] Add conversion to win32 path.
|
||||||
|
Include "/" case in trailing slash removal.
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/main.c (grub_load_config): Fix copy-pasted comment.
|
||||||
|
Reported by: Seth Goldberg
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* commands/help.c (grub_cmd_help): Fix a typo.
|
||||||
|
Reported by: Seth Goldberg
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* commands/hashsum.c (GRUB_MOD_INIT): Remove duplication of command
|
||||||
|
name and add N_.
|
||||||
|
* commands/i386/pc/drivemap.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* commands/iorw.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* commands/password_pbkdf2.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* commands/regexp.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* commands/setpci.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* commands/terminal.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* efiemu/main.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* font/font_cmd.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* kern/corecmd.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* mmap/mmap.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* normal/context.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* normal/main.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* term/gfxterm.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* term/serial.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
* term/terminfo.c (GRUB_MOD_INIT): Likewise.
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/mm.c (grub_real_malloc): Satisfy alignment requirement when
|
||||||
|
extra == 0.
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* commands/iorw.c: New file.
|
||||||
|
* conf/i386.rmk (pkglib_MODULES): Add iorw.mod.
|
||||||
|
(iorw_mod_SOURCES): New variable.
|
||||||
|
(iorw_mod_CFLAGS): Likewise.
|
||||||
|
(iorw_mod_LDFLAGS): Likewise.
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Hotkey support
|
||||||
|
|
||||||
|
* include/grub/menu.h (grub_menu_entry): New field 'hotkey'.
|
||||||
|
* normal/main.c (hotkey_aliases): New variable.
|
||||||
|
(grub_normal_add_menu_entry): Parse "--hotkey".
|
||||||
|
* normal/menu_text.c (run_menu): Handle hotkeys.
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/i386/coreboot/init.c (grub_machine_init): Call
|
||||||
|
grub_machine_mmap_init on qemu.
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* boot/i386/qemu/boot.S: Add a missing .code16.
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Use LBIO on coreboot.
|
||||||
|
|
||||||
|
* conf/i386-coreboot.rmk (kernel_img_SOURCES): Change
|
||||||
|
kern/i386/multiboot_mmap.c to kern/i386/coreboot/mmap.c.
|
||||||
|
* include/grub/i386/coreboot/memory.h (GRUB_LINUXBIOS_MEMBER_LINK):
|
||||||
|
New declaration.
|
||||||
|
* kern/i386/coreboot/init.c (grub_machine_init): Don't call
|
||||||
|
grub_machine_mmap_init on coreboot.
|
||||||
|
* kern/i386/coreboot/mmap.c (grub_linuxbios_table_iterate): Handle
|
||||||
|
GRUB_LINUXBIOS_MEMBER_LINK.
|
||||||
|
(grub_machine_mmap_iterate): Fix declaration.
|
||||||
|
* kern/i386/coreboot/startup.S: Don't save mbi location on coreboot.
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Split coreboot and multiboot ports.
|
||||||
|
|
||||||
|
* conf/i386-multiboot.rmk: New file.
|
||||||
|
* configure.ac: Add multiboot port.
|
||||||
|
* include/grub/i386/multiboot/boot.h: New file.
|
||||||
|
* include/grub/i386/multiboot/console.h: Likewise.
|
||||||
|
* include/grub/i386/multiboot/init.h: Likewise.
|
||||||
|
* include/grub/i386/multiboot/kernel.h: Likewise.
|
||||||
|
* include/grub/i386/multiboot/loader.h: Likewise.
|
||||||
|
* include/grub/i386/multiboot/memory.h: Likewise.
|
||||||
|
* include/grub/i386/multiboot/serial.h: Likewise.
|
||||||
|
* include/grub/i386/multiboot/time.h: Likewise.
|
||||||
|
* include/grub/multiboot.h: Add GRUB_MACHINE_MULTIBOOT to ifdef.
|
||||||
|
* loader/multiboot.c: Likewise.
|
||||||
|
* loader/multiboot_mbi2.c: Likewise.
|
||||||
|
* util/grub-mkrescue.in: Generate multiboot rescue.
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/parser.c (grub_parser_execute): Cope with read-only config.
|
||||||
|
|
||||||
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Merge handling of input and output terminals. Fix a hang.
|
||||||
|
|
||||||
|
* commands/terminal.c (abstract_terminal): New struct.
|
||||||
|
(handle_command): New function. Based on grub_cmd_terminal_input.
|
||||||
|
(grub_cmd_terminal_input): Use handle_command.
|
||||||
|
(grub_cmd_terminal_output): Use handle_command.
|
||||||
|
|
||||||
|
2010-05-01 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
|
Fix comment handling.
|
||||||
|
|
||||||
|
* tests/grub_script_comments.in: New testcase.
|
||||||
|
* conf/tests.rmk: Rules for new testcase.
|
||||||
|
* script/yylex.l: Updated flex rules.
|
||||||
|
|
||||||
|
2010-04-28 Samuel Thibault <samuel.thibault@ens-lyon.org>
|
||||||
|
|
||||||
|
* docs/grub.texi (play): Document that zero pitches produce rests.
|
||||||
|
* commands/i386/pc/play.c (grub_cmd_play): Call 'grub_file_open' only
|
||||||
|
if argc is 1.
|
||||||
|
|
||||||
|
2010-04-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* conf/x86-efi.rmk (linux_mod_SOURCES): Write explicitly to avoid
|
||||||
|
autogen issues.
|
||||||
|
|
||||||
|
2010-04-26 Christian Franke <franke@computer.org>
|
||||||
|
|
||||||
|
* include/grub/util/getroot.h (grub_get_prefix): Remove prototype.
|
||||||
|
* util/getroot.c [__CYGWIN__] (get_win32_path): Remove function.
|
||||||
|
(grub_get_prefix): Remove function.
|
||||||
|
* util/grub-emu.c (main): Replace grub_get_prefix () call by
|
||||||
|
make_system_path_relative_to_its_root ().
|
||||||
|
* util/sparc64/ieee1275/grub-setup.c (main): Likewise.
|
||||||
|
|
||||||
2010-04-24 Christian Franke <franke@computer.org>
|
2010-04-24 Christian Franke <franke@computer.org>
|
||||||
|
|
||||||
* Makefile.in (TARGET_LDFLAGS): Add -static-libgcc.
|
* Makefile.in (TARGET_LDFLAGS): Add -static-libgcc.
|
||||||
|
@ -95,7 +444,7 @@
|
||||||
|
|
||||||
* disk/lvm.c (grub_lvm_memberlist): Issue an error if pv->disk = 0.
|
* disk/lvm.c (grub_lvm_memberlist): Issue an error if pv->disk = 0.
|
||||||
|
|
||||||
2010-04-17 Christian Franke <franke@computer.org>
|
2010-04-17 Christian Franke <franke@computer.org>
|
||||||
|
|
||||||
* Makefile.in: Add missing localedir setting.
|
* Makefile.in: Add missing localedir setting.
|
||||||
|
|
||||||
|
|
|
@ -63,5 +63,8 @@ VARIABLE(grub_core_entry_addr)
|
||||||
*right here* and this is why we need this kludge. */
|
*right here* and this is why we need this kludge. */
|
||||||
|
|
||||||
. = GRUB_BOOT_MACHINE_SIZE - 16
|
. = GRUB_BOOT_MACHINE_SIZE - 16
|
||||||
|
|
||||||
|
.code16
|
||||||
|
|
||||||
jmp _start
|
jmp _start
|
||||||
. = GRUB_BOOT_MACHINE_SIZE
|
. = GRUB_BOOT_MACHINE_SIZE
|
||||||
|
|
|
@ -105,14 +105,14 @@ grub_usb_root_hub (grub_usb_controller_t controller __attribute__((unused)))
|
||||||
grub_usb_err_t
|
grub_usb_err_t
|
||||||
grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
|
grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
|
||||||
grub_uint8_t request, grub_uint16_t value,
|
grub_uint8_t request, grub_uint16_t value,
|
||||||
grub_uint16_t index, grub_size_t size, char *data)
|
grub_uint16_t idx, grub_size_t size, char *data)
|
||||||
{
|
{
|
||||||
usb_dev_handle *devh;
|
usb_dev_handle *devh;
|
||||||
struct usb_device *d = dev->data;
|
struct usb_device *d = dev->data;
|
||||||
|
|
||||||
devh = usb_open (d);
|
devh = usb_open (d);
|
||||||
if (usb_control_msg (devh, reqtype, request,
|
if (usb_control_msg (devh, reqtype, request,
|
||||||
value, index, data, size, 20) < 0)
|
value, idx, data, size, 20) < 0)
|
||||||
{
|
{
|
||||||
usb_close (devh);
|
usb_close (devh);
|
||||||
return GRUB_USB_ERR_STALL;
|
return GRUB_USB_ERR_STALL;
|
|
@ -24,13 +24,14 @@
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/crypto.h>
|
#include <grub/crypto.h>
|
||||||
#include <grub/normal.h>
|
#include <grub/normal.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
static const struct grub_arg_option options[] = {
|
static const struct grub_arg_option options[] = {
|
||||||
{"hash", 'h', 0, "Specify hash to use.", "HASH", ARG_TYPE_STRING},
|
{"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING},
|
||||||
{"check", 'c', 0, "Check hash list file.", "FILE", ARG_TYPE_STRING},
|
{"check", 'c', 0, N_("Check hash list file."), N_("FILE"), ARG_TYPE_STRING},
|
||||||
{"prefix", 'p', 0, "Base directory for hash list.", "DIRECTORY",
|
{"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIRECTORY"),
|
||||||
ARG_TYPE_STRING},
|
ARG_TYPE_STRING},
|
||||||
{"keep-going", 'k', 0, "Don't stop after first error.", 0, 0},
|
{"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},
|
||||||
{0, 0, 0, 0, 0, 0}
|
{0, 0, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -249,21 +250,21 @@ GRUB_MOD_INIT(hashsum)
|
||||||
options);
|
options);
|
||||||
cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum,
|
cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum,
|
||||||
GRUB_COMMAND_FLAG_BOTH,
|
GRUB_COMMAND_FLAG_BOTH,
|
||||||
"md5sum [-c FILE [-p PREFIX]] "
|
N_("[-c FILE [-p PREFIX]] "
|
||||||
"[FILE1 [FILE2 ...]]",
|
"[FILE1 [FILE2 ...]]"),
|
||||||
"Compute or check hash checksum.",
|
N_("Compute or check hash checksum."),
|
||||||
options);
|
options);
|
||||||
cmd_sha256 = grub_register_extcmd ("sha256sum", grub_cmd_hashsum,
|
cmd_sha256 = grub_register_extcmd ("sha256sum", grub_cmd_hashsum,
|
||||||
GRUB_COMMAND_FLAG_BOTH,
|
GRUB_COMMAND_FLAG_BOTH,
|
||||||
"sha256sum [-c FILE [-p PREFIX]] "
|
N_("[-c FILE [-p PREFIX]] "
|
||||||
"[FILE1 [FILE2 ...]]",
|
"[FILE1 [FILE2 ...]]"),
|
||||||
"Compute or check hash checksum.",
|
"Compute or check hash checksum.",
|
||||||
options);
|
options);
|
||||||
cmd_sha512 = grub_register_extcmd ("sha512sum", grub_cmd_hashsum,
|
cmd_sha512 = grub_register_extcmd ("sha512sum", grub_cmd_hashsum,
|
||||||
GRUB_COMMAND_FLAG_BOTH,
|
GRUB_COMMAND_FLAG_BOTH,
|
||||||
"sha512sum [-c FILE [-p PREFIX]] "
|
N_("[-c FILE [-p PREFIX]] "
|
||||||
"[FILE1 [FILE2 ...]]",
|
"[FILE1 [FILE2 ...]]"),
|
||||||
"Compute or check hash checksum.",
|
N_("Compute or check hash checksum."),
|
||||||
options);
|
options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
|
||||||
if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
|
if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
|
||||||
grub_arg_show_help ((grub_extcmd_t) cmd->data);
|
grub_arg_show_help ((grub_extcmd_t) cmd->data);
|
||||||
else
|
else
|
||||||
grub_printf ("%s %s %s\n%s\b", _("Usage:"), cmd->name, _(cmd->summary),
|
grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name, _(cmd->summary),
|
||||||
_(cmd->description));
|
_(cmd->description));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,11 +402,10 @@ GRUB_MOD_INIT (drivemap)
|
||||||
grub_get_root_biosnumber_saved = grub_get_root_biosnumber;
|
grub_get_root_biosnumber_saved = grub_get_root_biosnumber;
|
||||||
grub_get_root_biosnumber = grub_get_root_biosnumber_drivemap;
|
grub_get_root_biosnumber = grub_get_root_biosnumber_drivemap;
|
||||||
cmd = grub_register_extcmd ("drivemap", grub_cmd_drivemap,
|
cmd = grub_register_extcmd ("drivemap", grub_cmd_drivemap,
|
||||||
GRUB_COMMAND_FLAG_BOTH,
|
GRUB_COMMAND_FLAG_BOTH,
|
||||||
"drivemap"
|
N_("-l | -r | [-s] grubdev osdisk."),
|
||||||
N_("-l | -r | [-s] grubdev osdisk."),
|
N_("Manage the BIOS drive mappings."),
|
||||||
N_("Manage the BIOS drive mappings."),
|
options);
|
||||||
options);
|
|
||||||
drivemap_hook =
|
drivemap_hook =
|
||||||
grub_loader_register_preboot_hook (&install_int13_handler,
|
grub_loader_register_preboot_hook (&install_int13_handler,
|
||||||
&uninstall_int13_handler,
|
&uninstall_int13_handler,
|
||||||
|
|
|
@ -177,16 +177,20 @@ static grub_err_t
|
||||||
grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
||||||
int argc, char **args)
|
int argc, char **args)
|
||||||
{
|
{
|
||||||
grub_file_t file;
|
|
||||||
|
|
||||||
if (argc < 1)
|
if (argc < 1)
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name or tempo and notes required");
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name or tempo and notes required");
|
||||||
|
|
||||||
file = grub_file_open (args[0]);
|
if (argc == 1)
|
||||||
if (file)
|
|
||||||
{
|
{
|
||||||
struct note buf;
|
struct note buf;
|
||||||
grub_uint32_t tempo;
|
grub_uint32_t tempo;
|
||||||
|
grub_file_t file;
|
||||||
|
|
||||||
|
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 (grub_file_read (file, &tempo, sizeof (tempo)) != sizeof (tempo))
|
||||||
{
|
{
|
||||||
|
|
150
commands/iorw.c
Normal file
150
commands/iorw.c
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
/* memrw.c - command to read / write physical memory */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 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/dl.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/extcmd.h>
|
||||||
|
#include <grub/env.h>
|
||||||
|
#include <grub/cpu/io.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
|
static grub_extcmd_t cmd_read_byte, cmd_read_word, cmd_read_dword;
|
||||||
|
static grub_command_t cmd_write_byte, cmd_write_word, cmd_write_dword;
|
||||||
|
|
||||||
|
static const struct grub_arg_option options[] =
|
||||||
|
{
|
||||||
|
{0, 'v', 0, N_("Save read value into variable VARNAME."),
|
||||||
|
N_("VARNAME"), ARG_TYPE_STRING},
|
||||||
|
{0, 0, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_read (grub_extcmd_t cmd, int argc, char **argv)
|
||||||
|
{
|
||||||
|
grub_target_addr_t addr;
|
||||||
|
grub_uint32_t value = 0;
|
||||||
|
char buf[sizeof ("XXXXXXXX")];
|
||||||
|
|
||||||
|
if (argc != 1)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments");
|
||||||
|
|
||||||
|
addr = grub_strtoul (argv[0], 0, 0);
|
||||||
|
switch (cmd->cmd->name[sizeof ("in") - 1])
|
||||||
|
{
|
||||||
|
case 'l':
|
||||||
|
value = grub_inl (addr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'w':
|
||||||
|
value = grub_inw (addr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'b':
|
||||||
|
value = grub_inb (addr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd->state[0].set)
|
||||||
|
{
|
||||||
|
grub_snprintf (buf, sizeof (buf), "%x", value);
|
||||||
|
grub_env_set (cmd->state[0].arg, buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
grub_printf ("0x%x\n", value);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_write (grub_command_t cmd, int argc, char **argv)
|
||||||
|
{
|
||||||
|
grub_target_addr_t addr;
|
||||||
|
grub_uint32_t value;
|
||||||
|
grub_uint32_t mask = 0xffffffff;
|
||||||
|
|
||||||
|
if (argc != 2 && argc != 3)
|
||||||
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid number of arguments");
|
||||||
|
|
||||||
|
addr = grub_strtoul (argv[0], 0, 0);
|
||||||
|
value = grub_strtoul (argv[1], 0, 0);
|
||||||
|
if (argc == 3)
|
||||||
|
mask = grub_strtoul (argv[2], 0, 0);
|
||||||
|
value &= mask;
|
||||||
|
switch (cmd->name[sizeof ("out") - 1])
|
||||||
|
{
|
||||||
|
case 'l':
|
||||||
|
if (mask != 0xffffffff)
|
||||||
|
grub_outl ((grub_inl (addr) & ~mask) | value, addr);
|
||||||
|
else
|
||||||
|
grub_outl (value, addr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'w':
|
||||||
|
if ((mask & 0xffff) != 0xffff)
|
||||||
|
grub_outw ((grub_inw (addr) & ~mask) | value, addr);
|
||||||
|
else
|
||||||
|
grub_outw (value, addr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'b':
|
||||||
|
if ((mask & 0xff) != 0xff)
|
||||||
|
grub_outb ((grub_inb (addr) & ~mask) | value, addr);
|
||||||
|
else
|
||||||
|
grub_outb (value, addr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(memrw)
|
||||||
|
{
|
||||||
|
cmd_read_byte =
|
||||||
|
grub_register_extcmd ("inb", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH,
|
||||||
|
N_("PORT"), N_("Read byte from PORT."), options);
|
||||||
|
cmd_read_word =
|
||||||
|
grub_register_extcmd ("inw", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH,
|
||||||
|
N_("PORT"), N_("Read word from PORT."), options);
|
||||||
|
cmd_read_dword =
|
||||||
|
grub_register_extcmd ("inl", grub_cmd_read, GRUB_COMMAND_FLAG_BOTH,
|
||||||
|
N_("PORT"), N_("Read dword from PORT."), options);
|
||||||
|
cmd_write_byte =
|
||||||
|
grub_register_command ("outb", grub_cmd_write,
|
||||||
|
N_("PORT VALUE [MASK]"),
|
||||||
|
N_("Write byte VALUE to PORT."));
|
||||||
|
cmd_write_word =
|
||||||
|
grub_register_command ("outw", grub_cmd_write,
|
||||||
|
N_("PORT VALUE [MASK]"),
|
||||||
|
N_("Write word VALUE to PORT."));
|
||||||
|
cmd_write_dword =
|
||||||
|
grub_register_command ("outl", grub_cmd_write,
|
||||||
|
N_("ADDR VALUE [MASK]"),
|
||||||
|
N_("Write dword VALUE to PORT."));
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(memrw)
|
||||||
|
{
|
||||||
|
grub_unregister_extcmd (cmd_read_byte);
|
||||||
|
grub_unregister_extcmd (cmd_read_word);
|
||||||
|
grub_unregister_extcmd (cmd_read_dword);
|
||||||
|
grub_unregister_command (cmd_write_byte);
|
||||||
|
grub_unregister_command (cmd_write_word);
|
||||||
|
grub_unregister_command (cmd_write_dword);
|
||||||
|
}
|
|
@ -175,7 +175,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load modules. */
|
/* Load modules. */
|
||||||
#if GRUB_NO_MODULES
|
#if !GRUB_NO_MODULES
|
||||||
{
|
{
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
prefix = grub_env_get ("prefix");
|
prefix = grub_env_get ("prefix");
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/normal.h>
|
#include <grub/normal.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
static grub_dl_t my_mod;
|
static grub_dl_t my_mod;
|
||||||
|
|
||||||
|
@ -186,8 +187,8 @@ GRUB_MOD_INIT(password_pbkdf2)
|
||||||
{
|
{
|
||||||
my_mod = mod;
|
my_mod = mod;
|
||||||
cmd = grub_register_command ("password_pbkdf2", grub_cmd_password,
|
cmd = grub_register_command ("password_pbkdf2", grub_cmd_password,
|
||||||
"password_pbkdf2 USER PBKDF2_PASSWORD",
|
N_("USER PBKDF2_PASSWORD"),
|
||||||
"Set user password (PBKDF2). ");
|
N_("Set user password (PBKDF2). "));
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(password_pbkdf2)
|
GRUB_MOD_FINI(password_pbkdf2)
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
|
@ -69,8 +70,8 @@ static grub_command_t cmd;
|
||||||
GRUB_MOD_INIT(regexp)
|
GRUB_MOD_INIT(regexp)
|
||||||
{
|
{
|
||||||
cmd = grub_register_command ("regexp", grub_cmd_regexp,
|
cmd = grub_register_command ("regexp", grub_cmd_regexp,
|
||||||
"REGEXP STRING",
|
N_("REGEXP STRING"),
|
||||||
"Test if REGEXP matches STRING.");
|
N_("Test if REGEXP matches STRING."));
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(regexp)
|
GRUB_MOD_FINI(regexp)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <grub/extcmd.h>
|
#include <grub/extcmd.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
struct pci_register
|
struct pci_register
|
||||||
{
|
{
|
||||||
|
@ -329,9 +330,9 @@ static grub_extcmd_t cmd;
|
||||||
GRUB_MOD_INIT(setpci)
|
GRUB_MOD_INIT(setpci)
|
||||||
{
|
{
|
||||||
cmd = grub_register_extcmd ("setpci", grub_cmd_setpci, GRUB_COMMAND_FLAG_BOTH,
|
cmd = grub_register_extcmd ("setpci", grub_cmd_setpci, GRUB_COMMAND_FLAG_BOTH,
|
||||||
"setpci [-s POSITION] [-d DEVICE] [-v VAR] "
|
N_("[-s POSITION] [-d DEVICE] [-v VAR] "
|
||||||
"[REGISTER][=VALUE[:MASK]]",
|
"[REGISTER][=VALUE[:MASK]]"),
|
||||||
"Manipulate PCI devices.", options);
|
N_("Manipulate PCI devices."), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(setpci)
|
GRUB_MOD_FINI(setpci)
|
||||||
|
|
|
@ -26,37 +26,48 @@
|
||||||
struct grub_term_autoload *grub_term_input_autoload = NULL;
|
struct grub_term_autoload *grub_term_input_autoload = NULL;
|
||||||
struct grub_term_autoload *grub_term_output_autoload = NULL;
|
struct grub_term_autoload *grub_term_output_autoload = NULL;
|
||||||
|
|
||||||
|
struct abstract_terminal
|
||||||
|
{
|
||||||
|
struct abstract_terminal *next;
|
||||||
|
const char *name;
|
||||||
|
grub_err_t (*init) (void);
|
||||||
|
grub_err_t (*fini) (void);
|
||||||
|
};
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
||||||
int argc, char **args)
|
struct abstract_terminal **disabled,
|
||||||
|
struct grub_term_autoload *autoloads,
|
||||||
|
const char *active_str,
|
||||||
|
const char *available_str)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
grub_term_input_t term;
|
struct abstract_terminal *term;
|
||||||
struct grub_term_autoload *aut;
|
struct grub_term_autoload *aut;
|
||||||
|
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
{
|
{
|
||||||
grub_puts_ (N_ ("Active input terminals:"));
|
grub_puts_ (active_str);
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
for (term = *enabled; term; term = term->next)
|
||||||
grub_printf ("%s ", term->name);
|
grub_printf ("%s ", term->name);
|
||||||
grub_printf ("\n");
|
grub_printf ("\n");
|
||||||
grub_puts_ (N_ ("Available input terminals:"));
|
grub_puts_ (available_str);
|
||||||
FOR_DISABLED_TERM_INPUTS(term)
|
for (term = *disabled; term; term = term->next)
|
||||||
grub_printf ("%s ", term->name);
|
grub_printf ("%s ", term->name);
|
||||||
/* This is quadratic but we don't expect mode than 30 terminal
|
/* This is quadratic but we don't expect mode than 30 terminal
|
||||||
modules ever. */
|
modules ever. */
|
||||||
for (aut = grub_term_input_autoload; aut; aut = aut->next)
|
for (aut = autoloads; aut; aut = aut->next)
|
||||||
{
|
{
|
||||||
FOR_DISABLED_TERM_INPUTS(term)
|
for (term = *disabled; term; term = term->next)
|
||||||
if (grub_strcmp (term->name, aut->name) == 0)
|
if (grub_strcmp (term->name, aut->name) == 0)
|
||||||
break;
|
break;
|
||||||
if (!term)
|
if (!term)
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
for (term = *enabled; term; term = term->next)
|
||||||
if (grub_strcmp (term->name, aut->name) == 0)
|
if (grub_strcmp (term->name, aut->name) == 0)
|
||||||
break;
|
break;
|
||||||
if (!term)
|
if (!term)
|
||||||
grub_printf ("%s ", aut->name);
|
grub_printf ("%s ", aut->name);
|
||||||
}
|
}
|
||||||
grub_printf ("\n");
|
grub_printf ("\n");
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -73,112 +84,108 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
||||||
{
|
{
|
||||||
int again = 0;
|
int again = 0;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
FOR_DISABLED_TERM_INPUTS(term)
|
for (term = *disabled; term; term = term->next)
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
if (grub_strcmp (args[i], term->name) == 0)
|
||||||
break;
|
break;
|
||||||
if (term == 0)
|
if (term == 0)
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
for (term = *enabled; term; term = term->next)
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
if (grub_strcmp (args[i], term->name) == 0)
|
||||||
break;
|
break;
|
||||||
if (term)
|
if (term)
|
||||||
break;
|
break;
|
||||||
if (again)
|
if (again)
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
||||||
args[i]);
|
args[i]);
|
||||||
for (aut = grub_term_input_autoload; aut; aut = aut->next)
|
for (aut = autoloads; aut; aut = aut->next)
|
||||||
if (grub_strcmp (args[i], aut->name) == 0)
|
if (grub_strcmp (args[i], aut->name) == 0)
|
||||||
{
|
{
|
||||||
grub_dl_t mod;
|
grub_dl_t mod;
|
||||||
mod = grub_dl_load (aut->modname);
|
mod = grub_dl_load (aut->modname);
|
||||||
if (mod)
|
if (mod)
|
||||||
grub_dl_ref (mod);
|
grub_dl_ref (mod);
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!aut)
|
if (!aut)
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
||||||
args[i]);
|
args[i]);
|
||||||
again = 1;
|
again = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--append") == 0)
|
if (grub_strcmp (args[0], "--append") == 0)
|
||||||
{
|
{
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
FOR_DISABLED_TERM_INPUTS(term)
|
for (term = *disabled; term; term = term->next)
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
if (grub_strcmp (args[i], term->name) == 0)
|
||||||
break;
|
break;
|
||||||
if (term)
|
if (term)
|
||||||
{
|
{
|
||||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
if (term->init && term->init () != GRUB_ERR_NONE)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs_disabled)),
|
grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||||
GRUB_AS_LIST (term));
|
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs),
|
}
|
||||||
GRUB_AS_LIST (term));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--remove") == 0)
|
if (grub_strcmp (args[0], "--remove") == 0)
|
||||||
{
|
{
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
for (term = *enabled; term; term = term->next)
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
if (grub_strcmp (args[i], term->name) == 0)
|
||||||
break;
|
break;
|
||||||
if (term)
|
if (term)
|
||||||
{
|
{
|
||||||
if (!term->next && term == grub_term_inputs)
|
if (!term->next && term == *enabled)
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
"can't remove the last terminal");
|
"can't remove the last terminal");
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs)),
|
grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||||
GRUB_AS_LIST (term));
|
if (term->fini)
|
||||||
if (term->fini)
|
term->fini ();
|
||||||
term->fini ();
|
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
}
|
||||||
GRUB_AS_LIST (term));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
{
|
{
|
||||||
FOR_DISABLED_TERM_INPUTS(term)
|
for (term = *disabled; term; term = term->next)
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
if (grub_strcmp (args[i], term->name) == 0)
|
||||||
break;
|
break;
|
||||||
if (term)
|
if (term)
|
||||||
{
|
{
|
||||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
if (term->init && term->init () != GRUB_ERR_NONE)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs_disabled)),
|
grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||||
GRUB_AS_LIST (term));
|
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs),
|
}
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
|
||||||
{
|
{
|
||||||
for (i = 0; i < argc; i++)
|
struct abstract_terminal *next;
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
for (term = *enabled; term; term = next)
|
||||||
break;
|
|
||||||
if (i == argc)
|
|
||||||
{
|
{
|
||||||
if (!term->next && term == grub_term_inputs)
|
next = term->next;
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
for (i = 0; i < argc; i++)
|
||||||
"can't remove the last terminal");
|
if (grub_strcmp (args[i], term->name) == 0)
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_inputs)),
|
break;
|
||||||
GRUB_AS_LIST (term));
|
if (i == argc)
|
||||||
if (term->fini)
|
{
|
||||||
term->fini ();
|
if (!term->next && term == *enabled)
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
GRUB_AS_LIST (term));
|
"can't remove the last terminal");
|
||||||
|
grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||||
|
if (term->fini)
|
||||||
|
term->fini ();
|
||||||
|
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,163 +193,34 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
|
grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
||||||
int argc, char **args)
|
int argc, char **args)
|
||||||
{
|
{
|
||||||
int i;
|
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, next);
|
||||||
grub_term_output_t term;
|
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, name);
|
||||||
struct grub_term_autoload *aut;
|
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, init);
|
||||||
|
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, fini);
|
||||||
|
return handle_command (argc, args,
|
||||||
|
(struct abstract_terminal **) &grub_term_inputs,
|
||||||
|
(struct abstract_terminal **) &grub_term_inputs_disabled,
|
||||||
|
grub_term_input_autoload,
|
||||||
|
N_ ("Active input terminals:"),
|
||||||
|
N_ ("Available input terminals:"));
|
||||||
|
}
|
||||||
|
|
||||||
if (argc == 0)
|
static grub_err_t
|
||||||
{
|
grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
|
||||||
grub_puts_ (N_ ("Active output terminals:"));
|
int argc, char **args)
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
{
|
||||||
grub_printf ("%s ", term->name);
|
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, next);
|
||||||
grub_printf ("\n");
|
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, name);
|
||||||
grub_puts_ (N_ ("Available output terminals:"));
|
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, init);
|
||||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, fini);
|
||||||
grub_printf ("%s ", term->name);
|
return handle_command (argc, args, (struct abstract_terminal **) &grub_term_outputs,
|
||||||
/* This is quadratic but we don't expect mode than 30 terminal
|
(struct abstract_terminal **) &grub_term_outputs_disabled,
|
||||||
modules ever. */
|
grub_term_output_autoload,
|
||||||
for (aut = grub_term_output_autoload; aut; aut = aut->next)
|
N_ ("Active output terminals:"),
|
||||||
{
|
N_ ("Available output terminals:"));
|
||||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (term->name, aut->name) == 0)
|
|
||||||
break;
|
|
||||||
if (!term)
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (term->name, aut->name) == 0)
|
|
||||||
break;
|
|
||||||
if (!term)
|
|
||||||
grub_printf ("%s ", aut->name);
|
|
||||||
}
|
|
||||||
grub_printf ("\n");
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--append") == 0
|
|
||||||
|| grub_strcmp (args[0], "--remove") == 0)
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if (i == argc)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_ ("no terminal specified"));
|
|
||||||
|
|
||||||
for (; i < argc; i++)
|
|
||||||
{
|
|
||||||
int again = 0;
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term == 0)
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
break;
|
|
||||||
if (again)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
|
||||||
args[i]);
|
|
||||||
for (aut = grub_term_output_autoload; aut; aut = aut->next)
|
|
||||||
if (grub_strcmp (args[i], aut->name) == 0)
|
|
||||||
{
|
|
||||||
grub_dl_t mod;
|
|
||||||
mod = grub_dl_load (aut->modname);
|
|
||||||
if (mod)
|
|
||||||
grub_dl_ref (mod);
|
|
||||||
grub_errno = GRUB_ERR_NONE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!aut)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown terminal '%s'\n",
|
|
||||||
args[i]);
|
|
||||||
again = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--append") == 0)
|
|
||||||
{
|
|
||||||
for (i = 1; i < argc; i++)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
{
|
|
||||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grub_strcmp (args[0], "--remove") == 0)
|
|
||||||
{
|
|
||||||
for (i = 1; i < argc; i++)
|
|
||||||
{
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
{
|
|
||||||
if (!term->next && term == grub_term_outputs)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
||||||
"can't remove the last terminal");
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
if (term->fini)
|
|
||||||
term->fini ();
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
{
|
|
||||||
FOR_DISABLED_TERM_OUTPUTS(term)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (term)
|
|
||||||
{
|
|
||||||
if (term->init && term->init () != GRUB_ERR_NONE)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
|
||||||
{
|
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
if (grub_strcmp (args[i], term->name) == 0)
|
|
||||||
break;
|
|
||||||
if (i == argc)
|
|
||||||
{
|
|
||||||
if (!term->next && term == grub_term_outputs)
|
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
|
||||||
"can't remove the last terminal");
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs)),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
if (term->fini)
|
|
||||||
term->fini ();
|
|
||||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
|
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_command_t cmd_terminal_input, cmd_terminal_output;
|
static grub_command_t cmd_terminal_input, cmd_terminal_output;
|
||||||
|
@ -351,14 +229,14 @@ GRUB_MOD_INIT(terminal)
|
||||||
{
|
{
|
||||||
cmd_terminal_input =
|
cmd_terminal_input =
|
||||||
grub_register_command ("terminal_input", grub_cmd_terminal_input,
|
grub_register_command ("terminal_input", grub_cmd_terminal_input,
|
||||||
"[--append|--remove] "
|
N_("[--append|--remove] "
|
||||||
"[TERMINAL1] [TERMINAL2] ...",
|
"[TERMINAL1] [TERMINAL2] ..."),
|
||||||
"List or select an input terminal.");
|
N_("List or select an input terminal."));
|
||||||
cmd_terminal_output =
|
cmd_terminal_output =
|
||||||
grub_register_command ("terminal_output", grub_cmd_terminal_output,
|
grub_register_command ("terminal_output", grub_cmd_terminal_output,
|
||||||
"[--append|--remove] "
|
N_("[--append|--remove] "
|
||||||
"[TERMINAL1] [TERMINAL2] ...",
|
"[TERMINAL1] [TERMINAL2] ..."),
|
||||||
"List or select an output terminal.");
|
N_("List or select an output terminal."));
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(terminal)
|
GRUB_MOD_FINI(terminal)
|
||||||
|
|
|
@ -9,13 +9,14 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
|
||||||
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
|
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
|
||||||
kern/parser.c kern/partition.c kern/term.c \
|
kern/parser.c kern/partition.c kern/term.c \
|
||||||
kern/rescue_reader.c kern/rescue_parser.c \
|
kern/rescue_reader.c kern/rescue_parser.c \
|
||||||
\
|
\
|
||||||
util/console.c util/grub-emu.c util/misc.c \
|
kern/emu/main.c kern/emu/mm.c kern/emu/misc.c \
|
||||||
util/hostdisk.c util/getroot.c util/mm.c util/time.c \
|
kern/emu/getroot.c kern/emu/time.c kern/emu/hostdisk.c \
|
||||||
\
|
kern/emu/hostfs.c kern/emu/console.c \
|
||||||
gnulib/progname.c util/hostfs.c disk/host.c
|
\
|
||||||
kernel_img_HEADERS += datetime.h util/misc.h
|
gnulib/progname.c disk/host.c
|
||||||
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib
|
kernel_img_HEADERS += datetime.h emu/misc.h
|
||||||
|
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-char-subscripts -Wno-unused -Wno-deprecated-declarations -Wno-undef -I$(srcdir)/gnulib
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
TARGET_NO_STRIP = yes
|
TARGET_NO_STRIP = yes
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ ifeq ($(enable_grub_emu_usb), yes)
|
||||||
kernel_img_HEADERS += libusb.h
|
kernel_img_HEADERS += libusb.h
|
||||||
|
|
||||||
pkglib_MODULES += libusb.mod
|
pkglib_MODULES += libusb.mod
|
||||||
libusb_mod_SOURCES = util/usb.c
|
libusb_mod_SOURCES = bus/usb/emu/usb.c
|
||||||
libusb_mod_CFLAGS =
|
libusb_mod_CFLAGS =
|
||||||
libusb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
libusb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ endif
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_sdl), yes)
|
ifeq ($(enable_grub_emu_sdl), yes)
|
||||||
pkglib_MODULES += sdl.mod
|
pkglib_MODULES += sdl.mod
|
||||||
sdl_mod_SOURCES = util/sdl.c
|
sdl_mod_SOURCES = video/emu/sdl.c
|
||||||
sdl_mod_CFLAGS =
|
sdl_mod_CFLAGS =
|
||||||
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
grub_emu_LDFLAGS += $(LIBSDL)
|
grub_emu_LDFLAGS += $(LIBSDL)
|
||||||
|
@ -85,7 +86,7 @@ endif
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_pci), yes)
|
ifeq ($(enable_grub_emu_pci), yes)
|
||||||
pkglib_MODULES += pci.mod
|
pkglib_MODULES += pci.mod
|
||||||
pci_mod_SOURCES = util/pci.c commands/lspci.c
|
pci_mod_SOURCES = bus/emu/pci.c commands/lspci.c
|
||||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
||||||
kernel_img_HEADERS += libpciaccess.h
|
kernel_img_HEADERS += libpciaccess.h
|
||||||
|
@ -104,10 +105,10 @@ DISTCLEANFILES += grub_emu_init.c
|
||||||
CLEANFILES += grub-emu
|
CLEANFILES += grub-emu
|
||||||
ifneq ($(TARGET_NO_MODULES), yes)
|
ifneq ($(TARGET_NO_MODULES), yes)
|
||||||
grub-emu: $(pkglib_PROGRAMS)
|
grub-emu: $(pkglib_PROGRAMS)
|
||||||
$(CC) -o $@ $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
|
$(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS)
|
||||||
else
|
else
|
||||||
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
|
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
|
||||||
$(CC) -o $@ $(pkglib_MODULES) $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
|
$(CC) -o $@ $^ $(grub_emu_LDFLAGS) $(LDFLAGS)
|
||||||
endif
|
endif
|
||||||
GRUB_EMU=grub-emu
|
GRUB_EMU=grub-emu
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||||
sbin_UTILITIES += grub-mkdevicemap
|
sbin_UTILITIES += grub-mkdevicemap
|
||||||
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
||||||
util/deviceiter.c \
|
util/deviceiter.c \
|
||||||
util/misc.c
|
util/misc.c kern/emu/misc.c
|
||||||
|
|
||||||
ifeq ($(target_cpu)-$(platform), sparc64-ieee1275)
|
ifeq ($(target_cpu)-$(platform), sparc64-ieee1275)
|
||||||
grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
|
grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
|
||||||
|
@ -17,14 +17,14 @@ endif
|
||||||
# For grub-mkimage.
|
# For grub-mkimage.
|
||||||
bin_UTILITIES += grub-mkimage
|
bin_UTILITIES += grub-mkimage
|
||||||
grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkimage.c util/misc.c \
|
grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkimage.c util/misc.c \
|
||||||
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
|
util/resolve.c kern/emu/misc.c lib/LzmaEnc.c lib/LzFind.c
|
||||||
util/grub-mkimage.c_DEPENDENCIES = Makefile
|
util/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
||||||
# For grub-probe.
|
# For grub-probe.
|
||||||
sbin_UTILITIES += grub-probe
|
sbin_UTILITIES += grub-probe
|
||||||
util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
|
util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
|
||||||
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
||||||
util/hostdisk.c util/misc.c util/getroot.c util/mm.c \
|
kern/emu/hostdisk.c util/misc.c kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c \
|
||||||
kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
||||||
kern/parser.c kern/partition.c kern/file.c kern/list.c \
|
kern/parser.c kern/partition.c kern/file.c kern/list.c \
|
||||||
\
|
\
|
||||||
|
@ -59,8 +59,8 @@ grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
|
||||||
|
|
||||||
# For grub-fstest.
|
# For grub-fstest.
|
||||||
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
||||||
grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c kern/emu/hostfs.c \
|
||||||
util/misc.c util/mm.c \
|
util/misc.c kern/emu/misc.c kern/emu/mm.c \
|
||||||
kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
||||||
disk/host.c disk/loopback.c kern/list.c kern/command.c \
|
disk/host.c disk/loopback.c kern/list.c kern/command.c \
|
||||||
lib/arg.c commands/extcmd.c normal/datetime.c normal/misc.c \
|
lib/arg.c commands/extcmd.c normal/datetime.c normal/misc.c \
|
||||||
|
@ -82,14 +82,14 @@ grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
||||||
# For grub-mkfont.
|
# For grub-mkfont.
|
||||||
ifeq ($(enable_grub_mkfont), yes)
|
ifeq ($(enable_grub_mkfont), yes)
|
||||||
bin_UTILITIES += grub-mkfont
|
bin_UTILITIES += grub-mkfont
|
||||||
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c
|
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c kern/emu/misc.c
|
||||||
grub_mkfont_CFLAGS = $(freetype_cflags)
|
grub_mkfont_CFLAGS = $(freetype_cflags)
|
||||||
grub_mkfont_LDFLAGS = $(freetype_libs)
|
grub_mkfont_LDFLAGS = $(freetype_libs)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# For grub-mkrelpath.
|
# For grub-mkrelpath.
|
||||||
bin_UTILITIES += grub-mkrelpath
|
bin_UTILITIES += grub-mkrelpath
|
||||||
grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c
|
grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c kern/emu/misc.c
|
||||||
|
|
||||||
bin_UTILITIES += grub-bin2h
|
bin_UTILITIES += grub-bin2h
|
||||||
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
||||||
|
@ -103,7 +103,7 @@ DISTCLEANFILES += grub_script.yy.c grub_script.yy.h
|
||||||
bin_UTILITIES += grub-script-check
|
bin_UTILITIES += grub-script-check
|
||||||
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
|
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
|
||||||
grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \
|
grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \
|
||||||
util/grub-script-check.c util/misc.c util/mm.c \
|
util/grub-script-check.c util/misc.c kern/emu/misc.c kern/emu/mm.c \
|
||||||
script/main.c script/script.c script/function.c script/lexer.c \
|
script/main.c script/script.c script/function.c script/lexer.c \
|
||||||
kern/handler.c kern/err.c kern/parser.c kern/list.c \
|
kern/handler.c kern/err.c kern/parser.c kern/list.c \
|
||||||
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
|
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
|
||||||
|
@ -186,7 +186,7 @@ DISTCLEANFILES += grub_fstest_init.c
|
||||||
|
|
||||||
# for grub-editenv
|
# for grub-editenv
|
||||||
bin_UTILITIES += grub-editenv
|
bin_UTILITIES += grub-editenv
|
||||||
grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c util/mm.c kern/misc.c kern/err.c
|
grub_editenv_SOURCES = gnulib/progname.c util/grub-editenv.c lib/envblk.c util/misc.c kern/emu/misc.c kern/emu/mm.c kern/misc.c kern/err.c
|
||||||
CLEANFILES += grub-editenv
|
CLEANFILES += grub-editenv
|
||||||
|
|
||||||
# Needed for genmk.rb to work
|
# Needed for genmk.rb to work
|
||||||
|
@ -194,7 +194,7 @@ ifeq (0,1)
|
||||||
bin_UTILITIES += grub-macho2img grub-pe2elf
|
bin_UTILITIES += grub-macho2img grub-pe2elf
|
||||||
endif
|
endif
|
||||||
|
|
||||||
grub_pe2elf_SOURCES = gnulib/progname.c util/grub-pe2elf.c util/misc.c
|
grub_pe2elf_SOURCES = gnulib/progname.c util/grub-pe2elf.c util/misc.c kern/emu/misc.c
|
||||||
CLEANFILES += grub-pe2elf
|
CLEANFILES += grub-pe2elf
|
||||||
|
|
||||||
grub_macho2img_SOURCES = util/grub-macho2img.c
|
grub_macho2img_SOURCES = util/grub-macho2img.c
|
||||||
|
@ -860,7 +860,7 @@ boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
bin_UTILITIES += grub-mkpasswd-pbkdf2
|
bin_UTILITIES += grub-mkpasswd-pbkdf2
|
||||||
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c util/mm.c kern/err.c
|
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/emu/misc.c kern/emu/mm.c kern/err.c
|
||||||
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
|
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
|
||||||
|
|
||||||
include $(srcdir)/conf/gcry.mk
|
include $(srcdir)/conf/gcry.mk
|
||||||
|
|
|
@ -8,7 +8,7 @@ pkglib_PROGRAMS += kernel.img
|
||||||
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
||||||
kern/i386/misc.S \
|
kern/i386/misc.S \
|
||||||
kern/i386/coreboot/init.c \
|
kern/i386/coreboot/init.c \
|
||||||
kern/i386/multiboot_mmap.c \
|
kern/i386/coreboot/mmap.c \
|
||||||
kern/i386/halt.c \
|
kern/i386/halt.c \
|
||||||
kern/main.c kern/device.c \
|
kern/main.c kern/device.c \
|
||||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||||
|
|
74
conf/i386-multiboot.rmk
Normal file
74
conf/i386-multiboot.rmk
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
# -*- makefile -*-
|
||||||
|
|
||||||
|
COMMON_CFLAGS = -mrtd -mregparm=3
|
||||||
|
|
||||||
|
# Images.
|
||||||
|
|
||||||
|
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
||||||
|
|
||||||
|
pkglib_PROGRAMS += kernel.img
|
||||||
|
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
||||||
|
kern/i386/misc.S \
|
||||||
|
kern/i386/coreboot/init.c \
|
||||||
|
kern/i386/multiboot_mmap.c \
|
||||||
|
kern/i386/halt.c \
|
||||||
|
kern/main.c kern/device.c \
|
||||||
|
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||||
|
kern/misc.c kern/mm.c kern/term.c \
|
||||||
|
kern/rescue_parser.c kern/rescue_reader.c \
|
||||||
|
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
||||||
|
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
|
||||||
|
kern/i386/tsc.c kern/i386/pit.c \
|
||||||
|
kern/generic/rtc_get_time_ms.c \
|
||||||
|
kern/generic/millisleep.c \
|
||||||
|
kern/env.c \
|
||||||
|
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
||||||
|
symlist.c
|
||||||
|
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR),-Bstatic
|
||||||
|
|
||||||
|
sbin_SCRIPTS += grub-install
|
||||||
|
grub_install_SOURCES = util/grub-install.in
|
||||||
|
|
||||||
|
bin_SCRIPTS += grub-mkrescue
|
||||||
|
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
||||||
|
|
||||||
|
# Modules.
|
||||||
|
pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod
|
||||||
|
|
||||||
|
# For mmap.mod.
|
||||||
|
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
||||||
|
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
|
||||||
|
# For linux.mod.
|
||||||
|
linux_mod_SOURCES = loader/i386/linux.c
|
||||||
|
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For halt.mod.
|
||||||
|
halt_mod_SOURCES = commands/halt.c
|
||||||
|
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For aout.mod.
|
||||||
|
aout_mod_SOURCES = loader/aout.c
|
||||||
|
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For bsd.mod
|
||||||
|
pkglib_MODULES += bsd.mod
|
||||||
|
bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c loader/i386/bsd_helper.S loader/i386/bsd_trampoline.S
|
||||||
|
bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
|
||||||
|
# For datetime.mod
|
||||||
|
datetime_mod_SOURCES = lib/cmos_datetime.c
|
||||||
|
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
include $(srcdir)/conf/i386.mk
|
||||||
|
include $(srcdir)/conf/common.mk
|
|
@ -63,24 +63,23 @@ sbin_UTILITIES = grub-setup
|
||||||
|
|
||||||
# For grub-setup.
|
# For grub-setup.
|
||||||
util/i386/pc/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
util/i386/pc/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
||||||
grub_setup_SOURCES = gnulib/progname.c \
|
grub_setup_SOURCES = gnulib/progname.c util/i386/pc/grub-setup.c \
|
||||||
util/i386/pc/grub-setup.c util/hostdisk.c \
|
util/misc.c kern/emu/misc.c kern/emu/getroot.c \
|
||||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
kern/emu/hostdisk.c kern/device.c kern/disk.c kern/err.c \
|
||||||
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
kern/misc.c kern/parser.c kern/partition.c kern/file.c \
|
||||||
kern/file.c kern/fs.c kern/env.c kern/list.c \
|
kern/emu/mm.c kern/fs.c kern/env.c kern/list.c fs/fshelp.c \
|
||||||
fs/fshelp.c \
|
\
|
||||||
\
|
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
||||||
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
||||||
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
||||||
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
||||||
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
\
|
||||||
\
|
partmap/msdos.c partmap/bsdlabel.c partmap/sunpc.c \
|
||||||
partmap/msdos.c partmap/bsdlabel.c partmap/sunpc.c \
|
partmap/gpt.c \
|
||||||
partmap/gpt.c \
|
\
|
||||||
\
|
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
||||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
util/raid.c util/lvm.c \
|
||||||
util/raid.c util/lvm.c util/mm.c \
|
|
||||||
grub_setup_init.c
|
grub_setup_init.c
|
||||||
|
|
||||||
sbin_SCRIPTS += grub-install
|
sbin_SCRIPTS += grub-install
|
||||||
|
@ -175,7 +174,7 @@ vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
vbetest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
vbetest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For vga.mod.
|
# For vga.mod.
|
||||||
vga_mod_SOURCES = term/i386/pc/vga.c
|
vga_mod_SOURCES = video/i386/pc/vga.c
|
||||||
vga_mod_CFLAGS = $(COMMON_CFLAGS)
|
vga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
vga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
vga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
|
|
@ -68,3 +68,8 @@ play_mod_SOURCES = commands/i386/pc/play.c
|
||||||
play_mod_CFLAGS = $(COMMON_CFLAGS)
|
play_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For iorw.mod.
|
||||||
|
pkglib_MODULES += iorw.mod
|
||||||
|
iorw_mod_SOURCES = commands/iorw.c
|
||||||
|
iorw_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
iorw_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
|
@ -45,29 +45,29 @@ sbin_UTILITIES = grub-setup grub-ofpathname
|
||||||
|
|
||||||
# For grub-setup.
|
# For grub-setup.
|
||||||
util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
||||||
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
|
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c \
|
||||||
util/ieee1275/ofpath.c \
|
util/ieee1275/ofpath.c util/misc.c kern/emu/hostdisk.c \
|
||||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c kern/device.c \
|
||||||
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
kern/disk.c kern/err.c kern/misc.c kern/parser.c \
|
||||||
kern/file.c kern/fs.c kern/env.c kern/list.c \
|
kern/partition.c kern/file.c kern/fs.c kern/env.c kern/list.c \
|
||||||
fs/fshelp.c \
|
fs/fshelp.c \
|
||||||
\
|
\
|
||||||
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||||
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \
|
||||||
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \
|
||||||
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \
|
||||||
\
|
\
|
||||||
partmap/amiga.c partmap/apple.c partmap/msdos.c \
|
partmap/amiga.c partmap/apple.c partmap/msdos.c \
|
||||||
partmap/bsdlabel.c partmap/sun.c partmap/acorn.c \
|
partmap/bsdlabel.c partmap/sun.c partmap/acorn.c \
|
||||||
\
|
\
|
||||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
disk/raid.c disk/mdraid_linux.c disk/lvm.c util/raid.c \
|
||||||
util/raid.c util/lvm.c util/mm.c gnulib/progname.c \
|
util/lvm.c gnulib/progname.c grub_setup_init.c
|
||||||
grub_setup_init.c
|
|
||||||
|
|
||||||
# For grub-ofpathname.
|
# For grub-ofpathname.
|
||||||
grub_ofpathname_SOURCES = util/ieee1275/grub-ofpathname.c \
|
grub_ofpathname_SOURCES = util/ieee1275/grub-ofpathname.c \
|
||||||
util/ieee1275/ofpath.c util/misc.c gnulib/progname.c
|
util/ieee1275/ofpath.c util/misc.c kern/emu/misc.c \
|
||||||
|
gnulib/progname.c
|
||||||
|
|
||||||
# Scripts.
|
# Scripts.
|
||||||
sbin_SCRIPTS = grub-install
|
sbin_SCRIPTS = grub-install
|
||||||
|
|
|
@ -68,6 +68,9 @@ grub_script_final_semicolon_SOURCES = tests/grub_script_final_semicolon.in
|
||||||
check_SCRIPTS += grub_script_dollar
|
check_SCRIPTS += grub_script_dollar
|
||||||
grub_script_dollar_SOURCES = tests/grub_script_dollar.in
|
grub_script_dollar_SOURCES = tests/grub_script_dollar.in
|
||||||
|
|
||||||
|
check_SCRIPTS += grub_script_comments
|
||||||
|
grub_script_comments_SOURCES = tests/grub_script_comments.in
|
||||||
|
|
||||||
# List of tests to execute on "make check"
|
# List of tests to execute on "make check"
|
||||||
# SCRIPTED_TESTS = example_scripted_test
|
# SCRIPTED_TESTS = example_scripted_test
|
||||||
# SCRIPTED_TESTS += example_grub_script_test
|
# SCRIPTED_TESTS += example_grub_script_test
|
||||||
|
@ -83,6 +86,7 @@ SCRIPTED_TESTS += grub_script_if
|
||||||
SCRIPTED_TESTS += grub_script_blanklines
|
SCRIPTED_TESTS += grub_script_blanklines
|
||||||
SCRIPTED_TESTS += grub_script_final_semicolon
|
SCRIPTED_TESTS += grub_script_final_semicolon
|
||||||
SCRIPTED_TESTS += grub_script_dollar
|
SCRIPTED_TESTS += grub_script_dollar
|
||||||
|
SCRIPTED_TESTS += grub_script_comments
|
||||||
|
|
||||||
# dependencies between tests and testing-tools
|
# dependencies between tests and testing-tools
|
||||||
$(SCRIPTED_TESTS): grub-shell grub-shell-tester
|
$(SCRIPTED_TESTS): grub-shell grub-shell-tester
|
||||||
|
|
|
@ -59,13 +59,17 @@ appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For linux.mod.
|
# For linux.mod.
|
||||||
linux_mod_SOURCES = loader/i386/efi/linux.c
|
|
||||||
ifeq ($(target_cpu), x86_64)
|
ifeq ($(target_cpu), x86_64)
|
||||||
linux_mod_SOURCES += loader/i386/linux_trampoline.S
|
linux_mod_SOURCES = loader/i386/efi/linux.c loader/i386/linux_trampoline.S
|
||||||
endif
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
else
|
||||||
|
linux_mod_SOURCES = loader/i386/efi/linux.c
|
||||||
|
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
# For halt.mod.
|
# For halt.mod.
|
||||||
halt_mod_SOURCES = commands/halt.c
|
halt_mod_SOURCES = commands/halt.c
|
||||||
|
|
|
@ -102,6 +102,7 @@ case "$target_cpu"-"$platform" in
|
||||||
i386-efi) ;;
|
i386-efi) ;;
|
||||||
x86_64-efi) ;;
|
x86_64-efi) ;;
|
||||||
i386-pc) ;;
|
i386-pc) ;;
|
||||||
|
i386-multiboot) ;;
|
||||||
i386-coreboot) ;;
|
i386-coreboot) ;;
|
||||||
i386-linuxbios) platform=coreboot ;;
|
i386-linuxbios) platform=coreboot ;;
|
||||||
i386-ieee1275) ;;
|
i386-ieee1275) ;;
|
||||||
|
@ -136,6 +137,7 @@ esac
|
||||||
|
|
||||||
case "$platform" in
|
case "$platform" in
|
||||||
coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
|
coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
|
||||||
|
multiboot) machine_CFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;;
|
||||||
efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;;
|
efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;;
|
||||||
ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
|
ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
|
||||||
qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
|
qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <grub/lvm.h>
|
#include <grub/lvm.h>
|
||||||
|
|
||||||
#ifdef GRUB_UTIL
|
#ifdef GRUB_UTIL
|
||||||
#include <grub/util/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct grub_lvm_vg *vg_list;
|
static struct grub_lvm_vg *vg_list;
|
||||||
|
|
|
@ -1379,7 +1379,8 @@ pitch and duration pairs.
|
||||||
If the arguments are a series of numbers, play the inline tune.
|
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
|
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.
|
gives a half-second base, etc. Pitches are Hz. Set pitch to 0 to produce
|
||||||
|
a rest.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <grub/efiemu/efiemu.h>
|
#include <grub/efiemu/efiemu.h>
|
||||||
#include <grub/machine/efiemu.h>
|
#include <grub/machine/efiemu.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
/* System table. Two version depending on mode */
|
/* System table. Two version depending on mode */
|
||||||
grub_efi_system_table32_t *grub_efiemu_system_table32 = 0;
|
grub_efi_system_table32_t *grub_efiemu_system_table32 = 0;
|
||||||
|
@ -327,15 +328,15 @@ GRUB_MOD_INIT(efiemu)
|
||||||
{
|
{
|
||||||
cmd_loadcore = grub_register_command ("efiemu_loadcore",
|
cmd_loadcore = grub_register_command ("efiemu_loadcore",
|
||||||
grub_cmd_efiemu_load,
|
grub_cmd_efiemu_load,
|
||||||
"FILE",
|
N_("FILE"),
|
||||||
"Load and initialize EFI emulator.");
|
N_("Load and initialize EFI emulator."));
|
||||||
cmd_prepare = grub_register_command ("efiemu_prepare",
|
cmd_prepare = grub_register_command ("efiemu_prepare",
|
||||||
grub_cmd_efiemu_prepare,
|
grub_cmd_efiemu_prepare,
|
||||||
0,
|
0,
|
||||||
"Finalize loading of EFI emulator.");
|
N_("Finalize loading of EFI emulator."));
|
||||||
cmd_unload = grub_register_command ("efiemu_unload", grub_cmd_efiemu_unload,
|
cmd_unload = grub_register_command ("efiemu_unload", grub_cmd_efiemu_unload,
|
||||||
0,
|
0,
|
||||||
"Unload EFI emulator.");
|
N_("Unload EFI emulator."));
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(efiemu)
|
GRUB_MOD_FINI(efiemu)
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
loadfont_command (grub_command_t cmd __attribute__ ((unused)),
|
loadfont_command (grub_command_t cmd __attribute__ ((unused)),
|
||||||
|
@ -62,11 +63,11 @@ GRUB_MOD_INIT(font)
|
||||||
|
|
||||||
cmd_loadfont =
|
cmd_loadfont =
|
||||||
grub_register_command ("loadfont", loadfont_command,
|
grub_register_command ("loadfont", loadfont_command,
|
||||||
"FILE...",
|
N_("FILE..."),
|
||||||
"Specify one or more font files to load.");
|
N_("Specify one or more font files to load."));
|
||||||
cmd_lsfonts =
|
cmd_lsfonts =
|
||||||
grub_register_command ("lsfonts", lsfonts_command,
|
grub_register_command ("lsfonts", lsfonts_command,
|
||||||
0, "List the loaded fonts.");
|
0, N_("List the loaded fonts."));
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(font)
|
GRUB_MOD_FINI(font)
|
||||||
|
|
|
@ -54,6 +54,7 @@ static void
|
||||||
circprog_destroy (void *vself)
|
circprog_destroy (void *vself)
|
||||||
{
|
{
|
||||||
circular_progress_t self = vself;
|
circular_progress_t self = vself;
|
||||||
|
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||||
grub_free (self);
|
grub_free (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,6 +212,17 @@ circprog_get_bounds (void *vself, grub_video_rect_t *bounds)
|
||||||
*bounds = self->bounds;
|
*bounds = self->bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
circprog_set_state (void *vself, int visible, int start,
|
||||||
|
int current, int end)
|
||||||
|
{
|
||||||
|
circular_progress_t self = vself;
|
||||||
|
self->visible = visible;
|
||||||
|
self->start = start;
|
||||||
|
self->value = current;
|
||||||
|
self->end = end;
|
||||||
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
circprog_set_property (void *vself, const char *name, const char *value)
|
circprog_set_property (void *vself, const char *name, const char *value)
|
||||||
{
|
{
|
||||||
|
@ -247,26 +259,20 @@ circprog_set_property (void *vself, const char *name, const char *value)
|
||||||
}
|
}
|
||||||
else if (grub_strcmp (name, "id") == 0)
|
else if (grub_strcmp (name, "id") == 0)
|
||||||
{
|
{
|
||||||
|
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||||
grub_free (self->id);
|
grub_free (self->id);
|
||||||
if (value)
|
if (value)
|
||||||
self->id = grub_strdup (value);
|
self->id = grub_strdup (value);
|
||||||
else
|
else
|
||||||
self->id = 0;
|
self->id = 0;
|
||||||
|
if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
|
||||||
|
== 0)
|
||||||
|
grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
|
||||||
|
circprog_set_state);
|
||||||
}
|
}
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
circprog_set_state (void *vself, int visible, int start,
|
|
||||||
int current, int end)
|
|
||||||
{
|
|
||||||
circular_progress_t self = vself;
|
|
||||||
self->visible = visible;
|
|
||||||
self->start = start;
|
|
||||||
self->value = current;
|
|
||||||
self->end = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct grub_gui_component_ops circprog_ops =
|
static struct grub_gui_component_ops circprog_ops =
|
||||||
{
|
{
|
||||||
.destroy = circprog_destroy,
|
.destroy = circprog_destroy,
|
||||||
|
|
|
@ -46,8 +46,10 @@ struct grub_gui_label
|
||||||
char *id;
|
char *id;
|
||||||
int visible;
|
int visible;
|
||||||
char *text;
|
char *text;
|
||||||
|
char *template;
|
||||||
grub_font_t font;
|
grub_font_t font;
|
||||||
grub_gui_color_t color;
|
grub_gui_color_t color;
|
||||||
|
int value;
|
||||||
enum align_mode align;
|
enum align_mode align;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +59,9 @@ static void
|
||||||
label_destroy (void *vself)
|
label_destroy (void *vself)
|
||||||
{
|
{
|
||||||
grub_gui_label_t self = vself;
|
grub_gui_label_t self = vself;
|
||||||
|
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||||
grub_free (self->text);
|
grub_free (self->text);
|
||||||
|
grub_free (self->template);
|
||||||
grub_free (self);
|
grub_free (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +150,17 @@ label_get_minimal_size (void *vself, unsigned *width, unsigned *height)
|
||||||
+ grub_font_get_descent (self->font));
|
+ grub_font_get_descent (self->font));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
label_set_state (void *vself, int visible, int start __attribute__ ((unused)),
|
||||||
|
int current, int end __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
grub_gui_label_t self = vself;
|
||||||
|
self->value = -current;
|
||||||
|
self->visible = visible;
|
||||||
|
grub_free (self->text);
|
||||||
|
self->text = grub_xasprintf (self->template ? : "%d", self->value);
|
||||||
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
label_set_property (void *vself, const char *name, const char *value)
|
label_set_property (void *vself, const char *name, const char *value)
|
||||||
{
|
{
|
||||||
|
@ -153,9 +168,17 @@ label_set_property (void *vself, const char *name, const char *value)
|
||||||
if (grub_strcmp (name, "text") == 0)
|
if (grub_strcmp (name, "text") == 0)
|
||||||
{
|
{
|
||||||
grub_free (self->text);
|
grub_free (self->text);
|
||||||
|
grub_free (self->template);
|
||||||
if (! value)
|
if (! value)
|
||||||
value = "";
|
{
|
||||||
self->text = grub_strdup (value);
|
self->template = NULL;
|
||||||
|
self->text = grub_strdup ("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self->template = grub_strdup (value);
|
||||||
|
self->text = grub_xasprintf (value, self->value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (grub_strcmp (name, "font") == 0)
|
else if (grub_strcmp (name, "font") == 0)
|
||||||
{
|
{
|
||||||
|
@ -183,11 +206,16 @@ label_set_property (void *vself, const char *name, const char *value)
|
||||||
}
|
}
|
||||||
else if (grub_strcmp (name, "id") == 0)
|
else if (grub_strcmp (name, "id") == 0)
|
||||||
{
|
{
|
||||||
|
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||||
grub_free (self->id);
|
grub_free (self->id);
|
||||||
if (value)
|
if (value)
|
||||||
self->id = grub_strdup (value);
|
self->id = grub_strdup (value);
|
||||||
else
|
else
|
||||||
self->id = 0;
|
self->id = 0;
|
||||||
|
if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
|
||||||
|
== 0)
|
||||||
|
grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
|
||||||
|
label_set_state);
|
||||||
}
|
}
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ static void
|
||||||
progress_bar_destroy (void *vself)
|
progress_bar_destroy (void *vself)
|
||||||
{
|
{
|
||||||
grub_gui_progress_bar_t self = vself;
|
grub_gui_progress_bar_t self = vself;
|
||||||
|
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||||
grub_free (self);
|
grub_free (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,11 +334,16 @@ progress_bar_set_property (void *vself, const char *name, const char *value)
|
||||||
}
|
}
|
||||||
else if (grub_strcmp (name, "id") == 0)
|
else if (grub_strcmp (name, "id") == 0)
|
||||||
{
|
{
|
||||||
|
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||||
grub_free (self->id);
|
grub_free (self->id);
|
||||||
if (value)
|
if (value)
|
||||||
self->id = grub_strdup (value);
|
self->id = grub_strdup (value);
|
||||||
else
|
else
|
||||||
self->id = 0;
|
self->id = 0;
|
||||||
|
/* if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
|
||||||
|
== 0)*/
|
||||||
|
grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
|
||||||
|
progress_bar_set_state);
|
||||||
}
|
}
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
}
|
}
|
||||||
|
@ -368,6 +374,7 @@ grub_gui_progress_bar_new (void)
|
||||||
self = grub_zalloc (sizeof (*self));
|
self = grub_zalloc (sizeof (*self));
|
||||||
if (! self)
|
if (! self)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
self->progress.ops = &progress_bar_pb_ops;
|
self->progress.ops = &progress_bar_pb_ops;
|
||||||
self->progress.component.ops = &progress_bar_ops;
|
self->progress.component.ops = &progress_bar_ops;
|
||||||
self->visible = 1;
|
self->visible = 1;
|
||||||
|
|
|
@ -37,10 +37,6 @@
|
||||||
#include <grub/gui_string_util.h>
|
#include <grub/gui_string_util.h>
|
||||||
#include <grub/icon_manager.h>
|
#include <grub/icon_manager.h>
|
||||||
|
|
||||||
/* The component ID identifying GUI components to be updated as the timeout
|
|
||||||
status changes. */
|
|
||||||
#define TIMEOUT_COMPONENT_ID "__timeout__"
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_terminal (grub_gfxmenu_view_t view);
|
init_terminal (grub_gfxmenu_view_t view);
|
||||||
static grub_video_rect_t term_rect;
|
static grub_video_rect_t term_rect;
|
||||||
|
@ -166,16 +162,28 @@ struct progress_value_data
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
struct grub_gfxmenu_timeout_notify *grub_gfxmenu_timeout_notifications;
|
||||||
update_timeout_visit (grub_gui_component_t component,
|
|
||||||
void *userdata)
|
|
||||||
{
|
|
||||||
struct progress_value_data *pv;
|
|
||||||
pv = (struct progress_value_data *) userdata;
|
|
||||||
|
|
||||||
((struct grub_gui_progress *) component)->ops
|
static void
|
||||||
->set_state ((struct grub_gui_progress *) component,
|
update_timeouts (int visible, int start, int value, int end)
|
||||||
pv->visible, pv->start, pv->value, pv->end);
|
{
|
||||||
|
struct grub_gfxmenu_timeout_notify *cur;
|
||||||
|
|
||||||
|
for (cur = grub_gfxmenu_timeout_notifications; cur; cur = cur->next)
|
||||||
|
cur->set_state (cur->self, visible, start, value, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
redraw_timeouts (struct grub_gfxmenu_view *view)
|
||||||
|
{
|
||||||
|
struct grub_gfxmenu_timeout_notify *cur;
|
||||||
|
|
||||||
|
for (cur = grub_gfxmenu_timeout_notifications; cur; cur = cur->next)
|
||||||
|
{
|
||||||
|
grub_video_rect_t bounds;
|
||||||
|
cur->self->ops->get_bounds (cur->self, &bounds);
|
||||||
|
grub_gfxmenu_view_redraw (view, &bounds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -183,67 +191,26 @@ grub_gfxmenu_print_timeout (int timeout, void *data)
|
||||||
{
|
{
|
||||||
struct grub_gfxmenu_view *view = data;
|
struct grub_gfxmenu_view *view = data;
|
||||||
|
|
||||||
struct progress_value_data pv;
|
|
||||||
|
|
||||||
auto void redraw_timeout_visit (grub_gui_component_t component,
|
|
||||||
void *userdata __attribute__ ((unused)));
|
|
||||||
|
|
||||||
auto void redraw_timeout_visit (grub_gui_component_t component,
|
|
||||||
void *userdata __attribute__ ((unused)))
|
|
||||||
{
|
|
||||||
grub_video_rect_t bounds;
|
|
||||||
component->ops->get_bounds (component, &bounds);
|
|
||||||
grub_gfxmenu_view_redraw (view, &bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (view->first_timeout == -1)
|
if (view->first_timeout == -1)
|
||||||
view->first_timeout = timeout;
|
view->first_timeout = timeout;
|
||||||
|
|
||||||
pv.visible = 1;
|
update_timeouts (1, -(view->first_timeout + 1), -timeout, 0);
|
||||||
pv.start = -(view->first_timeout + 1);
|
redraw_timeouts (view);
|
||||||
pv.end = 0;
|
|
||||||
pv.value = -timeout;
|
|
||||||
|
|
||||||
grub_gui_find_by_id ((grub_gui_component_t) view->canvas,
|
|
||||||
TIMEOUT_COMPONENT_ID, update_timeout_visit, &pv);
|
|
||||||
grub_gui_find_by_id ((grub_gui_component_t) view->canvas,
|
|
||||||
TIMEOUT_COMPONENT_ID, redraw_timeout_visit, &pv);
|
|
||||||
grub_video_swap_buffers ();
|
grub_video_swap_buffers ();
|
||||||
if (view->double_repaint)
|
if (view->double_repaint)
|
||||||
grub_gui_find_by_id ((grub_gui_component_t) view->canvas,
|
redraw_timeouts (view);
|
||||||
TIMEOUT_COMPONENT_ID, redraw_timeout_visit, &pv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_gfxmenu_clear_timeout (void *data)
|
grub_gfxmenu_clear_timeout (void *data)
|
||||||
{
|
{
|
||||||
struct progress_value_data pv;
|
|
||||||
struct grub_gfxmenu_view *view = data;
|
struct grub_gfxmenu_view *view = data;
|
||||||
|
|
||||||
auto void redraw_timeout_visit (grub_gui_component_t component,
|
update_timeouts (0, 1, 0, 0);
|
||||||
void *userdata __attribute__ ((unused)));
|
redraw_timeouts (view);
|
||||||
|
|
||||||
auto void redraw_timeout_visit (grub_gui_component_t component,
|
|
||||||
void *userdata __attribute__ ((unused)))
|
|
||||||
{
|
|
||||||
grub_video_rect_t bounds;
|
|
||||||
component->ops->get_bounds (component, &bounds);
|
|
||||||
grub_gfxmenu_view_redraw (view, &bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
pv.visible = 0;
|
|
||||||
pv.start = 1;
|
|
||||||
pv.end = 0;
|
|
||||||
pv.value = 0;
|
|
||||||
|
|
||||||
grub_gui_find_by_id ((grub_gui_component_t) view->canvas,
|
|
||||||
TIMEOUT_COMPONENT_ID, update_timeout_visit, &pv);
|
|
||||||
grub_gui_find_by_id ((grub_gui_component_t) view->canvas,
|
|
||||||
TIMEOUT_COMPONENT_ID, redraw_timeout_visit, &pv);
|
|
||||||
grub_video_swap_buffers ();
|
grub_video_swap_buffers ();
|
||||||
if (view->double_repaint)
|
if (view->double_repaint)
|
||||||
grub_gui_find_by_id ((grub_gui_component_t) view->canvas,
|
redraw_timeouts (view);
|
||||||
TIMEOUT_COMPONENT_ID, redraw_timeout_visit, &pv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -96,23 +96,8 @@ void grub_dl_unload_all (void);
|
||||||
#else
|
#else
|
||||||
#define GRUB_NO_MODULES 0
|
#define GRUB_NO_MODULES 0
|
||||||
#endif
|
#endif
|
||||||
#if GRUB_NO_MODULES
|
|
||||||
static inline int
|
|
||||||
grub_dl_ref (grub_dl_t mod)
|
|
||||||
{
|
|
||||||
(void) mod;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static inline int
|
|
||||||
grub_dl_unref (grub_dl_t mod)
|
|
||||||
{
|
|
||||||
(void) mod;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
|
int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
|
||||||
int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
|
int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
|
||||||
#endif
|
|
||||||
void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod));
|
void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod));
|
||||||
grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
|
grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
|
||||||
grub_err_t grub_dl_register_symbol (const char *name, void *addr,
|
grub_err_t grub_dl_register_symbol (const char *name, void *addr,
|
||||||
|
|
|
@ -26,7 +26,6 @@ enum grub_dev_abstraction_types {
|
||||||
};
|
};
|
||||||
|
|
||||||
char *grub_guess_root_device (const char *dir);
|
char *grub_guess_root_device (const char *dir);
|
||||||
char *grub_get_prefix (const char *dir);
|
|
||||||
int grub_util_get_dev_abstraction (const char *os_dev);
|
int grub_util_get_dev_abstraction (const char *os_dev);
|
||||||
char *grub_util_get_grub_dev (const char *os_dev);
|
char *grub_util_get_grub_dev (const char *os_dev);
|
||||||
const char *grub_util_check_block_device (const char *blk_dev);
|
const char *grub_util_check_block_device (const char *blk_dev);
|
50
include/grub/emu/misc.h
Normal file
50
include/grub/emu/misc.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#ifndef GRUB_EMU_MISC_H
|
||||||
|
#define GRUB_EMU_MISC_H 1
|
||||||
|
|
||||||
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
# include <sys/fcntl.h>
|
||||||
|
# include <sys/cygwin.h>
|
||||||
|
# include <limits.h>
|
||||||
|
# define DEV_CYGDRIVE_MAJOR 98
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __NetBSD__
|
||||||
|
/* NetBSD uses /boot for its boot block. */
|
||||||
|
# define DEFAULT_DIRECTORY "/grub"
|
||||||
|
#else
|
||||||
|
# define DEFAULT_DIRECTORY "/boot/grub"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
extern const char *program_name;
|
||||||
|
|
||||||
|
void grub_init_all (void);
|
||||||
|
void grub_fini_all (void);
|
||||||
|
|
||||||
|
char *grub_make_system_path_relative_to_its_root (const char *path);
|
||||||
|
|
||||||
|
void * EXPORT_FUNC(xmalloc) (grub_size_t size);
|
||||||
|
void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size);
|
||||||
|
char * EXPORT_FUNC(xstrdup) (const char *str);
|
||||||
|
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...);
|
||||||
|
|
||||||
|
void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...);
|
||||||
|
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...);
|
||||||
|
void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((noreturn));
|
||||||
|
|
||||||
|
#ifndef HAVE_VASPRINTF
|
||||||
|
int EXPORT_FUNC(vasprintf) (char **buf, const char *fmt, va_list ap);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_ASPRINTF
|
||||||
|
int EXPORT_FUNC(asprintf) (char **buf, const char *fmt, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...);
|
||||||
|
|
||||||
|
#endif /* GRUB_EMU_MISC_H */
|
|
@ -22,10 +22,15 @@
|
||||||
#include <grub/video.h>
|
#include <grub/video.h>
|
||||||
#include <grub/bitmap.h>
|
#include <grub/bitmap.h>
|
||||||
#include <grub/gfxmenu_view.h>
|
#include <grub/gfxmenu_view.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
|
||||||
#ifndef GRUB_GUI_H
|
#ifndef GRUB_GUI_H
|
||||||
#define GRUB_GUI_H 1
|
#define GRUB_GUI_H 1
|
||||||
|
|
||||||
|
/* The component ID identifying GUI components to be updated as the timeout
|
||||||
|
status changes. */
|
||||||
|
#define GRUB_GFXMENU_TIMEOUT_COMPONENT_ID "__timeout__"
|
||||||
|
|
||||||
/* A representation of a color. Unlike grub_video_color_t, this
|
/* A representation of a color. Unlike grub_video_color_t, this
|
||||||
representation is independent of any video mode specifics. */
|
representation is independent of any video mode specifics. */
|
||||||
typedef struct grub_gui_color
|
typedef struct grub_gui_color
|
||||||
|
@ -79,6 +84,46 @@ struct grub_gui_progress_ops
|
||||||
void (*set_state) (void *self, int visible, int start, int current, int end);
|
void (*set_state) (void *self, int visible, int start, int current, int end);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*grub_gfxmenu_set_state_t) (void *self, int visible, int start,
|
||||||
|
int current, int end);
|
||||||
|
|
||||||
|
struct grub_gfxmenu_timeout_notify
|
||||||
|
{
|
||||||
|
struct grub_gfxmenu_timeout_notify *next;
|
||||||
|
grub_gfxmenu_set_state_t set_state;
|
||||||
|
grub_gui_component_t self;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct grub_gfxmenu_timeout_notify *grub_gfxmenu_timeout_notifications;
|
||||||
|
|
||||||
|
static inline grub_err_t
|
||||||
|
grub_gfxmenu_timeout_register (grub_gui_component_t self,
|
||||||
|
grub_gfxmenu_set_state_t set_state)
|
||||||
|
{
|
||||||
|
struct grub_gfxmenu_timeout_notify *ne = grub_malloc (sizeof (*ne));
|
||||||
|
if (!ne)
|
||||||
|
return grub_errno;
|
||||||
|
ne->set_state = set_state;
|
||||||
|
ne->self = self;
|
||||||
|
ne->next = grub_gfxmenu_timeout_notifications;
|
||||||
|
grub_gfxmenu_timeout_notifications = ne;
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
grub_gfxmenu_timeout_unregister (grub_gui_component_t self)
|
||||||
|
{
|
||||||
|
struct grub_gfxmenu_timeout_notify **p, *q;
|
||||||
|
|
||||||
|
for (p = &grub_gfxmenu_timeout_notifications, q = *p;
|
||||||
|
q; p = &(q->next), q = q->next)
|
||||||
|
if (q->self == self)
|
||||||
|
{
|
||||||
|
*p = q->next;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
typedef signed grub_fixed_signed_t;
|
typedef signed grub_fixed_signed_t;
|
||||||
#define GRUB_FIXED_1 0x10000
|
#define GRUB_FIXED_1 0x10000
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,9 @@ typedef struct grub_linuxbios_table_header *grub_linuxbios_table_header_t;
|
||||||
|
|
||||||
struct grub_linuxbios_table_item
|
struct grub_linuxbios_table_item
|
||||||
{
|
{
|
||||||
#define GRUB_LINUXBIOS_MEMBER_UNUSED 0
|
#define GRUB_LINUXBIOS_MEMBER_UNUSED 0x00
|
||||||
#define GRUB_LINUXBIOS_MEMBER_MEMORY 1
|
#define GRUB_LINUXBIOS_MEMBER_MEMORY 0x01
|
||||||
|
#define GRUB_LINUXBIOS_MEMBER_LINK 0x11
|
||||||
grub_uint32_t tag;
|
grub_uint32_t tag;
|
||||||
grub_uint32_t size;
|
grub_uint32_t size;
|
||||||
};
|
};
|
||||||
|
|
1
include/grub/i386/multiboot/boot.h
Normal file
1
include/grub/i386/multiboot/boot.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include <grub/i386/coreboot/boot.h>
|
1
include/grub/i386/multiboot/console.h
Normal file
1
include/grub/i386/multiboot/console.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include <grub/i386/coreboot/console.h>
|
1
include/grub/i386/multiboot/init.h
Normal file
1
include/grub/i386/multiboot/init.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include <grub/i386/coreboot/init.h>
|
1
include/grub/i386/multiboot/kernel.h
Normal file
1
include/grub/i386/multiboot/kernel.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include <grub/i386/coreboot/kernel.h>
|
1
include/grub/i386/multiboot/loader.h
Normal file
1
include/grub/i386/multiboot/loader.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include <grub/i386/coreboot/loader.h>
|
1
include/grub/i386/multiboot/memory.h
Normal file
1
include/grub/i386/multiboot/memory.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include <grub/i386/coreboot/memory.h>
|
1
include/grub/i386/multiboot/serial.h
Normal file
1
include/grub/i386/multiboot/serial.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include <grub/i386/coreboot/serial.h>
|
1
include/grub/i386/multiboot/time.h
Normal file
1
include/grub/i386/multiboot/time.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include <grub/i386/coreboot/time.h>
|
|
@ -100,6 +100,9 @@ enum grub_ieee1275_flag
|
||||||
|
|
||||||
/* Open Hack'Ware don't support the ANSI sequence. */
|
/* Open Hack'Ware don't support the ANSI sequence. */
|
||||||
GRUB_IEEE1275_FLAG_NO_ANSI,
|
GRUB_IEEE1275_FLAG_NO_ANSI,
|
||||||
|
|
||||||
|
/* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
|
||||||
|
GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);
|
extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);
|
||||||
|
|
|
@ -47,6 +47,8 @@ struct grub_menu_entry
|
||||||
/* The sourcecode of the menu entry, used by the editor. */
|
/* The sourcecode of the menu entry, used by the editor. */
|
||||||
const char *sourcecode;
|
const char *sourcecode;
|
||||||
|
|
||||||
|
int hotkey;
|
||||||
|
|
||||||
/* The next element. */
|
/* The next element. */
|
||||||
struct grub_menu_entry *next;
|
struct grub_menu_entry *next;
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,7 +49,7 @@ void grub_multiboot_set_bootdev (void);
|
||||||
grub_uint32_t grub_get_multiboot_mmap_count (void);
|
grub_uint32_t grub_get_multiboot_mmap_count (void);
|
||||||
grub_err_t grub_multiboot_set_video_mode (void);
|
grub_err_t grub_multiboot_set_video_mode (void);
|
||||||
|
|
||||||
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
|
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU)
|
||||||
#include <grub/i386/pc/vbe.h>
|
#include <grub/i386/pc/vbe.h>
|
||||||
#define GRUB_MACHINE_HAS_VGA_TEXT 1
|
#define GRUB_MACHINE_HAS_VGA_TEXT 1
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -28,26 +28,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
|
#include <grub/emu/misc.h>
|
||||||
#ifdef __NetBSD__
|
|
||||||
/* NetBSD uses /boot for its boot block. */
|
|
||||||
# define DEFAULT_DIRECTORY "/grub"
|
|
||||||
#else
|
|
||||||
# define DEFAULT_DIRECTORY "/boot/grub"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"
|
|
||||||
|
|
||||||
extern char *progname;
|
|
||||||
extern int verbosity;
|
|
||||||
|
|
||||||
void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...);
|
|
||||||
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...);
|
|
||||||
void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((noreturn));
|
|
||||||
|
|
||||||
void *xmalloc (size_t size);
|
|
||||||
void *xrealloc (void *ptr, size_t size);
|
|
||||||
char *xstrdup (const char *str);
|
|
||||||
|
|
||||||
char *grub_util_get_path (const char *dir, const char *file);
|
char *grub_util_get_path (const char *dir, const char *file);
|
||||||
size_t grub_util_get_fp_size (FILE *fp);
|
size_t grub_util_get_fp_size (FILE *fp);
|
||||||
|
@ -59,20 +40,6 @@ void grub_util_write_image (const char *img, size_t size, FILE *out);
|
||||||
void grub_util_write_image_at (const void *img, size_t size, off_t offset,
|
void grub_util_write_image_at (const void *img, size_t size, off_t offset,
|
||||||
FILE *out);
|
FILE *out);
|
||||||
|
|
||||||
#ifndef HAVE_VASPRINTF
|
|
||||||
|
|
||||||
int vasprintf (char **buf, const char *fmt, va_list ap);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_ASPRINTF
|
|
||||||
|
|
||||||
int asprintf (char **buf, const char *fmt, ...);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *xasprintf (const char *fmt, ...);
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
#define fseeko fseeko64
|
#define fseeko fseeko64
|
||||||
|
|
|
@ -181,7 +181,8 @@ typedef enum grub_video_driver_id
|
||||||
GRUB_VIDEO_DRIVER_VBE,
|
GRUB_VIDEO_DRIVER_VBE,
|
||||||
GRUB_VIDEO_DRIVER_EFI_UGA,
|
GRUB_VIDEO_DRIVER_EFI_UGA,
|
||||||
GRUB_VIDEO_DRIVER_EFI_GOP,
|
GRUB_VIDEO_DRIVER_EFI_GOP,
|
||||||
GRUB_VIDEO_DRIVER_SM712
|
GRUB_VIDEO_DRIVER_SM712,
|
||||||
|
GRUB_VIDEO_DRIVER_VGA
|
||||||
} grub_video_driver_id_t;
|
} grub_video_driver_id_t;
|
||||||
|
|
||||||
struct grub_video_adapter
|
struct grub_video_adapter
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
#include <grub/device.h>
|
#include <grub/device.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
/* set ENVVAR=VALUE */
|
/* set ENVVAR=VALUE */
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
|
@ -178,11 +179,13 @@ void
|
||||||
grub_register_core_commands (void)
|
grub_register_core_commands (void)
|
||||||
{
|
{
|
||||||
grub_register_command ("set", grub_core_cmd_set,
|
grub_register_command ("set", grub_core_cmd_set,
|
||||||
"[ENVVAR=VALUE]", "Set an environment variable.");
|
N_("[ENVVAR=VALUE]"),
|
||||||
|
N_("Set an environment variable."));
|
||||||
grub_register_command ("unset", grub_core_cmd_unset,
|
grub_register_command ("unset", grub_core_cmd_unset,
|
||||||
"ENVVAR", "Remove an environment variable.");
|
N_("ENVVAR"),
|
||||||
|
N_("Remove an environment variable."));
|
||||||
grub_register_command ("ls", grub_core_cmd_ls,
|
grub_register_command ("ls", grub_core_cmd_ls,
|
||||||
"[ARG]", "List devices or files.");
|
N_("[ARG]"), N_("List devices or files."));
|
||||||
grub_register_command ("insmod", grub_core_cmd_insmod,
|
grub_register_command ("insmod", grub_core_cmd_insmod,
|
||||||
"MODULE", "Insert a module.");
|
N_("MODULE"), N_("Insert a module."));
|
||||||
}
|
}
|
||||||
|
|
|
@ -469,12 +469,14 @@ grub_dl_resolve_dependencies (grub_dl_t mod, Elf_Ehdr *e)
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !GRUB_NO_MODULES
|
|
||||||
int
|
int
|
||||||
grub_dl_ref (grub_dl_t mod)
|
grub_dl_ref (grub_dl_t mod)
|
||||||
{
|
{
|
||||||
grub_dl_dep_t dep;
|
grub_dl_dep_t dep;
|
||||||
|
|
||||||
|
if (!mod)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (dep = mod->dep; dep; dep = dep->next)
|
for (dep = mod->dep; dep; dep = dep->next)
|
||||||
grub_dl_ref (dep->mod);
|
grub_dl_ref (dep->mod);
|
||||||
|
|
||||||
|
@ -486,12 +488,14 @@ grub_dl_unref (grub_dl_t mod)
|
||||||
{
|
{
|
||||||
grub_dl_dep_t dep;
|
grub_dl_dep_t dep;
|
||||||
|
|
||||||
|
if (!mod)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (dep = mod->dep; dep; dep = dep->next)
|
for (dep = mod->dep; dep; dep = dep->next)
|
||||||
grub_dl_unref (dep->mod);
|
grub_dl_unref (dep->mod);
|
||||||
|
|
||||||
return --mod->ref_count;
|
return --mod->ref_count;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_dl_flush_cache (grub_dl_t mod)
|
grub_dl_flush_cache (grub_dl_t mod)
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
# define A_STANDOUT 0
|
# define A_STANDOUT 0
|
||||||
#endif /* ! A_STANDOUT */
|
#endif /* ! A_STANDOUT */
|
||||||
|
|
||||||
#include <grub/util/console.h>
|
#include <grub/emu/console.h>
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
|
|
|
@ -19,16 +19,15 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
#ifdef __CYGWIN__
|
#include <stdio.h>
|
||||||
# include <sys/fcntl.h>
|
#include <stdlib.h>
|
||||||
# include <sys/cygwin.h>
|
#include <stdint.h>
|
||||||
# include <limits.h>
|
|
||||||
# define DEV_CYGDRIVE_MAJOR 98
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __GNU__
|
#ifdef __GNU__
|
||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
|
@ -36,9 +35,11 @@
|
||||||
#include <hurd/fs.h>
|
#include <hurd/fs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <grub/util/misc.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/util/getroot.h>
|
#include <grub/emu/misc.h>
|
||||||
|
#include <grub/emu/hostdisk.h>
|
||||||
|
#include <grub/emu/getroot.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
strip_extra_slashes (char *dir)
|
strip_extra_slashes (char *dir)
|
||||||
|
@ -79,103 +80,6 @@ xgetcwd (void)
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
/* Convert POSIX path to Win32 path,
|
|
||||||
remove drive letter, replace backslashes. */
|
|
||||||
static char *
|
|
||||||
get_win32_path (const char *path)
|
|
||||||
{
|
|
||||||
char winpath[PATH_MAX];
|
|
||||||
cygwin_conv_to_full_win32_path (path, winpath);
|
|
||||||
|
|
||||||
int len = strlen (winpath);
|
|
||||||
if (len > 2 && winpath[1] == ':')
|
|
||||||
{
|
|
||||||
len -= 2;
|
|
||||||
memmove (winpath, winpath + 2, len + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
if (winpath[i] == '\\')
|
|
||||||
winpath[i] = '/';
|
|
||||||
return xstrdup (winpath);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *
|
|
||||||
grub_get_prefix (const char *dir)
|
|
||||||
{
|
|
||||||
char *saved_cwd;
|
|
||||||
char *abs_dir, *prev_dir;
|
|
||||||
char *prefix;
|
|
||||||
struct stat st, prev_st;
|
|
||||||
|
|
||||||
/* Save the current directory. */
|
|
||||||
saved_cwd = xgetcwd ();
|
|
||||||
|
|
||||||
if (chdir (dir) < 0)
|
|
||||||
grub_util_error ("cannot change directory to `%s'", dir);
|
|
||||||
|
|
||||||
abs_dir = xgetcwd ();
|
|
||||||
strip_extra_slashes (abs_dir);
|
|
||||||
prev_dir = xstrdup (abs_dir);
|
|
||||||
|
|
||||||
if (stat (".", &prev_st) < 0)
|
|
||||||
grub_util_error ("cannot stat `%s'", dir);
|
|
||||||
|
|
||||||
if (! S_ISDIR (prev_st.st_mode))
|
|
||||||
grub_util_error ("`%s' is not a directory", dir);
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
if (chdir ("..") < 0)
|
|
||||||
grub_util_error ("cannot change directory to the parent");
|
|
||||||
|
|
||||||
if (stat (".", &st) < 0)
|
|
||||||
grub_util_error ("cannot stat current directory");
|
|
||||||
|
|
||||||
if (! S_ISDIR (st.st_mode))
|
|
||||||
grub_util_error ("current directory is not a directory???");
|
|
||||||
|
|
||||||
if (prev_st.st_dev != st.st_dev || prev_st.st_ino == st.st_ino)
|
|
||||||
break;
|
|
||||||
|
|
||||||
free (prev_dir);
|
|
||||||
prev_dir = xgetcwd ();
|
|
||||||
prev_st = st;
|
|
||||||
}
|
|
||||||
|
|
||||||
strip_extra_slashes (prev_dir);
|
|
||||||
prefix = xmalloc (strlen (abs_dir) - strlen (prev_dir) + 2);
|
|
||||||
prefix[0] = '/';
|
|
||||||
strcpy (prefix + 1, abs_dir + strlen (prev_dir));
|
|
||||||
strip_extra_slashes (prefix);
|
|
||||||
|
|
||||||
if (chdir (saved_cwd) < 0)
|
|
||||||
grub_util_error ("cannot change directory to `%s'", dir);
|
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
|
||||||
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
|
|
||||||
{
|
|
||||||
/* Reached some mount point not below /cygdrive.
|
|
||||||
GRUB does not know Cygwin's emulated mounts,
|
|
||||||
convert to Win32 path. */
|
|
||||||
grub_util_info ("Cygwin prefix = %s", prefix);
|
|
||||||
char * wprefix = get_win32_path (prefix);
|
|
||||||
free (prefix);
|
|
||||||
prefix = wprefix;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
free (saved_cwd);
|
|
||||||
free (abs_dir);
|
|
||||||
free (prev_dir);
|
|
||||||
|
|
||||||
grub_util_info ("prefix = %s", prefix);
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
@ -637,4 +541,3 @@ grub_util_check_char_device (const char *blk_dev)
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#include <grub/msdos_partition.h>
|
#include <grub/msdos_partition.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/err.h>
|
#include <grub/err.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/emu/hostdisk.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
#include <grub/list.h>
|
#include <grub/list.h>
|
|
@ -16,7 +16,10 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <setjmp.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -24,16 +27,17 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <grub/dl.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/setjmp.h>
|
#include <grub/setjmp.h>
|
||||||
#include <grub/fs.h>
|
#include <grub/fs.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/emu/hostdisk.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/time.h>
|
||||||
#include <grub/util/console.h>
|
#include <grub/emu/console.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/emu/misc.h>
|
||||||
#include <grub/kernel.h>
|
#include <grub/kernel.h>
|
||||||
#include <grub/normal.h>
|
#include <grub/normal.h>
|
||||||
#include <grub/util/getroot.h>
|
#include <grub/emu/getroot.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/partition.h>
|
#include <grub/partition.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
@ -242,7 +246,7 @@ main (int argc, char *argv[])
|
||||||
if (strcmp (root_dev, "host") == 0)
|
if (strcmp (root_dev, "host") == 0)
|
||||||
dir = xstrdup (dir);
|
dir = xstrdup (dir);
|
||||||
else
|
else
|
||||||
dir = grub_get_prefix (dir);
|
dir = grub_make_system_path_relative_to_its_root (dir);
|
||||||
prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1);
|
prefix = xmalloc (strlen (root_dev) + 2 + strlen (dir) + 1);
|
||||||
sprintf (prefix, "(%s)%s", root_dev, dir);
|
sprintf (prefix, "(%s)%s", root_dev, dir);
|
||||||
free (dir);
|
free (dir);
|
||||||
|
@ -261,3 +265,32 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_millisleep (grub_uint32_t ms)
|
||||||
|
{
|
||||||
|
Sleep (ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_millisleep (grub_uint32_t ms)
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
|
||||||
|
ts.tv_sec = ms / 1000;
|
||||||
|
ts.tv_nsec = (ms % 1000) * 1000000;
|
||||||
|
nanosleep (&ts, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if GRUB_NO_MODULES
|
||||||
|
void
|
||||||
|
grub_register_exported_symbols (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
296
kern/emu/misc.c
Normal file
296
kern/emu/misc.c
Normal file
|
@ -0,0 +1,296 @@
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/err.h>
|
||||||
|
#include <grub/env.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/time.h>
|
||||||
|
#include <grub/emu/misc.h>
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_util_warn (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
fprintf (stderr, _("%s: warn:"), program_name);
|
||||||
|
fprintf (stderr, " ");
|
||||||
|
va_start (ap, fmt);
|
||||||
|
vfprintf (stderr, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
fprintf (stderr, ".\n");
|
||||||
|
fflush (stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_util_info (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
if (verbosity > 0)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
fprintf (stderr, _("%s: info:"), program_name);
|
||||||
|
fprintf (stderr, " ");
|
||||||
|
va_start (ap, fmt);
|
||||||
|
vfprintf (stderr, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
fprintf (stderr, ".\n");
|
||||||
|
fflush (stderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_util_error (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
fprintf (stderr, _("%s: error:"), program_name);
|
||||||
|
fprintf (stderr, " ");
|
||||||
|
va_start (ap, fmt);
|
||||||
|
vfprintf (stderr, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
fprintf (stderr, ".\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
xmalloc (grub_size_t size)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
p = malloc (size);
|
||||||
|
if (! p)
|
||||||
|
grub_util_error ("out of memory");
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
xrealloc (void *ptr, grub_size_t size)
|
||||||
|
{
|
||||||
|
ptr = realloc (ptr, size);
|
||||||
|
if (! ptr)
|
||||||
|
grub_util_error ("out of memory");
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
xstrdup (const char *str)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char *newstr;
|
||||||
|
|
||||||
|
len = strlen (str);
|
||||||
|
newstr = (char *) xmalloc (len + 1);
|
||||||
|
memcpy (newstr, str, len + 1);
|
||||||
|
|
||||||
|
return newstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_VASPRINTF
|
||||||
|
|
||||||
|
int
|
||||||
|
vasprintf (char **buf, const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
/* Should be large enough. */
|
||||||
|
*buf = xmalloc (512);
|
||||||
|
|
||||||
|
return vsprintf (*buf, fmt, ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_ASPRINTF
|
||||||
|
|
||||||
|
int
|
||||||
|
asprintf (char **buf, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start (ap, fmt);
|
||||||
|
status = vasprintf (*buf, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char *
|
||||||
|
xasprintf (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
va_start (ap, fmt);
|
||||||
|
if (vasprintf (&result, fmt, ap) < 0)
|
||||||
|
{
|
||||||
|
if (errno == ENOMEM)
|
||||||
|
grub_util_error ("out of memory");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grub_exit (void)
|
||||||
|
{
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_uint64_t
|
||||||
|
grub_get_time_ms (void)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
gettimeofday (&tv, 0);
|
||||||
|
|
||||||
|
return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_uint32_t
|
||||||
|
grub_get_rtc (void)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
gettimeofday (&tv, 0);
|
||||||
|
|
||||||
|
return (tv.tv_sec * GRUB_TICKS_PER_SECOND
|
||||||
|
+ (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
|
||||||
|
* GRUB_TICKS_PER_SECOND / 1000000));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
/* Convert POSIX path to Win32 path,
|
||||||
|
remove drive letter, replace backslashes. */
|
||||||
|
static char *
|
||||||
|
get_win32_path (const char *path)
|
||||||
|
{
|
||||||
|
char winpath[PATH_MAX];
|
||||||
|
if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, path, winpath, sizeof(winpath)))
|
||||||
|
grub_util_error ("cygwin_conv_path() failed");
|
||||||
|
|
||||||
|
int len = strlen (winpath);
|
||||||
|
int offs = (len > 2 && winpath[1] == ':' ? 2 : 0);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = offs; i < len; i++)
|
||||||
|
if (winpath[i] == '\\')
|
||||||
|
winpath[i] = '/';
|
||||||
|
return xstrdup (winpath + offs);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This function never prints trailing slashes (so that its output
|
||||||
|
can be appended a slash unconditionally). */
|
||||||
|
char *
|
||||||
|
grub_make_system_path_relative_to_its_root (const char *path)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
char *p, *buf, *buf2, *buf3;
|
||||||
|
uintptr_t offset = 0;
|
||||||
|
dev_t num;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
/* canonicalize. */
|
||||||
|
p = canonicalize_file_name (path);
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
grub_util_error ("failed to get canonical path of %s", path);
|
||||||
|
|
||||||
|
len = strlen (p) + 1;
|
||||||
|
buf = xstrdup (p);
|
||||||
|
free (p);
|
||||||
|
|
||||||
|
if (stat (buf, &st) < 0)
|
||||||
|
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
||||||
|
|
||||||
|
buf2 = xstrdup (buf);
|
||||||
|
num = st.st_dev;
|
||||||
|
|
||||||
|
/* This loop sets offset to the number of chars of the root
|
||||||
|
directory we're inspecting. */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
p = strrchr (buf, '/');
|
||||||
|
if (p == NULL)
|
||||||
|
/* This should never happen. */
|
||||||
|
grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
|
||||||
|
if (p != buf)
|
||||||
|
*p = 0;
|
||||||
|
else
|
||||||
|
*++p = 0;
|
||||||
|
|
||||||
|
if (stat (buf, &st) < 0)
|
||||||
|
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
||||||
|
|
||||||
|
/* buf is another filesystem; we found it. */
|
||||||
|
if (st.st_dev != num)
|
||||||
|
{
|
||||||
|
/* offset == 0 means path given is the mount point.
|
||||||
|
This works around special-casing of "/" in Un*x. This function never
|
||||||
|
prints trailing slashes (so that its output can be appended a slash
|
||||||
|
unconditionally). Each slash in is considered a preceding slash, and
|
||||||
|
therefore the root directory is an empty string. */
|
||||||
|
if (offset == 0)
|
||||||
|
{
|
||||||
|
free (buf);
|
||||||
|
free (buf2);
|
||||||
|
return xstrdup ("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = p - buf;
|
||||||
|
/* offset == 1 means root directory. */
|
||||||
|
if (offset == 1)
|
||||||
|
{
|
||||||
|
/* Include leading slash. */
|
||||||
|
offset = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (buf);
|
||||||
|
buf3 = xstrdup (buf2 + offset);
|
||||||
|
free (buf2);
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
if (st.st_dev != (DEV_CYGDRIVE_MAJOR << 16))
|
||||||
|
{
|
||||||
|
/* Reached some mount point not below /cygdrive.
|
||||||
|
GRUB does not know Cygwin's emulated mounts,
|
||||||
|
convert to Win32 path. */
|
||||||
|
grub_util_info ("Cygwin path = %s\n", buf3);
|
||||||
|
char * temp = get_win32_path (buf3);
|
||||||
|
free (buf3);
|
||||||
|
buf3 = temp;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Remove trailing slashes, return empty string if root directory. */
|
||||||
|
len = strlen (buf3);
|
||||||
|
while (len > 0 && buf3[len - 1] == '/')
|
||||||
|
{
|
||||||
|
buf3[len - 1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf3;
|
||||||
|
}
|
|
@ -118,7 +118,9 @@ grub_machine_init (void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU)
|
||||||
grub_machine_mmap_init ();
|
grub_machine_mmap_init ();
|
||||||
|
#endif
|
||||||
grub_machine_mmap_iterate (heap_init);
|
grub_machine_mmap_iterate (heap_init);
|
||||||
|
|
||||||
grub_tsc_init ();
|
grub_tsc_init ();
|
||||||
|
|
|
@ -57,13 +57,23 @@ signature_found:
|
||||||
(long) table_header->size);
|
(long) table_header->size);
|
||||||
for (; table_item->size;
|
for (; table_item->size;
|
||||||
table_item = (grub_linuxbios_table_item_t) ((long) table_item + (long) table_item->size))
|
table_item = (grub_linuxbios_table_item_t) ((long) table_item + (long) table_item->size))
|
||||||
if (hook (table_item))
|
{
|
||||||
return 1;
|
if (table_item->tag == GRUB_LINUXBIOS_MEMBER_LINK
|
||||||
|
&& check_signature ((grub_linuxbios_table_header_t) (grub_addr_t)
|
||||||
|
*(grub_uint64_t *) (table_item + 1)))
|
||||||
|
{
|
||||||
|
table_header = (grub_linuxbios_table_header_t) (grub_addr_t)
|
||||||
|
*(grub_uint64_t *) (table_item + 1);
|
||||||
|
goto signature_found;
|
||||||
|
}
|
||||||
|
if (hook (table_item))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
grub_err_t
|
||||||
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
|
grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t))
|
||||||
{
|
{
|
||||||
mem_region_t mem_region;
|
mem_region_t mem_region;
|
||||||
|
|
|
@ -66,10 +66,12 @@ multiboot_header:
|
||||||
.long -0x1BADB002 - MULTIBOOT_MEMORY_INFO
|
.long -0x1BADB002 - MULTIBOOT_MEMORY_INFO
|
||||||
|
|
||||||
codestart:
|
codestart:
|
||||||
|
#ifdef GRUB_MACHINE_MULTIBOOT
|
||||||
cmpl $MULTIBOOT_BOOTLOADER_MAGIC, %eax
|
cmpl $MULTIBOOT_BOOTLOADER_MAGIC, %eax
|
||||||
jne 0f
|
jne 0f
|
||||||
movl %ebx, EXT_C(startup_multiboot_info)
|
movl %ebx, EXT_C(startup_multiboot_info)
|
||||||
0:
|
0:
|
||||||
|
#endif
|
||||||
|
|
||||||
/* initialize the stack */
|
/* initialize the stack */
|
||||||
movl $GRUB_MEMORY_MACHINE_PROT_STACK, %esp
|
movl $GRUB_MEMORY_MACHINE_PROT_STACK, %esp
|
||||||
|
|
|
@ -58,6 +58,7 @@ grub_ieee1275_find_options (void)
|
||||||
char tmp[32];
|
char tmp[32];
|
||||||
int is_smartfirmware = 0;
|
int is_smartfirmware = 0;
|
||||||
int is_olpc = 0;
|
int is_olpc = 0;
|
||||||
|
int is_qemu = 0;
|
||||||
|
|
||||||
grub_ieee1275_finddevice ("/", &root);
|
grub_ieee1275_finddevice ("/", &root);
|
||||||
grub_ieee1275_finddevice ("/options", &options);
|
grub_ieee1275_finddevice ("/options", &options);
|
||||||
|
@ -78,6 +79,11 @@ grub_ieee1275_find_options (void)
|
||||||
if (rc >= 0 && !grub_strcmp (tmp, "OLPC"))
|
if (rc >= 0 && !grub_strcmp (tmp, "OLPC"))
|
||||||
is_olpc = 1;
|
is_olpc = 1;
|
||||||
|
|
||||||
|
rc = grub_ieee1275_get_property (root, "model",
|
||||||
|
tmp, sizeof (tmp), 0);
|
||||||
|
if (rc >= 0 && !grub_strcmp (tmp, "Emulated PC"))
|
||||||
|
is_qemu = 1;
|
||||||
|
|
||||||
if (is_smartfirmware)
|
if (is_smartfirmware)
|
||||||
{
|
{
|
||||||
/* Broken in all versions */
|
/* Broken in all versions */
|
||||||
|
@ -134,6 +140,10 @@ grub_ieee1275_find_options (void)
|
||||||
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY);
|
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_qemu)
|
||||||
|
/* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
|
||||||
|
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM);
|
||||||
|
|
||||||
if (! grub_ieee1275_finddevice ("/rom/boot-rom", &bootrom))
|
if (! grub_ieee1275_finddevice ("/rom/boot-rom", &bootrom))
|
||||||
{
|
{
|
||||||
rc = grub_ieee1275_get_property (bootrom, "model", tmp, sizeof (tmp), 0);
|
rc = grub_ieee1275_get_property (bootrom, "model", tmp, sizeof (tmp), 0);
|
||||||
|
|
|
@ -132,6 +132,17 @@ static void grub_claim_heap (void)
|
||||||
if (type != 1)
|
if (type != 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM))
|
||||||
|
{
|
||||||
|
if (addr + len <= 0x180000)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (addr < 0x180000)
|
||||||
|
{
|
||||||
|
len = addr + len - 0x180000;
|
||||||
|
addr = 0x180000;
|
||||||
|
}
|
||||||
|
}
|
||||||
len -= 1; /* Required for some firmware. */
|
len -= 1; /* Required for some firmware. */
|
||||||
|
|
||||||
/* Never exceed HEAP_MAX_SIZE */
|
/* Never exceed HEAP_MAX_SIZE */
|
||||||
|
|
|
@ -102,7 +102,7 @@ grub_load_config (void)
|
||||||
auto int hook (struct grub_module_header *);
|
auto int hook (struct grub_module_header *);
|
||||||
int hook (struct grub_module_header *header)
|
int hook (struct grub_module_header *header)
|
||||||
{
|
{
|
||||||
/* Not an ELF module, skip. */
|
/* Not an embedded config, skip. */
|
||||||
if (header->type != OBJ_TYPE_CONFIG)
|
if (header->type != OBJ_TYPE_CONFIG)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
38
kern/mm.c
38
kern/mm.c
|
@ -148,15 +148,14 @@ grub_mm_init_region (void *addr, grub_size_t size)
|
||||||
grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size);
|
grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If this region is too small, ignore it. */
|
|
||||||
if (size < GRUB_MM_ALIGN * 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Allocate a region from the head. */
|
/* Allocate a region from the head. */
|
||||||
r = (grub_mm_region_t) (((grub_addr_t) addr + GRUB_MM_ALIGN - 1)
|
r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN);
|
||||||
& (~(GRUB_MM_ALIGN - 1)));
|
|
||||||
size -= (char *) r - (char *) addr + sizeof (*r);
|
size -= (char *) r - (char *) addr + sizeof (*r);
|
||||||
|
|
||||||
|
/* If this region is too small, ignore it. */
|
||||||
|
if (size < GRUB_MM_ALIGN)
|
||||||
|
return;
|
||||||
|
|
||||||
h = (grub_mm_header_t) ((char *) r + GRUB_MM_ALIGN);
|
h = (grub_mm_header_t) ((char *) r + GRUB_MM_ALIGN);
|
||||||
h->next = h;
|
h->next = h;
|
||||||
h->magic = GRUB_MM_FREE_MAGIC;
|
h->magic = GRUB_MM_FREE_MAGIC;
|
||||||
|
@ -221,9 +220,8 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
||||||
+---------------+ v
|
+---------------+ v
|
||||||
*/
|
*/
|
||||||
q->next = p->next;
|
q->next = p->next;
|
||||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
|
||||||
}
|
}
|
||||||
else if (extra == 0 || p->size == n + extra)
|
else if (align == 1 || p->size == n + extra)
|
||||||
{
|
{
|
||||||
/* There might be alignment requirement, when taking it into
|
/* There might be alignment requirement, when taking it into
|
||||||
account memory block fits in.
|
account memory block fits in.
|
||||||
|
@ -240,10 +238,25 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
||||||
| alloc, size=n | |
|
| alloc, size=n | |
|
||||||
+---------------+ v
|
+---------------+ v
|
||||||
*/
|
*/
|
||||||
|
|
||||||
p->size -= n;
|
p->size -= n;
|
||||||
p += p->size;
|
p += p->size;
|
||||||
p->size = n;
|
}
|
||||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
else if (extra == 0)
|
||||||
|
{
|
||||||
|
grub_mm_header_t r;
|
||||||
|
|
||||||
|
r = p + extra + n;
|
||||||
|
r->magic = GRUB_MM_FREE_MAGIC;
|
||||||
|
r->size = p->size - extra - n;
|
||||||
|
r->next = p->next;
|
||||||
|
q->next = r;
|
||||||
|
|
||||||
|
if (q == p)
|
||||||
|
{
|
||||||
|
q = r;
|
||||||
|
r->next = r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -276,10 +289,11 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
||||||
p->size = extra;
|
p->size = extra;
|
||||||
p->next = r;
|
p->next = r;
|
||||||
p += extra;
|
p += extra;
|
||||||
p->size = n;
|
|
||||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p->magic = GRUB_MM_ALLOC_MAGIC;
|
||||||
|
p->size = n;
|
||||||
|
|
||||||
/* Mark find as a start marker for next allocation to fasten it.
|
/* Mark find as a start marker for next allocation to fasten it.
|
||||||
This will have side effect of fragmenting memory as small
|
This will have side effect of fragmenting memory as small
|
||||||
pieces before this will be un-used. */
|
pieces before this will be un-used. */
|
||||||
|
|
|
@ -249,12 +249,11 @@ grub_parser_execute (char *source)
|
||||||
}
|
}
|
||||||
|
|
||||||
p = grub_strchr (source, '\n');
|
p = grub_strchr (source, '\n');
|
||||||
if (p)
|
|
||||||
*p = 0;
|
|
||||||
|
|
||||||
*line = grub_strdup (source);
|
|
||||||
if (p)
|
if (p)
|
||||||
*p = '\n';
|
*line = grub_strndup (source, p - source);
|
||||||
|
else
|
||||||
|
*line = grub_strdup (source);
|
||||||
source = p ? p + 1 : 0;
|
source = p ? p + 1 : 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
#include <grub/efi/efi.h>
|
#include <grub/efi/efi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
|
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
|
||||||
#define DEFAULT_VIDEO_MODE "text"
|
#define DEFAULT_VIDEO_MODE "text"
|
||||||
#else
|
#else
|
||||||
#define DEFAULT_VIDEO_MODE "auto"
|
#define DEFAULT_VIDEO_MODE "auto"
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/video.h>
|
#include <grub/video.h>
|
||||||
|
|
||||||
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
|
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU)
|
||||||
#include <grub/i386/pc/vbe.h>
|
#include <grub/i386/pc/vbe.h>
|
||||||
#define HAS_VGA_TEXT 1
|
#define HAS_VGA_TEXT 1
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
#ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE
|
#ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE
|
||||||
|
|
||||||
|
@ -414,8 +415,8 @@ static grub_command_t cmd;
|
||||||
GRUB_MOD_INIT(mmap)
|
GRUB_MOD_INIT(mmap)
|
||||||
{
|
{
|
||||||
cmd = grub_register_command ("badram", grub_cmd_badram,
|
cmd = grub_register_command ("badram", grub_cmd_badram,
|
||||||
"ADDR1,MASK1[,ADDR2,MASK2[,...]]",
|
N_("ADDR1,MASK1[,ADDR2,MASK2[,...]]"),
|
||||||
"Declare memory regions as badram.");
|
N_("Declare memory regions as badram."));
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(mmap)
|
GRUB_MOD_FINI(mmap)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/normal.h>
|
#include <grub/normal.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
struct menu_pointer
|
struct menu_pointer
|
||||||
{
|
{
|
||||||
|
@ -172,7 +173,7 @@ grub_context_init (void)
|
||||||
grub_env_export ("prefix");
|
grub_env_export ("prefix");
|
||||||
|
|
||||||
export_cmd = grub_register_command ("export", grub_cmd_export,
|
export_cmd = grub_register_command ("export", grub_cmd_export,
|
||||||
"export ENVVAR", "Export a variable.");
|
N_("ENVVAR"), N_("Export a variable."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -155,6 +155,17 @@ free_menu_entry_classes (struct grub_menu_entry_class *head)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
int key;
|
||||||
|
} hotkey_aliases[] =
|
||||||
|
{
|
||||||
|
{"backspace", '\b'},
|
||||||
|
{"tab", '\t'},
|
||||||
|
{"delete", GRUB_TERM_DC}
|
||||||
|
};
|
||||||
|
|
||||||
/* Add a menu entry to the current menu context (as given by the environment
|
/* Add a menu entry to the current menu context (as given by the environment
|
||||||
variable data slot `menu'). As the configuration file is read, the script
|
variable data slot `menu'). As the configuration file is read, the script
|
||||||
parser calls this when a menu entry is to be created. */
|
parser calls this when a menu entry is to be created. */
|
||||||
|
@ -171,6 +182,7 @@ grub_normal_add_menu_entry (int argc, const char **args,
|
||||||
struct grub_menu_entry_class *classes_head; /* Dummy head node for list. */
|
struct grub_menu_entry_class *classes_head; /* Dummy head node for list. */
|
||||||
struct grub_menu_entry_class *classes_tail;
|
struct grub_menu_entry_class *classes_tail;
|
||||||
char *users = NULL;
|
char *users = NULL;
|
||||||
|
int hotkey = 0;
|
||||||
|
|
||||||
/* Allocate dummy head node for class list. */
|
/* Allocate dummy head node for class list. */
|
||||||
classes_head = grub_zalloc (sizeof (struct grub_menu_entry_class));
|
classes_head = grub_zalloc (sizeof (struct grub_menu_entry_class));
|
||||||
|
@ -237,6 +249,32 @@ grub_normal_add_menu_entry (int argc, const char **args,
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (grub_strcmp(arg, "hotkey") == 0)
|
||||||
|
{
|
||||||
|
unsigned j;
|
||||||
|
|
||||||
|
i++;
|
||||||
|
if (args[i][1] == 0)
|
||||||
|
{
|
||||||
|
hotkey = args[i][0];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < ARRAY_SIZE (hotkey_aliases); j++)
|
||||||
|
if (grub_strcmp (args[i], hotkey_aliases[j].name) == 0)
|
||||||
|
{
|
||||||
|
hotkey = hotkey_aliases[j].key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j < ARRAY_SIZE (hotkey_aliases))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
failed = 1;
|
||||||
|
grub_error (GRUB_ERR_MENU,
|
||||||
|
"Invalid hotkey: '%s'.", args[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Handle invalid argument. */
|
/* Handle invalid argument. */
|
||||||
|
@ -293,6 +331,7 @@ grub_normal_add_menu_entry (int argc, const char **args,
|
||||||
}
|
}
|
||||||
|
|
||||||
(*last)->title = menutitle;
|
(*last)->title = menutitle;
|
||||||
|
(*last)->hotkey = hotkey;
|
||||||
(*last)->classes = classes_head;
|
(*last)->classes = classes_head;
|
||||||
if (users)
|
if (users)
|
||||||
(*last)->restricted = 1;
|
(*last)->restricted = 1;
|
||||||
|
@ -666,9 +705,9 @@ GRUB_MOD_INIT(normal)
|
||||||
|
|
||||||
/* Register a command "normal" for the rescue mode. */
|
/* Register a command "normal" for the rescue mode. */
|
||||||
grub_register_command ("normal", grub_cmd_normal,
|
grub_register_command ("normal", grub_cmd_normal,
|
||||||
0, "Enter normal mode.");
|
0, N_("Enter normal mode."));
|
||||||
grub_register_command ("normal_exit", grub_cmd_normal_exit,
|
grub_register_command ("normal_exit", grub_cmd_normal_exit,
|
||||||
0, "Exit from normal mode.");
|
0, N_("Exit from normal mode."));
|
||||||
|
|
||||||
/* Reload terminal colors when these variables are written to. */
|
/* Reload terminal colors when these variables are written to. */
|
||||||
grub_register_variable_hook ("color_normal", NULL, grub_env_write_color_normal);
|
grub_register_variable_hook ("color_normal", NULL, grub_env_write_color_normal);
|
||||||
|
|
|
@ -478,6 +478,18 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||||
goto refresh;
|
goto refresh;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
|
grub_menu_entry_t entry;
|
||||||
|
int i;
|
||||||
|
for (i = 0, entry = menu->entry_list; i < menu->size;
|
||||||
|
i++, entry = entry->next)
|
||||||
|
if (entry->hotkey == c)
|
||||||
|
{
|
||||||
|
menu_fini ();
|
||||||
|
*auto_boot = 0;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,9 +112,9 @@ typedef size_t yy_size_t;
|
||||||
%option extra-type="struct grub_parser_param*"
|
%option extra-type="struct grub_parser_param*"
|
||||||
|
|
||||||
BLANK [ \t]
|
BLANK [ \t]
|
||||||
COMMENT ^[ \t]*#.*$
|
COMMENT #.*$
|
||||||
|
|
||||||
CHAR [^|&$;<> \t\n\'\"\\]
|
CHAR [^{}|&$;<> \t\n\'\"\\]
|
||||||
DIGITS [[:digit:]]+
|
DIGITS [[:digit:]]+
|
||||||
NAME [[:alpha:]_][[:alnum:][:digit:]_]*
|
NAME [[:alpha:]_][[:alnum:][:digit:]_]*
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/extcmd.h>
|
#include <grub/extcmd.h>
|
||||||
#include <grub/bitmap_scale.h>
|
#include <grub/bitmap_scale.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
#define DEFAULT_VIDEO_MODE "auto"
|
#define DEFAULT_VIDEO_MODE "auto"
|
||||||
#define DEFAULT_BORDER_WIDTH 10
|
#define DEFAULT_BORDER_WIDTH 10
|
||||||
|
@ -1187,8 +1188,8 @@ GRUB_MOD_INIT(gfxterm)
|
||||||
grub_register_extcmd ("background_image",
|
grub_register_extcmd ("background_image",
|
||||||
grub_gfxterm_background_image_cmd,
|
grub_gfxterm_background_image_cmd,
|
||||||
GRUB_COMMAND_FLAG_BOTH,
|
GRUB_COMMAND_FLAG_BOTH,
|
||||||
"[-m (stretch|normal)] FILE",
|
N_("[-m (stretch|normal)] FILE"),
|
||||||
"Load background image for active terminal.",
|
N_("Load background image for active terminal."),
|
||||||
background_image_cmd_options);
|
background_image_cmd_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,513 +0,0 @@
|
||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: Deprecated and broken. Needs to be converted to Video Driver!
|
|
||||||
|
|
||||||
#include <grub/machine/vga.h>
|
|
||||||
#include <grub/machine/console.h>
|
|
||||||
#include <grub/cpu/io.h>
|
|
||||||
#include <grub/term.h>
|
|
||||||
#include <grub/types.h>
|
|
||||||
#include <grub/dl.h>
|
|
||||||
#include <grub/misc.h>
|
|
||||||
#include <grub/font.h>
|
|
||||||
|
|
||||||
#define DEBUG_VGA 0
|
|
||||||
|
|
||||||
#define VGA_WIDTH 640
|
|
||||||
#define VGA_HEIGHT 350
|
|
||||||
#define CHAR_WIDTH 8
|
|
||||||
#define CHAR_HEIGHT 16
|
|
||||||
#define TEXT_WIDTH (VGA_WIDTH / CHAR_WIDTH)
|
|
||||||
#define TEXT_HEIGHT (VGA_HEIGHT / CHAR_HEIGHT)
|
|
||||||
#define VGA_MEM ((grub_uint8_t *) GRUB_MEMORY_MACHINE_VGA_ADDR)
|
|
||||||
#define PAGE_OFFSET(x) ((x) * (VGA_WIDTH * VGA_HEIGHT / 8))
|
|
||||||
|
|
||||||
#define DEFAULT_FG_COLOR 0xa
|
|
||||||
#define DEFAULT_BG_COLOR 0x0
|
|
||||||
|
|
||||||
struct colored_char
|
|
||||||
{
|
|
||||||
/* An Unicode codepoint. */
|
|
||||||
grub_uint32_t code;
|
|
||||||
|
|
||||||
/* Color indexes. */
|
|
||||||
unsigned char fg_color;
|
|
||||||
unsigned char bg_color;
|
|
||||||
|
|
||||||
/* The width of this character minus one. */
|
|
||||||
unsigned char width;
|
|
||||||
|
|
||||||
/* The column index of this character. */
|
|
||||||
unsigned char index;
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned char text_mode;
|
|
||||||
static unsigned xpos, ypos;
|
|
||||||
static int cursor_state;
|
|
||||||
static unsigned char fg_color, bg_color;
|
|
||||||
static struct colored_char text_buf[TEXT_WIDTH * TEXT_HEIGHT];
|
|
||||||
static unsigned char saved_map_mask;
|
|
||||||
static int page = 0;
|
|
||||||
static grub_font_t font = 0;
|
|
||||||
|
|
||||||
#define SEQUENCER_ADDR_PORT 0x3C4
|
|
||||||
#define SEQUENCER_DATA_PORT 0x3C5
|
|
||||||
#define MAP_MASK_REGISTER 0x02
|
|
||||||
|
|
||||||
#define CRTC_ADDR_PORT 0x3D4
|
|
||||||
#define CRTC_DATA_PORT 0x3D5
|
|
||||||
#define START_ADDR_HIGH_REGISTER 0x0C
|
|
||||||
#define START_ADDR_LOW_REGISTER 0x0D
|
|
||||||
|
|
||||||
#define GRAPHICS_ADDR_PORT 0x3CE
|
|
||||||
#define GRAPHICS_DATA_PORT 0x3CF
|
|
||||||
#define READ_MAP_REGISTER 0x04
|
|
||||||
|
|
||||||
#define INPUT_STATUS1_REGISTER 0x3DA
|
|
||||||
#define INPUT_STATUS1_VERTR_BIT 0x08
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
wait_vretrace (void)
|
|
||||||
{
|
|
||||||
/* Wait until there is a vertical retrace. */
|
|
||||||
while (! (grub_inb (INPUT_STATUS1_REGISTER) & INPUT_STATUS1_VERTR_BIT));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get Map Mask Register. */
|
|
||||||
static unsigned char
|
|
||||||
get_map_mask (void)
|
|
||||||
{
|
|
||||||
unsigned char old_addr;
|
|
||||||
unsigned char old_data;
|
|
||||||
|
|
||||||
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
|
||||||
grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
|
|
||||||
|
|
||||||
old_data = grub_inb (SEQUENCER_DATA_PORT);
|
|
||||||
|
|
||||||
grub_outb (old_addr, SEQUENCER_ADDR_PORT);
|
|
||||||
|
|
||||||
return old_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set Map Mask Register. */
|
|
||||||
static void
|
|
||||||
set_map_mask (unsigned char mask)
|
|
||||||
{
|
|
||||||
unsigned char old_addr;
|
|
||||||
|
|
||||||
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
|
||||||
grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
|
|
||||||
|
|
||||||
grub_outb (mask, SEQUENCER_DATA_PORT);
|
|
||||||
|
|
||||||
grub_outb (old_addr, SEQUENCER_ADDR_PORT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set Read Map Register. */
|
|
||||||
static void
|
|
||||||
set_read_map (unsigned char map)
|
|
||||||
{
|
|
||||||
unsigned char old_addr;
|
|
||||||
|
|
||||||
old_addr = grub_inb (GRAPHICS_ADDR_PORT);
|
|
||||||
|
|
||||||
grub_outb (READ_MAP_REGISTER, GRAPHICS_ADDR_PORT);
|
|
||||||
grub_outb (map, GRAPHICS_DATA_PORT);
|
|
||||||
|
|
||||||
grub_outb (old_addr, GRAPHICS_ADDR_PORT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set start address. */
|
|
||||||
static void
|
|
||||||
set_start_address (unsigned int start)
|
|
||||||
{
|
|
||||||
unsigned char old_addr;
|
|
||||||
|
|
||||||
old_addr = grub_inb (CRTC_ADDR_PORT);
|
|
||||||
|
|
||||||
grub_outb (START_ADDR_LOW_REGISTER, CRTC_ADDR_PORT);
|
|
||||||
grub_outb (start & 0xFF, CRTC_DATA_PORT);
|
|
||||||
|
|
||||||
grub_outb (START_ADDR_HIGH_REGISTER, CRTC_ADDR_PORT);
|
|
||||||
grub_outb (start >> 8, CRTC_DATA_PORT);
|
|
||||||
|
|
||||||
grub_outb (old_addr, CRTC_ADDR_PORT);
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_vga_mod_init (void)
|
|
||||||
{
|
|
||||||
text_mode = grub_vga_set_mode (0x10);
|
|
||||||
cursor_state = 1;
|
|
||||||
fg_color = DEFAULT_FG_COLOR;
|
|
||||||
bg_color = DEFAULT_BG_COLOR;
|
|
||||||
saved_map_mask = get_map_mask ();
|
|
||||||
set_map_mask (0x0f);
|
|
||||||
set_start_address (PAGE_OFFSET (page));
|
|
||||||
font = grub_font_get (""); /* Choose any font, for now. */
|
|
||||||
if (!font)
|
|
||||||
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_err_t
|
|
||||||
grub_vga_mod_fini (void)
|
|
||||||
{
|
|
||||||
set_map_mask (saved_map_mask);
|
|
||||||
grub_vga_set_mode (text_mode);
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
check_vga_mem (void *p)
|
|
||||||
{
|
|
||||||
return (p >= (void *) (VGA_MEM + PAGE_OFFSET (page))
|
|
||||||
&& p <= (void *) (VGA_MEM + PAGE_OFFSET (page)
|
|
||||||
+ VGA_WIDTH * VGA_HEIGHT / 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
write_char (void)
|
|
||||||
{
|
|
||||||
struct colored_char *p = text_buf + xpos + ypos * TEXT_WIDTH;
|
|
||||||
struct grub_font_glyph *glyph;
|
|
||||||
unsigned char *mem_base;
|
|
||||||
unsigned plane;
|
|
||||||
|
|
||||||
mem_base = (VGA_MEM + xpos +
|
|
||||||
ypos * CHAR_HEIGHT * TEXT_WIDTH + PAGE_OFFSET (page)) - p->index;
|
|
||||||
p -= p->index;
|
|
||||||
|
|
||||||
/* Get glyph for character. */
|
|
||||||
glyph = grub_font_get_glyph (font, p->code);
|
|
||||||
|
|
||||||
for (plane = 0x01; plane <= 0x08; plane <<= 1)
|
|
||||||
{
|
|
||||||
unsigned y;
|
|
||||||
unsigned offset;
|
|
||||||
unsigned char *mem;
|
|
||||||
|
|
||||||
set_map_mask (plane);
|
|
||||||
|
|
||||||
for (y = 0, offset = 0, mem = mem_base;
|
|
||||||
y < CHAR_HEIGHT;
|
|
||||||
y++, mem += TEXT_WIDTH)
|
|
||||||
{
|
|
||||||
/* TODO Re-implement glyph drawing for vga module. */
|
|
||||||
#if 0
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
unsigned char_width = 1; /* TODO Figure out wide characters. */
|
|
||||||
for (i = 0; i < char_width && offset < 32; i++)
|
|
||||||
{
|
|
||||||
unsigned char fg_mask, bg_mask;
|
|
||||||
|
|
||||||
fg_mask = (p->fg_color & plane) ? glyph->bitmap[offset] : 0;
|
|
||||||
bg_mask = (p->bg_color & plane) ? ~(glyph->bitmap[offset]) : 0;
|
|
||||||
offset++;
|
|
||||||
|
|
||||||
if (check_vga_mem (mem + i))
|
|
||||||
mem[i] = (fg_mask | bg_mask);
|
|
||||||
}
|
|
||||||
#endif /* 0 */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set_map_mask (0x0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
write_cursor (void)
|
|
||||||
{
|
|
||||||
unsigned char *mem = (VGA_MEM + PAGE_OFFSET (page) + xpos
|
|
||||||
+ (ypos * CHAR_HEIGHT + CHAR_HEIGHT - 3) * TEXT_WIDTH);
|
|
||||||
if (check_vga_mem (mem))
|
|
||||||
*mem = 0xff;
|
|
||||||
|
|
||||||
mem += TEXT_WIDTH;
|
|
||||||
if (check_vga_mem (mem))
|
|
||||||
*mem = 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
scroll_up (void)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
unsigned plane;
|
|
||||||
|
|
||||||
/* Do all the work in the other page. */
|
|
||||||
grub_memmove (text_buf, text_buf + TEXT_WIDTH,
|
|
||||||
sizeof (struct colored_char) * TEXT_WIDTH * (TEXT_HEIGHT - 1));
|
|
||||||
|
|
||||||
for (i = TEXT_WIDTH * (TEXT_HEIGHT - 1); i < TEXT_WIDTH * TEXT_HEIGHT; i++)
|
|
||||||
{
|
|
||||||
text_buf[i].code = ' ';
|
|
||||||
text_buf[i].fg_color = 0;
|
|
||||||
text_buf[i].bg_color = 0;
|
|
||||||
text_buf[i].width = 0;
|
|
||||||
text_buf[i].index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (plane = 1; plane <= 4; plane++)
|
|
||||||
{
|
|
||||||
set_read_map (plane);
|
|
||||||
set_map_mask (1 << plane);
|
|
||||||
grub_memmove (VGA_MEM + PAGE_OFFSET (1 - page), VGA_MEM
|
|
||||||
+ PAGE_OFFSET (page) + VGA_WIDTH * CHAR_HEIGHT / 8,
|
|
||||||
VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
set_map_mask (0x0f);
|
|
||||||
grub_memset (VGA_MEM + PAGE_OFFSET (1 - page)
|
|
||||||
+ VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8, 0,
|
|
||||||
VGA_WIDTH * CHAR_HEIGHT / 8);
|
|
||||||
|
|
||||||
/* Activate the other page. */
|
|
||||||
page = 1 - page;
|
|
||||||
wait_vretrace ();
|
|
||||||
set_start_address (PAGE_OFFSET (page));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
grub_vga_putchar (grub_uint32_t c)
|
|
||||||
{
|
|
||||||
#if DEBUG_VGA
|
|
||||||
static int show = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (c == '\a')
|
|
||||||
/* FIXME */
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (c == '\b' || c == '\n' || c == '\r')
|
|
||||||
{
|
|
||||||
/* Erase current cursor, if any. */
|
|
||||||
if (cursor_state)
|
|
||||||
write_char ();
|
|
||||||
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case '\b':
|
|
||||||
if (xpos > 0)
|
|
||||||
xpos--;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '\n':
|
|
||||||
if (ypos >= TEXT_HEIGHT - 1)
|
|
||||||
scroll_up ();
|
|
||||||
else
|
|
||||||
ypos++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '\r':
|
|
||||||
xpos = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cursor_state)
|
|
||||||
write_cursor ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct grub_font_glyph *glyph;
|
|
||||||
struct colored_char *p;
|
|
||||||
unsigned char_width = 1;
|
|
||||||
|
|
||||||
glyph = grub_font_get_glyph(font, c);
|
|
||||||
|
|
||||||
if (xpos + char_width > TEXT_WIDTH)
|
|
||||||
grub_putchar ('\n');
|
|
||||||
|
|
||||||
p = text_buf + xpos + ypos * TEXT_WIDTH;
|
|
||||||
p->code = c;
|
|
||||||
p->fg_color = fg_color;
|
|
||||||
p->bg_color = bg_color;
|
|
||||||
p->width = char_width - 1;
|
|
||||||
p->index = 0;
|
|
||||||
|
|
||||||
if (char_width > 1)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
for (i = 1; i < char_width; i++)
|
|
||||||
{
|
|
||||||
p[i].code = ' ';
|
|
||||||
p[i].width = char_width - 1;
|
|
||||||
p[i].index = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
write_char ();
|
|
||||||
|
|
||||||
xpos += char_width;
|
|
||||||
if (xpos >= TEXT_WIDTH)
|
|
||||||
{
|
|
||||||
xpos = 0;
|
|
||||||
|
|
||||||
if (ypos >= TEXT_HEIGHT - 1)
|
|
||||||
scroll_up ();
|
|
||||||
else
|
|
||||||
ypos++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cursor_state)
|
|
||||||
write_cursor ();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DEBUG_VGA
|
|
||||||
if (show)
|
|
||||||
{
|
|
||||||
grub_uint16_t pos = grub_getxy ();
|
|
||||||
|
|
||||||
show = 0;
|
|
||||||
grub_gotoxy (0, 0);
|
|
||||||
grub_printf ("[%u:%u]", (unsigned) (pos >> 8), (unsigned) (pos & 0xff));
|
|
||||||
grub_gotoxy (pos >> 8, pos & 0xff);
|
|
||||||
show = 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_ssize_t
|
|
||||||
grub_vga_getcharwidth (grub_uint32_t c)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
struct grub_font_glyph glyph;
|
|
||||||
|
|
||||||
glyph = grub_font_get_glyph (c);
|
|
||||||
|
|
||||||
return glyph.char_width;
|
|
||||||
#else
|
|
||||||
(void) c; /* Prevent warning. */
|
|
||||||
return 1; /* TODO Fix wide characters? */
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_uint16_t
|
|
||||||
grub_vga_getwh (void)
|
|
||||||
{
|
|
||||||
return (TEXT_WIDTH << 8) | TEXT_HEIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
static grub_uint16_t
|
|
||||||
grub_vga_getxy (void)
|
|
||||||
{
|
|
||||||
return ((xpos << 8) | ypos);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
grub_vga_gotoxy (grub_uint8_t x, grub_uint8_t y)
|
|
||||||
{
|
|
||||||
if (x >= TEXT_WIDTH || y >= TEXT_HEIGHT)
|
|
||||||
{
|
|
||||||
grub_error (GRUB_ERR_OUT_OF_RANGE, "invalid point (%u,%u)",
|
|
||||||
(unsigned) x, (unsigned) y);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cursor_state)
|
|
||||||
write_char ();
|
|
||||||
|
|
||||||
xpos = x;
|
|
||||||
ypos = y;
|
|
||||||
|
|
||||||
if (cursor_state)
|
|
||||||
write_cursor ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
grub_vga_cls (void)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
wait_vretrace ();
|
|
||||||
for (i = 0; i < TEXT_WIDTH * TEXT_HEIGHT; i++)
|
|
||||||
{
|
|
||||||
text_buf[i].code = ' ';
|
|
||||||
text_buf[i].fg_color = 0;
|
|
||||||
text_buf[i].bg_color = 0;
|
|
||||||
text_buf[i].width = 0;
|
|
||||||
text_buf[i].index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_memset (VGA_MEM + PAGE_OFFSET (page), 0, VGA_WIDTH * VGA_HEIGHT / 8);
|
|
||||||
|
|
||||||
xpos = ypos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
grub_vga_setcolorstate (grub_term_color_state state)
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case GRUB_TERM_COLOR_STANDARD:
|
|
||||||
case GRUB_TERM_COLOR_NORMAL:
|
|
||||||
fg_color = DEFAULT_FG_COLOR;
|
|
||||||
bg_color = DEFAULT_BG_COLOR;
|
|
||||||
break;
|
|
||||||
case GRUB_TERM_COLOR_HIGHLIGHT:
|
|
||||||
fg_color = DEFAULT_BG_COLOR;
|
|
||||||
bg_color = DEFAULT_FG_COLOR;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
grub_vga_setcursor (int on)
|
|
||||||
{
|
|
||||||
if (cursor_state != on)
|
|
||||||
{
|
|
||||||
if (cursor_state)
|
|
||||||
write_char ();
|
|
||||||
else
|
|
||||||
write_cursor ();
|
|
||||||
|
|
||||||
cursor_state = on;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct grub_term_output grub_vga_term =
|
|
||||||
{
|
|
||||||
.name = "vga",
|
|
||||||
.init = grub_vga_mod_init,
|
|
||||||
.fini = grub_vga_mod_fini,
|
|
||||||
.putchar = grub_vga_putchar,
|
|
||||||
.getcharwidth = grub_vga_getcharwidth,
|
|
||||||
.getwh = grub_vga_getwh,
|
|
||||||
.getxy = grub_vga_getxy,
|
|
||||||
.gotoxy = grub_vga_gotoxy,
|
|
||||||
.cls = grub_vga_cls,
|
|
||||||
.setcolorstate = grub_vga_setcolorstate,
|
|
||||||
.setcursor = grub_vga_setcursor,
|
|
||||||
.flags = 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
GRUB_MOD_INIT(vga)
|
|
||||||
{
|
|
||||||
grub_term_register_output ("vga", &grub_vga_term);
|
|
||||||
}
|
|
||||||
|
|
||||||
GRUB_MOD_FINI(vga)
|
|
||||||
{
|
|
||||||
grub_term_unregister_output (&grub_vga_term);
|
|
||||||
}
|
|
|
@ -194,14 +194,15 @@ grub_ofconsole_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_col
|
||||||
*highlight_color = grub_ofconsole_highlight_color;
|
*highlight_color = grub_ofconsole_highlight_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ANSI_C0 0x9b
|
||||||
|
|
||||||
static int
|
static int
|
||||||
grub_ofconsole_readkey (int *key)
|
grub_ofconsole_readkey (int *key)
|
||||||
{
|
{
|
||||||
char c;
|
grub_uint8_t c;
|
||||||
grub_ssize_t actual = 0;
|
grub_ssize_t actual = 0;
|
||||||
|
|
||||||
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||||
|
|
||||||
if (actual > 0)
|
if (actual > 0)
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
|
@ -209,25 +210,30 @@ grub_ofconsole_readkey (int *key)
|
||||||
/* Backspace: Ctrl-h. */
|
/* Backspace: Ctrl-h. */
|
||||||
c = '\b';
|
c = '\b';
|
||||||
break;
|
break;
|
||||||
|
case ANSI_C0:
|
||||||
case '\e':
|
case '\e':
|
||||||
{
|
{
|
||||||
grub_uint64_t start;
|
grub_uint64_t start;
|
||||||
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
|
||||||
|
|
||||||
/* On 9600 we have to wait up to 12 milliseconds. */
|
if (c == '\e')
|
||||||
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';
|
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||||
return 1;
|
|
||||||
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != '[')
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
|
||||||
|
|
||||||
/* On 9600 we have to wait up to 12 milliseconds. */
|
/* On 9600 we have to wait up to 12 milliseconds. */
|
||||||
|
@ -321,7 +327,7 @@ grub_ofconsole_getkey (void)
|
||||||
static grub_uint16_t
|
static grub_uint16_t
|
||||||
grub_ofconsole_getxy (void)
|
grub_ofconsole_getxy (void)
|
||||||
{
|
{
|
||||||
return ((grub_curr_x - 1) << 8) | grub_curr_y;
|
return (grub_curr_x << 8) | grub_curr_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -616,8 +616,8 @@ GRUB_MOD_INIT(serial)
|
||||||
{
|
{
|
||||||
cmd = grub_register_extcmd ("serial", grub_cmd_serial,
|
cmd = grub_register_extcmd ("serial", grub_cmd_serial,
|
||||||
GRUB_COMMAND_FLAG_BOTH,
|
GRUB_COMMAND_FLAG_BOTH,
|
||||||
"serial [OPTIONS...]",
|
N_("[OPTIONS...]"),
|
||||||
"Configure serial port.", options);
|
N_("Configure serial port."), options);
|
||||||
|
|
||||||
/* Set default settings. */
|
/* Set default settings. */
|
||||||
serial_settings.port = serial_hw_get_port (0);
|
serial_settings.port = serial_hw_get_port (0);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <grub/terminfo.h>
|
#include <grub/terminfo.h>
|
||||||
#include <grub/tparm.h>
|
#include <grub/tparm.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
struct terminfo
|
struct terminfo
|
||||||
{
|
{
|
||||||
|
@ -178,7 +179,7 @@ static grub_command_t cmd;
|
||||||
GRUB_MOD_INIT(terminfo)
|
GRUB_MOD_INIT(terminfo)
|
||||||
{
|
{
|
||||||
cmd = grub_register_command ("terminfo", grub_cmd_terminfo,
|
cmd = grub_register_command ("terminfo", grub_cmd_terminfo,
|
||||||
"[TERM]", "Set terminfo type.");
|
N_("[TERM]"), N_("Set terminfo type."));
|
||||||
grub_terminfo_set_current ("vt100");
|
grub_terminfo_set_current ("vt100");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
28
tests/grub_script_comments.in
Normal file
28
tests/grub_script_comments.in
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#! @builddir@/grub-shell-tester
|
||||||
|
#
|
||||||
|
# Copyright (C) 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/>.
|
||||||
|
|
||||||
|
echo a###b
|
||||||
|
echo a# #b
|
||||||
|
|
||||||
|
echo #
|
||||||
|
echo \#
|
||||||
|
|
||||||
|
echo '#'
|
||||||
|
echo "#"
|
||||||
|
|
||||||
|
echo '\#'
|
||||||
|
echo "\#"
|
|
@ -1,5 +1,5 @@
|
||||||
# Helper library for grub-mkconfig
|
# Helper library for grub-mkconfig
|
||||||
# Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
|
# Copyright (C) 2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# GRUB is free software: you can redistribute it and/or modify
|
# GRUB is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -44,21 +44,7 @@ grub_warn ()
|
||||||
|
|
||||||
make_system_path_relative_to_its_root ()
|
make_system_path_relative_to_its_root ()
|
||||||
{
|
{
|
||||||
path="`${grub_mkrelpath} $1`"
|
${grub_mkrelpath} $1
|
||||||
|
|
||||||
case "`uname 2>/dev/null`" in
|
|
||||||
CYGWIN*)
|
|
||||||
# Cygwin: Check if regular or emulated mount.
|
|
||||||
if [ -z "$dir" ] || [ "`stat -c %D "$dir/.."`" != 620000 ] ; then
|
|
||||||
# Reached some mount point not below /cygdrive.
|
|
||||||
# GRUB does not know Cygwin's emulated mounts,
|
|
||||||
# convert to Win32 path and remove drive letter.
|
|
||||||
path=`cygpath -m "$path" | sed -n 's,^[A-Za-z]:,,p'`
|
|
||||||
test ! -z "$path" || return 1
|
|
||||||
fi ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "$path"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_path_readable_by_grub ()
|
is_path_readable_by_grub ()
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/util/misc.h>
|
||||||
|
#include <grub/emu/misc.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
@ -97,7 +99,7 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
argument = argv[optind];
|
argument = argv[optind];
|
||||||
|
|
||||||
relpath = make_system_path_relative_to_its_root (argument);
|
relpath = grub_make_system_path_relative_to_its_root (argument);
|
||||||
printf ("%s\n", relpath);
|
printf ("%s\n", relpath);
|
||||||
free (relpath);
|
free (relpath);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ target_cpu=@target_cpu@
|
||||||
native_platform=@platform@
|
native_platform=@platform@
|
||||||
pkglib_DATA="@pkglib_DATA@"
|
pkglib_DATA="@pkglib_DATA@"
|
||||||
|
|
||||||
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot
|
multiboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-multiboot
|
||||||
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc
|
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc
|
||||||
efi32_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi
|
efi32_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi
|
||||||
efi64_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi
|
efi64_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi
|
||||||
|
@ -124,8 +124,8 @@ process_input_dir ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "${override_dir}" = "" ] ; then
|
if [ "${override_dir}" = "" ] ; then
|
||||||
if test -e "${coreboot_dir}" ; then
|
if test -e "${multiboot_dir}" ; then
|
||||||
process_input_dir ${coreboot_dir} coreboot
|
process_input_dir ${multiboot_dir} multiboot
|
||||||
fi
|
fi
|
||||||
if test -e "${pc_dir}" ; then
|
if test -e "${pc_dir}" ; then
|
||||||
process_input_dir ${pc_dir} pc
|
process_input_dir ${pc_dir} pc
|
||||||
|
@ -138,13 +138,13 @@ if [ "${override_dir}" = "" ] ; then
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
process_input_dir ${override_dir} ${native_platform}
|
process_input_dir ${override_dir} ${native_platform}
|
||||||
coreboot_dir=
|
multiboot_dir=
|
||||||
pc_dir=
|
pc_dir=
|
||||||
efi32_dir=
|
efi32_dir=
|
||||||
efi64_dir=
|
efi64_dir=
|
||||||
case "${target_cpu}-${native_platform}" in
|
case "${target_cpu}-${native_platform}" in
|
||||||
i386-coreboot) coreboot_dir=${override_dir} ;;
|
|
||||||
i386-pc) pc_dir=${override_dir} ;;
|
i386-pc) pc_dir=${override_dir} ;;
|
||||||
|
i386-multiboot) multiboot_dir=${override_dir} ;;
|
||||||
i386-efi) efi32_dir=${override_dir} ;;
|
i386-efi) efi32_dir=${override_dir} ;;
|
||||||
x86_64-efi) efi64_dir=${override_dir} ;;
|
x86_64-efi) efi64_dir=${override_dir} ;;
|
||||||
esac
|
esac
|
||||||
|
@ -154,28 +154,28 @@ fi
|
||||||
iso_uuid=$(date -u +%Y-%m-%d-%H-%M-%S-00)
|
iso_uuid=$(date -u +%Y-%m-%d-%H-%M-%S-00)
|
||||||
grub_mkisofs_arguments="${grub_mkisofs_arguments} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
|
grub_mkisofs_arguments="${grub_mkisofs_arguments} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)"
|
||||||
|
|
||||||
# build coreboot core.img
|
# build coreboot multiboot.img
|
||||||
if test -e "${coreboot_dir}" ; then
|
if test -e "${multiboot_dir}" ; then
|
||||||
echo "Enabling coreboot support ..."
|
echo "Enabling multiboot support ..."
|
||||||
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
|
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
|
||||||
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
|
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
|
||||||
mkdir -p ${memdisk_dir}/boot/grub
|
mkdir -p ${memdisk_dir}/boot/grub
|
||||||
|
|
||||||
modules="$(cat ${coreboot_dir}/partmap.lst) ${modules}"
|
modules="$(cat ${multiboot_dir}/partmap.lst) ${modules}"
|
||||||
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
|
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
|
||||||
search --fs-uuid --set ${iso_uuid}
|
search --fs-uuid --set ${iso_uuid}
|
||||||
set prefix=(\${root})/boot/grub/${target_cpu}-coreboot
|
set prefix=(\${root})/boot/grub/${target_cpu}-multiboot
|
||||||
source \$prefix/grub.cfg
|
source \$prefix/grub.cfg
|
||||||
EOF
|
EOF
|
||||||
(for i in ${modules} ; do
|
(for i in ${modules} ; do
|
||||||
echo "insmod $i"
|
echo "insmod $i"
|
||||||
done ; \
|
done ; \
|
||||||
echo "source /boot/grub/grub.cfg") \
|
echo "source /boot/grub/grub.cfg") \
|
||||||
> ${iso9660_dir}/boot/grub/i386-coreboot/grub.cfg
|
> ${iso9660_dir}/boot/grub/i386-multiboot/grub.cfg
|
||||||
|
|
||||||
tar -C ${memdisk_dir} -cf ${memdisk_img} boot
|
tar -C ${memdisk_dir} -cf ${memdisk_img} boot
|
||||||
rm -rf ${memdisk_dir}
|
rm -rf ${memdisk_dir}
|
||||||
grub-mkimage -O i386-coreboot -d ${coreboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
|
grub-mkimage -O i386-coreboot -d ${multiboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
|
||||||
memdisk tar search iso9660 configfile sh \
|
memdisk tar search iso9660 configfile sh \
|
||||||
ata at_keyboard
|
ata at_keyboard
|
||||||
rm -f ${memdisk_img}
|
rm -f ${memdisk_img}
|
||||||
|
|
|
@ -20,14 +20,15 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/util/misc.h>
|
#include <grub/util/misc.h>
|
||||||
|
#include <grub/util/misc.h>
|
||||||
#include <grub/device.h>
|
#include <grub/device.h>
|
||||||
#include <grub/disk.h>
|
#include <grub/disk.h>
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
#include <grub/fs.h>
|
#include <grub/fs.h>
|
||||||
#include <grub/partition.h>
|
#include <grub/partition.h>
|
||||||
#include <grub/msdos_partition.h>
|
#include <grub/msdos_partition.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/emu/hostdisk.h>
|
||||||
#include <grub/util/getroot.h>
|
#include <grub/emu/getroot.h>
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/raid.h>
|
#include <grub/raid.h>
|
||||||
|
@ -261,7 +262,7 @@ probe (const char *path, char *device_name)
|
||||||
grub_util_info ("reading %s via OS facilities", path);
|
grub_util_info ("reading %s via OS facilities", path);
|
||||||
filebuf_via_sys = grub_util_read_image (path);
|
filebuf_via_sys = grub_util_read_image (path);
|
||||||
|
|
||||||
rel_path = make_system_path_relative_to_its_root (path);
|
rel_path = grub_make_system_path_relative_to_its_root (path);
|
||||||
grub_path = xasprintf ("(%s)%s", drive_name, rel_path);
|
grub_path = xasprintf ("(%s)%s", drive_name, rel_path);
|
||||||
free (rel_path);
|
free (rel_path);
|
||||||
grub_util_info ("reading %s via GRUB facilities", grub_path);
|
grub_util_info ("reading %s via GRUB facilities", grub_path);
|
||||||
|
|
|
@ -28,14 +28,14 @@
|
||||||
#include <grub/msdos_partition.h>
|
#include <grub/msdos_partition.h>
|
||||||
#include <grub/gpt_partition.h>
|
#include <grub/gpt_partition.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/emu/hostdisk.h>
|
||||||
#include <grub/machine/boot.h>
|
#include <grub/machine/boot.h>
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
#include <grub/util/raid.h>
|
#include <grub/util/raid.h>
|
||||||
#include <grub/util/lvm.h>
|
#include <grub/util/lvm.h>
|
||||||
#include <grub/util/getroot.h>
|
#include <grub/emu/getroot.h>
|
||||||
|
|
||||||
static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
|
static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ unable_to_embed:
|
||||||
/* Make sure that GRUB reads the identical image as the OS. */
|
/* Make sure that GRUB reads the identical image as the OS. */
|
||||||
tmp_img = xmalloc (core_size);
|
tmp_img = xmalloc (core_size);
|
||||||
core_path_dev_full = grub_util_get_path (dir, core_file);
|
core_path_dev_full = grub_util_get_path (dir, core_file);
|
||||||
core_path_dev = make_system_path_relative_to_its_root (core_path_dev_full);
|
core_path_dev = grub_make_system_path_relative_to_its_root (core_path_dev_full);
|
||||||
free (core_path_dev_full);
|
free (core_path_dev_full);
|
||||||
|
|
||||||
/* It is a Good Thing to sync two times. */
|
/* It is a Good Thing to sync two times. */
|
||||||
|
|
268
util/misc.c
268
util/misc.c
|
@ -58,53 +58,6 @@
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int verbosity = 0;
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_util_warn (const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
fprintf (stderr, _("%s: warn:"), program_name);
|
|
||||||
fprintf (stderr, " ");
|
|
||||||
va_start (ap, fmt);
|
|
||||||
vfprintf (stderr, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
fprintf (stderr, ".\n");
|
|
||||||
fflush (stderr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_util_info (const char *fmt, ...)
|
|
||||||
{
|
|
||||||
if (verbosity > 0)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
fprintf (stderr, _("%s: info:"), program_name);
|
|
||||||
fprintf (stderr, " ");
|
|
||||||
va_start (ap, fmt);
|
|
||||||
vfprintf (stderr, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
fprintf (stderr, ".\n");
|
|
||||||
fflush (stderr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_util_error (const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
fprintf (stderr, _("%s: error:"), program_name);
|
|
||||||
fprintf (stderr, " ");
|
|
||||||
va_start (ap, fmt);
|
|
||||||
vfprintf (stderr, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
fprintf (stderr, ".\n");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef GRUB_UTIL
|
#ifdef GRUB_UTIL
|
||||||
int
|
int
|
||||||
grub_err_printf (const char *fmt, ...)
|
grub_err_printf (const char *fmt, ...)
|
||||||
|
@ -120,41 +73,6 @@ grub_err_printf (const char *fmt, ...)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *
|
|
||||||
xmalloc (size_t size)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
p = malloc (size);
|
|
||||||
if (! p)
|
|
||||||
grub_util_error ("out of memory");
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
xrealloc (void *ptr, size_t size)
|
|
||||||
{
|
|
||||||
ptr = realloc (ptr, size);
|
|
||||||
if (! ptr)
|
|
||||||
grub_util_error ("out of memory");
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
xstrdup (const char *str)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
char *newstr;
|
|
||||||
|
|
||||||
len = strlen (str);
|
|
||||||
newstr = (char *) xmalloc (len + 1);
|
|
||||||
memcpy (newstr, str, len + 1);
|
|
||||||
|
|
||||||
return newstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
grub_util_get_path (const char *dir, const char *file)
|
grub_util_get_path (const char *dir, const char *file)
|
||||||
{
|
{
|
||||||
|
@ -277,34 +195,6 @@ grub_register_exported_symbols (void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
|
||||||
grub_exit (void)
|
|
||||||
{
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_uint32_t
|
|
||||||
grub_get_rtc (void)
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
gettimeofday (&tv, 0);
|
|
||||||
|
|
||||||
return (tv.tv_sec * GRUB_TICKS_PER_SECOND
|
|
||||||
+ (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
|
|
||||||
* GRUB_TICKS_PER_SECOND / 1000000));
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_uint64_t
|
|
||||||
grub_get_time_ms (void)
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
gettimeofday (&tv, 0);
|
|
||||||
|
|
||||||
return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -335,53 +225,6 @@ grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_VASPRINTF
|
|
||||||
|
|
||||||
int
|
|
||||||
vasprintf (char **buf, const char *fmt, va_list ap)
|
|
||||||
{
|
|
||||||
/* Should be large enough. */
|
|
||||||
*buf = xmalloc (512);
|
|
||||||
|
|
||||||
return vsprintf (*buf, fmt, ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_ASPRINTF
|
|
||||||
|
|
||||||
int
|
|
||||||
asprintf (char **buf, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
int status;
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start (ap, fmt);
|
|
||||||
status = vasprintf (*buf, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *
|
|
||||||
xasprintf (const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
va_start (ap, fmt);
|
|
||||||
if (vasprintf (&result, fmt, ap) < 0)
|
|
||||||
{
|
|
||||||
if (errno == ENOMEM)
|
|
||||||
grub_util_error ("out of memory");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
void sync (void)
|
void sync (void)
|
||||||
|
@ -456,103 +299,6 @@ canonicalize_file_name (const char *path)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function never prints trailing slashes (so that its output
|
|
||||||
can be appended a slash unconditionally). */
|
|
||||||
char *
|
|
||||||
make_system_path_relative_to_its_root (const char *path)
|
|
||||||
{
|
|
||||||
struct stat st;
|
|
||||||
char *p, *buf, *buf2, *buf3;
|
|
||||||
uintptr_t offset = 0;
|
|
||||||
dev_t num;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
/* canonicalize. */
|
|
||||||
p = canonicalize_file_name (path);
|
|
||||||
|
|
||||||
if (p == NULL)
|
|
||||||
grub_util_error ("failed to get canonical path of %s", path);
|
|
||||||
|
|
||||||
len = strlen (p) + 1;
|
|
||||||
buf = xstrdup (p);
|
|
||||||
free (p);
|
|
||||||
|
|
||||||
if (stat (buf, &st) < 0)
|
|
||||||
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
|
||||||
|
|
||||||
buf2 = xstrdup (buf);
|
|
||||||
num = st.st_dev;
|
|
||||||
|
|
||||||
/* This loop sets offset to the number of chars of the root
|
|
||||||
directory we're inspecting. */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
p = strrchr (buf, '/');
|
|
||||||
if (p == NULL)
|
|
||||||
/* This should never happen. */
|
|
||||||
grub_util_error ("FIXME: no / in buf. (make_system_path_relative_to_its_root)");
|
|
||||||
if (p != buf)
|
|
||||||
*p = 0;
|
|
||||||
else
|
|
||||||
*++p = 0;
|
|
||||||
|
|
||||||
if (stat (buf, &st) < 0)
|
|
||||||
grub_util_error ("cannot stat %s: %s", buf, strerror (errno));
|
|
||||||
|
|
||||||
/* buf is another filesystem; we found it. */
|
|
||||||
if (st.st_dev != num)
|
|
||||||
{
|
|
||||||
/* offset == 0 means path given is the mount point.
|
|
||||||
This works around special-casing of "/" in Un*x. This function never
|
|
||||||
prints trailing slashes (so that its output can be appended a slash
|
|
||||||
unconditionally). Each slash in is considered a preceding slash, and
|
|
||||||
therefore the root directory is an empty string. */
|
|
||||||
if (offset == 0)
|
|
||||||
{
|
|
||||||
free (buf);
|
|
||||||
free (buf2);
|
|
||||||
return xstrdup ("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
offset = p - buf;
|
|
||||||
/* offset == 1 means root directory. */
|
|
||||||
if (offset == 1)
|
|
||||||
{
|
|
||||||
free (buf);
|
|
||||||
len = strlen (buf2);
|
|
||||||
while (buf2[len - 1] == '/' && len > 1)
|
|
||||||
{
|
|
||||||
buf2[len - 1] = '\0';
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
if (len > 1)
|
|
||||||
return buf2;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* This means path given is just a backslash. As above
|
|
||||||
we have to return an empty string. */
|
|
||||||
free (buf2);
|
|
||||||
return xstrdup ("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free (buf);
|
|
||||||
buf3 = xstrdup (buf2 + offset);
|
|
||||||
free (buf2);
|
|
||||||
|
|
||||||
len = strlen (buf3);
|
|
||||||
while (buf3[len - 1] == '/' && len > 1)
|
|
||||||
{
|
|
||||||
buf3[len - 1] = '\0';
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf3;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef GRUB_UTIL
|
#ifdef GRUB_UTIL
|
||||||
void
|
void
|
||||||
grub_util_init_nls (void)
|
grub_util_init_nls (void)
|
||||||
|
@ -564,3 +310,17 @@ grub_util_init_nls (void)
|
||||||
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
|
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_dl_ref (grub_dl_t mod)
|
||||||
|
{
|
||||||
|
(void) mod;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
grub_dl_unref (grub_dl_t mod)
|
||||||
|
{
|
||||||
|
(void) mod;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <grub/msdos_partition.h>
|
#include <grub/msdos_partition.h>
|
||||||
#include <grub/gpt_partition.h>
|
#include <grub/gpt_partition.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/util/hostdisk.h>
|
#include <grub/emu/hostdisk.h>
|
||||||
#include <grub/machine/boot.h>
|
#include <grub/machine/boot.h>
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
#include <grub/term.h>
|
#include <grub/term.h>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <grub/util/getroot.h>
|
#include <grub/emu/getroot.h>
|
||||||
|
|
||||||
#define _GNU_SOURCE 1
|
#define _GNU_SOURCE 1
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
@ -634,7 +634,8 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
find_dest_dev (&ginfo, argv);
|
find_dest_dev (&ginfo, argv);
|
||||||
|
|
||||||
ginfo.prefix = grub_get_prefix (ginfo.dir ? : DEFAULT_DIRECTORY);
|
ginfo.prefix = grub_make_system_path_relative_to_its_root (ginfo.dir ?
|
||||||
|
: DEFAULT_DIRECTORY);
|
||||||
|
|
||||||
check_root_dev (&ginfo);
|
check_root_dev (&ginfo);
|
||||||
|
|
||||||
|
|
412
video/i386/pc/vga.c
Normal file
412
video/i386/pc/vga.c
Normal file
|
@ -0,0 +1,412 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define grub_video_render_target grub_video_fbrender_target
|
||||||
|
|
||||||
|
#include <grub/machine/vga.h>
|
||||||
|
#include <grub/machine/console.h>
|
||||||
|
#include <grub/cpu/io.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
#include <grub/video.h>
|
||||||
|
#include <grub/video_fb.h>
|
||||||
|
#include <grub/types.h>
|
||||||
|
#include <grub/dl.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
|
||||||
|
#define VGA_WIDTH 640
|
||||||
|
#define VGA_HEIGHT 350
|
||||||
|
#define VGA_MEM ((grub_uint8_t *) GRUB_MEMORY_MACHINE_VGA_ADDR)
|
||||||
|
#define PAGE_OFFSET(x) ((x) * (VGA_WIDTH * VGA_HEIGHT / 8))
|
||||||
|
|
||||||
|
static unsigned char text_mode;
|
||||||
|
static unsigned char saved_map_mask;
|
||||||
|
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
struct grub_video_mode_info mode_info;
|
||||||
|
struct grub_video_render_target *render_target;
|
||||||
|
grub_uint8_t *temporary_buffer;
|
||||||
|
int front_page;
|
||||||
|
int back_page;
|
||||||
|
} framebuffer;
|
||||||
|
|
||||||
|
#define SEQUENCER_ADDR_PORT 0x3C4
|
||||||
|
#define SEQUENCER_DATA_PORT 0x3C5
|
||||||
|
#define MAP_MASK_REGISTER 0x02
|
||||||
|
|
||||||
|
#define CRTC_ADDR_PORT 0x3D4
|
||||||
|
#define CRTC_DATA_PORT 0x3D5
|
||||||
|
#define START_ADDR_HIGH_REGISTER 0x0C
|
||||||
|
#define START_ADDR_LOW_REGISTER 0x0D
|
||||||
|
|
||||||
|
#define GRAPHICS_ADDR_PORT 0x3CE
|
||||||
|
#define GRAPHICS_DATA_PORT 0x3CF
|
||||||
|
#define READ_MAP_REGISTER 0x04
|
||||||
|
|
||||||
|
#define INPUT_STATUS1_REGISTER 0x3DA
|
||||||
|
#define INPUT_STATUS1_VERTR_BIT 0x08
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
wait_vretrace (void)
|
||||||
|
{
|
||||||
|
/* Wait until there is a vertical retrace. */
|
||||||
|
while (! (grub_inb (INPUT_STATUS1_REGISTER) & INPUT_STATUS1_VERTR_BIT));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get Map Mask Register. */
|
||||||
|
static unsigned char
|
||||||
|
get_map_mask (void)
|
||||||
|
{
|
||||||
|
unsigned char old_addr;
|
||||||
|
unsigned char old_data;
|
||||||
|
|
||||||
|
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
||||||
|
grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
|
||||||
|
|
||||||
|
old_data = grub_inb (SEQUENCER_DATA_PORT);
|
||||||
|
|
||||||
|
grub_outb (old_addr, SEQUENCER_ADDR_PORT);
|
||||||
|
|
||||||
|
return old_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set Map Mask Register. */
|
||||||
|
static void
|
||||||
|
set_map_mask (unsigned char mask)
|
||||||
|
{
|
||||||
|
unsigned char old_addr;
|
||||||
|
|
||||||
|
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
||||||
|
grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
|
||||||
|
|
||||||
|
grub_outb (mask, SEQUENCER_DATA_PORT);
|
||||||
|
|
||||||
|
grub_outb (old_addr, SEQUENCER_ADDR_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Set Read Map Register. */
|
||||||
|
static void
|
||||||
|
set_read_map (unsigned char map)
|
||||||
|
{
|
||||||
|
unsigned char old_addr;
|
||||||
|
|
||||||
|
old_addr = grub_inb (GRAPHICS_ADDR_PORT);
|
||||||
|
|
||||||
|
grub_outb (READ_MAP_REGISTER, GRAPHICS_ADDR_PORT);
|
||||||
|
grub_outb (map, GRAPHICS_DATA_PORT);
|
||||||
|
|
||||||
|
grub_outb (old_addr, GRAPHICS_ADDR_PORT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Set start address. */
|
||||||
|
static void
|
||||||
|
set_start_address (unsigned int start)
|
||||||
|
{
|
||||||
|
unsigned char old_addr;
|
||||||
|
|
||||||
|
old_addr = grub_inb (CRTC_ADDR_PORT);
|
||||||
|
|
||||||
|
grub_outb (START_ADDR_LOW_REGISTER, CRTC_ADDR_PORT);
|
||||||
|
grub_outb (start & 0xFF, CRTC_DATA_PORT);
|
||||||
|
|
||||||
|
grub_outb (START_ADDR_HIGH_REGISTER, CRTC_ADDR_PORT);
|
||||||
|
grub_outb (start >> 8, CRTC_DATA_PORT);
|
||||||
|
|
||||||
|
grub_outb (old_addr, CRTC_ADDR_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int setup = 0;
|
||||||
|
static int is_target = 0;
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_vga_init (void)
|
||||||
|
{
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_vga_setup (unsigned int width, unsigned int height,
|
||||||
|
unsigned int mode_type, unsigned int mode_mask)
|
||||||
|
{
|
||||||
|
grub_err_t err;
|
||||||
|
|
||||||
|
if ((width && width != VGA_WIDTH) || (height && height != VGA_HEIGHT))
|
||||||
|
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found");
|
||||||
|
|
||||||
|
framebuffer.temporary_buffer = grub_malloc (VGA_HEIGHT * VGA_WIDTH);
|
||||||
|
framebuffer.front_page = 0;
|
||||||
|
framebuffer.back_page = 0;
|
||||||
|
if (!framebuffer.temporary_buffer)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
saved_map_mask = get_map_mask ();
|
||||||
|
|
||||||
|
text_mode = grub_vga_set_mode (0x10);
|
||||||
|
setup = 1;
|
||||||
|
set_map_mask (0x0f);
|
||||||
|
set_start_address (PAGE_OFFSET (framebuffer.front_page));
|
||||||
|
|
||||||
|
framebuffer.mode_info.width = VGA_WIDTH;
|
||||||
|
framebuffer.mode_info.height = VGA_HEIGHT;
|
||||||
|
|
||||||
|
framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||||
|
|
||||||
|
if (grub_video_check_mode_flag (mode_type, mode_mask,
|
||||||
|
GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED, 1))
|
||||||
|
{
|
||||||
|
framebuffer.back_page = 1;
|
||||||
|
framebuffer.mode_info.mode_type |= GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED;
|
||||||
|
}
|
||||||
|
|
||||||
|
framebuffer.mode_info.bpp = 8;
|
||||||
|
framebuffer.mode_info.bytes_per_pixel = 1;
|
||||||
|
framebuffer.mode_info.pitch = VGA_WIDTH;
|
||||||
|
framebuffer.mode_info.number_of_colors = 16;
|
||||||
|
framebuffer.mode_info.red_mask_size = 0;
|
||||||
|
framebuffer.mode_info.red_field_pos = 0;
|
||||||
|
framebuffer.mode_info.green_mask_size = 0;
|
||||||
|
framebuffer.mode_info.green_field_pos = 0;
|
||||||
|
framebuffer.mode_info.blue_mask_size = 0;
|
||||||
|
framebuffer.mode_info.blue_field_pos = 0;
|
||||||
|
framebuffer.mode_info.reserved_mask_size = 0;
|
||||||
|
framebuffer.mode_info.reserved_field_pos = 0;
|
||||||
|
|
||||||
|
framebuffer.mode_info.blit_format
|
||||||
|
= grub_video_get_blit_format (&framebuffer.mode_info);
|
||||||
|
|
||||||
|
err = grub_video_fb_create_render_target_from_pointer (&framebuffer.render_target,
|
||||||
|
&framebuffer.mode_info,
|
||||||
|
framebuffer.temporary_buffer);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
grub_dprintf ("video", "Couldn't create FB target\n");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
is_target = 1;
|
||||||
|
err = grub_video_fb_set_active_render_target (framebuffer.render_target);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
|
||||||
|
grub_video_fbstd_colors);
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_vga_fini (void)
|
||||||
|
{
|
||||||
|
if (setup)
|
||||||
|
{
|
||||||
|
set_map_mask (saved_map_mask);
|
||||||
|
grub_vga_set_mode (text_mode);
|
||||||
|
}
|
||||||
|
setup = 0;
|
||||||
|
grub_free (framebuffer.temporary_buffer);
|
||||||
|
framebuffer.temporary_buffer = 0;
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
update_target (void)
|
||||||
|
{
|
||||||
|
int plane;
|
||||||
|
|
||||||
|
if (!is_target)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (plane = 0x01; plane <= 0x08; plane <<= 1)
|
||||||
|
{
|
||||||
|
grub_uint8_t *ptr;
|
||||||
|
volatile grub_uint8_t *ptr2;
|
||||||
|
unsigned cbyte = 0;
|
||||||
|
int shift = 7;
|
||||||
|
set_map_mask (plane);
|
||||||
|
for (ptr = framebuffer.temporary_buffer,
|
||||||
|
ptr2 = VGA_MEM + PAGE_OFFSET (framebuffer.back_page);
|
||||||
|
ptr < framebuffer.temporary_buffer + VGA_WIDTH * VGA_HEIGHT; ptr++)
|
||||||
|
{
|
||||||
|
cbyte |= (!!(plane & *ptr)) << shift;
|
||||||
|
shift--;
|
||||||
|
if (shift == -1)
|
||||||
|
{
|
||||||
|
*ptr2++ = cbyte;
|
||||||
|
shift = 7;
|
||||||
|
cbyte = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_vga_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 ret;
|
||||||
|
ret = grub_video_fb_blit_bitmap (bitmap, oper, x, y, offset_x, offset_y,
|
||||||
|
width, height);
|
||||||
|
update_target ();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_vga_blit_render_target (struct grub_video_fbrender_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 ret;
|
||||||
|
|
||||||
|
ret = grub_video_fb_blit_render_target (source, oper, x, y,
|
||||||
|
offset_x, offset_y, width, height);
|
||||||
|
update_target ();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_vga_set_active_render_target (struct grub_video_render_target *target)
|
||||||
|
{
|
||||||
|
if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
|
||||||
|
{
|
||||||
|
is_target = 1;
|
||||||
|
target = framebuffer.render_target;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
is_target = 0;
|
||||||
|
|
||||||
|
return grub_video_fb_set_active_render_target (target);
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_vga_get_active_render_target (struct grub_video_render_target **target)
|
||||||
|
{
|
||||||
|
grub_err_t err;
|
||||||
|
err = grub_video_fb_get_active_render_target (target);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
if (*target == framebuffer.render_target)
|
||||||
|
*target = GRUB_VIDEO_RENDER_TARGET_DISPLAY;
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_vga_swap_buffers (void)
|
||||||
|
{
|
||||||
|
if (!(framebuffer.mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED))
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
|
||||||
|
/* Activate the other page. */
|
||||||
|
framebuffer.front_page = !framebuffer.front_page;
|
||||||
|
framebuffer.back_page = !framebuffer.back_page;
|
||||||
|
wait_vretrace ();
|
||||||
|
set_start_address (PAGE_OFFSET (framebuffer.front_page));
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_vga_set_palette (unsigned int start __attribute__ ((unused)),
|
||||||
|
unsigned int count __attribute__ ((unused)),
|
||||||
|
struct grub_video_palette_data *palette_data __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
return grub_error (GRUB_ERR_IO, "can't change palette");
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_video_vga_get_info_and_fini (struct grub_video_mode_info *mode_info,
|
||||||
|
void **framebuf)
|
||||||
|
{
|
||||||
|
set_map_mask (0xf);
|
||||||
|
|
||||||
|
grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
|
||||||
|
mode_info->bpp = 1;
|
||||||
|
mode_info->bytes_per_pixel = 0;
|
||||||
|
mode_info->pitch = VGA_WIDTH / 8;
|
||||||
|
mode_info->number_of_colors = 1;
|
||||||
|
|
||||||
|
mode_info->bg_red = 0;
|
||||||
|
mode_info->bg_green = 0;
|
||||||
|
mode_info->bg_blue = 0;
|
||||||
|
mode_info->bg_alpha = 255;
|
||||||
|
|
||||||
|
mode_info->fg_red = 255;
|
||||||
|
mode_info->fg_green = 255;
|
||||||
|
mode_info->fg_blue = 255;
|
||||||
|
mode_info->fg_alpha = 255;
|
||||||
|
|
||||||
|
*framebuf = VGA_MEM + PAGE_OFFSET (framebuffer.front_page);
|
||||||
|
|
||||||
|
grub_video_fb_fini ();
|
||||||
|
grub_free (framebuffer.temporary_buffer);
|
||||||
|
framebuffer.temporary_buffer = 0;
|
||||||
|
setup = 0;
|
||||||
|
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct grub_video_adapter grub_video_vga_adapter =
|
||||||
|
{
|
||||||
|
.name = "VGA Video Driver",
|
||||||
|
.id = GRUB_VIDEO_DRIVER_VGA,
|
||||||
|
|
||||||
|
.init = grub_video_vga_init,
|
||||||
|
.fini = grub_video_vga_fini,
|
||||||
|
.setup = grub_video_vga_setup,
|
||||||
|
.get_info = grub_video_fb_get_info,
|
||||||
|
.get_info_and_fini = grub_video_vga_get_info_and_fini,
|
||||||
|
.set_palette = grub_video_vga_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_vga_blit_bitmap,
|
||||||
|
.blit_render_target = grub_video_vga_blit_render_target,
|
||||||
|
.scroll = grub_video_fb_scroll,
|
||||||
|
.swap_buffers = grub_video_vga_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_vga_set_active_render_target,
|
||||||
|
.get_active_render_target = grub_video_vga_get_active_render_target,
|
||||||
|
|
||||||
|
.next = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
GRUB_MOD_INIT(vga)
|
||||||
|
{
|
||||||
|
grub_video_register (&grub_video_vga_adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
GRUB_MOD_FINI(vga)
|
||||||
|
{
|
||||||
|
grub_video_unregister (&grub_video_vga_adapter);
|
||||||
|
}
|
|
@ -153,10 +153,11 @@ grub_jpeg_get_number (struct grub_jpeg_data *data, int num)
|
||||||
static int
|
static int
|
||||||
grub_jpeg_get_huff_code (struct grub_jpeg_data *data, int id)
|
grub_jpeg_get_huff_code (struct grub_jpeg_data *data, int id)
|
||||||
{
|
{
|
||||||
int code, i;
|
int code;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < ARRAY_SIZE (data->huff_maxval[id]); i++)
|
||||||
{
|
{
|
||||||
code <<= 1;
|
code <<= 1;
|
||||||
if (grub_jpeg_get_bit (data))
|
if (grub_jpeg_get_bit (data))
|
||||||
|
@ -171,47 +172,51 @@ grub_jpeg_get_huff_code (struct grub_jpeg_data *data, int id)
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
|
grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
|
||||||
{
|
{
|
||||||
int id, ac, i, n, base, ofs;
|
int id, ac, n, base, ofs;
|
||||||
grub_uint32_t next_marker;
|
grub_uint32_t next_marker;
|
||||||
grub_uint8_t count[16];
|
grub_uint8_t count[16];
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
next_marker = data->file->offset;
|
next_marker = data->file->offset;
|
||||||
next_marker += grub_jpeg_get_word (data);
|
next_marker += grub_jpeg_get_word (data);
|
||||||
|
|
||||||
id = grub_jpeg_get_byte (data);
|
while (data->file->offset + sizeof (count) + 1 <= next_marker)
|
||||||
ac = (id >> 4);
|
|
||||||
id &= 0xF;
|
|
||||||
if (id > 1)
|
|
||||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
|
||||||
"jpeg: too many huffman tables");
|
|
||||||
|
|
||||||
if (grub_file_read (data->file, &count, sizeof (count)) !=
|
|
||||||
sizeof (count))
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
n = 0;
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
n += count[i];
|
|
||||||
|
|
||||||
id += ac * 2;
|
|
||||||
data->huff_value[id] = grub_malloc (n);
|
|
||||||
if (grub_errno)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
if (grub_file_read (data->file, data->huff_value[id], n) != n)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
base = 0;
|
|
||||||
ofs = 0;
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
{
|
{
|
||||||
base += count[i];
|
id = grub_jpeg_get_byte (data);
|
||||||
ofs += count[i];
|
ac = (id >> 4) & 1;
|
||||||
|
id &= 0xF;
|
||||||
|
if (id > 1)
|
||||||
|
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||||
|
"jpeg: too many huffman tables");
|
||||||
|
|
||||||
data->huff_maxval[id][i] = base;
|
if (grub_file_read (data->file, &count, sizeof (count)) !=
|
||||||
data->huff_offset[id][i] = ofs - base;
|
sizeof (count))
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
base <<= 1;
|
n = 0;
|
||||||
|
for (i = 0; i < ARRAY_SIZE (count); i++)
|
||||||
|
n += count[i];
|
||||||
|
|
||||||
|
id += ac * 2;
|
||||||
|
data->huff_value[id] = grub_malloc (n);
|
||||||
|
if (grub_errno)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
if (grub_file_read (data->file, data->huff_value[id], n) != n)
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
base = 0;
|
||||||
|
ofs = 0;
|
||||||
|
for (i = 0; i < ARRAY_SIZE (count); i++)
|
||||||
|
{
|
||||||
|
base += count[i];
|
||||||
|
ofs += count[i];
|
||||||
|
|
||||||
|
data->huff_maxval[id][i] = base;
|
||||||
|
data->huff_offset[id][i] = ofs - base;
|
||||||
|
|
||||||
|
base <<= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->file->offset != next_marker)
|
if (data->file->offset != next_marker)
|
||||||
|
@ -229,17 +234,24 @@ grub_jpeg_decode_quan_table (struct grub_jpeg_data *data)
|
||||||
next_marker = data->file->offset;
|
next_marker = data->file->offset;
|
||||||
next_marker += grub_jpeg_get_word (data);
|
next_marker += grub_jpeg_get_word (data);
|
||||||
|
|
||||||
id = grub_jpeg_get_byte (data);
|
while (data->file->offset + sizeof (data->quan_table[id]) + 1
|
||||||
if (id >= 0x10) /* Upper 4-bit is precision. */
|
<= next_marker)
|
||||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
{
|
||||||
"jpeg: only 8-bit precision is supported");
|
id = grub_jpeg_get_byte (data);
|
||||||
|
if (id >= 0x10) /* Upper 4-bit is precision. */
|
||||||
|
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||||
|
"jpeg: only 8-bit precision is supported");
|
||||||
|
|
||||||
if (id > 1)
|
if (id > 1)
|
||||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||||
"jpeg: too many quantization tables");
|
"jpeg: too many quantization tables");
|
||||||
|
|
||||||
if (grub_file_read (data->file, &data->quan_table[id], 64) != 64)
|
if (grub_file_read (data->file, &data->quan_table[id],
|
||||||
return grub_errno;
|
sizeof (data->quan_table[id]))
|
||||||
|
!= sizeof (data->quan_table[id]))
|
||||||
|
return grub_errno;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (data->file->offset != next_marker)
|
if (data->file->offset != next_marker)
|
||||||
grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||||
|
@ -444,7 +456,8 @@ grub_jpeg_idct_transform (jpeg_data_unit_t du)
|
||||||
static void
|
static void
|
||||||
grub_jpeg_decode_du (struct grub_jpeg_data *data, int id, jpeg_data_unit_t du)
|
grub_jpeg_decode_du (struct grub_jpeg_data *data, int id, jpeg_data_unit_t du)
|
||||||
{
|
{
|
||||||
int pos, h1, h2, qt;
|
int h1, h2, qt;
|
||||||
|
unsigned pos;
|
||||||
|
|
||||||
grub_memset (du, 0, sizeof (jpeg_data_unit_t));
|
grub_memset (du, 0, sizeof (jpeg_data_unit_t));
|
||||||
|
|
||||||
|
@ -457,7 +470,7 @@ grub_jpeg_decode_du (struct grub_jpeg_data *data, int id, jpeg_data_unit_t du)
|
||||||
|
|
||||||
du[0] = data->dc_value[id] * (int) data->quan_table[qt][0];
|
du[0] = data->dc_value[id] * (int) data->quan_table[qt][0];
|
||||||
pos = 1;
|
pos = 1;
|
||||||
while (pos < 64)
|
while (pos < ARRAY_SIZE (data->quan_table[qt]))
|
||||||
{
|
{
|
||||||
int num, val;
|
int num, val;
|
||||||
|
|
||||||
|
@ -700,7 +713,7 @@ grub_video_reader_jpeg (struct grub_video_bitmap **bitmap,
|
||||||
#if defined(JPEG_DEBUG)
|
#if defined(JPEG_DEBUG)
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_cmd_jpegtest (grub_command_t cmd __attribute__ ((unused)),
|
grub_cmd_jpegtest (grub_command_t cmd __attribute__ ((unused)),
|
||||||
int argc, char **args)
|
int argc, char **args)
|
||||||
{
|
{
|
||||||
struct grub_video_bitmap *bitmap = 0;
|
struct grub_video_bitmap *bitmap = 0;
|
||||||
|
|
||||||
|
@ -735,8 +748,7 @@ GRUB_MOD_INIT (jpeg)
|
||||||
grub_video_bitmap_reader_register (&jpeg_reader);
|
grub_video_bitmap_reader_register (&jpeg_reader);
|
||||||
#if defined(JPEG_DEBUG)
|
#if defined(JPEG_DEBUG)
|
||||||
cmd = grub_register_command ("jpegtest", grub_cmd_jpegtest,
|
cmd = grub_register_command ("jpegtest", grub_cmd_jpegtest,
|
||||||
"FILE",
|
"FILE", "Tests loading of JPEG bitmap.");
|
||||||
"Tests loading of JPEG bitmap.");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue