X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=glue_netfs.c;h=eebfecc103ee692954ea8b48f77ca015f8c2346c;hb=35066b3244e795da02400086f85660e9b0b9e490;hp=5de36298256574621cb70f45bb58b360c8ac74fa;hpb=8e0034665aa8483b27191c723608575536d01303;p=debian%2Felilo diff --git a/glue_netfs.c b/glue_netfs.c index 5de3629..eebfecc 100644 --- a/glue_netfs.c +++ b/glue_netfs.c @@ -1,6 +1,10 @@ /* * Copyright (C) 2001-2003 Hewlett-Packard Co. * Contributed by Stephane Eranian + * Copyright (C) 2006-2009 Intel Corporation + * Contributed by Fenghua Yu + * Contributed by Bibo Mao + * Contributed by Chandramouli Narayanan * * This file is part of the ELILO, the EFI Linux boot loader. * @@ -60,6 +64,19 @@ static CHAR16 netfs_default_path[FILENAME_MAXLEN]; static CHAR16 *hexa=L"0123456789ABCDEF"; +static VOID +convert_mac2hex(UINT8 *hw_addr,INTN l, CHAR16 *str) +{ + UINTN i; + + for (i=0 ; i < l; i++) { + str[3*i] = hexa[(hw_addr[i] & 0xf0)>>4]; + str[3*i+1] = hexa[hw_addr[i] & 0x0f]; + str[3*i+2] = ':'; + } + str[3*l-1]='\0'; +} + static VOID convert_ip2hex(UINT8 *ip, INTN l, CHAR16 *str) { @@ -149,6 +166,8 @@ netfs_setdefaults(VOID *intf, config_file_t *config, CHAR16 *kname, UINTN maxlen set_var(VAR_NETFS_DOMAINAME, info.domainame); if (info.using_pxe) { + DBG_PRT((L"netfs_setdefaults: using_pxe")); + status = netfs->netfs_query_layer(netfs, 0, NETFS_CONFIG_LAYER, maxlen, config[0].fname); if (EFI_ERROR(status)) { StrnCpy(config[0].fname, NETFS_DEFAULT_CONFIG, maxlen-1); @@ -165,13 +184,20 @@ netfs_setdefaults(VOID *intf, config_file_t *config, CHAR16 *kname, UINTN maxlen # if defined(CONFIG_ia64) # define CONFIG_ARCH_EXTENSION L"-ia64.conf\0" +# define EXTENSION_LENGTH 11 # elif defined (CONFIG_ia32) -# define CONFIG_ARCH_EXTENSION L"-ia64.conf\0" +# define CONFIG_ARCH_EXTENSION L"-ia32.conf\0" +# define EXTENSION_LENGTH 11 +# elif defined (CONFIG_x86_64) +# define CONFIG_ARCH_EXTENSION L"-x86_64.conf\0" +# define EXTENSION_LENGTH 13 # else # error "You need to specfy your default arch config file" # endif # define CONFIG_EXTENSION L".conf\0" + + DBG_PRT((L"netfs_setdefaults: machine specific (!using_pxe)")); /* * will try machine/subnet specific files first. * the filenames are constructed based on the IP(v4) address @@ -181,22 +207,28 @@ netfs_setdefaults(VOID *intf, config_file_t *config, CHAR16 *kname, UINTN maxlen StrnCpy(config[0].fname+8, CONFIG_EXTENSION, 6); StrnCpy(config[1].fname, str, maxlen-1); - StrnCpy(config[1].fname+6, CONFIG_ARCH_EXTENSION, 11); + StrnCpy(config[1].fname+6, CONFIG_ARCH_EXTENSION, EXTENSION_LENGTH); StrnCpy(config[2].fname, str, maxlen-1); StrnCpy(config[2].fname+6, CONFIG_EXTENSION, 6); StrnCpy(config[3].fname, str, maxlen-1); - StrnCpy(config[3].fname+4, CONFIG_ARCH_EXTENSION, 11); + StrnCpy(config[3].fname+4, CONFIG_ARCH_EXTENSION, EXTENSION_LENGTH); StrnCpy(config[4].fname, str, maxlen-1); StrnCpy(config[4].fname+4, CONFIG_EXTENSION, 6); StrnCpy(config[5].fname, str, maxlen-1); - StrnCpy(config[5].fname+2, CONFIG_ARCH_EXTENSION, 11); + StrnCpy(config[5].fname+2, CONFIG_ARCH_EXTENSION, EXTENSION_LENGTH); StrnCpy(config[6].fname, str, maxlen-1); StrnCpy(config[6].fname+2, CONFIG_EXTENSION, 6); + + /* use the MAC address as a possible file name as well */ + convert_mac2hex(info.hw_addr,6,str); + StrnCpy(config[7].fname, str, maxlen-1); + StrnCpy(config[7].fname+17, CONFIG_EXTENSION, 6); + #else StrnCpy(config[0].fname, NETFS_DEFAULT_CONFIG, maxlen-1); config[0].fname[maxlen-1] = CHAR_NULL;