summaryrefslogtreecommitdiff
path: root/edk2/StdLib
diff options
context:
space:
mode:
authorRyan Harkin <ryan.harkin@linaro.org>2012-10-12 11:46:51 +0100
committerRyan Harkin <ryan.harkin@linaro.org>2012-10-12 11:46:51 +0100
commitb60dc2d3e998a65b6d34bfd852838ea1149f19f9 (patch)
tree7393bc3f451803043afe8cc12fd78ecc4d1f1215 /edk2/StdLib
parent25323acd0c4c5d7aba0125d031066e55333f214b (diff)
parent67154aa040304dd7b32471f32f3b0f2d4dfbb984 (diff)
Merge branch 'armlt-tracking' of git://git.linaro.org/arm/uefi/uefi-nextlinaro-uefi-2012.10
Diffstat (limited to 'edk2/StdLib')
-rw-r--r--edk2/StdLib/BsdSocketLib/BsdSocketLib.inf5
-rw-r--r--edk2/StdLib/BsdSocketLib/Ip6Addr_Any.c18
-rw-r--r--edk2/StdLib/BsdSocketLib/Ip6Addr_LinkLocal_AllNodes.c18
-rw-r--r--edk2/StdLib/BsdSocketLib/Ip6Addr_LinkLocal_AllRouters.c18
-rw-r--r--edk2/StdLib/BsdSocketLib/Ip6Addr_Loopback.c18
-rw-r--r--edk2/StdLib/BsdSocketLib/Ip6Addr_NodeLocal_AllNodes.c18
-rw-r--r--edk2/StdLib/BsdSocketLib/ns_ntoa.c2
-rw-r--r--edk2/StdLib/BsdSocketLib/ns_parse.c44
-rw-r--r--edk2/StdLib/Contributions.txt188
-rw-r--r--edk2/StdLib/EfiSocketLib/Ip4.c109
-rw-r--r--edk2/StdLib/EfiSocketLib/Service.c35
-rw-r--r--edk2/StdLib/EfiSocketLib/Socket.c2
-rw-r--r--edk2/StdLib/EfiSocketLib/Tcp4.c205
-rw-r--r--edk2/StdLib/EfiSocketLib/Tcp6.c313
-rw-r--r--edk2/StdLib/EfiSocketLib/Udp4.c109
-rw-r--r--edk2/StdLib/EfiSocketLib/Udp6.c103
-rw-r--r--edk2/StdLib/EfiSocketLib/UseEfiSocketLib.c31
-rw-r--r--edk2/StdLib/Include/Arm/machine/ansi.h26
-rw-r--r--edk2/StdLib/Include/Ia32/machine/ansi.h48
-rw-r--r--edk2/StdLib/Include/Ia32/machine/param.h154
-rw-r--r--edk2/StdLib/Include/Ipf/machine/ansi.h24
-rw-r--r--edk2/StdLib/Include/Ipf/machine/param.h114
-rw-r--r--edk2/StdLib/Include/X64/machine/ansi.h11
-rw-r--r--edk2/StdLib/Include/X64/machine/param.h115
-rw-r--r--edk2/StdLib/Include/limits.h4
-rw-r--r--edk2/StdLib/Include/stdarg.h11
-rw-r--r--edk2/StdLib/Include/stdio.h6
-rw-r--r--edk2/StdLib/Include/stdlib.h64
-rw-r--r--edk2/StdLib/Include/sys/EfiCdefs.h15
-rw-r--r--edk2/StdLib/Include/sys/EfiSysCall.h16
-rw-r--r--edk2/StdLib/Include/sys/fcntl.h8
-rw-r--r--edk2/StdLib/Include/sys/stat.h10
-rw-r--r--edk2/StdLib/Include/sys/syslimits.h3
-rw-r--r--edk2/StdLib/Include/sys/termios.h390
-rw-r--r--edk2/StdLib/Include/wchar.h60
-rw-r--r--edk2/StdLib/LibC/Locale/Locale.inf5
-rw-r--r--edk2/StdLib/LibC/Locale/multibyte_Utf8.c829
-rw-r--r--edk2/StdLib/LibC/Main/Main.c6
-rw-r--r--edk2/StdLib/LibC/StdLib/Malloc.c4
-rw-r--r--edk2/StdLib/LibC/Stdio/fputwc.c3
-rw-r--r--edk2/StdLib/LibC/Stdio/makebuf.c5
-rw-r--r--edk2/StdLib/LibC/Stdio/refill.c16
-rw-r--r--edk2/StdLib/LibC/Uefi/Devices/Console/daConsole.c83
-rw-r--r--edk2/StdLib/LibC/Uefi/SysCalls.c43
-rw-r--r--edk2/StdLib/LibC/gdtoa/strtod.c79
-rw-r--r--edk2/StdLib/LibC/gdtoa/strtodg.c71
-rw-r--r--edk2/StdLib/License.txt25
-rw-r--r--edk2/StdLib/StdLib.inc30
48 files changed, 2403 insertions, 1111 deletions
diff --git a/edk2/StdLib/BsdSocketLib/BsdSocketLib.inf b/edk2/StdLib/BsdSocketLib/BsdSocketLib.inf
index d095e5337..df699b19d 100644
--- a/edk2/StdLib/BsdSocketLib/BsdSocketLib.inf
+++ b/edk2/StdLib/BsdSocketLib/BsdSocketLib.inf
@@ -57,6 +57,11 @@
inet_net_pton.c
inet_neta.c
inet_pton.c
+ Ip6Addr_Any.c
+ Ip6Addr_Loopback.c
+ Ip6Addr_NodeLocal_AllNodes.c
+ Ip6Addr_LinkLocal_AllNodes.c
+ Ip6Addr_LinkLocal_AllRouters.c
listen.c
map_v4v6.c
ns_addr.c
diff --git a/edk2/StdLib/BsdSocketLib/Ip6Addr_Any.c b/edk2/StdLib/BsdSocketLib/Ip6Addr_Any.c
new file mode 100644
index 000000000..b1bbe2610
--- /dev/null
+++ b/edk2/StdLib/BsdSocketLib/Ip6Addr_Any.c
@@ -0,0 +1,18 @@
+/** @file
+ IP6 address: any
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <netinet/in.h>
+
+const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
+
diff --git a/edk2/StdLib/BsdSocketLib/Ip6Addr_LinkLocal_AllNodes.c b/edk2/StdLib/BsdSocketLib/Ip6Addr_LinkLocal_AllNodes.c
new file mode 100644
index 000000000..358055de4
--- /dev/null
+++ b/edk2/StdLib/BsdSocketLib/Ip6Addr_LinkLocal_AllNodes.c
@@ -0,0 +1,18 @@
+/** @file
+ IP6 address: link local, all nodes
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <netinet/in.h>
+
+const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
+
diff --git a/edk2/StdLib/BsdSocketLib/Ip6Addr_LinkLocal_AllRouters.c b/edk2/StdLib/BsdSocketLib/Ip6Addr_LinkLocal_AllRouters.c
new file mode 100644
index 000000000..ca8b847ee
--- /dev/null
+++ b/edk2/StdLib/BsdSocketLib/Ip6Addr_LinkLocal_AllRouters.c
@@ -0,0 +1,18 @@
+/** @file
+ IP6 address: link local, all routers
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <netinet/in.h>
+
+const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
+
diff --git a/edk2/StdLib/BsdSocketLib/Ip6Addr_Loopback.c b/edk2/StdLib/BsdSocketLib/Ip6Addr_Loopback.c
new file mode 100644
index 000000000..cc073f2e6
--- /dev/null
+++ b/edk2/StdLib/BsdSocketLib/Ip6Addr_Loopback.c
@@ -0,0 +1,18 @@
+/** @file
+ IP6 address: loopback
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <netinet/in.h>
+
+const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
+
diff --git a/edk2/StdLib/BsdSocketLib/Ip6Addr_NodeLocal_AllNodes.c b/edk2/StdLib/BsdSocketLib/Ip6Addr_NodeLocal_AllNodes.c
new file mode 100644
index 000000000..b597e11f3
--- /dev/null
+++ b/edk2/StdLib/BsdSocketLib/Ip6Addr_NodeLocal_AllNodes.c
@@ -0,0 +1,18 @@
+/** @file
+ IP6 address: node local, all nodes
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <netinet/in.h>
+
+const struct in6_addr in6addr_nodelocal_allnodes = IN6ADDR_NODELOCAL_ALLNODES_INIT;
+
diff --git a/edk2/StdLib/BsdSocketLib/ns_ntoa.c b/edk2/StdLib/BsdSocketLib/ns_ntoa.c
index d079dc866..5195d4ec9 100644
--- a/edk2/StdLib/BsdSocketLib/ns_ntoa.c
+++ b/edk2/StdLib/BsdSocketLib/ns_ntoa.c
@@ -55,7 +55,7 @@ ns_ntoa(
u_char *uplim = up + 6;
net.net_e = addr.x_net;
- sprintf(obuf, "%Lx", (u_long)ntohl(net.long_e));
+ sprintf(obuf, "%x", (UINT32)ntohl(net.long_e));
cp = spectHex(obuf);
cp2 = cp + 1;
while (*up==0 && up < uplim) up++;
diff --git a/edk2/StdLib/BsdSocketLib/ns_parse.c b/edk2/StdLib/BsdSocketLib/ns_parse.c
index 6909d4ef5..40ae79ea7 100644
--- a/edk2/StdLib/BsdSocketLib/ns_parse.c
+++ b/edk2/StdLib/BsdSocketLib/ns_parse.c
@@ -1,21 +1,13 @@
-/*
- * Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
+/** @file
+ Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-/*
* Portions copyright (c) 1999, 2000
* Intel Corporation.
* All rights reserved.
@@ -53,7 +45,21 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
- */
+ * Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+**/
#include <sys/types.h>
@@ -160,7 +166,7 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
int b;
/* Make section right. */
- if (section < 0 || section >= ns_s_max)
+ if ((unsigned int)section >= ns_s_max)
goto enodev;
if ((int)section != (int)handle->_sect) {
handle->_sect = section;
diff --git a/edk2/StdLib/Contributions.txt b/edk2/StdLib/Contributions.txt
new file mode 100644
index 000000000..667ca1035
--- /dev/null
+++ b/edk2/StdLib/Contributions.txt
@@ -0,0 +1,188 @@
+
+======================
+= Code Contributions =
+======================
+
+To make a contribution to a TianoCore project, follow these steps.
+1. Create a change description in the format specified below to
+ use in the source control commit log.
+2. Your commit message must include your "Signed-off-by" signature,
+ and "Contributed-under" message.
+3. Your "Contributed-under" message explicitly states that the
+ contribution is made under the terms of the specified
+ contribution agreement. Your "Contributed-under" message
+ must include the name of contribution agreement and version.
+ For example: Contributed-under: TianoCore Contribution Agreement 1.0
+ The "TianoCore Contribution Agreement" is included below in
+ this document.
+4. Submit your code to the TianoCore project using the process
+ that the project documents on its web page. If the process is
+ not documented, then submit the code on development email list
+ for the project.
+
+=======================================
+= Change Description / Commit Message =
+=======================================
+
+Your change description should use the standard format for a
+commit message, and must include your "Signed-off-by" signature
+and the "Contributed-under" message.
+
+== Sample Change Description / Commit Message =
+
+=== Definitions for sample change description ===
+
+* "CodeModule" is a short idenfier for the affected code. For
+ example MdePkg, or MdeModulePkg UsbBusDxe.
+* "Brief-single-line-summary" is a short summary of the change.
+* The entire first line should be less than ~70 characters.
+* "Full-commit-message" a verbose multiple line comment describing
+ the change. Each line should be less than ~70 characters.
+* "Contributed-under" explicitely states that the contribution is
+ made under the terms of the contribtion agreement. This
+ agreement is included below in this document.
+* "Signed-off-by" is the contributor's signature identifying them
+ by their real/legal name and their email address.
+
+=== Start of sample change description / commit message ===
+CodeModule: Brief-single-line-summary
+
+Full-commit-message
+
+Contributed-under: TianoCore Contribution Agreement 1.0
+Signed-off-by: Contributor Name <contributor@email.server>
+=== End of sample change description / commit message ===
+
+========================================
+= TianoCore Contribution Agreement 1.0 =
+========================================
+
+INTEL CORPORATION ("INTEL") MAKES AVAILABLE SOFTWARE, DOCUMENTATION,
+INFORMATION AND/OR OTHER MATERIALS FOR USE IN THE TIANOCORE OPEN SOURCE
+PROJECT (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE
+TERMS AND CONDITIONS OF THIS AGREEMENT BETWEEN YOU AND INTEL AND/OR THE
+TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR
+REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE
+CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS
+OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
+BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS
+AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
+AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT
+USE THE CONTENT.
+
+Unless otherwise indicated, all Content made available on the TianoCore
+site is provided to you under the terms and conditions of the BSD
+License ("BSD"). A copy of the BSD License is available at
+http://opensource.org/licenses/bsd-license.php
+or when applicable, in the associated License.txt file.
+
+Certain other content may be made available under other licenses as
+indicated in or with such Content. (For example, in a License.txt file.)
+
+You accept and agree to the following terms and conditions for Your
+present and future Contributions submitted to TianoCore site. Except
+for the license granted to Intel hereunder, You reserve all right,
+title, and interest in and to Your Contributions.
+
+== SECTION 1: Definitions ==
+* "You" or "Contributor" shall mean the copyright owner or legal
+ entity authorized by the copyright owner that is making a
+ Contribution hereunder. All other entities that control, are
+ controlled by, or are under common control with that entity are
+ considered to be a single Contributor. For the purposes of this
+ definition, "control" means (i) the power, direct or indirect, to
+ cause the direction or management of such entity, whether by
+ contract or otherwise, or (ii) ownership of fifty percent (50%)
+ or more of the outstanding shares, or (iii) beneficial ownership
+ of such entity.
+* "Contribution" shall mean any original work of authorship,
+ including any modifications or additions to an existing work,
+ that is intentionally submitted by You to the TinaoCore site for
+ inclusion in, or documentation of, any of the Content. For the
+ purposes of this definition, "submitted" means any form of
+ electronic, verbal, or written communication sent to the
+ TianoCore site or its representatives, including but not limited
+ to communication on electronic mailing lists, source code
+ control systems, and issue tracking systems that are managed by,
+ or on behalf of, the TianoCore site for the purpose of
+ discussing and improving the Content, but excluding
+ communication that is conspicuously marked or otherwise
+ designated in writing by You as "Not a Contribution."
+
+== SECTION 2: License for Contributions ==
+* Contributor hereby agrees that redistribution and use of the
+ Contribution in source and binary forms, with or without
+ modification, are permitted provided that the following
+ conditions are met:
+** Redistributions of source code must retain the Contributor's
+ copyright notice, this list of conditions and the following
+ disclaimer.
+** Redistributions in binary form must reproduce the Contributor's
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+* Disclaimer. None of the names of Contributor, Intel, or the names
+ of their respective contributors may be used to endorse or
+ promote products derived from this software without specific
+ prior written permission.
+* Contributor grants a license (with the right to sublicense) under
+ claims of Contributor's patents that Contributor can license that
+ are infringed by the Contribution (as delivered by Contributor) to
+ make, use, distribute, sell, offer for sale, and import the
+ Contribution and derivative works thereof solely to the minimum
+ extent necessary for licensee to exercise the granted copyright
+ license; this patent license applies solely to those portions of
+ the Contribution that are unmodified. No hardware per se is
+ licensed.
+* EXCEPT AS EXPRESSLY SET FORTH IN SECTION 3 BELOW, THE
+ CONTRIBUTION IS PROVIDED BY THE CONTRIBUTOR "AS IS" AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
+ CONTRIBUTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+
+== SECTION 3: Representations ==
+* You represent that You are legally entitled to grant the above
+ license. If your employer(s) has rights to intellectual property
+ that You create that includes Your Contributions, You represent
+ that You have received permission to make Contributions on behalf
+ of that employer, that Your employer has waived such rights for
+ Your Contributions.
+* You represent that each of Your Contributions is Your original
+ creation (see Section 4 for submissions on behalf of others).
+ You represent that Your Contribution submissions include complete
+ details of any third-party license or other restriction
+ (including, but not limited to, related patents and trademarks)
+ of which You are personally aware and which are associated with
+ any part of Your Contributions.
+
+== SECTION 4: Third Party Contributions ==
+* Should You wish to submit work that is not Your original creation,
+ You may submit it to TianoCore site separately from any
+ Contribution, identifying the complete details of its source
+ and of any license or other restriction (including, but not
+ limited to, related patents, trademarks, and license agreements)
+ of which You are personally aware, and conspicuously marking the
+ work as "Submitted on behalf of a third-party: [named here]".
+
+== SECTION 5: Miscellaneous ==
+* Applicable Laws. Any claims arising under or relating to this
+ Agreement shall be governed by the internal substantive laws of
+ the State of Delaware or federal courts located in Delaware,
+ without regard to principles of conflict of laws.
+* Language. This Agreement is in the English language only, which
+ language shall be controlling in all respects, and all versions
+ of this Agreement in any other language shall be for accommodation
+ only and shall not be binding. All communications and notices made
+ or given pursuant to this Agreement, and all documentation and
+ support to be provided, unless otherwise noted, shall be in the
+ English language.
+
diff --git a/edk2/StdLib/EfiSocketLib/Ip4.c b/edk2/StdLib/EfiSocketLib/Ip4.c
index 5a0f5284f..2e832c7ac 100644
--- a/edk2/StdLib/EfiSocketLib/Ip4.c
+++ b/edk2/StdLib/EfiSocketLib/Ip4.c
@@ -143,9 +143,9 @@ EslIp4LocalAddressSet (
}
else {
pConfig->SubnetMask.Addr[0] = 0xff;
- pConfig->SubnetMask.Addr[1] = 0xff;
- pConfig->SubnetMask.Addr[2] = 0xff;
- pConfig->SubnetMask.Addr[3] = 0xff;
+ pConfig->SubnetMask.Addr[1] = ( 128 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;
+ pConfig->SubnetMask.Addr[2] = ( 192 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;
+ pConfig->SubnetMask.Addr[3] = ( 224 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;
}
}
@@ -749,6 +749,7 @@ EslIp4RxComplete (
//
// Fill in the port list if necessary
//
+ pSocket->errno = ENETDOWN;
if ( NULL == pSocket->pPortList ) {
LocalAddress.sin_len = sizeof ( LocalAddress );
LocalAddress.sin_family = AF_INET;
@@ -804,34 +805,36 @@ EslIp4RxComplete (
NULL );
}
if ( EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_LISTEN,
- "ERROR - Failed to configure the Ip4 port, Status: %r\r\n",
- Status ));
- switch ( Status ) {
- case EFI_ACCESS_DENIED:
- pSocket->errno = EACCES;
- break;
+ if ( !pSocket->bConfigured ) {
+ DEBUG (( DEBUG_LISTEN,
+ "ERROR - Failed to configure the Ip4 port, Status: %r\r\n",
+ Status ));
+ switch ( Status ) {
+ case EFI_ACCESS_DENIED:
+ pSocket->errno = EACCES;
+ break;
+
+ default:
+ case EFI_DEVICE_ERROR:
+ pSocket->errno = EIO;
+ break;
- default:
- case EFI_DEVICE_ERROR:
- pSocket->errno = EIO;
- break;
+ case EFI_INVALID_PARAMETER:
+ pSocket->errno = EADDRNOTAVAIL;
+ break;
- case EFI_INVALID_PARAMETER:
- pSocket->errno = EADDRNOTAVAIL;
- break;
+ case EFI_NO_MAPPING:
+ pSocket->errno = EAFNOSUPPORT;
+ break;
- case EFI_NO_MAPPING:
- pSocket->errno = EAFNOSUPPORT;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOBUFS;
- break;
+ case EFI_OUT_OF_RESOURCES:
+ pSocket->errno = ENOBUFS;
+ break;
- case EFI_UNSUPPORTED:
- pSocket->errno = EOPNOTSUPP;
- break;
+ case EFI_UNSUPPORTED:
+ pSocket->errno = EOPNOTSUPP;
+ break;
+ }
}
}
else {
@@ -876,6 +879,7 @@ EslIp4RxComplete (
pIp4->ModeData.RouteTable[Index].GatewayAddress.Addr[3]));
}
pPort->bConfigured = TRUE;
+ pSocket->bConfigured = TRUE;
//
// Start the first read on the port
@@ -886,6 +890,7 @@ EslIp4RxComplete (
// The socket is connected
//
pSocket->State = SOCKET_STATE_CONNECTED;
+ pSocket->errno = 0;
}
//
@@ -893,21 +898,12 @@ EslIp4RxComplete (
//
pPort = pNextPort;
}
-
- //
- // Determine the configuration status
- //
- if ( NULL != pSocket->pPortList ) {
- pSocket->bConfigured = TRUE;
- }
}
//
// Determine the socket configuration status
//
- if ( !EFI_ERROR ( Status )) {
- Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
- }
+ Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
//
// Return the port connected state.
@@ -989,21 +985,21 @@ EslIp4TxBuffer (
//
if ( SOCKET_STATE_CONNECTED == pSocket->State ) {
//
- // Locate the port
+ // Verify that there is enough room to buffer another
+ // transmit operation
//
- pPort = pSocket->pPortList;
- if ( NULL != pPort ) {
+ pTxBytes = &pSocket->TxBytes;
+ if ( pSocket->MaxTxBuf > *pTxBytes ) {
//
- // Determine the queue head
+ // Locate the port
//
- pIp4 = &pPort->Context.Ip4;
- pTxBytes = &pSocket->TxBytes;
+ pPort = pSocket->pPortList;
+ while ( NULL != pPort ) {
+ //
+ // Determine the queue head
+ //
+ pIp4 = &pPort->Context.Ip4;
- //
- // Verify that there is enough room to buffer another
- // transmit operation
- //
- if ( pSocket->MaxTxBuf > *pTxBytes ) {
//
// Attempt to allocate the packet
//
@@ -1135,6 +1131,7 @@ EslIp4TxBuffer (
// Free the packet
//
EslSocketPacketFree ( pPacket, DEBUG_TX );
+ break;
}
//
@@ -1147,16 +1144,22 @@ EslIp4TxBuffer (
// Packet allocation failed
//
pSocket->errno = ENOMEM;
+ break;
}
- }
- else {
+
//
- // Not enough buffer space available
+ // Set the next port
//
- pSocket->errno = EAGAIN;
- Status = EFI_NOT_READY;
+ pPort = pPort->pLinkSocket;
}
}
+ else {
+ //
+ // Not enough buffer space available
+ //
+ pSocket->errno = EAGAIN;
+ Status = EFI_NOT_READY;
+ }
}
//
diff --git a/edk2/StdLib/EfiSocketLib/Service.c b/edk2/StdLib/EfiSocketLib/Service.c
index 927f0e45b..414cace00 100644
--- a/edk2/StdLib/EfiSocketLib/Service.c
+++ b/edk2/StdLib/EfiSocketLib/Service.c
@@ -29,7 +29,8 @@
@param [in] Controller Handle of device to work with.
@retval EFI_SUCCESS This driver is added to Controller.
- @retval other This driver does not support this device.
+ @retval EFI_OUT_OF_RESOURCES No more memory available.
+ @retval EFI_UNSUPPORTED This driver does not support this device.
**/
EFI_STATUS
@@ -40,6 +41,7 @@ EslServiceConnect (
)
{
BOOLEAN bInUse;
+ EFI_STATUS ExitStatus;
UINTN LengthInBytes;
UINT8 * pBuffer;
CONST ESL_SOCKET_BINDING * pEnd;
@@ -56,7 +58,7 @@ EslServiceConnect (
//
// Assume the list is empty
//
- Status = EFI_UNSUPPORTED;
+ ExitStatus = EFI_UNSUPPORTED;
bInUse = FALSE;
//
@@ -171,28 +173,9 @@ EslServiceConnect (
RESTORE_TPL ( TplPrevious );
//
- // Determine if the initialization was successful
+ // At least one service was made available
//
- if ( EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,
- "ERROR - Failed to initialize service %s on 0x%08x, Status: %r\r\n",
- pSocketBinding->pName,
- Controller,
- Status ));
-
- //
- // Free the network service binding if necessary
- //
- gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- pSocketBinding->pTagGuid,
- pService,
- NULL );
- DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
- "Removed: %s TagGuid from 0x%08x\r\n",
- pSocketBinding->pName,
- Controller ));
- }
+ ExitStatus = EFI_SUCCESS;
}
else {
DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,
@@ -241,6 +224,8 @@ EslServiceConnect (
DEBUG (( DEBUG_ERROR | DEBUG_INIT,
"ERROR - Failed service allocation, Status: %r\r\n",
Status ));
+ ExitStatus = EFI_OUT_OF_RESOURCES;
+ break;
}
}
}
@@ -254,8 +239,8 @@ EslServiceConnect (
//
// Display the driver start status
//
- DBG_EXIT_STATUS ( Status );
- return Status;
+ DBG_EXIT_STATUS ( ExitStatus );
+ return ExitStatus;
}
diff --git a/edk2/StdLib/EfiSocketLib/Socket.c b/edk2/StdLib/EfiSocketLib/Socket.c
index acb23677a..e718e9bdf 100644
--- a/edk2/StdLib/EfiSocketLib/Socket.c
+++ b/edk2/StdLib/EfiSocketLib/Socket.c
@@ -3191,7 +3191,7 @@ EslSocketPacketFree (
DBG_ENTER ( );
//
- // Allocate a packet structure
+ // Free a packet structure
//
LengthInBytes = pPacket->PacketSize;
Status = gBS->FreePool ( pPacket );
diff --git a/edk2/StdLib/EfiSocketLib/Tcp4.c b/edk2/StdLib/EfiSocketLib/Tcp4.c
index 32c7a394c..34e60e2a7 100644
--- a/edk2/StdLib/EfiSocketLib/Tcp4.c
+++ b/edk2/StdLib/EfiSocketLib/Tcp4.c
@@ -241,15 +241,17 @@ EslTcp4ConnectComplete (
//
// The connection failed
//
- DEBUG (( DEBUG_CONNECT,
- "0x%08x: Port connection to %d.%d.%d.%d:%d failed, Status: %r\r\n",
- pPort,
- pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[0],
- pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[1],
- pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[2],
- pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[3],
- pTcp4->ConfigData.AccessPoint.RemotePort,
- Status ));
+ if ( pPort->bConfigured ) {
+ DEBUG (( DEBUG_CONNECT,
+ "0x%08x: Port connection to %d.%d.%d.%d:%d failed, Status: %r\r\n",
+ pPort,
+ pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[0],
+ pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[1],
+ pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[2],
+ pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[3],
+ pTcp4->ConfigData.AccessPoint.RemotePort,
+ Status ));
+ }
//
// Close the current port
@@ -272,7 +274,6 @@ EslTcp4ConnectComplete (
//
Status = EslTcp4ConnectStart ( pSocket );
if ( EFI_NOT_READY != Status ) {
- pSocket->ConnectStatus = Status;
bRemoveFirstPort = TRUE;
}
}
@@ -374,24 +375,43 @@ EslTcp4ConnectPoll (
break;
case EFI_ABORTED:
- pSocket->errno = ECONNREFUSED;
+ pSocket->errno = ECONNABORTED;
+ break;
+
+ case EFI_ACCESS_DENIED:
+ pSocket->errno = EACCES;
+ break;
+
+ case EFI_CONNECTION_RESET:
+ pSocket->errno = ECONNRESET;
break;
case EFI_INVALID_PARAMETER:
- pSocket->errno = EINVAL;
+ pSocket->errno = EADDRNOTAVAIL;
break;
- case EFI_NO_MAPPING:
+ case EFI_HOST_UNREACHABLE:
case EFI_NO_RESPONSE:
pSocket->errno = EHOSTUNREACH;
break;
+ case EFI_NO_MAPPING:
+ pSocket->errno = EAFNOSUPPORT;
+ break;
+
case EFI_NO_MEDIA:
+ case EFI_NETWORK_UNREACHABLE:
pSocket->errno = ENETDOWN;
break;
case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOMEM;
+ pSocket->errno = ENOBUFS;
+ break;
+
+ case EFI_PORT_UNREACHABLE:
+ case EFI_PROTOCOL_UNREACHABLE:
+ case EFI_CONNECTION_REFUSED:
+ pSocket->errno = ECONNREFUSED;
break;
case EFI_SUCCESS:
@@ -404,13 +424,17 @@ EslTcp4ConnectPoll (
break;
case EFI_UNSUPPORTED:
- pSocket->errno = ENOTSUP;
- break;
-
- case 0x80000069:
- pSocket->errno = ECONNRESET;
+ pSocket->errno = EOPNOTSUPP;
break;
}
+
+ //
+ // Display the translation
+ //
+ DEBUG (( DEBUG_CONNECT,
+ "ERROR - errno: %d, Status: %r\r\n",
+ pSocket->errno,
+ Status ));
}
//
@@ -453,6 +477,7 @@ EslTcp4ConnectStart (
ESL_PORT * pPort;
ESL_TCP4_CONTEXT * pTcp4;
EFI_TCP4_PROTOCOL * pTcp4Protocol;
+ EFI_SIMPLE_NETWORK_MODE SnpModeData;
EFI_STATUS Status;
DBG_ENTER ( );
@@ -475,32 +500,6 @@ EslTcp4ConnectStart (
DEBUG (( DEBUG_CONNECT,
"ERROR - Failed to configure the Tcp4 port, Status: %r\r\n",
Status ));
- switch ( Status ) {
- case EFI_ACCESS_DENIED:
- pSocket->errno = EACCES;
- break;
-
- default:
- case EFI_DEVICE_ERROR:
- pSocket->errno = EIO;
- break;
-
- case EFI_INVALID_PARAMETER:
- pSocket->errno = EADDRNOTAVAIL;
- break;
-
- case EFI_NO_MAPPING:
- pSocket->errno = EAFNOSUPPORT;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOBUFS;
- break;
-
- case EFI_UNSUPPORTED:
- pSocket->errno = EOPNOTSUPP;
- break;
- }
}
else {
DEBUG (( DEBUG_CONNECT,
@@ -509,26 +508,31 @@ EslTcp4ConnectStart (
pPort->bConfigured = TRUE;
//
- // Attempt the connection to the remote system
+ // Verify the port connection
//
- Status = pTcp4Protocol->Connect ( pTcp4Protocol,
- &pTcp4->ConnectToken );
+ Status = pTcp4Protocol->GetModeData ( pTcp4Protocol,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &SnpModeData );
if ( !EFI_ERROR ( Status )) {
- //
- // Connection in progress
- //
- pSocket->errno = EINPROGRESS;
- Status = EFI_NOT_READY;
- DEBUG (( DEBUG_CONNECT,
- "0x%08x: Port attempting connection to %d.%d.%d.%d:%d\r\n",
- pPort,
- pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[0],
- pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[1],
- pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[2],
- pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[3],
- pTcp4->ConfigData.AccessPoint.RemotePort ));
+ if ( SnpModeData.MediaPresentSupported
+ && ( !SnpModeData.MediaPresent )) {
+ //
+ // Port is not connected to the network
+ //
+ Status = EFI_NO_MEDIA;
+ }
+ else {
+ //
+ // Attempt the connection to the remote system
+ //
+ Status = pTcp4Protocol->Connect ( pTcp4Protocol,
+ &pTcp4->ConnectToken );
+ }
}
- else {
+ if ( EFI_ERROR ( Status )) {
//
// Connection error
//
@@ -536,42 +540,38 @@ EslTcp4ConnectStart (
"ERROR - Port 0x%08x not connected, Status: %r\r\n",
pPort,
Status ));
- //
- // Determine the errno value
- //
- switch ( Status ) {
- default:
- pSocket->errno = EIO;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOBUFS;
- break;
-
- case EFI_TIMEOUT:
- pSocket->errno = ETIMEDOUT;
- break;
-
- case EFI_NETWORK_UNREACHABLE:
- pSocket->errno = ENETDOWN;
- break;
-
- case EFI_HOST_UNREACHABLE:
- pSocket->errno = EHOSTUNREACH;
- break;
-
- case EFI_PORT_UNREACHABLE:
- case EFI_PROTOCOL_UNREACHABLE:
- case EFI_CONNECTION_REFUSED:
- pSocket->errno = ECONNREFUSED;
- break;
-
- case EFI_CONNECTION_RESET:
- pSocket->errno = ECONNRESET;
- break;
- }
}
}
+ if ( !EFI_ERROR ( Status )) {
+ //
+ // Connection in progress
+ //
+ pSocket->errno = EINPROGRESS;
+ DEBUG (( DEBUG_CONNECT,
+ "0x%08x: Port attempting connection to %d.%d.%d.%d:%d\r\n",
+ pPort,
+ pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[0],
+ pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[1],
+ pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[2],
+ pTcp4->ConfigData.AccessPoint.RemoteAddress.Addr[3],
+ pTcp4->ConfigData.AccessPoint.RemotePort ));
+ }
+ else {
+ //
+ // Error return path is through EslTcp4ConnectComplete to
+ // enable retry on other ports
+ //
+ // Status to errno translation gets done in EslTcp4ConnectPoll
+ //
+ pTcp4->ConnectToken.CompletionToken.Status = Status;
+
+ //
+ // Continue with the next port
+ //
+ gBS->CheckEvent ( pTcp4->ConnectToken.CompletionToken.Event );
+ gBS->SignalEvent ( pTcp4->ConnectToken.CompletionToken.Event );
+ }
+ Status = EFI_NOT_READY;
}
else {
//
@@ -790,6 +790,8 @@ EslTcp4Listen (
// Mark the socket as configured
//
pSocket->bConfigured = TRUE;
+ Status = EFI_SUCCESS;
+ pSocket->errno = 0;
//
// All done
@@ -1155,9 +1157,9 @@ EslTcp4LocalAddressSet (
}
else {
pAccessPoint->SubnetMask.Addr[0] = 0xff;
- pAccessPoint->SubnetMask.Addr[1] = 0xff;
- pAccessPoint->SubnetMask.Addr[2] = 0xff;
- pAccessPoint->SubnetMask.Addr[3] = 0xff;
+ pAccessPoint->SubnetMask.Addr[1] = ( 128 <= pAccessPoint->StationAddress.Addr[0]) ? 0xff : 0;
+ pAccessPoint->SubnetMask.Addr[2] = ( 192 <= pAccessPoint->StationAddress.Addr[0]) ? 0xff : 0;
+ pAccessPoint->SubnetMask.Addr[3] = ( 224 <= pAccessPoint->StationAddress.Addr[0]) ? 0xff : 0;
}
//
@@ -1572,6 +1574,11 @@ EslTcp4Receive (
CopyMem ( pBuffer, pPacket->pBuffer, DataLength );
//
+ // Set the next buffer address
+ //
+ pBuffer += DataLength;
+
+ //
// Determine if the data is being read
//
if ( *pbConsumePacket ) {
diff --git a/edk2/StdLib/EfiSocketLib/Tcp6.c b/edk2/StdLib/EfiSocketLib/Tcp6.c
index 6f2cf7577..df70a94f4 100644
--- a/edk2/StdLib/EfiSocketLib/Tcp6.c
+++ b/edk2/StdLib/EfiSocketLib/Tcp6.c
@@ -247,27 +247,29 @@ EslTcp6ConnectComplete (
//
// The connection failed
//
- DEBUG (( DEBUG_CONNECT,
- "0x%08x: Port connection to [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d failed, Status: %r\r\n",
- pPort,
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[1],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[2],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[3],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[4],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[5],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[6],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[7],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[8],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[9],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[10],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[11],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[12],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[13],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[14],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[15],
- pTcp6->ConfigData.AccessPoint.RemotePort,
- Status ));
+ if ( pPort->bConfigured ) {
+ DEBUG (( DEBUG_CONNECT,
+ "0x%08x: Port connection to [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d failed, Status: %r\r\n",
+ pPort,
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[1],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[2],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[3],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[4],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[5],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[6],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[7],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[8],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[9],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[10],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[11],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[12],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[13],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[14],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[15],
+ pTcp6->ConfigData.AccessPoint.RemotePort,
+ Status ));
+ }
//
// Close the current port
@@ -290,7 +292,6 @@ EslTcp6ConnectComplete (
//
Status = EslTcp6ConnectStart ( pSocket );
if ( EFI_NOT_READY != Status ) {
- pSocket->ConnectStatus = Status;
bRemoveFirstPort = TRUE;
}
}
@@ -386,49 +387,72 @@ EslTcp6ConnectPoll (
//
Status = pSocket->ConnectStatus;
switch ( Status ) {
- default:
- case EFI_DEVICE_ERROR:
- pSocket->errno = EIO;
- break;
-
- case EFI_ABORTED:
- pSocket->errno = ECONNREFUSED;
- break;
-
- case EFI_INVALID_PARAMETER:
- pSocket->errno = EINVAL;
- break;
-
- case EFI_NO_MAPPING:
- case EFI_NO_RESPONSE:
- pSocket->errno = EHOSTUNREACH;
- break;
-
- case EFI_NO_MEDIA:
- pSocket->errno = ENETDOWN;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOMEM;
- break;
-
- case EFI_SUCCESS:
- pSocket->errno = 0;
- pSocket->bConfigured = TRUE;
- break;
-
- case EFI_TIMEOUT:
- pSocket->errno = ETIMEDOUT;
- break;
-
- case EFI_UNSUPPORTED:
- pSocket->errno = ENOTSUP;
- break;
-
- case 0x80000069:
- pSocket->errno = ECONNRESET;
- break;
+ default:
+ case EFI_DEVICE_ERROR:
+ pSocket->errno = EIO;
+ break;
+
+ case EFI_ABORTED:
+ pSocket->errno = ECONNABORTED;
+ break;
+
+ case EFI_ACCESS_DENIED:
+ pSocket->errno = EACCES;
+ break;
+
+ case EFI_CONNECTION_RESET:
+ pSocket->errno = ECONNRESET;
+ break;
+
+ case EFI_INVALID_PARAMETER:
+ pSocket->errno = EADDRNOTAVAIL;
+ break;
+
+ case EFI_HOST_UNREACHABLE:
+ case EFI_NO_RESPONSE:
+ pSocket->errno = EHOSTUNREACH;
+ break;
+
+ case EFI_NO_MAPPING:
+ pSocket->errno = EAFNOSUPPORT;
+ break;
+
+ case EFI_NO_MEDIA:
+ case EFI_NETWORK_UNREACHABLE:
+ pSocket->errno = ENETDOWN;
+ break;
+
+ case EFI_OUT_OF_RESOURCES:
+ pSocket->errno = ENOBUFS;
+ break;
+
+ case EFI_PORT_UNREACHABLE:
+ case EFI_PROTOCOL_UNREACHABLE:
+ case EFI_CONNECTION_REFUSED:
+ pSocket->errno = ECONNREFUSED;
+ break;
+
+ case EFI_SUCCESS:
+ pSocket->errno = 0;
+ pSocket->bConfigured = TRUE;
+ break;
+
+ case EFI_TIMEOUT:
+ pSocket->errno = ETIMEDOUT;
+ break;
+
+ case EFI_UNSUPPORTED:
+ pSocket->errno = EOPNOTSUPP;
+ break;
}
+
+ //
+ // Display the translation
+ //
+ DEBUG (( DEBUG_CONNECT,
+ "ERROR - errno: %d, Status: %r\r\n",
+ pSocket->errno,
+ Status ));
}
//
@@ -471,6 +495,7 @@ EslTcp6ConnectStart (
ESL_PORT * pPort;
ESL_TCP6_CONTEXT * pTcp6;
EFI_TCP6_PROTOCOL * pTcp6Protocol;
+ EFI_SIMPLE_NETWORK_MODE SnpModeData;
EFI_STATUS Status;
DBG_ENTER ( );
@@ -494,32 +519,6 @@ EslTcp6ConnectStart (
DEBUG (( DEBUG_CONNECT,
"ERROR - Failed to configure the Tcp6 port, Status: %r\r\n",
Status ));
- switch ( Status ) {
- case EFI_ACCESS_DENIED:
- pSocket->errno = EACCES;
- break;
-
- default:
- case EFI_DEVICE_ERROR:
- pSocket->errno = EIO;
- break;
-
- case EFI_INVALID_PARAMETER:
- pSocket->errno = EADDRNOTAVAIL;
- break;
-
- case EFI_NO_MAPPING:
- pSocket->errno = EAFNOSUPPORT;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOBUFS;
- break;
-
- case EFI_UNSUPPORTED:
- pSocket->errno = EOPNOTSUPP;
- break;
- }
}
else {
DEBUG (( DEBUG_CONNECT,
@@ -528,38 +527,31 @@ EslTcp6ConnectStart (
pPort->bConfigured = TRUE;
//
- // Attempt the connection to the remote system
+ // Verify the port connection
//
- Status = pTcp6Protocol->Connect ( pTcp6Protocol,
- &pTcp6->ConnectToken );
+ Status = pTcp6Protocol->GetModeData ( pTcp6Protocol,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &SnpModeData );
if ( !EFI_ERROR ( Status )) {
- //
- // Connection in progress
- //
- pSocket->errno = EINPROGRESS;
- Status = EFI_NOT_READY;
- DEBUG (( DEBUG_CONNECT,
- "0x%08x: Port attempting connection to [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",
- pPort,
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[1],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[2],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[3],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[4],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[5],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[6],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[7],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[8],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[9],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[10],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[11],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[12],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[13],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[14],
- pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[15],
- pTcp6->ConfigData.AccessPoint.RemotePort ));
+ if ( SnpModeData.MediaPresentSupported
+ && ( !SnpModeData.MediaPresent )) {
+ //
+ // Port is not connected to the network
+ //
+ Status = EFI_NO_MEDIA;
+ }
+ else {
+ //
+ // Attempt the connection to the remote system
+ //
+ Status = pTcp6Protocol->Connect ( pTcp6Protocol,
+ &pTcp6->ConnectToken );
+ }
}
- else {
+ if ( EFI_ERROR ( Status )) {
//
// Connection error
//
@@ -567,42 +559,50 @@ EslTcp6ConnectStart (
"ERROR - Port 0x%08x not connected, Status: %r\r\n",
pPort,
Status ));
- //
- // Determine the errno value
- //
- switch ( Status ) {
- default:
- pSocket->errno = EIO;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOBUFS;
- break;
-
- case EFI_TIMEOUT:
- pSocket->errno = ETIMEDOUT;
- break;
-
- case EFI_NETWORK_UNREACHABLE:
- pSocket->errno = ENETDOWN;
- break;
-
- case EFI_HOST_UNREACHABLE:
- pSocket->errno = EHOSTUNREACH;
- break;
-
- case EFI_PORT_UNREACHABLE:
- case EFI_PROTOCOL_UNREACHABLE:
- case EFI_CONNECTION_REFUSED:
- pSocket->errno = ECONNREFUSED;
- break;
-
- case EFI_CONNECTION_RESET:
- pSocket->errno = ECONNRESET;
- break;
- }
}
}
+ if ( !EFI_ERROR ( Status )) {
+ //
+ // Connection in progress
+ //
+ pSocket->errno = EINPROGRESS;
+ DEBUG (( DEBUG_CONNECT,
+ "0x%08x: Port attempting connection to [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",
+ pPort,
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[1],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[2],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[3],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[4],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[5],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[6],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[7],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[8],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[9],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[10],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[11],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[12],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[13],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[14],
+ pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[15],
+ pTcp6->ConfigData.AccessPoint.RemotePort ));
+ }
+ else {
+ //
+ // Error return path is through EslTcp6ConnectComplete to
+ // enable retry on other ports
+ //
+ // Status to errno translation gets done in EslTcp4ConnectPoll
+ //
+ pTcp6->ConnectToken.CompletionToken.Status = Status;
+
+ //
+ // Continue with the next port
+ //
+ gBS->CheckEvent ( pTcp6->ConnectToken.CompletionToken.Event );
+ gBS->SignalEvent ( pTcp6->ConnectToken.CompletionToken.Event );
+ }
+ Status = EFI_NOT_READY;
}
else {
//
@@ -821,6 +821,8 @@ EslTcp6Listen (
// Mark the socket as configured
//
pSocket->bConfigured = TRUE;
+ Status = EFI_SUCCESS;
+ pSocket->errno = 0;
//
// All done
@@ -1636,6 +1638,11 @@ EslTcp6Receive (
CopyMem ( pBuffer, pPacket->pBuffer, DataLength );
//
+ // Set the next buffer address
+ //
+ pBuffer += DataLength;
+
+ //
// Determine if the data is being read
//
if ( *pbConsumePacket ) {
diff --git a/edk2/StdLib/EfiSocketLib/Udp4.c b/edk2/StdLib/EfiSocketLib/Udp4.c
index ae67c4e8c..414e3fe32 100644
--- a/edk2/StdLib/EfiSocketLib/Udp4.c
+++ b/edk2/StdLib/EfiSocketLib/Udp4.c
@@ -131,9 +131,9 @@ EslUdp4LocalAddressSet (
}
else {
pConfig->SubnetMask.Addr[0] = 0xff;
- pConfig->SubnetMask.Addr[1] = 0xff;
- pConfig->SubnetMask.Addr[2] = 0xff;
- pConfig->SubnetMask.Addr[3] = 0xff;
+ pConfig->SubnetMask.Addr[1] = ( 128 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;
+ pConfig->SubnetMask.Addr[2] = ( 192 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;
+ pConfig->SubnetMask.Addr[3] = ( 224 <= pConfig->StationAddress.Addr[0]) ? 0xff : 0;
}
//
@@ -591,6 +591,7 @@ EslUdp4RxComplete (
//
// Fill in the port list if necessary
//
+ pSocket->errno = ENETDOWN;
if ( NULL == pSocket->pPortList ) {
LocalAddress.sin_len = sizeof ( LocalAddress );
LocalAddress.sin_family = AF_INET;
@@ -640,34 +641,36 @@ EslUdp4RxComplete (
NULL );
}
if ( EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_LISTEN,
- "ERROR - Failed to configure the Udp4 port, Status: %r\r\n",
- Status ));
- switch ( Status ) {
- case EFI_ACCESS_DENIED:
- pSocket->errno = EACCES;
- break;
+ if ( !pSocket->bConfigured ) {
+ DEBUG (( DEBUG_LISTEN,
+ "ERROR - Failed to configure the Udp4 port, Status: %r\r\n",
+ Status ));
+ switch ( Status ) {
+ case EFI_ACCESS_DENIED:
+ pSocket->errno = EACCES;
+ break;
+
+ default:
+ case EFI_DEVICE_ERROR:
+ pSocket->errno = EIO;
+ break;
- default:
- case EFI_DEVICE_ERROR:
- pSocket->errno = EIO;
- break;
+ case EFI_INVALID_PARAMETER:
+ pSocket->errno = EADDRNOTAVAIL;
+ break;
- case EFI_INVALID_PARAMETER:
- pSocket->errno = EADDRNOTAVAIL;
- break;
+ case EFI_NO_MAPPING:
+ pSocket->errno = EAFNOSUPPORT;
+ break;
- case EFI_NO_MAPPING:
- pSocket->errno = EAFNOSUPPORT;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOBUFS;
- break;
+ case EFI_OUT_OF_RESOURCES:
+ pSocket->errno = ENOBUFS;
+ break;
- case EFI_UNSUPPORTED:
- pSocket->errno = EOPNOTSUPP;
- break;
+ case EFI_UNSUPPORTED:
+ pSocket->errno = EOPNOTSUPP;
+ break;
+ }
}
}
else {
@@ -685,6 +688,7 @@ EslUdp4RxComplete (
pConfigData->RemoteAddress.Addr[3],
pConfigData->RemotePort ));
pPort->bConfigured = TRUE;
+ pSocket->bConfigured = TRUE;
//
// Start the first read on the port
@@ -695,6 +699,7 @@ EslUdp4RxComplete (
// The socket is connected
//
pSocket->State = SOCKET_STATE_CONNECTED;
+ pSocket->errno = 0;
}
//
@@ -702,21 +707,12 @@ EslUdp4RxComplete (
//
pPort = pNextPort;
}
-
- //
- // Determine the configuration status
- //
- if ( NULL != pSocket->pPortList ) {
- pSocket->bConfigured = TRUE;
- }
}
//
// Determine the socket configuration status
//
- if ( !EFI_ERROR ( Status )) {
- Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
- }
+ Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
//
// Return the port connected state.
@@ -798,21 +794,21 @@ EslUdp4TxBuffer (
//
if ( SOCKET_STATE_CONNECTED == pSocket->State ) {
//
- // Locate the port
+ // Verify that there is enough room to buffer another
+ // transmit operation
//
- pPort = pSocket->pPortList;
- if ( NULL != pPort ) {
+ pTxBytes = &pSocket->TxBytes;
+ if ( pSocket->MaxTxBuf > *pTxBytes ) {
//
- // Determine the queue head
+ // Locate the port
//
- pUdp4 = &pPort->Context.Udp4;
- pTxBytes = &pSocket->TxBytes;
+ pPort = pSocket->pPortList;
+ while ( NULL != pPort ) {
+ //
+ // Determine the queue head
+ //
+ pUdp4 = &pPort->Context.Udp4;
- //
- // Verify that there is enough room to buffer another
- // transmit operation
- //
- if ( pSocket->MaxTxBuf > *pTxBytes ) {
//
// Attempt to allocate the packet
//
@@ -927,6 +923,7 @@ EslUdp4TxBuffer (
// Free the packet
//
EslSocketPacketFree ( pPacket, DEBUG_TX );
+ break;
}
//
@@ -939,16 +936,22 @@ EslUdp4TxBuffer (
// Packet allocation failed
//
pSocket->errno = ENOMEM;
+ break;
}
- }
- else {
+
//
- // Not enough buffer space available
+ // Set the next port
//
- pSocket->errno = EAGAIN;
- Status = EFI_NOT_READY;
+ pPort = pPort->pLinkSocket;
}
}
+ else {
+ //
+ // Not enough buffer space available
+ //
+ pSocket->errno = EAGAIN;
+ Status = EFI_NOT_READY;
+ }
}
//
diff --git a/edk2/StdLib/EfiSocketLib/Udp6.c b/edk2/StdLib/EfiSocketLib/Udp6.c
index 9f47f1c73..7de500509 100644
--- a/edk2/StdLib/EfiSocketLib/Udp6.c
+++ b/edk2/StdLib/EfiSocketLib/Udp6.c
@@ -585,6 +585,7 @@ EslUdp6RxComplete (
//
// Fill in the port list if necessary
//
+ pSocket->errno = ENETDOWN;
if ( NULL == pSocket->pPortList ) {
ZeroMem ( &LocalAddress, sizeof ( LocalAddress ));
LocalAddress.sin6_len = sizeof ( LocalAddress );
@@ -657,34 +658,36 @@ EslUdp6RxComplete (
NULL );
}
if ( EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_LISTEN,
- "ERROR - Failed to configure the Udp6 port, Status: %r\r\n",
- Status ));
- switch ( Status ) {
- case EFI_ACCESS_DENIED:
- pSocket->errno = EACCES;
- break;
+ if ( !pSocket->bConfigured ) {
+ DEBUG (( DEBUG_LISTEN,
+ "ERROR - Failed to configure the Udp6 port, Status: %r\r\n",
+ Status ));
+ switch ( Status ) {
+ case EFI_ACCESS_DENIED:
+ pSocket->errno = EACCES;
+ break;
+
+ default:
+ case EFI_DEVICE_ERROR:
+ pSocket->errno = EIO;
+ break;
- default:
- case EFI_DEVICE_ERROR:
- pSocket->errno = EIO;
- break;
+ case EFI_INVALID_PARAMETER:
+ pSocket->errno = EADDRNOTAVAIL;
+ break;
- case EFI_INVALID_PARAMETER:
- pSocket->errno = EADDRNOTAVAIL;
- break;
+ case EFI_NO_MAPPING:
+ pSocket->errno = EAFNOSUPPORT;
+ break;
- case EFI_NO_MAPPING:
- pSocket->errno = EAFNOSUPPORT;
- break;
-
- case EFI_OUT_OF_RESOURCES:
- pSocket->errno = ENOBUFS;
- break;
+ case EFI_OUT_OF_RESOURCES:
+ pSocket->errno = ENOBUFS;
+ break;
- case EFI_UNSUPPORTED:
- pSocket->errno = EOPNOTSUPP;
- break;
+ case EFI_UNSUPPORTED:
+ pSocket->errno = EOPNOTSUPP;
+ break;
+ }
}
}
else {
@@ -726,6 +729,7 @@ EslUdp6RxComplete (
pConfigData->RemoteAddress.Addr[15],
pConfigData->RemotePort ));
pPort->bConfigured = TRUE;
+ pSocket->bConfigured = TRUE;
//
// Start the first read on the port
@@ -736,6 +740,7 @@ EslUdp6RxComplete (
// The socket is connected
//
pSocket->State = SOCKET_STATE_CONNECTED;
+ pSocket->errno = 0;
}
//
@@ -743,21 +748,12 @@ EslUdp6RxComplete (
//
pPort = pNextPort;
}
-
- //
- // Determine the configuration status
- //
- if ( NULL != pSocket->pPortList ) {
- pSocket->bConfigured = TRUE;
- }
}
//
// Determine the socket configuration status
//
- if ( !EFI_ERROR ( Status )) {
- Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
- }
+ Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;
//
// Return the port connected state.
@@ -839,21 +835,21 @@ EslUdp6TxBuffer (
//
if ( SOCKET_STATE_CONNECTED == pSocket->State ) {
//
- // Locate the port
+ // Verify that there is enough room to buffer another
+ // transmit operation
//
- pPort = pSocket->pPortList;
- if ( NULL != pPort ) {
+ pTxBytes = &pSocket->TxBytes;
+ if ( pSocket->MaxTxBuf > *pTxBytes ) {
//
- // Determine the queue head
+ // Locate the port
//
- pUdp6 = &pPort->Context.Udp6;
- pTxBytes = &pSocket->TxBytes;
+ pPort = pSocket->pPortList;
+ while ( NULL != pPort ) {
+ //
+ // Determine the queue head
+ //
+ pUdp6 = &pPort->Context.Udp6;
- //
- // Verify that there is enough room to buffer another
- // transmit operation
- //
- if ( pSocket->MaxTxBuf > *pTxBytes ) {
//
// Attempt to allocate the packet
//
@@ -964,6 +960,7 @@ EslUdp6TxBuffer (
// Free the packet
//
EslSocketPacketFree ( pPacket, DEBUG_TX );
+ break;
}
//
@@ -976,16 +973,22 @@ EslUdp6TxBuffer (
// Packet allocation failed
//
pSocket->errno = ENOMEM;
+ break;
}
- }
- else {
+
//
- // Not enough buffer space available
+ // Set the next port
//
- pSocket->errno = EAGAIN;
- Status = EFI_NOT_READY;
+ pPort = pPort->pLinkSocket;
}
}
+ else {
+ //
+ // Not enough buffer space available
+ //
+ pSocket->errno = EAGAIN;
+ Status = EFI_NOT_READY;
+ }
}
//
diff --git a/edk2/StdLib/EfiSocketLib/UseEfiSocketLib.c b/edk2/StdLib/EfiSocketLib/UseEfiSocketLib.c
index ed72e8e76..e44a72043 100644
--- a/edk2/StdLib/EfiSocketLib/UseEfiSocketLib.c
+++ b/edk2/StdLib/EfiSocketLib/UseEfiSocketLib.c
@@ -23,7 +23,7 @@
Tag GUID - IPv4 in use by an application using EfiSocketLib
**/
-CONST EFI_GUID mEslIp4ServiceGuid = {
+CONST EFI_GUID mEslIp4ServiceGuid __attribute__((weak)) = {
0x9c756011, 0x5d44, 0x4ee0, { 0xbc, 0xe7, 0xc3, 0x82, 0x18, 0xfe, 0x39, 0x8d }
};
@@ -31,7 +31,7 @@ CONST EFI_GUID mEslIp4ServiceGuid = {
/**
Tag GUID - IPv6 in use by an application using EfiSocketLib
**/
-CONST EFI_GUID mEslIp6ServiceGuid = {
+CONST EFI_GUID mEslIp6ServiceGuid __attribute__((weak)) = {
0xc51b2761, 0xc476, 0x45fe, { 0xbe, 0x61, 0xba, 0x4b, 0xcc, 0x32, 0xf2, 0x34 }
};
@@ -39,7 +39,7 @@ CONST EFI_GUID mEslIp6ServiceGuid = {
/**
Tag GUID - TCPv4 in use by an application using EfiSocketLib
**/
-CONST EFI_GUID mEslTcp4ServiceGuid = {
+CONST EFI_GUID mEslTcp4ServiceGuid __attribute__((weak)) = {
0xffc659c2, 0x4ef2, 0x4532, { 0xb8, 0x75, 0xcd, 0x9a, 0xa4, 0x27, 0x4c, 0xde }
};
@@ -47,7 +47,7 @@ CONST EFI_GUID mEslTcp4ServiceGuid = {
/**
Tag GUID - TCPv6 in use by an application using EfiSocketLib
**/
-CONST EFI_GUID mEslTcp6ServiceGuid = {
+CONST EFI_GUID mEslTcp6ServiceGuid __attribute__((weak)) = {
0x279858a4, 0x4e9e, 0x4e53, { 0x93, 0x22, 0xf2, 0x54, 0xe0, 0x7e, 0xef, 0xd4 }
};
@@ -55,7 +55,7 @@ CONST EFI_GUID mEslTcp6ServiceGuid = {
/**
Tag GUID - UDPv4 in use by an application using EfiSocketLib
**/
-CONST EFI_GUID mEslUdp4ServiceGuid = {
+CONST EFI_GUID mEslUdp4ServiceGuid __attribute__((weak)) = {
0x44e03a55, 0x8d97, 0x4511, { 0xbf, 0xef, 0xa, 0x8b, 0xc6, 0x2c, 0x25, 0xae }
};
@@ -63,7 +63,7 @@ CONST EFI_GUID mEslUdp4ServiceGuid = {
/**
Tag GUID - UDPv6 in use by an application using EfiSocketLib
**/
-CONST EFI_GUID mEslUdp6ServiceGuid = {
+CONST EFI_GUID mEslUdp6ServiceGuid __attribute__((weak)) = {
0xaa4af677, 0x6efe, 0x477c, { 0x96, 0x68, 0xe8, 0x13, 0x9d, 0x2, 0xfd, 0x9b }
};
@@ -196,10 +196,17 @@ EslServiceNetworkConnect (
for ( Index = 0; HandleCount > Index; Index++ ) {
Status = EslServiceConnect ( gImageHandle,
pHandles[ Index ]);
- if ( EFI_ERROR ( Status )) {
- break;
+ if ( !EFI_ERROR ( Status )) {
+ bSomethingFound = TRUE;
+ }
+ else {
+ if ( EFI_OUT_OF_RESOURCES == Status ) {
+ //
+ // Pointless to continue without memory
+ //
+ break;
+ }
}
- bSomethingFound = TRUE;
}
//
@@ -320,7 +327,7 @@ EslServiceNetworkDisconnect (
/**
Socket layer's service binding protocol delcaration.
**/
-CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding = {
+CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding __attribute__((weak)) = {
NULL,
NULL
};
@@ -331,5 +338,5 @@ CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding = {
for any socket application that links against the EfiSocketLib.
Note that the SocketDxe driver uses different redirection.
**/
-PFN_ESL_xSTRUCTOR mpfnEslConstructor = EslServiceNetworkConnect; ///< Constructor for EfiSocketLib
-PFN_ESL_xSTRUCTOR mpfnEslDestructor = EslServiceNetworkDisconnect; ///< Destructor for EfiSocketLib
+PFN_ESL_xSTRUCTOR mpfnEslConstructor __attribute__((weak)) = EslServiceNetworkConnect; ///< Constructor for EfiSocketLib
+PFN_ESL_xSTRUCTOR mpfnEslDestructor __attribute__((weak)) = EslServiceNetworkDisconnect; ///< Destructor for EfiSocketLib
diff --git a/edk2/StdLib/Include/Arm/machine/ansi.h b/edk2/StdLib/Include/Arm/machine/ansi.h
index 4c9e65a3b..8273905cd 100644
--- a/edk2/StdLib/Include/Arm/machine/ansi.h
+++ b/edk2/StdLib/Include/Arm/machine/ansi.h
@@ -1,6 +1,15 @@
-/* $NetBSD: ansi.h,v 1.7 2006/10/04 13:51:59 tnozaki Exp $ */
+/** @file
+ Machine dependent ANSI type definitions.
+
+ Copyright (c) 2010-2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License that accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-/*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -29,8 +38,8 @@
* SUCH DAMAGE.
*
* from: @(#)ansi.h 8.2 (Berkeley) 1/4/94
- */
-
+ NetBSD: ansi.h,v 1.7 2006/10/04 13:51:59 tnozaki Exp
+**/
#ifndef _ANSI_H_
#define _ANSI_H_
@@ -85,9 +94,12 @@
* mbstate_t is an opaque object to keep conversion state, during multibyte
* stream conversions. The content must not be referenced by user programs.
*/
-typedef union {
- __int64_t __mbstateL; /* for alignment */
- char __mbstate8[128];
+typedef struct {
+ UINT32 A; // Np;
+ UINT32 B; // U;
+ UINT32 E; // L
+ UINT8 C[4]; // n[4]
+ UINT16 D[2]; // w[2]
} __mbstate_t;
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
diff --git a/edk2/StdLib/Include/Ia32/machine/ansi.h b/edk2/StdLib/Include/Ia32/machine/ansi.h
index 5872eb369..6ef0a740c 100644
--- a/edk2/StdLib/Include/Ia32/machine/ansi.h
+++ b/edk2/StdLib/Include/Ia32/machine/ansi.h
@@ -1,8 +1,17 @@
-/* $NetBSD: ansi.h,v 1.19 2006/10/04 13:52:00 tnozaki Exp $ */
+/** @file
+ Machine dependent ANSI type definitions.
+
+ Copyright (c) 2010-2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License that accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-/*-
* Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,11 +37,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)ansi.h 8.2 (Berkeley) 1/4/94
+ * @(#)ansi.h 8.2 (Berkeley) 1/4/94
+ NetBSD: ansi.h,v 1.19 2006/10/04 13:52:00 tnozaki Exp
*/
-
-#ifndef _ANSI_H_
-#define _ANSI_H_
+#ifndef _ANSI_H_
+#define _ANSI_H_
#include <sys/EfiCdefs.h>
@@ -42,10 +51,10 @@
* Types which are fundamental to the implementation and may appear in
* more than one standard header are defined here. Standard headers
* then use:
- * #ifdef _BSD_SIZE_T_
- * typedef _BSD_SIZE_T_ size_t;
- * #undef _BSD_SIZE_T_
- * #endif
+ * #ifdef _BSD_SIZE_T_
+ * typedef _BSD_SIZE_T_ size_t;
+ * #undef _BSD_SIZE_T_
+ * #endif
*/
#define _BSD_CLOCK_T_ _EFI_CLOCK_T /* clock() */
#define _BSD_PTRDIFF_T_ _EFI_PTRDIFF_T_ /* ptr1 - ptr2 */
@@ -70,7 +79,7 @@
* chosen over a long is that the is*() and to*() routines take ints (says
* ANSI C), but they use _RUNE_T_ instead of int. By changing it here, you
* lose a bit of ANSI conformance, but your programs will still work.
- *
+ *
* Note that _WCHAR_T_ and _RUNE_T_ must be of the same type. When wchar_t
* and rune_t are typedef'd, _WCHAR_T_ will be undef'd, but _RUNE_T remains
* defined for ctype.h.
@@ -78,17 +87,20 @@
#define _BSD_WCHAR_T_ _EFI_WCHAR_T /* wchar_t */
#define _BSD_WINT_T_ _EFI_WINT_T /* wint_t */
#define _BSD_RUNE_T_ _EFI_WCHAR_T /* rune_t */
-#define _BSD_WCTRANS_T_ void * /* wctrans_t */
+#define _BSD_WCTRANS_T_ void * /* wctrans_t */
#define _BSD_WCTYPE_T_ unsigned int /* wctype_t */
/*
* mbstate_t is an opaque object to keep conversion state, during multibyte
* stream conversions. The content must not be referenced by user programs.
*/
-typedef union {
- __int64_t __mbstateL; /* for alignment */
- char __mbstate8[128];
+typedef struct {
+ UINT32 A; // Np;
+ UINT32 B; // U;
+ UINT32 E; // L
+ UINT8 C[4]; // n[4]
+ UINT16 D[2]; // w[2]
} __mbstate_t;
-#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
+#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
-#endif /* _ANSI_H_ */
+#endif /* _ANSI_H_ */
diff --git a/edk2/StdLib/Include/Ia32/machine/param.h b/edk2/StdLib/Include/Ia32/machine/param.h
index 72da83f48..9b57a32af 100644
--- a/edk2/StdLib/Include/Ia32/machine/param.h
+++ b/edk2/StdLib/Include/Ia32/machine/param.h
@@ -1,6 +1,15 @@
-/* $NetBSD: param.h,v 1.61 2006/08/28 13:43:35 yamt Exp $ */
+/** @file
+ Machine dependent constants for Intel IA32 Architecture.
+
+ Copyright (c) 2010-2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
@@ -31,29 +40,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)param.h 5.8 (Berkeley) 6/28/91
+ * @(#)param.h 5.8 (Berkeley) 6/28/91
+ * $NetBSD: param.h,v 1.61 2006/08/28 13:43:35 yamt Exp
*/
-
#ifndef _I386_PARAM_H_
#define _I386_PARAM_H_
-/*
- * Machine dependent constants for Intel 386.
- */
-
-#ifdef _KERNEL
-#ifdef _LOCORE
-#include <machine/psl.h>
-#else
-#include <machine/cpu.h>
-#endif
-#endif
-
-#define _MACHINE i386
-#define MACHINE "i386"
-#define _MACHINE_ARCH i386
-#define MACHINE_ARCH "i386"
-#define MID_MACHINE MID_I386
+#define _MACHINE i386
+#define MACHINE "i386"
+#define _MACHINE_ARCH i386
+#define MACHINE_ARCH "i386"
+#define MID_MACHINE MID_I386
/*
* Round p (pointer or byte index) up to a correctly-aligned value
@@ -63,58 +60,39 @@
* ALIGNED_POINTER is a boolean macro that checks whether an address
* is valid to fetch data elements of type t from on this architecture.
* This does not reflect the optimal alignment, just the possibility
- * (within reasonable limits).
+ * (within reasonable limits).
*
*/
-#define ALIGNBYTES (sizeof(int) - 1)
-#define ALIGN(p) (((u_int)(u_long)(p) + ALIGNBYTES) &~ \
- ALIGNBYTES)
-#define ALIGNED_POINTER(p,t) 1
-
-#define PGSHIFT 12 /* LOG2(NBPG) */
-#define NBPG (1 << PGSHIFT) /* bytes/page */
-#define PGOFSET (NBPG-1) /* byte offset into page */
-#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
-
-#if defined(_KERNEL_OPT)
-#include "opt_kernbase.h"
-#endif /* defined(_KERNEL_OPT) */
-
-#ifdef KERNBASE_LOCORE
-#error "You should only re-define KERNBASE"
+#define ALIGNBYTES (sizeof(int) - 1)
+#define ALIGN(p) (((EFI_ULONG_T)(p) + ALIGNBYTES) & ~ALIGNBYTES)
+#define ALIGNED_POINTER(p,t) 1
+
+#define PGSHIFT 12 /* LOG2(NBPG) */
+#define NBPG (1 << PGSHIFT) /* bytes/page */
+#define PGOFSET (NBPG-1) /* byte offset into page */
+#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
+
+#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
+#define DEV_BSIZE (1 << DEV_BSHIFT)
+#define BLKDEV_IOSIZE 2048
+#ifndef MAXPHYS
+ #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
#endif
-#ifndef KERNBASE
-#define KERNBASE 0xc0000000UL /* start of kernel virtual space */
-#endif
-
-#define KERNTEXTOFF (KERNBASE + 0x100000) /* start of kernel text */
-#define BTOPKERNBASE (KERNBASE >> PGSHIFT)
-
-#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
-#define DEV_BSIZE (1 << DEV_BSHIFT)
-#define BLKDEV_IOSIZE 2048
-#ifndef MAXPHYS
-#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
-#endif
-
-#define SSIZE 1 /* initial stack size/NBPG */
-#define SINCR 1 /* increment of stack/NBPG */
+#define SSIZE 1 /* initial stack size/NBPG */
+#define SINCR 1 /* increment of stack/NBPG */
-#ifdef _KERNEL_OPT
-#include "opt_noredzone.h"
-#endif
#ifndef UPAGES
-#ifdef NOREDZONE
-#define UPAGES 2 /* pages of u-area */
-#else
-#define UPAGES 3
-#endif /*NOREDZONE */
+ #ifdef NOREDZONE
+ #define UPAGES 2 /* pages of u-area */
+ #else
+ #define UPAGES 3
+ #endif /*NOREDZONE */
#endif /* !defined(UPAGES) */
-#define USPACE (UPAGES * NBPG) /* total size of u-area */
+#define USPACE (UPAGES * NBPG) /* total size of u-area */
#ifndef MSGBUFSIZE
-#define MSGBUFSIZE 4*NBPG /* default message buffer size */
+ #define MSGBUFSIZE 4*NBPG /* default message buffer size */
#endif
/*
@@ -124,51 +102,47 @@
* clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
* of the hardware page size.
*/
-#define MSIZE 256 /* size of an mbuf */
+#define MSIZE 256 /* size of an mbuf */
#ifndef MCLSHIFT
-#define MCLSHIFT 11 /* convert bytes to m_buf clusters */
- /* 2K cluster can hold Ether frame */
-#endif /* MCLSHIFT */
+ #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
+ /* 2K cluster can hold Ether frame */
+#endif /* MCLSHIFT */
-#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
+#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
#ifndef NMBCLUSTERS
-#if defined(_KERNEL_OPT)
-#include "opt_gateway.h"
-#endif
-
-#ifdef GATEWAY
-#define NMBCLUSTERS 2048 /* map size, max cluster allocation */
-#else
-#define NMBCLUSTERS 1024 /* map size, max cluster allocation */
-#endif
+ #ifdef GATEWAY
+ #define NMBCLUSTERS 2048 /* map size, max cluster allocation */
+ #else
+ #define NMBCLUSTERS 1024 /* map size, max cluster allocation */
+ #endif
#endif
#ifndef NFS_RSIZE
-#define NFS_RSIZE 32768
+ #define NFS_RSIZE 32768
#endif
#ifndef NFS_WSIZE
-#define NFS_WSIZE 32768
+ #define NFS_WSIZE 32768
#endif
/*
* Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
* logical pages.
*/
-#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT)
-#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT)
+#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT)
+#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT)
/*
* Mach derived conversion macros
*/
-#define x86_round_pdr(x) ((((unsigned)(x)) + PDOFSET) & ~PDOFSET)
-#define x86_trunc_pdr(x) ((unsigned)(x) & ~PDOFSET)
-#define x86_btod(x) ((unsigned)(x) >> PDSHIFT)
-#define x86_dtob(x) ((unsigned)(x) << PDSHIFT)
-#define x86_round_page(x) ((((unsigned)(x)) + PGOFSET) & ~PGOFSET)
-#define x86_trunc_page(x) ((unsigned)(x) & ~PGOFSET)
-#define x86_btop(x) ((unsigned)(x) >> PGSHIFT)
-#define x86_ptob(x) ((unsigned)(x) << PGSHIFT)
+#define x86_round_pdr(x) ((((EFI_ULONG_T)(x)) + PDOFSET) & ~PDOFSET)
+#define x86_trunc_pdr(x) ((EFI_ULONG_T)(x) & ~PDOFSET)
+#define x86_btod(x) ((EFI_ULONG_T)(x) >> PDSHIFT)
+#define x86_dtob(x) ((EFI_ULONG_T)(x) << PDSHIFT)
+#define x86_round_page(x) ((((EFI_ULONG_T)(x)) + PGOFSET) & ~PGOFSET)
+#define x86_trunc_page(x) ((EFI_ULONG_T)(x) & ~PGOFSET)
+#define x86_btop(x) ((EFI_ULONG_T)(x) >> PGSHIFT)
+#define x86_ptob(x) ((EFI_ULONG_T)(x) << PGSHIFT)
#endif /* _I386_PARAM_H_ */
diff --git a/edk2/StdLib/Include/Ipf/machine/ansi.h b/edk2/StdLib/Include/Ipf/machine/ansi.h
index 07a200871..bab41b040 100644
--- a/edk2/StdLib/Include/Ipf/machine/ansi.h
+++ b/edk2/StdLib/Include/Ipf/machine/ansi.h
@@ -1,6 +1,15 @@
-/* $NetBSD: ansi.h,v 1.3 2006/10/04 13:52:00 tnozaki Exp $ */
+/** @file
+ Machine dependent ANSI type definitions.
+
+ Copyright (c) 2010-2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License that accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -29,8 +38,8 @@
* SUCH DAMAGE.
*
* @(#)ansi.h 8.2 (Berkeley) 1/4/94
+ NetBSD: ansi.h,v 1.3 2006/10/04 13:52:00 tnozaki Exp
*/
-
#ifndef _ANSI_H_
#define _ANSI_H_
@@ -86,9 +95,12 @@
* mbstate_t is an opaque object to keep conversion state, during multibyte
* stream conversions. The content must not be referenced by user programs.
*/
-typedef union {
- __int64_t __mbstateL; /* for alignment */
- char __mbstate8[128];
+typedef struct {
+ UINT32 A; // Np;
+ UINT32 B; // U;
+ UINT32 E; // L
+ UINT8 C[4]; // n[4]
+ UINT16 D[2]; // w[2]
} __mbstate_t;
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
diff --git a/edk2/StdLib/Include/Ipf/machine/param.h b/edk2/StdLib/Include/Ipf/machine/param.h
index 1d7180606..c832f3487 100644
--- a/edk2/StdLib/Include/Ipf/machine/param.h
+++ b/edk2/StdLib/Include/Ipf/machine/param.h
@@ -1,6 +1,15 @@
-/* $NetBSD: param.h,v 1.2 2006/08/28 13:43:35 yamt Exp $ */
+/** @file
+ Machine dependent constants for Intel Itanium Architecture(IPF).
+
+ Copyright (c) 2010-2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
@@ -31,47 +40,43 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)param.h 5.8 (Berkeley) 6/28/91
+ * @(#)param.h 5.8 (Berkeley) 6/28/91
+ * $NetBSD: param.h,v 1.2 2006/08/28 13:43:35 yamt Exp
*/
-
#ifndef _IA64_PARAM_H_
#define _IA64_PARAM_H_
-/*
- * Machine dependent constants for Intel Itanium.
- */
-
-#define _MACHINE ia64
-#define MACHINE "ia64"
-#define _MACHINE_ARCH ia64
-#define MACHINE_ARCH "ia64"
-#define MID_MACHINE MID_IA64
+#define _MACHINE ia64
+#define MACHINE "ia64"
+#define _MACHINE_ARCH ia64
+#define MACHINE_ARCH "ia64"
+#define MID_MACHINE MID_IA64
#ifdef SMP
-#define MAXCPU 16
+#define MAXCPU 512
#else
-#define MAXCPU 1
+#define MAXCPU 1
#endif
-#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
-#define DEV_BSIZE (1<<DEV_BSHIFT)
-#define BLKDEV_IOSIZE 2048
+#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
+#define DEV_BSIZE (1<<DEV_BSHIFT)
+#define BLKDEV_IOSIZE 2048
#ifndef MAXPHYS
-#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
+#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
#endif
-#define UPAGES 4
-#define USPACE (UPAGES * NBPG) /* total size of u-area */
+#define UPAGES 4
+#define USPACE (UPAGES * NBPG) /* total size of u-area */
#ifndef MSGBUFSIZE
-#define MSGBUFSIZE NBPG /* default message buffer size */
+#define MSGBUFSIZE NBPG /* default message buffer size */
#endif
-#ifndef KSTACK_PAGES
-#define KSTACK_PAGES 4 /* pages of kernel stack */
+#ifndef KSTACK_PAGES
+#define KSTACK_PAGES 4 /* pages of kernel stack */
#endif
-#define KSTACK_GUARD_PAGES 0 /* pages of kstack guard; 0 disables */
+#define KSTACK_GUARD_PAGES 0 /* pages of kstack guard; 0 disables */
/*
* Round p (pointer or byte index) up to a correctly-aligned value
@@ -81,21 +86,21 @@
* ALIGNED_POINTER is a boolean macro that checks whether an address
* is valid to fetch data elements of type t from on this architecture.
* This does not reflect the optimal alignment, just the possibility
- * (within reasonable limits).
+ * (within reasonable limits).
*
*/
-#define ALIGNBYTES 15
-#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
+#define ALIGNBYTES 15
+#define ALIGN(p) (((UINT64)(p) + ALIGNBYTES) &~ ALIGNBYTES)
+#define ALIGNED_POINTER(p,t) ((((UINT64)(p)) & (sizeof(t)-1)) == 0)
-#define ALIGNBYTES32 (sizeof(int) - 1)
-#define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
+#define ALIGNBYTES32 (sizeof(INT32) - 1)
+#define ALIGN32(p) (((UINT64)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
-#define PGSHIFT 14 /* LOG2(NBPG) */
-#define NBPG (1 << PGSHIFT) /* bytes/page */
-#define PGOFSET (NBPG-1) /* byte offset into page */
-#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
+#define PGSHIFT 14 /* LOG2(NBPG) */
+#define NBPG (1 << PGSHIFT) /* bytes/page */
+#define PGOFSET (NBPG-1) /* byte offset into page */
+#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than NBPG (the software page size), and,
@@ -103,24 +108,19 @@
* clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
* of the hardware page size.
*/
-#define MSIZE 256 /* size of an mbuf */
+#define MSIZE 256 /* size of an mbuf */
#ifndef MCLSHIFT
-#define MCLSHIFT 11 /* convert bytes to m_buf clusters */
- /* 2K cluster can hold Ether frame */
-#endif /* MCLSHIFT */
-
-#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
+ #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
+ /* 2K cluster can hold Ether frame */
+#endif /* MCLSHIFT */
-#ifndef NMBCLUSTERS
-#if defined(_KERNEL_OPT)
-#include "opt_gateway.h"
-#endif
+#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
#ifdef GATEWAY
-#define NMBCLUSTERS 2048 /* map size, max cluster allocation */
+ #define NMBCLUSTERS 2048 /* map size, max cluster allocation */
#else
-#define NMBCLUSTERS 1024 /* map size, max cluster allocation */
+ #define NMBCLUSTERS 1024 /* map size, max cluster allocation */
#endif
#endif
@@ -128,25 +128,17 @@
* Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
* logical pages.
*/
-#define NKMEMPAGES_MIN_DEFAULT ((12 * 1024 * 1024) >> PAGE_SHIFT)
-#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT)
+#define NKMEMPAGES_MIN_DEFAULT ((12 * 1024 * 1024) >> PAGE_SHIFT)
+#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT)
/*
* Mach derived conversion macros
*/
-#define ia64_round_page(x) ((((unsigned long)(x)) + NBPG - 1) & ~(NBPG - 1))
-#define ia64_trunc_page(x) ((unsigned long)(x) & ~(NBPG - 1))
-
-#define ia64_btop(x) ((unsigned long)(x) >> PGSHIFT)
-#define ia64_ptob(x) ((unsigned long)(x) << PGSHIFT)
-
-#ifdef _KERNEL
-#ifndef _LOCORE
-
-#include <machine/intr.h>
+#define ia64_round_page(x) ((((EFI_ULONG_T)(x)) + NBPG - 1) & ~(NBPG - 1))
+#define ia64_trunc_page(x) ((EFI_ULONG_T)(x) & ~(NBPG - 1))
-#endif /* _LOCORE */
-#endif /* _KERNEL */
+#define ia64_btop(x) ((EFI_ULONG_T)(x) >> PGSHIFT)
+#define ia64_ptob(x) ((EFI_ULONG_T)(x) << PGSHIFT)
#endif /* _IA64_PARAM_H_ */
diff --git a/edk2/StdLib/Include/X64/machine/ansi.h b/edk2/StdLib/Include/X64/machine/ansi.h
index 1d276f608..e6ff195a8 100644
--- a/edk2/StdLib/Include/X64/machine/ansi.h
+++ b/edk2/StdLib/Include/X64/machine/ansi.h
@@ -1,7 +1,7 @@
/** @file
Machine dependent ANSI type definitions.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010-2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
@@ -94,9 +94,12 @@
* mbstate_t is an opaque object to keep conversion state, during multibyte
* stream conversions. The content must not be referenced by user programs.
*/
-typedef union {
- __int64_t __mbstateL; /* for alignment */
- char __mbstate8[128];
+typedef struct {
+ UINT32 A; // Np;
+ UINT32 B; // U;
+ UINT32 E; // L
+ UINT8 C[4]; // n[4]
+ UINT16 D[2]; // w[2]
} __mbstate_t;
#define _BSD_MBSTATE_T_ __mbstate_t /* mbstate_t */
diff --git a/edk2/StdLib/Include/X64/machine/param.h b/edk2/StdLib/Include/X64/machine/param.h
index abb979003..852690902 100644
--- a/edk2/StdLib/Include/X64/machine/param.h
+++ b/edk2/StdLib/Include/X64/machine/param.h
@@ -1,10 +1,25 @@
-/* $NetBSD: param.h,v 1.3 2006/08/28 13:43:35 yamt Exp $ */
+/** @file
+ Machine dependent constants for the Intel64 Architecture(X64).
-#define _MACHINE amd64
-#define MACHINE "amd64"
+ Copyright (c) 2010-2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ * $NetBSD: param.h,v 1.3 2006/08/28 13:43:35 yamt Exp
+**/
+#ifndef _X64_PARAM_H_
+#define _X64_PARAM_H_
+
+#define _MACHINE amd64
+#define MACHINE "amd64"
#define _MACHINE_ARCH x86_64
#define MACHINE_ARCH "x86_64"
-#define MID_MACHINE MID_X86_64
+#define MID_MACHINE MID_X86_64
/*
* Round p (pointer or byte index) up to a correctly-aligned value
@@ -17,46 +32,32 @@
* (within reasonable limits).
*
*/
-#define ALIGNBYTES (sizeof(INT64) - 1)
-#define ALIGN(p) (((UINT64)(p) + ALIGNBYTES) &~ALIGNBYTES)
+#define ALIGNBYTES (sizeof(INT64) - 1)
+#define ALIGN(p) (((UINT64)(p) + ALIGNBYTES) &~ALIGNBYTES)
#define ALIGNED_POINTER(p,t) 1
-#define ALIGNBYTES32 (sizeof(INT32) - 1)
-#define ALIGN32(p) (((UINT32)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
-
-#define PGSHIFT 12 /* LOG2(NBPG) */
-#define NBPG (1 << PGSHIFT) /* bytes/page */
-#define PGOFSET (NBPG-1) /* byte offset into page */
-#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
-
-/*
- * XXXfvdl change this (after bootstrap) to take # of bits from
- * config info into account.
- */
-#define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */
-#define KERNTEXTOFF 0xffffffff80100000 /* start of kernel text */
-#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
-
-#define KERNTEXTOFF_HI 0xffffffff
-#define KERNTEXTOFF_LO 0x80100000
+#define ALIGNBYTES32 (sizeof(INT32) - 1)
+#define ALIGN32(p) (((UINT64)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
-#define KERNBASE_HI 0xffffffff
-#define KERNBASE_LO 0x80000000
+#define PGSHIFT 12 /* LOG2(NBPG) */
+#define NBPG (1 << PGSHIFT) /* bytes/page */
+#define PGOFSET (NBPG-1) /* byte offset into page */
+#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
-#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
-#define DEV_BSIZE (1 << DEV_BSHIFT)
+#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
+#define DEV_BSIZE (1 << DEV_BSHIFT)
#define BLKDEV_IOSIZE 2048
#ifndef MAXPHYS
-#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
+ #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
#endif
-#define SSIZE 1 /* initial stack size/NBPG */
-#define SINCR 1 /* increment of stack/NBPG */
-#define UPAGES 5 /* pages of u-area */
-#define USPACE (UPAGES * NBPG) /* total size of u-area */
+#define SSIZE 1 /* initial stack size/NBPG */
+#define SINCR 1 /* increment of stack/NBPG */
+#define UPAGES 5 /* pages of u-area */
+#define USPACE (UPAGES * NBPG) /* total size of u-area */
#ifndef MSGBUFSIZE
-#define MSGBUFSIZE 4*NBPG /* default message buffer size */
+ #define MSGBUFSIZE 4*NBPG /* default message buffer size */
#endif
/*
@@ -66,14 +67,14 @@
* clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
* of the hardware page size.
*/
-#define MSIZE 512 /* size of an mbuf */
+#define MSIZE 512 /* size of an mbuf */
#ifndef MCLSHIFT
-#define MCLSHIFT 11 /* convert bytes to m_buf clusters */
- /* 2K cluster can hold Ether frame */
+ #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
+ /* 2K cluster can hold Ether frame */
#endif /* MCLSHIFT */
-#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
+#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
#ifndef NMBCLUSTERS
#ifdef GATEWAY
@@ -84,39 +85,21 @@
#endif
#ifndef NFS_RSIZE
- #define NFS_RSIZE 32768
+ #define NFS_RSIZE 32768
#endif
#ifndef NFS_WSIZE
- #define NFS_WSIZE 32768
+ #define NFS_WSIZE 32768
#endif
-/*
- * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
- * logical pages.
- */
-//#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT)
-//#define NKMEMPAGES_MAX_DEFAULT ((1 *1024 * 1024 * 1024) >> PAGE_SHIFT)
+#define x86_round_page(x) ((((EFI_ULONG_T)(x)) + PGOFSET) & ~PGOFSET)
+#define x86_trunc_page(x) ((EFI_ULONG_T)(x) & ~PGOFSET)
+#define x86_btop(x) ((EFI_ULONG_T)(x) >> PGSHIFT)
+#define x86_ptob(x) ((EFI_ULONG_T)(x) << PGSHIFT)
-/*
- * XXXfvdl the PD* stuff is different from i386.
- */
-/*
- * Mach derived conversion macros
- */
-#ifdef MACH_DCM
- #define x86_round_pdr(x) ((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1))
- #define x86_trunc_pdr(x) ((unsigned long)(x) & ~(NBPD_L2 - 1))
- #define x86_btod(x) ((unsigned long)(x) >> L2_SHIFT)
- #define x86_dtob(x) ((unsigned long)(x) << L2_SHIFT)
-#endif // MACH_DCM
-
-#define x86_round_page(x) ((((ULONG32)(x)) + PGOFSET) & ~PGOFSET)
-#define x86_trunc_page(x) ((ULONG32)(x) & ~PGOFSET)
-#define x86_btop(x) ((ULONG32)(x) >> PGSHIFT)
-#define x86_ptob(x) ((ULONG32)(x) << PGSHIFT)
-
-#define btop(x) x86_btop(x)
-#define ptob(x) x86_ptob(x)
+#define btop(x) x86_btop(x)
+#define ptob(x) x86_ptob(x)
#define round_pdr(x) x86_round_pdr(x)
#define mstohz(ms) ((ms + 0UL) * hz / 1000)
+
+#endif /* _X64_PARAM_H_ */
diff --git a/edk2/StdLib/Include/limits.h b/edk2/StdLib/Include/limits.h
index 4fceca201..5da4032f0 100644
--- a/edk2/StdLib/Include/limits.h
+++ b/edk2/StdLib/Include/limits.h
@@ -8,7 +8,7 @@
type as would an expression that is an object of the corresponding type
converted according to the integer promotions.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -28,7 +28,7 @@
/* Define the values required by the ISO/IEC 9899 Specification. */
/** Maximum number of bytes in a multibyte character, for any supported locale. **/
-#define MB_LEN_MAX 2 /* 16-bit UTC-2 */
+#define MB_LEN_MAX 4 /* UTF-8 can require up to 4 bytes */
/** Number of bits comprising the smallest object that is not a bit-field (byte). **/
#define CHAR_BIT __CHAR_BIT
diff --git a/edk2/StdLib/Include/stdarg.h b/edk2/StdLib/Include/stdarg.h
index b9de36423..9a30e28fb 100644
--- a/edk2/StdLib/Include/stdarg.h
+++ b/edk2/StdLib/Include/stdarg.h
@@ -20,7 +20,7 @@
function accepting a varying number of arguments, if access to the varying
arguments is desired.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -134,4 +134,13 @@ typedef __builtin_va_list va_list;
#endif
/*@}*/
+/** Provide a generic version of the compiler-dependent __va_copy macro.
+ Some software, such as Python 2.7.2, relies upon the existence of __va_copy.
+ If this macro is not defined, it just assigns one va_list item to another.
+ This breaks for compiler environments that define va_list as an array or structure.
+**/
+#ifndef __va_copy
+ #define __va_copy va_copy
+#endif
+
#endif /* _STDARG_H */
diff --git a/edk2/StdLib/Include/stdio.h b/edk2/StdLib/Include/stdio.h
index 59022666b..c0a4deb78 100644
--- a/edk2/StdLib/Include/stdio.h
+++ b/edk2/StdLib/Include/stdio.h
@@ -105,7 +105,7 @@
by a three-character attempt at a mnemonic.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -243,8 +243,8 @@ typedef struct __sFILE {
/*@}*/
/* tricks to meet minimum requirements even when malloc() fails */
- unsigned char _ubuf[3]; /**< guarantee an ungetc() buffer */
- unsigned char _nbuf[1]; /**< guarantee a getc() buffer */
+ unsigned char _ubuf[3 * MB_LEN_MAX]; /**< guarantee an ungetc() buffer */
+ unsigned char _nbuf[1 * MB_LEN_MAX]; /**< guarantee a getc() buffer */
/** separate buffer for fgetln() when line crosses buffer boundary */
struct __sbuf _lb; /* buffer for fgetln() */
diff --git a/edk2/StdLib/Include/stdlib.h b/edk2/StdLib/Include/stdlib.h
index 116684786..0b9dfd34b 100644
--- a/edk2/StdLib/Include/stdlib.h
+++ b/edk2/StdLib/Include/stdlib.h
@@ -101,7 +101,7 @@
char ** __restrict endptr);
@endverbatim
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -166,8 +166,11 @@ typedef struct {
maximum number of bytes in a multibyte character for the extended character
set specified by the current locale (category LC_CTYPE), which is never
greater than MB_LEN_MAX.
+
+ Since UEFI only supports the Unicode Base Multilingual Plane (BMP),
+ correctly formed characters will only produce 1, 2, or 3-byte UTF-8 characters.
**/
-#define MB_CUR_MAX 2
+#define MB_CUR_MAX 3
/** Maximum number of functions that can be registered by atexit.
@@ -845,7 +848,7 @@ size_t mbstowcs(wchar_t * __restrict Dest, const char * __restrict Src, size_t
@param[out] Dest Pointer to the array to receive the converted string.
@param[in] Src Pointer to the string to be converted.
- @param[in] Limit Maximum number of elements to be written to Dest.
+ @param[in] Limit Maximum number of bytes to be written to Dest.
@return If a wide character is encountered that does not correspond to a
valid multibyte character, the wcstombs function returns
@@ -855,7 +858,7 @@ size_t mbstowcs(wchar_t * __restrict Dest, const char * __restrict Src, size_t
**/
size_t wcstombs(char * __restrict Dest, const wchar_t * __restrict Src, size_t Limit);
-/* ################ Miscelaneous functions for *nix compatibility ########## */
+/* ############## Miscelaneous functions for *nix compatibility ########## */
/** The realpath() function shall derive, from the pathname pointed to by
file_name, an absolute pathname that names the same file, whose resolution
@@ -890,6 +893,59 @@ const char * getprogname(void);
**/
void setprogname(const char *progname);
+/* ############### Functions specific to this implementation ############# */
+
+/* Determine the number of bytes needed to represent a Wide character
+ as a MBCS character.
+
+ A single wide character may convert into a one, two, three, or four byte
+ narrow (MBCS or UTF-8) character. The number of MBCS bytes can be determined
+ as follows.
+
+ If WCS char < 0x00000080 One Byte
+ Else if WCS char < 0x0000D800 Two Bytes
+ Else Three Bytes
+
+ Since UEFI only supports the Unicode Base Multilingual Plane (BMP),
+ Four-byte characters are not supported.
+
+ @param[in] InCh Wide character to test.
+
+ @retval -1 Improperly formed character
+ @retval 0 InCh is 0x0000
+ @retval >0 Number of bytes needed for the MBCS character
+*/
+int
+EFIAPI
+OneWcToMcLen(const wchar_t InCh);
+
+/* Determine the number of bytes needed to represent a Wide character string
+ as a MBCS string of given maximum length. Will optionally return the number
+ of wide characters that would be consumed.
+
+ @param[in] Src Pointer to a wide character string.
+ @param[in] Limit Maximum number of bytes the converted string may occupy.
+ @param[out] NumChar Pointer to where to store the number of wide characters, or NULL.
+
+ @return The number of bytes required to convert Src to MBCS,
+ not including the terminating NUL. If NumChar is not NULL, the number
+ of characters represented by the return value will be written to
+ where it points.
+**/
+size_t
+EFIAPI
+EstimateWtoM(const wchar_t * Src, size_t Limit, size_t *NumChar);
+
+/** Determine the number of characters in a MBCS string.
+
+ @param[in] Src The string to examine
+
+ @return The number of characters represented by the MBCS string.
+**/
+size_t
+EFIAPI
+CountMbcsChars(const char *Src);
+
__END_DECLS
#endif /* _STDLIB_H */
diff --git a/edk2/StdLib/Include/sys/EfiCdefs.h b/edk2/StdLib/Include/sys/EfiCdefs.h
index 812a495d9..c436ff365 100644
--- a/edk2/StdLib/Include/sys/EfiCdefs.h
+++ b/edk2/StdLib/Include/sys/EfiCdefs.h
@@ -22,7 +22,7 @@
This file and its contents are inspired by the <sys/cdefs.h> files in Berkeley
Unix. They have been re-implemented to be specific to the EFI environment.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -330,8 +330,17 @@
#error You must specify /Zc:wchar_t- to the compiler to turn off intrinsic wchar_t.
#endif
+ /* Get rid of pre-defined macros that are misleading in this environment. */
+ #undef _WIN32
+ #undef _WIN64
+
// Keep compiler quiet about casting from smaller to larger types
#pragma warning ( disable : 4306 )
+
+ #define __STDC__ 1
+ #define __STDC_VERSION__ 199409L
+ #define __STDC_HOSTED__ 1
+
#endif /* defined(_MSC_VER) */
extern int _fltused; // VC++ requires this if you use floating point. KEEP for all compilers.
@@ -344,8 +353,8 @@ typedef UINT32 ULONG32;
typedef INT64 LONG64;
typedef UINT64 ULONG64;
-typedef INT32 EFI_LONG_T;
-typedef UINT32 EFI_ULONG_T;
+typedef INTN EFI_LONG_T;
+typedef UINTN EFI_ULONG_T;
/* These types reflect the compiler's size for long */
#if defined(__GNUC__)
diff --git a/edk2/StdLib/Include/sys/EfiSysCall.h b/edk2/StdLib/Include/sys/EfiSysCall.h
index cbaf1d139..6f4742875 100644
--- a/edk2/StdLib/Include/sys/EfiSysCall.h
+++ b/edk2/StdLib/Include/sys/EfiSysCall.h
@@ -53,7 +53,7 @@
BOOLEAN ValidateFD (int fd, int IsOpen);
@endverbatim
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -333,4 +333,18 @@ __BEGIN_DECLS
int reboot (int, char *);
__END_DECLS
+/* The console output stream, stdout, supports cursor positioning via the
+ lseek() function call. The following entities facilitate packing the
+ X and Y coordinates into the offset parameter of the lseek call.
+*/
+typedef struct {
+ UINT32 Column;
+ UINT32 Row;
+} CURSOR_XY;
+
+typedef union {
+ UINT64 Offset;
+ CURSOR_XY XYpos;
+} XY_OFFSET;
+
#endif /* _EFI_SYS_CALL_H */
diff --git a/edk2/StdLib/Include/sys/fcntl.h b/edk2/StdLib/Include/sys/fcntl.h
index b91792f9f..819461b49 100644
--- a/edk2/StdLib/Include/sys/fcntl.h
+++ b/edk2/StdLib/Include/sys/fcntl.h
@@ -2,7 +2,7 @@
This file includes the definitions for open and fcntl described by POSIX
for <fcntl.h>; it also includes related kernel definitions.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made
available under the terms and conditions of the BSD License which
accompanies this distribution. The full text of the license may be found
@@ -72,14 +72,16 @@
#define O_TRUNC 0x00000400 ///< truncate to zero length
#define O_EXCL 0x00000800 ///< error if already exists
+#define O_DIRECTORY 0x00001000 ///< error if path is not a directory
+#define O_NOCTTY 0x00002000 ///< Don't make this the controlling TTY
+#define O_TTY_INIT 0x00004000 ///< Initialize TTY to "sane" values on open
+
/* UEFI-specific open-only flags. */
#define O_HIDDEN 0x00010000 ///< Hidden file attribute
#define O_SYSTEM 0x00020000 ///< System file attribute
#define O_ARCHIVE 0x00040000 ///< Archive file attribute
/// @}
-//#define O_DIRECT 0x00080000 /* direct I/O hint */
-
#define O_SETMASK 0x0000000F ///< Flags modifiable by F_SETFD (fcntl)
/*
diff --git a/edk2/StdLib/Include/sys/stat.h b/edk2/StdLib/Include/sys/stat.h
index 6c5d5a807..12520be83 100644
--- a/edk2/StdLib/Include/sys/stat.h
+++ b/edk2/StdLib/Include/sys/stat.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made
available under the terms and conditions of the BSD License that
accompanies this distribution. The full text of the license may be found at
@@ -90,16 +90,18 @@ struct stat {
/* The Octal access modes, above, fall into the Hex mask 0x00000FFF.
Traditionally, the remainder of the flags are specified in Octal
but they are expressed in Hex here for modern clarity.
+
+ The basic file types, specified within 0x0000F000, are mutually exclusive.
*/
#define _S_IFMT 0x000FF000 ///< type-of-file mask
#define _S_IFIFO 0x00001000 ///< named pipe (fifo)
-#define _S_IFCHR 0x00002000 ///< character special
+#define _S_IFCHR 0x00002000 ///< character special device
#define _S_IFDIR 0x00004000 ///< directory
-#define _S_IFBLK 0x00006000 ///< block special
+#define _S_IFBLK 0x00006000 ///< block special device
#define _S_IFREG 0x00008000 ///< regular
#define _S_IFSOCK 0x0000C000 ///< socket
#define _S_ITTY 0x00010000 ///< File connects to a TTY device
-#define _S_IWTTY 0x00020000 ///< TTY receives Wide characters
+#define _S_IWTTY 0x00020000 ///< TTY sends and receives Wide characters
#define _S_ICONSOLE 0x00030000 ///< UEFI Console Device
/* UEFI specific (FAT file system) File attributes.
diff --git a/edk2/StdLib/Include/sys/syslimits.h b/edk2/StdLib/Include/sys/syslimits.h
index bee810cc1..9515e8f57 100644
--- a/edk2/StdLib/Include/sys/syslimits.h
+++ b/edk2/StdLib/Include/sys/syslimits.h
@@ -1,7 +1,7 @@
/** @file
Platform specific values for <limits.h>.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -50,6 +50,7 @@
#define ARGC_MAX (64) ///< Maximum value for argc.
#define MAX_INPUT 255 ///< Maximum bytes in terminal input.
+#define MAX_OUTPUT 255 ///< Maximum bytes in terminal output.
#define NAME_MAX 255 ///< Maximum bytes in a file name.
#ifndef OPEN_MAX
#define OPEN_MAX 20 ///< Maximum open files per process.
diff --git a/edk2/StdLib/Include/sys/termios.h b/edk2/StdLib/Include/sys/termios.h
index b1373dea2..13e15d2fa 100644
--- a/edk2/StdLib/Include/sys/termios.h
+++ b/edk2/StdLib/Include/sys/termios.h
@@ -1,6 +1,16 @@
-/* $NetBSD: termios.h,v 1.29 2005/12/11 12:25:21 christos Exp $ */
+/** @file
+ Macros and declarations for terminal oriented ioctls and
+ I/O discipline.
+
+ Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-/*
* Copyright (c) 1988, 1989, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
@@ -29,123 +39,95 @@
* SUCH DAMAGE.
*
* @(#)termios.h 8.3 (Berkeley) 3/28/94
- */
-
+ NetBSD: termios.h,v 1.29 2005/12/11 12:25:21 christos Exp
+**/
#ifndef _SYS_TERMIOS_H_
#define _SYS_TERMIOS_H_
#include <sys/ansi.h>
#include <sys/featuretest.h>
-/*
- * Special Control Characters
+/* Special Control Characters
*
* Index into c_cc[] character array.
- *
- * Name Subscript Enabled by
*/
-#define VEOF 0 /* ICANON */
-#define VEOL 1 /* ICANON */
-#if defined(_NETBSD_SOURCE)
-#define VEOL2 2 /* ICANON */
-#endif
-#define VERASE 3 /* ICANON */
-#if defined(_NETBSD_SOURCE)
-#define VWERASE 4 /* ICANON */
-#endif
-#define VKILL 5 /* ICANON */
-#if defined(_NETBSD_SOURCE)
-#define VREPRINT 6 /* ICANON */
-#endif
-/* 7 spare 1 */
-#define VINTR 8 /* ISIG */
-#define VQUIT 9 /* ISIG */
-#define VSUSP 10 /* ISIG */
-#if defined(_NETBSD_SOURCE)
-#define VDSUSP 11 /* ISIG */
-#endif
-#define VSTART 12 /* IXON, IXOFF */
-#define VSTOP 13 /* IXON, IXOFF */
-#if defined(_NETBSD_SOURCE)
-#define VLNEXT 14 /* IEXTEN */
-#define VDISCARD 15 /* IEXTEN */
-#endif
-#define VMIN 16 /* !ICANON */
-#define VTIME 17 /* !ICANON */
-#if defined(_NETBSD_SOURCE)
-#define VSTATUS 18 /* ICANON */
-/* 19 spare 2 */
-#endif
-#define NCCS 20
+typedef enum {
+/* Name Enabled by */
+ VTABLEN, /* OXTABS - Length between TAB stops. */
+ VEOF, /* ICANON */
+ VEOL, /* ICANON */
+ VERASE, /* ICANON */
+ VKILL, /* ICANON */
+ VINTR, /* ISIG */
+ VQUIT, /* ISIG */
+ VMIN, /* !ICANON */
+ VTIME, /* !ICANON */
+
+ /* Extensions from BSD and POSIX -- Not yet implemented for UEFI */
+ VWERASE, /* IEXTEN, ICANON -- Erase the WORD to the left of the cursor */
+ VREPRINT, /* IEXTEN, ICANON -- Re-draw the current line (input buffer) */
+ VLNEXT, /* IEXTEN, ICANON -- Input the next character literally */
+ VDISCARD, /* IEXTEN -- Toggle. Discards output display until toggled. */
+
+ /* NCCS must always be the last member of this enum. */
+ NCCS /* Number of control characters in c_cc[] */
+} CCC_INDEX;
#define _POSIX_VDISABLE ((unsigned char)'\377')
-#if defined(_NETBSD_SOURCE)
#define CCEQ(val, c) (c == val ? val != _POSIX_VDISABLE : 0)
-#endif
/*
* Input flags - software input processing
- */
-#define IGNBRK 0x00000001 /* ignore BREAK condition */
-#define BRKINT 0x00000002 /* map BREAK to SIGINTR */
-#define IGNPAR 0x00000004 /* ignore (discard) parity errors */
-#define PARMRK 0x00000008 /* mark parity and framing errors */
-#define INPCK 0x00000010 /* enable checking of parity errors */
-#define ISTRIP 0x00000020 /* strip 8th bit off chars */
-#define INLCR 0x00000040 /* map NL into CR */
-#define IGNCR 0x00000080 /* ignore CR */
-#define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */
-#define IXON 0x00000200 /* enable output flow control */
-#define IXOFF 0x00000400 /* enable input flow control */
-#if defined(_NETBSD_SOURCE)
-#define IXANY 0x00000800 /* any char will restart after stop */
-#endif
-#if defined(_NETBSD_SOURCE)
-#define IMAXBEL 0x00002000 /* ring bell on input queue full */
-#endif
+ c_iflag
+*/
+#define INLCR 0x0001 /* map NL into CR */
+#define IGNCR 0x0002 /* ignore CR */
+#define ICRNL 0x0004 /* map CR to NL (ala CRMOD) */
+#define IGNSPEC 0x0008 /* Ignore function, control, and other non-printing special keys. */
+#ifdef HAVE_DA_SERIAL
+ #define ISTRIP 0x0010 /* strip 8th bit off chars */
+ #define IGNBRK 0x0020 /* ignore BREAK condition */
+ #define BRKINT 0x0040 /* map BREAK to SIGINTR */
+ #define IRESRV1 0x0080
+ #define IGNPAR 0x0100 /* ignore (discard) parity errors */
+ #define PARMRK 0x0200 /* mark parity and framing errors */
+ #define INPCK 0x0400 /* enable checking of parity errors */
+ #define IXON 0x0800 /* enable output flow control */
+ #define IXOFF 0x1000 /* enable input flow control */
+ #define IXANY 0x2000 /* any char will restart after stop */
+#endif /* HAVE_DA_SERIAL */
/*
* Output flags - software output processing
+ c_oflag
*/
-#define OPOST 0x00000001 /* enable following output processing */
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
-#define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */
-#endif
-#if defined(_NETBSD_SOURCE)
-#define OXTABS 0x00000004 /* expand tabs to spaces */
-#define ONOEOT 0x00000008 /* discard EOT's (^D) on output */
-#endif
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
-#define OCRNL 0x00000010 /* map CR to NL */
-#define ONOCR 0x00000020 /* discard CR's when on column 0 */
-#define ONLRET 0x00000040 /* move to column 0 on CR */
-#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
+#define OPOST 0x0001 /* enable following output processing */
+#define ONLCR 0x0002 /* map NL to CR-NL (ala CRMOD) */
+#define OXTABS 0x0004 /* expand tabs to spaces */
+#define ONOEOT 0x0008 /* discard EOT's (^D) on output */
+#define OCRNL 0x0010 /* map CR to NL */
+#define ONOCR 0x0020 /* discard CR's when on column 0 */
+#define ONLRET 0x0040 /* move to column 0 on CR */
+#define OCTRL 0x0080 /* Map control characters to the sequence ^C */
/*
* Control flags - hardware control of terminal
+ c_cflag
*/
-#if defined(_NETBSD_SOURCE)
-#define CIGNORE 0x00000001 /* ignore control flags */
-#endif
-#define CSIZE 0x00000300 /* character size mask */
-#define CS5 0x00000000 /* 5 bits (pseudo) */
-#define CS6 0x00000100 /* 6 bits */
-#define CS7 0x00000200 /* 7 bits */
-#define CS8 0x00000300 /* 8 bits */
-#define CSTOPB 0x00000400 /* send 2 stop bits */
-#define CREAD 0x00000800 /* enable receiver */
-#define PARENB 0x00001000 /* parity enable */
-#define PARODD 0x00002000 /* odd parity, else even */
-#define HUPCL 0x00004000 /* hang up on last close */
-#define CLOCAL 0x00008000 /* ignore modem status lines */
-#if defined(_NETBSD_SOURCE)
-#define CRTSCTS 0x00010000 /* RTS/CTS full-duplex flow control */
-#define CRTS_IFLOW CRTSCTS /* XXX compat */
-#define CCTS_OFLOW CRTSCTS /* XXX compat */
-#define CDTRCTS 0x00020000 /* DTR/CTS full-duplex flow control */
-#define MDMBUF 0x00100000 /* DTR/DCD hardware flow control */
-#define CHWFLOW (MDMBUF|CRTSCTS|CDTRCTS) /* all types of hw flow control */
+#ifdef HAVE_DA_SERIAL
+ #define CIGNORE 0x0001 /* ignore control flags */
+ #define CSIZE 0x0300 /* character size mask */
+ #define CS5 0x0000 /* 5 bits (pseudo) */
+ #define CS6 0x0100 /* 6 bits */
+ #define CS7 0x0200 /* 7 bits */
+ #define CS8 0x0300 /* 8 bits */
+ #define CSTOPB 0x0400 /* send 2 stop bits, else 1 */
+ #define CREAD 0x0800 /* enable receiver */
+ #define PARENB 0x1000 /* parity enable */
+ #define PARODD 0x2000 /* odd parity, else even */
+ #define HUPCL 0x4000 /* hang up on last close */
+ #define CLOCAL 0x8000 /* ignore modem status lines */
#endif
@@ -156,149 +138,137 @@
* the letter "I" and look like they belong in the
* input flag.
*/
+#define ECHO 0x0001 /* enable echoing */
+#define ECHOE 0x0002 /* visually erase chars */
+#define ECHOK 0x0004 /* echo NL after line kill */
+#define ECHONL 0x0008 /* echo NL even if ECHO is off */
+#define ISIG 0x0010 /* enable signals INTR, QUIT, [D]SUSP */
+#define ICANON 0x0020 /* canonicalize input lines */
+#define IEXTEN 0x0040 /* enable Extensions */
+#define SKIP_1 0x0100 /* Currently unused */
+#define TOSTOP 0x0200 /* stop background jobs on output */
+#define PENDIN 0x0400 /* re-echo input buffer at next read */
+#define NOFLSH 0x0800 /* don't flush output on signal */
+#define FLUSHO 0x1000 /* output being flushed (state) */
-#if defined(_NETBSD_SOURCE)
-#define ECHOKE 0x00000001 /* visual erase for line kill */
-#endif
-#define ECHOE 0x00000002 /* visually erase chars */
-#define ECHOK 0x00000004 /* echo NL after line kill */
-#define ECHO 0x00000008 /* enable echoing */
-#define ECHONL 0x00000010 /* echo NL even if ECHO is off */
-#if defined(_NETBSD_SOURCE)
-#define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */
-#define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */
-#endif /* defined(_NETBSD_SOURCE) */
-#define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */
-#define ICANON 0x00000100 /* canonicalize input lines */
-#if defined(_NETBSD_SOURCE)
-#define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */
-#endif /* defined(_NETBSD_SOURCE) */
-#define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */
-#if defined(_NETBSD_SOURCE)
-#define EXTPROC 0x00000800 /* external processing */
-#endif /* defined(_NETBSD_SOURCE) */
-#define TOSTOP 0x00400000 /* stop background jobs on output */
-#if defined(_NETBSD_SOURCE)
-#define FLUSHO 0x00800000 /* output being flushed (state) */
-#define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */
-#define PENDIN 0x20000000 /* re-echo input buffer at next read */
-#endif /* defined(_NETBSD_SOURCE) */
-#define NOFLSH 0x80000000 /* don't flush output on signal */
-
-typedef unsigned int tcflag_t;
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
+typedef INT8 cc_t;
+typedef UINT16 tcflag_t;
+typedef UINT32 speed_t;
struct termios {
- tcflag_t c_iflag; /* input flags */
- tcflag_t c_oflag; /* output flags */
- tcflag_t c_cflag; /* control flags */
- tcflag_t c_lflag; /* local flags */
- cc_t c_cc[NCCS]; /* control chars */
- int c_ispeed; /* input speed */
- int c_ospeed; /* output speed */
+ INT32 c_ispeed; /* input speed - Use a signed type instead of speed_t */
+ INT32 c_ospeed; /* output speed - to ease integer promotion when used. */
+ tcflag_t c_iflag; /* input flags */
+ tcflag_t c_oflag; /* output flags */
+ tcflag_t c_cflag; /* control flags */
+ tcflag_t c_lflag; /* local flags */
+ cc_t c_cc[NCCS]; /* control chars */
};
/*
* Commands passed to tcsetattr() for setting the termios structure.
*/
-#define TCSANOW 0 /* make change immediate */
-#define TCSADRAIN 1 /* drain output, then change */
-#define TCSAFLUSH 2 /* drain output, flush input */
-#if defined(_NETBSD_SOURCE)
-#define TCSASOFT 0x10 /* flag - don't alter h.w. state */
-#endif
+#define TCSANOW 0 /* make change immediate */
+#define TCSADRAIN 1 /* drain output, then change */
+#define TCSAFLUSH 2 /* drain output, flush input */
+#define TCSASOFT 0x10 /* flag - don't alter h.w. state */
/*
* Standard speeds
*/
-#define B0 0
-#define B50 50
-#define B75 75
-#define B110 110
-#define B134 134
-#define B150 150
-#define B200 200
-#define B300 300
-#define B600 600
-#define B1200 1200
-#define B1800 1800
-#define B2400 2400
-#define B4800 4800
-#define B9600 9600
-#define B19200 19200
-#define B38400 38400
-#if defined(_NETBSD_SOURCE)
-#define B7200 7200
-#define B14400 14400
-#define B28800 28800
-#define B57600 57600
-#define B76800 76800
-#define B115200 115200
-#define B230400 230400
-#define B460800 460800
-#define B921600 921600
-#define EXTA 19200
-#define EXTB 38400
-#endif /* defined(_NETBSD_SOURCE) */
+#define B0 0
+#define B50 50
+#define B75 75
+#define B110 110
+#define B134 134
+#define B150 150
+#define B200 200
+#define B300 300
+#define B600 600
+#define B1200 1200
+#define B1800 1800
+#define B2400 2400
+#define B4800 4800
+#define B9600 9600
+#define B19200 19200
+#define B38400 38400
-#ifndef _KERNEL
+// Extended speed definitions
+#define B7200 7200
+#define B14400 14400
+#define B28800 28800
+#define B57600 57600
+#define B76800 76800
+#define B115200 115200
+#define B230400 230400
+#define B460800 460800
+#define B921600 921600
#define TCIFLUSH 1
#define TCOFLUSH 2
#define TCIOFLUSH 3
#define TCOOFF 1
-#define TCOON 2
+#define TCOON 2
#define TCIOFF 3
-#define TCION 4
+#define TCION 4
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
-#ifndef pid_t
-typedef __pid_t pid_t;
-#define pid_t __pid_t
-#endif
-#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
#include <sys/EfiCdefs.h>
__BEGIN_DECLS
-speed_t cfgetispeed(const struct termios *);
-speed_t cfgetospeed(const struct termios *);
-int cfsetispeed(struct termios *, speed_t);
-int cfsetospeed(struct termios *, speed_t);
-int tcgetattr(int, struct termios *);
-int tcsetattr(int, int, const struct termios *);
-int tcdrain(int);
-int tcflow(int, int);
-int tcflush(int, int);
-int tcsendbreak(int, int);
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
-pid_t tcgetsid(int);
-#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
+speed_t cfgetispeed (const struct termios *);
+speed_t cfgetospeed (const struct termios *);
+int cfsetispeed (struct termios *, speed_t);
+int cfsetospeed (struct termios *, speed_t);
+int tcgetattr (int, struct termios *);
+int tcsetattr (int, int, const struct termios *);
+int tcdrain (int);
+int tcflow (int, int);
+int tcflush (int, int);
+//int tcsendbreak (int, int);
+//pid_t tcgetsid (int);
-#if defined(_NETBSD_SOURCE)
-void cfmakeraw(struct termios *);
-int cfsetspeed(struct termios *, speed_t);
-#endif /* defined(_NETBSD_SOURCE) */
+//void cfmakeraw (struct termios *);
+//int cfsetspeed (struct termios *, speed_t);
__END_DECLS
-#endif /* !_KERNEL */
+/* Input values for UEFI Keyboard Scan Codes.
-#if defined(_NETBSD_SOURCE)
+ The UEFI Keyboard Scan Codes are mapped into the upper range of the Unicode
+ Private Use Area so that the characters can be inserted into the input stream
+ and treated the same as any other character.
-/*
- * Include tty ioctl's that aren't just for backwards compatibility
- * with the old tty driver. These ioctl definitions were previously
- * in <sys/ioctl.h>.
- */
-//#include <sys/ttycom.h>
-#endif
+ These values are only used for input. If these codes are output to the
+ console, or another interactive I/O device, the behavior will depend upon
+ the current locale and UEFI character set loaded.
+*/
+typedef enum {
+ TtySpecKeyMin = 0xF7F0,
+ /* This area is reserved for use by internal I/O software.
+ At least 4 values must exist between TtySpecKeyMin and TtyFunKeyMin.
+ */
+ TtyFunKeyMin = 0xF7FA,
+ TtyKeyEject = 0xF7FA,
+ TtyRecovery, TtyToggleDisplay, TtyHibernate,
+ TtySuspend, TtyBrightnessDown, TtyBrightnessUp,
+ TtyVolumeDown = 0xF87F,
+ TtyVolumeUp, TtyMute,
+ TtyF24 = 0xF88D,
+ TtyF23, TtyF22, TtyF21, TtyF20,
+ TtyF19, TtyF18, TtyF17, TtyF16,
+ TtyF15, TtyF14, TtyF13,
+ TtyEscape = 0xF8E9,
+ TtyF12, TtyF11, TtyF10, TtyF9,
+ TtyF8, TtyF7, TtyF6, TtyF5,
+ TtyF4, TtyF3, TtyF2, TtyF1,
+ TtyPageDown, TtyPageUp, TtyDelete, TtyInsert,
+ TtyEnd, TtyHome, TtyLeftArrow, TtyRightArrow,
+ TtyDownArrow,
+ TtyUpArrow = 0xF8FF,
+ TtyFunKeyMax = 0xF900
+} TtyFunKey;
-/*
- * END OF PROTECTED INCLUDE.
- */
-#endif /* !_SYS_TERMIOS_H_ */
+// Non-UEFI character definitions
+#define CHAR_EOT 0x0004 /* End of Text (EOT) character */
-#if defined(_NETBSD_SOURCE)
-//#include <sys/ttydefaults.h>
-#endif
+#endif /* !_SYS_TERMIOS_H_ */
diff --git a/edk2/StdLib/Include/wchar.h b/edk2/StdLib/Include/wchar.h
index d8e15caa4..2c9ec6e5e 100644
--- a/edk2/StdLib/Include/wchar.h
+++ b/edk2/StdLib/Include/wchar.h
@@ -150,7 +150,7 @@
- WEOF might not be negative.
- mbstate_t objects are not intended to be inspected by programs.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -913,7 +913,7 @@ wint_t fgetwc(FILE *Stream);
@param[out] S A pointer to the array to receive the input string.
@param[in] Limit The maximum number of characters to put into Buff,
including the terminating null character.
- @param[in] Stream An input stream from which to obtain a character.
+ @param[in] Stream An input stream from which to obtain the string.
@return The fgetws function returns S if successful. If end-of-file is
encountered and no characters have been read into the array, the
@@ -1415,12 +1415,18 @@ int mbsinit(const mbstate_t *ps);
where internal is the mbstate_t object for the mbrlen function, except that
the expression designated by ps is evaluated only once.
- @return The mbrlen function returns a value between zero and n,
- inclusive, (size_t)(-2), or (size_t)(-1).
+ @param[in] s Pointer to a multibyte character sequence.
+ @param[in] n Maximum number of bytes to examine.
+ @param[in] pS Pointer to the conversion state object.
+
+ @retval 0 The next n or fewer characters complete a NUL.
+ @retval 1..n The number of bytes that complete the multibyte character.
+ @retval -2 The next n bytes contribute to an incomplete (but potentially valid) multibyte character.
+ @retval -1 An encoding error occurred.
**/
-size_t mbrlen(const char * __restrict S, size_t n, mbstate_t * __restrict ps);
+size_t mbrlen(const char * __restrict S, size_t n, mbstate_t * __restrict pS);
-/**
+/** Restartable Multibyte to Wide character conversion.
If S is a null pointer, the mbrtowc function is equivalent to the call:<BR>
@verbatim
mbrtowc(NULL, "", 1, ps)
@@ -1476,22 +1482,27 @@ to restore the initial shift state; the resulting state described is the initial
**/
size_t wcrtomb(char * __restrict S, wchar_t wc, mbstate_t * __restrict ps);
-/**
-The mbsrtowcs function converts a sequence of multibyte characters that begins in the
-conversion state described by the object pointed to by ps, from the array indirectly
-pointed to by src into a sequence of corresponding wide characters. If dst is not a null
-pointer, the converted characters are stored into the array pointed to by dst. Conversion
-continues up to and including a terminating null character, which is also stored.
-Conversion stops earlier in two cases: when a sequence of bytes is encountered that does
-not form a valid multibyte character, or (if dst is not a null pointer) when len wide
-characters have been stored into the array pointed to by dst. Each conversion takes
-place as if by a call to the mbrtowc function.
-
-If dst is not a null pointer, the pointer object pointed to by src is assigned either a null
-pointer (if conversion stopped due to reaching a terminating null character) or the address
-just past the last multibyte character converted (if any). If conversion stopped due to
-reaching a terminating null character and if dst is not a null pointer, the resulting state
-described is the initial conversion state.
+/** Convert a sequence of multibyte characters into a sequence of wide characters.
+ The mbsrtowcs function converts a sequence of multibyte characters that begins in the
+ conversion state described by the object pointed to by ps, from the array indirectly
+ pointed to by src into a sequence of corresponding wide characters. If dst is not a null
+ pointer, the converted characters are stored into the array pointed to by dst. Conversion
+ continues up to and including a terminating null character, which is also stored.
+ Conversion stops earlier in two cases: when a sequence of bytes is encountered that does
+ not form a valid multibyte character, or (if dst is not a null pointer) when len wide
+ characters have been stored into the array pointed to by dst. Each conversion takes
+ place as if by a call to the mbrtowc function.
+
+ If dst is not a null pointer, the pointer object pointed to by src is assigned either a null
+ pointer (if conversion stopped due to reaching a terminating null character) or the address
+ just past the last multibyte character converted (if any). If conversion stopped due to
+ reaching a terminating null character and if dst is not a null pointer, the resulting state
+ described is the initial conversion state.
+
+ @param[in] dst Destination for the Wide character sequence.
+ @param[in] src Pointer to Pointer to MBCS char. sequence to convert.
+ @param[in] len Length of dest, in WIDE characters.
+ @param[in] ps Pointer to the conversion state object to be used for this conversion.
@return If the input conversion encounters a sequence of bytes that do
not form a valid multibyte character, an encoding error occurs:
@@ -1523,6 +1534,11 @@ size_t mbsrtowcs(wchar_t * __restrict dst, const char ** __restrict src, size_t
terminating null wide character, the resulting state described is the
initial conversion state.
+ @param[in] dst Destination for the MBCS sequence.
+ @param[in] src Pointer to Pointer to wide char. sequence to convert.
+ @param[in] len Length of dest, in bytes.
+ @param[in] ps Pointer to the conversion state object to be used for this conversion.
+
@return If conversion stops because a wide character is reached that
does not correspond to a valid multibyte character, an
encoding error occurs: the wcsrtombs function stores the
diff --git a/edk2/StdLib/LibC/Locale/Locale.inf b/edk2/StdLib/LibC/Locale/Locale.inf
index c891e3bfa..e0f163cb1 100644
--- a/edk2/StdLib/LibC/Locale/Locale.inf
+++ b/edk2/StdLib/LibC/Locale/Locale.inf
@@ -1,7 +1,7 @@
## @file
# Standard C library: Locale implementation.
#
-# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010-2012, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -10,7 +10,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
-#
##
[Defines]
@@ -50,10 +49,10 @@
wcstof.c #
wcstold.c #
wcsxfrm.c #
+ multibyte_Utf8.c #
# Single-byte locale to avoid bringing in citrus
iswctype_sb.c #
- multibyte_sb.c #
[Packages]
StdLib/StdLib.dec
diff --git a/edk2/StdLib/LibC/Locale/multibyte_Utf8.c b/edk2/StdLib/LibC/Locale/multibyte_Utf8.c
new file mode 100644
index 000000000..3f29f2942
--- /dev/null
+++ b/edk2/StdLib/LibC/Locale/multibyte_Utf8.c
@@ -0,0 +1,829 @@
+/** @file
+ Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#include <assert.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <sys/types.h>
+
+typedef int ch_UCS4;
+
+static mbstate_t LocalConvState = {0};
+
+/** Map a UTF-8 encoded prefix byte to a sequence length.
+ Zero means illegal prefix, but valid surrogate if < 0xC0.
+ One indicates an ASCII-7 equivalent character.
+ Two, three, and four are the first byte for 2, 3, and 4 byte sequences, respectively.
+ See RFC 3629 for details.
+
+ TABLE ENCODING:
+ Low Nibble decodes the first byte into the number of bytes in the sequence.
+ A value of zero indicates an invalid byte.
+ The High Nibble encodes a bit mask to be used to match against the high nibble of the second byte.
+
+ example:
+ SequenceLength = code[c0] & 0x0F;
+ Mask = 0x80 | code[c0];
+
+ Surrogate bytes are valid if: code[cX] & Mask > 0x80;
+
+*/
+static
+UINT8 utf8_code_length[256] = {
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, /* 00-0F */
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, /* 70-7F */
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, /* 80-8F */
+ 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, /* 90-9F */
+ 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, /* A0-AF */
+ 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, /* B0-BF */
+ 0x00, 0x00, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, /* C0-C1 + C2-CF */
+ 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, /* D0-DF */
+ 0x43, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x33, 0x73, 0x73, /* E0-EF */
+ 0x64, 0x74, 0x74, 0x74, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* F0-F4 + F5-FF */
+};
+
+/** Process one byte of a multibyte character.
+
+ @param ch
+ @param ps
+
+ @retval -2
+ @retval -1
+ @retval 1:4
+**/
+static
+int
+ProcessOneByte(unsigned char ch, mbstate_t *ps)
+{
+ UINT32 Mask;
+ UINT32 Length;
+ int RetVal = 0;
+
+ if(ps->A > 3) {
+ // We are in an invalid state
+ ps->A = 0; // Initial State
+ }
+ ps->C[ps->A] = ch; // Save the current character
+ Mask = utf8_code_length[ch];
+
+ if(ps->A == 0) { // Initial State. First byte of sequence.
+ ps->E = Mask | 0x80;
+ Length = Mask & 0xF;
+ switch(Length) {
+ case 0: // State 0, Code 0
+ errno = EILSEQ;
+ RetVal = -1;
+ ps->E = 1; // Consume this character
+ break;
+ case 1: // State 0, Code 1
+ // ASCII-7 Character
+ ps->B = ps->D[0] = ch;
+ RetVal = 1;
+ break;
+ default: // State 0, Code 2, 3, 4
+ ps->A = 1; // Next state is State-1
+ RetVal = -2; // Incomplete but potentially valid character
+ break;
+ }
+ }
+ else {
+ // We are in state 1, 2, or 3 and processing a surrogate byte
+ Length = ps->E & 0xF;
+ if((Mask & ps->E) > 0x80) {
+ // This byte is valid
+ switch(ps->A) { // Process based upon our current state
+ case 1: // Second byte of the sequence.
+ if(Length == 2) { // State 1, Code 2
+ Length = ((ps->C[0] & 0x1f) << 6) + (ps->C[1] & 0x3f);
+ assert ((Length > 0x007F) && (Length <= 0x07FF));
+ ps->B = ps->D[0] = (UINT16)Length;
+ ps->A = 0; // Next state is State-0
+ RetVal = 2;
+ }
+ else { // This isn't the last character, get more. State 1, Code 3 or 4
+ ps->A = 2;
+ RetVal = -2;
+ }
+ break;
+ case 2: // Third byte of the sequence
+ if(Length == 3) {
+ Length = ((ps->C[0] & 0x0f) << 12) + ((ps->C[1] & 0x3f) << 6) + (ps->C[2] & 0x3f);
+ assert ((Length > 0x07FF) && (Length <= 0xFFFF));
+ ps->B = ps->D[0] = (UINT16)Length;
+ ps->A = 0; // Next state is State-0
+ RetVal = 3;
+ }
+ else {
+ ps->A = 3;
+ RetVal = -2;
+ }
+ break;
+ case 3: // Fourth byte of the sequence
+ if(Length == 4) {
+ Length = ((ps->C[0] & 0x7) << 18) + ((ps->C[1] & 0x3f) << 12) +
+ ((ps->C[2] & 0x3f) << 6) + (ps->C[3] & 0x3f);
+ ps->B = Length;
+ assert ((Length > 0xFFFF) && (Length <= 0x10ffff));
+
+ /* compute and append the two surrogates: */
+
+ /* translate from 10000..10FFFF to 0..FFFF */
+ Length -= 0x10000;
+
+ /* high surrogate = top 10 bits added to D800 */
+ ps->D[0] = (UINT16)(0xD800 + (Length >> 10));
+
+ /* low surrogate = bottom 10 bits added to DC00 */
+ ps->D[1] = (UINT16)(0xDC00 + (Length & 0x03FF));
+ ps->A = 0; // Next state is State-0
+ RetVal = 4;
+ }
+ else {
+ errno = EILSEQ;
+ ps->A = 0;
+ RetVal = -1;
+ ps->E = 4; // Can't happen, but consume this character anyway
+ }
+ break;
+ }
+ }
+ else { // Invalid surrogate character
+ errno = EILSEQ;
+ ps->A = 0; // Next is State-0
+ RetVal = -1;
+ ps->E = 0; // Don't Consume, it may be an initial byte
+ }
+ }
+ return RetVal;
+}
+
+/** Convert one Multibyte sequence.
+
+ @param Dest
+ @param Src
+ @param Len
+ @param pS
+
+ @retval -2 Bytes processed comprise an incomplete, but potentially valid, character.
+ @retval -1 An encoding error was encountered. ps->E indicates the number of bytes consumed.
+ @retval 0 Either Src is NULL or it points to a NUL character.
+ @retval 1:N N bytes were consumed producing a valid wide character.
+**/
+int
+DecodeOneStateful(
+ wchar_t *Dest, // Pointer to output location, or NULL
+ const char *Src, // Multibyte Source (UTF8)
+ ssize_t Len, // Max Number of bytes to convert
+ mbstate_t *pS // Pointer to State struct., or NULL
+ )
+{
+ const char *SrcEnd;
+ int NumConv;
+ unsigned char ch;
+
+ if((Src == NULL) || (*Src == '\0')) {
+ return 0;
+ }
+ if(pS == NULL) {
+ pS = &LocalConvState;
+ }
+ SrcEnd = Src + Len;
+ NumConv = 0;
+ while(Src < SrcEnd) {
+ ch = (unsigned char)*Src++;
+ NumConv = ProcessOneByte(ch, pS);
+ if(NumConv != -2)
+ break;
+ }
+ if((NumConv > 0) && (Dest != NULL)) {
+ Dest[0] = pS->D[0];
+ if(NumConv == 4) {
+ Dest[1] = pS->D[1];
+ }
+ }
+ return NumConv;
+}
+
+/** Convert wide characters (UTF16) into multibyte characters (UTF8)
+
+ @param s Pointer to the wide-character string to convert
+ @param size Number of wide characters in s. size <= wcslen(s);
+
+ @return A newly allocated buffer containing the converted string is returned,
+ or NULL if an error occurred. Global variable errno contains more
+ information if NULL is returned.
+**/
+ssize_t
+EncodeUtf8(char *Dest, wchar_t *s, ssize_t size)
+{
+ char *p; /* next free byte in build buffer */
+ char *v; /* next free byte in destination */
+ ssize_t nneeded; /* number of result bytes needed */
+ int i; /* index into s of next input byte */
+ int NumInBuff; // number of bytes in Buff
+ char Buff[4]; // Buffer into which each character is built
+
+ assert(s != NULL);
+ assert(size >= 0);
+
+ v = Dest;
+ nneeded = 0;
+ if((size * MB_LEN_MAX) / MB_LEN_MAX != size) {
+ // size is too large and resulted in overflow when multiplied by MB_LEN_MAX
+ errno = EINVAL;
+ return (ssize_t)-1;
+ }
+
+ for (i = 0; i < size;) {
+ ch_UCS4 ch = s[i++];
+ p = Buff;
+
+ if (ch < 0x80) {
+ /* Encode ASCII -- One Byte */
+ *p++ = (char) ch;
+ }
+ else if (ch < 0x0800) {
+ /* Encode Latin-1 -- Two Byte */
+ *p++ = (char)(0xc0 | (ch >> 6));
+ *p++ = (char)(0x80 | (ch & 0x3f));
+ }
+ else {
+ /* Encode UCS2 Unicode ordinals -- Three Byte */
+ /* Special case: check for high surrogate -- Shouldn't happen in UEFI */
+ if (0xD800 <= ch && ch <= 0xDBFF && i < size) {
+ ch_UCS4 ch2 = s[i];
+ /* Check for low surrogate and combine the two to
+ form a UCS4 value */
+ if (0xDC00 <= ch2 && ch2 <= 0xDFFF) {
+ ch = ((ch - 0xD800) << 10 | (ch2 - 0xDC00)) + 0x10000;
+ i++;
+ /* Encode UCS4 Unicode ordinals -- Four Byte */
+ *p++ = (char)(0xf0 | (ch >> 18));
+ *p++ = (char)(0x80 | ((ch >> 12) & 0x3f));
+ *p++ = (char)(0x80 | ((ch >> 6) & 0x3f));
+ *p++ = (char)(0x80 | (ch & 0x3f));
+ continue;
+ }
+ /* Fall through: handles isolated high surrogates */
+ }
+ *p++ = (char)(0xe0 | (ch >> 12));
+ *p++ = (char)(0x80 | ((ch >> 6) & 0x3f));
+ *p++ = (char)(0x80 | (ch & 0x3f));
+ }
+ /* At this point, Buff holds the converted character which is NumInBuff bytes long.
+ NumInBuff is the value 1, 2, 3, or 4
+ */
+ NumInBuff = (int)(p - Buff); // Number of bytes in Buff
+ if(Dest != NULL) { // Save character if Dest is not NULL
+ memcpy(v, Buff, NumInBuff);
+ v += NumInBuff;
+ }
+ nneeded += NumInBuff; // Keep track of the number of bytes put into Dest
+ }
+ if(Dest != NULL) {
+ // Terminate the destination string.
+ *v = '\0';
+ }
+ return nneeded; // Tell the caller
+}
+
+// ######################## Narrow to Wide Conversions #######################
+
+/** If ps is not a null pointer, the mbsinit function determines whether the
+ pointed-to mbstate_t object describes an initial conversion state.
+
+ @return The mbsinit function returns nonzero if ps is a null pointer
+ or if the pointed-to object describes an initial conversion
+ state; otherwise, it returns zero.
+
+ Declared in: wchar.h
+**/
+int
+mbsinit(const mbstate_t *ps)
+{
+ if((ps == NULL) || (ps->A == 0)) {
+ return 1;
+ }
+ return 0;
+}
+
+/** The mbrlen function is equivalent to the call:<BR>
+@verbatim
+ mbrtowc(NULL, s, n, ps != NULL ? ps : &internal)
+@endverbatim
+ where internal is the mbstate_t object for the mbrlen function, except that
+ the expression designated by ps is evaluated only once.
+
+ @return The mbrlen function returns a value between zero and n,
+ inclusive, (size_t)(-2), or (size_t)(-1).
+
+ Declared in: wchar.h
+**/
+size_t
+mbrlen(
+ const char *s,
+ size_t n,
+ mbstate_t *ps
+ )
+{
+ return mbrtowc(NULL, s, n, ps);
+}
+
+/** Determine the number of bytes comprising a multibyte character.
+
+ If S is not a null pointer, the mblen function determines the number of bytes
+ contained in the multibyte character pointed to by S. Except that the
+ conversion state of the mbtowc function is not affected, it is equivalent to
+ mbtowc((wchar_t *)0, S, N);
+
+ @param[in] S NULL to query whether multibyte characters have
+ state-dependent encodings. Otherwise, points to a
+ multibyte character.
+ @param[in] N The maximum number of bytes in a multibyte character.
+
+ @return If S is a null pointer, the mblen function returns a nonzero or
+ zero value, if multibyte character encodings, respectively, do
+ or do not have state-dependent encodings. If S is not a null
+ pointer, the mblen function either returns 0 (if S points to the
+ null character), or returns the number of bytes that are contained
+ in the multibyte character (if the next N or fewer bytes form a
+ valid multibyte character), or returns -1 (if they do not form a
+ valid multibyte character).
+
+ Declared in: stdlib.h
+**/
+int
+mblen(
+ const char *s,
+ size_t n
+ )
+{
+ return (int)mbrlen(s, n, NULL);
+}
+
+/**
+If S is a null pointer, the mbrtowc function is equivalent to the call:<BR>
+@verbatim
+ mbrtowc(NULL, "", 1, ps)
+@endverbatim
+
+In this case, the values of the parameters pwc and n are ignored.
+
+If S is not a null pointer, the mbrtowc function inspects at most n bytes beginning with
+the byte pointed to by S to determine the number of bytes needed to complete the next
+multibyte character (including any shift sequences). If the function determines that the
+next multibyte character is complete and valid, it determines the value of the
+corresponding wide character and then, if pwc is not a null pointer, stores that value in
+the object pointed to by pwc. If the corresponding wide character is the null wide
+character, the resulting state described is the initial conversion state.
+
+ @retval 0 if the next n or fewer bytes complete the multibyte
+ character that corresponds to the null wide
+ character (which is the value stored).
+ @retval between_1_and_n_inclusive if the next n or fewer bytes complete
+ a valid multibyte character (which is the value
+ stored); the value returned is the number of bytes
+ that complete the multibyte character.
+ @retval (size_t)(-2) if the next n bytes contribute to an incomplete
+ (but potentially valid) multibyte character, and
+ all n bytes have been processed (no value is stored).
+ @retval (size_t)(-1) if an encoding error occurs, in which case the next
+ n or fewer bytes do not contribute to a complete and
+ valid multibyte character (no value is stored); the
+ value of the macro EILSEQ is stored in errno, and
+ the conversion state is unspecified.
+
+ Declared in: wchar.h
+**/
+size_t
+mbrtowc(
+ wchar_t *pwc,
+ const char *s,
+ size_t n,
+ mbstate_t *ps
+ )
+{
+ int RetVal;
+
+ RetVal = DecodeOneStateful(pwc, s, (ssize_t)n, ps);
+ return (size_t)RetVal;
+}
+
+/** Convert a multibyte character into a wide character.
+
+ If S is not a null pointer, the mbtowc function inspects at most N bytes
+ beginning with the byte pointed to by S to determine the number of bytes
+ needed to complete the next multibyte character (including any shift
+ sequences). If the function determines that the next multibyte character
+ is complete and valid, it determines the value of the corresponding wide
+ character and then, if Pwc is not a null pointer, stores that value in
+ the object pointed to by Pwc. If the corresponding wide character is the
+ null wide character, the function is left in the initial conversion state.
+
+ @param[out] Pwc Pointer to a wide-character object to receive the converted character.
+ @param[in] S Pointer to a multibyte character to convert.
+ @param[in] N Maximum number of bytes in a multibyte character.
+
+ @return If S is a null pointer, the mbtowc function returns a nonzero or
+ zero value, if multibyte character encodings, respectively, do
+ or do not have state-dependent encodings. If S is not a null
+ pointer, the mbtowc function either returns 0 (if S points to
+ the null character), or returns the number of bytes that are
+ contained in the converted multibyte character (if the next N or
+ fewer bytes form a valid multibyte character), or returns -1
+ (if they do not form a valid multibyte character).
+
+ In no case will the value returned be greater than N or the value
+ of the MB_CUR_MAX macro.
+
+ Declared in: stdlib.h
+**/
+int
+mbtowc(
+ wchar_t *pwc,
+ const char *s,
+ size_t n
+ )
+{
+ return (int)mbrtowc(pwc, s, n, NULL);
+}
+
+/**
+The mbsrtowcs function converts a sequence of multibyte characters that begins in the
+conversion state described by the object pointed to by ps, from the array indirectly
+pointed to by src into a sequence of corresponding wide characters. If dst is not a null
+pointer, the converted characters are stored into the array pointed to by dst. Conversion
+continues up to and including a terminating null character, which is also stored.
+Conversion stops earlier in two cases: when a sequence of bytes is encountered that does
+not form a valid multibyte character, or (if dst is not a null pointer) when len wide
+characters have been stored into the array pointed to by dst. Each conversion takes
+place as if by a call to the mbrtowc function.
+
+If dst is not a null pointer, the pointer object pointed to by src is assigned either a null
+pointer (if conversion stopped due to reaching a terminating null character) or the address
+just past the last multibyte character converted (if any). If conversion stopped due to
+reaching a terminating null character and if dst is not a null pointer, the resulting state
+described is the initial conversion state.
+
+ @return If the input conversion encounters a sequence of bytes that do
+ not form a valid multibyte character, an encoding error occurs:
+ the mbsrtowcs function stores the value of the macro EILSEQ in
+ errno and returns (size_t)(-1); the conversion state is
+ unspecified. Otherwise, it returns the number of multibyte
+ characters successfully converted, not including the terminating
+ null character (if any).
+
+ Declared in: wchar.h
+**/
+size_t
+mbsrtowcs(
+ wchar_t *dst,
+ const char **src,
+ size_t len,
+ mbstate_t *ps
+ )
+{
+ int x;
+ size_t RetVal = 0;
+ const char *MySrc;
+
+ if((src == NULL) || (*src == NULL) || (**src == '\0')) {
+ return 0;
+ }
+
+ MySrc = *src;
+ for(x = 1 ; (len != 0) && (x > 0); --len) {
+ x = DecodeOneStateful(dst, MySrc, MB_LEN_MAX, ps);
+ switch(x) {
+ case -2: // Incomplete character
+ case -1: // Encoding error
+ RetVal = (size_t)x;
+ break;
+ case 0: // Encountered NUL character: done.
+ if(dst != NULL) {
+ *dst = 0;
+ *src = NULL;
+ }
+ break;
+ default: // Successfully decoded a character, continue with next
+ MySrc += x;
+ if(dst != NULL) {
+ ++dst;
+ if(x == 4) {
+ ++dst;
+ }
+ *src = MySrc;
+ }
+ ++RetVal;
+ break;
+ }
+ }
+ return RetVal;
+}
+
+/** Convert a multibyte character string into a wide-character string.
+
+ The mbstowcs function converts a sequence of multibyte characters that
+ begins in the initial shift state from the array pointed to by Src into
+ a sequence of corresponding wide characters and stores not more than limit
+ wide characters into the array pointed to by Dest. No multibyte
+ characters that follow a null character (which is converted into a null
+ wide character) will be examined or converted. Each multibyte character
+ is converted as if by a call to the mbtowc function, except that the
+ conversion state of the mbtowc function is not affected.
+
+ No more than Limit elements will be modified in the array pointed to by Dest.
+ If copying takes place between objects that overlap,
+ the behavior is undefined.
+
+ @param[out] Dest Pointer to the array to receive the converted string.
+ @param[in] Src Pointer to the string to be converted.
+ @param[in] Limit Maximum number of elements to be written to Dest.
+
+ @return If an invalid multibyte character is encountered, the mbstowcs
+ function returns (size_t)(-1). Otherwise, the mbstowcs function
+ returns the number of array elements modified, not including a
+ terminating null wide character, if any.
+
+ Declared in: stdlib.h
+**/
+size_t
+mbstowcs(
+ wchar_t *pwcs,
+ const char *s,
+ size_t n
+ )
+{
+
+ /* pwcs may be NULL */
+ /* s may be NULL */
+
+ return mbsrtowcs(pwcs, &s, n, NULL);
+}
+
+/** The btowc function determines whether C constitutes a valid single-byte
+ character in the initial shift state.
+
+ @return The btowc function returns WEOF if c has the value EOF or if
+ (unsigned char)C does not constitute a valid single-byte
+ character in the initial shift state. Otherwise, it returns the
+ wide character representation of that character.
+
+ Declared in: wchar.h
+**/
+wint_t
+btowc(int c)
+{
+ int x;
+ wchar_t Dest;
+ wint_t RetVal = WEOF;
+
+ if (c == EOF)
+ return WEOF;
+ x = DecodeOneStateful(&Dest, (const char *)&c, 1, NULL);
+ if(x == 0) {
+ RetVal = 0;
+ }
+ else if(x == 1) {
+ RetVal = (wint_t)Dest;
+ }
+ return RetVal;
+}
+
+// ######################## Wide to Narrow Conversions #######################
+
+/**
+If S is a null pointer, the wcrtomb function is equivalent to the call:<BR>
+@verbatim
+ wcrtomb(buf, L'\0', ps)
+@endverbatim
+where buf is an internal buffer.
+
+If S is not a null pointer, the wcrtomb function determines the number of bytes needed
+to represent the multibyte character that corresponds to the wide character given by wc
+(including any shift sequences), and stores the multibyte character representation in the
+array whose first element is pointed to by S. At most MB_CUR_MAX bytes are stored. If
+wc is a null wide character, a null byte is stored, preceded by any shift sequence needed
+to restore the initial shift state; the resulting state described is the initial conversion state.
+
+ @return The wcrtomb function returns the number of bytes stored in the
+ array object (including any shift sequences). When wc is not a
+ valid wide character, an encoding error occurs: the function
+ stores the value of the macro EILSEQ in errno and
+ returns (size_t)(-1); the conversion state is unspecified.
+
+ Declared in: wchar.h
+**/
+size_t
+wcrtomb(
+ char *s,
+ wchar_t wchar,
+ mbstate_t *ps
+ )
+{
+ size_t RetVal;
+
+ /* s may be NULL */
+ if (s == NULL) {
+ RetVal = 1;
+ }
+ else {
+ if (wchar == L'\0') {
+ *s = '\0';
+ RetVal = 1;
+ }
+ else {
+ RetVal = EncodeUtf8(s, &wchar, 1);
+ }
+ }
+ return RetVal;
+}
+
+/** Convert a wide character into a multibyte character.
+
+ The wctomb function determines the number of bytes needed to represent the
+ multibyte character corresponding to the wide character given by WC
+ (including any shift sequences), and stores the multibyte character
+ representation in the array whose first element is pointed to by S (if S is
+ not a null pointer). At most MB_CUR_MAX characters are stored. If WC is a
+ null wide character, a null byte is stored, preceded by any shift sequence
+ needed to restore the initial shift state, and the function is left in the
+ initial conversion state.
+
+ @param[out] S Pointer to the object to receive the converted multibyte character.
+ @param[in] WC Wide character to be converted.
+
+ @return If S is a null pointer, the wctomb function returns a nonzero or
+ zero value, if multibyte character encodings, respectively, do or
+ do not have state-dependent encodings. If S is not a null pointer,
+ the wctomb function returns -1 if the value of WC does not
+ correspond to a valid multibyte character, or returns the number
+ of bytes that are contained in the multibyte character
+ corresponding to the value of WC.
+
+ In no case will the value returned be greater than the value of
+ the MB_CUR_MAX macro.
+
+ Declared in: stdlib.h
+**/
+int
+wctomb(
+ char *s,
+ wchar_t wchar
+ )
+{
+ /*
+ If s is NULL just return whether MB Characters have state
+ dependent encodings -- they don't.
+ */
+ if (s == NULL)
+ return 0;
+
+ return (int)wcrtomb(s, wchar, NULL);
+}
+
+/** The wcsrtombs function converts a sequence of wide characters from the array
+ indirectly pointed to by S into a sequence of corresponding multibyte
+ characters that begins in the conversion state described by the object
+ pointed to by ps.
+
+ If S is not a null pointer, the converted characters
+ are then stored into the array pointed to by S. Conversion continues
+ up to and including a terminating null wide character, which is also
+ stored. Conversion stops earlier in two cases: when a wide character is
+ reached that does not correspond to a valid multibyte character, or
+ (if S is not a null pointer) when the next multibyte character would
+ exceed the limit of N total bytes to be stored into the array pointed
+ to by S. Each conversion takes place as if by a call to the wcrtomb
+ function.)
+
+ If S is not a null pointer, the pointer object pointed to by pwcs is
+ assigned either a null pointer (if conversion stopped due to reaching
+ a terminating null wide character) or the address just past the last wide
+ character converted (if any). If conversion stopped due to reaching a
+ terminating null wide character, the resulting state described is the
+ initial conversion state.
+
+ @return If conversion stops because a wide character is reached that
+ does not correspond to a valid multibyte character, an
+ encoding error occurs: the wcsrtombs function stores the
+ value of the macro EILSEQ in errno and returns (size_t)(-1);
+ the conversion state is unspecified. Otherwise, it returns
+ the number of bytes in the resulting multibyte character
+ sequence, not including the terminating null character (if any).
+
+ Declared in: wchar.h
+**/
+size_t
+wcsrtombs(
+ char *s,
+ const wchar_t **pwcs,
+ size_t n,
+ mbstate_t *ps
+)
+{
+ int count = 0;
+
+ /* s may be NULL */
+ /* pwcs may be NULL */
+ /* ps appears to be unused */
+
+ if (pwcs == NULL || *pwcs == NULL)
+ return (0);
+
+ if (s == NULL) {
+ while (*(*pwcs)++ != 0)
+ count++;
+ return(count);
+ }
+
+ if (n != 0) {
+ do {
+ if ((*s++ = (char) *(*pwcs)++) == 0) {
+ *pwcs = NULL;
+ break;
+ }
+ count++;
+ } while (--n != 0);
+ }
+
+ return count;
+}
+
+/** Convert a wide-character string into a multibyte character string.
+
+ The wcstombs function converts a sequence of wide characters from the
+ array pointed to by Src into a sequence of corresponding multibyte
+ characters that begins in the initial shift state, and stores these
+ multibyte characters into the array pointed to by Dest, stopping if a
+ multibyte character would exceed the limit of Limit total bytes or if a
+ null character is stored. Each wide character is converted as if by
+ a call to the wctomb function, except that the conversion state of
+ the wctomb function is not affected.
+
+ No more than Limit bytes will be modified in the array pointed to by Dest.
+ If copying takes place between objects that overlap,
+ the behavior is undefined.
+
+ @param[out] Dest Pointer to the array to receive the converted string.
+ @param[in] Src Pointer to the string to be converted.
+ @param[in] Limit Maximum number of elements to be written to Dest.
+
+ @return If a wide character is encountered that does not correspond to a
+ valid multibyte character, the wcstombs function returns
+ (size_t)(-1). Otherwise, the wcstombs function returns the number
+ of bytes modified, not including a terminating null character,
+ if any.
+
+ Declared in: stdlib.h
+**/
+size_t
+wcstombs(
+ char *s,
+ const wchar_t *pwcs,
+ size_t n
+)
+{
+ /* s may be NULL */
+ return wcsrtombs(s, &pwcs, n, NULL);
+}
+
+/** The wctob function determines whether C corresponds to a member of the extended
+ character set whose multibyte character representation is a single byte when in the initial
+ shift state.
+
+ @return The wctob function returns EOF if C does not correspond to a multibyte
+ character with length one in the initial shift state. Otherwise, it
+ returns the single-byte representation of that character as an
+ unsigned char converted to an int.
+
+ Declared in: wchar.h
+**/
+int
+wctob(wint_t c)
+{
+ /* wctob needs to be consistent with wcrtomb.
+ if wcrtomb says that a character is representable in 1 byte,
+ which this implementation always says, then wctob needs to
+ also represent the character as 1 byte.
+ */
+ if (c == WEOF) {
+ return EOF;
+ }
+ return (int)(c & 0xFF);
+}
diff --git a/edk2/StdLib/LibC/Main/Main.c b/edk2/StdLib/LibC/Main/Main.c
index 59a72bd63..523965fa4 100644
--- a/edk2/StdLib/LibC/Main/Main.c
+++ b/edk2/StdLib/LibC/Main/Main.c
@@ -4,7 +4,7 @@
All of the global data in the gMD structure is initialized to 0, NULL, or
SIG_DFL; as appropriate.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -74,7 +74,7 @@ static
char **
ArgvConvert(UINTN Argc, CHAR16 **Argv)
{
- size_t AVsz; /* Size of a single nArgv string */
+ ssize_t AVsz; /* Size of a single nArgv string, or -1 */
UINTN count;
char **nArgv;
char *string;
@@ -90,7 +90,7 @@ DEBUG_CODE_END();
nArgvSize = Argc;
/* Determine space needed for narrow Argv strings. */
for(count = 0; count < Argc; ++count) {
- AVsz = wcstombs(NULL, Argv[count], ARG_MAX);
+ AVsz = (ssize_t)wcstombs(NULL, Argv[count], ARG_MAX);
if(AVsz < 0) {
Print(L"ABORTING: Argv[%d] contains an unconvertable character.\n", count);
exit(EXIT_FAILURE);
diff --git a/edk2/StdLib/LibC/StdLib/Malloc.c b/edk2/StdLib/LibC/StdLib/Malloc.c
index 51068d3a0..3f79deb49 100644
--- a/edk2/StdLib/LibC/StdLib/Malloc.c
+++ b/edk2/StdLib/LibC/StdLib/Malloc.c
@@ -137,7 +137,9 @@ calloc(size_t Num, size_t Size)
void
free(void *Ptr)
{
- (void) gBS->FreePool (Ptr);
+ if(Ptr != NULL) {
+ (void) gBS->FreePool (Ptr);
+ }
}
/** The realloc function changes the size of the object pointed to by Ptr to
diff --git a/edk2/StdLib/LibC/Stdio/fputwc.c b/edk2/StdLib/LibC/Stdio/fputwc.c
index 8bbd40736..76ed83920 100644
--- a/edk2/StdLib/LibC/Stdio/fputwc.c
+++ b/edk2/StdLib/LibC/Stdio/fputwc.c
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
@@ -81,7 +81,6 @@ __fputwc_unlock(wchar_t wc, FILE *fp)
size = wcrtomb(buf, wc, st);
if (size == (size_t)-1) {
- errno = EILSEQ;
return WEOF;
}
diff --git a/edk2/StdLib/LibC/Stdio/makebuf.c b/edk2/StdLib/LibC/Stdio/makebuf.c
index 1b5991489..684f0eebc 100644
--- a/edk2/StdLib/LibC/Stdio/makebuf.c
+++ b/edk2/StdLib/LibC/Stdio/makebuf.c
@@ -1,7 +1,7 @@
/** @file
Implementation of internal file buffer allocation functions.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
@@ -77,11 +77,12 @@ __smakebuf(FILE *fp)
if (fp != NULL) {
if (fp->_flags & __SNBF) {
fp->_bf._base = fp->_p = fp->_nbuf;
- fp->_bf._size = 1;
+ fp->_bf._size = MB_LEN_MAX;
return;
}
flags = __swhatbuf(fp, &size, &couldbetty);
if ((p = malloc(size)) == NULL) {
+ // malloc failed, act unbuffered.
fp->_flags |= __SNBF;
fp->_bf._base = fp->_p = fp->_nbuf;
fp->_bf._size = 1;
diff --git a/edk2/StdLib/LibC/Stdio/refill.c b/edk2/StdLib/LibC/Stdio/refill.c
index 953e8f674..a69f022de 100644
--- a/edk2/StdLib/LibC/Stdio/refill.c
+++ b/edk2/StdLib/LibC/Stdio/refill.c
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License that accompanies this
distribution. The full text of the license may be found at
@@ -41,9 +41,6 @@
NetBSD: refill.c,v 1.13 2003/08/07 16:43:30 agc Exp
refill.c 8.1 (Berkeley) 6/4/93
*/
-#include <Uefi.h> // REMOVE, For DEBUG only
-#include <Library/UefiLib.h> // REMOVE, For DEBUG only
-
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
@@ -93,28 +90,23 @@ __srefill(FILE *fp)
if (!__sdidinit)
__sinit();
-//Print(L"%a( %d)\n", __func__, fp->_file);
fp->_r = 0; /* largely a convenience for callers */
/* SysV does not make this test; take it out for compatibility */
if (fp->_flags & __SEOF) {
-//Print(L"%a: %d\n", __func__, __LINE__);
return (EOF);
}
/* if not already reading, have to be reading and writing */
if ((fp->_flags & __SRD) == 0) {
-//Print(L"%a: %d\n", __func__, __LINE__);
if ((fp->_flags & __SRW) == 0) {
errno = EBADF;
fp->_flags |= __SERR; //<dvm> Allows differentiation between errors and EOF
-//Print(L"%a: %d\n", __func__, __LINE__);
return (EOF);
}
/* switch to reading */
if (fp->_flags & __SWR) {
if (__sflush(fp)) {
-//Print(L"%a: %d\n", __func__, __LINE__);
return (EOF);
}
fp->_flags &= ~__SWR;
@@ -123,7 +115,6 @@ __srefill(FILE *fp)
}
fp->_flags |= __SRD;
} else {
-//Print(L"%a: %d\n", __func__, __LINE__);
/*
* We were reading. If there is an ungetc buffer,
* we must have been reading from that. Drop it,
@@ -134,7 +125,6 @@ __srefill(FILE *fp)
FREEUB(fp);
if ((fp->_r = fp->_ur) != 0) {
fp->_p = fp->_up;
-//Print(L"%a: %d\n", __func__, __LINE__);
return (0);
}
}
@@ -143,7 +133,6 @@ __srefill(FILE *fp)
if (fp->_bf._base == NULL)
__smakebuf(fp);
-//Print(L"%a: %d\n", __func__, __LINE__);
/*
* Before reading from a line buffered or unbuffered file,
* flush all line buffered output files, per the ANSI C
@@ -153,7 +142,6 @@ __srefill(FILE *fp)
rwlock_rdlock(&__sfp_lock);
(void) _fwalk(lflush);
rwlock_unlock(&__sfp_lock);
-//Print(L"%a: %d\n", __func__, __LINE__);
}
fp->_p = fp->_bf._base;
fp->_r = (*fp->_read)(fp->_cookie, (char *)fp->_p, fp->_bf._size);
@@ -165,9 +153,7 @@ __srefill(FILE *fp)
fp->_r = 0;
fp->_flags |= __SERR;
}
-//Print(L"%a: %d\n", __func__, __LINE__);
return (EOF);
}
-//Print(L"%a: %d\n", __func__, __LINE__);
return (0);
}
diff --git a/edk2/StdLib/LibC/Uefi/Devices/Console/daConsole.c b/edk2/StdLib/LibC/Uefi/Devices/Console/daConsole.c
index e9983e993..4897a2e56 100644
--- a/edk2/StdLib/LibC/Uefi/Devices/Console/daConsole.c
+++ b/edk2/StdLib/LibC/Uefi/Devices/Console/daConsole.c
@@ -3,7 +3,7 @@
Manipulates abstractions for stdin, stdout, stderr.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -52,27 +52,46 @@ static wchar_t *ConReadBuf;
static BOOLEAN TtyCooked;
static BOOLEAN TtyEcho;
+/** Convert string from MBCS to WCS and translate \n to \r\n.
+
+ It is the caller's responsibility to ensure that dest is
+ large enough to hold the converted results. It is guaranteed
+ that there will be fewer than n characters placed in dest.
+
+ @param dest WCS buffer to receive the converted string.
+ @param buf MBCS string to convert to WCS.
+ @param n Number of BYTES contained in buf.
+ @param Cs Pointer to the character state object for this stream
+
+ @return The number of BYTES consumed from buf.
+**/
ssize_t
-WideTtyCvt( CHAR16 *dest, const char *buf, size_t n)
+WideTtyCvt( CHAR16 *dest, const char *buf, ssize_t n, mbstate_t *Cs)
{
- UINTN i;
- wint_t wc;
+ ssize_t i = 0;
+ int numB = 0;
+ wchar_t wc[2];
- for(i = 0; i < n; ++i) {
- wc = btowc(*buf++);
- if( wc == 0) {
+ while(n > 0) {
+ numB = (int)mbrtowc(wc, buf, MIN(MB_LEN_MAX,n), Cs);
+ if( numB == 0) {
break;
};
- if(wc < 0) {
- wc = BLOCKELEMENT_LIGHT_SHADE;
+ if(numB < 0) { // If an unconvertable character, replace it.
+ wc[0] = BLOCKELEMENT_LIGHT_SHADE;
+ numB = 1;
}
- if(wc == L'\n') {
+ if(wc[0] == L'\n') {
*dest++ = L'\r';
+ ++i;
}
- *dest++ = (CHAR16)wc;
+ *dest++ = (CHAR16)wc[0];
+ i += numB;
+ n -= numB;
+ buf += numB;
}
*dest = 0;
- return (ssize_t)i;
+ return i;
}
static
@@ -105,7 +124,7 @@ da_ConSeek(
{
ConInstance *Stream;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Proto;
- XYoffset CursorPos;
+ XY_OFFSET CursorPos;
Stream = BASE_CR(filp->f_ops, ConInstance, Abstraction);
// Quick check to see if Stream looks reasonable
@@ -140,7 +159,7 @@ da_ConSeek(
the string couldn't be displayed.
@param[in] Buffer The WCS string to be displayed
- @return The number of characters written.
+ @return The number of BYTES written. Because of MBCS, this may be more than number of characters.
*/
static
ssize_t
@@ -155,8 +174,7 @@ da_ConWrite(
EFI_STATUS Status;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Proto;
ConInstance *Stream;
- ssize_t NumChar;
- //XYoffset CursorPos;
+ ssize_t NumBytes;
Stream = BASE_CR(filp->f_ops, ConInstance, Abstraction);
// Quick check to see if Stream looks reasonable
@@ -173,34 +191,21 @@ da_ConWrite(
Proto = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)Stream->Dev;
// Convert string from MBCS to WCS and translate \n to \r\n.
- NumChar = WideTtyCvt(gMD->UString, (const char *)Buffer, BufferSize);
- //if(NumChar > 0) {
- // BufferSize = (size_t)(NumChar * sizeof(CHAR16));
- //}
- BufferSize = NumChar;
-
- //if( Position != NULL) {
- // CursorPos.Offset = (UINT64)*Position;
-
- // Status = Proto->SetCursorPosition(Proto,
- // (INTN)CursorPos.XYpos.Column,
- // (INTN)CursorPos.XYpos.Row);
- // if(RETURN_ERROR(Status)) {
- // return -1;
- // }
- //}
+ NumBytes = WideTtyCvt(gMD->UString, (const char *)Buffer, (ssize_t)BufferSize, &Stream->CharState);
+ BufferSize = NumBytes;
+
// Send the Unicode buffer to the console
Status = Proto->OutputString( Proto, gMD->UString);
// Depending on status, update BufferSize and return
if(RETURN_ERROR(Status)) {
- BufferSize = 0; // We don't really know how many characters made it out
+ BufferSize = 0; // We don't really know how many characters made it out
}
else {
- //BufferSize = NumChar;
- Stream->NumWritten += NumChar;
+ //BufferSize = NumBytes;
+ Stream->NumWritten += NumBytes;
}
- EFIerrno = Status;
+ EFIerrno = Status; // Make error reason available to caller
return BufferSize;
}
@@ -327,7 +332,7 @@ da_ConStat(
{
ConInstance *Stream;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Proto;
- XYoffset CursorPos;
+ XY_OFFSET CursorPos;
INT32 OutMode;
UINTN ModeCol;
UINTN ModeRow;
@@ -342,7 +347,8 @@ da_ConStat(
return -1;
}
// All of our parameters are correct, so fill in the information.
- Buffer->st_blksize = 1;
+ Buffer->st_blksize = 0; // Character device, not a block device
+ Buffer->st_mode = filp->f_iflags;
// ConGetPosition
if(Stream->InstanceNum == STDIN_FILENO) {
@@ -504,6 +510,7 @@ __Cons_construct(
Stream->Cookie = CON_COOKIE;
Stream->InstanceNum = i;
+ Stream->CharState.A = 0; // Start in the initial state
switch(i) {
case STDIN_FILENO:
diff --git a/edk2/StdLib/LibC/Uefi/SysCalls.c b/edk2/StdLib/LibC/Uefi/SysCalls.c
index ebae38f3f..5576938f8 100644
--- a/edk2/StdLib/LibC/Uefi/SysCalls.c
+++ b/edk2/StdLib/LibC/Uefi/SysCalls.c
@@ -1,7 +1,7 @@
/** @file
EFI versions of NetBSD system calls.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -557,16 +557,38 @@ mkdir (const char *path, __mode_t perms)
}
/** Open a file.
+ The open() function establishes the connection between a file and a file
+ descriptor. It creates an open file description that refers to a file
+ and a file descriptor that refers to that open file description. The file
+ descriptor is used by other I/O functions to refer to that file.
+
+ The open() function returns a file descriptor for the named file that is
+ the lowest file descriptor not currently open for that process. The open
+ file description is new, and therefore the file descriptor shall not
+ share it with any other process in the system.
+
+ The file offset used to mark the current position within the file is set
+ to the beginning of the file.
The EFI ShellOpenFileByName() function is used to perform the low-level
file open operation. The primary task of open() is to translate from the
flags used in the <stdio.h> environment to those used by the EFI function.
+ The file status flags and file access modes of the open file description
+ are set according to the value of oflags.
+
+ Values for oflags are constructed by a bitwise-inclusive OR of flags from
+ the following list, defined in <fcntl.h>. Applications shall specify
+ exactly one of { O_RDONLY, O_RDWR, O_WRONLY } in the value of oflags.
+ Any combination of { O_NONBLOCK, O_APPEND, O_CREAT, O_TRUNC, O_EXCL } may
+ also be specified in oflags.
+
The only valid flag combinations for ShellOpenFileByName() are:
- Read
- Read/Write
- Create/Read/Write
+ Values for mode specify the access permissions for newly created files.
The mode value is saved in the FD to indicate permissions for further operations.
O_RDONLY -- flags = EFI_FILE_MODE_READ -- this is always done
@@ -578,6 +600,25 @@ mkdir (const char *path, __mode_t perms)
O_CREAT -- flags |= EFI_FILE_MODE_CREATE
O_TRUNC -- delete first then create new
O_EXCL -- if O_CREAT is also set, open will fail if the file already exists.
+
+ @param[in] Path The path argument points to a pathname naming the
+ object to be opened.
+ @param[in] oflags File status flags and file access modes of the
+ open file description.
+ @param[in] mode File access permission bits as defined in
+ <sys/stat.h>.
+
+ @return Upon successful completion, open() opens the file and returns
+ a non-negative integer representing the lowest numbered
+ unused file descriptor. Otherwise, open returns -1 and sets
+ errno to indicate the error. If a negative value is
+ returned, no files are created or modified.
+
+ @retval EMFILE No file descriptors available -- Max number already open.
+ @retval EINVAL Bad value specified for oflags or mode.
+ @retval ENOMEM Failure allocating memory for internal buffers.
+ @retval EEXIST File exists and open attempted with (O_EXCL | O_CREAT) set.
+ @retval EIO UEFI failure. Check value in EFIerrno.
**/
int
open(
diff --git a/edk2/StdLib/LibC/gdtoa/strtod.c b/edk2/StdLib/LibC/gdtoa/strtod.c
index 989663a01..5cc6b8e44 100644
--- a/edk2/StdLib/LibC/gdtoa/strtod.c
+++ b/edk2/StdLib/LibC/gdtoa/strtod.c
@@ -1,35 +1,48 @@
-/* $NetBSD: strtod.c,v 1.4.14.1 2008/04/08 21:10:55 jdc Exp $ */
-
-/****************************************************************
-
-The author of this software is David M. Gay.
-
-Copyright (C) 1998-2001 by Lucent Technologies
-All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and
-its documentation for any purpose and without fee is hereby
-granted, provided that the above copyright notice appear in all
-copies and that both that the copyright notice and this
-permission notice and warranty disclaimer appear in supporting
-documentation, and that the name of Lucent or any of its entities
-not be used in advertising or publicity pertaining to
-distribution of the software without specific, written prior
-permission.
-
-LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
-IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
-SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
-IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
-THIS SOFTWARE.
-
-****************************************************************/
-
-/* Please send bug reports to David M. Gay (dmg at acm dot org,
- * with " at " changed at "@" and " dot " changed to "."). */
+/** @file
+
+ Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ *****************************************************************
+
+ The author of this software is David M. Gay.
+
+ Copyright (C) 1998-2001 by Lucent Technologies
+ All Rights Reserved
+
+ Permission to use, copy, modify, and distribute this software and
+ its documentation for any purpose and without fee is hereby
+ granted, provided that the above copyright notice appear in all
+ copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of Lucent or any of its entities
+ not be used in advertising or publicity pertaining to
+ distribution of the software without specific, written prior
+ permission.
+
+ LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+ SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ THIS SOFTWARE.
+
+
+ Please send bug reports to David M. Gay (dmg at acm dot org,
+ with " at " changed at "@" and " dot " changed to ".").
+
+ *****************************************************************
+
+ NetBSD: strtod.c,v 1.4.14.1 2008/04/08 21:10:55 jdc Exp
+**/
#include <LibConfig.h>
#include "gdtoaimp.h"
@@ -477,7 +490,7 @@ strtod(CONST char *s00, char **se)
for(j = 0; e1 > 0; j++, e1 = (unsigned int)e1 >> 1)
if (e1 & 1)
dval(rv) *= tinytens[j];
- if (scale && (j = 2*P + 1 - ((word0(rv) & Exp_mask)
+ if (scale && (j = 2*P + 1 - (unsigned int)((word0(rv) & Exp_mask)
>> Exp_shift)) > 0) {
/* scaled rv is denormal; zap j low bits */
if (j >= 32) {
diff --git a/edk2/StdLib/LibC/gdtoa/strtodg.c b/edk2/StdLib/LibC/gdtoa/strtodg.c
index fc0ae7cf3..a8c28cf09 100644
--- a/edk2/StdLib/LibC/gdtoa/strtodg.c
+++ b/edk2/StdLib/LibC/gdtoa/strtodg.c
@@ -1,35 +1,48 @@
-/* $NetBSD: strtodg.c,v 1.5.14.1 2008/04/08 21:10:55 jdc Exp $ */
+/** @file
-/****************************************************************
+ Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
-The author of this software is David M. Gay.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Copyright (C) 1998-2001 by Lucent Technologies
-All Rights Reserved
+ *****************************************************************
-Permission to use, copy, modify, and distribute this software and
-its documentation for any purpose and without fee is hereby
-granted, provided that the above copyright notice appear in all
-copies and that both that the copyright notice and this
-permission notice and warranty disclaimer appear in supporting
-documentation, and that the name of Lucent or any of its entities
-not be used in advertising or publicity pertaining to
-distribution of the software without specific, written prior
-permission.
+ The author of this software is David M. Gay.
-LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
-IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
-SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
-IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
-THIS SOFTWARE.
+ Copyright (C) 1998-2001 by Lucent Technologies
+ All Rights Reserved
-****************************************************************/
+ Permission to use, copy, modify, and distribute this software and
+ its documentation for any purpose and without fee is hereby
+ granted, provided that the above copyright notice appear in all
+ copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of Lucent or any of its entities
+ not be used in advertising or publicity pertaining to
+ distribution of the software without specific, written prior
+ permission.
-/* Please send bug reports to David M. Gay (dmg at acm dot org,
- * with " at " changed at "@" and " dot " changed to "."). */
+ LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+ SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ THIS SOFTWARE.
+
+
+ Please send bug reports to David M. Gay (dmg at acm dot org,
+ with " at " changed at "@" and " dot " changed to ".").
+
+ *****************************************************************
+
+ NetBSD: strtodg.c,v 1.5.14.1 2008/04/08 21:10:55 jdc Exp
+**/
#include <LibConfig.h>
#include "gdtoaimp.h"
@@ -611,14 +624,14 @@ strtodg
if (e1 &= ~15) {
e1 = (unsigned int)e1 >> 4;
while(e1 >= (1 << (n_bigtens-1))) {
- e2 += ((word0(rv) & Exp_mask)
+ e2 += (unsigned int)((word0(rv) & Exp_mask)
>> Exp_shift1) - Bias;
word0(rv) &= ~Exp_mask;
word0(rv) |= Bias << Exp_shift1;
dval(rv) *= bigtens[n_bigtens-1];
e1 -= 1 << (n_bigtens-1);
}
- e2 += ((word0(rv) & Exp_mask) >> Exp_shift1) - Bias;
+ e2 += (unsigned int)((word0(rv) & Exp_mask) >> Exp_shift1) - Bias;
word0(rv) &= ~Exp_mask;
word0(rv) |= Bias << Exp_shift1;
for(j = 0; e1 > 0; j++, e1 = (unsigned int)e1 >> 1)
@@ -633,14 +646,14 @@ strtodg
if (e1 &= ~15) {
e1 = (unsigned int)e1 >> 4;
while(e1 >= (1 << (n_bigtens-1))) {
- e2 += ((word0(rv) & Exp_mask)
+ e2 += (unsigned int)((word0(rv) & Exp_mask)
>> Exp_shift1) - Bias;
word0(rv) &= ~Exp_mask;
word0(rv) |= Bias << Exp_shift1;
dval(rv) *= tinytens[n_bigtens-1];
e1 -= 1 << (n_bigtens-1);
}
- e2 += ((word0(rv) & Exp_mask) >> Exp_shift1) - Bias;
+ e2 += (unsigned int)((word0(rv) & Exp_mask) >> Exp_shift1) - Bias;
word0(rv) &= ~Exp_mask;
word0(rv) |= Bias << Exp_shift1;
for(j = 0; e1 > 0; j++, e1 = (unsigned int)e1 >> 1)
diff --git a/edk2/StdLib/License.txt b/edk2/StdLib/License.txt
new file mode 100644
index 000000000..be68999be
--- /dev/null
+++ b/edk2/StdLib/License.txt
@@ -0,0 +1,25 @@
+Copyright (c) 2012, Intel Corporation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/edk2/StdLib/StdLib.inc b/edk2/StdLib/StdLib.inc
index fa1865659..4b7e37eb6 100644
--- a/edk2/StdLib/StdLib.inc
+++ b/edk2/StdLib/StdLib.inc
@@ -5,7 +5,7 @@
# The including DSC file must DEFINE the EMULATE macro if
# the application is to be run in an emulation environment.
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -25,6 +25,12 @@
UseSocketDxe|StdLib/UseSocketDxe/UseSocketDxe.inf
[LibraryClasses.Common.UEFI_APPLICATION]
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf
+ PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf
+ ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
+
#
# C Standard Libraries
#
@@ -56,7 +62,7 @@
DevShell|StdLib/LibC/Uefi/Devices/daShell.inf
DevUtility|StdLib/LibC/Uefi/Devices/daUtility.inf
-[LibraryClasses.ARM.UEFI_APPLICATION]
+[LibraryClasses.ARM]
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
[Components]
@@ -90,19 +96,19 @@
!ifndef $(EMULATE)
# These Build Options are used when building the Standard Libraries to be run
# on real hardware.
- INTEL:*_*_*_CC_FLAGS = /Qfreestanding
- MSFT:*_*_*_CC_FLAGS = /X /Zc:wchar_t
- GCC:*_*_*_CC_FLAGS = -nostdinc -nostdlib
- RVCT:*_*_*_CC_FLAGS = --library_interface=none -J$(WORKSPACE)/StdLib/Include -J$(WORKSPACE)/StdLib/Include/Arm
- ARMGCC:*_*_*_CC_FLAGS = -nostdinc -nostdlib -Wno-unknown-pragmas -Wno-unused -Wno-format-zero-length
+ INTEL:*_*_*_CC_FLAGS = /Qfreestanding /D UEFI_C_SOURCE
+ MSFT:*_*_*_CC_FLAGS = /X /Zc:wchar_t /D UEFI_C_SOURCE
+ GCC:*_*_*_CC_FLAGS = -nostdinc -nostdlib -DUEFI_C_SOURCE
+ RVCT:*_*_*_CC_FLAGS = --library_interface=none -DUEFI_C_SOURCE -J$(WORKSPACE)/StdLib/Include -J$(WORKSPACE)/StdLib/Include/Arm
+ ARMGCC:*_*_*_CC_FLAGS = -nostdinc -nostdlib -DUEFI_C_SOURCE -Wno-unknown-pragmas -Wno-unused -Wno-format-zero-length
!else
# The Build Options, below, are only used when building the Standard Libraries
# to be run under an emulation environment.
# They disable optimization which facillitates debugging under the Emulation environment.
- INTEL:*_*_IA32_CC_FLAGS = /Od
- MSFT:*_*_IA32_CC_FLAGS = /Od
- GCC:*_*_IA32_CC_FLAGS = -O0
- RVCT:*_*_*_CC_FLAGS = --library_interface=none -J$(WORKSPACE)/StdLib/Include -J$(WORKSPACE)/StdLib/Include/Arm
- ARMGCC:*_*_*_CC_FLAGS = -O0 -Wno-unknown-pragmas -Wno-unused -Wno-format-zero-length
+ INTEL:*_*_IA32_CC_FLAGS = /Od /D UEFI_C_SOURCE
+ MSFT:*_*_IA32_CC_FLAGS = /Od /D UEFI_C_SOURCE
+ GCC:*_*_IA32_CC_FLAGS = -O0 -DUEFI_C_SOURCE
+ RVCT:*_*_*_CC_FLAGS = --library_interface=none -DUEFI_C_SOURCE -J$(WORKSPACE)/StdLib/Include -J$(WORKSPACE)/StdLib/Include/Arm
+ ARMGCC:*_*_*_CC_FLAGS = -O0 -DUEFI_C_SOURCE -Wno-unknown-pragmas -Wno-unused -Wno-format-zero-length
!endif