Re: Transparent decompression with file system filter
Hi, any suggestion about this patch ? i would like to commit it soon. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] jpeg image reader
code_sos (data); break; case M_EOI: /* End Of Image */ return; default:/* Skip unrecognized marker */ { grub_uint16_t sz; sz = get_word (data); grub_file_seek (data->file, data->file->offset + sz - 2); } } } } static grub_err_t grub_video_reader_jpeg (struct grub_video_bitmap **bitmap, const char *filename) { grub_file_t file; struct grub_jpeg_data *data; file = grub_file_open (filename); if (!file) return grub_errno; data = grub_malloc (sizeof (*data)); if (data != NULL) { int i; grub_memset (data, 0, sizeof (*data)); data->file = file; data->bitmap = bitmap; if (!grub_setjmp (data->jumper)) decode_jpeg (data); for (i = 0; i < 4; i++) if (data->huff_value[i]) grub_free (data->huff_value[i]); grub_free (data); } if (grub_errno != GRUB_ERR_NONE) { grub_video_bitmap_destroy (*bitmap); *bitmap = 0; } grub_file_close (file); return grub_errno; } #if defined(JPEG_DEBUG) static grub_err_t grub_cmd_jpegtest (struct grub_arg_list *state __attribute__ ((unused)), int argc, char **args) { struct grub_video_bitmap *bitmap = 0; if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); grub_video_reader_jpeg (&bitmap, args[0]); if (grub_errno != GRUB_ERR_NONE) return grub_errno; grub_video_bitmap_destroy (bitmap); return GRUB_ERR_NONE; } #endif static struct grub_video_bitmap_reader jpg_reader = { .extension = ".jpg", .reader = grub_video_reader_jpeg, .next = 0 }; static struct grub_video_bitmap_reader jpeg_reader = { .extension = ".jpeg", .reader = grub_video_reader_jpeg, .next = 0 }; GRUB_MOD_INIT (video_reader_jpeg) { grub_video_bitmap_reader_register (&jpg_reader); grub_video_bitmap_reader_register (&jpeg_reader); #if defined(JPEG_DEBUG) grub_register_command ("jpegtest", grub_cmd_jpegtest, GRUB_COMMAND_FLAG_BOTH, "jpegtest FILE", "Tests loading of JPEG bitmap.", 0); #endif } GRUB_MOD_FINI (video_reader_jpeg) { #if defined(JPEG_DEBUG) grub_unregister_command ("jpegtest"); #endif grub_video_bitmap_reader_unregister (&jpeg_reader); grub_video_bitmap_reader_unregister (&jpg_reader); } -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Bug fix for parser
On Jan 14, 2008 2:42 AM, Marco Gerards <[EMAIL PROTECTED]> wrote: > > @@ -99,6 +101,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) > >grubcmd = grub_command_find (cmdline->cmdname); > >if (! grubcmd) > > { > > + /* Ignore errors. */ > > + grub_errno = GRUB_ERR_NONE; > > + > > What are the implications of this? here is the function : /* Lookup the command. */ grubcmd = grub_command_find (cmdline->cmdname); if (! grubcmd) { /* Ignore errors. */ + grub_errno = GRUB_ERR_NONE; /* It's not a GRUB command, try all functions. */ func = grub_script_function_find (cmdline->cmdname); if (! func) { if the command is not found, grub_errno would be set, this will effect the later grub_script_function_find when it try to load the module from disk. > >/* It's not a GRUB command, try all functions. */ > >func = grub_script_function_find (cmdline->cmdname); > >if (! func) > > diff --git a/normal/main.c b/normal/main.c > > index ccea447..32e649c 100644 > > --- a/normal/main.c > > +++ b/normal/main.c > > @@ -261,6 +261,9 @@ read_config_file (const char *config, int nested) > >/* Execute the command(s). */ > >grub_script_execute (parsed_script); > > > > + /* Ignore errors. */ > > + grub_errno = GRUB_ERR_NONE; > > Same for this. Errors are not shown this way, for example. if grub_error is set, it will effect the parser, caused menu not to be showed, etc. > > >/* The parsed script was executed, throw it away. */ > >grub_script_free (parsed_script); > > } > > diff --git a/normal/parser.y b/normal/parser.y > > index 19cd1bd..8771773 100644 > > --- a/normal/parser.y > > +++ b/normal/parser.y > > @@ -43,7 +43,7 @@ > > %token GRUB_PARSER_TOKEN_FI "fi" > > %token GRUB_PARSER_TOKEN_NAME > > %token GRUB_PARSER_TOKEN_VAR > > -%type script grubcmd command commands commandblock menuentry if > > +%type script script_1 grubcmd command commands commandblock > > menuentry if > > %type arguments; > > %type argument; > > %type "if" "while" "function" "else" "then" "fi" > > @@ -55,12 +55,22 @@ > > > > %% > > /* It should be possible to do this in a clean way... */ > > -script: { state->err = 0} newlines commands > > +script: { state->err = 0} script_1 > > { > > - state->parsed = $3; > > + state->parsed = $2; > > } > > ; > > > > +script_1:commands { $$ = $1; } > > + | function '\n' { $$ = 0; } > > + | menuentry '\n' { $$ = $1; } > > +; > > I do not like the name "script_1". what do you suggest ? > > Looks fine to me at first sight. > > > /* A function. Carefully save the memory that is allocated. Don't > > @@ -194,7 +194,6 @@ function: "function" GRUB_PARSER_TOKEN_NAME > > commandblock:'{' > > { > > grub_script_lexer_ref (state->lexerstate); > > -grub_script_lexer_record_start (state->lexerstate); > > Ehm? Can you explain this? If I am not mistaken, this will result in > a memory leak. I split commandblock from menuentry, now it's a standalone statement. commandblock: '{' { grub_script_lexer_ref (state->lexerstate); } newlines commands '}' { grub_script_lexer_deref (state->lexerstate); $$ = $4; } > > > } > > newlines commands '}' > > { > > @@ -204,10 +203,17 @@ commandblock: '{' > > ; > > > > /* A menu entry. Carefully save the memory that is allocated. */ > > -menuentry: "menuentry" argument newlines commandblock > > +menuentry: "menuentry" argument > > + { > > + grub_script_lexer_ref (state->lexerstate); > > + } newlines '{' > > + { > > + grub_script_lexer_record_start (state->lexerstate); > > + } newlines commands '}' > > > What was the problem here? I don't like the idea of deref in another statement, and now we can use {} separately. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Transparent decompression with file system filter
On Jan 14, 2008 3:51 AM, Yoshinori K. Okuji <[EMAIL PROTECTED]> wrote: > On Sunday 13 January 2008 08:38, Bean wrote: > > Hi, > > > > any suggestion about this patch ? i would like to commit it soon. > > I am sorry that I forgot to reply. > > I would like to know how you intend to approach the following issues: > > - If you want to support, for example, an ecrypted and compressed file, in the > current implementation, each hook must try other hooks recursively. I believe > that this should be done at grub_file_open_ex rather than at every hook. Is > there any pitfall with this way? currently, at most one hook is applied to one file, recursive hook can be messy. but we can add a priority value, this would allow the hooks to be apply in a particular order. > > - There are some cases where the user wants to skip some decoding features > (i.e. decryptions and decompressions). For instance, gunzip does not make > sense for initrd, since the linux kernel performs this. But if the user uses > other compression algorithms (e.g. LZMA), GRUB must decompress it before > transferring control to the kernel. Or, in the case of Multiboot modules, an > OS image might want to keep compressed modules as they are, but have GRUB to > decrypt them, if they are encrypted. How does the user select which hooks > should be applied (from the viewpoint of UI)? i think this can be controlled by variables, for example, we can use filehook.gzip to control whether or not to use gzip, etc. -- Bean -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] jpeg image reader
_to_rgb (data, yy, cr, cb, ptr2); } } return grub_errno; } static grub_uint8_t grub_jpeg_get_marker (struct grub_jpeg_data *data) { grub_uint8_t r; r = grub_jpeg_get_byte (data); if (r != JPEG_ESC_CHAR) { grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid maker"); return 0; } return grub_jpeg_get_byte (data); } static grub_err_t grub_jpeg_decode_jpeg (struct grub_jpeg_data *data) { grub_jpeg_build_color_table (data); if (grub_jpeg_get_marker (data) != M_SOI) /* Start Of Image */ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid jpeg file"); while (grub_errno == 0) { grub_uint8_t marker; marker = grub_jpeg_get_marker (data); if (grub_errno) break; #ifdef JPEG_DEBUG grub_printf ("jpeg marker: %x\n", marker); #endif switch (marker) { case M_DHT: /* Define Huffman Table */ grub_jpeg_decode_huff_table (data); break; case M_DQT: /* Define Quantization Table */ grub_jpeg_decode_quan_table (data); break; case M_SOF0:/* Start Of Frame 0 */ grub_jpeg_decode_sof (data); break; case M_SOS: /* Start Of Scan */ grub_jpeg_decode_sos (data); break; case M_EOI: /* End Of Image */ return grub_errno; default:/* Skip unrecognized marker */ { grub_uint16_t sz; sz = grub_jpeg_get_word (data); if (grub_errno) return (grub_errno); grub_file_seek (data->file, data->file->offset + sz - 2); } } } return grub_errno; } static grub_err_t grub_video_reader_jpeg (struct grub_video_bitmap **bitmap, const char *filename) { grub_file_t file; struct grub_jpeg_data *data; file = grub_file_open (filename); if (!file) return grub_errno; data = grub_malloc (sizeof (*data)); if (data != NULL) { int i; grub_memset (data, 0, sizeof (*data)); data->file = file; data->bitmap = bitmap; grub_jpeg_decode_jpeg (data); for (i = 0; i < 4; i++) if (data->huff_value[i]) grub_free (data->huff_value[i]); grub_free (data); } if (grub_errno != GRUB_ERR_NONE) { grub_video_bitmap_destroy (*bitmap); *bitmap = 0; } grub_file_close (file); return grub_errno; } #if defined(JPEG_DEBUG) static grub_err_t grub_cmd_jpegtest (struct grub_arg_list *state __attribute__ ((unused)), int argc, char **args) { struct grub_video_bitmap *bitmap = 0; if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); grub_video_reader_jpeg (&bitmap, args[0]); if (grub_errno != GRUB_ERR_NONE) return grub_errno; grub_video_bitmap_destroy (bitmap); return GRUB_ERR_NONE; } #endif static struct grub_video_bitmap_reader jpg_reader = { .extension = ".jpg", .reader = grub_video_reader_jpeg, .next = 0 }; static struct grub_video_bitmap_reader jpeg_reader = { .extension = ".jpeg", .reader = grub_video_reader_jpeg, .next = 0 }; GRUB_MOD_INIT (video_reader_jpeg) { grub_video_bitmap_reader_register (&jpg_reader); grub_video_bitmap_reader_register (&jpeg_reader); #if defined(JPEG_DEBUG) grub_register_command ("jpegtest", grub_cmd_jpegtest, GRUB_COMMAND_FLAG_BOTH, "jpegtest FILE", "Tests loading of JPEG bitmap.", 0); #endif } GRUB_MOD_FINI (video_reader_jpeg) { #if defined(JPEG_DEBUG) grub_unregister_command ("jpegtest"); #endif grub_video_bitmap_reader_unregister (&jpeg_reader); grub_video_bitmap_reader_unregister (&jpg_reader); } -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] PNG image reader
data->wp++; if (data->wp >= WSIZE) data->wp = 0; pos++; if (pos >= WSIZE) pos = 0; len--; } } } return grub_errno; } static grub_err_t grub_png_decode_image_data (struct grub_png_data *data) { grub_uint8_t cmf, flg; int final; cmf = grub_png_get_byte (data); flg = grub_png_get_byte (data); if ((cmf & 0xF) != Z_DEFLATED) return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: only support deflate compression method"); if (flg & Z_FLAG_DICT) return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: dictionary not supported"); do { int block_type; final = grub_png_get_bits (data, 1); block_type = grub_png_get_bits (data, 2); switch (block_type) { case INFLATE_STORED: { grub_uint16_t i, len; data->bit_count = 0; len = grub_png_get_byte (data); len += ((grub_uint16_t) grub_png_get_byte (data)) << 8; grub_png_get_byte (data); /* skip NLEN field */ grub_png_get_byte (data); for (i = 0; i < len; i++) grub_png_output_byte (data, grub_png_get_byte (data)); break; } case INFLATE_FIXED: return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: block type fixed not supported"); case INFLATE_DYNAMIC: grub_png_init_dynamic_block (data); grub_png_read_dynamic_block (data); break; default: return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: unknown block type"); } } while ((!final) && (grub_errno == 0)); grub_png_get_dword (data);/* skip adler checksum */ grub_png_get_dword (data);/* skip crc checksum */ return grub_errno; } static grub_uint8_t png_magic[8] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0x0a }; static grub_err_t grub_png_decode_png (struct grub_png_data *data) { grub_uint8_t magic[8]; if (grub_file_read (data->file, (char *) &magic[0], 8) != 8) return grub_errno; if (grub_memcmp (magic, png_magic, sizeof (png_magic))) return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: not a png file"); while (grub_errno == 0) { grub_uint32_t len, type; len = grub_png_get_dword (data); type = grub_png_get_dword (data); switch (type) { case CHUNK_IHDR: grub_png_decode_image_header (data); break; case CHUNK_IDAT: data->inside_idat = 1; data->idat_remain = len; data->bit_count = 0; grub_png_decode_image_data (data); data->inside_idat = 0; break; case CHUNK_IEND: return grub_errno; default: grub_file_seek (data->file, data->file->offset + len + 4); } } return grub_errno; } static grub_err_t grub_video_reader_png (struct grub_video_bitmap **bitmap, const char *filename) { grub_file_t file; struct grub_png_data *data; file = grub_file_open (filename); if (!file) return grub_errno; data = grub_malloc (sizeof (*data)); if (data != NULL) { grub_memset (data, 0, sizeof (*data)); data->file = file; data->bitmap = bitmap; grub_png_decode_png (data); grub_free (data); } if (grub_errno != GRUB_ERR_NONE) { grub_video_bitmap_destroy (*bitmap); *bitmap = 0; } grub_file_close (file); return grub_errno; } #if defined(PNG_DEBUG) static grub_err_t grub_cmd_pngtest (struct grub_arg_list *state __attribute__ ((unused)), int argc, char **args) { struct grub_video_bitmap *bitmap = 0; if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); grub_video_reader_png (&bitmap, args[0]); if (grub_errno != GRUB_ERR_NONE) return grub_errno; grub_video_bitmap_destroy (bitmap); return GRUB_ERR_NONE; } #endif static struct grub_video_bitmap_reader png_reader = { .extension = ".png", .reader = grub_video_reader_png, .next = 0 }; GRUB_MOD_INIT (video_reader_png) { grub_video_bitmap_reader_register (&png_reader); #if defined(PNG_DEBUG) grub_register_command ("pngtest", grub_cmd_pngtest, GRUB_COMMAND_FLAG_BOTH, "pngtest FILE", "Tests loading of PNG bitmap.", 0); #endif } GRUB_MOD_FINI (video_reader_png) { #if defined(PNG_DEBUG) grub_unregister_command ("pngtest"); #endif grub_video_bitmap_reader_unregister (&png_reader); } -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Some new ideas on transparent filters
Hi, as Okuji suggested, the filter interface should be more general. I'm thinking about the following implementaion. 1, the filehook structure: struct grub_filehook { char *name; int priority; grub_file_t (*open_func) (grub_file_t file); struct grub_filehook *next; }; name is the text representation of the filter, and priority is integer of value 0 to 9. 2. priority By default, at most one filter of the same priority is applied to the same file, and higher priority filters are used before lower ones. In the following sections, we assume that decompression filter is of priority 4, and decryption filter is of priority 8. Priority 0 is a special case, it doesn't participate in auto filter selection, you must use it manually. This priority is usually used for filters that can't identify itself from file content, such as the little endian/big endian coversion filter. 3. filter rules you can customize how to apply the filters using a variable, say default_filter. you can use number 0-9 to represent filters of a certain priority, or use specific filter name, such as: set default_filter="9-1" This is actually the default handling described in section 2. set default_filter="9-1,be_to_le" Use the big endian to little endian conversion filter after normal processing. set default_filter="9,4,7-5,8,3-1" Swap processing order of decompression and decryption filters. set default_filter="-gzip,9-1" don't use gzip, otherwise the same as default handling. set default_filter="9-5,gzip,3-1" only try the gzip decompression filter. 4. enable/disable filters you can use two method to control the status of filter, you can enable all, then disable specific filter, or disable all, and enable specific ones. such as: set filehook=0 set filehook.gzip=1 set filehook.bzip2=1 set filehook=1 set filehook.gzip=0 set filehook.bzip2=0 5, source level control the function to open files with filter support: grub_open_file_ex(char* name,char *filter) filter is used to specify the filter rules to use. Examples: NULL use default filter rules "" don't use any filters "gzip" use only the gzip filter "-gzip,." don't use gzip, otherwise the same as default handling, . will be substituded with default_filter at runtime. 6. Filter filesystem In some case, we might want to apply a specify filter to a file, we can do this use the filter fileystem, such as: filter -a aa (hd0,1)/aa gzip.be_to_le now (filter)/aa is (hd0,1)/aa after gzip decompression and big endian to little endian conversion. to delete the mapping: filter -d aa This can also be used to add filter support to commands that dones't use grub_open_file_ex to open files. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Bug fix for parser
> > if grub_error is set, it will effect the parser, caused menu not to be > > showed, etc. > > Right, but do you want to see a menu if not everything is correctly executed? the problem is that it's not always an error when grub_errno is set, for example, the test command use it to report whether or not two strings equals. > >> I do not like the name "script_1". > > > > what do you suggest ? > > Hopefully someone else knows a better name? :-) how about script_init for the old script, and script here. > >> > commandblock:'{' > >> > { > >> > grub_script_lexer_ref (state->lexerstate); > >> > -grub_script_lexer_record_start (state->lexerstate); > >> > >> Ehm? Can you explain this? If I am not mistaken, this will result in > >> a memory leak. > > > > I split commandblock from menuentry, now it's a standalone statement. > > Ah ok, so there is a grub_script_lexer_record_start elsewhere that > forfills the same role? yes, the grub_script_lexer_record_start is in menuentry. > >> What was the problem here? > > > > I don't like the idea of deref in another statement, and now we can > > use {} separately. > > Of deref? Can you explain? The idea of commandblock was that this > structure might show up more often. But I have no objections for now > if a bug is fixed this way. in the old implementation, commandblock: '{' { grub_script_lexer_ref (state->lexerstate); } newlines commands '}' { grub_script_lexer_deref (state->lexerstate); grub_script_lexer_record_start (state->lexerstate); $$ = $4; } ; menuentry: "menuentry" argument newlines commandblock { char *menu_entry; menu_entry = grub_script_lexer_record_stop (state->lexerstate); $$ = grub_script_create_cmdmenu (state, $2, menu_entry, 0); } it calls grub_script_lexer_record_start in commandblock, and grub_script_lexer_record_stop in menuentry, but now it's both inside menuentry. i think it's better this way. besides, if you use commandblock alone in old implemenation, it will cause problem becuase there is no matching grub_script_lexer_record_stop. > > Btw, does this patch incorporate the previous patch you sent in > regarding scripting? I didn't include the fix on the lexer, for example. ${AA}${BB} should expand to one token instead of two. I think it's better to use a separate patch. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] jpeg image reader
On Jan 15, 2008 7:01 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > > static grub_err_t > > grub_jpeg_decode_sof (struct grub_jpeg_data *data) > > { > > int i, cc; > > grub_uint32_t next_marker; > > > > next_marker = data->file->offset; > > next_marker += grub_jpeg_get_word (data); > > > > if (grub_jpeg_get_byte (data) != 8) > > return grub_error (GRUB_ERR_BAD_FILE_TYPE, > > "jpeg: only 8-bit precision is supported"); > > > > data->image_height = grub_jpeg_get_word (data); > > data->image_width = grub_jpeg_get_word (data); > > > > if ((!data->image_height) || (!data->image_width)) > > return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid image size"); > > > > cc = grub_jpeg_get_byte (data); > > if (cc != 3) > > return grub_error (GRUB_ERR_BAD_FILE_TYPE, > > "jpeg: component count must be 3"); > > > > for (i = 0; i < cc; i++) > > { > > int id, ss; > > > > id = grub_jpeg_get_byte (data) - 1; > > if ((id < 0) || (id >= 3)) > > return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid index"); > > > > ss = grub_jpeg_get_byte (data); /* sampling factor */ > > if (!id) > > { > > data->vs = ss & 0xF; /* vertical sampling */ > > data->hs = ss >> 4; /* horizontal sampling */ > > Please use correct interpunction. I'm sorry, what do you mean by correct interpunction ? -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Bug fix for parser
On Jan 15, 2008 8:41 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Right. I am completely unhappy with the lexer as it is now... :-/ > The main reason for writing it manually is that flex depends on all > kinds of stuff I do not want in GRUB. Like reading files, etc. > > Thanks a lot for fixing bugs related to scripting. Lately I am rather > busy and I was the only person who worked on it. More testing, better > error handling, etc is appriciated. > > I still have an unfinished "test" command on my HD. thanks, if there is no problem, i would commit this now. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] jpeg image reader
On Jan 15, 2008 8:46 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Robert Millan <[EMAIL PROTECTED]> writes: > > > On Tue, Jan 15, 2008 at 01:21:04PM +0100, Marco Gerards wrote: > >> >> > >> >> I do not think these algorithms can be copyrighted and are in the > >> >> public domain? Can you check this? > >> > > >> > Only actual code can be copyrighted. Algorithms can only be patented. > >> > > >> > Copyright expires into public domain, but this is only theoretical since > >> > they reform copyright law every 20 years to extend it. > >> > > >> > I think only patents actually expire in practice. > >> > >> What I meant was, that the code Bean used is public domain already. > >> AFAIK that's not uncommon for reference implementations. > > > > It shouldn't be. I wouldn't be too sure though. > > Bean will know :-) I think copyright should not be the problem, the IJG's version can practically be used in anyway you wanted. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] jpeg image reader
On Jan 15, 2008 10:27 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > > [...] > > >> > for (i = 0; i < cc; i++) > >> > { > >> > int id, ss; > >> > > >> > id = grub_jpeg_get_byte (data) - 1; > >> > if ((id < 0) || (id >= 3)) > >> > return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid index"); > >> > > >> > ss = grub_jpeg_get_byte (data); /* sampling factor */ > >> > if (!id) > >> > { > >> > data->vs = ss & 0xF; /* vertical sampling */ > >> > data->hs = ss >> 4; /* horizontal sampling */ > >> > >> Please use correct interpunction. > > > > I'm sorry, what do you mean by correct interpunction ? > > That I prefer: > > /* vertical sampling */ -> /* Vertical sampling. */ > > Same for the other two lines. With this change, only the legal > question remains. oh, i see. The IJG's source code: http://www.ijg.org/files/jpegsrc.v6b.tar.gz there is a legal issue section in the README file. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Bug fix for parser
On Jan 15, 2008 10:33 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > > > On Jan 15, 2008 8:41 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > >> Right. I am completely unhappy with the lexer as it is now... :-/ > >> The main reason for writing it manually is that flex depends on all > >> kinds of stuff I do not want in GRUB. Like reading files, etc. > >> > >> Thanks a lot for fixing bugs related to scripting. Lately I am rather > >> busy and I was the only person who worked on it. More testing, better > >> error handling, etc is appriciated. > >> > >> I still have an unfinished "test" command on my HD. > > > > thanks, if there is no problem, i would commit this now. > > If you mean your patch, that's fine for me. Please do not forget to > rename script_1. Are there any other issues I brought up? ok, commited. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] jpeg image reader
On Jan 16, 2008 12:01 AM, Marco Gerards <[EMAIL PROTECTED]> wrote: > The license state that their README should be distributed together > with GRUB 2, if I understand it correctly. As you might guess, this > is not acceptable. Please be careful when using code from other > projects (or even better: totally avoid it!), at least tell us you did > so when submitting a patch. Are you sure only the color space > conversion and the IDCT are the only things from the jpeg group you > used? Please double check... > > If it is only color space conversion and IDCT, I am sure we can write > our own code for this. If you do now have the knowledge, I can help > you with this or point you to some documentation, if you'd like. > > I hope you understand my situation... I really like your code and I > want to help in any way to integrate it into GRUB 2. I think the color conversion is easy, i can change it myself. but idct is tricky, it use AA&N algorithm, which is the only effective solution. besides, the code is not exactly the same, i just take the basic idea. (it's in jidctfst.c) -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] jpeg image reader
(data, 0, data->ydu[r2 * 2 + c2]); grub_jpeg_decode_du (data, 1, data->cbdu); grub_jpeg_decode_du (data, 2, data->crdu); if (grub_errno) return grub_errno; nr2 = (r1 == nr1 - 1) ? (data->image_height - r1 * vb) : vb; nc2 = (c1 == nc1 - 1) ? (data->image_width - c1 * hb) : hb; ptr2 = ptr1; for (r2 = 0; r2 < nr2; r2++, ptr2 += (data->image_width - nc2) * 3) for (c2 = 0; c2 < nc2; c2++, ptr2 += 3) { int i0, yy, cr, cb; i0 = (r2 / data->vs) * 8 + (c2 / data->hs); cr = data->crdu[i0]; cb = data->cbdu[i0]; yy = data->ydu[(r2 / 8) * 2 + (c2 / 8)][(r2 % 8) * 8 + (c2 % 8)]; grub_jpeg_ycrcb_to_rgb (yy, cr, cb, ptr2); } } return grub_errno; } static grub_uint8_t grub_jpeg_get_marker (struct grub_jpeg_data *data) { grub_uint8_t r; r = grub_jpeg_get_byte (data); if (r != JPEG_ESC_CHAR) { grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid maker"); return 0; } return grub_jpeg_get_byte (data); } static grub_err_t grub_jpeg_decode_jpeg (struct grub_jpeg_data *data) { if (grub_jpeg_get_marker (data) != JPEG_MARKER_SOI) /* Start Of Image. */ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid jpeg file"); while (grub_errno == 0) { grub_uint8_t marker; marker = grub_jpeg_get_marker (data); if (grub_errno) break; #ifdef JPEG_DEBUG grub_printf ("jpeg marker: %x\n", marker); #endif switch (marker) { case JPEG_MARKER_DHT: /* Define Huffman Table. */ grub_jpeg_decode_huff_table (data); break; case JPEG_MARKER_DQT: /* Define Quantization Table. */ grub_jpeg_decode_quan_table (data); break; case JPEG_MARKER_SOF0: /* Start Of Frame 0. */ grub_jpeg_decode_sof (data); break; case JPEG_MARKER_SOS: /* Start Of Scan. */ grub_jpeg_decode_sos (data); break; case JPEG_MARKER_EOI: /* End Of Image. */ return grub_errno; default:/* Skip unrecognized marker. */ { grub_uint16_t sz; sz = grub_jpeg_get_word (data); if (grub_errno) return (grub_errno); grub_file_seek (data->file, data->file->offset + sz - 2); } } } return grub_errno; } static grub_err_t grub_video_reader_jpeg (struct grub_video_bitmap **bitmap, const char *filename) { grub_file_t file; struct grub_jpeg_data *data; file = grub_file_open (filename); if (!file) return grub_errno; data = grub_malloc (sizeof (*data)); if (data != NULL) { int i; grub_memset (data, 0, sizeof (*data)); data->file = file; data->bitmap = bitmap; grub_jpeg_decode_jpeg (data); for (i = 0; i < 4; i++) if (data->huff_value[i]) grub_free (data->huff_value[i]); grub_free (data); } if (grub_errno != GRUB_ERR_NONE) { grub_video_bitmap_destroy (*bitmap); *bitmap = 0; } grub_file_close (file); return grub_errno; } #if defined(JPEG_DEBUG) static grub_err_t grub_cmd_jpegtest (struct grub_arg_list *state __attribute__ ((unused)), int argc, char **args) { struct grub_video_bitmap *bitmap = 0; if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); grub_video_reader_jpeg (&bitmap, args[0]); if (grub_errno != GRUB_ERR_NONE) return grub_errno; grub_video_bitmap_destroy (bitmap); return GRUB_ERR_NONE; } #endif static struct grub_video_bitmap_reader jpg_reader = { .extension = ".jpg", .reader = grub_video_reader_jpeg, .next = 0 }; static struct grub_video_bitmap_reader jpeg_reader = { .extension = ".jpeg", .reader = grub_video_reader_jpeg, .next = 0 }; GRUB_MOD_INIT (video_reader_jpeg) { grub_video_bitmap_reader_register (&jpg_reader); grub_video_bitmap_reader_register (&jpeg_reader); #if defined(JPEG_DEBUG) grub_register_command ("jpegtest", grub_cmd_jpegtest, GRUB_COMMAND_FLAG_BOTH, "jpegtest FILE", "Tests loading of JPEG bitmap.", 0); #endif } GRUB_MOD_FINI (video_reader_jpeg) { #if defined(JPEG_DEBUG) grub_unregister_command ("jpegtest"); #endif grub_video_bitmap_reader_unregister (&jpeg_reader); grub_video_bitmap_reader_unregister (&jpg_reader); } -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: nested functions used by multiboot2 loader corrupt stack
On Jan 17, 2008 7:05 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > > I got pretty confused at this one. Maybe someone can sort this out. I'm > afraid I can't :-( > > It seems that at some point when loading multiboot2 images, our stack is > corrupted for no apparent reason and one of the hooks in our nested function > calls ends up jumping to the wrong place. > > This hangs qemu 0.9.0, but qemu 0.9.1 aborts with "triple fault" message. > > I added a few printf calls to trace what's going on, and switched to serial > terminal so that the output can be captured. My debugging patch is attached. > This is the output: > > grub_mb2_load_elf: going to call grub_elf32_load using > grub_mb2_arch_elf32_hook=0x7ffc72c as hook > grub_elf32_load: going to call grub_elf32_phdr_iterate using > grub_elf32_load_segment=0x7dda4 as hook, and _load_hook=0x7ffc72c as hook's > hook > grub_elf32_phdr_iterate: going to call hook=0x7dda4 using hook_arg=0x7ffc72c > as hook > grub_elf32_load_segment: going to call load_hook=0x7dd9c > qemu: fatal: triple fault > EAX=0004be50 EBX=0004bf30 ECX=0008de66 EDX=0007dd2c > ESI=0004be50 EDI=0007dd9c EBP=0007dd3c ESP=0007dd10 > EIP=0007dda0 EFL=0002 [---] CPL=0 II=0 A20=1 SMM=0 HLT=0 > > This seems to indicate that grub_elf32_phdr_iterate() called its hook, > 0x7dda4, > aka grub_elf32_load_segment() with proper hook_arg parameter = 0x7ffc72c, aka > grub_mb2_arch_elf32_hook(). > > When grub_elf32_load_segment() starts, its hook_arg parameter (now known as > load_hook) has been corrupted and now points at 0x7dd9c. The other two > parameters in this function are not tainted, only the third one is. > > I'm not sure how to proceed from here. I really miss a debugger in these > cases :-( > > Also attaching the sample multiboot2 program I used. I'm not sure of its > correctness, but nevertheless GRUB shouldn't crash because of incorrect > images; specially not at this point. You need to add NESTED_FUNC_ATTR to nested callback function that use local variable. here is the patch: diff --git a/kern/elf.c b/kern/elf.c index b362949..4978a27 100644 --- a/kern/elf.c +++ b/kern/elf.c @@ -139,7 +139,7 @@ grub_elf32_load_phdrs (grub_elf_t elf) static grub_err_t grub_elf32_phdr_iterate (grub_elf_t elf, -int (*hook) (grub_elf_t, Elf32_Phdr *, void *), +int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf32_Phdr *, void *), void *hook_arg) { Elf32_Phdr *phdrs; @@ -219,9 +219,8 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook, grub_size_t load_size = 0; grub_err_t err; - auto int grub_elf32_load_segment (grub_elf_t elf, Elf32_Phdr *phdr, - void *hook); - int grub_elf32_load_segment (grub_elf_t elf, Elf32_Phdr *phdr, void *hook) + auto int NESTED_FUNC_ATTR grub_elf32_load_segment (grub_elf_t elf, Elf32_Phdr *phdr, void *hook); + int NESTED_FUNC_ATTR grub_elf32_load_segment (grub_elf_t elf, Elf32_Phdr *phdr, void *hook) { grub_elf32_load_hook_t load_hook = (grub_elf32_load_hook_t) hook; grub_addr_t load_addr; -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: nested functions used by multiboot2 loader corrupt stack
On Jan 17, 2008 8:21 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Thu, Jan 17, 2008 at 04:15:23PM +0800, Bean wrote: > > > > You need to add NESTED_FUNC_ATTR to nested callback function that use > > local variable. here is the patch: > > Glad to see you found the reason! > > But I don't get it. I see that: > > #define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (2))) > > so does this mean in one of the calls the caller and callee disagreed about > how the third param is passed? > > Also, we have a lot of nested functions without this macro. How does one > distinguish the ones that need it from the ones that don't? Embedded function used %ecx to store the pointer to it's parent's stack. However, the program is compiled using option -mregparm=3, which means it can use up to 3 registry to pass parameter.In grub_elf32_load_segment, there are three parameter elf, phdr and hook, which will take up %eax, %edx and %ecx. The value of %ecx, hook, will be overwritten. Use NESTED_FUNC_ATTR ensure that only the first two parameter will be passed using registry This problem can occur when the following conditions are true: 1, Use embedded function as callback. 2, The embedded function use local variable in it's parent's stack. 3, The embedded function has at least three parameters. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: hfs breakage
if (found == -1) -return 0; + if (found == -1) +return 0; + root_idx = found; +} while (! isleaf); + /* If there was a matching record in this leaf node, continue the iteration until the last record was found. */ - if (isleaf) -{ - grub_hfs_iterate_records (data, 0, next, 1, it_dir); - return grub_errno; -} - - return grub_hfs_iterate_dir (data, found, dir, hook); + grub_hfs_iterate_records (data, 0, next, 1, it_dir); + return grub_errno; } -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] memdisk plus lnxboot extension
On Jan 21, 2008 7:24 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Sun, Dec 30, 2007 at 02:48:24PM +0100, Robert Millan wrote: > > On Sat, Dec 29, 2007 at 05:05:16PM +0800, Bean wrote: > > > Hi, > > > > > > This patch is based on robert's memdisk patch. I also modify lnxboot > > > so that it can load the memdisk using initrd. Changes: > > > > I'd really like to keep this separate, and get memdisk merged first. > > > > I recall Marco had some objections to memdisk, so I'd like to get that > > sorted > > out before we start building on it. > > memdisk is merged now, but as for supporting an initrd hack to load it, I'm > not > sure if that's a good idea. > > Currently, you can do: > > grub-mkimage -m filesystem -o core.img > cat lnxboot.img core.img > linux_image > > what you propose would be: > > grub-mkimage -o core.img > cat lnxboot.img core.img > linux_image > [ use filesystem as initrd ] > > but, what is the advantage in that? Is there any use case in which the first > option is not good but the second is? Some advantages of using external initrd: 1, Resolve size limit for core.img core.img can't be too large, otherwise it doesn't fit inside conventional memory. external initrd doesn't have this problem. 2. Easy to modify users may not know how to create core.img, but modifying files in a, say, tar or cpio archive is very easy. They can do simple tasks like replacing splash image without too much knowledge of grub2. 3. Multiple configuration We can use the same core.img, but different initrd to start grub2 with different configuration. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Can anybody give out a list of file systems the GRUB2 support?Thanks a lot.
2008/1/22 heguanbo <[EMAIL PROTECTED]>: > Dear all > > Can anybody give out a list of file systems the GRUB2 support?Thanks a lot. file system modules are listed in fs.lst: affs cpio ext2 fat hfs hfsplus iso9660 jfs minix ntfs reiserfs sfs ufs xfs -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub_cpio_find_file() finds unexisting files (Re: [PATCH] memdisk + grub-mkrescue)
On Jan 22, 2008 10:01 AM, Pavel Roskin <[EMAIL PROTECTED]> wrote: > > On Mon, 2008-01-21 at 22:09 +0100, Robert Millan wrote: > > On Mon, Jan 21, 2008 at 12:47:06PM -0500, Pavel Roskin wrote: > > > > > > I've tested the patch, and it seems to be OK, although I was surprised > > > to see an empty menu on startup. Perhaps a command line would be more > > > appropriate in absence of grub.cfg? > > > > I wanted to send a new mail about this, and then forgot. > > > > This is because of a bug in cpio.mod. The menu code thinks grub.cfg is > > present due to grub_cpio_find_file() returning here: > > > > if (!hd.name[0]) > > { > > *ofs = 0; > > return GRUB_ERR_NONE; > > } > > > > but I'm too clueless about tar format to figure this out. > > I guess the meaning of GRUB_ERR_NONE is confusing (no file vs. no > error), and the return value of grub_cpio_find_file() is not well > defined. > > Perhaps it should be GRUB_ERR_FILE_NOT_FOUND instead. you're right, i didn't notice this previously. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: hfs breakage
On Jan 21, 2008 6:38 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > Hi Bean, > > Thanks for picking this one up! > > [...] > > >> Moreover, if I mount the image as loop in Linux and remove files "grub" > >> and "grub.cfg", "ls" in grub-emu will go into infinite loop and print > >> "ofboot.b pc.mod raid.mod reboot.mod reiserfs.mod search.mod sfs.mod > >> sun.mod suspend.mod terminal.mod" over and over again. > > > > I think i figure out the problem, please try the following patch. > > > > * fs/hfs.c : Add magic values for cnid > > Did you forget the function name? perhaps i should use a name for the enum, something like hfs_cnid_t. > > > (grub_hfs_iterate_records): Use the correct file number for extents > > and catalog file. Fix problem in next index calculation. > > This line is too long, I think? Can you wrap this manually? ok. > > > (grub_hfs_find_node): Replace recursive function call with loop. > > (grub_hfs_iterate_dir): Replace recursive function call with loop. > > :-) > > I guess this code sucked a bit ;-) is the fix ok ? > > > diff --git a/fs/hfs.c b/fs/hfs.c > > index e8e9c3e..3480d3e 100644 > > --- a/fs/hfs.c > > +++ b/fs/hfs.c > > @@ -43,6 +43,16 @@ enum > > GRUB_HFS_FILETYPE_FILE = 2 > >}; > > > > +/* Catalog node ID (CNID). */ > > +enum > > + { > > +GRUB_HFS_CNID_ROOT_PARENT = 1, > > +GRUB_HFS_CNID_ROOT = 2, > > +GRUB_HFS_CNID_EXT = 3, > > +GRUB_HFS_CNID_CAT = 4, > > +GRUB_HFS_CNID_BAD = 5 > > + }; > > This is missing in the changelog entry. > > > /* A node descriptor. This is the header of every node. */ > > struct grub_hfs_node > > { > > @@ -447,7 +457,8 @@ grub_hfs_iterate_records (struct grub_hfs_data > > *data, int type, int idx, > > > >/* Read the node into memory. */ > >blk = grub_hfs_block (data, dat, > > - 0, idx / (data->blksz / nodesize), 0); > > +(type == 0) ? GRUB_HFS_CNID_CAT : > > GRUB_HFS_CNID_EXT, > > + idx / (data->blksz / nodesize), 0); > > What was the problem here? extents file and catalog file uses special file number, 3 and 4, respectively. for example, in sda.img, sector 5: 00 00 00 00 00 00 00 00 FF 01 00 01 00 00 07 00 00 00 00 04 00 2D 04 C3 00 0F 00 00 00 00 00 00 this is the first extent of catalog file that's not stored in super block, you can see that it use 4 as the file number. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] jpeg image reader
On Jan 21, 2008 6:21 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > Hi, > > > i finish converting the idct and color code, now it should be ok. > > If you are 100% sure all code is yours and there are no legal issues, > feel free to commit it. Your code looks good to me :-) Committed. when you have time, please review my png patch as well. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] memdisk plus lnxboot extension
On Jan 22, 2008 9:57 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Tue, Jan 22, 2008 at 12:25:49PM +0800, Bean wrote: > > > but, what is the advantage in that? Is there any use case in which the > > > first > > > option is not good but the second is? > > > > Some advantages of using external initrd: > > > > 1, Resolve size limit for core.img > > core.img can't be too large, otherwise it doesn't fit inside > > conventional memory. external initrd doesn't have this problem. > > Ok. > > > 2. Easy to modify > > users may not know how to create core.img, but modifying files in a, > > say, tar or cpio archive is very easy. They can do simple tasks like > > replacing splash image without too much knowledge of grub2. > > > > 3. Multiple configuration > > We can use the same core.img, but different initrd to start grub2 with > > different configuration. > > I don't think these two make a big difference, but well. > > No objection from me, then. this is the patch, please try it. * boot/i386/pc/lnxboot.S (data_start) : Simplify code. (real_code_2) : Set grub_memdisk_image_addr using initrd address. * include/grub/i386/pc/boot.h : New constant GRUB_BOOT_MACHINE_LNX_LENG_OFFSET. * include/grub/i386/pc/kernel.h : New constant GRUB_KENRL_MACHINE_MEMDISK_IMAGE_ADDR. New variable grub_memdisk_image_addr. * kern/i386/pc/init.c (grub_arch_memdisk_addr) : Use grub_memdisk_image_addr if it isn't zero. * kern/i386/pc/startup.S : New variable grub_memdisk_image_addr. * util/i386/pc/grub-mkimage.c (generate_image) : Add is_linux parameter. If it's set, use lnxboot.img as header instead of diskboot.img. (options): Add "linux"|'x' option (main): Parse --linux|-x option, and pass its value to generate_image. diff --git a/boot/i386/pc/lnxboot.S b/boot/i386/pc/lnxboot.S index f1a4ded..6503e26 100644 --- a/boot/i386/pc/lnxboot.S +++ b/boot/i386/pc/lnxboot.S @@ -36,22 +36,7 @@ .globl start, _start data_start: - pushw %cs - popw%ds - xorl%eax, %eax - xorl%ebx, %ebx - calldata_next - -data_next: - popw%bx - movw%cs, %ax - shll$4, %eax - leal0x200 + data_start - data_next(%ebx,%eax), %eax - movzbl setup_sects - data_next(%bx), %ecx - shll$9, %ecx - addl%ecx, %eax - movl%eax, code32_start - data_next(%bx) - + xorl%ebp, %ebp jmp linux_next . = data_start + 0x1F1 @@ -76,7 +61,7 @@ boot_flag: start: _start: - jmp linux_code + jmp linux_init .ascii "HdrS" // Header signature .word 0x0203 // Header version number @@ -134,9 +119,10 @@ reg_edx: data_leng: .long 0 -linux_code: +linux_init: movw%cs:(reg_edx - start), %dx + movl%cs:(code32_start - start), %ebp linux_next: @@ -164,9 +150,6 @@ real_code: movw%si, %ss movw$(CODE_ADDR), %sp - pushl %esi - pushl %edi - // Move itself to 0:CODE_ADDR cld @@ -183,17 +166,26 @@ real_code: real_code_2: + xchgl %ebp, %esi + orl %esi, %esi + jnz 1f + movw%ds, %si + shll$4, %esi + addl%ebp, %esi +1: + pushw %es popw%ds - movl(ramdisk_image - start), %esi - or %esi, %esi + movl(data_leng - start), %ecx + or %ecx, %ecx jnz 1f - movl(code32_start - start), %esi + movl(ramdisk_image - start), %esi + movl(ramdisk_size - start), %ecx + addl$0x200, %esi + subl$0x200, %ecx 1: - movl$0x200, %ecx - addl%ecx, %esi movl$DATA_ADDR, %edi callmove_memory @@ -204,13 +196,17 @@ real_code_2: movsbl (reg_edx + 2 - start), %eax movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART) - movl%ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx - addl$(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx + movl(data_leng - start), %eax + or %eax, %eax + jz 1f + movl(ramdisk_size - start), %eax + or %eax, %eax + jz 1f - callmove_memory - - popl%edi - popl%esi + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE) + movl(ramdisk_image - start), %eax + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_ADDR) +1: ljmp$(DATA_ADDR >> 4), $0 @@ -261,8 +257,8 @@ move_memory: 2: - leal(%esi, %eax), %esi - leal(%edi, %eax), %edi
Re: [PATCH] memdisk plus lnxboot extension
On Jan 23, 2008 12:51 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > I don't like this very much. We don't have grub-mkimage options to > concatenate > it with boot.img, so why with lnxboot.img ? The reason for new option is that the length of core.img needs to stored in lnxboot.img. Previously, i calculate the size using information in core.img header, but now there is issue, for example, 1. kernel lnxboot.img initrd core.img 2. cat lnxboot.img core.img > grub2.bin kernel grub2.bin initrd memdisk 1 and 2 looks the same to lnxboot header, it can't decide initrd is used as memdisk or core.img. However, 1 may not be that useful after all, we can disable this kind of usage. > Also, I can only think of very specific situations in which this interface > would be useful (that is, when firmware has only a linux loader). It makes > sense to me as a compatibility layer, yes. > > But it seems you want it as a general-purpose option; for that, why not make > it saner like multiboot? I don't think it's a good idea to compromise our > boot semantics because of the ones legacy Linux has. is multiboot support memdisk or something similar ? -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: UFS (FFS) support seems broken in grub2
This patch should fix the problem. diff --git a/fs/ufs.c b/fs/ufs.c index 917d9a2..bef19e6 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -38,6 +38,8 @@ #define GRUB_UFS_ATTR_DIR 04 +#define GRUB_UFS_MAX_VOLLEN32 + /* Calculate in which group the inode can be found. */ #define inode_group(inode,sblock) () @@ -86,7 +88,12 @@ struct grub_ufs_sblock /* The frags per cylinder group. */ grub_uint32_t frags_per_group; - grub_uint8_t unused7[1180]; + grub_uint8_t unused7[488]; + + /* Volume name for UFS2. */ + grub_uint8_t volume_name[GRUB_UFS_MAX_VOLLEN]; + + grub_uint8_t unused8[660]; /* Magic value to check if this is really a UFS filesystem. */ grub_uint32_t magic; @@ -393,13 +400,13 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino) static grub_err_t grub_ufs_find_file (struct grub_ufs_data *data, const char *path) { - char fpath[grub_strlen (path)]; + char fpath[grub_strlen (path) + 1]; char *name = fpath; char *next; unsigned int pos = 0; int dirino; - grub_strncpy (fpath, path, grub_strlen (path)); + grub_strcpy (fpath, path); /* Skip the first slash. */ if (name[0] == '/') @@ -649,10 +656,30 @@ grub_ufs_close (grub_file_t file) static grub_err_t -grub_ufs_label (grub_device_t device __attribute ((unused)), - char **label __attribute ((unused))) +grub_ufs_label (grub_device_t device,char **label) { - return GRUB_ERR_NONE; + struct grub_ufs_data *data = 0; + +#ifndef GRUB_UTIL + grub_dl_ref (my_mod); +#endif + + *label = 0; + + data = grub_ufs_mount (device->disk); + if (data) +{ + if (data->ufs_type == UFS2) +*label = grub_strdup ((char *) data->sblock.volume_name); +} + +#ifndef GRUB_UTIL + grub_dl_unref (my_mod); +#endif + + grub_free (data); + + return grub_errno; } -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] memdisk plus lnxboot extension
On Jan 23, 2008 4:54 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > When is this feature useful? Can you give an example? More features > can mean more bugs, more maintainance work, etc. If the feature is > not worthwhile for more than one person, I am not sure if it should be > included. Perhaps a better explaination of the problem to solve, > instead of what the patch does might help here. the most important usage of external initrd is to overcome the size limit of core.img. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: UFS (FFS) support seems broken in grub2
On Jan 24, 2008 12:15 AM, walt <[EMAIL PROTECTED]> wrote: > Bean wrote: > > This patch should fix the problem... > > Yes, thanks! I had to use the -l flag before patch would use it, > and even then the last hunk needed increased fuzz. > > Are you going to commit it today? thanks for the testing, if you have ufs2, please check it as well. this is the new patch after adding changelog: * fs/ufs.c (GRUB_UFS_MAX_VOLLEN) : New constant. (grub_ufs_sblock) : New member volume name. (grub_ufs_find_file) : Fix string copy bug. (grub_ufs_label) : Implement this function properly. diff --git a/fs/ufs.c b/fs/ufs.c index 917d9a2..a1fdcda 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -38,6 +38,8 @@ #define GRUB_UFS_ATTR_DIR 04 +#define GRUB_UFS_MAX_VOLLEN32 + /* Calculate in which group the inode can be found. */ #define inode_group(inode,sblock) () @@ -86,7 +88,12 @@ struct grub_ufs_sblock /* The frags per cylinder group. */ grub_uint32_t frags_per_group; - grub_uint8_t unused7[1180]; + grub_uint8_t unused7[488]; + + /* Volume name for UFS2. */ + grub_uint8_t volume_name[GRUB_UFS_MAX_VOLLEN]; + + grub_uint8_t unused8[660]; /* Magic value to check if this is really a UFS filesystem. */ grub_uint32_t magic; @@ -393,13 +400,13 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino) static grub_err_t grub_ufs_find_file (struct grub_ufs_data *data, const char *path) { - char fpath[grub_strlen (path)]; + char fpath[grub_strlen (path) + 1]; char *name = fpath; char *next; unsigned int pos = 0; int dirino; - grub_strncpy (fpath, path, grub_strlen (path)); + grub_strcpy (fpath, path); /* Skip the first slash. */ if (name[0] == '/') @@ -649,10 +656,30 @@ grub_ufs_close (grub_file_t file) static grub_err_t -grub_ufs_label (grub_device_t device __attribute ((unused)), - char **label __attribute ((unused))) +grub_ufs_label (grub_device_t device, char **label) { - return GRUB_ERR_NONE; + struct grub_ufs_data *data = 0; + +#ifndef GRUB_UTIL + grub_dl_ref (my_mod); +#endif + + *label = 0; + + data = grub_ufs_mount (device->disk); + if (data) +{ + if (data->ufs_type == UFS2) +*label = grub_strdup ((char *) data->sblock.volume_name); +} + +#ifndef GRUB_UTIL + grub_dl_unref (my_mod); +#endif + + grub_free (data); + + return grub_errno; } -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: hfs breakage
On Jan 23, 2008 5:01 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > > On Jan 21, 2008 6:38 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > >> Bean <[EMAIL PROTECTED]> writes: > >> > >> Hi Bean, > >> > >> Thanks for picking this one up! > >> > >> [...] > >> > >> >> Moreover, if I mount the image as loop in Linux and remove files "grub" > >> >> and "grub.cfg", "ls" in grub-emu will go into infinite loop and print > >> >> "ofboot.b pc.mod raid.mod reboot.mod reiserfs.mod search.mod sfs.mod > >> >> sun.mod suspend.mod terminal.mod" over and over again. > >> > > >> > I think i figure out the problem, please try the following patch. > >> > > >> > * fs/hfs.c : Add magic values for cnid > >> > >> Did you forget the function name? > > > > perhaps i should use a name for the enum, something like hfs_cnid_t. > > That might help :-) > > Otherwise you have to list all the values in the changelog entry... > > >> > (grub_hfs_find_node): Replace recursive function call with loop. > >> > (grub_hfs_iterate_dir): Replace recursive function call with loop. > >> > >> :-) > >> > >> I guess this code sucked a bit ;-) > > > > is the fix ok ? > > Yes, it seems so to me at least. I was talking about my code :-) ok then, i just revert to the original code. however, there is still a small bug in grub_hfs_find_node. please see the new patch below. > >> What was the problem here? > > > > extents file and catalog file uses special file number, 3 and 4, > > respectively. for example, in sda.img, sector 5: > > > > 00 00 00 00 00 00 00 00 FF 01 00 01 00 00 07 00 > > 00 00 00 04 00 2D 04 C3 00 0F 00 00 00 00 00 00 > > > > this is the first extent of catalog file that's not stored in super > > block, you can see that it use 4 as the file number. > > This applies in general? I do not have a working mac around ATM to > test with... i guess so, but i don't have mac to test on, maybe someone can verify it. * fs/hfs.c (grub_hfs_cnid_t): Add magic values for cnid (grub_hfs_iterate_records): Use the correct file number for extents and catalog file. Fix problem in next index calculation. (grub_hfs_find_node): Fix a bug that can cause the function to return 1 even if no match is found. diff --git a/fs/hfs.c b/fs/hfs.c index e8e9c3e..f2afa8a 100644 --- a/fs/hfs.c +++ b/fs/hfs.c @@ -43,6 +43,16 @@ enum GRUB_HFS_FILETYPE_FILE = 2 }; +/* Catalog node ID (CNID). */ +enum + { +GRUB_HFS_CNID_ROOT_PARENT = 1, +GRUB_HFS_CNID_ROOT = 2, +GRUB_HFS_CNID_EXT = 3, +GRUB_HFS_CNID_CAT = 4, +GRUB_HFS_CNID_BAD = 5 + } grub_hfs_cnid_t; + /* A node descriptor. This is the header of every node. */ struct grub_hfs_node { @@ -447,7 +457,8 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx, /* Read the node into memory. */ blk = grub_hfs_block (data, dat, - 0, idx / (data->blksz / nodesize), 0); +(type == 0) ? GRUB_HFS_CNID_CAT : GRUB_HFS_CNID_EXT, + idx / (data->blksz / nodesize), 0); blk += (idx % (data->blksz / nodesize)); if (grub_errno) return grub_errno; @@ -481,10 +492,7 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx, return 0; } - if (idx % (data->blksz / nodesize) == 0) - idx = grub_be_to_cpu32 (node.node.next); - else - idx++; + idx = grub_be_to_cpu32 (node.node.next); } while (idx && this); return 0; @@ -501,6 +509,7 @@ grub_hfs_find_node (struct grub_hfs_data *data, char *key, { int found = -1; int isleaf = 0; + int done = 0; auto int node_found (struct grub_hfs_node *, struct grub_hfs_record *); @@ -532,6 +541,8 @@ grub_hfs_find_node (struct grub_hfs_data *data, char *key, /* Found it */ if (cmp == 0) { + done = 1; + grub_memcpy (datar, rec->data, rec->datalen < datalen ? rec->datalen : datalen); return 1; @@ -548,7 +559,7 @@ grub_hfs_find_node (struct grub_hfs_data *data, char *key, return 0; if (isleaf) -return 1; +return done; return grub_hfs_find_node (data, key, found, type, datar, datalen); } -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: netboot/UNDI status
On Jan 23, 2008 11:46 PM, Douglas Ward <[EMAIL PROTECTED]> wrote: > Robert Millan wrote: > > On Wed, Jan 23, 2008 at 12:38:31PM +0100, Marco Gerards wrote: > > > >> But to be honest, there are more important issues than networking in > >> the short term... > >> > > > > ACK. Let's focus on what GRUB excels at, instead of trying to compete > > with etherboot just yet... > > > > > actually what i need isn't something that competes with etherboot/gpxe > but something that competes with pxelinux. UNDI support is not difficult, i have written one for grub4dos. maybe i can port it to grub2 sometime. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] PNG image reader
if (data->wp >= WSIZE) + data->wp = 0; + + pos++; + if (pos >= WSIZE) + pos = 0; + + len--; + } + } +} + + return grub_errno; +} + +static grub_err_t +grub_png_decode_image_data (struct grub_png_data *data) +{ + grub_uint8_t cmf, flg; + int final; + + cmf = grub_png_get_byte (data); + flg = grub_png_get_byte (data); + + if ((cmf & 0xF) != Z_DEFLATED) +return grub_error (GRUB_ERR_BAD_FILE_TYPE, + "png: only support deflate compression method"); + + if (flg & Z_FLAG_DICT) +return grub_error (GRUB_ERR_BAD_FILE_TYPE, + "png: dictionary not supported"); + + do +{ + int block_type; + + final = grub_png_get_bits (data, 1); + block_type = grub_png_get_bits (data, 2); + + switch (block_type) + { + case INFLATE_STORED: + { + grub_uint16_t i, len; + + data->bit_count = 0; + len = grub_png_get_byte (data); + len += ((grub_uint16_t) grub_png_get_byte (data)) << 8; + + grub_png_get_byte (data); /* skip NLEN field */ + grub_png_get_byte (data); + + for (i = 0; i < len; i++) + grub_png_output_byte (data, grub_png_get_byte (data)); + + break; + } + + case INFLATE_FIXED: + return grub_error (GRUB_ERR_BAD_FILE_TYPE, +"png: block type fixed not supported"); + + case INFLATE_DYNAMIC: + grub_png_init_dynamic_block (data); + grub_png_read_dynamic_block (data); + break; + + default: + return grub_error (GRUB_ERR_BAD_FILE_TYPE, +"png: unknown block type"); + } +} + while ((!final) && (grub_errno == 0)); + + /* Skip adler checksum. */ + grub_png_get_dword (data); + + /* Skip crc checksum. */ + grub_png_get_dword (data); + + return grub_errno; +} + +static const grub_uint8_t png_magic[8] = + { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0x0a }; + +static grub_err_t +grub_png_decode_png (struct grub_png_data *data) +{ + grub_uint8_t magic[8]; + + if (grub_file_read (data->file, (char *) &magic[0], 8) != 8) +return grub_errno; + + if (grub_memcmp (magic, png_magic, sizeof (png_magic))) +return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: not a png file"); + + while (grub_errno == 0) +{ + grub_uint32_t len, type; + + len = grub_png_get_dword (data); + type = grub_png_get_dword (data); + + switch (type) + { + case CHUNK_IHDR: + grub_png_decode_image_header (data); + break; + + case CHUNK_IDAT: + data->inside_idat = 1; + data->idat_remain = len; + data->bit_count = 0; + + grub_png_decode_image_data (data); + + data->inside_idat = 0; + break; + + case CHUNK_IEND: + return grub_errno; + + default: + grub_file_seek (data->file, data->file->offset + len + 4); + } +} + + return grub_errno; +} + +static grub_err_t +grub_video_reader_png (struct grub_video_bitmap **bitmap, + const char *filename) +{ + grub_file_t file; + struct grub_png_data *data; + + file = grub_file_open (filename); + if (!file) +return grub_errno; + + data = grub_malloc (sizeof (*data)); + if (data != NULL) +{ + grub_memset (data, 0, sizeof (*data)); + data->file = file; + data->bitmap = bitmap; + + grub_png_decode_png (data); + + grub_free (data); +} + + if (grub_errno != GRUB_ERR_NONE) +{ + grub_video_bitmap_destroy (*bitmap); + *bitmap = 0; + } + + grub_file_close (file); + return grub_errno; +} + +#if defined(PNG_DEBUG) +static grub_err_t +grub_cmd_pngtest (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **args) +{ + struct grub_video_bitmap *bitmap = 0; + + if (argc != 1) +return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); + + grub_video_reader_png (&bitmap, args[0]); + if (grub_errno != GRUB_ERR_NONE) +return grub_errno; + + grub_video_bitmap_destroy (bitmap); + + return GRUB_ERR_NONE; +} +#endif + +static struct grub_video_bitmap_reader png_reader = { + .extension = ".png", + .reader = grub_video_reader_png, + .next = 0 +}; + +GRUB_MOD_INIT (video_reader_png) +{ + grub_video_bitmap_reader_register (&png_reader); +#if defined(PNG_DEBUG) + grub_register_command ("pngtest", grub_cmd_pngtest, +GRUB_COMMAND_FLAG_BOTH, "pngtest FILE", +"Tests loading of PNG bitmap.", 0); +#endif +} + +GRUB_MOD_FINI (video_reader_png) +{ +#if defined(PNG_DEBUG) + grub_unregister_command ("pngtest"); +#endif + grub_video_bitmap_reader_unregister (&png_reader); +} -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] memdisk plus lnxboot extension
On Jan 24, 2008 12:18 AM, Bean <[EMAIL PROTECTED]> wrote: > On Jan 23, 2008 4:54 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > > When is this feature useful? Can you give an example? More features > > can mean more bugs, more maintainance work, etc. If the feature is > > not worthwhile for more than one person, I am not sure if it should be > > included. Perhaps a better explaination of the problem to solve, > > instead of what the patch does might help here. > > the most important usage of external initrd is to overcome the size > limit of core.img. this is the new patch, now no need to modify grub-mkimage, use cat just as before. * boot/i386/pc/lnxboot.S (data_start) : Simplify code. (real_code_2) : Set grub_memdisk_image_addr using initrd address. * include/grub/i386/pc/kernel.h : New constant GRUB_KENRL_MACHINE_MEMDISK_IMAGE_ADDR. New variable grub_memdisk_image_addr. * kern/i386/pc/init.c (grub_arch_memdisk_addr) : Use grub_memdisk_image_addr if it isn't zero. * kern/i386/pc/startup.S : New variable grub_memdisk_image_addr. diff --git a/boot/i386/pc/lnxboot.S b/boot/i386/pc/lnxboot.S index f1a4ded..25554d7 100644 --- a/boot/i386/pc/lnxboot.S +++ b/boot/i386/pc/lnxboot.S @@ -36,22 +36,7 @@ .globl start, _start data_start: - pushw %cs - popw%ds - xorl%eax, %eax - xorl%ebx, %ebx - calldata_next - -data_next: - popw%bx - movw%cs, %ax - shll$4, %eax - leal0x200 + data_start - data_next(%ebx,%eax), %eax - movzbl setup_sects - data_next(%bx), %ecx - shll$9, %ecx - addl%ecx, %eax - movl%eax, code32_start - data_next(%bx) - + xorl%ebp, %ebp jmp linux_next . = data_start + 0x1F1 @@ -76,7 +61,7 @@ boot_flag: start: _start: - jmp linux_code + jmp linux_init .ascii "HdrS" // Header signature .word 0x0203 // Header version number @@ -134,9 +119,10 @@ reg_edx: data_leng: .long 0 -linux_code: +linux_init: movw%cs:(reg_edx - start), %dx + movl%cs:(code32_start - start), %ebp linux_next: @@ -164,9 +150,6 @@ real_code: movw%si, %ss movw$(CODE_ADDR), %sp - pushl %esi - pushl %edi - // Move itself to 0:CODE_ADDR cld @@ -183,34 +166,53 @@ real_code: real_code_2: - pushw %es - popw%ds - - movl(ramdisk_image - start), %esi - or %esi, %esi + xchgl %ebp, %esi + orl %esi, %esi jnz 1f - movl(code32_start - start), %esi + movw%ds, %si + shll$4, %esi + addl%ebp, %esi 1: + pushw %es + popw%ds + movl$0x200, %ecx addl%ecx, %esi movl$DATA_ADDR, %edi callmove_memory - movsbl %dh, %eax - movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) + // Check for the multiboot signature + cmpl$0x1badb002, %ss:(DATA_ADDR + 0x50) + jz 1f - movsbl (reg_edx + 2 - start), %eax - movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART) + movl(ramdisk_image - start), %esi + movl(ramdisk_size - start), %ecx + movl$(DATA_ADDR - 0x200), %edi + jmp 2f + +1: + movl(ramdisk_size - start), %eax + or %eax, %eax + jz 1f + + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE) + movl(ramdisk_image - start), %eax + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_ADDR) +1: movl%ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx addl$(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx +2: callmove_memory - popl%edi - popl%esi + movsbl %dh, %eax + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) + + movsbl (reg_edx + 2 - start), %eax + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART) ljmp$(DATA_ADDR >> 4), $0 @@ -261,8 +263,8 @@ move_memory: 2: - leal(%esi, %eax), %esi - leal(%edi, %eax), %edi + addl%eax, %esi + addl%eax, %edi subl%eax, %ecx jnz 1b diff --git a/include/grub/i386/pc/kernel.h b/include/grub/i386/pc/kernel.h index ca16df7..f5d8438 100644 --- a/include/grub/i386/pc/kernel.h +++ b/include/grub/i386/pc/kernel.h @@ -37,8 +37,11 @@ /* The offset of GRUB_MEMDISK_IMAGE_SIZE. */ #define GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE 0x1c +/* The offset of GRUB_MEMDISK_IMAGE_ADDR. */ +#define GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_ADDR 0x20 + /* The offset of GRUB_PREFIX. */ -#define GRUB
Re: [PATCH] memdisk plus lnxboot extension
On Jan 24, 2008 3:14 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Thu, Jan 24, 2008 at 03:01:33AM +0800, Bean wrote: > > On Jan 24, 2008 12:18 AM, Bean <[EMAIL PROTECTED]> wrote: > > > On Jan 23, 2008 4:54 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > > > > When is this feature useful? Can you give an example? More features > > > > can mean more bugs, more maintainance work, etc. If the feature is > > > > not worthwhile for more than one person, I am not sure if it should be > > > > included. Perhaps a better explaination of the problem to solve, > > > > instead of what the patch does might help here. > > > > > > the most important usage of external initrd is to overcome the size > > > limit of core.img. > > > > this is the new patch, now no need to modify grub-mkimage, use cat > > just as before. > > Well.. even though I still don't see the motivation, I'm less concerned about > this if it's just added to lnxboot.img. > > > +VARIABLE(grub_memdisk_image_addr) > > + .long 0 > > I recall you said use of this variable could be avoided ? This variable can't be avoided. it's used by grub_arch_memdisk_addr to return the address of initrd. however, i can copy initrd to the location to make it look like core.img load it, but that means an extra memory copy. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: hfs breakage
Committed. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: UFS (FFS) support seems broken in grub2
Committed. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] memdisk plus lnxboot extension
On Jan 24, 2008 4:15 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > The region where memdisk is normally put has no size limit, only the core > image itself does. Why not load it at the same address? I just check, the lzo decompression will overwrite the area, so we can't copy initrd there. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] memdisk plus lnxboot extension
On Jan 24, 2008 5:15 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > > On Thu, Jan 24, 2008 at 05:04:56AM +0800, Bean wrote: > > On Jan 24, 2008 4:15 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > > > The region where memdisk is normally put has no size limit, only the core > > > image itself does. Why not load it at the same address? > > > > I just check, the lzo decompression will overwrite the area, so we > > can't copy initrd there. > > So where does your code copy it? currently, i don't copy it. i save the initrd address to variable grub_memdisk_image_addr, which is then used by grub_arch_memdisk_addr to locate the memdisk. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] memdisk plus lnxboot extension
On Jan 24, 2008 7:32 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > Sorry, my question was confusing; what I meant is, where is it located when > core.img is started. But Just checked in our Linux loader, and it seems to be > at a very high address. > > However, a very high address doesn't garantee that it won't be overwritten by > lzo decompression, just makes it less likely. > > Overall, this is why I don't like having to stick to a particular boot > mechanism. If our goal is overcome the size limit in memdisk, why not design > the boot mechanism ourselves? I'm not familiar with multiboot spec, does it support arbitrary kernel size ? -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] PNG image reader
On Jan 24, 2008 4:29 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > > On Jan 23, 2008 6:36 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > >> > static grub_uint32_t > >> > grub_png_get_dword (struct grub_png_data *data) > >> > { > >> > grub_uint32_t r; > >> > > >> > r = 0; > >> > >> Why this? > > > > just to make sure if grub_file_read fails, this function will return 0. > > It would better to do proper error handling. This error is never > picked up... How about: > > static grub_err_t > grub_png_get_dword (struct grub_png_data *data, grub_uint32_t *val) > > because grub_png_get_byte and grub_png_get_dword appear in many places, checking every call is not efficient. i have added test in critical place to ensure error will be caught. however, if you think strict checking is necessary, i can make the change. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] PNG image reader
On Jan 24, 2008 8:14 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > It would be nice, not required. I don't expect too much problems > here... > > Perhaps a better approach would be possible to do a check after > reading a size: > > int size = foo(); > > Check the size of the file here > > while (size--) > { > read pixels; > } > > png is compressed, it's not easy to separate the pixels. > Or just check for grub_errno or so after reading the picture? yes, after the picture is decoded, grub_errno is checked, if it's non zero, the bitmap image will be deallocated. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] memdisk plus lnxboot extension
On Jan 24, 2008 10:25 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > > On Thu, Jan 24, 2008 at 07:49:23PM +0800, Bean wrote: > > On Jan 24, 2008 7:32 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > > > Sorry, my question was confusing; what I meant is, where is it located > > > when > > > core.img is started. But Just checked in our Linux loader, and it seems > > > to be > > > at a very high address. > > > > > > However, a very high address doesn't garantee that it won't be > > > overwritten by > > > lzo decompression, just makes it less likely. > > > > > > Overall, this is why I don't like having to stick to a particular boot > > > mechanism. If our goal is overcome the size limit in memdisk, why not > > > design > > > the boot mechanism ourselves? > > > > I'm not familiar with multiboot spec, does it support arbitrary kernel size > > ? > > Sorry I don't know, you'd have to check. > > However, my point is more about the loadee than the loader. We provide a > multiboot image, which can also be a linux image with lnxboot.img, however, > this image needs to be very small, because it's intended usage is with > grub-setup, and that is why we only put the minimal stuff in it, and compress > it. > > You want to add a feature that only works when you have the ability to load > images of an arbitrary size. However, if we had this ability we wouldn't have > to compress core.img, or make it small in the first place. We would then > just create core.img of an arbitrary size, and include a memdisk of an > arbitrary size in it. But then we wouldn't need a feature to work around the > size restriction in memdisk! > > I think we need to discuss more about the situation you want to solve. Who > is going to load GRUB in lnxboot form + memdisk image? Where is it going to > load that from? If GRUB can access the same media, why not use loopback > to add a virtual disk based on the filesystem image, instead of loading it > in memory? i'm thinking about the situation where the boot media is not accessible, like pxe/cdrom. in this case, we can create core.img that contain minimum modules, and initrd that contain other modules plus font files and other data file. then, we can use loader like pxelinux/isolinux to load them at the same time. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Incomplete file listing with reiserfs partition
On Jan 24, 2008 2:30 AM, Antoine Cellerier <[EMAIL PROTECTED]> wrote: > Hello, > > I've been trying to use grub2 with a reiserfs partition and noticed that > it couldn't find all my files and folders. nyu and marco_g on IRC > suggested that I send a small test case. So here it comes. > > The attached disk-image.bz2 file is a 100 MB reiserfs partition with > folders 1, 2, 3, etc up to 199. When listing the folders in grub-emu > using ls (hd1)/ it only lists folders up to 163. > > grub> ls (hd1)/164 > error: file not found > > Thanks for your help, > > (Looks like the first version of the email with the attached diskimage > didn't make it, so here it is: > http://people.videolan.org/~dionoea/disk-image.bz2 . It's only 57KB > compressed) i can see the problem here. grub_reiserfs_iterate_dir only enum items in a block. when the items span over a block, the rest will be lost. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] memdisk plus lnxboot extension
On Jan 25, 2008 12:55 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Thu, Jan 24, 2008 at 03:25:51PM +0100, Robert Millan wrote: > > > > You want to add a feature that only works when you have the ability to load > > images of an arbitrary size. However, if we had this ability we wouldn't > > have > > to compress core.img, or make it small in the first place. We would then > > just create core.img of an arbitrary size, and include a memdisk of an > > arbitrary size in it. But then we wouldn't need a feature to work around > > the > > size restriction in memdisk! > > Just discussed it with Marco on IRC, and he said we could load core.img in > high > memory, like in 0x10 right away. This solves the size limit in memdisk > which I think is the source of the problem. > > Of course, this collides with the OS load area, so we'd also need to add > relocation in loader, as described in the "grub_dl_unload_all()" thread. I > do even have unfinished code for this, although it may take a while to get it > done properly (maybe we need to add features to memory manager or so). Does > this work for you? i think this is great, we don't have to worry about memdisk size, and no need for the initrd hack anymore. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Incomplete file listing with reiserfs partition
On Jan 25, 2008 12:11 AM, Marco Gerards <[EMAIL PROTECTED]> wrote: this is the patch, it can list all files. the main problem of the original code is that it assume that the next offset will be current offset + 1, this is not true. the offset is a hash value. it can be extracted when going through the B+ tree. * fs/reiserfs.c (grub_fshelp_node): New member next_offset. (grub_reiserfs_get_item): Save offset of the next item. (grub_reiserfs_iterate_dir): Use next_offset to find next item. diff --git a/fs/reiserfs.c b/fs/reiserfs.c index bbd1b34..a4c60ca 100644 --- a/fs/reiserfs.c +++ b/fs/reiserfs.c @@ -218,6 +218,7 @@ struct grub_fshelp_node struct grub_reiserfs_data *data; grub_uint32_t block_number; /* 0 if node is not found. */ grub_uint16_t block_position; + grub_uint64_t next_offset; enum grub_reiserfs_item_type type; /* To know how to read the header. */ struct grub_reiserfs_item_header header; }; @@ -499,6 +500,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data, if (! block_header) goto fail; + item->next_offset = 0; do { grub_disk_read (data->disk, @@ -542,6 +544,9 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data, #endif } block_number = grub_le_to_cpu32 (children[i].block_number); + if ((i < item_count) && (key->directory_id == keys[i].directory_id) + && (key->object_id == keys[i].object_id)) + item->next_offset = grub_reiserfs_get_key_offset(&(keys[i])); #ifdef GRUB_REISERFS_DEBUG if (i == item_count || grub_reiserfs_compare_keys (key, &(keys[i])) == 0) @@ -711,6 +716,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, struct grub_reiserfs_block_header *block_header = 0; grub_uint16_t block_size, block_position; grub_uint32_t block_number; + grub_uint64_t next_offset = item->next_offset; int ret = 0; if (item->type != GRUB_REISERFS_DIRECTORY) @@ -732,7 +738,6 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, struct grub_fshelp_node directory_item; grub_uint16_t entry_count, entry_number; struct grub_reiserfs_item_header *item_headers; - grub_uint64_t key_offset; grub_disk_read (data->disk, (((grub_disk_addr_t) block_number * block_size) @@ -939,16 +944,18 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, the current one. */ } } + + if (next_offset == 0) +break; - key_offset -= grub_reiserfs_get_key_offset (&(item_headers[block_position].key)); grub_reiserfs_set_key_offset (&(item_headers[block_position].key), -key_offset + 1); +next_offset); if (grub_reiserfs_get_item (data, &(item_headers[block_position].key), &directory_item) != GRUB_ERR_NONE) goto fail; block_number = directory_item.block_number; block_position = directory_item.block_position; + next_offset = directory_item.next_offset; } while (block_number); -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Incomplete file listing with reiserfs partition
this is the patch, it can list all files. the main problem of the original code is that it assume that the next offset will be current offset + 1, this is not true. the offset is a hash value. it can be extracted when going through the B+ tree. * fs/reiserfs.c (grub_fshelp_node): New member next_offset. (grub_reiserfs_get_item): Save offset of the next item. (grub_reiserfs_iterate_dir): Use next_offset to find next item. diff --git a/fs/reiserfs.c b/fs/reiserfs.c index bbd1b34..a4c60ca 100644 --- a/fs/reiserfs.c +++ b/fs/reiserfs.c @@ -218,6 +218,7 @@ struct grub_fshelp_node struct grub_reiserfs_data *data; grub_uint32_t block_number; /* 0 if node is not found. */ grub_uint16_t block_position; + grub_uint64_t next_offset; enum grub_reiserfs_item_type type; /* To know how to read the header. */ struct grub_reiserfs_item_header header; }; @@ -499,6 +500,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data, if (! block_header) goto fail; + item->next_offset = 0; do { grub_disk_read (data->disk, @@ -542,6 +544,9 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data, #endif } block_number = grub_le_to_cpu32 (children[i].block_number); + if ((i < item_count) && (key->directory_id == keys[i].directory_id) + && (key->object_id == keys[i].object_id)) + item->next_offset = grub_reiserfs_get_key_offset(&(keys[i])); #ifdef GRUB_REISERFS_DEBUG if (i == item_count || grub_reiserfs_compare_keys (key, &(keys[i])) == 0) @@ -711,6 +716,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, struct grub_reiserfs_block_header *block_header = 0; grub_uint16_t block_size, block_position; grub_uint32_t block_number; + grub_uint64_t next_offset = item->next_offset; int ret = 0; if (item->type != GRUB_REISERFS_DIRECTORY) @@ -732,7 +738,6 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, struct grub_fshelp_node directory_item; grub_uint16_t entry_count, entry_number; struct grub_reiserfs_item_header *item_headers; - grub_uint64_t key_offset; grub_disk_read (data->disk, (((grub_disk_addr_t) block_number * block_size) @@ -939,16 +944,18 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, the current one. */ } } + + if (next_offset == 0) +break; - key_offset -= grub_reiserfs_get_key_offset (&(item_headers[block_position].key)); grub_reiserfs_set_key_offset (&(item_headers[block_position].key), -key_offset + 1); +next_offset); if (grub_reiserfs_get_item (data, &(item_headers[block_position].key), &directory_item) != GRUB_ERR_NONE) goto fail; block_number = directory_item.block_number; block_position = directory_item.block_position; + next_offset = directory_item.next_offset; } while (block_number); -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] PNG image reader
_t png_magic[8] = + { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0x0a }; + +static grub_err_t +grub_png_decode_png (struct grub_png_data *data) +{ + grub_uint8_t magic[8]; + + if (grub_file_read (data->file, (char *) &magic[0], 8) != 8) +return grub_errno; + + if (grub_memcmp (magic, png_magic, sizeof (png_magic))) +return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: not a png file"); + + while (1) +{ + grub_uint32_t len, type; + + len = grub_png_get_dword (data); + type = grub_png_get_dword (data); + data->next_offset = data->file->offset + len + 4; + + switch (type) + { + case PNG_CHUNK_IHDR: + grub_png_decode_image_header (data); + break; + + case PNG_CHUNK_IDAT: + data->inside_idat = 1; + data->idat_remain = len; + data->bit_count = 0; + + grub_png_decode_image_data (data); + + data->inside_idat = 0; + break; + + case PNG_CHUNK_IEND: + return grub_errno; + + default: + grub_file_seek (data->file, data->file->offset + len + 4); + } + + if (grub_errno) +break; + + if (data->file->offset != data->next_offset) +return grub_error (GRUB_ERR_BAD_FILE_TYPE, + "png: chunk size error"); +} + + return grub_errno; +} + +static grub_err_t +grub_video_reader_png (struct grub_video_bitmap **bitmap, + const char *filename) +{ + grub_file_t file; + struct grub_png_data *data; + + file = grub_file_open (filename); + if (!file) +return grub_errno; + + data = grub_malloc (sizeof (*data)); + if (data != NULL) +{ + grub_memset (data, 0, sizeof (*data)); + data->file = file; + data->bitmap = bitmap; + + grub_png_decode_png (data); + + grub_free (data); +} + + if (grub_errno != GRUB_ERR_NONE) +{ + grub_video_bitmap_destroy (*bitmap); + *bitmap = 0; +} + + grub_file_close (file); + return grub_errno; +} + +#if defined(PNG_DEBUG) +static grub_err_t +grub_cmd_pngtest (struct grub_arg_list *state __attribute__ ((unused)), + int argc, char **args) +{ + struct grub_video_bitmap *bitmap = 0; + + if (argc != 1) +return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); + + grub_video_reader_png (&bitmap, args[0]); + if (grub_errno != GRUB_ERR_NONE) +return grub_errno; + + grub_video_bitmap_destroy (bitmap); + + return GRUB_ERR_NONE; +} +#endif + +static struct grub_video_bitmap_reader png_reader = { + .extension = ".png", + .reader = grub_video_reader_png, + .next = 0 +}; + +GRUB_MOD_INIT (video_reader_png) +{ + grub_video_bitmap_reader_register (&png_reader); +#if defined(PNG_DEBUG) + grub_register_command ("pngtest", grub_cmd_pngtest, +GRUB_COMMAND_FLAG_BOTH, "pngtest FILE", +"Tests loading of PNG bitmap.", 0); +#endif +} + +GRUB_MOD_FINI (video_reader_png) +{ +#if defined(PNG_DEBUG) + grub_unregister_command ("pngtest"); +#endif + grub_video_bitmap_reader_unregister (&png_reader); +} -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Incomplete file listing with reiserfs partition
Committed. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
this is the patch, problems found: 1, the mbi structure is not initialized to all zeros, this means some important member, like mods_count, will contain trash. 2, the entry point in the header is virtual address, we need to translate it to physical address. * loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get physical address of entry. (grub_multiboot_load_elf64): Likewise. (grub_multiboot): Initialize mbi structure. diff --git a/loader/i386/pc/multiboot.c b/loader/i386/pc/multiboot.c index fa6346e..2fd2b24 100644 --- a/loader/i386/pc/multiboot.c +++ b/loader/i386/pc/multiboot.c @@ -96,6 +96,7 @@ grub_multiboot_load_elf32 (grub_file_t file, void *buffer) { Elf32_Ehdr *ehdr = (Elf32_Ehdr *) buffer; Elf32_Phdr *phdr; + grub_addr_t real_entry = 0; int i; if (ehdr->e_ident[EI_CLASS] != ELFCLASS32) @@ -144,9 +145,16 @@ grub_multiboot_load_elf32 (grub_file_t file, void *buffer) if (phdr->p_filesz < phdr->p_memsz) grub_memset ((char *) phdr->p_paddr + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz); + + if ((entry >= phdr->p_vaddr) && + (entry < phdr->p_vaddr + phdr->p_memsz)) + real_entry = entry + phdr->p_paddr - phdr->p_vaddr; } } - + + if (real_entry) +entry = real_entry; + return grub_errno; } @@ -164,6 +172,7 @@ grub_multiboot_load_elf64 (grub_file_t file, void *buffer) { Elf64_Ehdr *ehdr = (Elf64_Ehdr *) buffer; Elf64_Phdr *phdr; + grub_addr_t real_entry = 0; int i; if (ehdr->e_ident[EI_CLASS] != ELFCLASS64) @@ -226,9 +235,16 @@ grub_multiboot_load_elf64 (grub_file_t file, void *buffer) + phdr->p_filesz), 0, phdr->p_memsz - phdr->p_filesz); + + if ((entry >= phdr->p_vaddr) && + (entry < phdr->p_vaddr + phdr->p_memsz)) + real_entry = entry + phdr->p_paddr - phdr->p_vaddr; } } - + + if (real_entry) +entry = real_entry; + return grub_errno; } @@ -306,6 +322,8 @@ grub_multiboot (int argc, char *argv[]) if (! mbi) goto fail; + grub_memset (mbi, 0, sizeof (struct grub_multiboot_info)); + mbi->flags = MULTIBOOT_INFO_MEMORY; /* Convert from bytes to kilobytes. */ -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Compiling grub2 on *BSD?
On Jan 27, 2008 1:21 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > > FreeBSD: > > > > lnxboot.S: Assembler messages: > > lnxboot.S:49: Error: `0x200+data_start - data_next(%ebx,%eax)' is not a > > valid 16 bit base/index expression > > lnxboot.S:264: Error: `(%esi,%eax)' is not a valid 16 bit base/index > > expression > > lnxboot.S:265: Error: `(%edi,%eax)' is not a valid 16 bit base/index > > expression > > I recall having seen this before. Please, can you check the list archives? > I think we solved it for other files, but it might have been respawned in > lnxboot.S. yes, this is caused by a trick to use 32-bit address mode for fast arithmetic. here is the patch, along with some code cleanup for lnxboot.S. diff --git a/boot/i386/pc/lnxboot.S b/boot/i386/pc/lnxboot.S index f1a4ded..81d8e40 100644 --- a/boot/i386/pc/lnxboot.S +++ b/boot/i386/pc/lnxboot.S @@ -36,22 +36,7 @@ .globl start, _start data_start: - pushw %cs - popw%ds - xorl%eax, %eax - xorl%ebx, %ebx - calldata_next - -data_next: - popw%bx - movw%cs, %ax - shll$4, %eax - leal0x200 + data_start - data_next(%ebx,%eax), %eax - movzbl setup_sects - data_next(%bx), %ecx - shll$9, %ecx - addl%ecx, %eax - movl%eax, code32_start - data_next(%bx) - + xorl%ebp, %ebp jmp linux_next . = data_start + 0x1F1 @@ -76,7 +61,7 @@ boot_flag: start: _start: - jmp linux_code + jmp linux_init .ascii "HdrS" // Header signature .word 0x0203 // Header version number @@ -134,9 +119,10 @@ reg_edx: data_leng: .long 0 -linux_code: +linux_init: movw%cs:(reg_edx - start), %dx + movl%cs:(code32_start - start), %ebp linux_next: @@ -164,9 +150,6 @@ real_code: movw%si, %ss movw$(CODE_ADDR), %sp - pushl %esi - pushl %edi - // Move itself to 0:CODE_ADDR cld @@ -183,34 +166,45 @@ real_code: real_code_2: - pushw %es - popw%ds - - movl(ramdisk_image - start), %esi - or %esi, %esi + xchgl %ebp, %esi + orl %esi, %esi jnz 1f - movl(code32_start - start), %esi + movw%ds, %si + shll$4, %esi + addl%ebp, %esi 1: + pushw %es + popw%ds + movl$0x200, %ecx addl%ecx, %esi movl$DATA_ADDR, %edi callmove_memory - movsbl %dh, %eax - movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) + // Check for the multiboot signature + cmpl$0x1badb002, %ss:(DATA_ADDR + 0x50) + jz 1f - movsbl (reg_edx + 2 - start), %eax - movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART) + movl(ramdisk_image - start), %esi + movl(ramdisk_size - start), %ecx + movl$(DATA_ADDR - 0x200), %edi + jmp 2f + +1: movl%ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx addl$(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx +2: callmove_memory - popl%edi - popl%esi + movsbl %dh, %eax + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) + + movsbl (reg_edx + 2 - start), %eax + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART) ljmp$(DATA_ADDR >> 4), $0 @@ -261,8 +255,8 @@ move_memory: 2: - leal(%esi, %eax), %esi - leal(%edi, %eax), %edi + addl%eax, %esi + addl%eax, %edi subl%eax, %ecx jnz 1b -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
On Jan 27, 2008 2:19 AM, walt <[EMAIL PROTECTED]> wrote: > > On Sat, 2008-01-26 at 18:24 +0100, Robert Millan wrote: > > On Sat, Jan 26, 2008 at 11:01:49PM +0800, Bean wrote: > > > this is the patch, problems found: > > > > > > 1, the mbi structure is not initialized to all zeros, this means some > > > important member, like mods_count, will contain trash. > > > 2, the entry point in the header is virtual address, we need to > > > translate it to physical address. > > > > > > * loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get physical > > > address of entry. > > > (grub_multiboot_load_elf64): Likewise. > > > (grub_multiboot): Initialize mbi structure. > > > > Wow, you're inexhaustible :-) > > Indeed! Unfortunately I still get the same free magic is broken :o( > As an experiment, I g-zipped the kernel and now grub2 just reboots > without printing anything when I do multiboot /netbsd.gz. (The same > kernel still boots normally with legacy grub.) don't gzip it, grub2 doesn't support auto decompression like grub legacy. > > > > Btw it won't apply to CVS head; maybe it was scrambled when sending it? > > I had to use the -l flag to get it to apply, but it did apply okay. maybe blank line problem. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
On Jan 27, 2008 2:24 AM, Bean <[EMAIL PROTECTED]> wrote: > On Jan 27, 2008 2:19 AM, walt <[EMAIL PROTECTED]> wrote: > > > > On Sat, 2008-01-26 at 18:24 +0100, Robert Millan wrote: > > > On Sat, Jan 26, 2008 at 11:01:49PM +0800, Bean wrote: > > > > this is the patch, problems found: > > > > > > > > 1, the mbi structure is not initialized to all zeros, this means some > > > > important member, like mods_count, will contain trash. > > > > 2, the entry point in the header is virtual address, we need to > > > > translate it to physical address. > > > > > > > > * loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get > > > > physical > > > > address of entry. > > > > (grub_multiboot_load_elf64): Likewise. > > > > (grub_multiboot): Initialize mbi structure. > > > > > > Wow, you're inexhaustible :-) > > > > Indeed! Unfortunately I still get the same free magic is broken :o( > > As an experiment, I g-zipped the kernel and now grub2 just reboots > > without printing anything when I do multiboot /netbsd.gz. (The same > > kernel still boots normally with legacy grub.) > > don't gzip it, grub2 doesn't support auto decompression like grub legacy. i just try multiboot_netbsd.gz, i boot ok. maybe you send netbsd.gz somewhere for me to test. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
On Jan 27, 2008 5:24 AM, walt <[EMAIL PROTECTED]> wrote: > > On Sat, 2008-01-26 at 23:01 +0800, Bean wrote: > > this is the patch, problems found: > > > > 1, the mbi structure is not initialized to all zeros, this means some > > important member, like mods_count, will contain trash. > > 2, the entry point in the header is virtual address, we need to > > translate it to physical address... > > Yes! I just discovered that I can multiboot the netbsd kernel off > of a FAT32 fs or even an NTFS fs, but *not* off of a UFS fs :o/ > > Apparently "something bad" happens to the kernel in the process of > reading or loading it from the UFS fs. I can read small text files > from a UFS fs, however, so I'm thinking maybe this has something to > do with the size of the netbsd kernel? > > BTW, I've tried booting the netbsd kernel off of a FreeBSD UFS1 fs > but I can't tell if my NetBSD partition is UFS1 or UFS2 -- dumpfs > doesn't say which kind it is. I confess I really don't remember if > I have any UFS2 partitions or not. > > Excellent work so far in just one day! Got any other tricks? :o) please make a small ufs image containing the netbsd kernel, i don't a a bsd system at hand. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Odd behavior in x86/pc booting process with minor modifications
On Jan 27, 2008 10:52 PM, Vesa Jääskeläinen <[EMAIL PROTECTED]> wrote: > Hi, > > I was playing around with IDT and needed some code space in startup.S > and in realmode.S. GRUB just hanged for some reason during the bootup > when I just had query instruction for current IDT descriptor and some > storage for it after GDT tables. > > I then reverted that code and added as many NOPs as that code would take > there and it was still hanging... then I removed some NOPs and hang went > away. I don't have good debugging capabilities other than qemu's log, > but it would seem like when grub is decompressing itself there is minor > code flow difference, though this could only be because binary is a bit > different... so I am not sure about that theory... anyway if there are > good ideas on how to debug this, or even better solutions to possible > problem :). Any ideas are welcome. > > So how to reproduce this problem: > > 1. open kern/i386/pc/startup.S > 2. find codestart > > // actual location is not so important > 3. find first sti instruction > 4. go 1 line backwards > > 5. add about 15 NOP's > > 6. recompile and make image > 7. try it out, it should hang without displaying grub shell or menu. This is actually caused by memory overlap. in grub-mkimage, it will compress from offset 0x4A0 (GRUB_KERNEL_MACHINE_RAW_SIZE), which corresponds to 0x6A0 of core.img. this is inside of lzo decompression code which ends at 0x6A2 (you can verify this by adding a text string at the end of lzo1x.S). it's a very delicate situation. when you add more code, it push the lzo decompression code further back, making more code inside compression zone, and it's bound to go wrong. The fix is to increase the value of GRUB_KERNEL_MACHINE_RAW_SIZE. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] a.out kernel loader
escue_register_command ("aout", grub_rescue_cmd_aout, "load a.out"); + my_mod = mod; +} + +GRUB_MOD_FINI (aout) +{ + grub_rescue_unregister_command ("aout"); +} diff --git a/loader/i386/pc/aout_normal.c b/loader/i386/pc/aout_normal.c new file mode 100755 index 000..b90e3af --- /dev/null +++ b/loader/i386/pc/aout_normal.c @@ -0,0 +1,44 @@ +/* aout_normal.c - boot a.out loader (*BSD) */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 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 +#include +#include +#include + +static grub_err_t +grub_normal_aout_command (struct grub_arg_list *state + __attribute__ ((unused)), int argc, char **args) +{ + grub_rescue_cmd_aout (argc, args); + return grub_errno; +} + +GRUB_MOD_INIT (aout_normal) +{ + (void) mod; /* To stop warning. */ + grub_register_command ("aout", grub_normal_aout_command, +GRUB_COMMAND_FLAG_BOTH, +"aout FILE [ARGS...]", "Load an a.out kernel.", 0); +} + +GRUB_MOD_FINI (aout_normal) +{ + grub_unregister_command ("aout"); +} -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] a.out kernel loader
On Jan 28, 2008 3:41 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Mon, Jan 28, 2008 at 02:53:14AM +0800, Bean wrote: > > Hi, > > > > This patch add support for a.out kernel, which includes the 4th loader > > of BSD system. For example, to start FreeBSD: > > Cool! > > How FreeBSD-specific is this? Will the same module apply to other a.out > binaries ? (I ask since you gave it a generic name) it's an old format of the unix system: http://en.wikipedia.org/wiki/A.out -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] a.out kernel loader
On Jan 28, 2008 4:06 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > > On Mon, Jan 28, 2008 at 03:55:19AM +0800, Bean wrote: > > On Jan 28, 2008 3:41 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > > > On Mon, Jan 28, 2008 at 02:53:14AM +0800, Bean wrote: > > > > Hi, > > > > > > > > This patch add support for a.out kernel, which includes the 4th loader > > > > of BSD system. For example, to start FreeBSD: > > > > > > Cool! > > > > > > How FreeBSD-specific is this? Will the same module apply to other a.out > > > binaries ? (I ask since you gave it a generic name) > > > > it's an old format of the unix system: > > > > http://en.wikipedia.org/wiki/A.out > > I know.. I was referring to your loader. it should be generic, but i only test it using the loader from freebsd. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
On Jan 28, 2008 4:13 AM, walt <[EMAIL PROTECTED]> wrote: > > On Sun, 2008-01-27 at 09:35 +0800, Bean wrote: > > On Jan 27, 2008 5:24 AM, walt <[EMAIL PROTECTED]> wrote: > > > > > > Apparently "something bad" happens to the kernel in the process of > > > reading or loading it from the UFS fs. I can read small text files > > > from a UFS fs, however, so I'm thinking maybe this has something to > > > do with the size of the netbsd kernel? > > > please make a small ufs image containing the netbsd kernel, i don't a > > a bsd system at hand. > > I can use dd to copy a UFS fs to a file. Is that what you mean? Are > you planning to use the loopback feature in grub2 to use the image? > (I want to test the image before I send it to you.) yes, thanks. btw, if you have time, please try the a.out loader, it should be able to boot /boot/loader of freebsd, i don't know if openbsd and netbsd use the same booting method. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Compiling grub2 on *BSD?
On Jan 27, 2008 2:15 AM, Bean <[EMAIL PROTECTED]> wrote: > On Jan 27, 2008 1:21 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > > > FreeBSD: > > > > > > lnxboot.S: Assembler messages: > > > lnxboot.S:49: Error: `0x200+data_start - data_next(%ebx,%eax)' is not a > > > valid 16 bit base/index expression > > > lnxboot.S:264: Error: `(%esi,%eax)' is not a valid 16 bit base/index > > > expression > > > lnxboot.S:265: Error: `(%edi,%eax)' is not a valid 16 bit base/index > > > expression > > > > I recall having seen this before. Please, can you check the list archives? > > I think we solved it for other files, but it might have been respawned in > > lnxboot.S. > > yes, this is caused by a trick to use 32-bit address mode for fast > arithmetic. here is the patch, along with some code cleanup for > lnxboot.S. > > diff --git a/boot/i386/pc/lnxboot.S b/boot/i386/pc/lnxboot.S > index f1a4ded..81d8e40 100644 > --- a/boot/i386/pc/lnxboot.S > +++ b/boot/i386/pc/lnxboot.S > @@ -36,22 +36,7 @@ > .globl start, _start > > data_start: > - pushw %cs > - popw%ds > - xorl%eax, %eax > - xorl%ebx, %ebx > - calldata_next > - > -data_next: > - popw%bx > - movw%cs, %ax > - shll$4, %eax > - leal0x200 + data_start - data_next(%ebx,%eax), %eax > - movzbl setup_sects - data_next(%bx), %ecx > - shll$9, %ecx > - addl%ecx, %eax > - movl%eax, code32_start - data_next(%bx) > - > + xorl%ebp, %ebp > jmp linux_next > > . = data_start + 0x1F1 > @@ -76,7 +61,7 @@ boot_flag: > start: > _start: > > - jmp linux_code > + jmp linux_init > > .ascii "HdrS" // Header signature > .word 0x0203 // Header version number > @@ -134,9 +119,10 @@ reg_edx: > data_leng: > .long 0 > > -linux_code: > +linux_init: > > movw%cs:(reg_edx - start), %dx > + movl%cs:(code32_start - start), %ebp > > linux_next: > > @@ -164,9 +150,6 @@ real_code: > movw%si, %ss > movw$(CODE_ADDR), %sp > > - pushl %esi > - pushl %edi > - > // Move itself to 0:CODE_ADDR > > cld > @@ -183,34 +166,45 @@ real_code: > > real_code_2: > > - pushw %es > - popw%ds > - > - movl(ramdisk_image - start), %esi > - or %esi, %esi > + xchgl %ebp, %esi > + orl %esi, %esi > jnz 1f > - movl(code32_start - start), %esi > + movw%ds, %si > + shll$4, %esi > + addl%ebp, %esi > 1: > > + pushw %es > + popw%ds > + > movl$0x200, %ecx > addl%ecx, %esi > movl$DATA_ADDR, %edi > > callmove_memory > > - movsbl %dh, %eax > - movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) > + // Check for the multiboot signature > + cmpl$0x1badb002, %ss:(DATA_ADDR + 0x50) > + jz 1f > > - movsbl (reg_edx + 2 - start), %eax > - movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART) > + movl(ramdisk_image - start), %esi > + movl(ramdisk_size - start), %ecx > + movl$(DATA_ADDR - 0x200), %edi > + jmp 2f > + > +1: > > movl%ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx > addl$(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx > > +2: > callmove_memory > > - popl%edi > - popl%esi > + movsbl %dh, %eax > + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) > + > + movsbl (reg_edx + 2 - start), %eax > + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART) > > ljmp$(DATA_ADDR >> 4), $0 > > @@ -261,8 +255,8 @@ move_memory: > > 2: > > - leal(%esi, %eax), %esi > - leal(%edi, %eax), %edi > + addl%eax, %esi > + addl%eax, %edi > subl%eax, %ecx > jnz 1b > > > > > -- > Bean > if there is no objection, I'd like to check in this patch. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
On Jan 28, 2008 9:54 AM, walt <[EMAIL PROTECTED]> wrote: > > On Mon, 2008-01-28 at 04:25 +0800, Bean wrote: > ... > > > > please make a small ufs image containing the netbsd kernel, i don't a > > > > a bsd system at hand > > http://leaf.dragonflybsd.org/~wa1ter/ufs.gz > > I included a small text file (motd) to demonstrate that you can cat it > okay, but when you try 'multiboot /netbsd' you should get the same error > I've been describing. > > > > btw, if you have time, please try the a.out loader, it should be able > > to boot /boot/loader of freebsd, i don't know if openbsd and netbsd > > use the same booting method. > > diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk > > Heh. I'm assuming an .rmk file involves ruby somehow? The bonehead > build process that I'm using doesn't turn an .rmk into a .mk AFAICT, > but I'd like to know how to do it. all you need to do is do install ruby. here is a patch for ufs, it fix the indirect block calculation problem. * fs/ufs.c (INODE_BLKSZ): Fix incorrect value. (grub_ufs_get_file_block): Fix indirect block calculation problem. diff --git a/fs/ufs.c b/fs/ufs.c index 25cd1fa..ebb7198 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -52,7 +52,7 @@ grub_le_to_cpu##bits2 (data->inode2.field)) #define INODE_SIZE(data) INODE_ENDIAN (data,size,32,64) #define INODE_MODE(data) INODE_ENDIAN (data,mode,16,16) -#define INODE_BLKSZ(data) (data->ufs_type == UFS1 ? 32 : 64) +#define INODE_BLKSZ(data) (data->ufs_type == UFS1 ? 4 : 8) #define INODE_DIRBLOCKS(data,blk) INODE_ENDIAN \ (data,blocks.dir_blocks[blk],32,64) #define INODE_INDIRBLOCKS(data,blk) INODE_ENDIAN \ @@ -205,35 +205,41 @@ grub_ufs_get_file_block (struct grub_ufs_data *data, unsigned int blk) { struct grub_ufs_sblock *sblock = &data->sblock; unsigned int indirsz; + int log2_blksz; /* Direct. */ if (blk < GRUB_UFS_DIRBLKS) return INODE_DIRBLOCKS (data, blk); + log2_blksz = grub_le_to_cpu32 (data->sblock.log2_blksz); + blk -= GRUB_UFS_DIRBLKS; indirsz = UFS_BLKSZ (sblock) / INODE_BLKSZ (data); /* Single indirect block. */ if (blk < indirsz) { - grub_uint32_t indir[UFS_BLKSZ (sblock)]; - grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 0), + grub_uint32_t indir[UFS_BLKSZ (sblock) >> 2]; + grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 0) << log2_blksz, 0, sizeof (indir), (char *) indir); - return indir[blk]; + return (data->ufs_type == UFS1) ? indir[blk] : indir[blk << 1]; } blk -= indirsz; /* Double indirect block. */ if (blk < UFS_BLKSZ (sblock) / indirsz) { - grub_uint32_t indir[UFS_BLKSZ (sblock)]; + grub_uint32_t indir[UFS_BLKSZ (sblock) >> 2]; - grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 1), + grub_disk_read (data->disk, INODE_INDIRBLOCKS (data, 1) << log2_blksz, 0, sizeof (indir), (char *) indir); - grub_disk_read (data->disk, indir[blk / indirsz], + grub_disk_read (data->disk, + (data->ufs_type == UFS1) ? + indir[blk / indirsz] : indir [(blk / indirsz) << 1], 0, sizeof (indir), (char *) indir); - return indir[blk % indirsz]; + return (data->ufs_type == UFS1) ? +indir[blk % indirsz] : indir[(blk % indirsz) << 1]; } -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
On Jan 28, 2008 4:57 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Robert Millan <[EMAIL PROTECTED]> writes: > > > On Sat, Jan 26, 2008 at 01:24:57PM -0800, walt wrote: > >> > >> Yes! I just discovered that I can multiboot the netbsd kernel off > >> of a FAT32 fs or even an NTFS fs, but *not* off of a UFS fs :o/ > >> > >> Apparently "something bad" happens to the kernel in the process of > >> reading or loading it from the UFS fs. I can read small text files > >> from a UFS fs, however, so I'm thinking maybe this has something to > >> do with the size of the netbsd kernel? > > > > I just committed a check in grub-probe that attempts to read and verify > > files > > using GRUB filesystems and compares them with output from your system. E.g. > > if you do: grub-probe -t fs /full/path/to/file it will compare and verify > > it > > using fs/ufs.c. > > > > Bean, IIRC you planned add something similar. Is this feature useful to > > you? > > It's at least useful to me :-) grub-probe is nice, but i normally use grub-fstest to debug fs problem, because it have more options. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Compiling grub2 on *BSD?
bits of target addy - .byte 0x93// Access rights - .byte 0 // Extended access rights + .byte 0, 0, 0 /* Low 24 bits of target addy */ + .byte 0x93/* Access rights */ + .byte 0 /* Extended access rights */ gdt_dst2: - .byte 0 // High 8 bits of source addy - .long 0, 0, 0, 0 // More space for the BIOS + .byte 0 /* High 8 bits of source addy */ + .long 0, 0, 0, 0 /* More space for the BIOS */ reg_edx: .byte 0x80,0,0xFF,0xFF @@ -134,9 +120,10 @@ reg_edx: data_leng: .long 0 -linux_code: +linux_init: movw%cs:(reg_edx - start), %dx + movl%cs:(code32_start - start), %ebp linux_next: @@ -150,7 +137,7 @@ normalize: addw%bx, %ax pushw %ax pushw $(real_code - start) - lret// jump to real_code + lret/* Jump to real_code */ real_code: subw$0x20, %ax @@ -158,16 +145,13 @@ real_code: movw(setup_sects - data_start), %cx shlw$7, %cx - // Setup stack + /* Setup stack */ xorw%si, %si movw%si, %ss movw$(CODE_ADDR), %sp - pushl %esi - pushl %edi - - // Move itself to 0:CODE_ADDR + /* Move itself to 0:CODE_ADDR */ cld movw%cs, %ax @@ -183,41 +167,55 @@ real_code: real_code_2: - pushw %es - popw%ds - - movl(ramdisk_image - start), %esi - or %esi, %esi + xchgl %ebp, %esi + orl %esi, %esi jnz 1f - movl(code32_start - start), %esi + movw%ds, %si + shll$4, %esi + addl%ebp, %esi 1: + pushw %es + popw%ds + movl$0x200, %ecx addl%ecx, %esi movl$DATA_ADDR, %edi callmove_memory - movsbl %dh, %eax - movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) + /* Check for multiboot signature */ + cmpl$MULTIBOOT_MAGIC, %ss:(DATA_ADDR + 0x50) + jz 1f - movsbl (reg_edx + 2 - start), %eax - movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART) + movl(ramdisk_image - start), %esi + movl(ramdisk_size - start), %ecx + movl$(DATA_ADDR - 0x200), %edi + jmp 2f + +1: movl%ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx addl$(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx +2: callmove_memory - popl%edi - popl%esi + movsbl %dh, %eax + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) + + movsbl (reg_edx + 2 - start), %eax + movl%eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART) ljmp$(DATA_ADDR >> 4), $0 -// Parameters: -// esi: source address -// edi: target address -// ecx: number of bytes +/* + * Parameters: + * esi: source address + * edi: target address + * ecx: number of bytes + */ + move_memory: incl%ecx andb$0xFE, %cl @@ -261,8 +259,8 @@ move_memory: 2: - leal(%esi, %eax), %esi - leal(%edi, %eax), %edi + addl%eax, %esi + addl%eax, %edi subl%eax, %ecx jnz 1b @@ -270,8 +268,11 @@ move_memory: popw%dx ret -// Parameters: -// si: message +/* + * Parameters: + * si: message + */ + fail: movb$0x0e, %ah xorw%bx, %bx -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] a.out kernel loader
On Jan 28, 2008 5:11 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote: > > > > > > > > > > How FreeBSD-specific is this? Will the same module apply to other > > > > > a.out > > > > > binaries ? (I ask since you gave it a generic name) > > > > > > > > it's an old format of the unix system: > > > > > > > > http://en.wikipedia.org/wiki/A.out > > > > > > I know.. I was referring to your loader. > > > > it should be generic, but i only test it using the loader from freebsd. > > In that case, I'd suggest putting it directly in loader/ (without i386/pc/). > > Moving files on CVS is a PITA :-/ ok, here is the new patch. * conf/i386-pc.rmk (pkglib_MODULES): Add aout.mod and _aout.mod. (aout_mod_SOURCES): New variable. (aout_mod_CFLAGS): Likewise. (aout_mod_LDFLAGS): Likewise. (_aout_mod_SOURCES): New variable. (_aout_mod_CFLAGS): Likewise. (_aout_mod_LDFLAGS): Likewise. * loader/aout.c: New file. * loader/aout_normal.c: New file. * loader/i386/pc/aout.c: New file. * include/grub/aout_loader.h: New file. diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index ff02332..36af7de 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -151,8 +151,8 @@ grub_mkrescue_SOURCES = util/i386/pc/grub-mkrescue.in # Modules. pkglib_MODULES = biosdisk.mod _chain.mod _linux.mod linux.mod normal.mod \ - _multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod \ - vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \ + _multiboot.mod chain.mod multiboot.mod _aout.mod aout.mod reboot.mod \ + halt.mod vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \ videotest.mod play.mod bitmap.mod tga.mod cpuid.mod serial.mod \ ata.mod vga.mod memdisk.mod jpeg.mod @@ -221,6 +221,16 @@ multiboot_mod_SOURCES = loader/multiboot_loader_normal.c multiboot_mod_CFLAGS = $(COMMON_CFLAGS) multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For _aout.mod. +_aout_mod_SOURCES = loader/aout.c loader/i386/pc/aout.c +_aout_mod_CFLAGS = $(COMMON_CFLAGS) +_aout_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For aout.mod. +aout_mod_SOURCES = loader/aout_normal.c +aout_mod_CFLAGS = $(COMMON_CFLAGS) +aout_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For vbe.mod. vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \ video/i386/pc/vbefill.c video/i386/pc/vbeutil.c diff --git a/include/grub/aout_loader.h b/include/grub/aout_loader.h new file mode 100755 index 000..64311eb --- /dev/null +++ b/include/grub/aout_loader.h @@ -0,0 +1,134 @@ +/* aout_loader.h - a.out loader header file. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 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/>. + */ + + +#ifndef GRUB_AOUT_LOADER_HEADER +#define GRUB_AOUT_LOADER_HEADER 1 + +#define __LDPGSZ 0x1000 + +#define N_GETMAGIC(ex) \ + ( (ex).a_midmag & 0x ) +#define N_GETMID(ex) \ + ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETMID_NET(ex) : \ + ((ex).a_midmag >> 16) & 0x03ff ) +#define N_GETFLAG(ex) \ + ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETFLAG_NET(ex) : \ + ((ex).a_midmag >> 26) & 0x3f ) +#define N_SETMAGIC(ex,mag,mid,flag) \ + ( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \ + ((mag) & 0x) ) + +#define N_GETMAGIC_NET(ex) \ + (grub_be_to_cpu32((ex).a_midmag) & 0x) +#define N_GETMID_NET(ex) \ + ((grub_be_to_cpu32((ex).a_midmag) >> 16) & 0x03ff) +#define N_GETFLAG_NET(ex) \ + ((grub_be_to_cpu32((ex).a_midmag) >> 26) & 0x3f) +#define N_SETMAGIC_NET(ex,mag,mid,flag) \ + ( (ex).a_midmag = grub_cpu_to_be32( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \ + (((mag)&0x)) ) ) + +#define N_ALIGN(ex,x) \ + (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \ +N_GETMAGIC_NET(ex) == ZMAGIC || N_GETMAGIC_NET(ex) == QMAGIC ? \ +((x) + __LDPGSZ - 1) & ~(unsigned long)(__LDPGSZ - 1) : (x)) + +/* Valid magic number check. */ +#defineN_BADMAG(ex) \ +
Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
On Jan 28, 2008 9:00 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > > On Jan 28, 2008 9:54 AM, walt <[EMAIL PROTECTED]> wrote: > >> > >> On Mon, 2008-01-28 at 04:25 +0800, Bean wrote: > >> ... > >> > > > please make a small ufs image containing the netbsd kernel, i don't a > >> > > > a bsd system at hand > >> > >> http://leaf.dragonflybsd.org/~wa1ter/ufs.gz > >> > >> I included a small text file (motd) to demonstrate that you can cat it > >> okay, but when you try 'multiboot /netbsd' you should get the same error > >> I've been describing. > >> > >> > >> > btw, if you have time, please try the a.out loader, it should be able > >> > to boot /boot/loader of freebsd, i don't know if openbsd and netbsd > >> > use the same booting method. > >> > >> diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk > >> > >> Heh. I'm assuming an .rmk file involves ruby somehow? The bonehead > >> build process that I'm using doesn't turn an .rmk into a .mk AFAICT, > >> but I'd like to know how to do it. > > > > all you need to do is do install ruby. > > > > here is a patch for ufs, it fix the indirect block calculation problem. > > > > * fs/ufs.c (INODE_BLKSZ): Fix incorrect value. > > (grub_ufs_get_file_block): Fix indirect block calculation problem. > > Fine for me, if you tested this. > > This patch fixes this specific problem regarding loading this > multiboot kernel from UFS? yes, it works for me. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] a.out kernel loader
On Jan 28, 2008 10:37 PM, walt <[EMAIL PROTECTED]> wrote: > > On Mon, 2008-01-28 at 19:48 +0800, Bean wrote: > > On Jan 28, 2008 5:11 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > > > On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote: > > > > > > > > > > > > > > How FreeBSD-specific is this? Will the same module apply to > > > > > > > other a.out > > > > > > > binaries ? (I ask since you gave it a generic name) > > > > > > > > > > > > it's an old format of the unix system: > > > > > > > > > > > > http://en.wikipedia.org/wiki/A.out > > > > > > > > > > I know.. I was referring to your loader. > > > > > > > > it should be generic, but i only test it using the loader from freebsd. > > > > > > In that case, I'd suggest putting it directly in loader/ (without > > > i386/pc/). > > > > > > Moving files on CVS is a PITA :-/ > > > > ok, here is the new patch... > > Good news and bad news. With this patch and your most recent ufs patch > I can aout /boot/loader or multiboot /netbsd from a UFS partition, that > is the good news. > > The bad news is that when I type 'boot', /boot/loader prints out its one > line of text to identify itself and then hangs forever. > > When I type 'boot' after loading the netbsd kernel with multiboot, the > machine reboots instantly instead of starting the OS. > > Any ideas? is grub legacy ok ? -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub-fstest: debug tool for filesystem driver
compare files\n\ + hex FILE hex dump FILE\n\ + blocklist FILEdisplay blocklist of FILE\n\ +\nOptions:\n\ + -p, --part=NUMselect partition NUM\n\ + -s, --skip=N skip N bytes from output file\n\ + -n, --length=Nhandle N bytes in output file\n\ + -r, --raw disable auto decompression\n\ + -l, --longshow long directory list\n\ + -h, --helpdisplay this message and exit\n\ + -V, --version print version information and exit\n\ + -v, --verbose print verbose messages\n\ +\n\ +Report bugs to <%s>.\n", PACKAGE_BUGREPORT); + + exit (status); +} + +int +main (int argc, char *argv[]) +{ + char *image_path; + int cmd, is_raw = 0, is_long = 0; + + progname = "grub-fstest"; + + /* Check for options. */ + while (1) +{ + int c = getopt_long (argc, argv, "p:s:n:rlhVv", options, 0); + + if (c == -1) + break; + else + switch (c) + { + case 'p': + part = grub_strtoul (optarg, NULL, 0); + break; + + case 's': + skip = grub_strtoul (optarg, NULL, 0); + break; + + case 'n': + leng = grub_strtoul (optarg, NULL, 0); + break; + + case 'r': + is_raw = 1; + break; + + case 'l': + is_long = 1; + break; + + case 'h': + usage (0); + break; + + case 'V': + printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION); + return 0; + + case 'v': + verbosity++; + break; + + default: + usage (1); + break; + } +} + + /* Obtain PATH. */ + if (optind >= argc) +{ + fprintf (stderr, "No path is specified.\n"); + usage (1); +} + + image_path = argv[optind]; + + if (*image_path != '/') +{ + fprintf (stderr, "Must use absolute path.\n"); + usage (1); +} + + optind++; + + cmd = 0; + if (optind < argc) +{ + int nparm = 1; + + if (!grub_strcmp (argv[optind], "ls")) + { + cmd = CMD_LS; + if (is_long) + argv[optind--] = "-l"; + else + nparm = 0; + } + else if (!grub_strcmp (argv[optind], "cp")) + { + cmd = CMD_CP; + nparm = 2; + } + else if (!grub_strcmp (argv[optind], "cmp")) + { + cmd = CMD_CMP; + nparm = 2; + } + else if (!grub_strcmp (argv[optind], "hex")) + { + cmd = CMD_HEX; + } + else if (!grub_strcmp (argv[optind], "blocklist")) + { + cmd = CMD_BLOCKLIST; + } + else + { + fprintf (stderr, "Invalid command %s.\n", argv[optind]); + usage (1); + } + + if (optind + 1 + nparm > argc) + { + fprintf (stderr, "Invalid parameter for command %s.\n", + argv[optind]); + usage (1); + } + + optind++; +} + else +{ + fprintf (stderr, "No command is specified.\n"); + usage (1); +} + + grub_hostfs_init (); + + /* Initialize all modules. */ + grub_init_all (); + + if (is_raw) +grub_env_set ("filehook", "0"); + + /* Do it. */ + fstest (image_path + 1, cmd, argc - optind, argv + optind); + + /* Free resources. */ + grub_fini_all (); + + grub_hostfs_fini (); + + return 0; +} -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub-fstest: debug tool for filesystem driver
On Jan 29, 2008 1:27 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Mon, Jan 28, 2008 at 10:48:13PM +0800, Bean wrote: > > +#include > > +#include > > +#include > > +#include > > + > > +#define _GNU_SOURCE 1 > > +#include > > I suspect this wouldn't work in practice, because any system header can > drag in. i'm not sure about this, in fact, the line is copied from grub-probe.c, perhaps i should remove it. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] a.out kernel loader
On Jan 29, 2008 6:04 AM, walt <[EMAIL PROTECTED]> wrote: > Bean wrote: > > On Jan 28, 2008 10:37 PM, walt<[EMAIL PROTECTED]> wrote: > ... > >> Good news and bad news. With this patch and your most recent ufs patch > >> I can aout /boot/loader or multiboot /netbsd from a UFS partition, that > >> is the good news. > >> > >> The bad news is that when I type 'boot', /boot/loader prints out its one > >> line of text to identify itself and then hangs forever. > >> > >> When I type 'boot' after loading the netbsd kernel with multiboot, the > >> machine reboots instantly instead of starting the OS. > >> > >> Any ideas? > > > is grub legacy ok ? > > I'm not sure what information you are asking for. Nothing has changed > at my end concerning legacy. It still works, but why should it not? this is strange, it's working for me. perhaps you can try to load netnsd kernel from the ufs image you sent. loopback loop (hd0,0)/ufs multiboot (loop)/netbsd boot ufs is better placed in non ufs partition. If this works, then it means there is still bug in the ufs driver. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] a.out kernel loader
On Jan 29, 2008 3:11 PM, <[EMAIL PROTECTED]> wrote: > On Mon, Jan 28, 2008 at 06:37:16AM -0800, walt wrote: > > > > When I type 'boot' after loading the netbsd kernel with multiboot, the > > machine reboots instantly instead of starting the OS. > > > > Any ideas? > > > > I've encountered this in qemu where it tells you you are executing code > outside ram/rom at the kernel virtual entry address of 0xc010. The > NetBSD/i386 kernel needs to be loaded/entered at physical address > 0x0010, it's, however, linked to run at 0xc010. > > This is trivial to fix, but the trivial fix may not be the right fix. > > Now if only I was having more luck when grub2 was loaded from coreboot. > But that's another thread maybe. my previous multiboot patch fix this problem. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] a.out kernel loader
On Jan 29, 2008 4:48 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > > On Jan 28, 2008 5:11 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > >> On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote: > >> > > > > > >> > > > > How FreeBSD-specific is this? Will the same module apply to other > >> > > > > a.out > >> > > > > binaries ? (I ask since you gave it a generic name) > >> > > > > >> > > > it's an old format of the unix system: > >> > > > > >> > > > http://en.wikipedia.org/wiki/A.out > >> > > > >> > > I know.. I was referring to your loader. > >> > > >> > it should be generic, but i only test it using the loader from freebsd. > >> > >> In that case, I'd suggest putting it directly in loader/ (without > >> i386/pc/). > >> > >> Moving files on CVS is a PITA :-/ > > > > ok, here is the new patch. > > It would be nice if a.out support could be shared so it can be used > for multiboot as well. you mean adding it to the multiboot module ? > > +/* a_mid */ > > +#define MID_ZERO0 /* unknown - implementation dependent > > */ > > +#define MID_SUN010 1 /* sun 68010/68020 binary */ > > +#define MID_SUN020 2 /* sun 68020-only binary */ > > +#define MID_I386 134 /* i386 BSD binary */ > > +#define MID_SPARC138 /* sparc */ > > +#define MID_HP200 200 /* hp200 (68010) BSD binary */ > > +#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */ > > +#define MID_HPUX0x20C /* hp200/300 HP-UX binary */ > > +#define MID_HPUX800 0x20B /* hp800 HP-UX binary */ > > Like Robert asked, did you type this yourself? the header is copied from grub legacy image_aout.h, maybe i can format it properly. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: eltorito support ..
On Jan 29, 2008 5:19 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Tue, Jan 29, 2008 at 10:11:45AM +0100, Marco Gerards wrote: > > Robert Millan <[EMAIL PROTECTED]> writes: > > > > > On Tue, Jan 29, 2008 at 09:30:16AM +0100, Marco Gerards wrote: > > >> Kalamatee <[EMAIL PROTECTED]> writes: > > >> > > >> Hi, > > >> > > >> > I read in previous mails that eltorito support would be getting worked > > >> > on > > >> > for the summer of code projects, and that it should be getting merged > > >> > into > > >> > the grub2 codebase at somepoint. > > >> > > > >> > Im just wondering what is the current situation with this? Is there any > > >> > timeline when it will be completed? > > >> > > >> Actually, I have no idea... Alex Roman worked on this. Perhaps you > > >> can contact him? The code is on the GSoC projects page. Robert tried > > >> to get it to work, but IIRC there were problems. > > > > > > I think using the ata driver would be a better approach. When our driver > > > doesn't "taint" bios-based CD access, we could merge the eltorito loader > > > from > > > GSoC codebase, without having to solve the problems in biosdisk CD access. > > > > I prefer both. Not all CDROM drives are ATA drives. > > But we are likely to get USB support this summer :-) > > Besides, unlike floppy or disk boot, code size is not that much of an issue > for cdrom boot. i think biosdisk support for cd access shouldn't be too difficult, there is similar code in grub legacy. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] PNG image reader
On Jan 29, 2008 5:10 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > > add two sanity check, one for chuck size, make sure the on disk > > structure is correct, one for raw image, make sure the image won't > > overflown. also adjust a few macro names and the filter handling code. > > > > * conf/i386-pc.rmk (pkglib_MODULES): Add `png.mod'. > > (png_mod_SOURCES): New variable. > > (png_mod_CFLAGS): Likewise. > > (png_mod_LDFLAGS): Likewise. > > > > * video/readers/png.c : New file. > > Can you please include the header for the changelog entry? It's > minor, but it prevents some confusion at my side. > > One small comment below. Can you fix this before you commit? :-) Fixed and committed. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub-fstest: debug tool for filesystem driver
Some changes in this new patch: Remove the _GNU_SOURCE line. Partition number is now string, so that you can use bsd sub partition. Code cleanup for function fstest. 2008-01-29 Bean <[EMAIL PROTECTED]> * Makefile.in (enable_grub_fstest): New variable. * conf/common.rmk (grub_fstest_init.lst): New rule. (grub_fstest_init.h): Likewise. (grub_fstest_init.c): Likewise. * i396-pc.rmk (util/grub-fstest.c_DEPENDENCIES): New variable. (grub_fstest_SOURCES): Likewise. * configure.ac (enable_grub_fstest): New test. * util/grub-fstest.c: New file. diff --git a/Makefile.in b/Makefile.in index 84b4e9c..ba07577 100644 --- a/Makefile.in +++ b/Makefile.in @@ -79,6 +79,7 @@ UNIFONT_HEX = @UNIFONT_HEX@ # Options. enable_grub_emu = @enable_grub_emu@ +enable_grub_fstest = @enable_grub_fstest@ ### General variables. diff --git a/conf/common.rmk b/conf/common.rmk index c1f367b..6e06a3e 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -44,6 +44,19 @@ grub_setup_init.c: grub_setup_init.lst $(filter-out grub_setup_init.c,$(grub_set rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@ DISTCLEANFILES += grub_setup_init.c +# For grub-fstest. +grub_fstest_init.lst: geninit.sh $(filter-out grub_fstest_init.c,$(grub_fstest_SOURCES)) + rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@ +DISTCLEANFILES += grub_fstest_init.lst + +grub_fstest_init.h: grub_fstest_init.lst $(filter-out grub_fstest_init.c,$(grub_fstest_SOURCES)) geninitheader.sh + rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@ +DISTCLEANFILES += grub_fstest_init.h + +grub_fstest_init.c: grub_fstest_init.lst $(filter-out grub_fstest_init.c,$(grub_fstest_SOURCES)) geninit.sh grub_fstest_init.h + rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@ +DISTCLEANFILES += grub_fstest_init.c + # For update-grub update-grub: util/update-grub.in config.status ./config.status --file=$@:$< diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index ff02332..5902608 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -61,6 +61,9 @@ sbin_UTILITIES = grub-setup grub-mkdevicemap grub-probe ifeq ($(enable_grub_emu), yes) sbin_UTILITIES += grub-emu endif +ifeq ($(enable_grub_fstest), yes) +bin_UTILITIES += grub-fstest +endif # For grub-mkimage. grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \ @@ -139,6 +142,22 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \ grub_emu_LDFLAGS = $(LIBCURSES) +# For grub-fstest. +util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h +grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c \ + kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c\ + disk/host.c disk/loopback.c normal/arg.c normal/misc.c \ + io/gzio.c commands/hexdump.c commands/blocklist.c commands/ls.c \ + \ + fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ + fs/hfsplus.c fs/iso9660.c fs/jfs.c fs/minix.c \ + fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ + fs/ufs.c fs/xfs.c \ + \ + kern/partition.c partmap/pc.c partmap/apple.c partmap/gpt.c \ + kern/fs.c kern/env.c fs/fshelp.c disk/lvm.c disk/raid.c \ + grub_fstest_init.c + # Scripts. sbin_SCRIPTS = grub-install bin_SCRIPTS = grub-mkrescue diff --git a/configure b/configure index d272ea6..d1918ca 100755 --- a/configure +++ b/configure @@ -695,6 +695,7 @@ TARGET_CPPFLAGS TARGET_LDFLAGS LIBCURSES enable_grub_emu +enable_grub_fstest LIBOBJS LTLIBOBJS' ac_subst_files='' @@ -1290,6 +1291,8 @@ Optional Features: --disable-largefile omit support for large files --enable-mm-debug include memory manager debugging --enable-grub-emu build and install the `grub-emu' debugging utility + --enable-grub-fstestbuild and install the `grub-fstest' debugging + utility Optional Packages: --with-PACKAGE[=ARG]use PACKAGE [ARG=yes] @@ -8142,6 +8145,13 @@ done fi +# Check whether --enable-grub-fstest was given. +if test "${enable_grub_fstest+set}" = set; then + enableval=$enable_grub_fstest; +fi + + + # Output files. ac_config_links="$ac_config_links include/grub/cpu:include/grub/$target_cpu include/grub/machine:include/grub/$target_cpu/$platform" @@ -8855,11 +8865,12 @@ TARGET_CPPFLAGS!$TARGET_CPPFLAGS$ac_delim TARGET_LDFLAGS!$TARGET_LDFLAGS$ac_delim LIBCURSES!$LIBCURSES$ac_delim enable_grub_emu!$enable_grub_emu$ac_delim +enable_grub_fstest!$enable_grub_fstest$ac_delim LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 82; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 83; then break e
Re: [PATCH] a.out kernel loader
On Jan 29, 2008 5:14 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > > On Jan 29, 2008 4:48 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > >> Bean <[EMAIL PROTECTED]> writes: > >> > >> > On Jan 28, 2008 5:11 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > >> >> On Mon, Jan 28, 2008 at 04:10:42AM +0800, Bean wrote: > >> >> > > > > > >> >> > > > > How FreeBSD-specific is this? Will the same module apply to > >> >> > > > > other a.out > >> >> > > > > binaries ? (I ask since you gave it a generic name) > >> >> > > > > >> >> > > > it's an old format of the unix system: > >> >> > > > > >> >> > > > http://en.wikipedia.org/wiki/A.out > >> >> > > > >> >> > > I know.. I was referring to your loader. > >> >> > > >> >> > it should be generic, but i only test it using the loader from > >> >> > freebsd. > >> >> > >> >> In that case, I'd suggest putting it directly in loader/ (without > >> >> i386/pc/). > >> >> > >> >> Moving files on CVS is a PITA :-/ > >> > > >> > ok, here is the new patch. > >> > >> It would be nice if a.out support could be shared so it can be used > >> for multiboot as well. > > > > you mean adding it to the multiboot module ? > > The multiboot standard supports a.out. It would be nice if it was > also capable of a.out. So this code can somehow be shared, like ELF > support is shared now. but it doesn't have the multiboot header, or the header is not necessary in multiboot 2 ? btw, where can i find spec on multiboot 2 ? -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub-fstest: debug tool for filesystem driver
On Jan 29, 2008 9:45 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > > On Tue, Jan 29, 2008 at 06:18:35PM +0800, Bean wrote: > > --- a/conf/i386-pc.rmk > > +++ b/conf/i386-pc.rmk > > @@ -61,6 +61,9 @@ sbin_UTILITIES = grub-setup grub-mkdevicemap grub-probe > > ifeq ($(enable_grub_emu), yes) > > sbin_UTILITIES += grub-emu > > endif > > +ifeq ($(enable_grub_fstest), yes) > > +bin_UTILITIES += grub-fstest > > +endif > > > > # For grub-mkimage. > > grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \ > > @@ -139,6 +142,22 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c > > commands/cmp.c\ > > > > grub_emu_LDFLAGS = $(LIBCURSES) > > > > +# For grub-fstest. > > +util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h > > +grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c \ > > + kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c\ > > + disk/host.c disk/loopback.c normal/arg.c normal/misc.c \ > > + io/gzio.c commands/hexdump.c commands/blocklist.c commands/ls.c \ > > + \ > > + fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ > > + fs/hfsplus.c fs/iso9660.c fs/jfs.c fs/minix.c \ > > + fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ > > + fs/ufs.c fs/xfs.c \ > > + \ > > + kern/partition.c partmap/pc.c partmap/apple.c partmap/gpt.c \ > > + kern/fs.c kern/env.c fs/fshelp.c disk/lvm.c disk/raid.c \ > > + grub_fstest_init.c > > + > > Can this be in common.rmk ? it seems so, all the required modules are platform independent. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: No entries seen in grub 2 menu
On Jan 30, 2008 2:05 AM, shirish <[EMAIL PROTECTED]> wrote: > Hi all, >First of all Robert, thanx for answering. I know grub2 uses > grub2.cfg & not menu.lst but was thinking if there is some way > whatever is in grub.cfg can be passed to menu.lst so in some way I can > see the menu without changing the entries manually, but now it seems > there is no way to do it unless I just am on grub 0.97 >Now there is another thing which has been the same for the last 6 > months. There is no menu entries in grub2. I get the rectangular box & > that's it. Just for reference here are the same 2 links :- > > http://pastebin.ca/877007 menu.lst (which is of grub 0.97 or grub legacy) > > http://pastebin.ca/877010 grub.cfg ( the newer grub uses this) > > Now from what little I understand when I click on the first option it > chainloads to grub2 & tries to read grub.cfg . Now something or the > other doesn't get it right for I'm not able to see any of the entries. > I don't know whether it has anything to do with unifont.pff or > something else? > > I know unifont has been having some problems. I reported one such > thing about 6-7 months which hasn't moved anywhere till now. > https://bugs.launchpad.net/ubuntu/+source/unifont/+bug/122565 . > Subsequently I see this mail > http://www.mail-archive.com/[EMAIL PROTECTED]/msg19430.html > & it isn't encouraging. If unifont has some issues how can we use > other fonts? What is the *.pff extension? This again may be a repost > hence apologies if they are. > -- > Regards, > Shirish Agarwal > This email is licensed under http://creativecommons.org/licenses/by-nc/3.0/ > > 065C 6D79 A68C E7EA 52B3 8D70 950D 53FB 729A 8B17 are you using the cvs version ? this bug should be fixed by now. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: Compiling grub2 on *BSD?
On Jan 28, 2008 8:56 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Robert Millan <[EMAIL PROTECTED]> writes: > > >> > - movsbl %dh, %eax > >> > - movl%eax, %ss:(DATA_ADDR + > >> > GRUB_KERNEL_MACHINE_INSTALL_DOS_PART) > >> > + // Check for the multiboot signature > >> > + cmpl$0x1badb002, %ss:(DATA_ADDR + 0x50) > >> > + jz 1f > >> [...] > >> > >> if there is no objection, I'd like to check in this patch. > > > > I don't like that you hardcode 0x1badb002. Could you use the macro from > > multiboot.h ? > > > > Also for the comments, I think /* */ is preferred (at least, it is > > consistent > > with the rest of GRUB). > > And do not forget "." :-) Fixed and committed. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] a.out kernel loader
On Jan 30, 2008 2:11 AM, <[EMAIL PROTECTED]> wrote: > > On Tue, Jan 29, 2008 at 03:20:12PM +0800, Bean wrote: > > On Jan 29, 2008 3:11 PM, <[EMAIL PROTECTED]> wrote: > > > On Mon, Jan 28, 2008 at 06:37:16AM -0800, walt wrote: > > > > > > > > When I type 'boot' after loading the netbsd kernel with multiboot, the > > > > machine reboots instantly instead of starting the OS. > > > > > > > > Any ideas? > > > > > > > > > > I've encountered this in qemu where it tells you you are executing code > > > outside ram/rom at the kernel virtual entry address of 0xc010. The > > > NetBSD/i386 kernel needs to be loaded/entered at physical address > > > 0x0010, it's, however, linked to run at 0xc010. > > > > > > This is trivial to fix, but the trivial fix may not be the right fix. > > > > > > Now if only I was having more luck when grub2 was loaded from coreboot. > > > But that's another thread maybe. > > > > my previous multiboot patch fix this problem. > > Did that make it into the repository yet? no, you need to find it among the replies. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] eltorito cdrom boot
data->sectors; + return grub_biosdisk_rw (cmd, disk, sector, size, segment); + } } else { @@ -323,6 +353,8 @@ grub_disk_biosdisk_fini (void) GRUB_MOD_INIT(biosdisk) { + int drive, found = 0; + if (grub_disk_firmware_is_tainted) { grub_printf ("Firmware is marked as tainted, refusing to initialize.\n"); @@ -331,6 +363,23 @@ GRUB_MOD_INIT(biosdisk) grub_disk_firmware_fini = grub_disk_biosdisk_fini; grub_disk_dev_register (&grub_biosdisk_dev); + + for (drive = 0xe0; drive < 0xff; drive++) +{ + if (grub_biosdisk_check_int13_extensions (drive)) +{ + if (! found) + cd_start = drive; + found++; + } + else +{ + if (found) +break; + } +} + + cd_count = found; } GRUB_MOD_FINI(biosdisk) diff --git a/include/grub/i386/pc/biosdisk.h b/include/grub/i386/pc/biosdisk.h index 3591c2b..8319135 100644 --- a/include/grub/i386/pc/biosdisk.h +++ b/include/grub/i386/pc/biosdisk.h @@ -23,6 +23,7 @@ #include #define GRUB_BIOSDISK_FLAG_LBA 1 +#define GRUB_BIOSDISK_FLAG_CDROM 2 struct grub_biosdisk_data { diff --git a/kern/i386/pc/init.c b/kern/i386/pc/init.c index acaf20b..1a4e9df 100644 --- a/kern/i386/pc/init.c +++ b/kern/i386/pc/init.c @@ -71,9 +71,12 @@ make_install_device (void) } else if (grub_install_dos_part != -2) { - grub_sprintf (dev, "(%cd%u", - (grub_boot_drive & 0x80) ? 'h' : 'f', - grub_boot_drive & 0x7f); + if (grub_boot_drive >= 0xe0) +grub_sprintf (dev, "(cd%u", grub_boot_drive - 0xe0); + else +grub_sprintf (dev, "(%cd%u", + (grub_boot_drive & 0x80) ? 'h' : 'f', + grub_boot_drive & 0x7f); if (grub_install_dos_part >= 0) grub_sprintf (dev + grub_strlen (dev), ",%u", grub_install_dos_part + 1); -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub2 resets machine when reading from an xfs filesystem
On Jan 30, 2008 5:39 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Tue, Jan 29, 2008 at 09:32:16PM +, Peter Hicks wrote: > > > > It appears that grub is no longer able to read from an xfs filesystem, and > > an example 32Mb image is contained in a .bz2 file linked to from the bug > > page above. > > Available at: http://stash.poggs.com/grub-xfs-example.bz2 > > It can be reproduced with qemu at least. I gave it a try but get lost too > easily on filesystem stuff. Anyone feels like having a look? Bean what do > you think? :-) when using grub-fstest, i can list and compare files in the example xfs, but if i run it in qemu, it shows qemu: fatal: Trying to execute code outside RAM or ROM at 0x2e2e002e i guess it's caused by invalid memory access somewhere. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub2 resets machine when reading from an xfs filesystem
I figure it out, the problem is caused by nested function: int call_hook (grub_uint64_t ino, char *filename) it would take 3 registry to pass the parameter ! (2 for ino), so %ecx will be overwritten agian. NESTED_FUNC_ATTR doesn't help, because there is only 2 parameters here, so you need to use __attribute__ ((regparm (1))) explicitly. diff --git a/fs/xfs.c b/fs/xfs.c index b3154c7..0e5f323 100644 --- a/fs/xfs.c +++ b/fs/xfs.c @@ -306,9 +306,9 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, grub_fshelp_node_t node)) { struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir; - auto int call_hook (grub_uint64_t ino, char *filename); + auto int __attribute__ ((regparm(1))) call_hook (grub_uint64_t ino, char *filename); - int call_hook (grub_uint64_t ino, char *filename) + int __attribute__ ((regparm(1))) call_hook (grub_uint64_t ino, char *filename) { struct grub_fshelp_node *fdiro; -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub2 resets machine when reading from an xfs filesystem
On Jan 30, 2008 8:08 PM, Marco Gerards <[EMAIL PROTECTED]> wrote: > > Bean <[EMAIL PROTECTED]> writes: > > > I figure it out, the problem is caused by nested function: > > > > int call_hook (grub_uint64_t ino, char *filename) > > > > it would take 3 registry to pass the parameter ! (2 for ino), so %ecx > > will be overwritten agian. > > > > NESTED_FUNC_ATTR doesn't help, because there is only 2 parameters > > here, so you need to use __attribute__ ((regparm (1))) explicitly. > > > > diff --git a/fs/xfs.c b/fs/xfs.c > > index b3154c7..0e5f323 100644 > > --- a/fs/xfs.c > > +++ b/fs/xfs.c > > @@ -306,9 +306,9 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, > > grub_fshelp_node_t node)) > > { > >struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir; > > - auto int call_hook (grub_uint64_t ino, char *filename); > > + auto int __attribute__ ((regparm(1))) call_hook (grub_uint64_t ino, > > char *filename); > > > > - int call_hook (grub_uint64_t ino, char *filename) > > + int __attribute__ ((regparm(1))) call_hook (grub_uint64_t ino, char > > *filename) > > { > >struct grub_fshelp_node *fdiro; > > Do you have a more generic solution to this? Something that can be > compared with NESTED_FUNC_ATTR? This is an i386 only bug... perhaps define NESTED_FUNC_ADDR2 as __attribute__ ((regparm(1))) ? > Besides that, XFS is still not finished as BTrees are not yet > supported. So big files/directories cannot be accessed yet :-/ i'll check this out later. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] a.out kernel loader
On Jan 30, 2008 8:24 PM, walt <[EMAIL PROTECTED]> wrote: > Sorry, I gave you incomplete information. I can use 'multiboot' to load > the netbsd from any kind of fs, but it makes no difference: 'boot' then > causes the machine to reboot instantly. The same applies to aout: I > can aout load from any fs, but then 'boot' make the machine hang. The > type of fs makes no difference. > > I can still 'chainload +1' or 'linux' successfully. > > All of the above applies to the latest grub2 from cvs with your most > recent ufs and aout patches applied. in this case, the ufs driver should be ok. btw, do you remember to apply the multiboot patch ? you can also make a qemu image for me to test. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] eltorito cdrom boot
disk_open (const char *name, grub_disk_t disk) if (drive < 0) return grub_errno; - disk->has_partitions = (drive & 0x80); + disk->has_partitions = ((drive & 0x80) && (drive < cd_start)); disk->id = drive; data = (struct grub_biosdisk_data *) grub_malloc (sizeof (*data)); @@ -106,8 +118,14 @@ grub_biosdisk_open (const char *name, grub_disk_t disk) data->drive = drive; data->flags = 0; - - if (drive & 0x80) + + if (drive >= cd_start) +{ + data->flags = GRUB_BIOSDISK_FLAG_LBA | GRUB_BIOSDISK_FLAG_CDROM; + data->sectors = 32; + total_sectors = 900; /* TODO: get the correct size. */ +} + else if (drive & 0x80) { /* HDD */ int version; @@ -136,18 +154,21 @@ grub_biosdisk_open (const char *name, grub_disk_t disk) } } - if (grub_biosdisk_get_diskinfo_standard (drive, - &data->cylinders, - &data->heads, - &data->sectors) != 0) + if (drive < cd_start) { - grub_free (data); - return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values"); + if (grub_biosdisk_get_diskinfo_standard (drive, + &data->cylinders, + &data->heads, + &data->sectors) != 0) +{ + grub_free (data); + return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values"); +} + + if (! total_sectors) +total_sectors = data->cylinders * data->heads * data->sectors; } - if (! total_sectors) -total_sectors = data->cylinders * data->heads * data->sectors; - disk->total_sectors = total_sectors; disk->data = data; @@ -184,13 +205,22 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk, dap->buffer = segment << 16; /* The format SEGMENT:ADDRESS. */ dap->block = sector; - if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap)) - { - /* Fall back to the CHS mode. */ - data->flags &= ~GRUB_BIOSDISK_FLAG_LBA; - disk->total_sectors = data->cylinders * data->heads * data->sectors; - return grub_biosdisk_rw (cmd, disk, sector, size, segment); + if (data->flags & GRUB_BIOSDISK_FLAG_CDROM) +{ + dap->blocks >>= 2; + dap->block >>= 2; + + if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap)) + return grub_errno; } + else +if (grub_biosdisk_rw_int13_extensions (cmd + 0x42, data->drive, dap)) + { + /* Fall back to the CHS mode. */ + data->flags &= ~GRUB_BIOSDISK_FLAG_LBA; + disk->total_sectors = data->cylinders * data->heads * data->sectors; + return grub_biosdisk_rw (cmd, disk, sector, size, segment); + } } else { @@ -323,6 +353,8 @@ grub_disk_biosdisk_fini (void) GRUB_MOD_INIT(biosdisk) { + int drive, found = 0; + if (grub_disk_firmware_is_tainted) { grub_printf ("Firmware is marked as tainted, refusing to initialize.\n"); @@ -331,6 +363,23 @@ GRUB_MOD_INIT(biosdisk) grub_disk_firmware_fini = grub_disk_biosdisk_fini; grub_disk_dev_register (&grub_biosdisk_dev); + + for (drive = 0xe0; drive < 0xff; drive++) +{ + if (grub_biosdisk_check_int13_extensions (drive)) +{ + if (! found) + cd_start = drive; + found++; + } + else +{ + if (found) +break; + } +} + + cd_count = found; } GRUB_MOD_FINI(biosdisk) diff --git a/include/grub/i386/pc/biosdisk.h b/include/grub/i386/pc/biosdisk.h index 3591c2b..8319135 100644 --- a/include/grub/i386/pc/biosdisk.h +++ b/include/grub/i386/pc/biosdisk.h @@ -23,6 +23,7 @@ #include #define GRUB_BIOSDISK_FLAG_LBA 1 +#define GRUB_BIOSDISK_FLAG_CDROM 2 struct grub_biosdisk_data { diff --git a/kern/i386/pc/init.c b/kern/i386/pc/init.c index acaf20b..1a4e9df 100644 --- a/kern/i386/pc/init.c +++ b/kern/i386/pc/init.c @@ -71,9 +71,12 @@ make_install_device (void) } else if (grub_install_dos_part != -2) { - grub_sprintf (dev, "(%cd%u", - (grub_boot_drive & 0x80) ? 'h' : 'f', - grub_boot_drive & 0x7f); + if (grub_boot_drive >= 0xe0) +grub_sprintf (dev, "(cd%u", grub_boot_drive - 0xe0); + else +grub_sprintf (dev, "(%cd%u", + (grub_boot_drive & 0x80) ? 'h' : 'f', + grub_boot_drive & 0x7f); if (grub_install_dos_part >= 0) grub_sprintf (dev + grub_strlen (dev), ",%u", grub_install_dos_part + 1); -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] eltorito cdrom boot
Changes in this new version: Fix a bug in lnxboot. Use macro for magic values. Try 3 times when reading from cdrom. 2008-01-31 Bean <[EMAIL PROTECTED]> * boot/i396/pc/lnxboot.S (data_start): Add cdrom boot support. * disk/i386/pc/biosdisk.c (cd_start): New variable. (cd_count): Likewise. (grub_biosdisk_get_drive): Add support for cd device. (grub_biosdisk_call_hook): Likewise. (grub_biosdisk_iterate): Likewise. (grub_biosdisk_open): Likewise. (GRUB_BIOSDISK_CDROM_RETRY_COUNT): New macro. (grub_biosdisk_rw): Support reading from cd device. (GRUB_MOD_INIT): Iterate cd devices. * include/grub/i386/pc/biosdisk.h (GRUB_BIOSDISK_FLAG_CDROM): New macro. (GRUB_BIOSDISK_MACHINE_CDROM_START): Likewise. (GRUB_BIOSDISK_MACHINE_CDROM_END): Likewise. * kern/i386/pc/init.c (make_install_device): Check for cd device. diff --git a/boot/i386/pc/lnxboot.S b/boot/i386/pc/lnxboot.S index 6a4de8d..99f896f 100644 --- a/boot/i386/pc/lnxboot.S +++ b/boot/i386/pc/lnxboot.S @@ -30,6 +30,9 @@ #define BLCK_LENG 0x4000 +#define CDSEC_SHIFT11 +#define CDBLK_LENG 16 + .text .code16 @@ -38,7 +41,122 @@ data_start: xorl%ebp, %ebp - jmp linux_next + calldata_next + +data_next: + jmp 1f + + . = data_start + 8 + +bi_pvd: + .long 0 /* LBA of primary volume descript. */ +bi_file: + .long 0 /* LBA of boot file. */ +bi_length: + .long 0 /* Length of boot file. */ +bi_csum: + .long 0 /* Checksum of boot file */ +bi_reserved: + .space (10*4) /* Reserved */ + +1: + popw%bx + + cmpb$0xe0, %dl + jb linux_next + + movl%cs: bi_length - data_next(%bx), %ecx + orl %ecx, %ecx + jz linux_next + + /* Boot from CDROM. */ + + xorw%ax, %ax + movw%ax, %ss + movw$(CODE_ADDR), %sp + movw%ax, %ds + movw%ax, %es + + addl$((1 << CDSEC_SHIFT) - 1), %ecx + shrl$CDSEC_SHIFT, %ecx + + movl%cs: bi_file - data_next(%bx), %esi + + callread_cdrom + + ljmp$(DATA_ADDR >> 4), $0 + + +/* + * Parameters: + * esi: start sector + * ecx: number of sectors + */ +read_cdrom: + xorl%eax, %eax + + /* Number of blocks to read. */ + pushw $CDBLK_LENG + + /* Block number. */ + pushl %eax + pushl %esi + + /* Buffer address. */ + pushw $((DATA_ADDR - CODE_LENG - 0x400)>> 4) + pushl %eax + pushw $0x10 + + xorl%edi, %edi + movw%sp, %si + +1: + movw0x10(%si), %di + cmpl%ecx, %edi + jbe 2f + movl%ecx, %edi + +2: + mov %di, 2(%si) + + pushl %ecx + + movb$0x42, %ah + int $0x13 + + jnc 3f + + movb$0x42, %ah /* Try again. */ + int $0x13 + + jnc 3f + +2: + shrw$1, %di /* Reduce transfer size. */ + jz cdrom_fail + movw%di, 0x10(%si) + movw%di, 2(%si) + movb$0x42, %ah + int $0x13 + jc 2b + +3: + + movw%di, %ax + shlw$(CDSEC_SHIFT - 4), %ax + addw%ax, 6(%si) + addl%edi, 8(%si) + + popl%ecx + subl%edi, %ecx + jnz 1b + + addw$0x12, %sp + ret + +cdrom_fail: + movw$(0x7C00 + err_cdfail_msg - data_start), %si + jmp fail . = data_start + 0x1F1 @@ -142,8 +260,7 @@ normalize: real_code: subw$0x20, %ax movw%ax, %ds - movw(setup_sects - data_start), %cx - shlw$7, %cx + movw$((CODE_LENG) >> 2), %cx /* Setup stack. */ @@ -286,6 +403,9 @@ fail: err_int15_msg: .ascii "move memory fails\0" +err_cdfail_msg: + .ascii "cdrom read fails\0" + . = (. & (~0x1FF)) + 0x1FF .byte 0 diff --git a/disk/i386/pc/biosdisk.c b/disk/i386/pc/biosdisk.c index eb22e6d..9c0ecc5 100644 --- a/disk/i386/pc/biosdisk.c +++ b/disk/i386/pc/biosdisk.c @@ -26,12 +26,15 @@ #include #include +static int cd_start = GRUB_BIOSDISK_MACHINE_CDROM_START; +static int cd_count = 0; + static int grub_biosdisk_get_drive (const char *name) { unsigned long drive; - if ((name[0] != 'f' && name[0] != 'h') || name[1] != 'd') + if ((name[0] != 'f' && name[0] != 'h' && name[0] != 'c') || name[1] != 'd') goto fail; drive = grub_strtoul (name + 2, 0, 10); @@ -40,6 +43,8 @@ grub_biosdisk_get_drive (const char *name) if (name[0] == 'h') drive += 0x80; + else if (name[0] == 'c') +drive += cd_sta
Re: [PATCH] eltorito cdrom boot
Hi, ok, this is the new patch, the cdboot function is implemented in separate file cdboot.S. To create a eltorito boot file, use: cat cdboot.img core.img > grub2cd.bin 2008-01-31 Bean <[EMAIL PROTECTED]> * conf/i386-pc.rmk (pkglib_IMAGES): Add cdboot.img. (cdboot_img_SOURCES): New variable. (cdboot_img_ASFLAGS): New variable. (cdboot_img_LDFLAGS): New variable. * boot/i386/pc/cdboot.S: New file. * disk/i386/pc/biosdisk.c (cd_start): New variable. (cd_count): Likewise. (grub_biosdisk_get_drive): Add support for cd device. (grub_biosdisk_call_hook): Likewise. (grub_biosdisk_iterate): Likewise. (grub_biosdisk_open): Likewise. (GRUB_BIOSDISK_CDROM_RETRY_COUNT): New macro. (grub_biosdisk_rw): Support reading from cd device. (GRUB_MOD_INIT): Iterate cd devices. * include/grub/i386/pc/biosdisk.h (GRUB_BIOSDISK_FLAG_CDROM): New macro. (GRUB_BIOSDISK_MACHINE_CDROM_START): Likewise. (GRUB_BIOSDISK_MACHINE_CDROM_END): Likewise. * kern/i386/pc/init.c (make_install_device): Check for cd device. diff --git a/boot/i386/pc/cdboot.S b/boot/i386/pc/cdboot.S new file mode 100644 index 000..430496f --- /dev/null +++ b/boot/i386/pc/cdboot.S @@ -0,0 +1,171 @@ +/* -*-Asm-*- */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 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 +#include +#include +#include + +.file "cdboot.S" + +#define CODE_ADDR 0x6000 +#define DATA_ADDR ((GRUB_BOOT_MACHINE_KERNEL_ADDR) + 0x200) + +#define CDSEC_SHIFT11 +#define CDBLK_LENG 16 + + .text + +.code16 + +.globl start, _start + +data_start: + calldata_next + +data_next: + jmp 1f + + . = data_start + 8 + +bi_pvd: + .long 0 /* LBA of primary volume descript. */ +bi_file: + .long 0 /* LBA of boot file. */ +bi_length: + .long 0 /* Length of boot file. */ +bi_csum: + .long 0 /* Checksum of boot file */ +bi_reserved: + .space (10*4) /* Reserved */ + +1: + popw%bx + + /* Boot from CDROM. */ + + xorw%ax, %ax + movw%ax, %ss + movw$(CODE_ADDR), %sp + movw%ax, %ds + movw%ax, %es + + movw$(0x7C00 + err_noboot_msg - data_start), %si + movl%cs: bi_length - data_next(%bx), %ecx + orl %ecx, %ecx + jz fail + + addl$((1 << CDSEC_SHIFT) - 1), %ecx + shrl$CDSEC_SHIFT, %ecx + + movl%cs: bi_file - data_next(%bx), %esi + + callread_cdrom + + ljmp$(DATA_ADDR >> 4), $0 + +/* + * Parameters: + * esi: start sector + * ecx: number of sectors + */ +read_cdrom: + xorl%eax, %eax + + /* Number of blocks to read. */ + pushw $CDBLK_LENG + + /* Block number. */ + pushl %eax + pushl %esi + + /* Buffer address. */ + pushw $((DATA_ADDR - 0x400)>> 4) + pushl %eax + pushw $0x10 + + xorl%edi, %edi + movw%sp, %si + +1: + movw0x10(%si), %di + cmpl%ecx, %edi + jbe 2f + movl%ecx, %edi + +2: + mov %di, 2(%si) + + pushl %ecx + + movb$0x42, %ah + int $0x13 + + jnc 3f + + movb$0x42, %ah /* Try again. */ + int $0x13 + + jnc 3f + +2: + shrw$1, %di /* Reduce transfer size. */ + jz cdrom_fail + movw%di, 0x10(%si) + movw%di, 2(%si) + movb$0x42, %ah + int $0x13 + jc 2b + +3: + + movw%di, %ax + shlw$(CDSEC_SHIFT - 4), %ax + addw%ax, 6(%si) + addl%edi, 8(%si) + + popl%ecx + subl%edi, %ecx + jnz 1b + + addw$0x12, %sp + ret + +cdrom_fail: + movw$(0x7C00 + err_cdfail_msg - data_start), %si + +fail: + movb$0x0e, %ah + xorw%bx, %bx +1: + lodsb (%si), %al + int $0x10 + cmpb$0, %al + jne 1b +1: jmp 1b + +err_noboot_msg: + .ascii "no boot info\0" + +err_cdfail_msg: +
Re: [PATCH] eltorito cdrom boot
On Jan 31, 2008 8:47 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Thu, Jan 31, 2008 at 12:09:06PM +0100, Robert Millan wrote: > > > > Typo (i396). > > > > Do we really want to mix linux boot with eltorito boot? Is much core from > > original lnxboot reused by eltorito boot? > > I meant `code' of course. the error report routine is shared, other code is separate. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] btree support in xfs driver
Hi, I add btree support for the xfs driver, and fix a few bugs. Now i' m able to list a directory of over 5000 files, please test it. 2008-02-01 Bean <[EMAIL PROTECTED]> * fs/xfs.h (grub_xfs_sblock): New member log2_dirblk. (grub_xfs_btree_node): New structure. (grub_xfs_btree_root): New structure. (grub_xfs_inode): New member nblocks, extsize, nextents and btree. (GRUB_XFS_EXTENT_OFFSET): Use exts instead of inode->data.extents. (GRUB_XFS_EXTENT_BLOCK): Likewise. (GRUB_XFS_EXTENT_SIZE): Likewise. (grub_xfs_read_block): Support btree format type. (grub_xfs_iterate_dir): Use regparm(1) attribute in call_hook. Use directory block as basic unit. diff --git a/fs/xfs.c b/fs/xfs.c index b3154c7..fc5dc04 100644 --- a/fs/xfs.c +++ b/fs/xfs.c @@ -47,6 +46,8 @@ struct grub_xfs_sblock grub_uint8_t unused4[2]; grub_uint8_t log2_inop; grub_uint8_t log2_agblk; + grub_uint8_t unused5[67]; + grub_uint8_t log2_dirblk; } __attribute__ ((packed)); struct grub_xfs_dir_header @@ -72,6 +73,23 @@ struct grub_xfs_dir2_entry typedef grub_uint32_t grub_xfs_extent[4]; +struct grub_xfs_btree_node +{ + grub_uint8_t magic[4]; + grub_uint16_t level; + grub_uint16_t numrecs; + grub_uint64_t left; + grub_uint64_t right; + grub_uint64_t keys[1]; +} __attribute__ ((packed)); + +struct grub_xfs_btree_root +{ + grub_uint16_t level; + grub_uint16_t numrecs; + grub_uint64_t keys[1]; +} __attribute__ ((packed)); + struct grub_xfs_inode { grub_uint8_t magic[2]; @@ -80,7 +98,10 @@ struct grub_xfs_inode grub_uint8_t format; grub_uint8_t unused2[50]; grub_uint64_t size; - grub_uint8_t unused3[36]; + grub_uint64_t nblocks; + grub_uint32_t extsize; + grub_uint32_t nextents; + grub_uint8_t unused3[20]; union { char raw[156]; @@ -90,6 +111,7 @@ struct grub_xfs_inode struct grub_xfs_dir_entry direntry[1]; } dir; grub_xfs_extent extents[XFS_INODE_EXTENTS]; +struct grub_xfs_btree_root btree; } data __attribute__ ((packed)); } __attribute__ ((packed)); @@ -138,18 +160,18 @@ static grub_dl_t my_mod; #define GRUB_XFS_INO_AG(data,ino) \ (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data)) -#define GRUB_XFS_EXTENT_OFFSET(inode,ex) \ - ((grub_be_to_cpu32 ((inode)->data.extents[ex][0]) & ~(1 << 31)) << 23 \ - | grub_be_to_cpu32 ((inode)->data.extents[ex][1]) >> 9) +#define GRUB_XFS_EXTENT_OFFSET(exts,ex) \ + ((grub_be_to_cpu32 (exts[ex][0]) & ~(1 << 31)) << 23 \ + | grub_be_to_cpu32 (exts[ex][1]) >> 9) -#define GRUB_XFS_EXTENT_BLOCK(inode,ex)\ - ((grub_uint64_t) (grub_be_to_cpu32 ((inode)->data.extents[ex][1]) \ +#define GRUB_XFS_EXTENT_BLOCK(exts,ex) \ + ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex][1]) \ & (~255)) << 43 \ - | (grub_uint64_t) grub_be_to_cpu32 ((inode)->data.extents[ex][2]) << 11 \ - | grub_be_to_cpu32 ((inode)->data.extents[ex][3]) >> 21) + | (grub_uint64_t) grub_be_to_cpu32 (exts[ex][2]) << 11 \ + | grub_be_to_cpu32 (exts[ex][3]) >> 21) -#define GRUB_XFS_EXTENT_SIZE(inode,ex) \ - (grub_be_to_cpu32 ((inode)->data.extents[ex][3]) & ((1 << 20) - 1)) +#define GRUB_XFS_EXTENT_SIZE(exts,ex) \ + (grub_be_to_cpu32 (exts[ex][3]) & ((1 << 20) - 1)) #define GRUB_XFS_ROUND_TO_DIRENT(pos) pos) + 8 - 1) / 8) * 8) #define GRUB_XFS_NEXT_DIRENT(pos,len) \ @@ -200,9 +221,60 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, static int grub_xfs_read_block (grub_fshelp_node_t node, int fileblock) { - int ex; + struct grub_xfs_btree_node *leaf = 0; + int ex, nrec; + grub_xfs_extent *exts; + + if (node->inode.format == XFS_INODE_FORMAT_BTREE) +{ + grub_uint64_t *keys; + + leaf = grub_malloc (node->data->sblock.bsize); + if (leaf == 0) +return 0; + + nrec = grub_be_to_cpu16 (node->inode.data.btree.numrecs); + keys = &node->inode.data.btree.keys[0]; + do +{ + int i; + + for (i = 0; i < nrec; i++) +{ + if ((grub_uint64_t) fileblock >= grub_be_to_cpu64 (keys[i])) +break; +} - if (node->inode.format != XFS_INODE_FORMAT_EXT) + /* Not found, it's a sparse block. */ + if (i == nrec) +{ + grub_free (leaf); + return 0; +} + + if (grub_disk_read(node->data->disk, + grub_be_to_cpu64(keys[i + XFS_INODE_EXTENTS]) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS), + 0, node->data->sblock.bsize, (char *) leaf)) +return 0; + + if (grub_strncmp ((char *) leaf->magic,
Re: [PATCH] a.out kernel loader
On Feb 1, 2008 9:46 AM, walt <[EMAIL PROTECTED]> wrote: > > Bean wrote: > > On Jan 30, 2008 8:24 PM, walt<[EMAIL PROTECTED]> wrote: > >> Sorry, I gave you incomplete information. I can use 'multiboot' to load > >> the netbsd from any kind of fs, but it makes no difference: 'boot' then > >> causes the machine to reboot instantly. The same applies to aout: I > >> can aout load from any fs, but then 'boot' make the machine hang. The > >> type of fs makes no difference. > >> > >> I can still 'chainload +1' or 'linux' successfully. > >> > >> All of the above applies to the latest grub2 from cvs with your most > >> recent ufs and aout patches applied. > > > > in this case, the ufs driver should be ok. > > > > btw, do you remember to apply the multiboot patch ? you can also make > > a qemu image for me to test. > > Aha! I forgot the multiboot patch :o( Now I can multiboot netbsd from > any filesystem and it 'just works'. Most excellent, thank you! > > Sadly, 'aout /boot/loader' still hangs when I type 'boot'. The loader > is obviously probing the floppy drive because I can hear it seeking just > like it does when the machine reboots. This is not what happens when > /boot/loader is working normally -- it should immediately load the kernel > from the hard disk with no additional hardware probing. > > Let me know if I can give you any more info. i see, perhaps i need to set %dl properly before jumping to the code. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] btree support in xfs driver
On Feb 1, 2008 3:57 AM, Marco Gerards <[EMAIL PROTECTED]> wrote: > Bean <[EMAIL PROTECTED]> writes: > > Hi Bean! > > > I add btree support for the xfs driver, and fix a few bugs. Now i' m > > able to list a directory of over 5000 files, please test it. > > You rock! > > Can you load big files now, that are stored in BTrees. Did you use > code from elsewhere? it should be, grub_xfs_read_block is used by both file and directory. > > > 2008-02-01 Bean <[EMAIL PROTECTED]> > > > > * fs/xfs.h (grub_xfs_sblock): New member log2_dirblk. > > (grub_xfs_btree_node): New structure. > > (grub_xfs_btree_root): New structure. > > (grub_xfs_inode): New member nblocks, extsize, nextents and btree. > > members > > > (GRUB_XFS_EXTENT_OFFSET): Use exts instead of inode->data.extents. > > (GRUB_XFS_EXTENT_BLOCK): Likewise. > > (GRUB_XFS_EXTENT_SIZE): Likewise. > > (grub_xfs_read_block): Support btree format type. > > (grub_xfs_iterate_dir): Use regparm(1) attribute in call_hook. > > Use directory block as basic unit. > > This won't work on non-i386. So I think this has to be fixed like > that other bug, for example with the autoconf check extension you > proposed. i take a look at the aclocal.m4, the place where NESTED_FUNC_ATTR is defined: AC_MSG_RESULT([$grub_cv_i386_check_nested_functions]) if test "x$grub_cv_i386_check_nested_functions" = xyes; then AC_DEFINE([NESTED_FUNC_ATTR], [__attribute__ ((__regparm__ (2)))], [Catch gcc bug]) else dnl Unfortunately, the above test does not detect a bug in gcc-4.0. dnl So use regparm 2 until a better test is found. AC_DEFINE([NESTED_FUNC_ATTR], [__attribute__ ((__regparm__ (2)))], [Catch gcc bug]) fi is there a problem here ? i think NESTED_FUNC_ATTR is defined regardless of the test result. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] btree support in xfs driver
Hi, change in this new patch: Fix small bug in xfs Fix a bug in fshelp Define NESTED_FUNC_ATTR as regparm(1) and us it for call_hook. With this patch, i'm able to load a highly sparse file about 200M. 2008-02-01 Bean <[EMAIL PROTECTED]> * fs/xfs.c (grub_xfs_sblock): New member log2_dirblk. (grub_xfs_btree_node): New structure. (grub_xfs_btree_root): New structure. (grub_xfs_inode): New members nblocks, extsize, nextents and btree. (GRUB_XFS_EXTENT_OFFSET): Use exts instead of inode->data.extents. (GRUB_XFS_EXTENT_BLOCK): Likewise. (GRUB_XFS_EXTENT_SIZE): Likewise. (grub_xfs_read_block): Support btree format type. (grub_xfs_iterate_dir): Use NESTED_FUNC_ATTR in call_hook. Use directory block as basic unit. * fs/fshelp.c (grub_fshelp_read_file): Bug fix for sparse block. * aclocal.m4 (grub_i386_CHECK_REGPARM_BUG): Define NESTED_FUNC_ATTR as __attribute__ ((__regparm__ (1))). diff --git a/aclocal.m4 b/aclocal.m4 index 803d57b..a634253 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -333,13 +333,13 @@ AC_MSG_RESULT([$grub_cv_i386_check_nested_functions]) if test "x$grub_cv_i386_check_nested_functions" = xyes; then AC_DEFINE([NESTED_FUNC_ATTR], - [__attribute__ ((__regparm__ (2)))], + [__attribute__ ((__regparm__ (1)))], [Catch gcc bug]) else dnl Unfortunately, the above test does not detect a bug in gcc-4.0. dnl So use regparm 2 until a better test is found. AC_DEFINE([NESTED_FUNC_ATTR], - [__attribute__ ((__regparm__ (2)))], + [__attribute__ ((__regparm__ (1)))], [Catch gcc bug]) fi ]) diff --git a/configure b/configure index d1918ca..aa52a94 100755 --- a/configure +++ b/configure @@ -7515,13 +7515,13 @@ echo "${ECHO_T}$grub_cv_i386_check_nested_functions" >&6; } if test "x$grub_cv_i386_check_nested_functions" = xyes; then cat >>confdefs.h <<\_ACEOF -#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (2))) +#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (1))) _ACEOF else cat >>confdefs.h <<\_ACEOF -#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (2))) +#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (1))) _ACEOF fi diff --git a/fs/fshelp.c b/fs/fshelp.c index ba97a2f..bbb58ac 100644 --- a/fs/fshelp.c +++ b/fs/fshelp.c @@ -282,7 +282,7 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node, return -1; } else - grub_memset (buf, blocksize - skipfirst, 0); + grub_memset (buf, 0, blockend); buf += blocksize - skipfirst; } diff --git a/fs/xfs.c b/fs/xfs.c index b3154c7..29f7891 100644 --- a/fs/xfs.c +++ b/fs/xfs.c @@ -47,6 +47,8 @@ struct grub_xfs_sblock grub_uint8_t unused4[2]; grub_uint8_t log2_inop; grub_uint8_t log2_agblk; + grub_uint8_t unused5[67]; + grub_uint8_t log2_dirblk; } __attribute__ ((packed)); struct grub_xfs_dir_header @@ -72,6 +74,23 @@ struct grub_xfs_dir2_entry typedef grub_uint32_t grub_xfs_extent[4]; +struct grub_xfs_btree_node +{ + grub_uint8_t magic[4]; + grub_uint16_t level; + grub_uint16_t numrecs; + grub_uint64_t left; + grub_uint64_t right; + grub_uint64_t keys[1]; +} __attribute__ ((packed)); + +struct grub_xfs_btree_root +{ + grub_uint16_t level; + grub_uint16_t numrecs; + grub_uint64_t keys[1]; +} __attribute__ ((packed)); + struct grub_xfs_inode { grub_uint8_t magic[2]; @@ -80,7 +99,10 @@ struct grub_xfs_inode grub_uint8_t format; grub_uint8_t unused2[50]; grub_uint64_t size; - grub_uint8_t unused3[36]; + grub_uint64_t nblocks; + grub_uint32_t extsize; + grub_uint32_t nextents; + grub_uint8_t unused3[20]; union { char raw[156]; @@ -90,6 +112,7 @@ struct grub_xfs_inode struct grub_xfs_dir_entry direntry[1]; } dir; grub_xfs_extent extents[XFS_INODE_EXTENTS]; +struct grub_xfs_btree_root btree; } data __attribute__ ((packed)); } __attribute__ ((packed)); @@ -138,18 +161,18 @@ static grub_dl_t my_mod; #define GRUB_XFS_INO_AG(data,ino) \ (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data)) -#define GRUB_XFS_EXTENT_OFFSET(inode,ex) \ - ((grub_be_to_cpu32 ((inode)->data.extents[ex][0]) & ~(1 << 31)) << 23 \ - | grub_be_to_cpu32 ((inode)->data.extents[ex][1]) >> 9) +#define GRUB_XFS_EXTENT_OFFSET(exts,ex) \ + ((grub_be_to_cpu32 (exts[ex][0]) & ~(1 << 31)) << 23 \ + | grub_be_to_cpu32 (exts[ex][1]) >> 9) -#define GRUB_XFS_EXTENT_BLOCK(inode,ex)\ - ((grub_uint64_t) (grub_be_to_cpu32 ((inode)->data.extents[ex][1]) \ - & (~255)) << 43 \ - | (grub_uint64_t) grub_be_to_cpu32 ((inode)->data.extents[ex][2]) << 11 \ - | grub_be_to_cpu32 ((inode)->data.extents[ex][3]) >> 21) +#define GRUB_XFS_EXTENT_BLOC
[PATCH] support joliet extension in iso9660 filesystem
Hi, This patch add joliet extension support for iso9660. 2008-02-02 Bean <[EMAIL PROTECTED]> * fs/iso9660.c (GRUB_ISO9660_VOLDESC_BOOT): New macro. (GRUB_ISO9660_VOLDESC_PRIMARY): Likewise. (GRUB_ISO9660_VOLDESC_SUPP): Likewise. (GRUB_ISO9660_VOLDESC_PART): Likewise. (GRUB_ISO9660_VOLDESC_END): Likewise. (grub_iso9660_primary_voldesc): New member escape. (grub_iso9660_data): New member joliet. (grub_iso9660_convert_string): New function. (grub_iso9660_mount): Detect joliet extension. (grub_iso9660_iterate_dir): Convert filename when joliet is detected. (grub_iso9660_iso9660_label): Likewise. diff --git a/fs/iso9660.c b/fs/iso9660.c index 15ce51d..b1562a7 100644 --- a/fs/iso9660.c +++ b/fs/iso9660.c @@ -38,6 +38,12 @@ #define GRUB_ISO9660_RR_DOT2 #define GRUB_ISO9660_RR_DOTDOT 4 +#define GRUB_ISO9660_VOLDESC_BOOT 0 +#define GRUB_ISO9660_VOLDESC_PRIMARY 1 +#define GRUB_ISO9660_VOLDESC_SUPP 2 +#define GRUB_ISO9660_VOLDESC_PART 3 +#define GRUB_ISO9660_VOLDESC_END 255 + /* The head of a volume descriptor. */ struct grub_iso9660_voldesc { @@ -67,11 +73,13 @@ struct grub_iso9660_primary_voldesc struct grub_iso9660_voldesc voldesc; grub_uint8_t unused1[33]; grub_uint8_t volname[32]; - grub_uint8_t unused2[60]; + grub_uint8_t unused2[16]; + grub_uint8_t escape[32]; + grub_uint8_t unused3[12]; grub_uint32_t path_table_size; - grub_uint8_t unused3[4]; + grub_uint8_t unused4[4]; grub_uint32_t path_table; - grub_uint8_t unused4[12]; + grub_uint8_t unused5[12]; struct grub_iso9660_dir rootdir; } __attribute__ ((packed)); @@ -115,6 +123,7 @@ struct grub_iso9660_data unsigned int length; int rockridge; int susp_skip; + int joliet; }; struct grub_fshelp_node @@ -197,6 +206,23 @@ grub_iso9660_susp_iterate (struct grub_iso9660_data *data, return 0; } +static grub_uint8_t * +grub_iso9660_convert_string (grub_uint16_t *us, int len) +{ + grub_uint8_t *p; + int i; + + p = grub_malloc (len * 4 + 1); + if (! p) +return p; + + for (i=0; idisk = disk; + data->rockridge = 0; + data->joliet = 0; + + sec = 16; + do +{ + int is_copy = 0; + /* Read the superblock. */ - if (grub_disk_read (disk, 16 << GRUB_ISO9660_LOG2_BLKSZ, 0, + if (grub_disk_read (disk, sec << GRUB_ISO9660_LOG2_BLKSZ, 0, sizeof (struct grub_iso9660_primary_voldesc), - (char *) &data->voldesc)) + (char *) &voldesc)) { grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem"); goto fail; } - if (grub_strncmp ((char *) data->voldesc.voldesc.magic, "CD001", 5) != 0) + if (grub_strncmp ((char *) voldesc.voldesc.magic, "CD001", 5) != 0) { grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem"); goto fail; } - data->disk = disk; - data->rockridge = 0; - - /* Read the system use area and test it to see if SUSP is - supported. */ - if (grub_disk_read (disk, (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector) -<< GRUB_ISO9660_LOG2_BLKSZ), 0, - sizeof (rootdir), (char *) &rootdir)) + if (voldesc.voldesc.type == GRUB_ISO9660_VOLDESC_PRIMARY) +is_copy = 1; + else if ((voldesc.voldesc.type == GRUB_ISO9660_VOLDESC_SUPP) && + (voldesc.escape[0] == 0x25) && (voldesc.escape[1] == 0x2f) && + ((voldesc.escape[2] == 0x40) || /* UCS-2 Level 1. */ +(voldesc.escape[2] == 0x43) || /* UCS-2 Level 2. */ +(voldesc.escape[2] == 0x45))) /* UCS-2 Level 3. */ { - grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem"); - goto fail; + is_copy = 1; + data->joliet = 1; } + if (is_copy) +grub_memcpy((char *) &data->voldesc, (char *) &voldesc, +sizeof (struct grub_iso9660_primary_voldesc)); + + sec++; +} while (voldesc.voldesc.type != GRUB_ISO9660_VOLDESC_END); + + /* Read the system use area and test it to see if SUSP is + supported. */ if (grub_disk_read (disk, (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector) << GRUB_ISO9660_LOG2_BLKSZ), 0, sizeof (rootdir), (char *) &rootdir)) @@ -572,6 +617,20 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, filename = name; } +if (dir->data->joliet) + { +char *oldname; + +oldname = filename; +filename = grub_iso9660_convert_string + ((grub_uint16_t *) oldname, dirent.namelen >> 1); + +if (filename_alloc) + grub_free (oldname); + +file
Re: booting kernel of NetBSD (Re: UFS (FFS) support seems broken in grub2)
Committed. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] btree support in xfs driver
Committed. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] eltorito cdrom boot
On Jan 31, 2008 8:43 PM, Bean <[EMAIL PROTECTED]> wrote: > 2008-01-31 Bean <[EMAIL PROTECTED]> > > * conf/i386-pc.rmk (pkglib_IMAGES): Add cdboot.img. > (cdboot_img_SOURCES): New variable. > (cdboot_img_ASFLAGS): New variable. > (cdboot_img_LDFLAGS): New variable. > > * boot/i386/pc/cdboot.S: New file. > > * disk/i386/pc/biosdisk.c (cd_start): New variable. > (cd_count): Likewise. > (grub_biosdisk_get_drive): Add support for cd device. > (grub_biosdisk_call_hook): Likewise. > (grub_biosdisk_iterate): Likewise. > (grub_biosdisk_open): Likewise. > (GRUB_BIOSDISK_CDROM_RETRY_COUNT): New macro. > (grub_biosdisk_rw): Support reading from cd device. > (GRUB_MOD_INIT): Iterate cd devices. > > * include/grub/i386/pc/biosdisk.h (GRUB_BIOSDISK_FLAG_CDROM): New > macro. > (GRUB_BIOSDISK_MACHINE_CDROM_START): Likewise. > (GRUB_BIOSDISK_MACHINE_CDROM_END): Likewise. > > * kern/i386/pc/init.c (make_install_device): Check for cd device. > any objection for this patch ? i would like to commit it soon. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Move os dependent code to a separate file ?
Hi, i can see that there are linux specific code in util/biosdisk.c, perhaps we should move them to a separate file such as util/osdep.c ? -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] eltorito cdrom boot
On Feb 3, 2008 12:33 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Sat, Feb 02, 2008 at 10:19:55PM +0800, Bean wrote: > > > > any objection for this patch ? i would like to commit it soon. > > Looks fine to me. Just a minor comment: > > > +#define GRUB_BIOSDISK_MACHINE_CDROM_START 0xe0 > > +#define GRUB_BIOSDISK_MACHINE_CDROM_END 0xf0 > > could you make this tab-indented? no problem. > > Also, I notice that GRUB_BIOSDISK_MACHINE_CDROM_END is not used. Did you plan > to add a sanity check in init.c using this macro ? it's used in GRUB_MOD_INIT(biosdisk) as the end drive letter to scan for cds. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub.cfg parser still doesn't abort on error
On Feb 3, 2008 5:07 AM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Sat, Feb 02, 2008 at 09:59:57PM +0100, Marco Gerards wrote: > > Robert Millan <[EMAIL PROTECTED]> writes: > > > > > Try the following grub.cfg: > > > > > > cat (memdisk)/non-existant-file > > > echo this point should never be reached > > > read > > > > > > You'll see that the echo is reached, even if cat returned an error. > > > > > > This becomes much worse when found in situations like: > > > > > > font (xxx)/some-file.pff > > > terminal gfxterm > > > > > > and the font wasn't loaded. > > > > Urgh! Bean committed a patch that zero'ed the error. Perhaps it was > > wrong? ;-) > > > > Can you try reverting it? :-) > > Actually, it was wrong before that. i think you can use the if statement to test command result. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] eltorito cdrom boot
Committed. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub.cfg parser still doesn't abort on error
On Feb 3, 2008 6:55 PM, Robert Millan <[EMAIL PROTECTED]> wrote: > On Sun, Feb 03, 2008 at 11:05:26AM +0800, Bean wrote: > > > > > Try the following grub.cfg: > > > > > > > > > > cat (memdisk)/non-existant-file > > > > > echo this point should never be reached > > > > > read > > > > > > > > > > You'll see that the echo is reached, even if cat returned an error. > > > > > > > > > > This becomes much worse when found in situations like: > > > > > > > > > > font (xxx)/some-file.pff > > > > > terminal gfxterm > > > > > > > > > > and the font wasn't loaded. > > > > > > > > Urgh! Bean committed a patch that zero'ed the error. Perhaps it was > > > > wrong? ;-) > > > > > > > > Can you try reverting it? :-) > > > > > > Actually, it was wrong before that. > > > > i think you can use the if statement to test command result. > > You mean it is intentional? I think it's a bad plan to assume user will check > for error status of each command, specially in situations like font/gfxterm. In fact, the most common error is the font command, as sometimes it can't find the font file from disk. I think you can change the grub.cfg to something like this: if font (xxx)/some-file.pff ; then # graphic mode setting else # text mode setting fi i think this behavior is consistent with sh, an error code returned from command should not cause the script to abort. -- Bean ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: grub-fstest: debug tool for filesystem driver
Hi, Some change in this version: Move grub-fstest.c_DEPENDENCIES and grub_fstest_SOURCES to common.rmk. Add new option -d for grub-fstest, it's used to set the debug environment variable. This could be the final version, if nobody objects, i will check it in. 2008-02-03 Bean <[EMAIL PROTECTED]> * Makefile.in (enable_grub_fstest): New variable. * conf/common.rmk (grub_fstest_init.lst): New rule. (grub_fstest_init.h): Likewise. (grub_fstest_init.c): Likewise. (util/grub-fstest.c_DEPENDENCIES): New variable. (grub_fstest_SOURCES): Likewise. * configure.ac (enable_grub_fstest): New test. * util/grub-fstest.c: New file. diff --git a/Makefile.in b/Makefile.in index 84b4e9c..ba07577 100644 --- a/Makefile.in +++ b/Makefile.in @@ -79,6 +79,7 @@ UNIFONT_HEX = @UNIFONT_HEX@ # Options. enable_grub_emu = @enable_grub_emu@ +enable_grub_fstest = @enable_grub_fstest@ ### General variables. diff --git a/conf/common.rmk b/conf/common.rmk index 4722ac1..ec4c663 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -61,6 +61,19 @@ grub_setup_init.c: grub_setup_init.lst $(filter-out grub_setup_init.c,$(grub_set rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@ DISTCLEANFILES += grub_setup_init.c +# For grub-fstest. +grub_fstest_init.lst: geninit.sh $(filter-out grub_fstest_init.c,$(grub_fstest_SOURCES)) + rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@ +DISTCLEANFILES += grub_fstest_init.lst + +grub_fstest_init.h: grub_fstest_init.lst $(filter-out grub_fstest_init.c,$(grub_fstest_SOURCES)) geninitheader.sh + rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@ +DISTCLEANFILES += grub_fstest_init.h + +grub_fstest_init.c: grub_fstest_init.lst $(filter-out grub_fstest_init.c,$(grub_fstest_SOURCES)) geninit.sh grub_fstest_init.h + rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@ +DISTCLEANFILES += grub_fstest_init.c + # For update-grub update-grub: util/update-grub.in config.status ./config.status --file=$@:$< @@ -331,3 +344,23 @@ gzio_mod_LDFLAGS = $(COMMON_LDFLAGS) read_mod_SOURCES = commands/read.c read_mod_CFLAGS = $(COMMON_CFLAGS) read_mod_LDFLAGS = $(COMMON_LDFLAGS) + +ifeq ($(enable_grub_fstest), yes) +bin_UTILITIES += grub-fstest +endif + +# For grub-fstest. +util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h +grub_fstest_SOURCES = util/grub-fstest.c util/hostfs.c util/misc.c \ + kern/file.c kern/device.c kern/disk.c kern/err.c kern/misc.c\ + disk/host.c disk/loopback.c normal/arg.c normal/misc.c \ + io/gzio.c commands/hexdump.c commands/blocklist.c commands/ls.c \ + \ + fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \ + fs/hfsplus.c fs/iso9660.c fs/jfs.c fs/minix.c \ + fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ + fs/ufs.c fs/xfs.c \ + \ + kern/partition.c partmap/pc.c partmap/apple.c partmap/gpt.c \ + kern/fs.c kern/env.c fs/fshelp.c disk/lvm.c disk/raid.c \ + grub_fstest_init.c diff --git a/configure b/configure index e5912e2..eced238 100755 --- a/configure +++ b/configure @@ -311,7 +311,7 @@ ac_includes_default="\ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os platform CMP YACC UNIFONT_HEX INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA AWK SET_MAKE RUBY CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP LIBLZO TARGET_CC ac_ct_TARGET_CC OBJCOPY ac_ct_OBJCOPY STRIP ac_ct_STRIP NM ac_ct_NM TARGET_CFLAGS TARGET_CPPFLAGS TARGET_LDFLAGS LIBCURSES enable_grub_emu LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os platform CMP YACC UNIFONT_HEX INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA AWK SET_MAKE RUBY CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP LIBLZO TARGET_CC ac_ct_TARGET_CC OBJCOPY ac_ct_OBJCOPY STRIP ac_ct_STRIP NM ac_ct_NM TARGET_CFLAGS TARGET_CPPFLAGS TARGET_LDFLAGS LIBCURSES enable_grub_emu enable_grub_fstest LIBOBJS LTLIBOBJS' ac_subst_files=''