Commit Graph

41 Commits

Author SHA1 Message Date
Peter Jones d5a32255de misc: Make grub_strtol() "end" pointers have safer const qualifiers
Currently the string functions grub_strtol(), grub_strtoul(), and
grub_strtoull() don't declare the "end" pointer in such a way as to
require the pointer itself or the character array to be immutable to the
implementation, nor does the C standard do so in its similar functions,
though it does require us not to change any of it.

The typical declarations of these functions follow this pattern:

long
strtol(const char * restrict nptr, char ** restrict endptr, int base);

Much of the reason for this is historic, and a discussion of that
follows below, after the explanation of this change.  (GRUB currently
does not include the "restrict" qualifiers, and we name the arguments a
bit differently.)

The implementation is semantically required to treat the character array
as immutable, but such accidental modifications aren't stopped by the
compiler, and the semantics for both the callers and the implementation
of these functions are sometimes also helped by adding that requirement.

This patch changes these declarations to follow this pattern instead:

long
strtol(const char * restrict nptr,
       const char ** const restrict endptr,
       int base);

This means that if any modification to these functions accidentally
introduces either an errant modification to the underlying character
array, or an accidental assignment to endptr rather than *endptr, the
compiler should generate an error.  (The two uses of "restrict" in this
case basically mean strtol() isn't allowed to modify the character array
by going through *endptr, and endptr isn't allowed to point inside the
array.)

It also means the typical use case changes to:

  char *s = ...;
  const char *end;
  long l;

  l = strtol(s, &end, 10);

Or even:

  const char *p = str;
  while (p && *p) {
	  long l = strtol(p, &p, 10);
	  ...
  }

This fixes 26 places where we discard our attempts at treating the data
safely by doing:

  const char *p = str;
  long l;

  l = strtol(p, (char **)&ptr, 10);

It also adds 5 places where we do:

  char *p = str;
  while (p && *p) {
	  long l = strtol(p, (const char ** const)&p, 10);
	  ...
	  /* more calls that need p not to be pointer-to-const */
  }

While moderately distasteful, this is a better problem to have.

With one minor exception, I have tested that all of this compiles
without relevant warnings or errors, and that /much/ of it behaves
correctly, with gcc 9 using 'gcc -W -Wall -Wextra'.  The one exception
is the changes in grub-core/osdep/aros/hostdisk.c , which I have no idea
how to build.

Because the C standard defined type-qualifiers in a way that can be
confusing, in the past there's been a slow but fairly regular stream of
churn within our patches, which add and remove the const qualifier in many
of the users of these functions.  This change should help avoid that in
the future, and in order to help ensure this, I've added an explanation
in misc.h so that when someone does get a compiler warning about a type
error, they have the fix at hand.

The reason we don't have "const" in these calls in the standard is
purely anachronistic: C78 (de facto) did not have type qualifiers in the
syntax, and the "const" type qualifier was added for C89 (I think; it
may have been later).  strtol() appears to date from 4.3BSD in 1986,
which means it could not be added to those functions in the standard
without breaking compatibility, which is usually avoided.

The syntax chosen for type qualifiers is what has led to the churn
regarding usage of const, and is especially confusing on string
functions due to the lack of a string type.  Quoting from C99, the
syntax is:

 declarator:
  pointer[opt] direct-declarator
 direct-declarator:
  identifier
  ( declarator )
  direct-declarator [ type-qualifier-list[opt] assignment-expression[opt] ]
  ...
  direct-declarator [ type-qualifier-list[opt] * ]
  ...
 pointer:
  * type-qualifier-list[opt]
  * type-qualifier-list[opt] pointer
 type-qualifier-list:
  type-qualifier
  type-qualifier-list type-qualifier
 ...
 type-qualifier:
  const
  restrict
  volatile

So the examples go like:

const char foo;			// immutable object
const char *foo;		// mutable pointer to object
char * const foo;		// immutable pointer to mutable object
const char * const foo;		// immutable pointer to immutable object
const char const * const foo; 	// XXX extra const keyword in the middle
const char * const * const foo; // immutable pointer to immutable
				//   pointer to immutable object
const char ** const foo;	// immutable pointer to mutable pointer
				//   to immutable object

Making const left-associative for * and right-associative for everything
else may not have been the best choice ever, but here we are, and the
inevitable result is people using trying to use const (as they should!),
putting it at the wrong place, fighting with the compiler for a bit, and
then either removing it or typecasting something in a bad way.  I won't
go into describing restrict, but its syntax has exactly the same issue
as with const.

Anyway, the last example above actually represents the *behavior* that's
required of strtol()-like functions, so that's our choice for the "end"
pointer.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-02-28 12:41:29 +01:00
Vladimir Serbinenko e95685dab1 Avoid division by zero in serial. 2015-01-21 17:42:13 +01:00
Andrei Borzenkov bac5d1a64a Fix serial --rtscts option processing 2014-12-09 21:56:39 +03:00
Vladimir Serbinenko 9afe2053c9 * grub-core/term/serial.c (grub_serial_register): Fix invalid free.
Ensure that pointers are inited to NULL and that pointers are not
	accessed after free.
2014-01-26 02:36:05 +01:00
Vladimir Serbinenko 065adc346c Clarify several translatable messages. 2013-12-21 03:21:45 +01:00
Vladimir Serbinenko bfdfeb2508 Clarify several translatable messages. 2013-12-21 01:41:16 +01:00
Vladimir Serbinenko 9f8acdaa5d * grub-core/term/serial.c: Add option for enabling/disabling
RTS/CTS flow control.
2013-11-08 18:20:20 +01:00
Vladimir Serbinenko 896f913571 * grub-core/term/serial.c (options), (grub_cmd_serial): Fix handling
of SI suffixes.
2013-11-01 19:46:30 +01:00
Vladimir Serbinenko 89295a0628 Support --base-clock for serial command to handle weird cards with
non-standard base clock.
2013-11-01 19:33:22 +01:00
Vladimir Serbinenko af81ed880d * conf/Makefile.common (CPPFLAGS_KERNEL): Add -DGRUB_KERNEL=1.
* include/grub/dl.h (GRUB_MOD_INIT), (GRUB_MOD_FINI): Define
	functions when compiling for kernel.
2013-10-25 16:07:01 +02:00
Paulo Flabiano Smorigo 84a0e9699f Add progress module to display load progress of files.
* grub-core/lib/progress.c: New file.
	* grub-core/Makefile.core.def (progress): New module.
	* grub-core/kern/file.c (grub_file_open): File name added.
	* (grub_file_read): Progress hook added.
	* grub-core/fs/cbfs.c (grub_cbfs_read): Likewise.
	* grub-core/fs/cpio_common.c (grub_cpio_read): Likewise.
	* grub-core/net/net.c (grub_net_fs_read_real): Likewise.
	* include/grub/file.h (struct grub_file): Add progress module
	* members.
	* include/grub/term.h (struct grub_term_output): Likewise.
	* grub-core/osdep/unix/emuconsole.c (grub_console_term_output):
	Terminal velocity added.
	* grub-core/osdep/windows/emuconsole.c (grub_console_term_output):
	* Likewise.
	* grub-core/term/arc/console.c (grub_console_term_output): Likewise.
	* grub-core/term/efi/console.c (grub_console_term_output): Likewise.
	* grub-core/term/gfxterm.c (grub_video_term): Likewise.
	* grub-core/term/i386/coreboot/cbmemc.c (grub_cbmemc_term_output):
	* Likewise.
	* grub-core/term/i386/pc/console.c (grub_console_term_output):
	* Likewise.
	* grub-core/term/i386/pc/vga_text.c (grub_vga_text_term): Likewise.
	* grub-core/term/ieee1275/console.c (grub_console_term_output):
	* Likewise.
	* grub-core/term/morse.c (grub_audio_term_output): Likewise.
	* grub-core/term/serial.c (grub_serial_term_output): Likewise.
	* grub-core/term/spkmodem.c (grub_spkmodem_term_output): Likewise.
	* grub-core/term/uboot/console.c (uboot_console_term_output):
	* Likewise.
2013-10-22 16:42:20 -02:00
Vladimir 'phcoder' Serbinenko e89c2d48a9 Lift 255x255 erminal sie restriction to 65535x65535. Also change from
bitmasks to small structures of size chosen to fit in registers.
2013-10-19 23:59:32 +02:00
Vladimir 'phcoder' Serbinenko b04b5990df Add serial on ARC platform. 2013-04-25 22:40:03 +02:00
Vladimir 'phcoder' Serbinenko aa1af9bbda Allow IEEE1275 ports on path even if it wasn't detected automatically.
Needed on OpenBIOS due to incomplete device tree.
2013-04-14 17:01:31 +02:00
Vladimir 'phcoder' Serbinenko bc1369732f Make color variables global instead of it being per-terminal. 2013-01-21 17:53:41 +01:00
Vladimir 'phcoder' Serbinenko 08dafeeaae Add a 1.5 stop bits value.
* grub-core/term/serial.c (grub_cmd_serial): Handle 1.5.
	* include/grub/serial.h (grub_serial_stop_bits_t): Add
	GRUB_SERIAL_STOP_BITS_1_5.
2012-06-08 19:32:57 +02:00
Vladimir 'phcoder' Serbinenko b1622487a8 * grub-core/term/serial.c (grub_serial_register)
[GRUB_MACHINE_MIPS_QEMU_MIPS]: Don't autostart console in order to bring
	the behaviour in line with x86 platforms.
2012-06-06 12:25:13 +02:00
Vladimir 'phcoder' Serbinenko 036985b8ce Remove grub_{modname}_init and grub_{modname}_fini. They should never
be used directly if it's really a module and GRUB_MOD_INIT shouldn't
	be used on non-modules.

	* grub-core/commands/boot.c (GRUB_MOD_INIT) [LOONGSON || QEMU_MIPS]:
	Rename to grub_boot_init.
	(GRUB_MOD_FINI) [LOONGSON || QEMU_MIPS]: Rename to grub_boot_fini.
	* grub-core/commands/keylayouts.c (GRUB_MOD_INIT)
	[LOONGSON || QEMU_MIPS]: Rename to grub_keylayouts_init.
	(GRUB_MOD_FINI) [LOONGSON || QEMU_MIPS]: Rename to grub_keylayouts_fini.
	* grub-core/font/font_cmd.c (GRUB_MOD_INIT)
	[LOONGSON || QEMU_MIPS]: Rename to grub_font_init.
	(GRUB_MOD_FINI) [LOONGSON || QEMU_MIPS]: Rename to grub_font_fini.
	* grub-core/kern/mips/loongson/init.c: Replace explicit protos with
	includes.
	(grub_machine_init): Remove empty inits.
	* grub-core/kern/mips/qemu_mips/init.c: Replace explicit protos with
	includes.
	(grub_machine_init): Remove empty inits.
	* grub-core/term/arc/console.c: Remove explicit proto.
	* grub-core/term/at_keyboard.c (GRUB_MOD_INIT)
	[LOONGSON || QEMU_MIPS]: Rename to grub_at_keyboard_init.
	(GRUB_MOD_FINI) [LOONGSON || QEMU_MIPS]: Rename to
	grub_at_keyboard_fini.
	* grub-core/term/gfxterm.c (GRUB_MOD_INIT)
	[LOONGSON || QEMU_MIPS]: Rename to grub_gfxterm_init.
	(GRUB_MOD_FINI) [LOONGSON || QEMU_MIPS]: Rename to
	grub_gfxterm_fini.
	* grub-core/term/i386/pc/vga_text.c (GRUB_MOD_INIT)
	[LOONGSON || QEMU_MIPS]: Rename to grub_vgatext_init.
	(GRUB_MOD_FINI) [LOONGSON || QEMU_MIPS]: Rename to
	grub_vgatext_fini.
	* grub-core/term/ieee1275/console.c: Remove explicit proto.
	* grub-core/term/serial.c (GRUB_MOD_INIT)
	[LOONGSON || QEMU_MIPS]: Rename to grub_serial_init.
	(GRUB_MOD_FINI) [LOONGSON || QEMU_MIPS]: Rename to
	grub_serial_fini.
	* grub-core/term/terminfo.c (GRUB_MOD_INIT)
	[LOONGSON || QEMU_MIPS]: Rename to grub_terminfo_init.
	(GRUB_MOD_FINI) [LOONGSON || QEMU_MIPS]: Rename to
	grub_terminfo_fini.
	* grub-core/video/bitmap.c (GRUB_MOD_INIT): Removed.
	(GRUB_MOD_FINI): Likewise.
	* grub-core/video/radeon_fuloong2e.c (GRUB_MOD_INIT)
	[LOONGSON]: Rename to grub_video_radeon_fuloong2e_init.
	(GRUB_MOD_FINI) [LOONGSON]: Rename to
	grub_video_radeon_fuloong2e_fini.
	* grub-core/video/sis315pro.c (GRUB_MOD_INIT)
	[LOONGSON]: Rename to grub_video_sis315pro_init.
	(GRUB_MOD_FINI) [LOONGSON]: Rename to
	grub_video_sis315pro_fini.
	* grub-core/video/sm712.c (GRUB_MOD_INIT)
	[LOONGSON]: Rename to grub_video_sm712_init.
	(GRUB_MOD_FINI) [LOONGSON]: Rename to
	grub_video_sm712_fini.
	* include/grub/at_keyboard.h (grub_at_keyboard_init): New proto.
	(grub_at_keyboard_fini): Likewise.
	* include/grub/dl.h (GRUB_MOD_INIT) [!GRUB_UTIL && !EMU]:
	Don't declare grub_{modname}_init.
	(GRUB_MOD_INIT) [!GRUB_UTIL && !EMU]: Don't declare grub_{modname}_fini.
	* include/grub/keyboard_layouts.h (grub_keylayouts_init) [!EMU]:
	New proto.
	(grub_keylayouts_fini) [!EMU]: Likewise.
	* include/grub/serial.h (grub_serial_init) [!EMU]:
	New proto.
	(grub_serial_fini) [!EMU]: Likewise.
	* include/grub/terminfo.h (grub_terminfo_init) [!EMU]:
	New proto.
	(grub_terminfo_fini) [!EMU]: Likewise.
	* include/grub/video.h (grub_font_init) [!EMU]:
	New proto.
	(grub_font_fini) [!EMU]: Likewise.
	(grub_gfxterm_init) [!EMU]: Likewise.
	(grub_gfxterm_fini) [!EMU]: Likewise.
	(grub_video_sm712_init) [!EMU]: Likewise.
	(grub_video_sm712_fini) [!EMU]: Likewise.
	(grub_video_sis315pro_init) [!EMU]: Likewise.
	(grub_video_sis315pro_fini) [!EMU]: Likewise.
	(grub_video_radeon_fuloong2e_init) [!EMU]: Likewise.
	(grub_video_radeon_fuloong2e_fini) [!EMU]: Likewise.
2012-02-27 00:28:45 +01:00
Vladimir 'phcoder' Serbinenko a9c7fd1c6c Implement serial on IEEE1275 and EFI.
* docs/grub.texi (Platform-specific limitations): Fix the columen video
	on emu. Mention arc and emu as the only platforms without serial
	support.
	* grub-core/Makefile.core.def (serial): Enable on all terminfomodule and
	ieee1275 platforms.
	* grub-core/term/efi/serial.c: New file.
	* grub-core/term/ieee1275/serial.c: Likewise.
	* grub-core/term/serial.c (grub_serial_find): Disable direct port
	specification if no ns8250 driver is available.
	(grub_cmd_serial): Likewise.
	(GRUB_MOD_INIT) [GRUB_MACHINE_IEEE1275]: Init ofserial.
	(GRUB_MOD_INIT) [GRUB_MACHINE_EFI]: Init efiserial.
	* include/grub/efi/api.h (GRUB_EFI_SERIAL_IO_GUID): New define.
	(grub_efi_parity_type_t): New type.
	(grub_efi_stop_bits_t): Likewise.
	(grub_efi_serial_io_interface): New struct.
	* include/grub/serial.h (grub_serial_port): Make 'broken' field
	available for all interfaces.
	Add EFI and IEEE1275 fields.
	(grub_ofserial_init): New proto.
	(grub_efiserial_init): Likeiwse.
	* util/grub.d/00_header.in: Don't check for the presence of serial
	module.
2012-02-26 17:08:11 +01:00
Vladimir 'phcoder' Serbinenko d61386e21d Improve string. Gettextize. 2012-02-12 15:25:25 +01:00
Vladimir 'phcoder' Serbinenko 87edb8940a Replace single-linked with double-linked lists. It results in more
compact and more efficient code.

	* grub-core/kern/list.c (grub_list_push): Moved from here ...
	* include/grub/list.h (grub_list_push): ... to here. Set prev.
	(grub_list_remove): Moved from here ...
	* include/grub/list.h (grub_list_remove): ... here. Use and set prev.
	(grub_prio_list_insert): Set prev.
	* include/grub/list.h (grub_list): Add prev. All users updated.
2012-01-24 13:31:12 +01:00
Vladimir 'phcoder' Serbinenko bf3a385792 Add missing const qualifiers.
* grub-core/commands/i386/pc/sendkey.c (keysym): Add missing const.
	* grub-core/commands/lspci.c (grub_pci_classname): Likewise.
	* grub-core/commands/menuentry.c (hotkey_aliases): Likewise.
	* grub-core/disk/lvm.c (grub_lvm_getvalue): Likewise.
	(grub_lvm_check_flag): Likewise.
	* grub-core/efiemu/i386/coredetect.c
	(grub_efiemu_get_default_core_name): Likewise
	* grub-core/efiemu/main.c (grub_efiemu_autocore): Likewise.
	* grub-core/fs/hfsplus.c (grub_hfsplus_catkey_internal): Likewise.
	* grub-core/fs/ntfs.c (fixup): Likewise.
	* grub-core/fs/xfs.c (grub_xfs_iterate_dir): Likewise.
	* grub-core/fs/zfs/zfs.c (decomp_entry): Likewise.
	(fzap_lookup): Likewise.
	(zap_lookup): Likewise.
	* grub-core/gnulib/regcomp.c (init_dfa): Likewise.
	* grub-core/lib/legacy_parse.c (check_option): Likewise.
	* grub-core/lib/posix_wrap/langinfo.h (nl_langinfo): Likewise.
	* grub-core/loader/i386/bsd.c (grub_bsd_add_meta): Likewise.
	(grub_freebsd_add_meta_module): Likewise.
	(grub_cmd_freebsd_module): Likewise.
	* grub-core/loader/i386/xnu.c (tbl_alias): Likewise.
	* grub-core/loader/xnu.c (grub_xnu_register_memory): Likewise.
	(grub_xnu_writetree_get_size): Likewise.
	(grub_xnu_writetree_toheap_real): Likewise.
	(grub_xnu_find_key): Likewise.
	(grub_xnu_create_key): Likewise.
	(grub_xnu_create_value): Likewise.
	(grub_xnu_register_memory): Likewise.
	(grub_xnu_check_os_bundle_required): Likewise.
	(grub_xnu_scan_dir_for_kexts): Likewise.
	(grub_xnu_load_kext_from_dir): Likewise.
	* grub-core/normal/color.c (color_list): Likewise.
	* grub-core/normal/completion.c (current_word): Likewise.
	* grub-core/normal/menu_entry.c (insert_string): Likewise.
	* grub-core/term/serial.c (grub_serial_find): Likewise.
	* grub-core/term/tparm.c (grub_terminfo_tparm): Likewise.
	* include/grub/efiemu/efiemu.h (grub_efiemu_get_default_core_name):
	Likewise.
	* include/grub/i386/bsd.h (grub_bsd_add_meta): Likewise.
	(grub_freebsd_add_meta_module): Likewise.
	* include/grub/lib/arg.h (grub_arg_option): Likewise.
	* include/grub/net.h (grub_net_card_driver): Likewise.
	(grub_net_card): Likewise.
	(grub_net_app_protocol): Likewise.
	* include/grub/parttool.h (grub_parttool_argdesc): Likewise.
	* include/grub/serial.h (grub_serial_find): Likewise.
	* include/grub/tparm.h (grub_terminfo_tparm): Likewise.
	* include/grub/xnu.h (grub_xnu_create_key): Likewise.
	(grub_xnu_create_value): Likewise.
	(grub_xnu_find_key): Likewise.
	(grub_xnu_scan_dir_for_kexts): Likewise.
	(grub_xnu_load_kext_from_dir): Likewise.

	* include/grub/zfs/zio_checksum.h (zio_checksum_t): Moved from here ...
	* grub-core/fs/zfs/zfs.c (zio_checksum_t): ...here.
	* include/grub/zfs/zio_checksum.h (zio_checksum_info):
	Moved from here ...
	* grub-core/fs/zfs/zfs.c (zio_checksum_info): ... here. Added missing const.
2011-11-30 16:20:13 +01:00
Shea Levy 33f784e881 Allow all modules to perform serial IO
* grub-core/term-serial.c (grub_serial_find): Remove static qualifier
	* include/grub/serial.h (grub_serial_port_configure): New inline
	function.
	(grub_serial_port_fetch): Likewise.
	(grub_serial_port_put): Likewise.
	(grub_serial_port_fini): Likewise.
	(grub_serial_find): New proto.
2011-11-10 09:41:07 +01:00
Vladimir 'phcoder' Serbinenko 0eb8ffb1f5 * grub-core/lib/posix_wrap/ctype.h (isxdigit): Use grub_isxdigit.
* include/grub/misc.h (grub_isxdigit): New function.
	* grub-core/video/colors.c (my_isxdigit): Removed. All users
	switched to grub_isxdigit.
	* grub-core/term/serial.c (grub_serial_find): Fix in case of port
	number starting with a letter.
2011-10-14 19:16:37 +02:00
Vladimir 'phcoder' Serbinenko 14a2562cf7 Rename Fuloong into Fuloong 2F. Add new ID for Fuloong2E.
* grub-core/Makefile.core.def (fwstart_fuloong): Rename fwstart_fuloong
	into fwstart_fuloong2f. Use boot/mips/loongson/fuloong2f.S.
	* grub-core/boot/mips/loongson/fuloong.S: Rename to ...
	* grub-core/boot/mips/loongson/fuloong2f.S: ... this.
	(FULOONG): Rename to ...
	(FULOONG2F): ... this. All users updated.
	* grub-core/boot/mips/startup_raw.S (machtype_fuloong_str): Rename to
	(machtype_fuloong2f_str): ... this.
	(machtype_fuloong2e_str): New string.
	Check for machtype_fuloong2e_str.
	* grub-core/loader/mips/linux.c (loongson_machtypes)
	[GRUB_MACHINE_MIPS_LOONGSON]: Add GRUB_ARCH_MACHINE_FULOONG2E.
	* grub-core/term/serial.c (loongson_defserial)
	[GRUB_MACHINE_MIPS_LOONGSON]: New array.
	(grub_serial_register) [GRUB_MACHINE_MIPS_LOONGSON]: Use
	loongson_defserial.
	* include/grub/mips/loongson/kernel.h (GRUB_ARCH_MACHINE_FULOONG):
	Rename to ...
	(GRUB_ARCH_MACHINE_FULOONG2F): ... this.
	(GRUB_ARCH_MACHINE_FULOONG2E): New const.
	* util/grub-mkimage.c (image_target_desc): Rename IMAGE_FULOONG_FLASH
	to IMAGE_FULOONG2F_FLASH. All users updated.
	(image_targets): Rename images.
	* util/grub-mkstandalone.in: Accept fuloong2f and fuloong2e.
2011-08-19 22:46:11 +02:00
Vladimir 'phcoder' Serbinenko d734599439 MIPS qemu at_keyboard support.
* gentpl.py (videoinkernel): Add qemu-mips.
	* grub-core/Makefile.am (KERNEL_HEADER_FILES): Add necessary headers.
	* grub-core/Makefile.core.def (kernel): Add at_keyboard and layout.
	* grub-core/kern/mips/qemu_mips/init.c (grub_machine_init): Init new
	modules.
	* grub-core/term/at_keyboard.c (grub_keyboard_controller_init)
	[GRUB_MACHINE_MIPS_QEMU_MIPS]: Don't consider original set.
	* grub-core/term/serial.c (grub_serial_register)
	[GRUB_MACHINE_MIPS_QEMU_MIPS]: Make com0 explicitly active.
2011-07-05 21:00:01 +02:00
Vladimir 'phcoder' Serbinenko 5d063cdc10 Fuloong support.
* configure.ac: Rename yeeloong platform to loongson. All users updated.
	* grub-core/Makefile.core.def (fwstart_fuloong): New image.
	* grub-core/boot/mips/loongson/fuloong.S: New file.
	* grub-core/boot/mips/loongson/fwstart.S: Wait for CS5536 to come up.
	Explicitly init CS5536.
	[FULOONG]: Don't use serial until CS5536 is available.
	Set GPIO based on dumps.
	(serial_hw_init) [FULOONG]: Handle CS5536 parts.
	[FULOONG]: Handle GPIO and memory controller differences.
	Parse machine type in $a2.
	* grub-core/boot/mips/startup_raw.S: Determine and save the
	architecture.
	* grub-core/bus/cs5536.c (gpiodump): Move to fwstart.S.
	(grub_cs5536_init_geode): Remove gpio part. Conditionalise DIVIL
	init on architecture type.
	* grub-core/kern/mips/loongson/init.c (grub_machine_init): Init
	SIS315E. Don't init at_keyboard on fuloong.
	(grub_halt): Support Fuloong.
	* grub-core/kern/mips/startup.S [LOONGSON]: Save $s7.
	* grub-core/loader/mips/linux.c (LOONGSON_MACHTYPE): Removed.
	(loongson_machtypes): New array.
	(grub_cmd_linux) [GRUB_MACHINE_MIPS_LOONGSON]: Pass the right machine
	type.
	* grub-core/term/ns8250.c (serial_get_divisor): New parameter port and
	config. All users updated. Handle CS5536 serial.
	* grub-core/term/serial.c (grub_serial_register): Conditionalise
	default port on machine type. Register serial as inactive.
	* grub-core/video/sis315pro.c: New file.
	* include/grub/cs5536.h (GRUB_CS5536_MSR_MAILBOX_CONFIG_ENABLED): New
	definition.
	(GRUB_CS5536_MSR_MAILBOX_CONFIG): Likewise.
	(GRUB_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1): Likewise.
	(GRUB_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3): Likewise.
	(GRUB_CS5536_MSR_DIVIL_UART1_CONF): Likewise.
	(GRUB_CS5536_MSR_DIVIL_UART2_CONF): Likewise.
	* include/grub/mips/loongson.h (GRUB_CPU_LOONGSON_SHUTDOWN_GPIO): Rename
	to ...
	(GRUB_CPU_YEELOONG_SHUTDOWN_GPIO): ... this.
	* include/grub/mips/loongson/kernel.h (GRUB_ARCH_MACHINE_YEELOONG): New
	definition.
	(GRUB_ARCH_MACHINE_FULOONG): Likewise.
	(grub_arch_machine): New extern var.
	* include/grub/mips/loongson/serial.h
	(GRUB_MACHINE_SERIAL_DIVISOR_115200): Renamed to ...
	(GRUB_MACHINE_SERIAL_PORT0_DIVISOR_115200): ... this.
	(GRUB_MACHINE_SERIAL_PORT): Renamed to ...
	(GRUB_MACHINE_SERIAL_PORT0): ... this.
	(GRUB_MACHINE_SERIAL_PORT2_DIVISOR_115200): New definition.
	(GRUB_MACHINE_SERIAL_PORT1): Likewise.
	(GRUB_MACHINE_SERIAL_PORT2): Likewise.
	(GRUB_MACHINE_SERIAL_PORTS): Include ports 1 and 2.
	* include/grub/term.h (grub_term_register_input_inactive): New inline
	function.
	(grub_term_register_output_inactive): Likewise.
	* include/grub/video.h (grub_video_driver_id): New value
	GRUB_VIDEO_DRIVER_SIS315PRO.
	* util/grub-mkimage.c (image_target_desc): Rename name to dirname.
	New field "names". All users updated.
	New field value IMAGE_FULOONG_FLASH.
	(generate_image): USe separate fwstart hashes for yeeloong and fuloong.
2011-05-15 01:43:44 +02:00
Vladimir 'phcoder' Serbinenko e745cf0ca6 Implement automatic module license checking according to new GNU
guidelines.

	* grub-core/kern/dl.c (grub_dl_check_license): New function.
	(grub_dl_load_core): Use grub_dl_check_license.
	* include/grub/dl.h (GRUB_MOD_SECTION): New macro.
	(GRUB_MOD_LICENSE): Likewise.
	(GRUB_MOD_DUAL_LICENSE): Likewise.
	All modules updated.
2011-04-11 23:01:51 +02:00
Vladimir 'phcoder' Serbinenko 7d4e39d65a * grub-core/bus/usb/usb.c (attach_hooks): Make static.
* grub-core/bus/usb/usbhub.c (hubs): Likewise.
	* grub-core/commands/hashsum.c (aliases): Likewise.
	* grub-core/commands/setpci.c (pci_registers): Likewise.
	* grub-core/disk/usbms.c (attach_hook): Likewise.
	* grub-core/fs/zfs/zfs.c (decomp_table): Likewise.
	(zio_checksum_table): Likewise.
	* grub-core/gettext/gettext.c (grub_gettext_msg_list): Likewise.
	* grub-core/gfxmenu/gfxmenu.c (cached_view): Likewise.
	* grub-core/lib/legacy_parse.c (legacy_commands): Likewise.
	* grub-core/lib/relocator.c (leftovers): Likewise.
	(extra_blocks): Likewise.
	* grub-core/loader/i386/bsd.c (relocator): Likewise.
	* grub-core/loader/i386/multiboot_mbi.c (modules): Likewise.
	(modules_last): Likewise.
	* grub-core/loader/i386/xnu.c (table_aliases): Likewise.
	(devices): Likewise.
	* grub-core/loader/multiboot_mbi2.c (modules): Likewise.
	(modules_last): Likewise.
	* grub-core/normal/auth.c (users): Likewise.
	* grub-core/normal/context.c (initial_menu): Likewise.
	(current_menu): Likewise.
	* grub-core/normal/crypto.c (crypto_specs): Likewise.
	* grub-core/term/serial.c (grub_serial_ports): Likewise.
	(grub_serial_terminfo_input_template): Likewise.
	(grub_serial_terminfo_output_template): Likewise.
	(grub_serial_terminfo_input): Likewise.
	(grub_serial_terminfo_output): Likewise.
	(registered): Likewise.
	* grub-core/term/usb_keyboard.c (attach_hook): Likewise.
2011-03-23 12:05:13 +01:00
Vladimir 'phcoder' Serbinenko 54da1febce Rename mipsel-yeeloong to mipsel-loongson 2011-02-19 13:18:05 +01:00
Vladimir 'phcoder' Serbinenko 74eea126f4 fuloong support 2011-01-18 15:28:44 +01:00
Vladimir 'phcoder' Serbinenko b3f8d28ad0 Run terminfo_cls on initing terminfo output to clear the screen and
move the cursor to (0,0).

	* grub-core/term/ieee1275/ofconsole.c (grub_ofconsole_init_output):
	Call grub_terminfo_output_init.
	* grub-core/term/serial.c (grub_serial_term_output): Set .init.
	* grub-core/term/terminfo.c (grub_terminfo_output_init): New function.
	* include/grub/terminfo.h (grub_terminfo_output_init): New declaration.
2011-01-05 12:23:06 +01:00
Vladimir 'phcoder' Serbinenko 9c693bd66a Properly register serial terminfo.
Reported by: Jordan Uggla

	* grub-core/term/serial.c (grub_serial_terminfo_input_template): New
	const.
	(grub_serial_terminfo_output_template): Likewise.
	(grub_cmd_serial): Register "serial" with terminfo.
	(GRUB_MOD_INIT(serial)): Fill grub_serial_terminfo_input and
	grub_serial_terminfo_output.
2010-11-06 20:40:08 +01:00
Vladimir 'phcoder' Serbinenko a9cc5438a5 Suport manual terminal geometry specification.
* grub-core/term/ieee1275/ofconsole.c (grub_ofconsole_dimensions):
	Save state in grub_ofconsole_terminfo_output.
	(grub_ofconsole_term): Use grub_terminfo_getwh.
	(grub_ofconsole_getwh): Removed.
	* grub-core/term/serial.c (grub_serial_getwh): Removed.
	(grub_serial_term): Use grub_terminfo_getwh.
	* grub-core/term/terminfo.c (grub_terminfo_getwh): New function.
	(options): New struct.
	(OPTION_*): New enum.
	(grub_cmd_terminfo): Transform into extcmd and handle new parameters.
	* include/grub/terminfo.h (grub_terminfo_output_state): New fields
	width and height.
	(grub_terminfo_getwh): New proto.
	* grub-core/lib/legacy_parse.c (grub_legacy_parse): Handle --lines.
2010-09-20 16:27:33 +02:00
Carles Pina i Estany 1a9130dd3f Add keyboard layouts support.
* Makefile.util.def (grub-mklayout): New file.
	(grub-kbdcomp): New script.
	* grub-core/Makefile.am (KERNEL_HEADER_FILES) [COND_mips_yeeloong]:
	Add keyboard_layouts.h.
	* grub-core/Makefile.core.def (kernel): Add commands/keylayouts.c and
	commands/boot.c on yeeloong.
	(keylayouts): New module.
	* grub-core/bus/usb/ohci.c
	* grub-core/bus/usb/uhci.c
	* grub-core/bus/usb/usbhub.c (rescan): New variable.
	(grub_usb_add_hub): Poll interrupt pipe for device handling.
	(attach_root_port): Likewise.
	(poll_nonroot_hub): Likewise.
	(grub_usb_poll_devices): Likewise.
	(detach_device): Close transfer.
	* grub-core/bus/usb/usbtrans.c (grub_usb_execute_and_wait_transfer): New
	function.
	(grub_usb_bulk_setup_readwrite): Likewise.
	(grub_usb_bulk_finish_readwrite): Likewise.
	* grub-core/commands/keylayouts.c: New file.
	* grub-core/commands/keystatus.c (grub_getkeystatus): New function.
	* grub-core/commands/menuentry.c (hotkey_aliases): All several new
	aliases.
	* grub-core/term/at_keyboard.c: Restructured to use keylayouts and
	support scancode 2.
	* grub-core/term/usb_keyboard.c: Restructured to use keylayouts.
	* include/grub/keyboard_layouts.h: New file.
	* util/grub-mklayout.c: New file.
	* util/grub-kbdcomp.in: Likewise.

	Also-By: Aleš Nesrsta <starous@volny.cz>

	Also-By: Vladimir Serbinenko <phcoder@gmail.com>
2010-09-19 01:01:35 +02:00
Vladimir 'phcoder' Serbinenko ed80f7d586 * include/grub/command.h (GRUB_COMMAND_FLAG_CMDLINE): Removed. All
users updated.
	(GRUB_COMMAND_FLAG_MENU): Likewise.
	(GRUB_COMMAND_FLAG_BOTH): Likewise.
	(GRUB_COMMAND_FLAG_TITLE): Removed.
	(GRUB_COMMAND_FLAG_NO_ECHO): Likewise.
	(GRUB_COMMAND_FLAG_EXTCMD): Moved into enum.
	(GRUB_COMMAND_FLAG_DYNCMD): Likewise.
	(GRUB_COMMAND_FLAG_BLOCKS): Likewise.
	(grub_command_flags_t): New enum. All users updated.
2010-09-14 23:06:01 +02:00
Vladimir 'phcoder' Serbinenko 5aaf2c18bd Merge mainline into keylayouts 2010-08-31 14:03:29 +02:00
BVK Chaitanya 928bad4708 merge with mainline 2010-08-26 09:30:11 +05:30
BVK Chaitanya d84666e6bb merge with mainline 2010-08-22 21:00:22 +05:30
BVK Chaitanya 297f0c2b6e merge with mainline 2010-07-13 00:43:28 +05:30
BVK Chaitanya 8c41176882 automake commit without merge history 2010-05-06 11:34:04 +05:30