* [PATCH] Fixed ieee1275 console
@ 2007-10-01 10:57 Marcin Kurek
2007-10-01 12:31 ` Robert Millan
` (3 more replies)
0 siblings, 4 replies; 21+ messages in thread
From: Marcin Kurek @ 2007-10-01 10:57 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]
Hell[o]
Finaly I found a few free minutes to look at ofconsole as it never
correctly work for me. There was 3 problems on my Pegasos:
1) Backspace key not works with USB keyboard.
2) menu looks ugly like hell as it contains some random characters in
place of borders.
3) Console works wrong (the cursor position was wrong after some
commands eg. ls and it displays only a black hole when grub prints
more than one screen of text)
I am not sure how correct my fix is for non Efika/ODW machines, but I
tested it on both without any problems.
In grub_ofconsole_writeesc() I think it would be good idea to use
single "write" command, but this is a cosmetics only I guess. Also in
grub_ofconsole_getxy() the -1 for grub_curr_x seems to be wrong for
me.
Replaced borders characters in grub_ofconsole_putchar() by '-', '|',
etc. Maybe not perfect, but looks definitly better than before [2].
Also fixed cursor position tracking (grub_curr_x, grub_curr_y) which
fix both console problems [3]
Handle 127 keycode as backspace key in grub_ofconsole_readkey() which fix [1]
BTW Also attach my previous patches with [PATCH] in topic this time.
--
--- Marcin 'Morgoth' Kurek ---
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: grub2-affs.patch --]
[-- Type: text/x-patch; name="grub2-affs.patch", Size: 2314 bytes --]
diff -urN grub2.org/fs/affs.c grub2/fs/affs.c
--- grub2.org/fs/affs.c 2007-08-02 20:40:36.000000000 +0200
+++ grub2/fs/affs.c 2007-09-15 10:23:35.550133111 +0200
@@ -25,6 +25,7 @@
#include <grub/dl.h>
#include <grub/types.h>
#include <grub/fshelp.h>
+#include <grub/partition.h>
/* The affs bootblock. */
struct grub_affs_bblock
@@ -97,6 +98,9 @@
struct grub_fshelp_node diropen;
grub_disk_t disk;
+ /* Size in sectors */
+ grub_uint64_t len;
+
/* Blocksize in sectors. */
int blocksize;
@@ -170,10 +174,17 @@
int checksumr = 0;
int blocksize = 0;
+
data = grub_malloc (sizeof (struct grub_affs_data));
if (!data)
return 0;
+ /* total_sectors are not valid on ieee1275 */
+ if(disk->partition)
+ data->len = grub_partition_get_len (disk->partition);
+ else
+ data->len = disk->total_sectors;
+
/* Read the bootblock. */
grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock),
(char *) &data->bblock);
@@ -194,12 +205,6 @@
goto fail;
}
- /* Read the bootblock. */
- grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock),
- (char *) &data->bblock);
- if (grub_errno)
- goto fail;
-
/* No sane person uses more than 8KB for a block. At least I hope
for that person because in that case this won't work. */
rootblock = grub_malloc (GRUB_DISK_SECTOR_SIZE * 16);
@@ -209,7 +214,7 @@
rblock = (struct grub_affs_rblock *) rootblock;
/* Read the rootblock. */
- grub_disk_read (disk, (disk->total_sectors >> 1) + blocksize, 0,
+ grub_disk_read (disk, (data->len >> 1) + blocksize, 0,
GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock);
if (grub_errno)
goto fail;
@@ -241,7 +246,7 @@
data->disk = disk;
data->htsize = grub_be_to_cpu32 (rblock->htsize);
data->diropen.data = data;
- data->diropen.block = (disk->total_sectors >> 1);
+ data->diropen.block = (data->len >> 1);
grub_free (rootblock);
@@ -522,7 +527,7 @@
{
/* The rootblock maps quite well on a file header block, it's
something we can use here. */
- grub_disk_read (data->disk, disk->total_sectors >> 1,
+ grub_disk_read (data->disk, data->len >> 1,
data->blocksize * (GRUB_DISK_SECTOR_SIZE
- GRUB_AFFS_FILE_LOCATION),
sizeof (file), (char *) &file);
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: grub2-ofboot2.patch --]
[-- Type: text/x-patch; name="grub2-ofboot2.patch", Size: 26918 bytes --]
diff -urN grub2.org/conf/powerpc-ieee1275.mk grub2/conf/powerpc-ieee1275.mk
--- grub2.org/conf/powerpc-ieee1275.mk 2007-08-29 19:49:46.000000000 +0200
+++ grub2/conf/powerpc-ieee1275.mk 2007-09-15 02:40:33.144459267 +0200
@@ -235,14 +235,14 @@
normal/menu_entry.c normal/misc.c normal/script.c \
partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \
partmap/acorn.c \
- util/console.c util/grub-emu.c util/misc.c \
+ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \
util/biosdisk.c util/getroot.c \
util/powerpc/ieee1275/misc.c grub_script.tab.c grub_emu_init.c
-CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o
-MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_help.d grub_emu-commands_search.d grub_emu-commands_terminal.d grub_emu-commands_test.d grub_emu-commands_ls.d grub_emu-commands_blocklist.d grub_emu-commands_ieee1275_halt.d grub_emu-commands_ieee1275_reboot.d grub_emu-disk_loopback.d grub_emu-fs_affs.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_sfs.d grub_emu-fs_ufs.d grub_emu-fs_xfs.d grub_emu-fs_hfsplus.d grub_emu-fs_ntfs.d grub_emu-io_gzio.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_elf.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_parser.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_completion.d grub_emu-normal_execute.d grub_emu-normal_function.d grub_emu-normal_lexer.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-normal_script.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-partmap_acorn.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_biosdisk.d grub_emu-util_getroot.d grub_emu-util_powerpc_ieee1275_misc.d grub_emu-grub_script_tab.d grub_emu-grub_emu_init.d
+CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_hostfs.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o
+MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_help.d grub_emu-commands_search.d grub_emu-commands_terminal.d grub_emu-commands_test.d grub_emu-commands_ls.d grub_emu-commands_blocklist.d grub_emu-commands_ieee1275_halt.d grub_emu-commands_ieee1275_reboot.d grub_emu-disk_loopback.d grub_emu-fs_affs.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_sfs.d grub_emu-fs_ufs.d grub_emu-fs_xfs.d grub_emu-fs_hfsplus.d grub_emu-fs_ntfs.d grub_emu-io_gzio.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_elf.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_parser.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_completion.d grub_emu-normal_execute.d grub_emu-normal_function.d grub_emu-normal_lexer.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-normal_script.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-partmap_acorn.d grub_emu-util_console.d grub_emu-util_hostfs.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_biosdisk.d grub_emu-util_getroot.d grub_emu-util_powerpc_ieee1275_misc.d grub_emu-grub_script_tab.d grub_emu-grub_emu_init.d
-grub-emu: $(grub_emu_DEPENDENCIES) grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o
- $(CC) -o $@ grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o $(LDFLAGS) $(grub_emu_LDFLAGS)
+grub-emu: $(grub_emu_DEPENDENCIES) grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_hostfs.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o
+ $(CC) -o $@ grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_execute.o grub_emu-normal_function.o grub_emu-normal_lexer.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-normal_script.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-partmap_acorn.o grub_emu-util_console.o grub_emu-util_hostfs.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_biosdisk.o grub_emu-util_getroot.o grub_emu-util_powerpc_ieee1275_misc.o grub_emu-grub_script_tab.o grub_emu-grub_emu_init.o $(LDFLAGS) $(grub_emu_LDFLAGS)
grub_emu-commands_boot.o: commands/boot.c $(commands/boot.c_DEPENDENCIES)
$(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
@@ -484,6 +484,10 @@
$(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
-include grub_emu-util_console.d
+grub_emu-util_hostfs.o: util/hostfs.c $(util/hostfs.c_DEPENDENCIES)
+ $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
+-include grub_emu-util_hostfs.d
+
grub_emu-util_grub_emu.o: util/grub-emu.c $(util/grub-emu.c_DEPENDENCIES)
$(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -MD -c -o $@ $<
-include grub_emu-util_grub_emu.d
@@ -649,6 +653,8 @@
# Modules.
pkgdata_MODULES = halt.mod \
+ _ofboot.mod \
+ ofboot.mod \
_linux.mod \
linux.mod \
normal.mod \
@@ -657,6 +663,110 @@
_multiboot.mod \
multiboot.mod
+# For _ofboot.mod.
+_ofboot_mod_SOURCES = loader/powerpc/ieee1275/ofboot.c
+CLEANFILES += _ofboot.mod mod-_ofboot.o mod-_ofboot.c pre-_ofboot.o _ofboot_mod-loader_powerpc_ieee1275_ofboot.o und-_ofboot.lst
+ifneq ($(_ofboot_mod_EXPORTS),no)
+CLEANFILES += def-_ofboot.lst
+DEFSYMFILES += def-_ofboot.lst
+endif
+MOSTLYCLEANFILES += _ofboot_mod-loader_powerpc_ieee1275_ofboot.d
+UNDSYMFILES += und-_ofboot.lst
+
+_ofboot.mod: pre-_ofboot.o mod-_ofboot.o
+ -rm -f $@
+ $(TARGET_CC) $(_ofboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
+ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-_ofboot.o: $(_ofboot_mod_DEPENDENCIES) _ofboot_mod-loader_powerpc_ieee1275_ofboot.o
+ -rm -f $@
+ $(TARGET_CC) $(_ofboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ _ofboot_mod-loader_powerpc_ieee1275_ofboot.o
+
+mod-_ofboot.o: mod-_ofboot.c
+ $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_ofboot_mod_CFLAGS) -c -o $@ $<
+
+mod-_ofboot.c: moddep.lst genmodsrc.sh
+ sh $(srcdir)/genmodsrc.sh '_ofboot' $< > $@ || (rm -f $@; exit 1)
+
+ifneq ($(_ofboot_mod_EXPORTS),no)
+def-_ofboot.lst: pre-_ofboot.o
+ $(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 _ofboot/' > $@
+endif
+
+und-_ofboot.lst: pre-_ofboot.o
+ echo '_ofboot' > $@
+ $(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+_ofboot_mod-loader_powerpc_ieee1275_ofboot.o: loader/powerpc/ieee1275/ofboot.c
+ $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_ofboot_mod_CFLAGS) -MD -c -o $@ $<
+-include _ofboot_mod-loader_powerpc_ieee1275_ofboot.d
+
+CLEANFILES += cmd-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst fs-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst
+COMMANDFILES += cmd-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst
+FSFILES += fs-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst
+
+cmd-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst: loader/powerpc/ieee1275/ofboot.c gencmdlist.sh
+ set -e; $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_ofboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _ofboot > $@ || (rm -f $@; exit 1)
+
+fs-_ofboot_mod-loader_powerpc_ieee1275_ofboot.lst: loader/powerpc/ieee1275/ofboot.c genfslist.sh
+ set -e; $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_ofboot_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh _ofboot > $@ || (rm -f $@; exit 1)
+
+
+_ofboot_mod_CFLAGS = $(COMMON_CFLAGS)
+_ofboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For ofboot.mod.
+ofboot_mod_SOURCES = loader/powerpc/ieee1275/ofboot_normal.c
+CLEANFILES += ofboot.mod mod-ofboot.o mod-ofboot.c pre-ofboot.o ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.o und-ofboot.lst
+ifneq ($(ofboot_mod_EXPORTS),no)
+CLEANFILES += def-ofboot.lst
+DEFSYMFILES += def-ofboot.lst
+endif
+MOSTLYCLEANFILES += ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.d
+UNDSYMFILES += und-ofboot.lst
+
+ofboot.mod: pre-ofboot.o mod-ofboot.o
+ -rm -f $@
+ $(TARGET_CC) $(ofboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
+ $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-ofboot.o: $(ofboot_mod_DEPENDENCIES) ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.o
+ -rm -f $@
+ $(TARGET_CC) $(ofboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.o
+
+mod-ofboot.o: mod-ofboot.c
+ $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(ofboot_mod_CFLAGS) -c -o $@ $<
+
+mod-ofboot.c: moddep.lst genmodsrc.sh
+ sh $(srcdir)/genmodsrc.sh 'ofboot' $< > $@ || (rm -f $@; exit 1)
+
+ifneq ($(ofboot_mod_EXPORTS),no)
+def-ofboot.lst: pre-ofboot.o
+ $(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 ofboot/' > $@
+endif
+
+und-ofboot.lst: pre-ofboot.o
+ echo 'ofboot' > $@
+ $(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.o: loader/powerpc/ieee1275/ofboot_normal.c
+ $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(ofboot_mod_CFLAGS) -MD -c -o $@ $<
+-include ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.d
+
+CLEANFILES += cmd-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst fs-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst
+COMMANDFILES += cmd-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst
+FSFILES += fs-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst
+
+cmd-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst: loader/powerpc/ieee1275/ofboot_normal.c gencmdlist.sh
+ set -e; $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(ofboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ofboot > $@ || (rm -f $@; exit 1)
+
+fs-ofboot_mod-loader_powerpc_ieee1275_ofboot_normal.lst: loader/powerpc/ieee1275/ofboot_normal.c genfslist.sh
+ set -e; $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(ofboot_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh ofboot > $@ || (rm -f $@; exit 1)
+
+
+ofboot_mod_CFLAGS = $(COMMON_CFLAGS)
+ofboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
# For _linux.mod.
_linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c
CLEANFILES += _linux.mod mod-_linux.o mod-_linux.c pre-_linux.o _linux_mod-loader_powerpc_ieee1275_linux.o und-_linux.lst
diff -urN grub2.org/conf/powerpc-ieee1275.rmk grub2/conf/powerpc-ieee1275.rmk
--- grub2.org/conf/powerpc-ieee1275.rmk 2007-08-29 19:49:46.000000000 +0200
+++ grub2/conf/powerpc-ieee1275.rmk 2007-09-15 02:39:55.481459267 +0200
@@ -73,7 +73,7 @@
normal/menu_entry.c normal/misc.c normal/script.c \
partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \
partmap/acorn.c \
- util/console.c util/grub-emu.c util/misc.c \
+ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \
util/biosdisk.c util/getroot.c \
util/powerpc/ieee1275/misc.c grub_script.tab.c grub_emu_init.c
@@ -101,6 +101,8 @@
# Modules.
pkgdata_MODULES = halt.mod \
+ _ofboot.mod \
+ ofboot.mod \
_linux.mod \
linux.mod \
normal.mod \
@@ -109,6 +111,16 @@
_multiboot.mod \
multiboot.mod
+# For _ofboot.mod.
+_ofboot_mod_SOURCES = loader/powerpc/ieee1275/ofboot.c
+_ofboot_mod_CFLAGS = $(COMMON_CFLAGS)
+_ofboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For ofboot.mod.
+ofboot_mod_SOURCES = loader/powerpc/ieee1275/ofboot_normal.c
+ofboot_mod_CFLAGS = $(COMMON_CFLAGS)
+ofboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
# For _linux.mod.
_linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c
_linux_mod_CFLAGS = $(COMMON_CFLAGS)
diff -urN grub2.org/include/grub/powerpc/ieee1275/loader.h grub2/include/grub/powerpc/ieee1275/loader.h
--- grub2.org/include/grub/powerpc/ieee1275/loader.h 2007-07-22 01:32:24.000000000 +0200
+++ grub2/include/grub/powerpc/ieee1275/loader.h 2007-09-14 23:08:09.932217034 +0200
@@ -23,10 +23,13 @@
loader. */
void grub_rescue_cmd_linux (int argc, char *argv[]);
void grub_rescue_cmd_initrd (int argc, char *argv[]);
+void grub_rescue_cmd_ofboot (int argc, char *argv[]);
void grub_linux_init (void);
void grub_linux_fini (void);
void grub_linux_normal_init (void);
void grub_linux_normal_fini (void);
+void grub_ofboot_normal_init (void);
+void grub_ofboot_normal_fini (void);
#endif /* ! GRUB_LOADER_MACHINE_HEADER */
diff -urN grub2.org/loader/powerpc/ieee1275/ofboot.c grub2/loader/powerpc/ieee1275/ofboot.c
--- grub2.org/loader/powerpc/ieee1275/ofboot.c 1970-01-01 01:00:00.000000000 +0100
+++ grub2/loader/powerpc/ieee1275/ofboot.c 2007-09-15 04:45:47.960133111 +0200
@@ -0,0 +1,135 @@
+/* ofboot.c - OF boot */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/loader.h>
+#include <grub/dl.h>
+#include <grub/mm.h>
+#include <grub/rescue.h>
+#include <grub/misc.h>
+#include <grub/ieee1275/ieee1275.h>
+#include <grub/machine/loader.h>
+
+static grub_dl_t my_mod;
+
+static char *ofboot_args;
+
+static grub_err_t
+grub_ofboot_boot (void)
+{
+ grub_err_t err;
+
+ err = grub_ieee1275_interpret("go", 0);
+
+ return err;
+}
+
+static grub_err_t
+grub_ofboot_release_mem (void)
+{
+ grub_free (ofboot_args);
+ ofboot_args = 0;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_ofboot_unload (void)
+{
+ grub_err_t err;
+
+ err = grub_ofboot_release_mem ();
+ grub_dl_unref (my_mod);
+
+ return err;
+}
+
+void
+grub_rescue_cmd_ofboot (int argc, char *argv[])
+{
+ int i;
+ int size;
+ grub_err_t err;
+ grub_ieee1275_cell_t res;
+ char *dest;
+
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
+ goto out;
+ }
+
+ /* Release the previously used memory. */
+ grub_loader_unset ();
+
+ size = sizeof("load") + 1;
+ for (i = 0; i < argc; i++)
+ size += grub_strlen (argv[i]) + 1;
+
+ ofboot_args = grub_malloc (size);
+ if (! ofboot_args)
+ goto out;
+
+ dest = grub_stpcpy (ofboot_args, "load");
+ for (i = 0; i < argc; i++)
+ {
+ *dest++ = ' ';
+ dest = grub_stpcpy (dest, argv[i]);
+ }
+
+ err = grub_ieee1275_interpret(ofboot_args, &res);
+ if (err || res)
+ {
+ grub_error (GRUB_ERR_UNKNOWN_OS, "Failed to \"load\"");
+ goto out;
+ }
+
+ err = grub_ieee1275_interpret("init-program", &res);
+ if (err || res)
+ {
+ grub_error (GRUB_ERR_UNKNOWN_OS, "Failed to \"init-program\"");
+ goto out;
+ }
+
+out:
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_ofboot_release_mem ();
+ grub_dl_unref (my_mod);
+ }
+ else
+ {
+ grub_loader_set (grub_ofboot_boot, grub_ofboot_unload, 1);
+ }
+}
+
+\f
+GRUB_MOD_INIT(ofboot)
+{
+ grub_rescue_register_command ("ofboot", grub_rescue_cmd_ofboot,
+ "load using OF interface");
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI(ofboot)
+{
+ grub_rescue_unregister_command ("ofboot");
+}
diff -urN grub2.org/loader/powerpc/ieee1275/ofboot_normal.c grub2/loader/powerpc/ieee1275/ofboot_normal.c
--- grub2.org/loader/powerpc/ieee1275/ofboot_normal.c 1970-01-01 01:00:00.000000000 +0100
+++ grub2/loader/powerpc/ieee1275/ofboot_normal.c 2007-09-14 22:54:03.573217034 +0200
@@ -0,0 +1,48 @@
+/* ofboot_normal.c - OF boot */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2007 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/machine/loader.h>
+
+static const struct grub_arg_option options[] =
+ {
+ {0, 0, 0, 0, 0, 0}
+ };
+
+static grub_err_t
+grub_cmd_ofboot (struct grub_arg_list *state __attribute__ ((unused)),
+ int argc, char **args)
+{
+ grub_rescue_cmd_ofboot (argc, args);
+ return GRUB_ERR_NONE;
+}
+
+GRUB_MOD_INIT(ofboot_normal)
+{
+ (void) mod;
+ grub_register_command ("ofboot", grub_cmd_ofboot, GRUB_COMMAND_FLAG_BOTH,
+ "ofboot [ARGS...]",
+ "Loads using OF interface", options);
+}
+
+GRUB_MOD_FINI(ofboot_normal)
+{
+ grub_unregister_command ("ofboot");
+}
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: grub2-ofconsole.patch --]
[-- Type: text/x-patch; name="grub2-ofconsole.patch", Size: 3846 bytes --]
--- ../Cache/cvs/grub2/term/ieee1275/ofconsole.c 2007-07-22 11:05:11.000000000 +0200
+++ grub2/term/ieee1275/ofconsole.c 2007-10-01 12:12:47.075370575 +0200
@@ -63,29 +63,81 @@
static void
grub_ofconsole_writeesc (const char *str)
{
- while (*str)
- {
- char chr = *(str++);
- grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
- }
-
+ int len = grub_strlen(str);
+ grub_ieee1275_write (stdout_ihandle, str, len, 0);
}
static void
grub_ofconsole_putchar (grub_uint32_t c)
{
- char chr = c;
- if (c == '\n')
- {
+ char chr;
+
+ switch (c)
+ {
+ case GRUB_TERM_DISP_LEFT:
+ c = '<';
+ break;
+ case GRUB_TERM_DISP_UP:
+ c = '^';
+ break;
+ case GRUB_TERM_DISP_RIGHT:
+ c = '>';
+ break;
+ case GRUB_TERM_DISP_DOWN:
+ c = 'v';
+ break;
+ case GRUB_TERM_DISP_HLINE:
+ c = '-';
+ break;
+ case GRUB_TERM_DISP_VLINE:
+ c = '|';
+ break;
+ case GRUB_TERM_DISP_UL:
+ case GRUB_TERM_DISP_UR:
+ case GRUB_TERM_DISP_LL:
+ case GRUB_TERM_DISP_LR:
+ c = '+';
+ break;
+ case '\t':
+ c = ' ';
+ break;
+
+ default:
+ /* of does not support Unicode. */
+ if (c > 0x7f)
+ c = '?';
+ break;
+ }
+
+ switch(c)
+ {
+ case '\a':
+ break;
+ case '\n':
+ grub_putcode ('\r');
grub_curr_y++;
+
+ if(grub_curr_y > (grub_ofconsole_height - 1))
+ grub_curr_y -= 4; /* Is this realy correct for all OF versions around ? */
+ break;
+ case '\r':
grub_curr_x = 0;
- }
- else
- {
+ break;
+ case '\b':
+ if(grub_curr_x > 0)
+ grub_curr_x--;
+ break;
+
+ default:
+
+ if (grub_curr_x >= (grub_ofconsole_width - 1))
+ grub_putcode ('\n');
+
grub_curr_x++;
- if (grub_curr_x > grub_ofconsole_width)
- grub_putcode ('\n');
- }
+ break;
+ }
+
+ chr = c;
grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
}
@@ -137,43 +189,56 @@
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
- if (actual > 0 && c == '\e')
+ if (actual > 0)
{
- grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
- if (actual <= 0)
- {
- *key = '\e';
- return 1;
- }
+ if (c != '\e')
+ {
+ switch(c)
+ {
+ case 127:
+ /* Backspace */
+ c = '\b';
+ break;
+ }
+ }
+ else
+ {
+ grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
+ if (actual <= 0)
+ {
+ *key = '\e';
+ return 1;
+ }
- if (c != 91)
- return 0;
+ if (c != 91)
+ return 0;
- grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
- if (actual <= 0)
- return 0;
+ grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
+ if (actual <= 0)
+ return 0;
- switch (c)
- {
- case 65:
- /* Up: Ctrl-p. */
- c = 16;
- break;
- case 66:
- /* Down: Ctrl-n. */
- c = 14;
- break;
- case 67:
- /* Right: Ctrl-f. */
- c = 6;
- break;
- case 68:
- /* Left: Ctrl-b. */
- c = 2;
- break;
- }
+ switch (c)
+ {
+ case 65:
+ /* Up: Ctrl-p. */
+ c = 16;
+ break;
+ case 66:
+ /* Down: Ctrl-n. */
+ c = 14;
+ break;
+ case 67:
+ /* Right: Ctrl-f. */
+ c = 6;
+ break;
+ case 68:
+ /* Left: Ctrl-b. */
+ c = 2;
+ break;
+ }
+ }
}
-
+
*key = c;
return actual > 0;
}
@@ -217,7 +282,7 @@
static grub_uint16_t
grub_ofconsole_getxy (void)
{
- return ((grub_curr_x - 1) << 8) | grub_curr_y;
+ return (grub_curr_x << 8) | grub_curr_y;
}
static grub_uint16_t
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] Fixed ieee1275 console 2007-10-01 10:57 [PATCH] Fixed ieee1275 console Marcin Kurek @ 2007-10-01 12:31 ` Robert Millan 2007-10-01 12:33 ` Robert Millan ` (2 subsequent siblings) 3 siblings, 0 replies; 21+ messages in thread From: Robert Millan @ 2007-10-01 12:31 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 2138 bytes --] On Mon, Oct 01, 2007 at 12:57:35PM +0200, Marcin Kurek wrote: > 2) menu looks ugly like hell as it contains some random characters in > place of borders. I have a few concerns about this part: > static void > grub_ofconsole_putchar (grub_uint32_t c) > { > - char chr = c; > - if (c == '\n') > - { > + char chr; > + > + switch (c) > + { > + case GRUB_TERM_DISP_LEFT: > + c = '<'; > + break; > + case GRUB_TERM_DISP_UP: > + c = '^'; > + break; > + case GRUB_TERM_DISP_RIGHT: > + c = '>'; > + break; > + case GRUB_TERM_DISP_DOWN: > + c = 'v'; > + break; > + case GRUB_TERM_DISP_HLINE: > + c = '-'; > + break; > + case GRUB_TERM_DISP_VLINE: > + c = '|'; > + break; > + case GRUB_TERM_DISP_UL: > + case GRUB_TERM_DISP_UR: > + case GRUB_TERM_DISP_LL: > + case GRUB_TERM_DISP_LR: > + c = '+'; > + break; > + case '\t': > + c = ' '; > + break; > + > + default: > + /* of does not support Unicode. */ > + if (c > 0x7f) > + c = '?'; > + break; > + } 1- First, you're duplicating code from term/i386/pc/serial.c. I think it should be shared. 2- Do we _always_ want to map to ascii? Of course, mapping to ascii is the best choice when we don't have anything better, but if we can distinguish physical screen (cp437 charset, on PCs and on efika as well) from serial cable (must be ascii?), we could still draw pretty lines instead of -|+ stuff. 3- The cp437 charset in efika is buggy (I don't know about pegasos), as some chars are replaced with portions of the bplan logo (sigh). I gave it a try before, and the only sane way to draw a pretty rectangle seems to be: (warning, utf-8 follows. if you can't read this get a decent MUA ;-)) ╒═╕ │ │ ╘═╛ I had this pending patch liing around. I never got the time to sort out all these problems, but perhaps you can obtain something useful from it. -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.) [-- Attachment #2: charset.diff --] [-- Type: text/x-diff, Size: 7314 bytes --] Tested on Efika *only* Get rid of the FIXME diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/conf/i386-pc.rmk grub2/conf/i386-pc.rmk --- grub2.old/conf/i386-pc.rmk 2007-06-23 16:40:12.000000000 +0200 +++ grub2/conf/i386-pc.rmk 2007-07-10 21:32:52.000000000 +0200 @@ -28,7 +28,7 @@ kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \ kern/i386/dl.c kern/i386/pc/init.c kern/parser.c kern/partition.c \ kern/env.c disk/i386/pc/biosdisk.c \ - term/i386/pc/console.c \ + term/i386/pc/console.c term/cp437.c \ symlist.c kernel_img_HEADERS = arg.h boot.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/conf/powerpc-ieee1275.rmk grub2/conf/powerpc-ieee1275.rmk --- grub2.old/conf/powerpc-ieee1275.rmk 2007-07-10 20:40:07.000000000 +0200 +++ grub2/conf/powerpc-ieee1275.rmk 2007-07-10 21:33:19.000000000 +0200 @@ -80,7 +80,8 @@ kern/ieee1275/ieee1275.c kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \ kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \ - kern/powerpc/ieee1275/init.c term/ieee1275/ofconsole.c \ + kern/powerpc/ieee1275/init.c term/ieee1275/ofconsole.c \ + term/cp437.c \ kern/powerpc/ieee1275/openfw.c disk/ieee1275/ofdisk.c \ kern/parser.c kern/partition.c kern/env.c kern/powerpc/dl.c \ kernel_elf_symlist.c kern/powerpc/cache.S diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/include/grub/ieee1275/ieee1275.h grub2/include/grub/ieee1275/ieee1275.h --- grub2.old/include/grub/ieee1275/ieee1275.h 2007-07-09 17:12:15.000000000 +0200 +++ grub2/include/grub/ieee1275/ieee1275.h 2007-07-10 23:29:37.000000000 +0200 @@ -83,6 +83,14 @@ /* CodeGen firmware does not correctly implement "output-device output" */ GRUB_IEEE1275_FLAG_BROKEN_OUTPUT, + + /* On CodeGen firmware (maybe others?), extended chars are assumed to be + cp437-encoded */ + GRUB_IEEE1275_FLAG_CP437_DISPLAY, + + /* On CodeGen firmware, cp437 characters 0xc0 to 0xcb are reserved for the + bplan logo */ + GRUB_IEEE1275_FLAG_BPLAN_LOGO, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/include/grub/term.h grub2/include/grub/term.h --- grub2.old/include/grub/term.h 2005-10-15 11:22:31.000000000 +0200 +++ grub2/include/grub/term.h 2007-07-10 23:31:02.000000000 +0200 @@ -202,6 +202,7 @@ int EXPORT_FUNC(grub_getcursor) (void); void EXPORT_FUNC(grub_refresh) (void); void EXPORT_FUNC(grub_set_more) (int onoff); +grub_uint32_t EXPORT_FUNC(grub_utf8_to_cp437) (grub_uint32_t c); /* For convenience. */ #define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff) diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/kern/powerpc/ieee1275/cmain.c grub2/kern/powerpc/ieee1275/cmain.c --- grub2.old/kern/powerpc/ieee1275/cmain.c 2007-07-09 17:12:15.000000000 +0200 +++ grub2/kern/powerpc/ieee1275/cmain.c 2007-07-10 23:30:34.000000000 +0200 @@ -66,6 +66,8 @@ { grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CP437_DISPLAY); + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO); } } diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/term/i386/pc/console.c grub2/term/i386/pc/console.c --- grub2.old/term/i386/pc/console.c 2007-05-05 00:28:31.000000000 +0200 +++ grub2/term/i386/pc/console.c 2007-07-10 21:30:06.000000000 +0200 @@ -26,58 +26,10 @@ static grub_uint8_t grub_console_normal_color = 0x7; static grub_uint8_t grub_console_highlight_color = 0x70; -static grub_uint32_t -map_char (grub_uint32_t c) -{ - if (c > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (c) - { - case 0x2190: /* left arrow */ - c = 0x1b; - break; - case 0x2191: /* up arrow */ - c = 0x18; - break; - case 0x2192: /* right arrow */ - c = 0x1a; - break; - case 0x2193: /* down arrow */ - c = 0x19; - break; - case 0x2501: /* horizontal line */ - c = 0xc4; - break; - case 0x2503: /* vertical line */ - c = 0xb3; - break; - case 0x250F: /* upper-left corner */ - c = 0xda; - break; - case 0x2513: /* upper-right corner */ - c = 0xbf; - break; - case 0x2517: /* lower-left corner */ - c = 0xc0; - break; - case 0x251B: /* lower-right corner */ - c = 0xd9; - break; - - default: - c = '?'; - break; - } - } - - return c; -} - static void grub_console_putchar (grub_uint32_t c) { - grub_console_real_putchar (map_char (c)); + grub_console_real_putchar (grub_utf8_to_cp437 (c)); } static grub_ssize_t diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/term/i386/pc/serial.c grub2/term/i386/pc/serial.c --- grub2.old/term/i386/pc/serial.c 2005-11-13 16:47:09.000000000 +0100 +++ grub2/term/i386/pc/serial.c 2007-07-10 23:18:53.000000000 +0200 @@ -328,44 +328,7 @@ /* The serial terminal does not have VGA fonts. */ if (c > 0x7F) { - /* Better than nothing. */ - switch (c) - { - case GRUB_TERM_DISP_LEFT: - c = '<'; - break; - - case GRUB_TERM_DISP_UP: - c = '^'; - break; - - case GRUB_TERM_DISP_RIGHT: - c = '>'; - break; - - case GRUB_TERM_DISP_DOWN: - c = 'v'; - break; - - case GRUB_TERM_DISP_HLINE: - c = '-'; - break; - - case GRUB_TERM_DISP_VLINE: - c = '|'; - break; - - case GRUB_TERM_DISP_UL: - case GRUB_TERM_DISP_UR: - case GRUB_TERM_DISP_LL: - case GRUB_TERM_DISP_LR: - c = '+'; - break; - - default: - c = '?'; - break; - } + / * FIXME */ } switch (c) diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.old/term/ieee1275/ofconsole.c 2007-07-09 17:12:15.000000000 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-07-10 23:30:34.000000000 +0200 @@ -75,7 +75,45 @@ static void grub_ofconsole_putchar (grub_uint32_t c) { - char chr = c; + char chr; + + /* cp437 characters 0xc0 to 0xcb are reserved for the bplan logo. Use + this layout to workaround it: + ╒═╕ + │ │ + ╘═╛ + */ + if (c > 0x7F) + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CP437_DISPLAY)) + { + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO)) + switch (c) + { + case GRUB_TERM_DISP_HLINE: + c = 0xcd; + break; + case GRUB_TERM_DISP_VLINE: + c = 0xb3; + break; + case GRUB_TERM_DISP_UL: + c = 0xd5; + break; + case GRUB_TERM_DISP_UR: + c = 0xb8; + break; + case GRUB_TERM_DISP_LL: + c = 0xd4; + break; + case GRUB_TERM_DISP_LR: + c = 0xbe; + break; + default: + c = grub_utf8_to_cp437 (c); + } + else + c = grub_utf8_to_cp437 (c); + } + if (c == '\n') { grub_curr_y++; @@ -87,6 +125,8 @@ if (grub_curr_x > grub_ofconsole_width) grub_putcode ('\n'); } + + chr = c; grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); } ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-01 10:57 [PATCH] Fixed ieee1275 console Marcin Kurek 2007-10-01 12:31 ` Robert Millan @ 2007-10-01 12:33 ` Robert Millan 2007-10-01 18:14 ` Marcin Kurek 2007-10-11 15:06 ` Marco Gerards 2007-11-18 12:11 ` Marco Gerards 3 siblings, 1 reply; 21+ messages in thread From: Robert Millan @ 2007-10-01 12:33 UTC (permalink / raw) To: The development of GRUB 2 On Mon, Oct 01, 2007 at 12:57:35PM +0200, Marcin Kurek wrote: > Hell[o] > > Finaly I found a few free minutes to look at ofconsole as it never > correctly work for me. There was 3 problems on my Pegasos: > > 1) Backspace key not works with USB keyboard. > 2) menu looks ugly like hell as it contains some random characters in > place of borders. > 3) Console works wrong (the cursor position was wrong after some > commands eg. ls and it displays only a black hole when grub prints > more than one screen of text) Now that I look at it, it seems you attached 3 patches but they're not addressed at each of the problems you describe. Could you split up the console patch in 3 for each of the problems, and start a separate thread for the others? Also, please include ChangeLog entries with your patches. -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.) ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-01 12:33 ` Robert Millan @ 2007-10-01 18:14 ` Marcin Kurek 2007-10-01 18:39 ` Robert Millan 0 siblings, 1 reply; 21+ messages in thread From: Marcin Kurek @ 2007-10-01 18:14 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 1645 bytes --] Hell[o] > [...] OK, split fixes in to separate patches this time as requested. 01-grub2-simple_console.patch ========================== This is a idea how to handle ascii&&cp473&&utf based menus for diffrent consoles. I added a two term flags GRUB_TERM_SIMPLE_MENU (ascii menu) and GRUB_TERM_CP437_MENU (cp437 menus) and handle borders code remap in kern/term.c/grub_putcode() by using new function remap_border() For now GRUB_TERM_CP437_MENU is used in i386/pc/console.c, vesafb.c, vga.c and GRUB_TERM_SIMPLE_MENU is used in i386/pc/serial.c and in ieee1275/ofconsole.c I think it would be wise to use ascii border codes for OF as there is no easy way to check the terminal type (serial, screen) and encoding (on my ODW normal console seems to use cp437, but framebuffer console seems to be using something else) Anyway ascii menu looks quite nice here. 02-grub2-ofconsole_cosmetic.patch ============================== Two small things here. First make grub_ofconsole_writeesc() use single grub_ieee1275_write() call and correct '- 1' in grub_ofconsole_getxy() ... hmmm maybe this should go in to [4] 03-grub2-ofconsole_backspace.patch =============================== My OF seems to send 127 for backspace key this patch handle '127' as backspace. Now I can use it normaly ;) 04-grub2-ofconsole_fix.patch ======================== Fixed cursor x/y position tracking for ofconsole as currect version definitly doesn't not work as expect to. I am not sure only about grub_curr_y -= 4; line as my OF scroll the console +4 lines when reach last line, but is '4' correct for other OF implementations ? -- --- Marcin 'Morgoth' Kurek --- [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 01-grub2-simple_console.patch --] [-- Type: text/x-patch; name="01-grub2-simple_console.patch", Size: 11023 bytes --] diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h --- grub2.org/include/grub/term.h 2007-07-22 01:32:22.000000000 +0200 +++ grub2/include/grub/term.h 2007-10-01 19:20:49.734330521 +0200 @@ -51,10 +51,13 @@ #define GRUB_TERM_NO_EDIT (1 << 1) /* Set when the terminal cannot do fancy things. */ #define GRUB_TERM_DUMB (1 << 2) +/* Set to use ascii menu borders. */ +#define GRUB_TERM_SIMPLE_MENU (1 << 3) +/* Set to use cp437 menu borders. */ +#define GRUB_TERM_CP437_MENU (1 << 4) /* Set when the terminal needs to be initialized. */ #define GRUB_TERM_NEED_INIT (1 << 16) - /* Unicode characters for fancy graphics. */ #define GRUB_TERM_DISP_LEFT 0x2190 #define GRUB_TERM_DISP_UP 0x2191 diff -urN grub2.org/kern/term.c grub2/kern/term.c --- grub2.org/kern/term.c 2007-07-22 01:32:26.000000000 +0200 +++ grub2/kern/term.c 2007-10-01 19:27:23.367330521 +0200 @@ -90,6 +90,94 @@ return grub_cur_term; } +static +grub_uint32_t remap_border(grub_uint32_t code) +{ + if (grub_cur_term->flags & GRUB_TERM_SIMPLE_MENU) + { + switch (code) + { + case GRUB_TERM_DISP_LEFT: + code = '<'; + break; + + case GRUB_TERM_DISP_UP: + code = '^'; + break; + + case GRUB_TERM_DISP_RIGHT: + code = '>'; + break; + + case GRUB_TERM_DISP_DOWN: + code = 'v'; + break; + + case GRUB_TERM_DISP_HLINE: + code = '-'; + break; + + case GRUB_TERM_DISP_VLINE: + code = '|'; + break; + + case GRUB_TERM_DISP_UL: + case GRUB_TERM_DISP_UR: + case GRUB_TERM_DISP_LL: + case GRUB_TERM_DISP_LR: + code = '+'; + break; + } + } + else if(grub_cur_term->flags & GRUB_TERM_CP437_MENU) + { + switch (code) + { + case GRUB_TERM_DISP_LEFT: + code = 0x1b; + break; + + case GRUB_TERM_DISP_UP: + code = 0x18; + break; + + case GRUB_TERM_DISP_RIGHT: + code = 0x1a; + break; + + case GRUB_TERM_DISP_DOWN: + code = 0x19; + break; + + case GRUB_TERM_DISP_HLINE: + code = 0xc4; + break; + + case GRUB_TERM_DISP_VLINE: + code = 0xb3; + break; + + case GRUB_TERM_DISP_UL: + code = 0xda; + break; + + case GRUB_TERM_DISP_UR: + code = 0xbf; + break; + + case GRUB_TERM_DISP_LL: + code = 0xc0; + break; + + case GRUB_TERM_DISP_LR: + code = 0xd9; + break; + } + } + + return code; +} + /* Put a Unicode character. */ void grub_putcode (grub_uint32_t code) @@ -106,7 +194,9 @@ return; } - + + code = remap_border (code); + (grub_cur_term->putchar) (code); if (code == '\n') diff -urN grub2.org/term/i386/pc/console.c grub2/term/i386/pc/console.c --- grub2.org/term/i386/pc/console.c 2007-07-22 01:32:30.000000000 +0200 +++ grub2/term/i386/pc/console.c 2007-10-01 19:30:35.966330521 +0200 @@ -25,58 +25,13 @@ static grub_uint8_t grub_console_normal_color = 0x7; static grub_uint8_t grub_console_highlight_color = 0x70; -static grub_uint32_t -map_char (grub_uint32_t c) -{ - if (c > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (c) - { - case 0x2190: /* left arrow */ - c = 0x1b; - break; - case 0x2191: /* up arrow */ - c = 0x18; - break; - case 0x2192: /* right arrow */ - c = 0x1a; - break; - case 0x2193: /* down arrow */ - c = 0x19; - break; - case 0x2501: /* horizontal line */ - c = 0xc4; - break; - case 0x2503: /* vertical line */ - c = 0xb3; - break; - case 0x250F: /* upper-left corner */ - c = 0xda; - break; - case 0x2513: /* upper-right corner */ - c = 0xbf; - break; - case 0x2517: /* lower-left corner */ - c = 0xc0; - break; - case 0x251B: /* lower-right corner */ - c = 0xd9; - break; - - default: - c = '?'; - break; - } - } - - return c; -} - static void grub_console_putchar (grub_uint32_t c) { - grub_console_real_putchar (map_char (c)); + /* No Unicode support. */ + if (c > 0x7f) + c = '?'; + grub_console_real_putchar (c); } static grub_ssize_t @@ -133,7 +88,7 @@ .setcolorstate = grub_console_setcolorstate, .setcolor = grub_console_setcolor, .setcursor = grub_console_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/serial.c grub2/term/i386/pc/serial.c --- grub2.org/term/i386/pc/serial.c 2007-07-22 01:32:30.000000000 +0200 +++ grub2/term/i386/pc/serial.c 2007-10-01 19:30:22.478330521 +0200 @@ -324,48 +324,9 @@ /* Keep track of the cursor. */ if (keep_track) { - /* The serial terminal does not have VGA fonts. */ + /* The serial terminal does not support Unicode. */ if (c > 0x7F) - { - /* Better than nothing. */ - switch (c) - { - case GRUB_TERM_DISP_LEFT: - c = '<'; - break; - - case GRUB_TERM_DISP_UP: - c = '^'; - break; - - case GRUB_TERM_DISP_RIGHT: - c = '>'; - break; - - case GRUB_TERM_DISP_DOWN: - c = 'v'; - break; - - case GRUB_TERM_DISP_HLINE: - c = '-'; - break; - - case GRUB_TERM_DISP_VLINE: - c = '|'; - break; - - case GRUB_TERM_DISP_UL: - case GRUB_TERM_DISP_UR: - case GRUB_TERM_DISP_LL: - case GRUB_TERM_DISP_LR: - c = '+'; - break; - - default: - c = '?'; - break; - } - } + c = '?'; switch (c) { @@ -498,7 +459,7 @@ .setcolorstate = grub_serial_setcolorstate, .setcolor = grub_serial_setcolor, .setcursor = grub_serial_setcursor, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/vesafb.c grub2/term/i386/pc/vesafb.c --- grub2.org/term/i386/pc/vesafb.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/term/i386/pc/vesafb.c 2007-10-01 19:37:38.160330521 +0200 @@ -214,45 +214,7 @@ unsigned *width) { if (code > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (code) - { - case 0x2190: /* left arrow */ - code = 0x1b; - break; - case 0x2191: /* up arrow */ - code = 0x18; - break; - case 0x2192: /* right arrow */ - code = 0x1a; - break; - case 0x2193: /* down arrow */ - code = 0x19; - break; - case 0x2501: /* horizontal line */ - code = 0xc4; - break; - case 0x2503: /* vertical line */ - code = 0xb3; - break; - case 0x250F: /* upper-left corner */ - code = 0xda; - break; - case 0x2513: /* upper-right corner */ - code = 0xbf; - break; - case 0x2517: /* lower-left corner */ - code = 0xc0; - break; - case 0x251B: /* lower-right corner */ - code = 0xd9; - break; - - default: - return grub_font_get_glyph (code, bitmap, width); - } - } + return grub_font_get_glyph (code, bitmap, width); if (bitmap) grub_memcpy (bitmap, @@ -601,7 +563,7 @@ .setcolorstate = grub_virtual_screen_setcolorstate, .setcolor = grub_virtual_screen_setcolor, .setcursor = grub_vesafb_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/vga.c grub2/term/i386/pc/vga.c --- grub2.org/term/i386/pc/vga.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/term/i386/pc/vga.c 2007-10-01 19:38:10.883330521 +0200 @@ -198,45 +198,7 @@ get_vga_glyph (grub_uint32_t code, unsigned char bitmap[32], unsigned *width) { if (code > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (code) - { - case 0x2190: /* left arrow */ - code = 0x1b; - break; - case 0x2191: /* up arrow */ - code = 0x18; - break; - case 0x2192: /* right arrow */ - code = 0x1a; - break; - case 0x2193: /* down arrow */ - code = 0x19; - break; - case 0x2501: /* horizontal line */ - code = 0xc4; - break; - case 0x2503: /* vertical line */ - code = 0xb3; - break; - case 0x250F: /* upper-left corner */ - code = 0xda; - break; - case 0x2513: /* upper-right corner */ - code = 0xbf; - break; - case 0x2517: /* lower-left corner */ - code = 0xc0; - break; - case 0x251B: /* lower-right corner */ - code = 0xd9; - break; - - default: - return grub_font_get_glyph (code, bitmap, width); - } - } + return grub_font_get_glyph (code, bitmap, width); if (bitmap) grub_memcpy (bitmap, vga_font + code * CHAR_HEIGHT, CHAR_HEIGHT); @@ -590,7 +552,7 @@ .setcolorstate = grub_vga_setcolorstate, .setcolor = grub_vga_setcolor, .setcursor = grub_vga_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-07-22 11:05:11.000000000 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-01 19:01:49.820330521 +0200 @@ -75,6 +75,7 @@ grub_ofconsole_putchar (grub_uint32_t c) { char chr = c; + if (c == '\n') { grub_curr_y++; @@ -86,6 +87,7 @@ if (grub_curr_x > grub_ofconsole_width) grub_putcode ('\n'); } + grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); } @@ -366,7 +368,7 @@ .setcolor = grub_ofconsole_setcolor, .setcursor = grub_ofconsole_setcursor, .refresh = grub_ofconsole_refresh, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; diff -urN grub2.org/util/console.c grub2/util/console.c --- grub2.org/util/console.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/util/console.c 2007-10-01 19:01:49.821330521 +0200 @@ -44,47 +44,6 @@ static void grub_ncurses_putchar (grub_uint32_t c) { - /* Better than nothing. */ - switch (c) - { - case GRUB_TERM_DISP_LEFT: - c = '<'; - break; - - case GRUB_TERM_DISP_UP: - c = '^'; - break; - - case GRUB_TERM_DISP_RIGHT: - c = '>'; - break; - - case GRUB_TERM_DISP_DOWN: - c = 'v'; - break; - - case GRUB_TERM_DISP_HLINE: - c = '-'; - break; - - case GRUB_TERM_DISP_VLINE: - c = '|'; - break; - - case GRUB_TERM_DISP_UL: - case GRUB_TERM_DISP_UR: - case GRUB_TERM_DISP_LL: - case GRUB_TERM_DISP_LR: - c = '+'; - break; - - default: - /* ncurses does not support Unicode. */ - if (c > 0x7f) - c = '?'; - break; - } - addch (c | grub_console_attr); } @@ -302,7 +261,7 @@ .setcolor = grub_ncurses_setcolor, .setcursor = grub_ncurses_setcursor, .refresh = grub_ncurses_refresh, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 02-grub2-ofconsole_cosmetic.patch --] [-- Type: text/x-patch; name="02-grub2-ofconsole_cosmetic.patch", Size: 721 bytes --] diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-01 18:02:14.964330521 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-01 18:02:39.000000000 +0200 @@ -63,12 +63,8 @@ static void grub_ofconsole_writeesc (const char *str) { - while (*str) - { - char chr = *(str++); - grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); - } - + int len = grub_strlen(str); + grub_ieee1275_write (stdout_ihandle, str, len, 0); } static void @@ -219,7 +215,7 @@ static grub_uint16_t grub_ofconsole_getxy (void) { - return ((grub_curr_x - 1) << 8) | grub_curr_y; + return (grub_curr_x << 8) | grub_curr_y; } static grub_uint16_t [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #4: 03-grub2-ofconsole_backspace.patch --] [-- Type: text/x-patch; name="03-grub2-ofconsole_backspace.patch", Size: 1722 bytes --] diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-01 18:02:39.000000000 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-01 18:06:33.000000000 +0200 @@ -135,43 +135,56 @@ grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual > 0 && c == '\e') + if (actual > 0) { - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual <= 0) - { - *key = '\e'; - return 1; - } + if (c != '\e') + { + switch(c) + { + case 127: + /* Backspace */ + c = '\b'; + break; + } + } + else + { + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); + if (actual <= 0) + { + *key = '\e'; + return 1; + } - if (c != 91) - return 0; + if (c != 91) + return 0; - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual <= 0) - return 0; + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); + if (actual <= 0) + return 0; - switch (c) - { - case 65: - /* Up: Ctrl-p. */ - c = 16; - break; - case 66: - /* Down: Ctrl-n. */ - c = 14; - break; - case 67: - /* Right: Ctrl-f. */ - c = 6; - break; - case 68: - /* Left: Ctrl-b. */ - c = 2; - break; - } + switch (c) + { + case 65: + /* Up: Ctrl-p. */ + c = 16; + break; + case 66: + /* Down: Ctrl-n. */ + c = 14; + break; + case 67: + /* Right: Ctrl-f. */ + c = 6; + break; + case 68: + /* Left: Ctrl-b. */ + c = 2; + break; + } + } } - + *key = c; return actual > 0; } [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #5: 04-grub2-ofconsole_fix.patch --] [-- Type: text/x-patch; name="04-grub2-ofconsole_fix.patch", Size: 1300 bytes --] diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-01 18:06:33.000000000 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-01 18:11:58.000000000 +0200 @@ -70,20 +70,38 @@ static void grub_ofconsole_putchar (grub_uint32_t c) { - char chr = c; - - if (c == '\n') - { + char chr; + + switch(c) + { + case '\a': + break; + case '\n': + grub_putcode ('\r'); grub_curr_y++; + if(grub_curr_y > (grub_ofconsole_height - 1)) + grub_curr_y -= 4; /* Is this realy correct for all OF versions around ? */ + break; + case '\r': grub_curr_x = 0; - } - else - { + break; + case '\b': + if(grub_curr_x > 0) + grub_curr_x--; + break; + + default: + if(c == '\t') + c = ' '; + + if (grub_curr_x >= (grub_ofconsole_width - 1)) + grub_putcode ('\n'); + grub_curr_x++; - if (grub_curr_x > grub_ofconsole_width) - grub_putcode ('\n'); - } + break; + } + chr = c; grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); } ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-01 18:14 ` Marcin Kurek @ 2007-10-01 18:39 ` Robert Millan 2007-10-01 19:43 ` Marcin Kurek 0 siblings, 1 reply; 21+ messages in thread From: Robert Millan @ 2007-10-01 18:39 UTC (permalink / raw) To: The development of GRUB 2 On Mon, Oct 01, 2007 at 08:14:16PM +0200, Marcin Kurek wrote: > diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h > --- grub2.org/include/grub/term.h 2007-07-22 01:32:22.000000000 +0200 > +++ grub2/include/grub/term.h 2007-10-01 19:20:49.734330521 +0200 > @@ -51,10 +51,13 @@ > #define GRUB_TERM_NO_EDIT (1 << 1) > /* Set when the terminal cannot do fancy things. */ > #define GRUB_TERM_DUMB (1 << 2) > +/* Set to use ascii menu borders. */ > +#define GRUB_TERM_SIMPLE_MENU (1 << 3) > +/* Set to use cp437 menu borders. */ > +#define GRUB_TERM_CP437_MENU (1 << 4) > /* Set when the terminal needs to be initialized. */ > #define GRUB_TERM_NEED_INIT (1 << 16) Is this a bitmask? In this case, looks like you aren't using the right numbers. Now GRUB_TERM_SIMPLE_MENU == GRUB_TERM_DUMB | GRUB_TERM_NO_EDIT OTOH if that's what you intended, I think it's better to build one macro using the others. > diff -urN grub2.org/term/i386/pc/vesafb.c grub2/term/i386/pc/vesafb.c > --- grub2.org/term/i386/pc/vesafb.c 2007-07-22 01:32:31.000000000 +0200 > +++ grub2/term/i386/pc/vesafb.c 2007-10-01 19:37:38.160330521 +0200 > @@ -214,45 +214,7 @@ > unsigned *width) > { > if (code > 0x7f) > - { > - /* Map some unicode characters to the VGA font, if possible. */ > - switch (code) > - { > - case 0x2190: /* left arrow */ > - code = 0x1b; > - break; > - case 0x2191: /* up arrow */ > - code = 0x18; > - break; > - case 0x2192: /* right arrow */ > - code = 0x1a; > - break; > - case 0x2193: /* down arrow */ > - code = 0x19; > - break; > - case 0x2501: /* horizontal line */ > - code = 0xc4; > - break; > - case 0x2503: /* vertical line */ > - code = 0xb3; > - break; > - case 0x250F: /* upper-left corner */ > - code = 0xda; > - break; > - case 0x2513: /* upper-right corner */ > - code = 0xbf; > - break; > - case 0x2517: /* lower-left corner */ > - code = 0xc0; > - break; > - case 0x251B: /* lower-right corner */ > - code = 0xd9; > - break; > - > - default: > - return grub_font_get_glyph (code, bitmap, width); > - } > - } > + return grub_font_get_glyph (code, bitmap, width); > > if (bitmap) > grub_memcpy (bitmap, > @@ -601,7 +563,7 @@ > .setcolorstate = grub_virtual_screen_setcolorstate, > .setcolor = grub_virtual_screen_setcolor, > .setcursor = grub_vesafb_setcursor, > - .flags = 0, > + .flags = GRUB_TERM_CP437_MENU, > .next = 0 > }; > > diff -urN grub2.org/term/i386/pc/vga.c grub2/term/i386/pc/vga.c > --- grub2.org/term/i386/pc/vga.c 2007-07-22 01:32:31.000000000 +0200 > +++ grub2/term/i386/pc/vga.c 2007-10-01 19:38:10.883330521 +0200 > @@ -198,45 +198,7 @@ > get_vga_glyph (grub_uint32_t code, unsigned char bitmap[32], unsigned *width) > { > if (code > 0x7f) > - { > - /* Map some unicode characters to the VGA font, if possible. */ > - switch (code) > - { > - case 0x2190: /* left arrow */ > - code = 0x1b; > - break; > - case 0x2191: /* up arrow */ > - code = 0x18; > - break; > - case 0x2192: /* right arrow */ > - code = 0x1a; > - break; > - case 0x2193: /* down arrow */ > - code = 0x19; > - break; > - case 0x2501: /* horizontal line */ > - code = 0xc4; > - break; > - case 0x2503: /* vertical line */ > - code = 0xb3; > - break; > - case 0x250F: /* upper-left corner */ > - code = 0xda; > - break; > - case 0x2513: /* upper-right corner */ > - code = 0xbf; > - break; > - case 0x2517: /* lower-left corner */ > - code = 0xc0; > - break; > - case 0x251B: /* lower-right corner */ > - code = 0xd9; > - break; > - > - default: > - return grub_font_get_glyph (code, bitmap, width); > - } > - } > + return grub_font_get_glyph (code, bitmap, width); This part doesn't look right. vesa/vga is a whole different history. At the least vesa *does* support unicode. > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-07-22 11:05:11.000000000 +0200 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-01 19:01:49.820330521 +0200 > @@ -75,6 +75,7 @@ > grub_ofconsole_putchar (grub_uint32_t c) > { > char chr = c; > + > if (c == '\n') > { > grub_curr_y++; > @@ -86,6 +87,7 @@ > if (grub_curr_x > grub_ofconsole_width) > grub_putcode ('\n'); > } > + > grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); > } Please try to avoid cosmetical changes. > diff -urN grub2.org/util/console.c grub2/util/console.c > --- grub2.org/util/console.c 2007-07-22 01:32:31.000000000 +0200 > +++ grub2/util/console.c 2007-10-01 19:01:49.821330521 +0200 > @@ -44,47 +44,6 @@ > static void > grub_ncurses_putchar (grub_uint32_t c) > { Have you verified that grub-emu still builds / works? > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-10-01 18:02:39.000000000 +0200 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-01 18:06:33.000000000 +0200 > @@ -135,43 +135,56 @@ > > grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > > - if (actual > 0 && c == '\e') > + if (actual > 0) > { > - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > - if (actual <= 0) > - { > - *key = '\e'; > - return 1; > - } > + if (c != '\e') > + { > + switch(c) > + { > + case 127: > + /* Backspace */ > + c = '\b'; > + break; What is 127 normally? For firmware bugs, we have a flag mechanism so that it only affects the buggy firmware. Check my latest commit to kern/powerpc/ieee1275/cmain.c. -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.) ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-01 18:39 ` Robert Millan @ 2007-10-01 19:43 ` Marcin Kurek 2007-10-02 21:39 ` Robert Millan 0 siblings, 1 reply; 21+ messages in thread From: Marcin Kurek @ 2007-10-01 19:43 UTC (permalink / raw) To: The development of GRUB 2 Hell[o] > Is this a bitmask? In this case, looks like you aren't using the right > numbers. Now GRUB_TERM_SIMPLE_MENU == GRUB_TERM_DUMB | GRUB_TERM_NO_EDIT > OTOH if that's what you intended, I think it's better to build one macro > using the others. Eeeek, why ? The flags are checked using 'flags & <flag>' as I can see in kern/term.c, then how (1 << 3) can be evaluated as (1 << 1) and (1 << 2) in this case ? > This part doesn't look right. vesa/vga is a whole different history. At the > least vesa *does* support unicode. But both remaps border codes to cp437 and my code change only this part, the unicode support is still there I does not touch it. > Please try to avoid cosmetical changes. Hmmm, I can not see this change in patch in files I have on my hd :/ > Have you verified that grub-emu still builds / works? It does not build for ieee1275 on cvs because missing util/hostfs.c in powerpc-ieee1275.rmk, but after adding it builds/runs fine. > What is 127 normally? For firmware bugs, we have a flag mechanism so that it > only affects the buggy firmware. Check my latest commit to > kern/powerpc/ieee1275/cmain.c. It's DEL key. I placed it here as I saw similar thing in util/console.c and of coz I verified first that both keys (del && backspace) are working correctly on ODW && Efika. -- --- Marcin 'Morgoth' Kurek --- ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-01 19:43 ` Marcin Kurek @ 2007-10-02 21:39 ` Robert Millan 2007-10-03 23:33 ` Marcin Kurek 0 siblings, 1 reply; 21+ messages in thread From: Robert Millan @ 2007-10-02 21:39 UTC (permalink / raw) To: The development of GRUB 2 On Mon, Oct 01, 2007 at 09:43:27PM +0200, Marcin Kurek wrote: > Hell[o] > > > Is this a bitmask? In this case, looks like you aren't using the right > > numbers. Now GRUB_TERM_SIMPLE_MENU == GRUB_TERM_DUMB | GRUB_TERM_NO_EDIT > > OTOH if that's what you intended, I think it's better to build one macro > > using the others. > > Eeeek, why ? The flags are checked using 'flags & <flag>' as I can see > in kern/term.c, then how (1 << 3) can be evaluated as (1 << 1) and (1 > << 2) in this case ? Oops, sorry. That was an oversight. (why does it jump directly from 4 to 16??). > > This part doesn't look right. vesa/vga is a whole different history. At the > > least vesa *does* support unicode. > > But both remaps border codes to cp437 and my code change only this > part, the unicode support is still there I does not touch it. Oh, that's odd. I thought it would be using utf-8 directly. > > Have you verified that grub-emu still builds / works? > > It does not build for ieee1275 on cvs because missing util/hostfs.c in > powerpc-ieee1275.rmk, but after adding it builds/runs fine. Fixed, thanks. -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.) ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-02 21:39 ` Robert Millan @ 2007-10-03 23:33 ` Marcin Kurek 2007-10-04 20:50 ` Robert Millan 0 siblings, 1 reply; 21+ messages in thread From: Marcin Kurek @ 2007-10-03 23:33 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 607 bytes --] Hell[o] Attached current version of console fix'es patches, generaly synced with cvs && cleanups for all of them and some changes in 04-grub2-ofconsole_fix.patch. First it seems pegasos OF uses 24 lines console by default, but it seems when no framebuffer is used the real number of rows is 25 not 24. Introduced GRUB_IEEE1275_FLAG_NOFB_ROWS25 to handle this situation. Second the very old OF version (Pegaos 1 mainly) has problem to interpret the cls escape and simply ignore it. Introduce GRUB_IEEE1275_FLAG_NOCLS to simulate cls with sequence of '\n' in that case. -- --- Marcin 'Morgoth' Kurek --- [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 01-grub2-simple_console.patch --] [-- Type: text/x-patch; name="01-grub2-simple_console.patch", Size: 11023 bytes --] diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h --- grub2.org/include/grub/term.h 2007-07-22 01:32:22.000000000 +0200 +++ grub2/include/grub/term.h 2007-10-01 19:20:49.734330521 +0200 @@ -51,10 +51,13 @@ #define GRUB_TERM_NO_EDIT (1 << 1) /* Set when the terminal cannot do fancy things. */ #define GRUB_TERM_DUMB (1 << 2) +/* Set to use ascii menu borders. */ +#define GRUB_TERM_SIMPLE_MENU (1 << 3) +/* Set to use cp437 menu borders. */ +#define GRUB_TERM_CP437_MENU (1 << 4) /* Set when the terminal needs to be initialized. */ #define GRUB_TERM_NEED_INIT (1 << 16) - /* Unicode characters for fancy graphics. */ #define GRUB_TERM_DISP_LEFT 0x2190 #define GRUB_TERM_DISP_UP 0x2191 diff -urN grub2.org/kern/term.c grub2/kern/term.c --- grub2.org/kern/term.c 2007-07-22 01:32:26.000000000 +0200 +++ grub2/kern/term.c 2007-10-01 19:27:23.367330521 +0200 @@ -90,6 +90,94 @@ return grub_cur_term; } +static +grub_uint32_t remap_border(grub_uint32_t code) +{ + if (grub_cur_term->flags & GRUB_TERM_SIMPLE_MENU) + { + switch (code) + { + case GRUB_TERM_DISP_LEFT: + code = '<'; + break; + + case GRUB_TERM_DISP_UP: + code = '^'; + break; + + case GRUB_TERM_DISP_RIGHT: + code = '>'; + break; + + case GRUB_TERM_DISP_DOWN: + code = 'v'; + break; + + case GRUB_TERM_DISP_HLINE: + code = '-'; + break; + + case GRUB_TERM_DISP_VLINE: + code = '|'; + break; + + case GRUB_TERM_DISP_UL: + case GRUB_TERM_DISP_UR: + case GRUB_TERM_DISP_LL: + case GRUB_TERM_DISP_LR: + code = '+'; + break; + } + } + else if(grub_cur_term->flags & GRUB_TERM_CP437_MENU) + { + switch (code) + { + case GRUB_TERM_DISP_LEFT: + code = 0x1b; + break; + + case GRUB_TERM_DISP_UP: + code = 0x18; + break; + + case GRUB_TERM_DISP_RIGHT: + code = 0x1a; + break; + + case GRUB_TERM_DISP_DOWN: + code = 0x19; + break; + + case GRUB_TERM_DISP_HLINE: + code = 0xc4; + break; + + case GRUB_TERM_DISP_VLINE: + code = 0xb3; + break; + + case GRUB_TERM_DISP_UL: + code = 0xda; + break; + + case GRUB_TERM_DISP_UR: + code = 0xbf; + break; + + case GRUB_TERM_DISP_LL: + code = 0xc0; + break; + + case GRUB_TERM_DISP_LR: + code = 0xd9; + break; + } + } + + return code; +} + /* Put a Unicode character. */ void grub_putcode (grub_uint32_t code) @@ -106,7 +194,9 @@ return; } - + + code = remap_border (code); + (grub_cur_term->putchar) (code); if (code == '\n') diff -urN grub2.org/term/i386/pc/console.c grub2/term/i386/pc/console.c --- grub2.org/term/i386/pc/console.c 2007-07-22 01:32:30.000000000 +0200 +++ grub2/term/i386/pc/console.c 2007-10-01 19:30:35.966330521 +0200 @@ -25,58 +25,13 @@ static grub_uint8_t grub_console_normal_color = 0x7; static grub_uint8_t grub_console_highlight_color = 0x70; -static grub_uint32_t -map_char (grub_uint32_t c) -{ - if (c > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (c) - { - case 0x2190: /* left arrow */ - c = 0x1b; - break; - case 0x2191: /* up arrow */ - c = 0x18; - break; - case 0x2192: /* right arrow */ - c = 0x1a; - break; - case 0x2193: /* down arrow */ - c = 0x19; - break; - case 0x2501: /* horizontal line */ - c = 0xc4; - break; - case 0x2503: /* vertical line */ - c = 0xb3; - break; - case 0x250F: /* upper-left corner */ - c = 0xda; - break; - case 0x2513: /* upper-right corner */ - c = 0xbf; - break; - case 0x2517: /* lower-left corner */ - c = 0xc0; - break; - case 0x251B: /* lower-right corner */ - c = 0xd9; - break; - - default: - c = '?'; - break; - } - } - - return c; -} - static void grub_console_putchar (grub_uint32_t c) { - grub_console_real_putchar (map_char (c)); + /* No Unicode support. */ + if (c > 0x7f) + c = '?'; + grub_console_real_putchar (c); } static grub_ssize_t @@ -133,7 +88,7 @@ .setcolorstate = grub_console_setcolorstate, .setcolor = grub_console_setcolor, .setcursor = grub_console_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/serial.c grub2/term/i386/pc/serial.c --- grub2.org/term/i386/pc/serial.c 2007-07-22 01:32:30.000000000 +0200 +++ grub2/term/i386/pc/serial.c 2007-10-01 19:30:22.478330521 +0200 @@ -324,48 +324,9 @@ /* Keep track of the cursor. */ if (keep_track) { - /* The serial terminal does not have VGA fonts. */ + /* The serial terminal does not support Unicode. */ if (c > 0x7F) - { - /* Better than nothing. */ - switch (c) - { - case GRUB_TERM_DISP_LEFT: - c = '<'; - break; - - case GRUB_TERM_DISP_UP: - c = '^'; - break; - - case GRUB_TERM_DISP_RIGHT: - c = '>'; - break; - - case GRUB_TERM_DISP_DOWN: - c = 'v'; - break; - - case GRUB_TERM_DISP_HLINE: - c = '-'; - break; - - case GRUB_TERM_DISP_VLINE: - c = '|'; - break; - - case GRUB_TERM_DISP_UL: - case GRUB_TERM_DISP_UR: - case GRUB_TERM_DISP_LL: - case GRUB_TERM_DISP_LR: - c = '+'; - break; - - default: - c = '?'; - break; - } - } + c = '?'; switch (c) { @@ -498,7 +459,7 @@ .setcolorstate = grub_serial_setcolorstate, .setcolor = grub_serial_setcolor, .setcursor = grub_serial_setcursor, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/vesafb.c grub2/term/i386/pc/vesafb.c --- grub2.org/term/i386/pc/vesafb.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/term/i386/pc/vesafb.c 2007-10-01 19:37:38.160330521 +0200 @@ -214,45 +214,7 @@ unsigned *width) { if (code > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (code) - { - case 0x2190: /* left arrow */ - code = 0x1b; - break; - case 0x2191: /* up arrow */ - code = 0x18; - break; - case 0x2192: /* right arrow */ - code = 0x1a; - break; - case 0x2193: /* down arrow */ - code = 0x19; - break; - case 0x2501: /* horizontal line */ - code = 0xc4; - break; - case 0x2503: /* vertical line */ - code = 0xb3; - break; - case 0x250F: /* upper-left corner */ - code = 0xda; - break; - case 0x2513: /* upper-right corner */ - code = 0xbf; - break; - case 0x2517: /* lower-left corner */ - code = 0xc0; - break; - case 0x251B: /* lower-right corner */ - code = 0xd9; - break; - - default: - return grub_font_get_glyph (code, bitmap, width); - } - } + return grub_font_get_glyph (code, bitmap, width); if (bitmap) grub_memcpy (bitmap, @@ -601,7 +563,7 @@ .setcolorstate = grub_virtual_screen_setcolorstate, .setcolor = grub_virtual_screen_setcolor, .setcursor = grub_vesafb_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/vga.c grub2/term/i386/pc/vga.c --- grub2.org/term/i386/pc/vga.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/term/i386/pc/vga.c 2007-10-01 19:38:10.883330521 +0200 @@ -198,45 +198,7 @@ get_vga_glyph (grub_uint32_t code, unsigned char bitmap[32], unsigned *width) { if (code > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (code) - { - case 0x2190: /* left arrow */ - code = 0x1b; - break; - case 0x2191: /* up arrow */ - code = 0x18; - break; - case 0x2192: /* right arrow */ - code = 0x1a; - break; - case 0x2193: /* down arrow */ - code = 0x19; - break; - case 0x2501: /* horizontal line */ - code = 0xc4; - break; - case 0x2503: /* vertical line */ - code = 0xb3; - break; - case 0x250F: /* upper-left corner */ - code = 0xda; - break; - case 0x2513: /* upper-right corner */ - code = 0xbf; - break; - case 0x2517: /* lower-left corner */ - code = 0xc0; - break; - case 0x251B: /* lower-right corner */ - code = 0xd9; - break; - - default: - return grub_font_get_glyph (code, bitmap, width); - } - } + return grub_font_get_glyph (code, bitmap, width); if (bitmap) grub_memcpy (bitmap, vga_font + code * CHAR_HEIGHT, CHAR_HEIGHT); @@ -590,7 +552,7 @@ .setcolorstate = grub_vga_setcolorstate, .setcolor = grub_vga_setcolor, .setcursor = grub_vga_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-07-22 11:05:11.000000000 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-01 19:01:49.820330521 +0200 @@ -75,6 +75,7 @@ grub_ofconsole_putchar (grub_uint32_t c) { char chr = c; + if (c == '\n') { grub_curr_y++; @@ -86,6 +87,7 @@ if (grub_curr_x > grub_ofconsole_width) grub_putcode ('\n'); } + grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); } @@ -366,7 +368,7 @@ .setcolor = grub_ofconsole_setcolor, .setcursor = grub_ofconsole_setcursor, .refresh = grub_ofconsole_refresh, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; diff -urN grub2.org/util/console.c grub2/util/console.c --- grub2.org/util/console.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/util/console.c 2007-10-01 19:01:49.821330521 +0200 @@ -44,47 +44,6 @@ static void grub_ncurses_putchar (grub_uint32_t c) { - /* Better than nothing. */ - switch (c) - { - case GRUB_TERM_DISP_LEFT: - c = '<'; - break; - - case GRUB_TERM_DISP_UP: - c = '^'; - break; - - case GRUB_TERM_DISP_RIGHT: - c = '>'; - break; - - case GRUB_TERM_DISP_DOWN: - c = 'v'; - break; - - case GRUB_TERM_DISP_HLINE: - c = '-'; - break; - - case GRUB_TERM_DISP_VLINE: - c = '|'; - break; - - case GRUB_TERM_DISP_UL: - case GRUB_TERM_DISP_UR: - case GRUB_TERM_DISP_LL: - case GRUB_TERM_DISP_LR: - c = '+'; - break; - - default: - /* ncurses does not support Unicode. */ - if (c > 0x7f) - c = '?'; - break; - } - addch (c | grub_console_attr); } @@ -302,7 +261,7 @@ .setcolor = grub_ncurses_setcolor, .setcursor = grub_ncurses_setcursor, .refresh = grub_ncurses_refresh, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 02-grub2-ofconsole_cosmetic.patch --] [-- Type: text/x-patch; name="02-grub2-ofconsole_cosmetic.patch", Size: 526 bytes --] diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-03 10:55:27.191943734 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-03 10:56:26.399943734 +0200 @@ -63,12 +63,8 @@ static void grub_ofconsole_writeesc (const char *str) { - while (*str) - { - char chr = *(str++); - grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); - } - + int len = grub_strlen(str); + grub_ieee1275_write (stdout_ihandle, str, len, 0); } static void [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #4: 03-grub2-ofconsole_backspace.patch --] [-- Type: text/x-patch; name="03-grub2-ofconsole_backspace.patch", Size: 1722 bytes --] diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-01 18:02:39.000000000 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-01 18:06:33.000000000 +0200 @@ -135,43 +135,56 @@ grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual > 0 && c == '\e') + if (actual > 0) { - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual <= 0) - { - *key = '\e'; - return 1; - } + if (c != '\e') + { + switch(c) + { + case 127: + /* Backspace */ + c = '\b'; + break; + } + } + else + { + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); + if (actual <= 0) + { + *key = '\e'; + return 1; + } - if (c != 91) - return 0; + if (c != 91) + return 0; - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual <= 0) - return 0; + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); + if (actual <= 0) + return 0; - switch (c) - { - case 65: - /* Up: Ctrl-p. */ - c = 16; - break; - case 66: - /* Down: Ctrl-n. */ - c = 14; - break; - case 67: - /* Right: Ctrl-f. */ - c = 6; - break; - case 68: - /* Left: Ctrl-b. */ - c = 2; - break; - } + switch (c) + { + case 65: + /* Up: Ctrl-p. */ + c = 16; + break; + case 66: + /* Down: Ctrl-n. */ + c = 14; + break; + case 67: + /* Right: Ctrl-f. */ + c = 6; + break; + case 68: + /* Left: Ctrl-b. */ + c = 2; + break; + } + } } - + *key = c; return actual > 0; } [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #5: 04-grub2-ofconsole_fix.patch --] [-- Type: text/x-patch; name="04-grub2-ofconsole_fix.patch", Size: 5240 bytes --] diff -urN grub2.org/include/grub/ieee1275/ieee1275.h grub2/include/grub/ieee1275/ieee1275.h --- grub2.org/include/grub/ieee1275/ieee1275.h 2007-10-03 17:52:35.006425889 +0200 +++ grub2/include/grub/ieee1275/ieee1275.h 2007-10-03 16:45:56.000000000 +0200 @@ -82,6 +82,12 @@ /* CodeGen firmware does not correctly implement "output-device output" */ GRUB_IEEE1275_FLAG_BROKEN_OUTPUT, + + /* In non fb mode default number of console rows is 24, but in fact it's 25 */ + GRUB_IEEE1275_FLAG_NOFB_ROWS25, + + /* Old Pegaos firmware does not accept cls escape sequence use workaround */ + GRUB_IEEE1275_FLAG_NOCLS, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); diff -urN grub2.org/kern/powerpc/ieee1275/cmain.c grub2/kern/powerpc/ieee1275/cmain.c --- grub2.org/kern/powerpc/ieee1275/cmain.c 2007-10-03 17:52:35.007425889 +0200 +++ grub2/kern/powerpc/ieee1275/cmain.c 2007-10-03 16:49:21.000000000 +0200 @@ -73,6 +73,7 @@ { /* Broken in all versions */ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25); /* There are two incompatible ways of checking the version number. Try both. */ @@ -98,6 +99,14 @@ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0); grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); } + /* It seems old firmware for Pegaos 1 do not accept cls escape then + we need to emulate it using \n sequence */ + if (!grub_strcmp (tmp, "0.") + || !grub_strcmp (tmp, "1.0") + || !grub_strcmp (tmp, "1.1")) + { + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOCLS); + } } } } diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-03 17:52:35.009425889 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-03 17:40:31.000000000 +0200 @@ -29,6 +29,7 @@ static grub_uint8_t grub_ofconsole_width; static grub_uint8_t grub_ofconsole_height; +static grub_uint8_t grub_ofconsole_fb; static int grub_curr_x; static int grub_curr_y; @@ -70,20 +71,40 @@ static void grub_ofconsole_putchar (grub_uint32_t c) { - char chr = c; - - if (c == '\n') - { + char chr; + + switch(c) + { + case '\a': + break; + case '\n': + grub_putcode ('\r'); grub_curr_y++; + if(grub_curr_y > (grub_ofconsole_height - 1)) + /* Is this realy correct for all OF versions around ? */ + grub_curr_y = grub_ofconsole_fb ? + grub_curr_y - 4 : grub_ofconsole_height - 1; + break; + case '\r': grub_curr_x = 0; - } - else - { + break; + case '\b': + if(grub_curr_x > 0) + grub_curr_x--; + break; + + default: + if(c == '\t') + c = ' '; + + if (grub_curr_x >= (grub_ofconsole_width - 1)) + grub_putcode ('\n'); + grub_curr_x++; - if (grub_curr_x > grub_ofconsole_width) - grub_putcode ('\n'); - } + break; + } + chr = c; grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); } @@ -228,7 +249,7 @@ static grub_uint16_t grub_ofconsole_getxy (void) { - return ((grub_curr_x - 1) << 8) | grub_curr_y; + return (grub_curr_x << 8) | grub_curr_y; } static grub_uint16_t @@ -270,6 +291,21 @@ grub_free (val); } } + if (! grub_ieee1275_get_property_length (options, "fb-mode", + &lval) && lval != -1) + { + val = grub_malloc (lval); + if (val) + { + if (! grub_ieee1275_get_property (options, "fb-mode", + val, lval, 0)) + { + if (grub_strncmp (val, "0x0x0", 5) != 0) + grub_ofconsole_fb = 1; + } + grub_free (val); + } + } } /* Use a small console by default. */ @@ -278,6 +314,9 @@ if (! grub_ofconsole_height) grub_ofconsole_height = 24; + if ( grub_ofconsole_fb == 0 && grub_ofconsole_height == 24 && grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25)) + grub_ofconsole_height = 25; + return (grub_ofconsole_width << 8) | grub_ofconsole_height; } @@ -295,10 +334,20 @@ static void grub_ofconsole_cls (void) { - /* Clear the screen. Using serial console, screen(1) only recognizes the - * ANSI escape sequence. Using video console, Apple Open Firmware (version - * 3.1.1) only recognizes the literal ^L. So use both. */ - grub_ofconsole_writeesc ("\f\e[2J"); + if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOCLS)) + { + /* Clear the screen. Using serial console, screen(1) only recognizes the + * ANSI escape sequence. Using video console, Apple Open Firmware (version + * 3.1.1) only recognizes the literal ^L. So use both. */ + grub_ofconsole_writeesc ("\f\e[2J"); + } + else + { + /* It seems no cls escape is available then simulate it using \n flood */ + int x = (grub_ofconsole_height * 2) - grub_curr_y; + while(x--) + grub_putcode ('\n'); + } grub_gotoxy (0, 0); } ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-03 23:33 ` Marcin Kurek @ 2007-10-04 20:50 ` Robert Millan 2007-10-10 15:11 ` Marcin Kurek 0 siblings, 1 reply; 21+ messages in thread From: Robert Millan @ 2007-10-04 20:50 UTC (permalink / raw) To: The development of GRUB 2 On Thu, Oct 04, 2007 at 01:33:25AM +0200, Marcin Kurek wrote: > diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h > --- grub2.org/include/grub/term.h 2007-07-22 01:32:22.000000000 +0200 > +++ grub2/include/grub/term.h 2007-10-01 19:20:49.734330521 +0200 > @@ -51,10 +51,13 @@ > #define GRUB_TERM_NO_EDIT (1 << 1) > /* Set when the terminal cannot do fancy things. */ > #define GRUB_TERM_DUMB (1 << 2) > +/* Set to use ascii menu borders. */ > +#define GRUB_TERM_SIMPLE_MENU (1 << 3) > +/* Set to use cp437 menu borders. */ > +#define GRUB_TERM_CP437_MENU (1 << 4) > /* Set when the terminal needs to be initialized. */ > #define GRUB_TERM_NEED_INIT (1 << 16) > > - Avoid the cosmetical changes! (there are more thorough the patch) Also remember to include a ChangeLog entry. -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.) ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-04 20:50 ` Robert Millan @ 2007-10-10 15:11 ` Marcin Kurek 2007-10-10 19:19 ` Robert Millan 0 siblings, 1 reply; 21+ messages in thread From: Marcin Kurek @ 2007-10-10 15:11 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 938 bytes --] Hell[o] > Avoid the cosmetical changes! (there are more thorough the patch) Arghh, I was sure I removed it :/ Anyway attached updated console patches. 01-grub2-simple_console.patch: Cleanups only. Should have no more "cosmetical" changes inside. 04-grub2-ofconsole_fix.patch: Added detection of console type (serial, normal or fb) and use GRUB_TERM_CP437_MENU from [01] for normal console and GRUB_TERM_SIMPLE_MENU for serial (default) and fb (The font used by fb has no characters required to use cp437 frames. I think we can use fb interface to draw frames or use "set-font" commend to load font with requred characters) Also added workaround of non working 'cls' escape in old pegasos1 firmware. To workaround bPlan logo problem I used parts of patch send ealrier to this list ThX for that. > Also remember to include a ChangeLog entry. If the patch would be good enough to commit it I will. -- --- Marcin 'Morgoth' Kurek --- [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 01-grub2-simple_console.patch --] [-- Type: text/x-patch; name="01-grub2-simple_console.patch", Size: 10899 bytes --] diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h --- grub2.org/include/grub/term.h 2007-07-22 01:32:22.000000000 +0200 +++ grub2/include/grub/term.h 2007-10-10 16:04:18.331688149 +0200 @@ -51,6 +51,10 @@ #define GRUB_TERM_NO_EDIT (1 << 1) /* Set when the terminal cannot do fancy things. */ #define GRUB_TERM_DUMB (1 << 2) +/* Set to use ascii menu borders. */ +#define GRUB_TERM_SIMPLE_MENU (1 << 3) +/* Set to use cp437 menu borders. */ +#define GRUB_TERM_CP437_MENU (1 << 4) /* Set when the terminal needs to be initialized. */ #define GRUB_TERM_NEED_INIT (1 << 16) diff -urN grub2.org/kern/term.c grub2/kern/term.c --- grub2.org/kern/term.c 2007-07-22 01:32:26.000000000 +0200 +++ grub2/kern/term.c 2007-10-10 16:05:03.047688149 +0200 @@ -90,6 +90,94 @@ return grub_cur_term; } +static +grub_uint32_t remap_border(grub_uint32_t code) +{ + if (grub_cur_term->flags & GRUB_TERM_SIMPLE_MENU) + { + switch (code) + { + case GRUB_TERM_DISP_LEFT: + code = '<'; + break; + + case GRUB_TERM_DISP_UP: + code = '^'; + break; + + case GRUB_TERM_DISP_RIGHT: + code = '>'; + break; + + case GRUB_TERM_DISP_DOWN: + code = 'v'; + break; + + case GRUB_TERM_DISP_HLINE: + code = '-'; + break; + + case GRUB_TERM_DISP_VLINE: + code = '|'; + break; + + case GRUB_TERM_DISP_UL: + case GRUB_TERM_DISP_UR: + case GRUB_TERM_DISP_LL: + case GRUB_TERM_DISP_LR: + code = '+'; + break; + } + } + else if(grub_cur_term->flags & GRUB_TERM_CP437_MENU) + { + switch (code) + { + case GRUB_TERM_DISP_LEFT: + code = 0x1b; + break; + + case GRUB_TERM_DISP_UP: + code = 0x18; + break; + + case GRUB_TERM_DISP_RIGHT: + code = 0x1a; + break; + + case GRUB_TERM_DISP_DOWN: + code = 0x19; + break; + + case GRUB_TERM_DISP_HLINE: + code = 0xc4; + break; + + case GRUB_TERM_DISP_VLINE: + code = 0xb3; + break; + + case GRUB_TERM_DISP_UL: + code = 0xda; + break; + + case GRUB_TERM_DISP_UR: + code = 0xbf; + break; + + case GRUB_TERM_DISP_LL: + code = 0xc0; + break; + + case GRUB_TERM_DISP_LR: + code = 0xd9; + break; + } + } + + return code; +} + /* Put a Unicode character. */ void grub_putcode (grub_uint32_t code) @@ -107,6 +195,8 @@ return; } + code = remap_border (code); + (grub_cur_term->putchar) (code); if (code == '\n') diff -urN grub2.org/term/i386/pc/console.c grub2/term/i386/pc/console.c --- grub2.org/term/i386/pc/console.c 2007-07-22 01:32:30.000000000 +0200 +++ grub2/term/i386/pc/console.c 2007-10-10 16:03:34.131688149 +0200 @@ -25,58 +25,13 @@ static grub_uint8_t grub_console_normal_color = 0x7; static grub_uint8_t grub_console_highlight_color = 0x70; -static grub_uint32_t -map_char (grub_uint32_t c) -{ - if (c > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (c) - { - case 0x2190: /* left arrow */ - c = 0x1b; - break; - case 0x2191: /* up arrow */ - c = 0x18; - break; - case 0x2192: /* right arrow */ - c = 0x1a; - break; - case 0x2193: /* down arrow */ - c = 0x19; - break; - case 0x2501: /* horizontal line */ - c = 0xc4; - break; - case 0x2503: /* vertical line */ - c = 0xb3; - break; - case 0x250F: /* upper-left corner */ - c = 0xda; - break; - case 0x2513: /* upper-right corner */ - c = 0xbf; - break; - case 0x2517: /* lower-left corner */ - c = 0xc0; - break; - case 0x251B: /* lower-right corner */ - c = 0xd9; - break; - - default: - c = '?'; - break; - } - } - - return c; -} - static void grub_console_putchar (grub_uint32_t c) { - grub_console_real_putchar (map_char (c)); + /* No Unicode support. */ + if (c > 0x7f) + c = '?'; + grub_console_real_putchar (c); } static grub_ssize_t @@ -133,7 +88,7 @@ .setcolorstate = grub_console_setcolorstate, .setcolor = grub_console_setcolor, .setcursor = grub_console_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/serial.c grub2/term/i386/pc/serial.c --- grub2.org/term/i386/pc/serial.c 2007-07-22 01:32:30.000000000 +0200 +++ grub2/term/i386/pc/serial.c 2007-10-10 16:03:34.132688149 +0200 @@ -324,48 +324,9 @@ /* Keep track of the cursor. */ if (keep_track) { - /* The serial terminal does not have VGA fonts. */ + /* The serial terminal does not support Unicode. */ if (c > 0x7F) - { - /* Better than nothing. */ - switch (c) - { - case GRUB_TERM_DISP_LEFT: - c = '<'; - break; - - case GRUB_TERM_DISP_UP: - c = '^'; - break; - - case GRUB_TERM_DISP_RIGHT: - c = '>'; - break; - - case GRUB_TERM_DISP_DOWN: - c = 'v'; - break; - - case GRUB_TERM_DISP_HLINE: - c = '-'; - break; - - case GRUB_TERM_DISP_VLINE: - c = '|'; - break; - - case GRUB_TERM_DISP_UL: - case GRUB_TERM_DISP_UR: - case GRUB_TERM_DISP_LL: - case GRUB_TERM_DISP_LR: - c = '+'; - break; - - default: - c = '?'; - break; - } - } + c = '?'; switch (c) { @@ -498,7 +459,7 @@ .setcolorstate = grub_serial_setcolorstate, .setcolor = grub_serial_setcolor, .setcursor = grub_serial_setcursor, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/vesafb.c grub2/term/i386/pc/vesafb.c --- grub2.org/term/i386/pc/vesafb.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/term/i386/pc/vesafb.c 2007-10-10 16:03:34.133688149 +0200 @@ -214,45 +214,7 @@ unsigned *width) { if (code > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (code) - { - case 0x2190: /* left arrow */ - code = 0x1b; - break; - case 0x2191: /* up arrow */ - code = 0x18; - break; - case 0x2192: /* right arrow */ - code = 0x1a; - break; - case 0x2193: /* down arrow */ - code = 0x19; - break; - case 0x2501: /* horizontal line */ - code = 0xc4; - break; - case 0x2503: /* vertical line */ - code = 0xb3; - break; - case 0x250F: /* upper-left corner */ - code = 0xda; - break; - case 0x2513: /* upper-right corner */ - code = 0xbf; - break; - case 0x2517: /* lower-left corner */ - code = 0xc0; - break; - case 0x251B: /* lower-right corner */ - code = 0xd9; - break; - - default: - return grub_font_get_glyph (code, bitmap, width); - } - } + return grub_font_get_glyph (code, bitmap, width); if (bitmap) grub_memcpy (bitmap, @@ -601,7 +563,7 @@ .setcolorstate = grub_virtual_screen_setcolorstate, .setcolor = grub_virtual_screen_setcolor, .setcursor = grub_vesafb_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/vga.c grub2/term/i386/pc/vga.c --- grub2.org/term/i386/pc/vga.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/term/i386/pc/vga.c 2007-10-10 16:03:34.135688149 +0200 @@ -198,45 +198,7 @@ get_vga_glyph (grub_uint32_t code, unsigned char bitmap[32], unsigned *width) { if (code > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (code) - { - case 0x2190: /* left arrow */ - code = 0x1b; - break; - case 0x2191: /* up arrow */ - code = 0x18; - break; - case 0x2192: /* right arrow */ - code = 0x1a; - break; - case 0x2193: /* down arrow */ - code = 0x19; - break; - case 0x2501: /* horizontal line */ - code = 0xc4; - break; - case 0x2503: /* vertical line */ - code = 0xb3; - break; - case 0x250F: /* upper-left corner */ - code = 0xda; - break; - case 0x2513: /* upper-right corner */ - code = 0xbf; - break; - case 0x2517: /* lower-left corner */ - code = 0xc0; - break; - case 0x251B: /* lower-right corner */ - code = 0xd9; - break; - - default: - return grub_font_get_glyph (code, bitmap, width); - } - } + return grub_font_get_glyph (code, bitmap, width); if (bitmap) grub_memcpy (bitmap, vga_font + code * CHAR_HEIGHT, CHAR_HEIGHT); @@ -590,7 +552,7 @@ .setcolorstate = grub_vga_setcolorstate, .setcolor = grub_vga_setcolor, .setcursor = grub_vga_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-07-22 11:05:11.000000000 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-10 16:03:34.136688149 +0200 @@ -75,6 +75,7 @@ grub_ofconsole_putchar (grub_uint32_t c) { char chr = c; + if (c == '\n') { grub_curr_y++; @@ -86,6 +87,7 @@ if (grub_curr_x > grub_ofconsole_width) grub_putcode ('\n'); } + grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); } @@ -366,7 +368,7 @@ .setcolor = grub_ofconsole_setcolor, .setcursor = grub_ofconsole_setcursor, .refresh = grub_ofconsole_refresh, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; diff -urN grub2.org/util/console.c grub2/util/console.c --- grub2.org/util/console.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/util/console.c 2007-10-10 16:03:34.137688149 +0200 @@ -44,47 +44,6 @@ static void grub_ncurses_putchar (grub_uint32_t c) { - /* Better than nothing. */ - switch (c) - { - case GRUB_TERM_DISP_LEFT: - c = '<'; - break; - - case GRUB_TERM_DISP_UP: - c = '^'; - break; - - case GRUB_TERM_DISP_RIGHT: - c = '>'; - break; - - case GRUB_TERM_DISP_DOWN: - c = 'v'; - break; - - case GRUB_TERM_DISP_HLINE: - c = '-'; - break; - - case GRUB_TERM_DISP_VLINE: - c = '|'; - break; - - case GRUB_TERM_DISP_UL: - case GRUB_TERM_DISP_UR: - case GRUB_TERM_DISP_LL: - case GRUB_TERM_DISP_LR: - c = '+'; - break; - - default: - /* ncurses does not support Unicode. */ - if (c > 0x7f) - c = '?'; - break; - } - addch (c | grub_console_attr); } @@ -302,7 +261,7 @@ .setcolor = grub_ncurses_setcolor, .setcursor = grub_ncurses_setcursor, .refresh = grub_ncurses_refresh, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 04-grub2-ofconsole_fix.patch --] [-- Type: text/x-patch; name="04-grub2-ofconsole_fix.patch", Size: 8448 bytes --] diff -urN grub2.org/include/grub/ieee1275/ieee1275.h grub2/include/grub/ieee1275/ieee1275.h --- grub2.org/include/grub/ieee1275/ieee1275.h 2007-10-04 22:44:12.000000000 +0200 +++ grub2/include/grub/ieee1275/ieee1275.h 2007-10-10 16:41:39.594688149 +0200 @@ -82,6 +82,16 @@ /* CodeGen firmware does not correctly implement "output-device output" */ GRUB_IEEE1275_FLAG_BROKEN_OUTPUT, + + /* In non fb mode default number of console rows is 24, but in fact it's 25 */ + GRUB_IEEE1275_FLAG_NOFB_ROWS25, + + /* Old Pegaos firmware does not accept cls escape sequence */ + GRUB_IEEE1275_FLAG_NOCLS, + + /* On CodeGen firmware, cp437 characters 0xc0 to 0xcb are reserved for the + bplan logo */ + GRUB_IEEE1275_FLAG_BPLAN_LOGO, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); diff -urN grub2.org/kern/powerpc/ieee1275/cmain.c grub2/kern/powerpc/ieee1275/cmain.c --- grub2.org/kern/powerpc/ieee1275/cmain.c 2007-10-04 22:44:12.000000000 +0200 +++ grub2/kern/powerpc/ieee1275/cmain.c 2007-10-10 16:42:30.520688149 +0200 @@ -73,6 +73,8 @@ { /* Broken in all versions */ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25); + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO); /* There are two incompatible ways of checking the version number. Try both. */ @@ -98,6 +100,13 @@ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0); grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); } + /* It seems old firmware for Pegaos 1 do not accept cls escape then + we need to emulate it using \n sequence */ + if (!grub_strcmp (tmp, "1.0") + || !grub_strcmp (tmp, "1.1")) + { + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOCLS); + } } } } diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-04 22:44:12.000000000 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-10 16:51:56.829688149 +0200 @@ -24,12 +24,18 @@ #include <grub/machine/console.h> #include <grub/ieee1275/ieee1275.h> +static void grub_ofconsole_setflags(int flags, int x); + static grub_ieee1275_ihandle_t stdout_ihandle; static grub_ieee1275_ihandle_t stdin_ihandle; static grub_uint8_t grub_ofconsole_width; static grub_uint8_t grub_ofconsole_height; +/* We will assume serial console by default */ +static grub_uint8_t grub_ofconsole_fb = 0; +static grub_uint8_t grub_ofconsole_serial = 1; + static int grub_curr_x; static int grub_curr_y; @@ -70,20 +76,76 @@ static void grub_ofconsole_putchar (grub_uint32_t c) { - char chr = c; - - if (c == '\n') + char chr; + + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO)) { + /* cp437 characters 0xc0 to 0xcb are reserved for the bplan logo. Use + this layout to workaround it: + ╒═╕ + │ │ + ╘═╛ */ + switch (c) + { + case 0xc4: + /* GRUB_TERM_DISP_HLINE */ + c = 0xcd; + break; + case 0xb3: + /* GRUB_TERM_DISP_VLINE */ + c = 0xb3; + break; + case 0xda: + /* GRUB_TERM_DISP_UL */ + c = 0xd5; + break; + case 0xbf: + /* GRUB_TERM_DISP_UR */ + c = 0xb8; + break; + case 0xc0: + /* GRUB_TERM_DISP_LL */ + c = 0xd4; + break; + case 0xd9: + /* GRUB_TERM_DISP_LR */ + c = 0xbe; + break; + } + } + + switch(c) + { + case '\a': + break; + case '\n': + grub_putcode ('\r'); grub_curr_y++; + if(grub_curr_y > (grub_ofconsole_height - 1)) + /* Is this realy correct for all OF versions around ? */ + grub_curr_y = grub_ofconsole_fb ? + grub_curr_y - 4 : grub_ofconsole_height - 1; + break; + case '\r': grub_curr_x = 0; - } - else - { + break; + case '\b': + if(grub_curr_x > 0) + grub_curr_x--; + break; + + default: + if(c == '\t') + c = ' '; + + if (grub_curr_x >= (grub_ofconsole_width - 1)) + grub_putcode ('\n'); + grub_curr_x++; - if (grub_curr_x > grub_ofconsole_width) - grub_putcode ('\n'); - } + break; + } + chr = c; grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); } @@ -228,7 +290,7 @@ static grub_uint16_t grub_ofconsole_getxy (void) { - return ((grub_curr_x - 1) << 8) | grub_curr_y; + return (grub_curr_x << 8) | grub_curr_y; } static grub_uint16_t @@ -278,6 +340,10 @@ if (! grub_ofconsole_height) grub_ofconsole_height = 24; + if ( grub_ofconsole_fb == 0 && grub_ofconsole_serial == 0 && grub_ofconsole_height == 24 && + grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25)) + grub_ofconsole_height = 25; + return (grub_ofconsole_width << 8) | grub_ofconsole_height; } @@ -295,10 +361,20 @@ static void grub_ofconsole_cls (void) { - /* Clear the screen. Using serial console, screen(1) only recognizes the - * ANSI escape sequence. Using video console, Apple Open Firmware (version - * 3.1.1) only recognizes the literal ^L. So use both. */ - grub_ofconsole_writeesc ("\f\e[2J"); + if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOCLS)) + { + /* Clear the screen. Using serial console, screen(1) only recognizes the + * ANSI escape sequence. Using video console, Apple Open Firmware (version + * 3.1.1) only recognizes the literal ^L. So use both. */ + grub_ofconsole_writeesc ("\f\e[2J"); + } + else + { + /* It seems no cls escape is available then simulate it using \n flood */ + int x = (grub_ofconsole_height * 2) - grub_curr_y; + while(x--) + grub_putcode ('\n'); + } grub_gotoxy (0, 0); } @@ -317,6 +393,7 @@ static grub_err_t grub_ofconsole_init (void) { + grub_ieee1275_phandle_t stdout_phandle; unsigned char data[4]; grub_ssize_t actual; int col; @@ -349,6 +426,48 @@ /* Set the right fg and bg colors. */ grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL); + /* Check do we are on serial or normal console */ + if(! grub_ieee1275_instance_to_package (stdout_ihandle, &stdout_phandle)) + { + char type[16]; + char name[128]; + + if(! grub_ieee1275_get_property (stdout_phandle, "device_type", &type, + sizeof type, 0) && + ! grub_ieee1275_get_property (stdout_phandle, "name", &name, + sizeof name, 0)) + { + /* + * In general type "serial" is used for console without + * framebuffer support in recent firmware versions then + * we need to check the name too to determine is it real or + * serial console + */ + + if (! grub_strcmp (type, "serial")) + { + /* If "name" is something else than "display" we assume serial console */ + if(! grub_strcmp (name, "display")) + grub_ofconsole_serial = 0; + } + else + { + grub_ofconsole_serial = 0; + + /* Older versions use name/type set to "bootconsole" */ + if ( grub_strcmp (name, "bootconsole")) + grub_ofconsole_fb = 1; + } + } + } + + /* Set term flags */ + if(!grub_ofconsole_serial && !grub_ofconsole_fb) + { + grub_ofconsole_setflags(GRUB_TERM_SIMPLE_MENU, 0); + grub_ofconsole_setflags(GRUB_TERM_CP437_MENU, 1); + } + return 0; } @@ -377,7 +496,7 @@ .setcolor = grub_ofconsole_setcolor, .setcursor = grub_ofconsole_setcursor, .refresh = grub_ofconsole_refresh, - .flags = GRUB_TERM_SIMPLE_MENU, + .flags = GRUB_TERM_SIMPLE_MENU, /* We are set to serial by default */ .next = 0 }; @@ -393,3 +512,12 @@ { grub_term_unregister (&grub_ofconsole_term); } + +static void +grub_ofconsole_setflags(int flags, int x) +{ + if(x) + grub_ofconsole_term.flags |= flags; + else + grub_ofconsole_term.flags &= ~flags; +} ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-10 15:11 ` Marcin Kurek @ 2007-10-10 19:19 ` Robert Millan 2007-10-10 21:57 ` Marcin Kurek 0 siblings, 1 reply; 21+ messages in thread From: Robert Millan @ 2007-10-10 19:19 UTC (permalink / raw) To: The development of GRUB 2 On Wed, Oct 10, 2007 at 05:11:13PM +0200, Marcin Kurek wrote: > Hell[o] > > > Avoid the cosmetical changes! (there are more thorough the patch) > > Arghh, I was sure I removed it :/ Anyway attached updated console patches. Great, thank you. > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-07-22 11:05:11.000000000 +0200 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-10 16:03:34.136688149 +0200 > @@ -75,6 +75,7 @@ > grub_ofconsole_putchar (grub_uint32_t c) > { > char chr = c; > + > if (c == '\n') Caught you! ;-) > diff -urN grub2.org/include/grub/ieee1275/ieee1275.h grub2/include/grub/ieee1275/ieee1275.h > --- grub2.org/include/grub/ieee1275/ieee1275.h 2007-10-04 22:44:12.000000000 +0200 > +++ grub2/include/grub/ieee1275/ieee1275.h 2007-10-10 16:41:39.594688149 +0200 > @@ -82,6 +82,16 @@ > > /* CodeGen firmware does not correctly implement "output-device output" */ > GRUB_IEEE1275_FLAG_BROKEN_OUTPUT, > + > + /* In non fb mode default number of console rows is 24, but in fact it's 25 */ > + GRUB_IEEE1275_FLAG_NOFB_ROWS25, > + > + /* Old Pegaos firmware does not accept cls escape sequence */ > + GRUB_IEEE1275_FLAG_NOCLS, > + > + /* On CodeGen firmware, cp437 characters 0xc0 to 0xcb are reserved for the > + bplan logo */ > + GRUB_IEEE1275_FLAG_BPLAN_LOGO, > }; I know it seems burdensome, but please can you split this in three patches, one for each fix? Then it's easier to review just one and say "this is good", and also easier to figure out why every hunk was done (since one knows what we're trying to archieve). > + /* It seems no cls escape is available then simulate it using \n flood */ > + int x = (grub_ofconsole_height * 2) - grub_curr_y; Maybe this would be easier to understand as "(grub_ofconsole_height - grub_curr_y) + grub_ofconsole_height". What do others think? :-) > + /* Check do we are on serial or normal console */ > + if(! grub_ieee1275_instance_to_package (stdout_ihandle, &stdout_phandle)) > + { > + char type[16]; > + char name[128]; > + > + if(! grub_ieee1275_get_property (stdout_phandle, "device_type", &type, > + sizeof type, 0) && > + ! grub_ieee1275_get_property (stdout_phandle, "name", &name, > + sizeof name, 0)) > + { > + /* > + * In general type "serial" is used for console without > + * framebuffer support in recent firmware versions then > + * we need to check the name too to determine is it real or > + * serial console > + */ > + > + if (! grub_strcmp (type, "serial")) > + { > + /* If "name" is something else than "display" we assume serial console */ > + if(! grub_strcmp (name, "display")) > + grub_ofconsole_serial = 0; > + } > + else > + { > + grub_ofconsole_serial = 0; > + > + /* Older versions use name/type set to "bootconsole" */ > + if ( grub_strcmp (name, "bootconsole")) > + grub_ofconsole_fb = 1; > + } > + } > + } Nice. On which firmware variants did you try this? I can try efika (stock firmware) if you haven't yet. In your code there's a condition in which _serial is set to 0 and _fb is left unset (as 0). Is this intended? Sounds like a bug. This could be avoided if you represent it as a multi-value variable, e.g. enum { GRUB_OFCONSOLE_SERIAL, GRUB_OFCONSOLE_FB, }; grub_u8_t grub_ofconsole_backend = GRUB_OFCONSOLE_SERIAL; [...] if (foo) grub_ofconsole_backend = GRUB_OFCONSOLE_FB; what do you think? -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.) ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-10 19:19 ` Robert Millan @ 2007-10-10 21:57 ` Marcin Kurek 2007-10-11 14:01 ` Robert Millan 0 siblings, 1 reply; 21+ messages in thread From: Marcin Kurek @ 2007-10-10 21:57 UTC (permalink / raw) To: The development of GRUB 2 Hell[o] > Caught you! ;-) Holy shit. Lesson one take one more look at diff before send it :) > I know it seems burdensome, but please can you split this in three patches, one > for each fix? Then it's easier to review just one and say "this is good", and > also easier to figure out why every hunk was done (since one knows what we're > trying to archieve). Hmmm, I can try, but generaly splitting this fix has only a little sense as all of these patches depends on each other. Anyway I will send splited patches tommorow. > > + /* It seems no cls escape is available then simulate it using \n flood */ > > + int x = (grub_ofconsole_height * 2) - grub_curr_y; > > Maybe this would be easier to understand as "(grub_ofconsole_height - > grub_curr_y) + grub_ofconsole_height". What do others think? :-) Hmmm, good point looks better IMHO. > Nice. On which firmware variants did you try this? I can try efika (stock > firmware) if you haven't yet. I tired on Pegasos 1 with ancient OF revision, Pegasos 2 with Sven unofficial one and Efika and it works in all cases. > In your code there's a condition in which _serial is set to 0 and _fb is > left unset (as 0). Is this intended? Sounds like a bug. Not this is not a bug. We can heve 3 cases here: 1) True serial console. In this case recent versions of OF set stdout name and type to "serial" (_serial = 1, _fb = 0) In this case we want to use simple frames. 2) On the screen terminal without framebuffer (fb-mode not existing or set to 0x0x0) In this case we will get type "serial" (As it not supports pixel operations) and name "display" as this is not real serial console. (_serial = 0, _fb = 0) In this case we can use cp437 frames. For old versions of OF this case need to catch "bootconsole" too. 3) Console with framebuffer (fb-mode != 0x0x0) In this case we will get type to "display" or "vga" (_serial = 0, _fb = 1) In this case we can not use cp437 frames as vga font used by OF maps only first 127 characters ;( I put this in to separate case as we can still use framebuffer interface to draw some frames or try to load a working font, etc. I use 'true serial' as a safe default if detection fails for some reasons. -- --- Marcin 'Morgoth' Kurek --- ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-10 21:57 ` Marcin Kurek @ 2007-10-11 14:01 ` Robert Millan 0 siblings, 0 replies; 21+ messages in thread From: Robert Millan @ 2007-10-11 14:01 UTC (permalink / raw) To: The development of GRUB 2 On Wed, Oct 10, 2007 at 11:57:44PM +0200, Marcin Kurek wrote: > > In your code there's a condition in which _serial is set to 0 and _fb is > > left unset (as 0). Is this intended? Sounds like a bug. > > Not this is not a bug. We can heve 3 cases here: > > 1) True serial console. In this case recent versions of OF set stdout > name and type to "serial" (_serial = 1, _fb = 0) In this case we want > to use simple frames. > > 2) On the screen terminal without framebuffer (fb-mode not existing or > set to 0x0x0) In this case we will get type "serial" (As it not > supports pixel operations) and name "display" as this is not real > serial console. (_serial = 0, _fb = 0) In this case we can use cp437 > frames. > > For old versions of OF this case need to catch "bootconsole" too. > > 3) Console with framebuffer (fb-mode != 0x0x0) In this case we will > get type to "display" or "vga" (_serial = 0, _fb = 1) In this case we > can not use cp437 frames as vga font used by OF maps only first 127 > characters ;( I put this in to separate case as we can still use > framebuffer interface to draw some frames or try to load a working > font, etc. > > I use 'true serial' as a safe default if detection fails for some reasons. Ok but do we really need to make that distinction? Perhaps it would be simpler to define a structure that only cares about charset capability, and make code that plays with charsets just check that, without caring if it's a serial cable or a vga with old firmware, etc. And possibly this could be integrated with your proposed use of grub_term.flags ? (I'm not sure if that would make sense, but it would be nice to simplify if possible) -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call, if you are unable to speak? (as seen on /.) ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-01 10:57 [PATCH] Fixed ieee1275 console Marcin Kurek 2007-10-01 12:31 ` Robert Millan 2007-10-01 12:33 ` Robert Millan @ 2007-10-11 15:06 ` Marco Gerards 2007-10-12 16:16 ` Marcin Kurek 2007-10-15 20:43 ` Marcin Kurek 2007-11-18 12:11 ` Marco Gerards 3 siblings, 2 replies; 21+ messages in thread From: Marco Gerards @ 2007-10-11 15:06 UTC (permalink / raw) To: The development of GRUB 2 "Marcin Kurek" <morgoth6@gmail.com> writes: Hi Marcin, Sorry for the late reply. I have been absent for quite a while, but I intend to go over the emails on this list during the weekend (including yours). I noticed this email because I worked on this problem myself, so that is why I am replying now. > Finaly I found a few free minutes to look at ofconsole as it never > correctly work for me. There was 3 problems on my Pegasos: > > 1) Backspace key not works with USB keyboard. > 2) menu looks ugly like hell as it contains some random characters in > place of borders. Right, this is because it seems that the MSB is lost when writing a character to the screen. For the borders specific characters are used above 127 (non-ASCII). I wonder if the Pegasos console supports this ASCII extension if you change some settings or so... [...] > Replaced borders characters in grub_ofconsole_putchar() by '-', '|', > etc. Maybe not perfect, but looks definitly better than before [2]. > Also fixed cursor position tracking (grub_curr_x, grub_curr_y) which > fix both console problems [3] I prefer if it can be detected if this is Efika or for example an apple implementation of OF and handle these characters depending on that. IIRC this code does work on the apple, but unfortunately I cannot check this anymore. > Handle 127 keycode as backspace key in grub_ofconsole_readkey() which fix [1] Can you explain this? -- Marco ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-11 15:06 ` Marco Gerards @ 2007-10-12 16:16 ` Marcin Kurek 2007-11-10 17:05 ` Marco Gerards 2007-10-15 20:43 ` Marcin Kurek 1 sibling, 1 reply; 21+ messages in thread From: Marcin Kurek @ 2007-10-12 16:16 UTC (permalink / raw) To: The development of GRUB 2 Hell[o] > Right, this is because it seems that the MSB is lost when writing a > character to the screen. For the borders specific characters are used > above 127 (non-ASCII). I wonder if the Pegasos console supports this > ASCII extension if you change some settings or so... The problem is in framebuffer mode OF loads glyphs starting from 32 to 127 then any characters abowe 127 are displayed as white '?'. The solution would be to use "set-font" to load a proper font to use with grub. In non framebuffer mode cp437 is used by console then we can use it to draw borders same as for PC. > I prefer if it can be detected if this is Efika or for example an > apple implementation of OF and handle these characters depending on > that. IIRC this code does work on the apple, but unfortunately I > cannot check this anymore. Ahhh, I see you looked at first version of patch. Please take a look at recent version of my patches. > > Handle 127 keycode as backspace key in grub_ofconsole_readkey() which fix > [1] > > Can you explain this? For some reasons my OF sends \b && 127 (Del) sequence for backspace key. It seems to be same sa ncurses console. -- --- Marcin 'Morgoth' Kurek --- ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-12 16:16 ` Marcin Kurek @ 2007-11-10 17:05 ` Marco Gerards 2007-11-11 11:02 ` Marcin Kurek 0 siblings, 1 reply; 21+ messages in thread From: Marco Gerards @ 2007-11-10 17:05 UTC (permalink / raw) To: The development of GRUB 2 "Marcin Kurek" <morgoth6@gmail.com> writes: > Hell[o] > >> Right, this is because it seems that the MSB is lost when writing a >> character to the screen. For the borders specific characters are used >> above 127 (non-ASCII). I wonder if the Pegasos console supports this >> ASCII extension if you change some settings or so... > > The problem is in framebuffer mode OF loads glyphs starting from 32 to > 127 then any characters abowe 127 are displayed as white '?'. The > solution would be to use "set-font" to load a proper font to use with > grub. In non framebuffer mode cp437 is used by console then we can use > it to draw borders same as for PC. Can you provide something that makes use of that? >> I prefer if it can be detected if this is Efika or for example an >> apple implementation of OF and handle these characters depending on >> that. IIRC this code does work on the apple, but unfortunately I >> cannot check this anymore. > > Ahhh, I see you looked at first version of patch. Please take a look > at recent version of my patches. Will do :-) >> > Handle 127 keycode as backspace key in grub_ofconsole_readkey() which fix >> [1] >> >> Can you explain this? > > For some reasons my OF sends \b && 127 (Del) sequence for backspace > key. It seems to be same sa ncurses console. Ok. -- Marco ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-11-10 17:05 ` Marco Gerards @ 2007-11-11 11:02 ` Marcin Kurek 2007-11-18 11:37 ` Marco Gerards 0 siblings, 1 reply; 21+ messages in thread From: Marcin Kurek @ 2007-11-11 11:02 UTC (permalink / raw) To: The development of GRUB 2 Hell[o] > Can you provide something that makes use of that? Hmm, I should have example code somewhere on disk. I will try to find it. > Will do :-) I already send e-mail to fsf today as there was no reply to my previous e-mail. -- --- Marcin 'Morgoth' Kurek --- ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-11-11 11:02 ` Marcin Kurek @ 2007-11-18 11:37 ` Marco Gerards 0 siblings, 0 replies; 21+ messages in thread From: Marco Gerards @ 2007-11-18 11:37 UTC (permalink / raw) To: The development of GRUB 2 "Marcin Kurek" <morgoth6@gmail.com> writes: Hi, >> Can you provide something that makes use of that? > > Hmm, I should have example code somewhere on disk. I will try to find it. :-) >> Will do :-) > > I already send e-mail to fsf today as there was no reply to my previous e-mail. Great! -- Marco ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-11 15:06 ` Marco Gerards 2007-10-12 16:16 ` Marcin Kurek @ 2007-10-15 20:43 ` Marcin Kurek 2007-11-18 13:18 ` Marco Gerards 1 sibling, 1 reply; 21+ messages in thread From: Marcin Kurek @ 2007-10-15 20:43 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 3376 bytes --] Hell[o] > I prefer if it can be detected if this is Efika or for example an > apple implementation of OF and handle these characters depending on > that. IIRC this code does work on the apple, but unfortunately I > cannot check this anymore. Attached current console patchset. The graphical frames workaround is used only for SmartFirmware then Apple machines should get cp437 frames normaly. Sorry still no time to split it :( Anyway I will try to explain a bit each of them. ======== Simple Console: Generaly it seems cp437 frames are used on pc, same for simple frames using '-' characters which are used for ncurses console and serial console on pc. I think keep same code in many places is not so good idea then I moved conversion rutines in to one place and introduce two term flags GRUB_TERM_SIMPLE_MENU and GRUB_TERM_CP437_MENU. In case when term has GRUB_TERM_SIMPLE_MENU set it would automaticly use '-' frames and same for GRUB_TERM_CP437_MENU to use cp437 frames. If no flags is set there would be no charset translation for frames. Cosmetic: In general I see no reason to use multiple grub_ieee1275_write() calls if we can use single one. Nothing important, but good to have IMHO. Backspace: As I already wrote my version of OF seems to sent \b && <del> sequence for backspace key. This change cause no side effects on Efika (USB keyboard) and Pegasos 1 with PS/2 keyboard. Can anyone check it on Apple OF ? In case of any troubles we can still use a IEEE1275 flag to use it only for SmartFw. OFConsole: A biggest patch in pack. Generaly the grub console is completly broken here (Pegasos 1 && 2, Efika) The x/y cursor tracking not works as expect to and cursor position is random after few written lines. Generaly I introduce realy working x/y position tracking and in result this give me a working console output in all cases (no random cursor position after 'ls' command, no empty screen after more than one output, etc) Second change was detection of console type (serial, screen, framebuffer) The reason was to draw frames which looks good in all three. Default ofconsole uses now simple frames (same for serial console) and switch to cp437 frames if detect normal screen console, unfortunatly if of uses framebuffer mode (efika, unofficial OF upgrade for Pegasos 2) we can not use this frame type as framebuffer font lack required characters. The reason why framebuffer mode and serial mode are separated is planned vesa support as I already have a basic vesa framework we will be able to use it when finished (Then simple frames on serial console, cp437 on normal console and graphical frames on framebuffer) This code uses some new flags: GRUB_IEEE1275_FLAG_NOFB_ROWS25: For some reason all versions of SF has 25 rows on normal console, but report only 24 which broke the grub console. This flag was added to workaround this problem. GRUB_IEEE1275_FLAG_NOCLS: Pegasos 1 OF seems to not interpret the cls escape then if detected we use \n workaround. GRUB_IEEE1275_FLAG_BPLAN_LOGO: Arghhh, we can use cp437 frames on pegasos, but it seems a parts of characters used by grub are replaced by bPlan logo. Use a workaround proposed here in this case and in a result have a nice looking grub menu on pegasos/efika too. I hope I explain everything here. In another e-mail I attach rest of my patches for grub. -- --- Marcin 'Morgoth' Kurek --- [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 01-grub2-simple_console.patch --] [-- Type: text/x-patch; name="01-grub2-simple_console.patch", Size: 10613 bytes --] diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h --- grub2.org/include/grub/term.h 2007-07-22 01:32:22.000000000 +0200 +++ grub2/include/grub/term.h 2007-10-15 21:26:48.401210358 +0200 @@ -51,6 +51,10 @@ #define GRUB_TERM_NO_EDIT (1 << 1) /* Set when the terminal cannot do fancy things. */ #define GRUB_TERM_DUMB (1 << 2) +/* Set to use ascii menu borders. */ +#define GRUB_TERM_SIMPLE_MENU (1 << 3) +/* Set to use cp437 menu borders. */ +#define GRUB_TERM_CP437_MENU (1 << 4) /* Set when the terminal needs to be initialized. */ #define GRUB_TERM_NEED_INIT (1 << 16) diff -urN grub2.org/kern/term.c grub2/kern/term.c --- grub2.org/kern/term.c 2007-07-22 01:32:26.000000000 +0200 +++ grub2/kern/term.c 2007-10-15 21:26:48.402210358 +0200 @@ -90,6 +90,94 @@ return grub_cur_term; } +static +grub_uint32_t remap_border(grub_uint32_t code) +{ + if (grub_cur_term->flags & GRUB_TERM_SIMPLE_MENU) + { + switch (code) + { + case GRUB_TERM_DISP_LEFT: + code = '<'; + break; + + case GRUB_TERM_DISP_UP: + code = '^'; + break; + + case GRUB_TERM_DISP_RIGHT: + code = '>'; + break; + + case GRUB_TERM_DISP_DOWN: + code = 'v'; + break; + + case GRUB_TERM_DISP_HLINE: + code = '-'; + break; + + case GRUB_TERM_DISP_VLINE: + code = '|'; + break; + + case GRUB_TERM_DISP_UL: + case GRUB_TERM_DISP_UR: + case GRUB_TERM_DISP_LL: + case GRUB_TERM_DISP_LR: + code = '+'; + break; + } + } + else if(grub_cur_term->flags & GRUB_TERM_CP437_MENU) + { + switch (code) + { + case GRUB_TERM_DISP_LEFT: + code = 0x1b; + break; + + case GRUB_TERM_DISP_UP: + code = 0x18; + break; + + case GRUB_TERM_DISP_RIGHT: + code = 0x1a; + break; + + case GRUB_TERM_DISP_DOWN: + code = 0x19; + break; + + case GRUB_TERM_DISP_HLINE: + code = 0xc4; + break; + + case GRUB_TERM_DISP_VLINE: + code = 0xb3; + break; + + case GRUB_TERM_DISP_UL: + code = 0xda; + break; + + case GRUB_TERM_DISP_UR: + code = 0xbf; + break; + + case GRUB_TERM_DISP_LL: + code = 0xc0; + break; + + case GRUB_TERM_DISP_LR: + code = 0xd9; + break; + } + } + + return code; +} + /* Put a Unicode character. */ void grub_putcode (grub_uint32_t code) @@ -107,6 +195,8 @@ return; } + code = remap_border (code); + (grub_cur_term->putchar) (code); if (code == '\n') diff -urN grub2.org/term/i386/pc/console.c grub2/term/i386/pc/console.c --- grub2.org/term/i386/pc/console.c 2007-07-22 01:32:30.000000000 +0200 +++ grub2/term/i386/pc/console.c 2007-10-15 21:26:48.403210358 +0200 @@ -25,58 +25,13 @@ static grub_uint8_t grub_console_normal_color = 0x7; static grub_uint8_t grub_console_highlight_color = 0x70; -static grub_uint32_t -map_char (grub_uint32_t c) -{ - if (c > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (c) - { - case 0x2190: /* left arrow */ - c = 0x1b; - break; - case 0x2191: /* up arrow */ - c = 0x18; - break; - case 0x2192: /* right arrow */ - c = 0x1a; - break; - case 0x2193: /* down arrow */ - c = 0x19; - break; - case 0x2501: /* horizontal line */ - c = 0xc4; - break; - case 0x2503: /* vertical line */ - c = 0xb3; - break; - case 0x250F: /* upper-left corner */ - c = 0xda; - break; - case 0x2513: /* upper-right corner */ - c = 0xbf; - break; - case 0x2517: /* lower-left corner */ - c = 0xc0; - break; - case 0x251B: /* lower-right corner */ - c = 0xd9; - break; - - default: - c = '?'; - break; - } - } - - return c; -} - static void grub_console_putchar (grub_uint32_t c) { - grub_console_real_putchar (map_char (c)); + /* No Unicode support. */ + if (c > 0x7f) + c = '?'; + grub_console_real_putchar (c); } static grub_ssize_t @@ -133,7 +88,7 @@ .setcolorstate = grub_console_setcolorstate, .setcolor = grub_console_setcolor, .setcursor = grub_console_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/serial.c grub2/term/i386/pc/serial.c --- grub2.org/term/i386/pc/serial.c 2007-07-22 01:32:30.000000000 +0200 +++ grub2/term/i386/pc/serial.c 2007-10-15 21:26:48.405210358 +0200 @@ -324,48 +324,9 @@ /* Keep track of the cursor. */ if (keep_track) { - /* The serial terminal does not have VGA fonts. */ + /* The serial terminal does not support Unicode. */ if (c > 0x7F) - { - /* Better than nothing. */ - switch (c) - { - case GRUB_TERM_DISP_LEFT: - c = '<'; - break; - - case GRUB_TERM_DISP_UP: - c = '^'; - break; - - case GRUB_TERM_DISP_RIGHT: - c = '>'; - break; - - case GRUB_TERM_DISP_DOWN: - c = 'v'; - break; - - case GRUB_TERM_DISP_HLINE: - c = '-'; - break; - - case GRUB_TERM_DISP_VLINE: - c = '|'; - break; - - case GRUB_TERM_DISP_UL: - case GRUB_TERM_DISP_UR: - case GRUB_TERM_DISP_LL: - case GRUB_TERM_DISP_LR: - c = '+'; - break; - - default: - c = '?'; - break; - } - } + c = '?'; switch (c) { @@ -498,7 +459,7 @@ .setcolorstate = grub_serial_setcolorstate, .setcolor = grub_serial_setcolor, .setcursor = grub_serial_setcursor, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/vesafb.c grub2/term/i386/pc/vesafb.c --- grub2.org/term/i386/pc/vesafb.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/term/i386/pc/vesafb.c 2007-10-15 21:26:48.418210358 +0200 @@ -214,45 +214,7 @@ unsigned *width) { if (code > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (code) - { - case 0x2190: /* left arrow */ - code = 0x1b; - break; - case 0x2191: /* up arrow */ - code = 0x18; - break; - case 0x2192: /* right arrow */ - code = 0x1a; - break; - case 0x2193: /* down arrow */ - code = 0x19; - break; - case 0x2501: /* horizontal line */ - code = 0xc4; - break; - case 0x2503: /* vertical line */ - code = 0xb3; - break; - case 0x250F: /* upper-left corner */ - code = 0xda; - break; - case 0x2513: /* upper-right corner */ - code = 0xbf; - break; - case 0x2517: /* lower-left corner */ - code = 0xc0; - break; - case 0x251B: /* lower-right corner */ - code = 0xd9; - break; - - default: - return grub_font_get_glyph (code, bitmap, width); - } - } + return grub_font_get_glyph (code, bitmap, width); if (bitmap) grub_memcpy (bitmap, @@ -601,7 +563,7 @@ .setcolorstate = grub_virtual_screen_setcolorstate, .setcolor = grub_virtual_screen_setcolor, .setcursor = grub_vesafb_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/i386/pc/vga.c grub2/term/i386/pc/vga.c --- grub2.org/term/i386/pc/vga.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/term/i386/pc/vga.c 2007-10-15 21:26:48.447210358 +0200 @@ -198,45 +198,7 @@ get_vga_glyph (grub_uint32_t code, unsigned char bitmap[32], unsigned *width) { if (code > 0x7f) - { - /* Map some unicode characters to the VGA font, if possible. */ - switch (code) - { - case 0x2190: /* left arrow */ - code = 0x1b; - break; - case 0x2191: /* up arrow */ - code = 0x18; - break; - case 0x2192: /* right arrow */ - code = 0x1a; - break; - case 0x2193: /* down arrow */ - code = 0x19; - break; - case 0x2501: /* horizontal line */ - code = 0xc4; - break; - case 0x2503: /* vertical line */ - code = 0xb3; - break; - case 0x250F: /* upper-left corner */ - code = 0xda; - break; - case 0x2513: /* upper-right corner */ - code = 0xbf; - break; - case 0x2517: /* lower-left corner */ - code = 0xc0; - break; - case 0x251B: /* lower-right corner */ - code = 0xd9; - break; - - default: - return grub_font_get_glyph (code, bitmap, width); - } - } + return grub_font_get_glyph (code, bitmap, width); if (bitmap) grub_memcpy (bitmap, vga_font + code * CHAR_HEIGHT, CHAR_HEIGHT); @@ -590,7 +552,7 @@ .setcolorstate = grub_vga_setcolorstate, .setcolor = grub_vga_setcolor, .setcursor = grub_vga_setcursor, - .flags = 0, + .flags = GRUB_TERM_CP437_MENU, .next = 0 }; diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-07-22 11:05:11.000000000 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-15 21:27:17.621210358 +0200 @@ -366,7 +366,7 @@ .setcolor = grub_ofconsole_setcolor, .setcursor = grub_ofconsole_setcursor, .refresh = grub_ofconsole_refresh, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; diff -urN grub2.org/util/console.c grub2/util/console.c --- grub2.org/util/console.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/util/console.c 2007-10-15 21:26:48.456210358 +0200 @@ -44,47 +44,6 @@ static void grub_ncurses_putchar (grub_uint32_t c) { - /* Better than nothing. */ - switch (c) - { - case GRUB_TERM_DISP_LEFT: - c = '<'; - break; - - case GRUB_TERM_DISP_UP: - c = '^'; - break; - - case GRUB_TERM_DISP_RIGHT: - c = '>'; - break; - - case GRUB_TERM_DISP_DOWN: - c = 'v'; - break; - - case GRUB_TERM_DISP_HLINE: - c = '-'; - break; - - case GRUB_TERM_DISP_VLINE: - c = '|'; - break; - - case GRUB_TERM_DISP_UL: - case GRUB_TERM_DISP_UR: - case GRUB_TERM_DISP_LL: - case GRUB_TERM_DISP_LR: - c = '+'; - break; - - default: - /* ncurses does not support Unicode. */ - if (c > 0x7f) - c = '?'; - break; - } - addch (c | grub_console_attr); } @@ -302,7 +261,7 @@ .setcolor = grub_ncurses_setcolor, .setcursor = grub_ncurses_setcursor, .refresh = grub_ncurses_refresh, - .flags = 0, + .flags = GRUB_TERM_SIMPLE_MENU, .next = 0 }; [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #3: 02-grub2-ofconsole_cosmetic.patch --] [-- Type: text/x-patch; name="02-grub2-ofconsole_cosmetic.patch", Size: 526 bytes --] diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-03 10:55:27.191943734 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-03 10:56:26.399943734 +0200 @@ -63,12 +63,8 @@ static void grub_ofconsole_writeesc (const char *str) { - while (*str) - { - char chr = *(str++); - grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); - } - + int len = grub_strlen(str); + grub_ieee1275_write (stdout_ihandle, str, len, 0); } static void [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #4: 03-grub2-ofconsole_backspace.patch --] [-- Type: text/x-patch; name="03-grub2-ofconsole_backspace.patch", Size: 1695 bytes --] diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-15 21:23:24.554210358 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-15 21:24:13.111210358 +0200 @@ -135,41 +135,54 @@ grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual > 0 && c == '\e') + if (actual > 0) { - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual <= 0) - { - *key = '\e'; - return 1; - } + if (c != '\e') + { + switch(c) + { + case 127: + /* Backspace */ + c = '\b'; + break; + } + } + else + { + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); + if (actual <= 0) + { + *key = '\e'; + return 1; + } - if (c != 91) - return 0; + if (c != 91) + return 0; - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); - if (actual <= 0) - return 0; + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); + if (actual <= 0) + return 0; - switch (c) - { - case 65: - /* Up: Ctrl-p. */ - c = 16; - break; - case 66: - /* Down: Ctrl-n. */ - c = 14; - break; - case 67: - /* Right: Ctrl-f. */ - c = 6; - break; - case 68: - /* Left: Ctrl-b. */ - c = 2; - break; - } + switch (c) + { + case 65: + /* Up: Ctrl-p. */ + c = 16; + break; + case 66: + /* Down: Ctrl-n. */ + c = 14; + break; + case 67: + /* Right: Ctrl-f. */ + c = 6; + break; + case 68: + /* Left: Ctrl-b. */ + c = 2; + break; + } + } } *key = c; [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #5: 04-grub2-ofconsole_fix.patch --] [-- Type: text/x-patch; name="04-grub2-ofconsole_fix.patch", Size: 8448 bytes --] diff -urN grub2.org/include/grub/ieee1275/ieee1275.h grub2/include/grub/ieee1275/ieee1275.h --- grub2.org/include/grub/ieee1275/ieee1275.h 2007-10-04 22:44:12.000000000 +0200 +++ grub2/include/grub/ieee1275/ieee1275.h 2007-10-10 16:41:39.594688149 +0200 @@ -82,6 +82,16 @@ /* CodeGen firmware does not correctly implement "output-device output" */ GRUB_IEEE1275_FLAG_BROKEN_OUTPUT, + + /* In non fb mode default number of console rows is 24, but in fact it's 25 */ + GRUB_IEEE1275_FLAG_NOFB_ROWS25, + + /* Old Pegaos firmware does not accept cls escape sequence */ + GRUB_IEEE1275_FLAG_NOCLS, + + /* On CodeGen firmware, cp437 characters 0xc0 to 0xcb are reserved for the + bplan logo */ + GRUB_IEEE1275_FLAG_BPLAN_LOGO, }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); diff -urN grub2.org/kern/powerpc/ieee1275/cmain.c grub2/kern/powerpc/ieee1275/cmain.c --- grub2.org/kern/powerpc/ieee1275/cmain.c 2007-10-04 22:44:12.000000000 +0200 +++ grub2/kern/powerpc/ieee1275/cmain.c 2007-10-10 16:42:30.520688149 +0200 @@ -73,6 +73,8 @@ { /* Broken in all versions */ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25); + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO); /* There are two incompatible ways of checking the version number. Try both. */ @@ -98,6 +100,13 @@ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0); grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); } + /* It seems old firmware for Pegaos 1 do not accept cls escape then + we need to emulate it using \n sequence */ + if (!grub_strcmp (tmp, "1.0") + || !grub_strcmp (tmp, "1.1")) + { + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOCLS); + } } } } diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-04 22:44:12.000000000 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-10 16:51:56.829688149 +0200 @@ -24,12 +24,18 @@ #include <grub/machine/console.h> #include <grub/ieee1275/ieee1275.h> +static void grub_ofconsole_setflags(int flags, int x); + static grub_ieee1275_ihandle_t stdout_ihandle; static grub_ieee1275_ihandle_t stdin_ihandle; static grub_uint8_t grub_ofconsole_width; static grub_uint8_t grub_ofconsole_height; +/* We will assume serial console by default */ +static grub_uint8_t grub_ofconsole_fb = 0; +static grub_uint8_t grub_ofconsole_serial = 1; + static int grub_curr_x; static int grub_curr_y; @@ -70,20 +76,76 @@ static void grub_ofconsole_putchar (grub_uint32_t c) { - char chr = c; - - if (c == '\n') + char chr; + + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO)) { + /* cp437 characters 0xc0 to 0xcb are reserved for the bplan logo. Use + this layout to workaround it: + ╒═╕ + │ │ + ╘═╛ */ + switch (c) + { + case 0xc4: + /* GRUB_TERM_DISP_HLINE */ + c = 0xcd; + break; + case 0xb3: + /* GRUB_TERM_DISP_VLINE */ + c = 0xb3; + break; + case 0xda: + /* GRUB_TERM_DISP_UL */ + c = 0xd5; + break; + case 0xbf: + /* GRUB_TERM_DISP_UR */ + c = 0xb8; + break; + case 0xc0: + /* GRUB_TERM_DISP_LL */ + c = 0xd4; + break; + case 0xd9: + /* GRUB_TERM_DISP_LR */ + c = 0xbe; + break; + } + } + + switch(c) + { + case '\a': + break; + case '\n': + grub_putcode ('\r'); grub_curr_y++; + if(grub_curr_y > (grub_ofconsole_height - 1)) + /* Is this realy correct for all OF versions around ? */ + grub_curr_y = grub_ofconsole_fb ? + grub_curr_y - 4 : grub_ofconsole_height - 1; + break; + case '\r': grub_curr_x = 0; - } - else - { + break; + case '\b': + if(grub_curr_x > 0) + grub_curr_x--; + break; + + default: + if(c == '\t') + c = ' '; + + if (grub_curr_x >= (grub_ofconsole_width - 1)) + grub_putcode ('\n'); + grub_curr_x++; - if (grub_curr_x > grub_ofconsole_width) - grub_putcode ('\n'); - } + break; + } + chr = c; grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); } @@ -228,7 +290,7 @@ static grub_uint16_t grub_ofconsole_getxy (void) { - return ((grub_curr_x - 1) << 8) | grub_curr_y; + return (grub_curr_x << 8) | grub_curr_y; } static grub_uint16_t @@ -278,6 +340,10 @@ if (! grub_ofconsole_height) grub_ofconsole_height = 24; + if ( grub_ofconsole_fb == 0 && grub_ofconsole_serial == 0 && grub_ofconsole_height == 24 && + grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25)) + grub_ofconsole_height = 25; + return (grub_ofconsole_width << 8) | grub_ofconsole_height; } @@ -295,10 +361,20 @@ static void grub_ofconsole_cls (void) { - /* Clear the screen. Using serial console, screen(1) only recognizes the - * ANSI escape sequence. Using video console, Apple Open Firmware (version - * 3.1.1) only recognizes the literal ^L. So use both. */ - grub_ofconsole_writeesc ("\f\e[2J"); + if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOCLS)) + { + /* Clear the screen. Using serial console, screen(1) only recognizes the + * ANSI escape sequence. Using video console, Apple Open Firmware (version + * 3.1.1) only recognizes the literal ^L. So use both. */ + grub_ofconsole_writeesc ("\f\e[2J"); + } + else + { + /* It seems no cls escape is available then simulate it using \n flood */ + int x = (grub_ofconsole_height * 2) - grub_curr_y; + while(x--) + grub_putcode ('\n'); + } grub_gotoxy (0, 0); } @@ -317,6 +393,7 @@ static grub_err_t grub_ofconsole_init (void) { + grub_ieee1275_phandle_t stdout_phandle; unsigned char data[4]; grub_ssize_t actual; int col; @@ -349,6 +426,48 @@ /* Set the right fg and bg colors. */ grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL); + /* Check do we are on serial or normal console */ + if(! grub_ieee1275_instance_to_package (stdout_ihandle, &stdout_phandle)) + { + char type[16]; + char name[128]; + + if(! grub_ieee1275_get_property (stdout_phandle, "device_type", &type, + sizeof type, 0) && + ! grub_ieee1275_get_property (stdout_phandle, "name", &name, + sizeof name, 0)) + { + /* + * In general type "serial" is used for console without + * framebuffer support in recent firmware versions then + * we need to check the name too to determine is it real or + * serial console + */ + + if (! grub_strcmp (type, "serial")) + { + /* If "name" is something else than "display" we assume serial console */ + if(! grub_strcmp (name, "display")) + grub_ofconsole_serial = 0; + } + else + { + grub_ofconsole_serial = 0; + + /* Older versions use name/type set to "bootconsole" */ + if ( grub_strcmp (name, "bootconsole")) + grub_ofconsole_fb = 1; + } + } + } + + /* Set term flags */ + if(!grub_ofconsole_serial && !grub_ofconsole_fb) + { + grub_ofconsole_setflags(GRUB_TERM_SIMPLE_MENU, 0); + grub_ofconsole_setflags(GRUB_TERM_CP437_MENU, 1); + } + return 0; } @@ -377,7 +496,7 @@ .setcolor = grub_ofconsole_setcolor, .setcursor = grub_ofconsole_setcursor, .refresh = grub_ofconsole_refresh, - .flags = GRUB_TERM_SIMPLE_MENU, + .flags = GRUB_TERM_SIMPLE_MENU, /* We are set to serial by default */ .next = 0 }; @@ -393,3 +512,12 @@ { grub_term_unregister (&grub_ofconsole_term); } + +static void +grub_ofconsole_setflags(int flags, int x) +{ + if(x) + grub_ofconsole_term.flags |= flags; + else + grub_ofconsole_term.flags &= ~flags; +} ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-15 20:43 ` Marcin Kurek @ 2007-11-18 13:18 ` Marco Gerards 0 siblings, 0 replies; 21+ messages in thread From: Marco Gerards @ 2007-11-18 13:18 UTC (permalink / raw) To: The development of GRUB 2 "Marcin Kurek" <morgoth6@gmail.com> writes: Hi, >> I prefer if it can be detected if this is Efika or for example an >> apple implementation of OF and handle these characters depending on >> that. IIRC this code does work on the apple, but unfortunately I >> cannot check this anymore. > > Attached current console patchset. The graphical frames workaround is > used only for SmartFirmware then Apple machines should get cp437 > frames normaly. Sorry still no time to split it :( Anyway I will try > to explain a bit each of them. Whoops, I almost missed this patch :-) > Simple Console: Generaly it seems cp437 frames are used on pc, same > for simple frames using '-' characters which are used for ncurses > console and serial console on pc. I think keep same code in many > places is not so good idea then I moved conversion rutines in to one > place and introduce two term flags GRUB_TERM_SIMPLE_MENU and > GRUB_TERM_CP437_MENU. > > In case when term has GRUB_TERM_SIMPLE_MENU set it would automaticly > use '-' frames and same for GRUB_TERM_CP437_MENU to use cp437 frames. > If no flags is set there would be no charset translation for frames. AFAIK it is not certain if it is CP437 that is used. This is just the case for PPC. > Cosmetic: In general I see no reason to use multiple > grub_ieee1275_write() calls if we can use single one. Nothing > important, but good to have IMHO. Right, we can use this and always revert if it causes problems. > Backspace: As I already wrote my version of OF seems to sent \b && > <del> sequence for backspace key. This change cause no side effects on > Efika (USB keyboard) and Pegasos 1 with PS/2 keyboard. Can anyone > check it on Apple OF ? In case of any troubles we can still use a > IEEE1275 flag to use it only for SmartFw. Right. > OFConsole: A biggest patch in pack. Generaly the grub console is > completly broken here (Pegasos 1 && 2, Efika) The x/y cursor tracking > not works as expect to and cursor position is random after few written > lines. Right. > Generaly I introduce realy working x/y position tracking and in result > this give me a working console output in all cases (no random cursor > position after 'ls' command, no empty screen after more than one > output, etc) Great! > Second change was detection of console type (serial, screen, > framebuffer) The reason was to draw frames which looks good in all > three. Default ofconsole uses now simple frames (same for serial > console) and switch to cp437 frames if detect normal screen console, > unfortunatly if of uses framebuffer mode (efika, unofficial OF upgrade > for Pegasos 2) we can not use this frame type as framebuffer font lack > required characters. The reason why framebuffer mode and serial mode > are separated is planned vesa support as I already have a basic vesa > framework we will be able to use it when finished (Then simple frames > on serial console, cp437 on normal console and graphical frames on > framebuffer) The PegasosII has VESA support!? > This code uses some new flags: > > GRUB_IEEE1275_FLAG_NOFB_ROWS25: For some reason all versions of SF has > 25 rows on normal console, but report only 24 which broke the grub > console. This flag was added to workaround this problem. Weird... > GRUB_IEEE1275_FLAG_NOCLS: Pegasos 1 OF seems to not interpret the cls > escape then if detected we use \n workaround. Ok. > GRUB_IEEE1275_FLAG_BPLAN_LOGO: Arghhh, we can use cp437 frames on > pegasos, but it seems a parts of characters used by grub are replaced > by bPlan logo. Use a workaround proposed here in this case and in a > result have a nice looking grub menu on pegasos/efika too. Workaround as in using ----- to draw the menu? > I hope I explain everything here. In another e-mail I attach rest of > my patches for grub. Great! > -- > --- Marcin 'Morgoth' Kurek --- > > diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h > --- grub2.org/include/grub/term.h 2007-07-22 01:32:22.000000000 +0200 > +++ grub2/include/grub/term.h 2007-10-15 21:26:48.401210358 +0200 > @@ -51,6 +51,10 @@ > #define GRUB_TERM_NO_EDIT (1 << 1) > /* Set when the terminal cannot do fancy things. */ > #define GRUB_TERM_DUMB (1 << 2) > +/* Set to use ascii menu borders. */ > +#define GRUB_TERM_SIMPLE_MENU (1 << 3) > +/* Set to use cp437 menu borders. */ > +#define GRUB_TERM_CP437_MENU (1 << 4) Only the GRUB_TERM_SIMPLE_MENU flag should be sufficient, right? > /* Set when the terminal needs to be initialized. */ > #define GRUB_TERM_NEED_INIT (1 << 16) > > diff -urN grub2.org/kern/term.c grub2/kern/term.c > --- grub2.org/kern/term.c 2007-07-22 01:32:26.000000000 +0200 > +++ grub2/kern/term.c 2007-10-15 21:26:48.402210358 +0200 > @@ -90,6 +90,94 @@ > return grub_cur_term; > } > > +static > +grub_uint32_t remap_border(grub_uint32_t code) Please follow the same coding style as we do: the GCS. Return types are on a separate line, the "(" is prefixed by a space. Thus: static grub_uint32_t remap_border (grub_uint32_t code) Remap is a somewhat confusing name. Perhaps something like remap_to_ascii? > diff -urN grub2.org/term/i386/pc/serial.c grub2/term/i386/pc/serial.c > --- grub2.org/term/i386/pc/serial.c 2007-07-22 01:32:30.000000000 +0200 > +++ grub2/term/i386/pc/serial.c 2007-10-15 21:26:48.405210358 +0200 > @@ -324,48 +324,9 @@ > /* Keep track of the cursor. */ > if (keep_track) > { > - /* The serial terminal does not have VGA fonts. */ > + /* The serial terminal does not support Unicode. */ > if (c > 0x7F) > - { > - /* Better than nothing. */ > - switch (c) > - { > - case GRUB_TERM_DISP_LEFT: > - c = '<'; > - break; > - > - case GRUB_TERM_DISP_UP: > - c = '^'; > - break; > - > - case GRUB_TERM_DISP_RIGHT: > - c = '>'; > - break; > - > - case GRUB_TERM_DISP_DOWN: > - c = 'v'; > - break; > - > - case GRUB_TERM_DISP_HLINE: > - c = '-'; > - break; > - > - case GRUB_TERM_DISP_VLINE: > - c = '|'; > - break; > - > - case GRUB_TERM_DISP_UL: > - case GRUB_TERM_DISP_UR: > - case GRUB_TERM_DISP_LL: > - case GRUB_TERM_DISP_LR: > - c = '+'; > - break; > - > - default: > - c = '?'; > - break; > - } > - } > + c = '?'; Sometimes it might be supported, depending on the terminal settings. Can this be detected? > switch (c) > { > @@ -498,7 +459,7 @@ > .setcolorstate = grub_serial_setcolorstate, > .setcolor = grub_serial_setcolor, > .setcursor = grub_serial_setcursor, > - .flags = 0, > + .flags = GRUB_TERM_SIMPLE_MENU, > .next = 0 > }; > > diff -urN grub2.org/term/i386/pc/vesafb.c grub2/term/i386/pc/vesafb.c > --- grub2.org/term/i386/pc/vesafb.c 2007-07-22 01:32:31.000000000 +0200 > +++ grub2/term/i386/pc/vesafb.c 2007-10-15 21:26:48.418210358 +0200 > @@ -214,45 +214,7 @@ > unsigned *width) > { > if (code > 0x7f) > - { > - /* Map some unicode characters to the VGA font, if possible. */ > - switch (code) > - { > - case 0x2190: /* left arrow */ > - code = 0x1b; > - break; > - case 0x2191: /* up arrow */ > - code = 0x18; > - break; > - case 0x2192: /* right arrow */ > - code = 0x1a; > - break; > - case 0x2193: /* down arrow */ > - code = 0x19; > - break; > - case 0x2501: /* horizontal line */ > - code = 0xc4; > - break; > - case 0x2503: /* vertical line */ > - code = 0xb3; > - break; > - case 0x250F: /* upper-left corner */ > - code = 0xda; > - break; > - case 0x2513: /* upper-right corner */ > - code = 0xbf; > - break; > - case 0x2517: /* lower-left corner */ > - code = 0xc0; > - break; > - case 0x251B: /* lower-right corner */ > - code = 0xd9; > - break; > - > - default: > - return grub_font_get_glyph (code, bitmap, width); > - } > - } > + return grub_font_get_glyph (code, bitmap, width); > > if (bitmap) > grub_memcpy (bitmap, > @@ -601,7 +563,7 @@ > .setcolorstate = grub_virtual_screen_setcolorstate, > .setcolor = grub_virtual_screen_setcolor, > .setcursor = grub_vesafb_setcursor, > - .flags = 0, > + .flags = GRUB_TERM_CP437_MENU, > .next = 0 > }; > > diff -urN grub2.org/term/i386/pc/vga.c grub2/term/i386/pc/vga.c > --- grub2.org/term/i386/pc/vga.c 2007-07-22 01:32:31.000000000 +0200 > +++ grub2/term/i386/pc/vga.c 2007-10-15 21:26:48.447210358 +0200 > @@ -198,45 +198,7 @@ > get_vga_glyph (grub_uint32_t code, unsigned char bitmap[32], unsigned *width) > { > if (code > 0x7f) > - { > - /* Map some unicode characters to the VGA font, if possible. */ > - switch (code) > - { > - case 0x2190: /* left arrow */ > - code = 0x1b; > - break; > - case 0x2191: /* up arrow */ > - code = 0x18; > - break; > - case 0x2192: /* right arrow */ > - code = 0x1a; > - break; > - case 0x2193: /* down arrow */ > - code = 0x19; > - break; > - case 0x2501: /* horizontal line */ > - code = 0xc4; > - break; > - case 0x2503: /* vertical line */ > - code = 0xb3; > - break; > - case 0x250F: /* upper-left corner */ > - code = 0xda; > - break; > - case 0x2513: /* upper-right corner */ > - code = 0xbf; > - break; > - case 0x2517: /* lower-left corner */ > - code = 0xc0; > - break; > - case 0x251B: /* lower-right corner */ > - code = 0xd9; > - break; > - > - default: > - return grub_font_get_glyph (code, bitmap, width); > - } > - } > + return grub_font_get_glyph (code, bitmap, width); > > if (bitmap) > grub_memcpy (bitmap, vga_font + code * CHAR_HEIGHT, CHAR_HEIGHT); > @@ -590,7 +552,7 @@ > .setcolorstate = grub_vga_setcolorstate, > .setcolor = grub_vga_setcolor, > .setcursor = grub_vga_setcursor, > - .flags = 0, > + .flags = GRUB_TERM_CP437_MENU, > .next = 0 > }; > > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-07-22 11:05:11.000000000 +0200 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-15 21:27:17.621210358 +0200 > @@ -366,7 +366,7 @@ > .setcolor = grub_ofconsole_setcolor, > .setcursor = grub_ofconsole_setcursor, > .refresh = grub_ofconsole_refresh, > - .flags = 0, > + .flags = GRUB_TERM_SIMPLE_MENU, > .next = 0 > }; > > diff -urN grub2.org/util/console.c grub2/util/console.c > --- grub2.org/util/console.c 2007-07-22 01:32:31.000000000 +0200 > +++ grub2/util/console.c 2007-10-15 21:26:48.456210358 +0200 > @@ -44,47 +44,6 @@ > static void > grub_ncurses_putchar (grub_uint32_t c) > { > - /* Better than nothing. */ > - switch (c) > - { > - case GRUB_TERM_DISP_LEFT: > - c = '<'; > - break; > - > - case GRUB_TERM_DISP_UP: > - c = '^'; > - break; > - > - case GRUB_TERM_DISP_RIGHT: > - c = '>'; > - break; > - > - case GRUB_TERM_DISP_DOWN: > - c = 'v'; > - break; > - > - case GRUB_TERM_DISP_HLINE: > - c = '-'; > - break; > - > - case GRUB_TERM_DISP_VLINE: > - c = '|'; > - break; > - > - case GRUB_TERM_DISP_UL: > - case GRUB_TERM_DISP_UR: > - case GRUB_TERM_DISP_LL: > - case GRUB_TERM_DISP_LR: > - c = '+'; > - break; > - > - default: > - /* ncurses does not support Unicode. */ > - if (c > 0x7f) > - c = '?'; > - break; > - } > - > addch (c | grub_console_attr); > } > > @@ -302,7 +261,7 @@ > .setcolor = grub_ncurses_setcolor, > .setcursor = grub_ncurses_setcursor, > .refresh = grub_ncurses_refresh, > - .flags = 0, > + .flags = GRUB_TERM_SIMPLE_MENU, > .next = 0 > }; > > > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-10-03 10:55:27.191943734 +0200 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-03 10:56:26.399943734 +0200 > @@ -63,12 +63,8 @@ > static void > grub_ofconsole_writeesc (const char *str) > { > - while (*str) > - { > - char chr = *(str++); > - grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); > - } > - > + int len = grub_strlen(str); > + grub_ieee1275_write (stdout_ihandle, str, len, 0); > } Ok. > static void > > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-10-15 21:23:24.554210358 +0200 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-15 21:24:13.111210358 +0200 > @@ -135,41 +135,54 @@ > > grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); What are you doing below? > - if (actual > 0 && c == '\e') > + if (actual > 0) > { > - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > - if (actual <= 0) > - { > - *key = '\e'; > - return 1; > - } > + if (c != '\e') > + { > + switch(c) > + { > + case 127: > + /* Backspace */ > + c = '\b'; > + break; > + } > + } > + else > + { > + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > + if (actual <= 0) > + { > + *key = '\e'; > + return 1; > + } > > - if (c != 91) > - return 0; > + if (c != 91) > + return 0; > > - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > - if (actual <= 0) > - return 0; > + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > + if (actual <= 0) > + return 0; > > - switch (c) > - { > - case 65: > - /* Up: Ctrl-p. */ > - c = 16; > - break; > - case 66: > - /* Down: Ctrl-n. */ > - c = 14; > - break; > - case 67: > - /* Right: Ctrl-f. */ > - c = 6; > - break; > - case 68: > - /* Left: Ctrl-b. */ > - c = 2; > - break; > - } > + switch (c) > + { > + case 65: > + /* Up: Ctrl-p. */ > + c = 16; > + break; > + case 66: > + /* Down: Ctrl-n. */ > + c = 14; > + break; > + case 67: > + /* Right: Ctrl-f. */ > + c = 6; > + break; > + case 68: > + /* Left: Ctrl-b. */ > + c = 2; > + break; > + } > + } > } > > *key = c; > > diff -urN grub2.org/include/grub/ieee1275/ieee1275.h grub2/include/grub/ieee1275/ieee1275.h > --- grub2.org/include/grub/ieee1275/ieee1275.h 2007-10-04 22:44:12.000000000 +0200 > +++ grub2/include/grub/ieee1275/ieee1275.h 2007-10-10 16:41:39.594688149 +0200 > @@ -82,6 +82,16 @@ > > /* CodeGen firmware does not correctly implement "output-device output" */ > GRUB_IEEE1275_FLAG_BROKEN_OUTPUT, > + > + /* In non fb mode default number of console rows is 24, but in fact it's 25 */ > + GRUB_IEEE1275_FLAG_NOFB_ROWS25, > + > + /* Old Pegaos firmware does not accept cls escape sequence */ > + GRUB_IEEE1275_FLAG_NOCLS, > + > + /* On CodeGen firmware, cp437 characters 0xc0 to 0xcb are reserved for the > + bplan logo */ > + GRUB_IEEE1275_FLAG_BPLAN_LOGO, > }; > > extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); > diff -urN grub2.org/kern/powerpc/ieee1275/cmain.c grub2/kern/powerpc/ieee1275/cmain.c > --- grub2.org/kern/powerpc/ieee1275/cmain.c 2007-10-04 22:44:12.000000000 +0200 > +++ grub2/kern/powerpc/ieee1275/cmain.c 2007-10-10 16:42:30.520688149 +0200 > @@ -73,6 +73,8 @@ > { > /* Broken in all versions */ > grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); > + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25); > + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO); I thought this is bplan specific? Or am I missing the context of this check? > /* There are two incompatible ways of checking the version number. Try > both. */ > @@ -98,6 +100,13 @@ > grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0); > grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); > } > + /* It seems old firmware for Pegaos 1 do not accept cls escape then > + we need to emulate it using \n sequence */ > + if (!grub_strcmp (tmp, "1.0") > + || !grub_strcmp (tmp, "1.1")) > + { > + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOCLS); > + } > } > } > } > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-10-04 22:44:12.000000000 +0200 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-10 16:51:56.829688149 +0200 > @@ -24,12 +24,18 @@ > #include <grub/machine/console.h> > #include <grub/ieee1275/ieee1275.h> > > +static void grub_ofconsole_setflags(int flags, int x); setflags (... > + > static grub_ieee1275_ihandle_t stdout_ihandle; > static grub_ieee1275_ihandle_t stdin_ihandle; > > static grub_uint8_t grub_ofconsole_width; > static grub_uint8_t grub_ofconsole_height; > > +/* We will assume serial console by default */ Please end a sentence with a ".". After every ".", add two spaces before beginning the next sentence or ending the comment. > +static grub_uint8_t grub_ofconsole_fb = 0; static grub_uint8_t grub_ofconsole_fb = 0; By default this is initialized to 0, no need to do this yourself. > +static grub_uint8_t grub_ofconsole_serial = 1; Please just use integers for the two variables you added. > + > static int grub_curr_x; > static int grub_curr_y; > > @@ -70,20 +76,76 @@ > static void > grub_ofconsole_putchar (grub_uint32_t c) > { > - char chr = c; > - > - if (c == '\n') > + char chr; > + > + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO)) > { > + /* cp437 characters 0xc0 to 0xcb are reserved for the bplan logo. Use > + this layout to workaround it: > + âââ > + â â > + âââ */ Ehm? Please do not put unicode in this C file. > + switch (c) > + { > + case 0xc4: > + /* GRUB_TERM_DISP_HLINE */ > + c = 0xcd; > + break; > + case 0xb3: > + /* GRUB_TERM_DISP_VLINE */ > + c = 0xb3; > + break; > + case 0xda: > + /* GRUB_TERM_DISP_UL */ > + c = 0xd5; > + break; > + case 0xbf: > + /* GRUB_TERM_DISP_UR */ > + c = 0xb8; > + break; > + case 0xc0: > + /* GRUB_TERM_DISP_LL */ > + c = 0xd4; > + break; > + case 0xd9: > + /* GRUB_TERM_DISP_LR */ > + c = 0xbe; > + break; > + } > + } What does this do? You mention macros like GRUB_TERM_DISP_HLINE, but you use constants, why? > + > + switch(c) > + { > + case '\a': > + break; > + case '\n': > + grub_putcode ('\r'); > grub_curr_y++; > + if(grub_curr_y > (grub_ofconsole_height - 1)) > + /* Is this realy correct for all OF versions around ? */ around? */ > + grub_curr_y = grub_ofconsole_fb ? > + grub_curr_y - 4 : grub_ofconsole_height - 1; Please put the "?" on the next line. > + break; > + case '\r': > grub_curr_x = 0; > - } > - else > - { > + break; > + case '\b': > + if(grub_curr_x > 0) > + grub_curr_x--; > + break; > + > + default: > + if(c == '\t') > + c = ' '; > + > + if (grub_curr_x >= (grub_ofconsole_width - 1)) > + grub_putcode ('\n'); > + > grub_curr_x++; > - if (grub_curr_x > grub_ofconsole_width) > - grub_putcode ('\n'); > - } > + break; > + } > > + chr = c; > grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); > } > > @@ -228,7 +290,7 @@ > static grub_uint16_t > grub_ofconsole_getxy (void) > { > - return ((grub_curr_x - 1) << 8) | grub_curr_y; > + return (grub_curr_x << 8) | grub_curr_y; > } > > static grub_uint16_t > @@ -278,6 +340,10 @@ > if (! grub_ofconsole_height) > grub_ofconsole_height = 24; > > + if ( grub_ofconsole_fb == 0 && grub_ofconsole_serial == 0 && grub_ofconsole_height == 24 && > + grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25)) > + grub_ofconsole_height = 25; > + if (grub_ofconsole_fb == 0 && grub_ofconsole_serial == 0 && grub_ofconsole_height == 24 && grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25)) grub_ofconsole_height = 25; > return (grub_ofconsole_width << 8) | grub_ofconsole_height; > } > > @@ -295,10 +361,20 @@ > static void > grub_ofconsole_cls (void) > { > - /* Clear the screen. Using serial console, screen(1) only recognizes the > - * ANSI escape sequence. Using video console, Apple Open Firmware (version > - * 3.1.1) only recognizes the literal ^L. So use both. */ > - grub_ofconsole_writeesc ("\f\e[2J"); > + if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOCLS)) > + { > + /* Clear the screen. Using serial console, screen(1) only recognizes the > + * ANSI escape sequence. Using video console, Apple Open Firmware (version > + * 3.1.1) only recognizes the literal ^L. So use both. */ > + grub_ofconsole_writeesc ("\f\e[2J"); > + } > + else > + { > + /* It seems no cls escape is available then simulate it using \n flood */ ". */" > + int x = (grub_ofconsole_height * 2) - grub_curr_y; > + while(x--) > + grub_putcode ('\n'); > + } > grub_gotoxy (0, 0); > } > > @@ -317,6 +393,7 @@ > static grub_err_t > grub_ofconsole_init (void) > { > + grub_ieee1275_phandle_t stdout_phandle; > unsigned char data[4]; > grub_ssize_t actual; > int col; > @@ -349,6 +426,48 @@ > /* Set the right fg and bg colors. */ > grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL); > > + /* Check do we are on serial or normal console */ ". */" > + if(! grub_ieee1275_instance_to_package (stdout_ihandle, &stdout_phandle)) > + { > + char type[16]; > + char name[128]; > + > + if(! grub_ieee1275_get_property (stdout_phandle, "device_type", &type, > + sizeof type, 0) && > + ! grub_ieee1275_get_property (stdout_phandle, "name", &name, > + sizeof name, 0)) > + { > + /* > + * In general type "serial" is used for console without > + * framebuffer support in recent firmware versions then > + * we need to check the name too to determine is it real or > + * serial console > + */ Please do not use this style of comments. So without the *'s. It's preferred to do: / In general type "serial" is used for console without framebuffer support in recent firmware versions then we need to check the name too to determine is it real or serial console. */ > + > + if (! grub_strcmp (type, "serial")) > + { > + /* If "name" is something else than "display" we assume serial console */ . */ Please also fix all the other comments :-) > + if(! grub_strcmp (name, "display")) > + grub_ofconsole_serial = 0; > + } > + else > + { > + grub_ofconsole_serial = 0; > + > + /* Older versions use name/type set to "bootconsole" */ > + if ( grub_strcmp (name, "bootconsole")) > + grub_ofconsole_fb = 1; > + } > + } > + } > + > + /* Set term flags */ > + if(!grub_ofconsole_serial && !grub_ofconsole_fb) > + { > + grub_ofconsole_setflags(GRUB_TERM_SIMPLE_MENU, 0); > + grub_ofconsole_setflags(GRUB_TERM_CP437_MENU, 1); > + } > + > return 0; > } > > @@ -377,7 +496,7 @@ > .setcolor = grub_ofconsole_setcolor, > .setcursor = grub_ofconsole_setcursor, > .refresh = grub_ofconsole_refresh, > - .flags = GRUB_TERM_SIMPLE_MENU, > + .flags = GRUB_TERM_SIMPLE_MENU, /* We are set to serial by default */ > .next = 0 > }; > > @@ -393,3 +512,12 @@ > { > grub_term_unregister (&grub_ofconsole_term); > } > + > +static void > +grub_ofconsole_setflags(int flags, int x) > +{ > + if(x) > + grub_ofconsole_term.flags |= flags; > + else > + grub_ofconsole_term.flags &= ~flags; > +} > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] Fixed ieee1275 console 2007-10-01 10:57 [PATCH] Fixed ieee1275 console Marcin Kurek ` (2 preceding siblings ...) 2007-10-11 15:06 ` Marco Gerards @ 2007-11-18 12:11 ` Marco Gerards 3 siblings, 0 replies; 21+ messages in thread From: Marco Gerards @ 2007-11-18 12:11 UTC (permalink / raw) To: The development of GRUB 2 "Marcin Kurek" <morgoth6@gmail.com> writes: Hi Marcin, > Finaly I found a few free minutes to look at ofconsole as it never > correctly work for me. There was 3 problems on my Pegasos: :-) > 1) Backspace key not works with USB keyboard. It does with PS/2? Are you sure this fix works on apple firmware? > 2) menu looks ugly like hell as it contains some random characters in > place of borders. You had some code for this, right? > 3) Console works wrong (the cursor position was wrong after some > commands eg. ls and it displays only a black hole when grub prints > more than one screen of text) getxy was the problem, right? > I am not sure how correct my fix is for non Efika/ODW machines, but I > tested it on both without any problems. Great. Although for us it is important that it works on all machines, which makes some things a bit less trivial to fix... > In grub_ofconsole_writeesc() I think it would be good idea to use > single "write" command, but this is a cosmetics only I guess. Also in > grub_ofconsole_getxy() the -1 for grub_curr_x seems to be wrong for > me. Yes, although I wonder why I used multiple commands at the time. Perhaps there was a problem with this that we forgot to document :-/ > Replaced borders characters in grub_ofconsole_putchar() by '-', '|', > etc. Maybe not perfect, but looks definitly better than before [2]. > Also fixed cursor position tracking (grub_curr_x, grub_curr_y) which > fix both console problems [3] Can you separate the getxy patch? It is quite small and fixes an annoying bug. It should be committed soon. > Handle 127 keycode as backspace key in grub_ofconsole_readkey() which fix [1] > > BTW Also attach my previous patches with [PATCH] in topic this time. :-) Can you please write changelog entries for your patches? It's important to us. > --- Marcin 'Morgoth' Kurek --- > > diff -urN grub2.org/fs/affs.c grub2/fs/affs.c > --- grub2.org/fs/affs.c 2007-08-02 20:40:36.000000000 +0200 > +++ grub2/fs/affs.c 2007-09-15 10:23:35.550133111 +0200 > @@ -25,6 +25,7 @@ > #include <grub/dl.h> > #include <grub/types.h> > #include <grub/fshelp.h> > +#include <grub/partition.h> > > /* The affs bootblock. */ > struct grub_affs_bblock > @@ -97,6 +98,9 @@ > struct grub_fshelp_node diropen; > grub_disk_t disk; > > + /* Size in sectors */ > + grub_uint64_t len; > + > /* Blocksize in sectors. */ > int blocksize; > > @@ -170,10 +174,17 @@ > int checksumr = 0; > int blocksize = 0; > > + > data = grub_malloc (sizeof (struct grub_affs_data)); > if (!data) > return 0; > > + /* total_sectors are not valid on ieee1275 */ > + if(disk->partition) > + data->len = grub_partition_get_len (disk->partition); > + else > + data->len = disk->total_sectors; Can you please fix total_sectors instead? This patch does not fix the problem, but it moves the problem elsewhere. > /* Read the bootblock. */ > grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock), > (char *) &data->bblock); > @@ -194,12 +205,6 @@ > goto fail; > } > > - /* Read the bootblock. */ > - grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock), > - (char *) &data->bblock); > - if (grub_errno) > - goto fail; > - It was read twice!? Silly me... :-) > /* No sane person uses more than 8KB for a block. At least I hope > for that person because in that case this won't work. */ > rootblock = grub_malloc (GRUB_DISK_SECTOR_SIZE * 16); > @@ -209,7 +214,7 @@ > rblock = (struct grub_affs_rblock *) rootblock; > > /* Read the rootblock. */ > - grub_disk_read (disk, (disk->total_sectors >> 1) + blocksize, 0, > + grub_disk_read (disk, (data->len >> 1) + blocksize, 0, > GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock); > if (grub_errno) > goto fail; > @@ -241,7 +246,7 @@ > data->disk = disk; > data->htsize = grub_be_to_cpu32 (rblock->htsize); > data->diropen.data = data; > - data->diropen.block = (disk->total_sectors >> 1); > + data->diropen.block = (data->len >> 1); > > grub_free (rootblock); > > @@ -522,7 +527,7 @@ > { > /* The rootblock maps quite well on a file header block, it's > something we can use here. */ > - grub_disk_read (data->disk, disk->total_sectors >> 1, > + grub_disk_read (data->disk, data->len >> 1, > data->blocksize * (GRUB_DISK_SECTOR_SIZE > - GRUB_AFFS_FILE_LOCATION), > sizeof (file), (char *) &file); > > diff -urN grub2.org/conf/powerpc-ieee1275.mk grub2/conf/powerpc-ieee1275.mk > #endif /* ! GRUB_LOADER_MACHINE_HEADER */ > diff -urN grub2.org/loader/powerpc/ieee1275/ofboot.c grub2/loader/powerpc/ieee1275/ofboot.c > --- grub2.org/loader/powerpc/ieee1275/ofboot.c 1970-01-01 01:00:00.000000000 +0100 > +++ grub2/loader/powerpc/ieee1275/ofboot.c 2007-09-15 04:45:47.960133111 +0200 > @@ -0,0 +1,135 @@ > +/* ofboot.c - OF boot */ > +/* > + * GRUB -- GRand Unified Bootloader > + * Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. > + * > + * GRUB is free software: you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation, either version 3 of the License, or > + * (at your option) any later version. > + * > + * GRUB is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with GRUB. If not, see <http://www.gnu.org/licenses/>. > + */ > + > +#include <grub/loader.h> > +#include <grub/dl.h> > +#include <grub/mm.h> > +#include <grub/rescue.h> > +#include <grub/misc.h> > +#include <grub/ieee1275/ieee1275.h> > +#include <grub/machine/loader.h> > + > +static grub_dl_t my_mod; > + > +static char *ofboot_args; > + > +static grub_err_t > +grub_ofboot_boot (void) > +{ > + grub_err_t err; > + > + err = grub_ieee1275_interpret("go", 0); > + > + return err; > +} > + > +static grub_err_t > +grub_ofboot_release_mem (void) > +{ > + grub_free (ofboot_args); > + ofboot_args = 0; > + > + return GRUB_ERR_NONE; > +} > + > +static grub_err_t > +grub_ofboot_unload (void) > +{ > + grub_err_t err; > + > + err = grub_ofboot_release_mem (); > + grub_dl_unref (my_mod); > + > + return err; > +} > + > +void > +grub_rescue_cmd_ofboot (int argc, char *argv[]) > +{ > + int i; > + int size; > + grub_err_t err; > + grub_ieee1275_cell_t res; > + char *dest; > + > + grub_dl_ref (my_mod); > + > + if (argc == 0) > + { > + grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified"); > + goto out; > + } > + > + /* Release the previously used memory. */ > + grub_loader_unset (); > + > + size = sizeof("load") + 1; > + for (i = 0; i < argc; i++) > + size += grub_strlen (argv[i]) + 1; > + > + ofboot_args = grub_malloc (size); > + if (! ofboot_args) > + goto out; > + > + dest = grub_stpcpy (ofboot_args, "load"); > + for (i = 0; i < argc; i++) > + { > + *dest++ = ' '; > + dest = grub_stpcpy (dest, argv[i]); > + } > + > + err = grub_ieee1275_interpret(ofboot_args, &res); > + if (err || res) > + { > + grub_error (GRUB_ERR_UNKNOWN_OS, "Failed to \"load\""); > + goto out; > + } > + > + err = grub_ieee1275_interpret("init-program", &res); > + if (err || res) > + { > + grub_error (GRUB_ERR_UNKNOWN_OS, "Failed to \"init-program\""); > + goto out; > + } > + > +out: > + > + if (grub_errno != GRUB_ERR_NONE) > + { > + grub_ofboot_release_mem (); > + grub_dl_unref (my_mod); > + } > + else > + { > + grub_loader_set (grub_ofboot_boot, grub_ofboot_unload, 1); > + } > +} > + > +\f > +GRUB_MOD_INIT(ofboot) > +{ > + grub_rescue_register_command ("ofboot", grub_rescue_cmd_ofboot, > + "load using OF interface"); > + my_mod = mod; > +} > + > +GRUB_MOD_FINI(ofboot) > +{ > + grub_rescue_unregister_command ("ofboot"); > +} It would be better to make a loader out of this. In that case it better integrates into GRUB 2. > diff -urN grub2.org/loader/powerpc/ieee1275/ofboot_normal.c grub2/loader/powerpc/ieee1275/ofboot_normal.c > --- grub2.org/loader/powerpc/ieee1275/ofboot_normal.c 1970-01-01 01:00:00.000000000 +0100 > +++ grub2/loader/powerpc/ieee1275/ofboot_normal.c 2007-09-14 22:54:03.573217034 +0200 > @@ -0,0 +1,48 @@ > +/* ofboot_normal.c - OF boot */ > +/* > + * GRUB -- GRand Unified Bootloader > + * Copyright (C) 2004,2007 Free Software Foundation, Inc. > + * > + * GRUB is free software: you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation, either version 3 of the License, or > + * (at your option) any later version. > + * > + * GRUB is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with GRUB. If not, see <http://www.gnu.org/licenses/>. > + */ > + > +#include <grub/normal.h> > +#include <grub/dl.h> > +#include <grub/machine/loader.h> > + > +static const struct grub_arg_option options[] = > + { > + {0, 0, 0, 0, 0, 0} > + }; > + > +static grub_err_t > +grub_cmd_ofboot (struct grub_arg_list *state __attribute__ ((unused)), > + int argc, char **args) > +{ > + grub_rescue_cmd_ofboot (argc, args); > + return GRUB_ERR_NONE; > +} > + > +GRUB_MOD_INIT(ofboot_normal) > +{ > + (void) mod; > + grub_register_command ("ofboot", grub_cmd_ofboot, GRUB_COMMAND_FLAG_BOTH, > + "ofboot [ARGS...]", > + "Loads using OF interface", options); > +} > + > +GRUB_MOD_FINI(ofboot_normal) > +{ > + grub_unregister_command ("ofboot"); > +} > > --- ../Cache/cvs/grub2/term/ieee1275/ofconsole.c 2007-07-22 11:05:11.000000000 +0200 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-01 12:12:47.075370575 +0200 > @@ -63,29 +63,81 @@ > static void > grub_ofconsole_writeesc (const char *str) > { > - while (*str) > - { > - char chr = *(str++); > - grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); > - } > - > + int len = grub_strlen(str); grub_strlen (str) > + grub_ieee1275_write (stdout_ihandle, str, len, 0); > } > > static void > grub_ofconsole_putchar (grub_uint32_t c) > { > - char chr = c; > - if (c == '\n') > - { > + char chr; > + > + switch (c) > + { > + case GRUB_TERM_DISP_LEFT: > + c = '<'; > + break; > + case GRUB_TERM_DISP_UP: > + c = '^'; > + break; > + case GRUB_TERM_DISP_RIGHT: > + c = '>'; > + break; > + case GRUB_TERM_DISP_DOWN: > + c = 'v'; > + break; > + case GRUB_TERM_DISP_HLINE: > + c = '-'; > + break; > + case GRUB_TERM_DISP_VLINE: > + c = '|'; > + break; > + case GRUB_TERM_DISP_UL: > + case GRUB_TERM_DISP_UR: > + case GRUB_TERM_DISP_LL: > + case GRUB_TERM_DISP_LR: > + c = '+'; > + break; > + case '\t': > + c = ' '; > + break; > + > + default: > + /* of does not support Unicode. */ > + if (c > 0x7f) > + c = '?'; > + break; > + } > + > + switch(c) > + { > + case '\a': > + break; > + case '\n': > + grub_putcode ('\r'); > grub_curr_y++; > + > + if(grub_curr_y > (grub_ofconsole_height - 1)) > + grub_curr_y -= 4; /* Is this realy correct for all OF versions around ? */ > + break; > + case '\r': > grub_curr_x = 0; > - } > - else > - { > + break; > + case '\b': > + if(grub_curr_x > 0) > + grub_curr_x--; > + break; > + > + default: > + > + if (grub_curr_x >= (grub_ofconsole_width - 1)) > + grub_putcode ('\n'); > + > grub_curr_x++; > - if (grub_curr_x > grub_ofconsole_width) > - grub_putcode ('\n'); > - } > + break; > + } > + > + chr = c; > grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); > } > > @@ -137,43 +189,56 @@ > > grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > > - if (actual > 0 && c == '\e') > + if (actual > 0) > { > - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > - if (actual <= 0) > - { > - *key = '\e'; > - return 1; > - } > + if (c != '\e') > + { > + switch(c) > + { > + case 127: > + /* Backspace */ > + c = '\b'; > + break; > + } Is this also true for the Apple firmwares? I do not fix this for one firmware and break it for the other... > + } > + else > + { > + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > + if (actual <= 0) > + { > + *key = '\e'; > + return 1; > + } > > - if (c != 91) > - return 0; > + if (c != 91) > + return 0; > > - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > - if (actual <= 0) > - return 0; > + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > + if (actual <= 0) > + return 0; > > - switch (c) > - { > - case 65: > - /* Up: Ctrl-p. */ > - c = 16; > - break; > - case 66: > - /* Down: Ctrl-n. */ > - c = 14; > - break; > - case 67: > - /* Right: Ctrl-f. */ > - c = 6; > - break; > - case 68: > - /* Left: Ctrl-b. */ > - c = 2; > - break; > - } > + switch (c) > + { > + case 65: > + /* Up: Ctrl-p. */ > + c = 16; > + break; > + case 66: > + /* Down: Ctrl-n. */ > + c = 14; > + break; > + case 67: > + /* Right: Ctrl-f. */ > + c = 6; > + break; > + case 68: > + /* Left: Ctrl-b. */ > + c = 2; > + break; > + } > + } > } > - > + > *key = c; > return actual > 0; > } > @@ -217,7 +282,7 @@ > static grub_uint16_t > grub_ofconsole_getxy (void) > { > - return ((grub_curr_x - 1) << 8) | grub_curr_y; > + return (grub_curr_x << 8) | grub_curr_y; > } Most likely getxy is broken for every firmware? -- Marco ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2007-11-18 13:17 UTC | newest] Thread overview: 21+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-10-01 10:57 [PATCH] Fixed ieee1275 console Marcin Kurek 2007-10-01 12:31 ` Robert Millan 2007-10-01 12:33 ` Robert Millan 2007-10-01 18:14 ` Marcin Kurek 2007-10-01 18:39 ` Robert Millan 2007-10-01 19:43 ` Marcin Kurek 2007-10-02 21:39 ` Robert Millan 2007-10-03 23:33 ` Marcin Kurek 2007-10-04 20:50 ` Robert Millan 2007-10-10 15:11 ` Marcin Kurek 2007-10-10 19:19 ` Robert Millan 2007-10-10 21:57 ` Marcin Kurek 2007-10-11 14:01 ` Robert Millan 2007-10-11 15:06 ` Marco Gerards 2007-10-12 16:16 ` Marcin Kurek 2007-11-10 17:05 ` Marco Gerards 2007-11-11 11:02 ` Marcin Kurek 2007-11-18 11:37 ` Marco Gerards 2007-10-15 20:43 ` Marcin Kurek 2007-11-18 13:18 ` Marco Gerards 2007-11-18 12:11 ` Marco Gerards
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.