From 93c120754a537a2f060b8e20eab620e714309b82 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 28 Oct 2013 15:53:39 +0100 Subject: [PATCH] * grub-core/loader/multiboot_mbi2.c: Implement network tag. --- ChangeLog | 4 ++++ grub-core/loader/multiboot_mbi2.c | 34 ++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 344e3c09d..93fe8be25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-10-28 Vladimir Serbinenko + + * grub-core/loader/multiboot_mbi2.c: Implement network tag. + 2013-10-28 Vladimir Serbinenko * grub-core/loader/multiboot_mbi2.c: Add EFI memory map to the list diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 09452cce2..6a6be77e2 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2010,2011,2012,2013 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 @@ -34,6 +34,7 @@ #include #include #include +#include #if defined (GRUB_MACHINE_EFI) #include @@ -156,6 +157,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) case MULTIBOOT_TAG_TYPE_EFI64: case MULTIBOOT_TAG_TYPE_ACPI_OLD: case MULTIBOOT_TAG_TYPE_ACPI_NEW: + case MULTIBOOT_TAG_TYPE_NETWORK: case MULTIBOOT_TAG_TYPE_EFI_MMAP: break; @@ -338,6 +340,19 @@ find_efi_mmap_size (void) } #endif +static grub_size_t +net_size (void) +{ + struct grub_net_network_level_interface *net; + grub_size_t ret = 0; + + FOR_NET_NETWORK_LEVEL_INTERFACES(net) + if (net->dhcp_ack) + ret += ALIGN_UP (sizeof (struct multiboot_tag_network) + net->dhcp_acklen, + MULTIBOOT_TAG_ALIGN); + return ret; +} + static grub_size_t grub_multiboot_get_mbi_size (void) { @@ -365,6 +380,7 @@ grub_multiboot_get_mbi_size (void) + ALIGN_UP (sizeof (struct multiboot_tag_old_acpi) + sizeof (struct grub_acpi_rsdp_v10), MULTIBOOT_TAG_ALIGN) + acpiv2_size () + + net_size () #ifdef GRUB_MACHINE_EFI + ALIGN_UP (sizeof (struct multiboot_tag_efi_mmap) + efi_mmap_size, MULTIBOOT_TAG_ALIGN) @@ -736,6 +752,22 @@ grub_multiboot_make_mbi (grub_uint32_t *target) / sizeof (grub_properly_aligned_t); } + { + struct grub_net_network_level_interface *net; + + FOR_NET_NETWORK_LEVEL_INTERFACES(net) + if (net->dhcp_ack) + { + struct multiboot_tag_network *tag + = (struct multiboot_tag_network *) ptrorig; + tag->type = MULTIBOOT_TAG_TYPE_NETWORK; + tag->size = sizeof (struct multiboot_tag_network) + net->dhcp_acklen; + grub_memcpy (tag->dhcpack, net->dhcp_ack, net->dhcp_acklen); + ptrorig += ALIGN_UP (tag->size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } + } + if (bootdev_set) { struct multiboot_tag_bootdev *tag