From 0b4de514913ce6e5f4f29fc274a499264d6d6586 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 10 Jan 2010 23:13:53 +0100 Subject: [PATCH 01/11] 2010-01-10 Robert Millan * conf/common.rmk (bin_UTILITIES): Add `grub-bin2h'. (grub_bin2h_SOURCES): New variable. * util/bin2h.c: New file. --- ChangeLog.kernel-font | 5 ++++ conf/common.rmk | 3 ++ util/bin2h.c | 69 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 ChangeLog.kernel-font create mode 100644 util/bin2h.c diff --git a/ChangeLog.kernel-font b/ChangeLog.kernel-font new file mode 100644 index 000000000..c21696db9 --- /dev/null +++ b/ChangeLog.kernel-font @@ -0,0 +1,5 @@ +2010-01-10 Robert Millan + + * conf/common.rmk (bin_UTILITIES): Add `grub-bin2h'. + (grub_bin2h_SOURCES): New variable. + * util/bin2h.c: New file. diff --git a/conf/common.rmk b/conf/common.rmk index 3f1689370..0a67cf0cf 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -88,6 +88,9 @@ endif bin_UTILITIES += grub-mkrelpath grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c +bin_UTILITIES += grub-bin2h +grub_bin2h_SOURCES = util/bin2h.c + # For the parser. grub_script.tab.c grub_script.tab.h: script/parser.y $(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y diff --git a/util/bin2h.c b/util/bin2h.c new file mode 100644 index 000000000..e93a89032 --- /dev/null +++ b/util/bin2h.c @@ -0,0 +1,69 @@ +/* + * 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 . + */ + +#include +#include + +int +main (int argc, char *argv[]) +{ + int b, i; + char *sym; + unsigned int len; + + if (argc != 3) + { + fprintf (stderr, "Usage: %s symbol_name length\n", argv[0]); + exit (1); + } + + sym = argv[1]; + len = atoi (argv[2]); + + b = getchar (); + if (b == EOF) + goto abort; + + printf ("/* THIS CHUNK OF BYTES IS AUTOMATICALY GENERATED */\n" + "unsigned char %s[%u] =\n{\n", sym, len); + + while (1) + { + printf ("0x%02x", b); + + b = getchar (); + if (b == EOF) + goto end; + + for (i = 0; i < 16 - 1; i++) + { + printf (", 0x%02x", b); + + b = getchar (); + if (b == EOF) + goto end; + } + + printf (",\n"); + } + +end: + printf ("\n};\n"); + +abort: + exit (0); +} From f40f890a124031ae3b2b3d02c12a8622625f4484 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 11 Jan 2010 00:03:42 +0100 Subject: [PATCH 02/11] Eliminate obnoxious length parameter --- util/bin2h.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/util/bin2h.c b/util/bin2h.c index e93a89032..4139b52eb 100644 --- a/util/bin2h.c +++ b/util/bin2h.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 2008,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,23 +23,21 @@ main (int argc, char *argv[]) { int b, i; char *sym; - unsigned int len; - if (argc != 3) + if (argc != 2) { - fprintf (stderr, "Usage: %s symbol_name length\n", argv[0]); + fprintf (stderr, "Usage: %s symbol_name\n", argv[0]); exit (1); } sym = argv[1]; - len = atoi (argv[2]); b = getchar (); if (b == EOF) goto abort; printf ("/* THIS CHUNK OF BYTES IS AUTOMATICALY GENERATED */\n" - "unsigned char %s[%u] =\n{\n", sym, len); + "unsigned char %s[] =\n{\n", sym); while (1) { From 26ba5c22623cce2dd1adc94a5aad950cace26062 Mon Sep 17 00:00:00 2001 From: carles Date: Sun, 10 Jan 2010 23:33:57 +0000 Subject: [PATCH 03/11] 2010-01-10 Carles Pina i Estany * font/font.c: Include `ascii.h'. (ASCII_BITMAP_SIZE): New macro. (ascii_font_glyph): Define. (ascii_glyph_lookup): New function. (grub_font_get_string_width): Change comment. If glyph not found, use ascii_glyph_lookup. (grub_font_get_glyph_with_fallback): If glyph not available returns ascii_glyph_lookup. * util/grub-mkfont.c (file_formats): New enum. (options): Add `ascii-bitmaps' new option. (usage): Add `asii-bitmaps' new option. (write_font_ascii_bitmap): New function. (write_font): Rename to ... (write_font_p2): ... this. Remove print_glyphs call. (main): Use file_format. Implement code for ranges if ascii-bitmaps is used. Call print_glyphs. * Makefile.in (pkgdata_DATA): Add `font/ascii.h'. --- ChangeLog.kernel-font | 20 +++++++++++ Makefile.in | 8 ++++- font/font.c | 61 +++++++++++++++++++++++++++++++--- util/grub-mkfont.c | 77 +++++++++++++++++++++++++++++++++++++++---- 4 files changed, 154 insertions(+), 12 deletions(-) diff --git a/ChangeLog.kernel-font b/ChangeLog.kernel-font index c21696db9..9933c21a5 100644 --- a/ChangeLog.kernel-font +++ b/ChangeLog.kernel-font @@ -1,3 +1,23 @@ +2010-01-10 Carles Pina i Estany + + * font/font.c: Include `ascii.h'. + (ASCII_BITMAP_SIZE): New macro. + (ascii_font_glyph): Define. + (ascii_glyph_lookup): New function. + (grub_font_get_string_width): Change comment. If glyph not found, use + ascii_glyph_lookup. + (grub_font_get_glyph_with_fallback): If glyph not available returns + ascii_glyph_lookup. + * util/grub-mkfont.c (file_formats): New enum. + (options): Add `ascii-bitmaps' new option. + (usage): Add `asii-bitmaps' new option. + (write_font_ascii_bitmap): New function. + (write_font): Rename to ... + (write_font_p2): ... this. Remove print_glyphs call. + (main): Use file_format. Implement code for ranges if ascii-bitmaps is + used. Call print_glyphs. + * Makefile.in (pkgdata_DATA): Add `font/ascii.h'. + 2010-01-10 Robert Millan * conf/common.rmk (bin_UTILITIES): Add `grub-bin2h'. diff --git a/Makefile.in b/Makefile.in index 79045ee64..f30264b00 100644 --- a/Makefile.in +++ b/Makefile.in @@ -234,7 +234,7 @@ else ifeq ($(enable_grub_mkfont),yes) -pkgdata_DATA += unicode.pf2 ascii.pf2 +pkgdata_DATA += unicode.pf2 ascii.pf2 font/ascii.h # Arrows and lines are needed to draw the menu, so we always include them UNICODE_ARROWS=0x2190-0x2193 @@ -245,6 +245,12 @@ unicode.pf2: $(FONT_SOURCE) grub-mkfont ascii.pf2: $(FONT_SOURCE) grub-mkfont $(builddir)/grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) + +font/ascii.bitmaps: $(FONT_SOURCE) grub-mkfont + $(builddir)/grub-mkfont --ascii-bitmaps -o $@ $(FONT_SOURCE) + +font/ascii.h: font/ascii.bitmaps grub-bin2h + $(builddir)/grub-bin2h ascii_bitmaps 2048 < font/ascii.bitmaps > font/ascii.h endif endif diff --git a/font/font.c b/font/font.c index 44827a9a1..9819958e3 100644 --- a/font/font.c +++ b/font/font.c @@ -17,6 +17,8 @@ * along with GRUB. If not, see . */ +#define GENERATE_ASCII + #include #include #include @@ -27,6 +29,10 @@ #include #include +#ifdef GENERATE_ASCII +#include "ascii.h" +#endif + #ifndef FONT_DEBUG #define FONT_DEBUG 0 #endif @@ -43,6 +49,7 @@ struct char_index_entry #define FONT_WEIGHT_NORMAL 100 #define FONT_WEIGHT_BOLD 200 +#define ASCII_BITMAP_SIZE 16 struct grub_font { @@ -129,6 +136,48 @@ static struct grub_font null_font; /* Flag to ensure module is initialized only once. */ static grub_uint8_t font_loader_initialized; +#ifdef GENERATE_ASCII +static struct grub_font_glyph *ascii_font_glyph[0x80]; +#endif + +static struct grub_font_glyph * +ascii_glyph_lookup (grub_uint32_t code) +{ +#ifdef GENERATE_ASCII + static int ascii_failback_initialized = 0; + + if (code >= 0x80) + return unknown_glyph; + + if (ascii_failback_initialized == 0) + { + int current; + for (current = 0; current < 0x80; current++) + { + ascii_font_glyph[current] = grub_malloc(sizeof(struct grub_font_glyph) + + ASCII_BITMAP_SIZE); + + ascii_font_glyph[current]->width = 8; + ascii_font_glyph[current]->height = 16; + ascii_font_glyph[current]->offset_x = 0; + ascii_font_glyph[current]->offset_y = -2; + ascii_font_glyph[current]->device_width = 8; + + grub_memcpy (ascii_font_glyph[current]->bitmap, + &ascii_bitmaps[(0x7f - current) * ASCII_BITMAP_SIZE], + ASCII_BITMAP_SIZE); + } + + ascii_failback_initialized = 1; + } + + return ascii_font_glyph[code]; +#else + (void) code; + return unknown_glyph; +#endif +} + void grub_font_loader_init (void) { @@ -865,15 +914,17 @@ grub_font_get_string_width (grub_font_t font, const char *str) } /* Get the glyph for FONT corresponding to the Unicode code point CODE. - Returns a pointer to an glyph indicating there is no glyph available - if CODE does not exist in the font. The glyphs are cached once loaded. */ + Returns the ASCII glyph for the code if no other fonts are available. + The glyphs are cached once loaded. */ struct grub_font_glyph * grub_font_get_glyph (grub_font_t font, grub_uint32_t code) { struct grub_font_glyph *glyph; glyph = grub_font_get_glyph_internal (font, code); if (glyph == 0) - glyph = unknown_glyph; + { + glyph = ascii_glyph_lookup (code); + } return glyph; } @@ -968,8 +1019,8 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code) if (best_glyph) return best_glyph; else - /* Glyph not available in any font. Return unknown glyph. */ - return unknown_glyph; + /* Glyph not available in any font. Return ASCII failback. */ + return ascii_glyph_lookup (code); } diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index 3d1c6faac..e8e712f2c 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -49,6 +49,12 @@ struct grub_glyph_info grub_uint8_t bitmap[0]; }; +enum file_formats +{ + PF2, + ASCII_BITMAPS +}; + #define GRUB_FONT_FLAG_BOLD 1 #define GRUB_FONT_FLAG_NOBITMAP 2 #define GRUB_FONT_FLAG_NOHINTING 4 @@ -87,6 +93,7 @@ static struct option options[] = {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, {"verbose", no_argument, 0, 'v'}, + {"ascii-bitmaps", no_argument, 0, 0x102}, {0, 0, 0, 0} }; @@ -102,6 +109,7 @@ usage (int status) Usage: %s [OPTIONS] FONT_FILES\n\ \nOptions:\n\ -o, --output=FILE_NAME set output file name\n\ + --ascii-bitmaps save only the ASCII bitmaps\n\ -i, --index=N set face index\n\ -r, --range=A-B[,C-D] set font range\n\ -n, --name=S set font family name\n\ @@ -337,7 +345,39 @@ print_glyphs (struct grub_font_info *font_info) } void -write_font (struct grub_font_info *font_info, char *output_file) +write_font_ascii_bitmap (struct grub_font_info *font_info, char *output_file) +{ + FILE *file; + struct grub_glyph_info *glyph; + int num; + + file = fopen (output_file, "wb"); + if (! file) + grub_util_error ("Can\'t write to file %s.", output_file); + + int correct_size; + for (glyph = font_info->glyph, num = 0; glyph; glyph = glyph->next, num++) + { + correct_size = 1; + if (glyph->width != 8 || glyph->height != 16) + { + // printf ("Width or height from glyph U+%04x not supported, skipping.\n", glyph->char_code); + correct_size = 0; + } + int row; + for (row = 0; row < glyph->height; row++) + { + if (correct_size) + fwrite (&glyph->bitmap[row], sizeof(glyph->bitmap[row]), 1, file); + else + fwrite (&correct_size, 1, 1, file); + } + } + fclose (file); +} + +void +write_font_pf2 (struct grub_font_info *font_info, char *output_file) { FILE *file; grub_uint32_t leng, data; @@ -473,9 +513,6 @@ write_font (struct grub_font_info *font_info, char *output_file) grub_util_write_image ((char *) &cur->bitmap[0], cur->bitmap_size, file); } - if (font_verbosity > 1) - print_glyphs (font_info); - fclose (file); } @@ -487,6 +524,7 @@ main (int argc, char *argv[]) int font_index = 0; int font_size = 0; char *output_file = NULL; + enum file_formats file_format = PF2; memset (&font_info, 0, sizeof (font_info)); @@ -552,7 +590,7 @@ main (int argc, char *argv[]) font_info.ranges = xrealloc (font_info.ranges, (font_info.num_range + GRUB_FONT_RANGE_BLOCK) * - sizeof (int) * 2); + sizeof (grub_uint32_t) * 2); font_info.ranges[font_info.num_range * 2] = a; font_info.ranges[font_info.num_range * 2 + 1] = b; @@ -591,12 +629,33 @@ main (int argc, char *argv[]) font_verbosity++; break; + case 0x102: + file_format = ASCII_BITMAPS; + break; + default: usage (1); break; } } + if (file_format == ASCII_BITMAPS && font_info.num_range > 0) + { + grub_util_error ("Option --ascii-bitmaps doesn't accept ranges (use ASCII)."); + return 1; + } + + else if (file_format == ASCII_BITMAPS) + { + font_info.ranges = xrealloc (font_info.ranges, + GRUB_FONT_RANGE_BLOCK * + sizeof (grub_uint32_t) * 2); + + font_info.ranges[0] = (grub_uint32_t) 0x00; + font_info.ranges[1] = (grub_uint32_t) 0x7f; + font_info.num_range = 1; + } + if (! output_file) grub_util_error ("No output file is specified."); @@ -638,7 +697,13 @@ main (int argc, char *argv[]) FT_Done_FreeType (ft_lib); - write_font (&font_info, output_file); + if (file_format == PF2) + write_font_pf2 (&font_info, output_file); + else if (file_format == ASCII_BITMAPS) + write_font_ascii_bitmap (&font_info, output_file); + + if (font_verbosity > 1) + print_glyphs (&font_info); return 0; } From d1fb0f65de960a99c3c1d918d1fb69167456b4d8 Mon Sep 17 00:00:00 2001 From: carles Date: Mon, 11 Jan 2010 00:10:38 +0000 Subject: [PATCH 04/11] 2010-01-10 Carles Pina i Estany * font/font.c: Update copyright years. * util/grub-mkfont.c (write_font_ascii_bitmap): Change comment format. --- ChangeLog.kernel-font | 5 +++++ font/font.c | 2 +- util/grub-mkfont.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog.kernel-font b/ChangeLog.kernel-font index 9933c21a5..e7ca2a374 100644 --- a/ChangeLog.kernel-font +++ b/ChangeLog.kernel-font @@ -1,3 +1,8 @@ +2010-01-10 Carles Pina i Estany + + * font/font.c: Update copyright years. + * util/grub-mkfont.c (write_font_ascii_bitmap): Change comment format. + 2010-01-10 Carles Pina i Estany * font/font.c: Include `ascii.h'. diff --git a/font/font.c b/font/font.c index 9819958e3..a00aef94f 100644 --- a/font/font.c +++ b/font/font.c @@ -1,7 +1,7 @@ /* font.c - Font API and font file loader. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index e8e712f2c..3dd0bafdd 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -361,7 +361,7 @@ write_font_ascii_bitmap (struct grub_font_info *font_info, char *output_file) correct_size = 1; if (glyph->width != 8 || glyph->height != 16) { - // printf ("Width or height from glyph U+%04x not supported, skipping.\n", glyph->char_code); + /* printf ("Width or height from glyph U+%04x not supported, skipping.\n", glyph->char_code); */ correct_size = 0; } int row; From d0230c211973d781cb1fe9eefa6157290f09916e Mon Sep 17 00:00:00 2001 From: carles Date: Mon, 11 Jan 2010 20:43:11 +0000 Subject: [PATCH 05/11] 2010-01-11 Carles Pina i Estany * font/font.c (GENERATE_ASCII): Change the name to USE_ASCII_FAILBACK. By default: disabled. * Makefile.in (font/ascii.h): Remove the non-needed grub/bin2h size parameter. --- ChangeLog.kernel-font | 7 +++++++ Makefile.in | 2 +- font/font.c | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog.kernel-font b/ChangeLog.kernel-font index e7ca2a374..36c3b695b 100644 --- a/ChangeLog.kernel-font +++ b/ChangeLog.kernel-font @@ -1,3 +1,10 @@ +2010-01-11 Carles Pina i Estany + + * font/font.c (GENERATE_ASCII): Change the name to USE_ASCII_FAILBACK. + By default: disabled. + * Makefile.in (font/ascii.h): Remove the non-needed grub/bin2h size + parameter. + 2010-01-10 Carles Pina i Estany * font/font.c: Update copyright years. diff --git a/Makefile.in b/Makefile.in index f30264b00..ff59c4efd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -250,7 +250,7 @@ font/ascii.bitmaps: $(FONT_SOURCE) grub-mkfont $(builddir)/grub-mkfont --ascii-bitmaps -o $@ $(FONT_SOURCE) font/ascii.h: font/ascii.bitmaps grub-bin2h - $(builddir)/grub-bin2h ascii_bitmaps 2048 < font/ascii.bitmaps > font/ascii.h + $(builddir)/grub-bin2h ascii_bitmaps < font/ascii.bitmaps > font/ascii.h endif endif diff --git a/font/font.c b/font/font.c index a00aef94f..7aef1b163 100644 --- a/font/font.c +++ b/font/font.c @@ -17,7 +17,7 @@ * along with GRUB. If not, see . */ -#define GENERATE_ASCII +//#define USE_ASCII_FAILBACK 0 #include #include @@ -29,7 +29,7 @@ #include #include -#ifdef GENERATE_ASCII +#ifdef USE_ASCII_FAILBACK #include "ascii.h" #endif @@ -136,14 +136,14 @@ static struct grub_font null_font; /* Flag to ensure module is initialized only once. */ static grub_uint8_t font_loader_initialized; -#ifdef GENERATE_ASCII +#ifdef USE_ASCII_FAILBACK static struct grub_font_glyph *ascii_font_glyph[0x80]; #endif static struct grub_font_glyph * ascii_glyph_lookup (grub_uint32_t code) { -#ifdef GENERATE_ASCII +#ifdef USE_ASCII_FAILBACK static int ascii_failback_initialized = 0; if (code >= 0x80) From bd719e5a73757956671a640c5897a842a739d773 Mon Sep 17 00:00:00 2001 From: carles Date: Tue, 12 Jan 2010 20:37:45 +0000 Subject: [PATCH 06/11] 2010-01-12 Carles Pina i Estany * Makefile.in (DUSE_ASCII_FAILBACK): New macro. --- ChangeLog.kernel-font | 4 ++++ Makefile.in | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog.kernel-font b/ChangeLog.kernel-font index 36c3b695b..69e3dafe8 100644 --- a/ChangeLog.kernel-font +++ b/ChangeLog.kernel-font @@ -1,3 +1,7 @@ +2010-01-12 Carles Pina i Estany + + * Makefile.in (DUSE_ASCII_FAILBACK): New macro. + 2010-01-11 Carles Pina i Estany * font/font.c (GENERATE_ASCII): Change the name to USE_ASCII_FAILBACK. diff --git a/Makefile.in b/Makefile.in index ff59c4efd..c551a0d79 100644 --- a/Makefile.in +++ b/Makefile.in @@ -251,6 +251,8 @@ font/ascii.bitmaps: $(FONT_SOURCE) grub-mkfont font/ascii.h: font/ascii.bitmaps grub-bin2h $(builddir)/grub-bin2h ascii_bitmaps < font/ascii.bitmaps > font/ascii.h + +TARGET_CFLAGS += -DUSE_ASCII_FAILBACK=1 endif endif From 885d1a8d9090fe19e05dddea39ac5e689e75a7ec Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 14 Jan 2010 20:33:10 +0000 Subject: [PATCH 07/11] Support --help and --version in grub-bin2h. --- ChangeLog.kernel-font | 2 +- conf/common.rmk | 2 +- util/bin2h.c | 66 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/ChangeLog.kernel-font b/ChangeLog.kernel-font index 69e3dafe8..3842f9b51 100644 --- a/ChangeLog.kernel-font +++ b/ChangeLog.kernel-font @@ -34,7 +34,7 @@ used. Call print_glyphs. * Makefile.in (pkgdata_DATA): Add `font/ascii.h'. -2010-01-10 Robert Millan +2010-01-14 Robert Millan * conf/common.rmk (bin_UTILITIES): Add `grub-bin2h'. (grub_bin2h_SOURCES): New variable. diff --git a/conf/common.rmk b/conf/common.rmk index 0a67cf0cf..ee503f8b6 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -89,7 +89,7 @@ bin_UTILITIES += grub-mkrelpath grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c bin_UTILITIES += grub-bin2h -grub_bin2h_SOURCES = util/bin2h.c +grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c # For the parser. grub_script.tab.c grub_script.tab.h: script/parser.y diff --git a/util/bin2h.c b/util/bin2h.c index 4139b52eb..5ce47f086 100644 --- a/util/bin2h.c +++ b/util/bin2h.c @@ -15,22 +15,80 @@ * along with GRUB. If not, see . */ +#include #include #include +#define _GNU_SOURCE 1 +#include + +#include "progname.h" + +static struct option options[] = + { + {"help", no_argument, 0, 'h' }, + {"version", no_argument, 0, 'V' }, + {0, 0, 0, 0 } + }; + +static void +usage (int status) +{ + if (status) + fprintf (stderr, + "Try ``%s --help'' for more information.\n", program_name); + else + printf ("\ +Usage: %s [OPTIONS] SYMBOL-NAME\n\ +\n\ + -h, --help display this message and exit\n\ + -V, --version print version information and exit\n\ +\n\ +Report bugs to <%s>.\n\ +", program_name, PACKAGE_BUGREPORT); + + exit (status); +} + int main (int argc, char *argv[]) { int b, i; char *sym; - if (argc != 2) + set_program_name (argv[0]); + + /* Check for options. */ + while (1) { - fprintf (stderr, "Usage: %s symbol_name\n", argv[0]); - exit (1); + int c = getopt_long (argc, argv, "snm:r:hVv", options, 0); + + if (c == -1) + break; + else + switch (c) + { + case 'h': + usage (0); + break; + + case 'V': + printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION); + return 0; + + default: + usage (1); + break; + } } - sym = argv[1]; + if (optind >= argc) + usage (1); + + if (optind + 1 != argc) + usage (1); + + sym = argv[optind]; b = getchar (); if (b == EOF) From b4f58b4aec8455d5ea0162e7b1ff163c944ab0cf Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Thu, 14 Jan 2010 22:17:05 +0100 Subject: [PATCH 08/11] Fix $srcdir != $builddir build by moving ascii.h to top dir. --- ChangeLog.kernel-font | 4 ++-- Makefile.in | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ChangeLog.kernel-font b/ChangeLog.kernel-font index 3842f9b51..576c85904 100644 --- a/ChangeLog.kernel-font +++ b/ChangeLog.kernel-font @@ -6,7 +6,7 @@ * font/font.c (GENERATE_ASCII): Change the name to USE_ASCII_FAILBACK. By default: disabled. - * Makefile.in (font/ascii.h): Remove the non-needed grub/bin2h size + * Makefile.in (ascii.h): Remove the non-needed grub/bin2h size parameter. 2010-01-10 Carles Pina i Estany @@ -32,7 +32,7 @@ (write_font_p2): ... this. Remove print_glyphs call. (main): Use file_format. Implement code for ranges if ascii-bitmaps is used. Call print_glyphs. - * Makefile.in (pkgdata_DATA): Add `font/ascii.h'. + * Makefile.in (pkgdata_DATA): Add `ascii.h'. 2010-01-14 Robert Millan diff --git a/Makefile.in b/Makefile.in index c551a0d79..a3084c69a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -234,7 +234,7 @@ else ifeq ($(enable_grub_mkfont),yes) -pkgdata_DATA += unicode.pf2 ascii.pf2 font/ascii.h +pkgdata_DATA += unicode.pf2 ascii.pf2 ascii.h # Arrows and lines are needed to draw the menu, so we always include them UNICODE_ARROWS=0x2190-0x2193 @@ -246,11 +246,11 @@ unicode.pf2: $(FONT_SOURCE) grub-mkfont ascii.pf2: $(FONT_SOURCE) grub-mkfont $(builddir)/grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) -font/ascii.bitmaps: $(FONT_SOURCE) grub-mkfont +ascii.bitmaps: $(FONT_SOURCE) grub-mkfont $(builddir)/grub-mkfont --ascii-bitmaps -o $@ $(FONT_SOURCE) -font/ascii.h: font/ascii.bitmaps grub-bin2h - $(builddir)/grub-bin2h ascii_bitmaps < font/ascii.bitmaps > font/ascii.h +ascii.h: ascii.bitmaps grub-bin2h + $(builddir)/grub-bin2h ascii_bitmaps < $< > $@ TARGET_CFLAGS += -DUSE_ASCII_FAILBACK=1 endif From 41f683d45610aaa7e9da629a5388c386b7f2dd31 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 18 Jan 2010 20:20:34 +0000 Subject: [PATCH 09/11] 2010-01-18 Robert Millan * include/grub/term.h (grub_term_register_input, grub_term_register_output): Check return of terminal init() routines, and abort if errors are raised. * commands/terminal.c: Update copyright year. --- ChangeLog.kernel-font | 7 +++++++ conf/common.rmk | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog.kernel-font b/ChangeLog.kernel-font index 576c85904..73f8a895e 100644 --- a/ChangeLog.kernel-font +++ b/ChangeLog.kernel-font @@ -1,3 +1,10 @@ +2010-01-18 Robert Millan + + Fix parallel builds. + + * conf/common.rmk (font/font.c_DEPENDENCIES): New variable (makes + font.c depend on ascii.h). + 2010-01-12 Carles Pina i Estany * Makefile.in (DUSE_ASCII_FAILBACK): New macro. diff --git a/conf/common.rmk b/conf/common.rmk index a83bd0fca..956ed8ec3 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -600,7 +600,7 @@ sh_mod_LDFLAGS = $(COMMON_LDFLAGS) # Common Video Subsystem specific modules. pkglib_MODULES += video.mod videotest.mod bitmap.mod tga.mod jpeg.mod \ - png.mod font.mod gfxterm.mod video_fb.mod + png.mod gfxterm.mod video_fb.mod # For video.mod. video_mod_SOURCES = video/video.c @@ -637,7 +637,8 @@ png_mod_SOURCES = video/readers/png.c png_mod_CFLAGS = $(COMMON_CFLAGS) png_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For font.mod. +pkglib_MODULES += font.mod +font/font.c_DEPENDENCIES = ascii.h font_mod_SOURCES = font/font_cmd.c font/font.c font_mod_CFLAGS = $(COMMON_CFLAGS) font_mod_LDFLAGS = $(COMMON_LDFLAGS) From 915fc1b8bfa683a1cb456d4c4e38806d2631f4ed Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 20 Jan 2010 01:08:46 +0100 Subject: [PATCH 10/11] 2010-01-20 Vladimir Serbinenko * include/multiboot.h: Resynced with spec. * include/multiboot2.h: Likewise. * loader/i386/multiboot_mbi.c (grub_fill_multiboot_mmap): Handle GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE and GRUB_MACHINE_MEMORY_NVS. --- ChangeLog | 7 +++++++ include/multiboot.h | 2 ++ include/multiboot2.h | 2 ++ loader/i386/multiboot_mbi.c | 12 ++++++++++++ 4 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index 40984c187..9097153e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-01-20 Vladimir Serbinenko + + * include/multiboot.h: Resynced with spec. + * include/multiboot2.h: Likewise. + * loader/i386/multiboot_mbi.c (grub_fill_multiboot_mmap): Handle + GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE and GRUB_MACHINE_MEMORY_NVS. + 2010-01-18 Robert Millan * include/grub/term.h (grub_term_register_input, diff --git a/include/multiboot.h b/include/multiboot.h index 57c154c98..c529c5c5f 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -233,6 +233,8 @@ struct multiboot_mmap_entry multiboot_uint64_t len; #define MULTIBOOT_MEMORY_AVAILABLE 1 #define MULTIBOOT_MEMORY_RESERVED 2 +#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 +#define MULTIBOOT_MEMORY_NVS 4 multiboot_uint32_t type; } __attribute__((packed)); typedef struct multiboot_mmap_entry multiboot_memory_map_t; diff --git a/include/multiboot2.h b/include/multiboot2.h index a241a70ad..1b649d514 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -233,6 +233,8 @@ struct multiboot_mmap_entry multiboot_uint64_t len; #define MULTIBOOT_MEMORY_AVAILABLE 1 #define MULTIBOOT_MEMORY_RESERVED 2 +#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 +#define MULTIBOOT_MEMORY_NVS 4 multiboot_uint32_t type; } __attribute__((packed)); typedef struct multiboot_mmap_entry multiboot_memory_map_t; diff --git a/loader/i386/multiboot_mbi.c b/loader/i386/multiboot_mbi.c index 58bb68323..5154a64df 100644 --- a/loader/i386/multiboot_mbi.c +++ b/loader/i386/multiboot_mbi.c @@ -110,6 +110,18 @@ grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry) case GRUB_MACHINE_MEMORY_AVAILABLE: mmap_entry->type = MULTIBOOT_MEMORY_AVAILABLE; break; + +#ifdef GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE + case GRUB_MACHINE_MEMORY_ACPI_RECLAIMABLE: + mmap_entry->type = MULTIBOOT_MEMORY_ACPI_RECLAIMABLE; + break; +#endif + +#ifdef GRUB_MACHINE_MEMORY_NVS + case GRUB_MACHINE_MEMORY_NVS: + mmap_entry->type = MULTIBOOT_MEMORY_NVS; + break; +#endif default: mmap_entry->type = MULTIBOOT_MEMORY_RESERVED; From 7a988ee134edafbd460fc455798b02217bb5bd71 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Wed, 20 Jan 2010 00:34:57 +0000 Subject: [PATCH 11/11] Remove a debug comment. --- font/font.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/font/font.c b/font/font.c index 7aef1b163..9f8e0f5c6 100644 --- a/font/font.c +++ b/font/font.c @@ -17,8 +17,6 @@ * along with GRUB. If not, see . */ -//#define USE_ASCII_FAILBACK 0 - #include #include #include