aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--com32/elflink/ldlinux/readconfig.c5
-rw-r--r--com32/include/byteswap.h2
-rw-r--r--com32/include/syslinux/movebits.h2
-rw-r--r--com32/lib/syslinux/zonelist.c2
-rw-r--r--com32/modules/poweroff.c2
-rw-r--r--core/conio.c2
-rw-r--r--efi/console.c4
-rw-r--r--efi/derivative.c4
-rw-r--r--efi/diskio.c4
-rw-r--r--efi/efi.h5
-rw-r--r--efi/main.c4
-rw-r--r--efi/mem.c4
-rw-r--r--efi/pxe.c4
-rw-r--r--efi/tcp.c26
-rw-r--r--efi/udp.c89
-rw-r--r--mk/efi.mk4
16 files changed, 124 insertions, 39 deletions
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 22efbe43..347f8264 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -764,8 +764,8 @@ extern void sirq_cleanup_nowipe(void);
extern void sirq_install(void);
extern void write_serial_str(char *);
-extern void loadfont(char *);
-extern void loadkeys(char *);
+extern void loadfont(const char *);
+extern void loadkeys(const char *);
extern char syslinux_banner[];
extern char copyright_str[];
@@ -868,7 +868,6 @@ static void do_include(char *str)
if (f)
parse_config_file(f);
-bail:
close(fd);
put:
refstr_put(file);
diff --git a/com32/include/byteswap.h b/com32/include/byteswap.h
index d1a4d543..b7eeeb40 100644
--- a/com32/include/byteswap.h
+++ b/com32/include/byteswap.h
@@ -45,7 +45,7 @@ static inline __constfunc uint32_t __bswap_32(uint32_t v)
#define __bswap_64_macro(v) ((uint64_t) \
(((uint64_t)__bswap_32_macro((uint32_t)(v)) << 32) | \
- (__bswap_32__macro((uint32_t)((uint64_t)(v) >> 32)))))
+ (__bswap_32_macro((uint32_t)((uint64_t)(v) >> 32)))))
static inline __constfunc uint64_t __bswap_64(uint64_t v)
{
diff --git a/com32/include/syslinux/movebits.h b/com32/include/syslinux/movebits.h
index f35418f9..4a4ce9ef 100644
--- a/com32/include/syslinux/movebits.h
+++ b/com32/include/syslinux/movebits.h
@@ -83,7 +83,7 @@ enum syslinux_memmap_types syslinux_memmap_type(struct syslinux_memmap *list,
int syslinux_memmap_largest(struct syslinux_memmap *list,
enum syslinux_memmap_types type,
addr_t * start, addr_t * len);
-int syslinux_memmap_highest(struct syslinux_memmap *list,
+int syslinux_memmap_highest(const struct syslinux_memmap *list,
enum syslinux_memmap_types types,
addr_t *start, addr_t len,
addr_t ceiling, addr_t align);
diff --git a/com32/lib/syslinux/zonelist.c b/com32/lib/syslinux/zonelist.c
index 337eb867..dbc874c5 100644
--- a/com32/lib/syslinux/zonelist.c
+++ b/com32/lib/syslinux/zonelist.c
@@ -227,7 +227,7 @@ int syslinux_memmap_largest(struct syslinux_memmap *list,
*
* Returns -1 on failure.
*/
-int syslinux_memmap_highest(struct syslinux_memmap *list,
+int syslinux_memmap_highest(const struct syslinux_memmap *list,
enum syslinux_memmap_types type,
addr_t *start, addr_t len,
addr_t ceiling, addr_t align)
diff --git a/com32/modules/poweroff.c b/com32/modules/poweroff.c
index 3255ac26..41e501e9 100644
--- a/com32/modules/poweroff.c
+++ b/com32/modules/poweroff.c
@@ -20,7 +20,7 @@
#include <string.h>
#include <com32.h>
-int main()
+int main(int argc __unused, char *argv[] __unused)
{
com32sys_t inregs, outregs;
diff --git a/core/conio.c b/core/conio.c
index df929aed..35ef0b4e 100644
--- a/core/conio.c
+++ b/core/conio.c
@@ -54,7 +54,7 @@ uint8_t ScrollAttribute = 0x07; /* Grey on white (normal text color) */
*
* Returns 0 on success, or -1 on error.
*/
-__export int loadkeys(char *filename)
+__export int loadkeys(const char *filename)
{
FILE *f;
diff --git a/efi/console.c b/efi/console.c
index a01e14e8..d7ed0b4a 100644
--- a/efi/console.c
+++ b/efi/console.c
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2011-2014 Intel Corporation - All Rights Reserved
+ */
+
#include <syslinux/linux.h>
#include "efi.h"
#include <string.h>
diff --git a/efi/derivative.c b/efi/derivative.c
index ca43b98b..12edd705 100644
--- a/efi/derivative.c
+++ b/efi/derivative.c
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2012-2014 Intel Corporation - All Rights Reserved
+ */
+
#include <syslinux/config.h>
/*
diff --git a/efi/diskio.c b/efi/diskio.c
index 01ab2a0e..d6a160e1 100644
--- a/efi/diskio.c
+++ b/efi/diskio.c
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2011-2014 Intel Corporation - All Rights Reserved
+ */
+
#include <fs.h>
#include <ilog2.h>
#include <disk.h>
diff --git a/efi/efi.h b/efi/efi.h
index 9e4a4432..ef5bacb3 100644
--- a/efi/efi.h
+++ b/efi/efi.h
@@ -24,6 +24,11 @@
#include <efilib.h>
#include <efistdarg.h>
+/* Delay for 100 ms */
+#define EFI_NOMAP_PRINT_DELAY 100
+/* We should keep EFI_NOMAP_PRINT_COUNT at 10 to limit flooding the console */
+#define EFI_NOMAP_PRINT_COUNT 10
+
struct efi_disk_private {
EFI_HANDLE dev_handle;
EFI_BLOCK_IO *bio;
diff --git a/efi/main.c b/efi/main.c
index d37a57b5..0e6b1370 100644
--- a/efi/main.c
+++ b/efi/main.c
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2011-2014 Intel Corporation - All Rights Reserved
+ */
+
#include <codepage.h>
#include <core.h>
#include <fs.h>
diff --git a/efi/mem.c b/efi/mem.c
index 50e93b08..67e8221d 100644
--- a/efi/mem.c
+++ b/efi/mem.c
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2012-2014 Intel Corporation - All Rights Reserved
+ */
+
#include <mem/malloc.h>
#include <string.h>
#include "efi.h"
diff --git a/efi/pxe.c b/efi/pxe.c
index 1acfcdc5..62fddb08 100644
--- a/efi/pxe.c
+++ b/efi/pxe.c
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2013-2014 Intel Corporation - All Rights Reserved
+ */
+
#include <syslinux/firmware.h>
#include <syslinux/pxe_api.h>
#include "efi.h"
diff --git a/efi/tcp.c b/efi/tcp.c
index f041b677..b90efaf3 100644
--- a/efi/tcp.c
+++ b/efi/tcp.c
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2013-2014 Intel Corporation - All Rights Reserved
+ */
+
#include "efi.h"
#include "net.h"
#include "fs/pxe/pxe.h"
@@ -52,19 +56,35 @@ int core_tcp_connect(struct pxe_pvt_inode *socket, uint32_t ip, uint16_t port)
EFI_STATUS status;
EFI_TCP4 *tcp = (EFI_TCP4 *)b->this;
int rv = -1;
+ int unmapped = 1;
+ jiffies_t start, last, cur;
memset(&tdata, 0, sizeof(tdata));
ap = &tdata.AccessPoint;
- memcpy(&ap->StationAddress, &IPInfo.myip, sizeof(IPInfo.myip));
- memcpy(&ap->SubnetMask, &IPInfo.netmask, sizeof(IPInfo.netmask));
+ ap->UseDefaultAddress = TRUE;
memcpy(&ap->RemoteAddress, &ip, sizeof(ip));
ap->RemotePort = port;
ap->ActiveFlag = TRUE; /* Initiate active open */
tdata.TimeToLive = 64;
- status = uefi_call_wrapper(tcp->Configure, 2, tcp, &tdata);
+ last = start = jiffies();
+ while (unmapped){
+ status = uefi_call_wrapper(tcp->Configure, 2, tcp, &tdata);
+ if (status != EFI_NO_MAPPING)
+ unmapped = 0;
+ else {
+ cur = jiffies();
+ if ( (cur - last) >= EFI_NOMAP_PRINT_DELAY ) {
+ last = cur;
+ Print(L"core_tcp_connect: stalling on configure with no mapping\n");
+ } else if ( (cur - start) > EFI_NOMAP_PRINT_DELAY * EFI_NOMAP_PRINT_COUNT) {
+ Print(L"core_tcp_connect: aborting on no mapping\n");
+ unmapped = 0;
+ }
+ }
+ }
if (status != EFI_SUCCESS)
return -1;
diff --git a/efi/udp.c b/efi/udp.c
index 59bb4263..7c1d09e2 100644
--- a/efi/udp.c
+++ b/efi/udp.c
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2013-2014 Intel Corporation - All Rights Reserved
+ */
+
#include <string.h>
#include <minmax.h>
#include "efi.h"
@@ -14,6 +18,42 @@ extern EFI_GUID Udp4ServiceBindingProtocol, Udp4Protocol;
*/
static struct efi_binding *udp_reader;
+/**
+ * Try to configure this UDP socket
+ *
+ * @param:udp, the EFI_UDP4 socket to configure
+ * @param:udata, the EFI_UDP4_CONFIG_DATA to use
+ * @param:f, the name of the function as a wide string.
+ *
+ * @out: status as EFI_STATUS
+ */
+
+EFI_STATUS core_udp_configure(EFI_UDP4 *udp, EFI_UDP4_CONFIG_DATA *udata,
+ short unsigned int *f)
+{
+ EFI_STATUS status;
+ int unmapped = 1;
+ jiffies_t start, last, cur;
+
+ last = start = jiffies();
+ while (unmapped){
+ status = uefi_call_wrapper(udp->Configure, 2, udp, udata);
+ if (status != EFI_NO_MAPPING)
+ unmapped = 0;
+ else {
+ cur = jiffies();
+ if ( (cur - last) >= EFI_NOMAP_PRINT_DELAY ) {
+ last = cur;
+ Print(L"%s: stalling on configure with no mapping\n", f);
+ } else if ( (cur - start) > EFI_NOMAP_PRINT_DELAY * EFI_NOMAP_PRINT_COUNT) {
+ Print(L"%s: aborting on no mapping\n", f);
+ unmapped = 0;
+ }
+ }
+ }
+ return status;
+}
+
/**
* Open a socket
*
@@ -41,15 +81,25 @@ int core_udp_open(struct pxe_pvt_inode *socket)
udp = (EFI_UDP4 *)udp_reader->this;
memset(&udata, 0, sizeof(udata));
- udata.AcceptPromiscuous = TRUE;
- udata.AcceptAnyPort = TRUE;
- status = uefi_call_wrapper(udp->Configure, 2, udp, &udata);
+ status = core_udp_configure(udp, &udata, L"core_udp_open");
if (status != EFI_SUCCESS)
goto bail;
socket->net.efi.binding = b;
+ /*
+ * Save the random local port number that the UDPv4 Protocol
+ * Driver picked for us. The TFTP protocol uses the local port
+ * number as the TID.
+ */
+ status = uefi_call_wrapper(udp->GetModeData, 5, udp,
+ &udata, NULL, NULL, NULL);
+ if (status != EFI_SUCCESS)
+ Print(L"Failed to get UDP mode data: %d\n", status);
+ else
+ socket->net.efi.localport = udata.StationPort;
+
return 0;
bail:
@@ -100,33 +150,17 @@ void core_udp_connect(struct pxe_pvt_inode *socket, uint32_t ip,
/* Re-use the existing local port number */
udata.StationPort = socket->net.efi.localport;
- memcpy(&udata.StationAddress, &IPInfo.myip, sizeof(IPInfo.myip));
- memcpy(&udata.SubnetMask, &IPInfo.netmask, sizeof(IPInfo.netmask));
+ udata.UseDefaultAddress = TRUE;
memcpy(&udata.RemoteAddress, &ip, sizeof(ip));
udata.RemotePort = port;
udata.AcceptPromiscuous = TRUE;
udata.TimeToLive = 64;
- status = uefi_call_wrapper(udp->Configure, 2, udp, &udata);
+ status = core_udp_configure(udp, &udata, L"core_udp_connect");
if (status != EFI_SUCCESS) {
Print(L"Failed to configure UDP: %d\n", status);
return;
}
-
- /*
- * If this is the first time connecting, save the random local port
- * number that the UDPv4 Protocol Driver picked for us. The TFTP
- * protocol uses the local port number as the TID, and it needs to
- * be consistent across connect()/disconnect() calls.
- */
- if (!socket->net.efi.localport) {
- status = uefi_call_wrapper(udp->GetModeData, 5, udp,
- &udata, NULL, NULL, NULL);
- if (status != EFI_SUCCESS)
- Print(L"Failed to get UDP mode data: %d\n", status);
- else
- socket->net.efi.localport = udata.StationPort;
- }
}
/**
@@ -188,6 +222,7 @@ int core_udp_recv(struct pxe_pvt_inode *socket, void *buf, uint16_t *buf_len,
b = udp_reader;
udp = (EFI_UDP4 *)b->this;
+ memset(&token, 0, sizeof(token));
status = efi_setup_event(&token.Event, (EFI_EVENT_NOTIFY)udp4_cb,
&token);
@@ -269,8 +304,6 @@ void core_udp_send(struct pxe_pvt_inode *socket, const void *data, size_t len)
if (status != EFI_SUCCESS)
goto bail;
- txdata->UdpSessionData = NULL;
- txdata->GatewayAddress = NULL;
txdata->DataLength = len;
txdata->FragmentCount = 1;
frag = &txdata->FragmentTable[0];
@@ -336,14 +369,16 @@ void core_udp_sendto(struct pxe_pvt_inode *socket, const void *data,
memset(&udata, 0, sizeof(udata));
- memcpy(&udata.StationAddress, &IPInfo.myip, sizeof(IPInfo.myip));
- memcpy(&udata.SubnetMask, &IPInfo.netmask, sizeof(IPInfo.netmask));
+ /* Re-use the existing local port number */
+ udata.StationPort = socket->net.efi.localport;
+
+ udata.UseDefaultAddress = TRUE;
memcpy(&udata.RemoteAddress, &ip, sizeof(ip));
udata.RemotePort = port;
udata.AcceptPromiscuous = TRUE;
udata.TimeToLive = 64;
- status = uefi_call_wrapper(udp->Configure, 2, udp, &udata);
+ status = core_udp_configure(udp, &udata, L"core_udp_sendto");
if (status != EFI_SUCCESS)
goto bail;
@@ -352,8 +387,6 @@ void core_udp_sendto(struct pxe_pvt_inode *socket, const void *data,
if (status != EFI_SUCCESS)
goto bail;
- txdata->UdpSessionData = NULL;
- txdata->GatewayAddress = NULL;
txdata->DataLength = len;
txdata->FragmentCount = 1;
frag = &txdata->FragmentTable[0];
diff --git a/mk/efi.mk b/mk/efi.mk
index 9377637c..592a2357 100644
--- a/mk/efi.mk
+++ b/mk/efi.mk
@@ -50,6 +50,10 @@ SFLAGS = $(GCCOPT) $(GCCWARN) $(SARCHOPT) \
-nostdinc -iwithprefix include \
-I$(com32)/libutil/include -I$(com32)/include -I$(com32)/include/sys $(GPLINCLUDE)
+%.o: %.S # Cancel old rule
+
+%.o: %.c
+
.PRECIOUS: %.o
%.o: %.S
$(CC) $(SFLAGS) -c -o $@ $<