diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/fbcon.c | 72 | ||||
-rw-r--r-- | src/core/menu.c | 13 | ||||
-rw-r--r-- | src/core/settings.c | 47 |
3 files changed, 99 insertions, 33 deletions
diff --git a/src/core/fbcon.c b/src/core/fbcon.c index ff3132ac..056b164c 100644 --- a/src/core/fbcon.c +++ b/src/core/fbcon.c @@ -525,6 +525,9 @@ static int fbcon_picture_init ( struct fbcon *fbcon, /* Allocate buffer */ len = ( pixel->height * pixel->stride ); + if ( picture->start ) { + ufree( picture->start ); + } picture->start = umalloc ( len ); if ( ! picture->start ) { DBGC ( fbcon, "FBCON %p could not allocate %zd bytes for " @@ -600,21 +603,23 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, unsigned int bottom; int rc; - /* Initialise data structure */ - memset ( fbcon, 0, sizeof ( *fbcon ) ); - fbcon->start = start; - fbcon->pixel = pixel; - assert ( pixel->len <= sizeof ( uint32_t ) ); - fbcon->map = map; - fbcon->font = font; - fbcon->ctx.handlers = fbcon_ansiesc_handlers; - fbcon->show_cursor = 1; - - /* Derive overall length */ - fbcon->len = ( pixel->height * pixel->stride ); - DBGC ( fbcon, "FBCON %p at [%08lx,%08lx)\n", fbcon, - user_to_phys ( fbcon->start, 0 ), - user_to_phys ( fbcon->start, fbcon->len ) ); + if ( ! config->lazy_update ) { + /* Initialise data structure */ + memset ( fbcon, 0, sizeof ( *fbcon ) ); + fbcon->start = start; + fbcon->pixel = pixel; + assert ( pixel->len <= sizeof ( uint32_t ) ); + fbcon->map = map; + fbcon->font = font; + fbcon->ctx.handlers = fbcon_ansiesc_handlers; + fbcon->show_cursor = 1; + + /* Derive overall length */ + fbcon->len = ( pixel->height * pixel->stride ); + DBGC ( fbcon, "FBCON %p at [%08lx,%08lx)\n", fbcon, + user_to_phys ( fbcon->start, 0 ), + user_to_phys ( fbcon->start, fbcon->len ) ); + } /* Calculate margin. If the actual screen size is larger than * the requested screen size, then update the margins so that @@ -669,27 +674,32 @@ int fbcon_init ( struct fbcon *fbcon, userptr_t start, fbcon->margin.top, ( fbcon->pixel->height - fbcon->margin.bottom ) ); - /* Set default colours */ - fbcon_set_default_foreground ( fbcon ); - fbcon_set_default_background ( fbcon ); + if ( ! config->lazy_update ) { + /* Set default colours */ + fbcon_set_default_foreground ( fbcon ); + fbcon_set_default_background ( fbcon ); + + /* Allocate and initialise stored character array */ + fbcon->text.start = umalloc ( fbcon->character.width * + fbcon->character.height * + sizeof ( struct fbcon_text_cell ) ); + if ( ! fbcon->text.start ) { + rc = -ENOMEM; + goto err_text; + } + fbcon_clear ( fbcon, 0 ); - /* Allocate and initialise stored character array */ - fbcon->text.start = umalloc ( fbcon->character.width * - fbcon->character.height * - sizeof ( struct fbcon_text_cell ) ); - if ( ! fbcon->text.start ) { - rc = -ENOMEM; - goto err_text; + /* Set framebuffer to all black (including margins) */ + memset_user ( fbcon->start, 0, 0, fbcon->len ); + } else { + fbcon_clear ( fbcon, 0 ); } - fbcon_clear ( fbcon, 0 ); - - /* Set framebuffer to all black (including margins) */ - memset_user ( fbcon->start, 0, 0, fbcon->len ); /* Generate pixel buffer from background image, if applicable */ if ( config->pixbuf && - ( ( rc = fbcon_picture_init ( fbcon, config->pixbuf ) ) != 0 ) ) - goto err_picture; + ( ( rc = fbcon_picture_init ( fbcon, config->pixbuf ) ) != 0 ) && + ( ! config->lazy_update ) ) + goto err_picture; /* Keep going w/o background in lazy_update mode */ /* Draw background picture (including margins), if applicable */ if ( fbcon->picture.start ) { diff --git a/src/core/menu.c b/src/core/menu.c index ab5b0c7f..abad5999 100644 --- a/src/core/menu.c +++ b/src/core/menu.c @@ -80,6 +80,7 @@ struct menu * create_menu ( const char *name, const char *title ) { strcpy ( title_copy, title ); menu->title = title_copy; INIT_LIST_HEAD ( &menu->items ); + INIT_LIST_HEAD ( &menu->hidden_items ); /* Add to list of menus */ list_add_tail ( &menu->list, &menus ); @@ -102,7 +103,7 @@ struct menu * create_menu ( const char *name, const char *title ) { */ struct menu_item * add_menu_item ( struct menu *menu, const char *label, const char *text, int shortcut, - int is_default ) { + int is_default, int is_hidden ) { size_t label_len; size_t text_len; size_t len; @@ -135,7 +136,11 @@ struct menu_item * add_menu_item ( struct menu *menu, const char *label, item->is_default = is_default; /* Add to list of items */ - list_add_tail ( &item->list, &menu->items ); + if ( is_hidden ) { + list_add_tail ( &item->list, &menu->hidden_items ); + } else { + list_add_tail ( &item->list, &menu->items ); + } return item; } @@ -157,6 +162,10 @@ void destroy_menu ( struct menu *menu ) { list_del ( &item->list ); free ( item ); } + list_for_each_entry_safe ( item, tmp, &menu->hidden_items, list ) { + list_del ( &item->list ); + free ( item ); + } /* Free menu */ free ( menu ); diff --git a/src/core/settings.c b/src/core/settings.c index 9fbf753a..aa4bbae2 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -45,6 +45,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <ipxe/init.h> #include <ipxe/version.h> #include <ipxe/settings.h> +#include <ipxe/md5.h> /** @file * @@ -2133,6 +2134,46 @@ static int format_hex_raw_setting ( const struct setting_type *type __unused, return hex_encode ( 0, raw, raw_len, buf, len ); } +/** + * Parsing md5 setting doesn't make any sense + * + * @v type Setting type + * @v value Formatted setting value + * @v buf Buffer to contain raw value + * @v len Length of buffer + * @v size Integer size, in bytes + * @ret len Length of raw value, or negative error + */ +static int parse_md5_setting ( const struct setting_type *type __unused, + const char *value __unused, void *buf __unused, + size_t len __unused ) { + return -ENOTSUP; +} + +/** + * Format setting value as md5 hash (hex representation) + * + * @v type Setting type + * @v raw Raw setting value + * @v raw_len Length of raw setting value + * @v buf Buffer to contain formatted value + * @v len Length of buffer + * @ret len Length of formatted value, or negative error + */ +static int format_md5_setting ( const struct setting_type *type __unused, + const void *raw, size_t raw_len, + char *buf, size_t len ) { + struct md5_context ctx; + uint8_t digest[MD5_DIGEST_SIZE]; + + if ( len < MD5_DIGEST_SIZE * 2 ) + return MD5_DIGEST_SIZE * 2; + digest_init ( &md5_algorithm, &ctx ); + digest_update ( &md5_algorithm, &ctx, raw, raw_len ); + digest_final ( &md5_algorithm, &ctx, digest ); + return hex_encode ( 0, digest, sizeof(digest), buf, len ); +} + /** A hex-string setting (colon-delimited) */ const struct setting_type setting_type_hex __setting_type = { .name = "hex", @@ -2154,6 +2195,12 @@ const struct setting_type setting_type_hexraw __setting_type = { .format = format_hex_raw_setting, }; +const struct setting_type setting_type_md5 __setting_type = { + .name = "md5", + .parse = parse_md5_setting, + .format = format_md5_setting, +}; + /** * Parse Base64-encoded setting value * |