iPXE
efi_autoboot.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
22 */
23
24FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25FILE_SECBOOT ( PERMITTED );
26
27#include <string.h>
28#include <errno.h>
29#include <ipxe/if_ether.h>
30#include <ipxe/vlan.h>
31#include <ipxe/efi/efi.h>
32#include <ipxe/efi/efi_path.h>
35#include <usr/autoboot.h>
36
37/** @file
38 *
39 * EFI autoboot device
40 *
41 */
42
43/**
44 * Identify autoboot device
45 *
46 * @v device Device handle
47 * @v path Device path
48 * @ret rc Return status code
49 */
54 unsigned int vlan;
55 int rc;
56
57 /* Look for an SNP instance on the image's device handle */
59 &snp ) ) != 0 ) {
60 DBGC ( device, "EFI %s has no SNP instance: %s\n",
62 return rc;
63 }
64
65 /* Record autoboot device */
66 mode = snp->Mode;
67 vlan = efi_path_vlan ( path );
68 set_autoboot_ll_addr ( &mode->CurrentAddress, mode->HwAddressSize,
69 vlan );
70 DBGC ( device, "EFI %s found autoboot link-layer address:\n",
72 DBGC_HDA ( device, 0, &mode->CurrentAddress, mode->HwAddressSize );
73 if ( vlan ) {
74 DBGC ( device, "EFI %s found autoboot VLAN %d\n",
75 efi_handle_name ( device ), vlan );
76 }
77
78 /* Configure automatic VLAN device, if applicable */
79 if ( vlan && ( mode->HwAddressSize == ETH_ALEN ) ) {
80 vlan_auto ( &mode->CurrentAddress, vlan );
81 DBGC ( device, "EFI %s configured automatic VLAN %d\n",
82 efi_handle_name ( device ), vlan );
83 }
84
85 return 0;
86}
The EFI_SIMPLE_NETWORK_PROTOCOL provides services to initialize a network interface,...
struct _EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK_PROTOCOL
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
void set_autoboot_ll_addr(const void *ll_addr, size_t len, unsigned int vlan)
Identify autoboot device by link-layer address.
Definition autoboot.c:521
Automatic booting.
int efi_set_autoboot_ll_addr(EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path)
Identify autoboot device.
EFI autoboot device.
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition efi_debug.c:652
EFI_GUID efi_simple_network_protocol_guid
Simple network protocol GUID.
Definition efi_guid.c:341
unsigned int efi_path_vlan(EFI_DEVICE_PATH_PROTOCOL *path)
Get VLAN tag from device path.
Definition efi_path.c:237
EFI device paths.
uint16_t mode
Acceleration mode.
Definition ena.h:15
Error codes.
#define DBGC(...)
Definition compiler.h:505
#define DBGC_HDA(...)
Definition compiler.h:506
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define ETH_ALEN
Definition if_ether.h:9
EFI API.
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition efi.h:444
#define EFI_HANDLE
Definition efi.h:53
String functions.
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition DevicePath.h:46
EFI_SIMPLE_NETWORK_MODE * Mode
Pointer to the EFI_SIMPLE_NETWORK_MODE data for the device.
A hardware device.
Definition device.h:77
void vlan_auto(const void *ll_addr, unsigned int tag)
Configure automatic VLAN device.
Definition vlan.c:463
Virtual LANs.