Re: [PATCH] Fixed ieee1275 console
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 --- ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Workaround for grub_ofdisk_read()
Hell[o] You sent a patch, but the patch didn't fix the problem. The code we have is obviously buggy, but we don't know exactly what should it do. Eeeek, why ? No one told me that there is any problem in it. Maybe you talk about first one ? Attached current. -- --- Marcin 'Morgoth' Kurek --- diff -urN grub2.org/disk/ieee1275/ofdisk.c grub2/disk/ieee1275/ofdisk.c --- grub2.org/disk/ieee1275/ofdisk.c 2007-07-22 01:32:20.0 +0200 +++ grub2/disk/ieee1275/ofdisk.c 2007-10-15 21:45:40.998210358 +0200 @@ -124,7 +124,7 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector, grub_size_t size, char *buf) { - grub_ssize_t status, actual; + grub_ssize_t status = 0, actual = 0; unsigned long long pos; grub_dprintf (disk, @@ -139,9 +139,10 @@ return grub_error (GRUB_ERR_READ_ERROR, Seek error, can't seek block %llu, sector); + size *= 512UL; grub_ieee1275_read ((grub_ieee1275_ihandle_t) disk-data, buf, - size * 512UL, actual); - if (actual != actual) + size, actual); + if (actual != size) return grub_error (GRUB_ERR_READ_ERROR, Read error on block: %llu, sector); ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Workaround for grub_ofdisk_read()
Hell[o] What do we need to do with this one? Perhaps you could investigate and report? If I remember correctly I alreay send a patch for this one ... or I forgot ? Sorry I have some personal troubles around and only a little free time for computers :( -- --- Marcin 'Morgoth' Kurek --- ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Fixed ieee1275 console
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 --- 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.0 +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.0 +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: +
Re: [PATCH] Fixed ieee1275 console
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 --- ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] bring initial context to a known state
Hell[o] When GRUB starts initial_context is in an unknown state. This can lead to GRUB detecting bogus variables from it. Attached patch zeroes that struct during initialisation to avoid that. This change broken command line argument handling for ieee1275. Arguments are read by grub_machine_init() in this case and zeroing is done just after that. I guess it should be placed before grub_machine_init() to avoid this problem. -- --- Marcin 'Morgoth' Kurek --- ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Fixed ieee1275 console
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 --- 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.0 +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.0 +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.0 +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; -
[PATCH] Workaround for grub_ofdisk_read()
Hell[o] When testing grub on Pegasos 1 machine I was hit by quite weird problem when reading partition table. It seems my friends firmware version do not set status to 0 after grub_ieee1275_read() even if the read was fine. Attached patch fixed the problem. -- --- Marcin 'Morgoth' Kurek --- diff -urN grub2.org/disk/ieee1275/ofdisk.c grub2/disk/ieee1275/ofdisk.c --- grub2.org/disk/ieee1275/ofdisk.c 2007-07-22 01:32:20.0 +0200 +++ grub2/disk/ieee1275/ofdisk.c 2007-10-07 22:55:48.0 +0200 @@ -124,7 +124,7 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector, grub_size_t size, char *buf) { - grub_ssize_t status, actual; + grub_ssize_t status = 0, actual = 0; unsigned long long pos; grub_dprintf (disk, ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Workaround for grub_ofdisk_read()
Hell[o] woops. actual is never != actual!! what is this supposed to do? If it works like grub_ieee1275_seek, I suppose what we want is to zero it and then compare it with 0? (instead of with itself ;-)). I must be completly blind to not notice this ;( -- --- Marcin 'Morgoth' Kurek --- ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Fixed ieee1275 console
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 --- ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Fixed ieee1275 console
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 --- 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.0 +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.0 +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.0 +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. */ +
[PATCH] Fixed ieee1275 console
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 --- diff -urN grub2.org/fs/affs.c grub2/fs/affs.c --- grub2.org/fs/affs.c 2007-08-02 20:40:36.0 +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); 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.0 +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
Re: [PATCH] Fixed ieee1275 console
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 asciicp473utf 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 --- 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.0 +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.0 +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.0 +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;
Re: [PATCH] fix memory management on efika/pegasos
Hell[o] Finally, I think I got this right now. My efika boots and all the other setups should be happy as well. Please, review/test this and report. Tested on ODW Efika, works fine in both cases. -- --- Marcin 'Morgoth' Kurek --- ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Fixed ieee1275 console
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 --- ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] fix memory management on efika/pegasos
Hell[o] [...] I just checked cvs grub2 with this patch on older version of pegasos firmware (1.2 - 20040810) and it seems to fail with out of memory message. Then it seems to fix problem for efika and for latest version of pegasos firmware. -- --- Marcin 'Morgoth' Kurek --- ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Grun and Efika
Hell[o] Now it is time for efika. 1) Backspace key is not working as on my Pegasos 2) It gives me Out of memory message on boot. I wonder why patch from http://lists.gnu.org/archive/html/grub-devel/2007-08/msg00031.html is not on cvs ? As it fixes grub on efika for me. I tired also a previous version, but it makes MorphOS unbootable using my ofboot hack. For now I not tested anything else because lack of time ;( Anyway I removed forth based boot menu and completly switched to Grub2 yesterday. -- --- Marcin 'Morgoth' Kurek --- ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel