diff options
author | Ryan Harkin <ryan.harkin@linaro.org> | 2012-10-12 11:46:51 +0100 |
---|---|---|
committer | Ryan Harkin <ryan.harkin@linaro.org> | 2012-10-12 11:46:51 +0100 |
commit | b60dc2d3e998a65b6d34bfd852838ea1149f19f9 (patch) | |
tree | 7393bc3f451803043afe8cc12fd78ecc4d1f1215 /edk2/EmbeddedPkg | |
parent | 25323acd0c4c5d7aba0125d031066e55333f214b (diff) | |
parent | 67154aa040304dd7b32471f32f3b0f2d4dfbb984 (diff) |
Merge branch 'armlt-tracking' of git://git.linaro.org/arm/uefi/uefi-nextlinaro-uefi-2012.10
Diffstat (limited to 'edk2/EmbeddedPkg')
24 files changed, 835 insertions, 1136 deletions
diff --git a/edk2/EmbeddedPkg/Contributions.txt b/edk2/EmbeddedPkg/Contributions.txt new file mode 100644 index 000000000..667ca1035 --- /dev/null +++ b/edk2/EmbeddedPkg/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/EmbeddedPkg/Ebl/Main.c b/edk2/EmbeddedPkg/Ebl/Main.c index e4879bcf9..f1665627a 100644 --- a/edk2/EmbeddedPkg/Ebl/Main.c +++ b/edk2/EmbeddedPkg/Ebl/Main.c @@ -557,6 +557,8 @@ ProcessCmdLine ( // if any command fails stop processing CmdLine
break;
}
+ } else {
+ AsciiPrint ("The command '%a' is not supported.\n", Argv[0]);
}
}
}
diff --git a/edk2/EmbeddedPkg/EmbeddedPkg.dec b/edk2/EmbeddedPkg/EmbeddedPkg.dec index 5165f04d1..f4cf1b312 100644 --- a/edk2/EmbeddedPkg/EmbeddedPkg.dec +++ b/edk2/EmbeddedPkg/EmbeddedPkg.dec @@ -108,6 +108,8 @@ gEmbeddedTokenSpaceGuid.PcdTimerVector|7|UINT32|0x0000001d
gEmbeddedTokenSpaceGuid.PcdTimerPeriod|100000|UINT32|0x0000001e
gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress|0x38e00000|UINT32|0x0000001f
+
+ gEmbeddedTokenSpaceGuid.PcdMetronomeTickPeriod|100|UINT32|0x00000020
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress|0xffff0000|UINT32|0x00000030
gEmbeddedTokenSpaceGuid.PcdEmbeddedFdSize|0x0000000|UINT32|0x00000031
diff --git a/edk2/EmbeddedPkg/EmbeddedPkg.dsc b/edk2/EmbeddedPkg/EmbeddedPkg.dsc index c3a2464f3..8862f3d1e 100644 --- a/edk2/EmbeddedPkg/EmbeddedPkg.dsc +++ b/edk2/EmbeddedPkg/EmbeddedPkg.dsc @@ -97,7 +97,6 @@ EblNetworkLib|EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf - FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf [LibraryClasses.common.DXE_DRIVER] PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf diff --git a/edk2/EmbeddedPkg/Include/Library/SerialPortExtLib.h b/edk2/EmbeddedPkg/Include/Library/SerialPortExtLib.h new file mode 100644 index 000000000..74f5e4c58 --- /dev/null +++ b/edk2/EmbeddedPkg/Include/Library/SerialPortExtLib.h @@ -0,0 +1,66 @@ +/** @file + + Copyright (c) 2012, ARM Ltd. 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.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. + +**/ + +#ifndef __SERIAL_PORT_EXT_LIB_H__ +#define __SERIAL_PORT_EXT_LIB_H__ + +#include <Uefi/UefiBaseType.h> +#include <Protocol/SerialIo.h> + +/** + Set the serial device control bits. + + @return Always return EFI_UNSUPPORTED. + +**/ +RETURN_STATUS +EFIAPI +SerialPortSetControl ( + IN UINT32 Control + ); + +/** + Get the serial device control bits. + + @param Control Control signals read from the serial device. + + @retval EFI_SUCCESS The control bits were read from the serial device. + @retval EFI_DEVICE_ERROR The serial device is not functioning correctly. + +**/ +RETURN_STATUS +EFIAPI +SerialPortGetControl ( + OUT UINT32 *Control + ); + +/** + Set the serial device attributes. + + @return Always return EFI_UNSUPPORTED. + +**/ +RETURN_STATUS +EFIAPI +SerialPortSetAttributes ( + IN UINT64 BaudRate, + IN UINT32 ReceiveFifoDepth, + IN UINT32 Timeout, + IN EFI_PARITY_TYPE Parity, + IN UINT8 DataBits, + IN EFI_STOP_BITS_TYPE StopBits + ); + +#endif + diff --git a/edk2/EmbeddedPkg/Include/fdt.h b/edk2/EmbeddedPkg/Include/fdt.h index 48ccfd910..6e7a8b397 100644 --- a/edk2/EmbeddedPkg/Include/fdt.h +++ b/edk2/EmbeddedPkg/Include/fdt.h @@ -1,3 +1,17 @@ +/** @file +* +* Copyright (c) 2011-2012, ARM Limited. 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.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. +* +**/ + #ifndef _FDT_H #define _FDT_H diff --git a/edk2/EmbeddedPkg/Include/libfdt.h b/edk2/EmbeddedPkg/Include/libfdt.h index 060479eb2..73f49759a 100644 --- a/edk2/EmbeddedPkg/Include/libfdt.h +++ b/edk2/EmbeddedPkg/Include/libfdt.h @@ -852,17 +852,17 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, const void *val, int len); /** - * fdt_setprop_inplace_cell - change the value of a single-cell property + * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property * @fdt: pointer to the device tree blob * @nodeoffset: offset of the node whose property to change * @name: name of the property to change - * @val: cell (32-bit integer) value to replace the property with + * @val: 32-bit integer value to replace the property with * - * fdt_setprop_inplace_cell() replaces the value of a given property - * with the 32-bit integer cell value in val, converting val to - * big-endian if necessary. This function cannot change the size of a - * property, and so will only work if the property already exists and - * has length 4. + * fdt_setprop_inplace_u32() replaces the value of a given property + * with the 32-bit integer value in val, converting val to big-endian + * if necessary. This function cannot change the size of a property, + * and so will only work if the property already exists and has length + * 4. * * This function will alter only the bytes in the blob which contain * the given property value, and will not alter or move any other part @@ -871,7 +871,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, * returns: * 0, on success * -FDT_ERR_NOSPACE, if the property's length is not equal to 4 - * -FDT_ERR_NOTFOUND, node does not have the named property + * -FDT_ERR_NOTFOUND, node does not have the named property * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag * -FDT_ERR_BADMAGIC, * -FDT_ERR_BADVERSION, @@ -879,14 +879,60 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, * -FDT_ERR_BADSTRUCTURE, * -FDT_ERR_TRUNCATED, standard meanings */ -static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, - const char *name, uint32_t val) +static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, + const char *name, uint32_t val) { val = cpu_to_fdt32(val); return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val)); } /** + * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 64-bit integer value to replace the property with + * + * fdt_setprop_inplace_u64() replaces the value of a given property + * with the 64-bit integer value in val, converting val to big-endian + * if necessary. This function cannot change the size of a property, + * and so will only work if the property already exists and has length + * 8. + * + * This function will alter only the bytes in the blob which contain + * the given property value, and will not alter or move any other part + * of the tree. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, if the property's length is not equal to 8 + * -FDT_ERR_NOTFOUND, node does not have the named property + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset, + const char *name, uint64_t val) +{ + val = cpu_to_fdt64(val); + return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val)); +} + +/** + * fdt_setprop_inplace_cell - change the value of a single-cell property + * + * This is an alternative name for fdt_setprop_inplace_u32() + */ +static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, + const char *name, uint32_t val) +{ + return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val); +} + +/** * fdt_nop_property - replace a property with nop tags * @fdt: pointer to the device tree blob * @nodeoffset: offset of the node whose property to nop @@ -945,11 +991,20 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size); int fdt_finish_reservemap(void *fdt); int fdt_begin_node(void *fdt, const char *name); int fdt_property(void *fdt, const char *name, const void *val, int len); -static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) +static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val) { val = cpu_to_fdt32(val); return fdt_property(fdt, name, &val, sizeof(val)); } +static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val) +{ + val = cpu_to_fdt64(val); + return fdt_property(fdt, name, &val, sizeof(val)); +} +static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) +{ + return fdt_property_u32(fdt, name, val); +} #define fdt_property_string(fdt, name, str) \ fdt_property(fdt, name, str, strlen(str)+1) int fdt_end_node(void *fdt); @@ -959,6 +1014,7 @@ int fdt_finish(void *fdt); /* Read-write functions */ /**********************************************************************/ +int fdt_create_empty_tree(void *buf, int bufsize); int fdt_open_into(const void *fdt, void *buf, int bufsize); int fdt_pack(void *fdt); @@ -1068,14 +1124,14 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, const void *val, int len); /** - * fdt_setprop_cell - set a property to a single cell value + * fdt_setprop_u32 - set a property to a 32-bit integer * @fdt: pointer to the device tree blob * @nodeoffset: offset of the node whose property to change * @name: name of the property to change * @val: 32-bit integer value for the property (native endian) * - * fdt_setprop_cell() sets the value of the named property in the - * given node to the given cell value (converting to big-endian if + * fdt_setprop_u32() sets the value of the named property in the given + * node to the given 32-bit integer value (converting to big-endian if * necessary), or creates a new property with that value if it does * not already exist. * @@ -1095,14 +1151,60 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, * -FDT_ERR_BADLAYOUT, * -FDT_ERR_TRUNCATED, standard meanings */ -static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, - uint32_t val) +static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name, + uint32_t val) { val = cpu_to_fdt32(val); return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val)); } /** + * fdt_setprop_u64 - set a property to a 64-bit integer + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 64-bit integer value for the property (native endian) + * + * fdt_setprop_u64() sets the value of the named property in the given + * node to the given 64-bit integer value (converting to big-endian if + * necessary), or creates a new property with that value if it does + * not already exist. + * + * This function may insert or delete data from the blob, and will + * therefore change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new property value + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name, + uint64_t val) +{ + val = cpu_to_fdt64(val); + return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val)); +} + +/** + * fdt_setprop_cell - set a property to a single cell value + * + * This is an alternative name for fdt_setprop_u32() + */ +static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, + uint32_t val) +{ + return fdt_setprop_u32(fdt, nodeoffset, name, val); +} + +/** * fdt_setprop_string - set a property to a string value * @fdt: pointer to the device tree blob * @nodeoffset: offset of the node whose property to change @@ -1164,16 +1266,16 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, const void *val, int len); /** - * fdt_appendprop_cell - append a single cell value to a property + * fdt_appendprop_u32 - append a 32-bit integer value to a property * @fdt: pointer to the device tree blob * @nodeoffset: offset of the node whose property to change * @name: name of the property to change * @val: 32-bit integer value to append to the property (native endian) * - * fdt_appendprop_cell() appends the given cell value (converting to - * big-endian if necessary) to the value of the named property in the - * given node, or creates a new property with that value if it does - * not already exist. + * fdt_appendprop_u32() appends the given 32-bit integer value + * (converting to big-endian if necessary) to the value of the named + * property in the given node, or creates a new property with that + * value if it does not already exist. * * This function may insert data into the blob, and will therefore * change the offsets of some existing nodes. @@ -1191,14 +1293,60 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name, * -FDT_ERR_BADLAYOUT, * -FDT_ERR_TRUNCATED, standard meanings */ -static inline int fdt_appendprop_cell(void *fdt, int nodeoffset, - const char *name, uint32_t val) +static inline int fdt_appendprop_u32(void *fdt, int nodeoffset, + const char *name, uint32_t val) { val = cpu_to_fdt32(val); return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val)); } /** + * fdt_appendprop_u64 - append a 64-bit integer value to a property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 64-bit integer value to append to the property (native endian) + * + * fdt_appendprop_u64() appends the given 64-bit integer value + * (converting to big-endian if necessary) to the value of the named + * property in the given node, or creates a new property with that + * value if it does not already exist. + * + * This function may insert data into the blob, and will therefore + * change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new property value + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +static inline int fdt_appendprop_u64(void *fdt, int nodeoffset, + const char *name, uint64_t val) +{ + val = cpu_to_fdt64(val); + return fdt_appendprop(fdt, nodeoffset, name, &val, sizeof(val)); +} + +/** + * fdt_appendprop_cell - append a single cell value to a property + * + * This is an alternative name for fdt_appendprop_u32() + */ +static inline int fdt_appendprop_cell(void *fdt, int nodeoffset, + const char *name, uint32_t val) +{ + return fdt_appendprop_u32(fdt, nodeoffset, name, val); +} + +/** * fdt_appendprop_string - append a string to a property * @fdt: pointer to the device tree blob * @nodeoffset: offset of the node whose property to change diff --git a/edk2/EmbeddedPkg/Include/libfdt_env.h b/edk2/EmbeddedPkg/Include/libfdt_env.h index 8c4f1c733..d35b8692c 100644 --- a/edk2/EmbeddedPkg/Include/libfdt_env.h +++ b/edk2/EmbeddedPkg/Include/libfdt_env.h @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2011, ARM Limited. All rights reserved. +* Copyright (c) 2011-2012, ARM Limited. All rights reserved. * * This program and the accompanying materials * are licensed and made available under the terms and conditions of the BSD License @@ -27,19 +27,19 @@ typedef UINTN size_t; static inline uint16_t fdt16_to_cpu(uint16_t x) { - return SwapBytes16 (x); + return SwapBytes16 (x); } #define cpu_to_fdt16(x) fdt16_to_cpu(x) static inline uint32_t fdt32_to_cpu(uint32_t x) { - return SwapBytes32 (x); + return SwapBytes32 (x); } #define cpu_to_fdt32(x) fdt32_to_cpu(x) static inline uint64_t fdt64_to_cpu(uint64_t x) { - return SwapBytes64 (x); + return SwapBytes64 (x); } #define cpu_to_fdt64(x) fdt64_to_cpu(x) diff --git a/edk2/EmbeddedPkg/Library/FdtLib/0001-EmbeddedPkg-Added-libfdt-port.patch b/edk2/EmbeddedPkg/Library/FdtLib/0001-EmbeddedPkg-Added-libfdt-port.patch deleted file mode 100644 index ae06b6f39..000000000 --- a/edk2/EmbeddedPkg/Library/FdtLib/0001-EmbeddedPkg-Added-libfdt-port.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 669778eab2092ef85ed5b5e537203721cfb1215d Mon Sep 17 00:00:00 2001 -From: Olivier Martin <olivier.martin@arm.com> -Date: Thu, 16 Feb 2012 15:44:35 +0000 -Subject: [PATCH 1/3] EmbeddedPkg: Added libfdt port - -This port is based on the 'libfdt' project (dual licensed BSD/GPL). - -Prior to apply this patch you must execute the following steps: - -1. Clone the dtc into a temporary directory: -cd EmbeddedPkg/Library -git clone git://git.jdl.com/software/dtc.git - -2. Copy the content of 'libfdt' into EmbeddedPkg/Library/FdtLib/ -cd dtc -cp -a libfdt ../FdtLib - -3. Copy the libfdt headers: -mv ../FdtLib/libfdt.h ../../Include/ -mv ../FdtLib/fdt.h ../../Include/ -rm ../FdtLib/libfdt_env.h ---- - EmbeddedPkg/EmbeddedPkg.dsc | 1 + - EmbeddedPkg/Include/libfdt_env.h | 77 +++++++++++++++++++++++++++++++++ - EmbeddedPkg/Library/FdtLib/FdtLib.inf | 38 ++++++++++++++++ - EmbeddedPkg/Library/FdtLib/README.txt | 38 ++++++++++++++++ - 4 files changed, 154 insertions(+), 0 deletions(-) - mode change 100644 => 100755 EmbeddedPkg/EmbeddedPkg.dsc - create mode 100755 EmbeddedPkg/Include/libfdt_env.h - create mode 100755 EmbeddedPkg/Library/FdtLib/FdtLib.inf - create mode 100755 EmbeddedPkg/Library/FdtLib/README.txt - -diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc -old mode 100644 -new mode 100755 -index 8862f3d..c3a2464 ---- a/EmbeddedPkg/EmbeddedPkg.dsc -+++ b/EmbeddedPkg/EmbeddedPkg.dsc -@@ -97,6 +97,7 @@ - - EblNetworkLib|EmbeddedPkg/Library/EblNetworkLib/EblNetworkLib.inf - -+ FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf - - [LibraryClasses.common.DXE_DRIVER] - PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -diff --git a/EmbeddedPkg/Include/libfdt_env.h b/EmbeddedPkg/Include/libfdt_env.h -new file mode 100755 -index 0000000..8c4f1c7 ---- /dev/null -+++ b/EmbeddedPkg/Include/libfdt_env.h -@@ -0,0 +1,77 @@ -+/** @file -+* -+* Copyright (c) 2011, ARM Limited. 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.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. -+* -+**/ -+ -+#ifndef _LIBFDT_ENV_H -+#define _LIBFDT_ENV_H -+ -+#include <Library/BaseLib.h> -+#include <Library/BaseMemoryLib.h> -+ -+typedef UINT8 uint8_t; -+typedef UINT16 uint16_t; -+typedef UINT32 uint32_t; -+typedef UINT64 uint64_t; -+typedef UINTN uintptr_t; -+typedef UINTN size_t; -+ -+static inline uint16_t fdt16_to_cpu(uint16_t x) -+{ -+ return SwapBytes16 (x); -+} -+#define cpu_to_fdt16(x) fdt16_to_cpu(x) -+ -+static inline uint32_t fdt32_to_cpu(uint32_t x) -+{ -+ return SwapBytes32 (x); -+} -+#define cpu_to_fdt32(x) fdt32_to_cpu(x) -+ -+static inline uint64_t fdt64_to_cpu(uint64_t x) -+{ -+ return SwapBytes64 (x); -+} -+#define cpu_to_fdt64(x) fdt64_to_cpu(x) -+ -+static inline void* memcpy(void* dest, const void* src, size_t len) { -+ return CopyMem (dest, src, len); -+} -+ -+static inline void *memmove(void *dest, const void *src, size_t n) { -+ return CopyMem (dest, src, n); -+} -+ -+static inline void *memset(void *s, int c, size_t n) { -+ return SetMem (s, n, c); -+} -+ -+static inline int memcmp(const void* dest, const void* src, int len) { -+ return CompareMem (dest, src, len); -+} -+ -+static inline void *memchr(const void *s, int c, size_t n) { -+ return ScanMem8 (s, n, c); -+} -+ -+static inline size_t strlen (const char* str) { -+ return AsciiStrLen (str); -+} -+ -+static inline char *strchr(const char *s, int c) { -+ char pattern[2]; -+ pattern[0] = c; -+ pattern[1] = 0; -+ return AsciiStrStr (s, pattern); -+} -+ -+#endif /* _LIBFDT_ENV_H */ -diff --git a/EmbeddedPkg/Library/FdtLib/FdtLib.inf b/EmbeddedPkg/Library/FdtLib/FdtLib.inf -new file mode 100755 -index 0000000..9753ed8 ---- /dev/null -+++ b/EmbeddedPkg/Library/FdtLib/FdtLib.inf -@@ -0,0 +1,38 @@ -+#/* @file
-+# Copyright (c) 2011, ARM Limited. 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.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.
-+#
-+#*/
-+
-+[Defines]
-+ INF_VERSION = 0x00010005
-+ BASE_NAME = FdtLib
-+ FILE_GUID = 6b2478c0-be23-11e0-a28c-0002a5d5c51b
-+ MODULE_TYPE = BASE
-+ VERSION_STRING = 1.0
-+ LIBRARY_CLASS = FdtLib
-+
-+#
-+# The following information is for reference only and not required by the build tools.
-+#
-+# VALID_ARCHITECTURES = ARM
-+#
-+
-+[Sources]
-+ fdt_ro.c
-+ fdt_rw.c
-+ fdt_strerror.c
-+ fdt_sw.c
-+ fdt_wip.c
-+ fdt.c
-+
-+[Packages]
-+ MdePkg/MdePkg.dec
-+ EmbeddedPkg/EmbeddedPkg.dec
-diff --git a/EmbeddedPkg/Library/FdtLib/README.txt b/EmbeddedPkg/Library/FdtLib/README.txt -new file mode 100755 -index 0000000..c74db7a ---- /dev/null -+++ b/EmbeddedPkg/Library/FdtLib/README.txt -@@ -0,0 +1,38 @@ -+Credits
-+-------
-+Principal original author: David Gibson (david AT gibson.dropbear.id.au)
-+Maintainer: Jon Loeliger (jdl AT jdl.com)
-+
-+
-+Licensing:
-+----------
-+libfdt is GPL/BSD dual-licensed.
-+
-+
-+Current version:
-+----------------
-+
-+# Latest commit in dtc.git repository :
-+commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86
-+Author: Minghuan Lian <Minghuan.Lian@freescale.com>
-+Date: Mon Dec 5 12:22:07 2011 +1100
-+
-+# Latest commit in libfdt :
-+commit a31e3ef83bfce62d07695355e5f06cd4d0e44b86
-+Author: Minghuan Lian <Minghuan.Lian@freescale.com>
-+Date: Mon Dec 5 12:22:07 2011 +1100
-+
-+
-+How to update EmbeddedPkg/Library/FdtLib
-+----------------------------------------
-+1. Clone the dtc into a temporary directory:
-+git clone git://git.jdl.com/software/dtc.git
-+
-+2. Copy the content of 'libfdt' into EmbeddedPkg/Library/FdtLib/
-+cd dtc
-+cp -a libfdt/* $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/
-+
-+3. Copy the libfdt headers:
-+mv $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/libfdt.h $(EDK2_ROOT)/EmbeddedPkg/Include/
-+mv $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/fdt.h $(EDK2_ROOT)/EmbeddedPkg/Include/
-+rm $(EDK2_ROOT)/EmbeddedPkg/Library/FdtLib/libfdt_env.h
--- -1.7.0.4 - diff --git a/edk2/EmbeddedPkg/Library/FdtLib/0002-ArmPkg-BdsLib-Added-support-for-modifying-the-passed.patch b/edk2/EmbeddedPkg/Library/FdtLib/0002-ArmPkg-BdsLib-Added-support-for-modifying-the-passed.patch deleted file mode 100644 index 66ea90287..000000000 --- a/edk2/EmbeddedPkg/Library/FdtLib/0002-ArmPkg-BdsLib-Added-support-for-modifying-the-passed.patch +++ /dev/null @@ -1,489 +0,0 @@ -From 9c16a23fba659cdf0ce798aa085a4fb8c3bd47d1 Mon Sep 17 00:00:00 2001 -From: Olivier Martin <olivier.martin@arm.com> -Date: Thu, 16 Feb 2012 15:50:59 +0000 -Subject: [PATCH 2/3] ArmPkg/BdsLib: Added support for modifying the passed FDT blob - -- Add Linux CmdLine if not defined -- Add initrd if not defined -- Add CPU parking address if not defined -- Add System Memory info if not defined ---- - ArmPkg/ArmPkg.dsc | 1 + - ArmPkg/Library/BdsLib/BdsInternal.h | 9 + - ArmPkg/Library/BdsLib/BdsLib.inf | 3 + - ArmPkg/Library/BdsLib/BdsLinuxFdt.c | 353 ++++++++++++++++++++++++++++++++ - ArmPkg/Library/BdsLib/BdsLinuxLoader.c | 8 + - ArmPkg/Library/BdsLib/BdsLinuxLoader.h | 10 +- - 6 files changed, 383 insertions(+), 1 deletions(-) - mode change 100644 => 100755 ArmPkg/ArmPkg.dsc - mode change 100644 => 100755 ArmPkg/Library/BdsLib/BdsInternal.h - mode change 100644 => 100755 ArmPkg/Library/BdsLib/BdsLib.inf - create mode 100755 ArmPkg/Library/BdsLib/BdsLinuxFdt.c - -diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc -old mode 100644 -new mode 100755 -index f4989a6..07c825d ---- a/ArmPkg/ArmPkg.dsc -+++ b/ArmPkg/ArmPkg.dsc -@@ -72,6 +72,7 @@ - SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf - - BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf -+ FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf - - IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf - -diff --git a/ArmPkg/Library/BdsLib/BdsInternal.h b/ArmPkg/Library/BdsLib/BdsInternal.h -old mode 100644 -new mode 100755 -index 880d780..80d21b2 ---- a/ArmPkg/Library/BdsLib/BdsInternal.h -+++ b/ArmPkg/Library/BdsLib/BdsInternal.h -@@ -103,4 +103,13 @@ PrepareAtagList ( - OUT UINT32 *AtagSize - ); - -+EFI_STATUS -+PrepareFdt ( -+ IN CONST CHAR8* CommandLineString, -+ IN EFI_PHYSICAL_ADDRESS InitrdImage, -+ IN UINTN InitrdImageSize, -+ IN OUT EFI_PHYSICAL_ADDRESS *FdtBlobBase, -+ IN OUT UINT32 *FdtBlobSize -+ ); -+ - #endif -diff --git a/ArmPkg/Library/BdsLib/BdsLib.inf b/ArmPkg/Library/BdsLib/BdsLib.inf -old mode 100644 -new mode 100755 -index 20644f1..b3cab21 ---- a/ArmPkg/Library/BdsLib/BdsLib.inf -+++ b/ArmPkg/Library/BdsLib/BdsLib.inf -@@ -27,6 +27,7 @@ - - BdsLinuxLoader.c - BdsLinuxAtag.c -+ BdsLinuxFdt.c - - [Packages] - MdePkg/MdePkg.dec -@@ -41,9 +42,11 @@ - HobLib - PerformanceLib - SerialPortLib -+ FdtLib - - [Guids] - gEfiFileInfoGuid -+ gArmMpCoreInfoGuid - - [Protocols] - gEfiBdsArchProtocolGuid -diff --git a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c -new file mode 100755 -index 0000000..5c14b65 ---- /dev/null -+++ b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c -@@ -0,0 +1,353 @@ -+/** @file -+* -+* Copyright (c) 2011-2012, ARM Limited. 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.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 <Library/PcdLib.h> -+#include <libfdt.h> -+ -+#include "BdsInternal.h" -+ -+#define LINUX_FDT_MAX_OFFSET (PcdGet32(PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxAtagMaxOffset)) -+ -+#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) -+#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) -+#define GET_CELL(p) (p += 4, *((const UINT32 *)(p-4))) -+ -+STATIC -+UINTN -+IsPrintableString ( -+ IN CONST VOID* data, -+ IN UINTN len -+ ) -+{ -+ CONST CHAR8 *s = data; -+ CONST CHAR8 *ss; -+ -+ // zero length is not -+ if (len == 0) { -+ return 0; -+ } -+ -+ // must terminate with zero -+ if (s[len - 1] != '\0') { -+ return 0; -+ } -+ -+ ss = s; -+ while (*s/* && isprint(*s)*/) { -+ s++; -+ } -+ -+ // not zero, or not done yet -+ if (*s != '\0' || (s + 1 - ss) < len) { -+ return 0; -+ } -+ -+ return 1; -+} -+ -+STATIC -+VOID -+PrintData ( -+ IN CONST CHAR8* data, -+ IN UINTN len -+ ) -+{ -+ UINTN i; -+ CONST CHAR8 *p = data; -+ -+ // no data, don't print -+ if (len == 0) -+ return; -+ -+ if (IsPrintableString (data, len)) { -+ Print(L" = \"%a\"", (const char *)data); -+ } else if ((len % 4) == 0) { -+ Print(L" = <"); -+ for (i = 0; i < len; i += 4) { -+ Print(L"0x%08x%a", fdt32_to_cpu(GET_CELL(p)),i < (len - 4) ? " " : ""); -+ } -+ Print(L">"); -+ } else { -+ Print(L" = ["); -+ for (i = 0; i < len; i++) -+ Print(L"%02x%a", *p++, i < len - 1 ? " " : ""); -+ Print(L"]"); -+ } -+} -+ -+VOID -+DebugDumpFdt ( -+ IN VOID* FdtBlob -+ ) -+{ -+ struct fdt_header *bph; -+ UINT32 off_dt; -+ UINT32 off_str; -+ CONST CHAR8* p_struct; -+ CONST CHAR8* p_strings; -+ CONST CHAR8* p; -+ CONST CHAR8* s; -+ CONST CHAR8* t; -+ UINT32 tag; -+ UINTN sz; -+ UINTN depth; -+ UINTN shift; -+ UINT32 version; -+ -+ depth = 0; -+ shift = 4; -+ -+ bph = FdtBlob; -+ off_dt = fdt32_to_cpu(bph->off_dt_struct); -+ off_str = fdt32_to_cpu(bph->off_dt_strings); -+ p_struct = (CONST CHAR8*)FdtBlob + off_dt; -+ p_strings = (CONST CHAR8*)FdtBlob + off_str; -+ version = fdt32_to_cpu(bph->version); -+ -+ p = p_struct; -+ while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) { -+ -+ //printf("tag: 0x%08x (%d)\n", tag, p - p_struct); -+ -+ if (tag == FDT_BEGIN_NODE) { -+ s = p; -+ p = PALIGN(p + AsciiStrLen (s) + 1, 4); -+ -+ if (*s == '\0') -+ s = "/"; -+ -+ Print(L"%*s%a {\n", depth * shift, L" ", s); -+ -+ depth++; -+ continue; -+ } -+ -+ if (tag == FDT_END_NODE) { -+ depth--; -+ -+ Print(L"%*s};\n", depth * shift, L" "); -+ continue; -+ } -+ -+ if (tag == FDT_NOP) { -+ Print(L"%*s// [NOP]\n", depth * shift, L" "); -+ continue; -+ } -+ -+ if (tag != FDT_PROP) { -+ Print(L"%*s ** Unknown tag 0x%08x\n", depth * shift, L" ", tag); -+ break; -+ } -+ sz = fdt32_to_cpu(GET_CELL(p)); -+ s = p_strings + fdt32_to_cpu(GET_CELL(p)); -+ if (version < 16 && sz >= 8) -+ p = PALIGN(p, 8); -+ t = p; -+ -+ p = PALIGN(p + sz, 4); -+ -+ Print(L"%*s%a", depth * shift, L" ", s); -+ PrintData(t, sz); -+ Print(L";\n"); -+ } -+} -+ -+typedef struct { -+ UINTN Base; -+ UINTN Size; -+} FdtRegion; -+ -+EFI_STATUS -+PrepareFdt ( -+ IN CONST CHAR8* CommandLineString, -+ IN EFI_PHYSICAL_ADDRESS InitrdImage, -+ IN UINTN InitrdImageSize, -+ IN OUT EFI_PHYSICAL_ADDRESS *FdtBlobBase, -+ IN OUT UINT32 *FdtBlobSize -+ ) -+{ -+ EFI_STATUS Status; -+ EFI_PHYSICAL_ADDRESS NewFdtBlobBase; -+ UINTN NewFdtBlobSize; -+ VOID* fdt; -+ INTN err; -+ INTN node; -+ INTN cpu_node; -+ INTN lenp; -+ CONST VOID* BootArg; -+ EFI_PHYSICAL_ADDRESS InitrdImageStart; -+ EFI_PHYSICAL_ADDRESS InitrdImageEnd; -+ FdtRegion Region; -+ UINTN Index; -+ CHAR8 Name[10]; -+ LIST_ENTRY ResourceList; -+ BDS_SYSTEM_MEMORY_RESOURCE *Resource; -+ ARM_PROCESSOR_TABLE *ArmProcessorTable; -+ ARM_CORE_INFO *ArmCoreInfoTable; -+ UINT32 MpId; -+ UINT32 ClusterId; -+ UINT32 CoreId; -+ UINT64 CpuReleaseAddr; -+ -+ err = fdt_check_header ((VOID*)(UINTN)(*FdtBlobBase)); -+ if (err != 0) { -+ Print (L"ERROR: Device Tree header not valid (err:%d)\n", err); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // Allocate memory for the new FDT -+ NewFdtBlobBase = LINUX_FDT_MAX_OFFSET; -+ NewFdtBlobSize = *FdtBlobSize + FDT_ADDITIONAL_ENTRIES_SIZE; -+ Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(NewFdtBlobSize), &NewFdtBlobBase); -+ if (EFI_ERROR(Status)) { -+ DEBUG ((EFI_D_WARN, "Warning: Failed to allocate Fdt below 0x%lX (%r). The Fdt will be allocated somewhere else in System Memory.\n",NewFdtBlobBase,Status)); -+ Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, EFI_SIZE_TO_PAGES(NewFdtBlobSize), &NewFdtBlobBase); -+ ASSERT_EFI_ERROR(Status); -+ goto FAIL_NEW_FDT; -+ } -+ -+ // Load the Original FDT tree into the new region -+ fdt = (VOID*)(UINTN)NewFdtBlobBase; -+ err = fdt_open_into((VOID*)(UINTN)(*FdtBlobBase), fdt, NewFdtBlobSize); -+ if (err) { -+ DEBUG((EFI_D_ERROR, "fdt_open_into(): %a\n", fdt_strerror(err))); -+ Status = EFI_INVALID_PARAMETER; -+ goto FAIL_NEW_FDT; -+ } -+ -+ DEBUG_CODE_BEGIN(); -+ DebugDumpFdt (fdt); -+ DEBUG_CODE_END(); -+ -+ node = fdt_subnode_offset(fdt, 0, "chosen"); -+ if (node < 0) { -+ // The 'chosen' node does not exist, create it -+ node = fdt_add_subnode(fdt, 0, "chosen"); -+ if (node < 0) { -+ DEBUG((EFI_D_ERROR,"Error on finding 'chosen' node\n")); -+ Status = EFI_INVALID_PARAMETER; -+ goto FAIL_NEW_FDT; -+ } -+ } -+ -+ DEBUG_CODE_BEGIN(); -+ BootArg = fdt_getprop(fdt, node, "bootargs", &lenp); -+ if (BootArg != NULL) { -+ DEBUG((EFI_D_ERROR,"BootArg: %a\n",BootArg)); -+ } -+ DEBUG_CODE_END(); -+ -+ // Set Linux CmdLine -+ if ((CommandLineString != NULL) && (AsciiStrLen (CommandLineString) > 0)) { -+ err = fdt_setprop(fdt, node, "bootargs", CommandLineString, AsciiStrSize(CommandLineString)); -+ if (err) { -+ DEBUG((EFI_D_ERROR,"Fail to set new 'bootarg' (err:%d)\n",err)); -+ } -+ } -+ -+ // Set Linux Initrd -+ if (InitrdImageSize != 0) { -+ InitrdImageStart = cpu_to_fdt64 (InitrdImage); -+ err = fdt_setprop(fdt, node, "linux,initrd-start", &InitrdImageStart, sizeof(EFI_PHYSICAL_ADDRESS)); -+ if (err) { -+ DEBUG((EFI_D_ERROR,"Fail to set new 'linux,initrd-start' (err:%d)\n",err)); -+ } -+ InitrdImageEnd = cpu_to_fdt64 (InitrdImage + InitrdImageSize); -+ err = fdt_setprop(fdt, node, "linux,initrd-end", &InitrdImageEnd, sizeof(EFI_PHYSICAL_ADDRESS)); -+ if (err) { -+ DEBUG((EFI_D_ERROR,"Fail to set new 'linux,initrd-start' (err:%d)\n",err)); -+ } -+ } -+ -+ // Set Physical memory setup if does not exist -+ node = fdt_subnode_offset(fdt, 0, "memory"); -+ if (node < 0) { -+ // The 'chosen' node does not exist, create it -+ node = fdt_add_subnode(fdt, 0, "memory"); -+ if (node >= 0) { -+ fdt_setprop_string(fdt, node, "name", "memory"); -+ fdt_setprop_string(fdt, node, "device_type", "memory"); -+ -+ GetSystemMemoryResources (&ResourceList); -+ Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceList.ForwardLink; -+ -+ if (sizeof(UINTN) == sizeof(UINT32)) { -+ Region.Base = cpu_to_fdt32((UINTN)Resource->PhysicalStart); -+ Region.Size = cpu_to_fdt32((UINTN)Resource->ResourceLength); -+ } else { -+ Region.Base = cpu_to_fdt64((UINTN)Resource->PhysicalStart); -+ Region.Size = cpu_to_fdt64((UINTN)Resource->ResourceLength); -+ } -+ -+ err = fdt_setprop(fdt, node, "reg", &Region, sizeof(Region)); -+ if (err) { -+ DEBUG((EFI_D_ERROR,"Fail to set new 'memory region' (err:%d)\n",err)); -+ } -+ } -+ } -+ -+ // Setup Arm Mpcore Info if it is a multi-core or multi-cluster platforms -+ for (Index=0; Index < gST->NumberOfTableEntries; Index++) { -+ // Check for correct GUID type -+ if (CompareGuid (&gArmMpCoreInfoGuid, &(gST->ConfigurationTable[Index].VendorGuid))) { -+ MpId = ArmReadMpidr (); -+ ClusterId = GET_CLUSTER_ID(MpId); -+ CoreId = GET_CORE_ID(MpId); -+ -+ node = fdt_subnode_offset(fdt, 0, "cpus"); -+ if (node < 0) { -+ // Create the /cpus node -+ node = fdt_add_subnode(fdt, 0, "cpus"); -+ fdt_setprop_string(fdt, node, "name", "cpus"); -+ fdt_setprop_cell(fdt, node, "#address-cells", 1); -+ fdt_setprop_cell(fdt, node, "#size-cells", 0); -+ } -+ -+ // Get pointer to ARM processor table -+ ArmProcessorTable = (ARM_PROCESSOR_TABLE *)gST->ConfigurationTable[Index].VendorTable; -+ ArmCoreInfoTable = ArmProcessorTable->ArmCpus; -+ -+ for (Index = 0; Index < ArmProcessorTable->NumberOfEntries; Index++) { -+ if (((ArmCoreInfoTable[Index].ClusterId != ClusterId) || (ArmCoreInfoTable[Index].CoreId != CoreId))) { -+ AsciiSPrint (Name, 10, "cpu@%d", Index); -+ cpu_node = fdt_subnode_offset(fdt, node, Name); -+ if (cpu_node < 0) { -+ cpu_node = fdt_add_subnode(fdt, node, Name); -+ } -+ fdt_setprop_string(fdt, cpu_node, "device-type", "cpu"); -+ fdt_setprop_string(fdt, cpu_node, "enable-method", "spin-table"); -+ fdt_setprop_string(fdt, cpu_node, "status", "disabled"); -+ CpuReleaseAddr = cpu_to_fdt64(ArmCoreInfoTable[Index].MailboxSetAddress); -+ fdt_setprop(fdt, cpu_node, "cpu-release-addr", &CpuReleaseAddr, sizeof(CpuReleaseAddr)); -+ } -+ } -+ break; -+ } -+ } -+ -+ DEBUG_CODE_BEGIN(); -+ DebugDumpFdt (fdt); -+ DEBUG_CODE_END(); -+ -+ *FdtBlobBase = NewFdtBlobBase; -+ *FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(NewFdtBlobBase));; -+ return EFI_SUCCESS; -+ -+FAIL_NEW_FDT: -+ *FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(*FdtBlobBase)); -+ // Return success even if we failed to update the FDT blob. The original one is still valid. -+ return EFI_SUCCESS; -+} -+ -+ -diff --git a/ArmPkg/Library/BdsLib/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/BdsLinuxLoader.c -index 12a8862..82fa811 100755 ---- a/ArmPkg/Library/BdsLib/BdsLinuxLoader.c -+++ b/ArmPkg/Library/BdsLib/BdsLinuxLoader.c -@@ -241,6 +241,14 @@ BdsBootLinuxFdt ( - Print (L"ERROR: Did not find Device Tree blob.\n"); - return Status; - } -+ -+ // By setting address=0 we leave the memory allocation to the function -+ Status = PrepareFdt (Arguments, InitrdImage, InitrdImageSize, &KernelParamsAddress, &KernelParamsSize); -+ if (EFI_ERROR(Status)) { -+ Print(L"ERROR: Can not load Linux kernel with Device Tree. Status=0x%X\n", Status); -+ return Status; -+ } -+ - return StartLinux (LinuxImage, LinuxImageSize, KernelParamsAddress, KernelParamsSize, FdtMachineType); - } - -diff --git a/ArmPkg/Library/BdsLib/BdsLinuxLoader.h b/ArmPkg/Library/BdsLib/BdsLinuxLoader.h -index 8d58ce1..9e45e03 100755 ---- a/ArmPkg/Library/BdsLib/BdsLinuxLoader.h -+++ b/ArmPkg/Library/BdsLib/BdsLinuxLoader.h -@@ -15,12 +15,20 @@ - #ifndef __BDSLINUXLOADER_H - #define __BDSLINUXLOADER_H - -+#include <Guid/ArmMpCoreInfo.h> -+ - #define LINUX_UIMAGE_SIGNATURE 0x56190527 - - #define LINUX_ATAG_MAX_OFFSET (PcdGet32(PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxAtagMaxOffset)) - #define LINUX_KERNEL_MAX_OFFSET (PcdGet32(PcdSystemMemoryBase) + PcdGet32(PcdArmLinuxKernelMaxOffset)) - --#define ATAG_MAX_SIZE 0x3000 -+// Size allocated for the Atag list -+#define ATAG_MAX_SIZE 0x3000 -+ -+// Additional size that could be used for FDT entries added by the UEFI OS Loader -+// Estimation based on: EDID (300bytes) + bootargs (200bytes) + initrd region (20bytes) -+// + system memory region (20bytes) + mp_core entries (200 bytes) -+#define FDT_ADDITIONAL_ENTRIES_SIZE 0x300 - - /* ATAG : list of possible tags */ - #define ATAG_NONE 0x00000000 --- -1.7.0.4 - diff --git a/edk2/EmbeddedPkg/Library/FdtLib/0003-ArmPlatformPkg-EblCmdLib-Add-dumpfdt-EBL-command.patch b/edk2/EmbeddedPkg/Library/FdtLib/0003-ArmPlatformPkg-EblCmdLib-Add-dumpfdt-EBL-command.patch deleted file mode 100644 index 98fc8fcb1..000000000 --- a/edk2/EmbeddedPkg/Library/FdtLib/0003-ArmPlatformPkg-EblCmdLib-Add-dumpfdt-EBL-command.patch +++ /dev/null @@ -1,300 +0,0 @@ -From 82540f3a4b280133f2d1a58cb8baba01c1f09690 Mon Sep 17 00:00:00 2001 -From: Olivier Martin <olivier.martin@arm.com> -Date: Thu, 16 Feb 2012 15:56:40 +0000 -Subject: [PATCH 3/3] ArmPlatformPkg/EblCmdLib: Add 'dumpfdt' EBL command - -This command dumps the FDT blob pointed by the Device Path defined in the -command argument or used the Platform specifc FDT defined by its Device Path -in the UEFI Variable 'Fdt' or the PcdFdtDevicePath PCD. ---- - ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c | 206 ++++++++++++++++++++++++ - ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c | 12 ++ - ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf | 6 + - 3 files changed, 224 insertions(+), 0 deletions(-) - create mode 100755 ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c - mode change 100644 => 100755 ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c - mode change 100644 => 100755 ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf - -diff --git a/ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c b/ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c -new file mode 100755 -index 0000000..3c5eb8e ---- /dev/null -+++ b/ArmPlatformPkg/Library/EblCmdLib/EblCmdFdt.c -@@ -0,0 +1,206 @@ -+#include <Base.h> -+#include <Uefi.h> -+#include <Library/MemoryAllocationLib.h> -+#include <Library/BdsLib.h> -+#include <Library/DebugLib.h> -+#include <Library/PcdLib.h> -+#include <Library/PrintLib.h> -+#include <Library/UefiLib.h> -+#include <Library/UefiApplicationEntryPoint.h> -+#include <Library/UefiBootServicesTableLib.h> -+#include <Library/UefiRuntimeServicesTableLib.h> -+ -+#include <Protocol/DevicePathFromText.h> -+ -+#include <Guid/GlobalVariable.h> -+ -+#include <libfdt.h> -+ -+#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) -+#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) -+#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4))) -+ -+STATIC -+UINTN -+IsPrintableString ( -+ IN CONST VOID* data, -+ IN UINTN len -+ ) -+{ -+ CONST CHAR8 *s = data; -+ CONST CHAR8 *ss; -+ -+ /* zero length is not */ -+ if (len == 0) { -+ return 0; -+ } -+ -+ /* must terminate with zero */ -+ if (s[len - 1] != '\0') { -+ return 0; -+ } -+ -+ ss = s; -+ while (*s/* && isprint(*s)*/) { -+ s++; -+ } -+ -+ /* not zero, or not done yet */ -+ if (*s != '\0' || (s + 1 - ss) < len) { -+ return 0; -+ } -+ -+ return 1; -+} -+ -+STATIC -+VOID -+PrintData ( -+ IN CONST CHAR8* data, -+ IN UINTN len -+ ) -+{ -+ UINTN i; -+ CONST CHAR8 *p = data; -+ -+ /* no data, don't print */ -+ if (len == 0) -+ return; -+ -+ if (IsPrintableString (data, len)) { -+ Print(L" = \"%a\"", (const char *)data); -+ } else if ((len % 4) == 0) { -+ Print(L" = <"); -+ for (i = 0; i < len; i += 4) { -+ Print(L"0x%08x%a", fdt32_to_cpu(GET_CELL(p)),i < (len - 4) ? " " : ""); -+ } -+ Print(L">"); -+ } else { -+ Print(L" = ["); -+ for (i = 0; i < len; i++) -+ Print(L"%02x%a", *p++, i < len - 1 ? " " : ""); -+ Print(L"]"); -+ } -+} -+ -+VOID -+DumpFdt ( -+ IN VOID* FdtBlob -+ ) -+{ -+ struct fdt_header *bph; -+ UINT32 off_dt; -+ UINT32 off_str; -+ CONST CHAR8* p_struct; -+ CONST CHAR8* p_strings; -+ CONST CHAR8* p; -+ CONST CHAR8* s; -+ CONST CHAR8* t; -+ UINT32 tag; -+ UINTN sz; -+ UINTN depth; -+ UINTN shift; -+ UINT32 version; -+ -+ depth = 0; -+ shift = 4; -+ -+ bph = FdtBlob; -+ off_dt = fdt32_to_cpu(bph->off_dt_struct); -+ off_str = fdt32_to_cpu(bph->off_dt_strings); -+ p_struct = (CONST CHAR8*)FdtBlob + off_dt; -+ p_strings = (CONST CHAR8*)FdtBlob + off_str; -+ version = fdt32_to_cpu(bph->version); -+ -+ p = p_struct; -+ while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) { -+ -+ /* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */ -+ -+ if (tag == FDT_BEGIN_NODE) { -+ s = p; -+ p = PALIGN(p + strlen(s) + 1, 4); -+ -+ if (*s == '\0') -+ s = "/"; -+ -+ Print(L"%*s%a {\n", depth * shift, L" ", s); -+ -+ depth++; -+ continue; -+ } -+ -+ if (tag == FDT_END_NODE) { -+ depth--; -+ -+ Print(L"%*s};\n", depth * shift, L" "); -+ continue; -+ } -+ -+ if (tag == FDT_NOP) { -+ Print(L"%*s// [NOP]\n", depth * shift, L" "); -+ continue; -+ } -+ -+ if (tag != FDT_PROP) { -+ Print(L"%*s ** Unknown tag 0x%08x\n", depth * shift, L" ", tag); -+ break; -+ } -+ sz = fdt32_to_cpu(GET_CELL(p)); -+ s = p_strings + fdt32_to_cpu(GET_CELL(p)); -+ if (version < 16 && sz >= 8) -+ p = PALIGN(p, 8); -+ t = p; -+ -+ p = PALIGN(p + sz, 4); -+ -+ Print(L"%*s%a", depth * shift, L" ", s); -+ PrintData(t, sz); -+ Print(L";\n"); -+ } -+} -+ -+EFI_STATUS -+EblDumpFdt ( -+ IN UINTN Argc, -+ IN CHAR8 **Argv -+ ) -+{ -+ EFI_STATUS Status; -+ EFI_DEVICE_PATH* FdtDevicePath; -+ VOID* FdtBlob; -+ UINTN FdtBlobSize; -+ UINTN Ret; -+ EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *EfiDevicePathFromTextProtocol; -+ -+ // If no FDT file is passed to the argument then get the one from the platform -+ if (Argc < 2) { -+ Status = GetEnvironmentVariable (L"Fdt",NULL,NULL,(VOID**)&FdtDevicePath); -+ if (Status == EFI_NOT_FOUND) { -+ // No set yet, get the Default Device Path -+ Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&EfiDevicePathFromTextProtocol); -+ ASSERT_EFI_ERROR(Status); -+ FdtDevicePath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdFdtDevicePath)); -+ } -+ } else { -+ return EFI_NOT_FOUND; -+ } -+ -+ Status = BdsLoadImage (FdtDevicePath, AllocateAnyPages, (EFI_PHYSICAL_ADDRESS*)&FdtBlob, &FdtBlobSize); -+ if (EFI_ERROR(Status)) { -+ Print (L"ERROR: Did not find the Fdt Blob.\n"); -+ return Status; -+ } -+ -+ Ret = fdt_check_header(FdtBlob); -+ if (Ret != 0) { -+ Print (L"ERROR: Device Tree header not valid (err:%d)\n",Ret); -+ return Status; -+ } -+ -+ DumpFdt (FdtBlob); -+ -+ FreePool (FdtDevicePath); -+ -+ return EFI_SUCCESS; -+} -diff --git a/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c b/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c -old mode 100644 -new mode 100755 -index b75dbfb..327a794 ---- a/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c -+++ b/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c -@@ -42,6 +42,12 @@ EblDumpMmu ( - IN UINTN Argc,
- IN CHAR8 **Argv
- );
-+
-+EFI_STATUS
-+EblDumpFdt (
-+ IN UINTN Argc,
-+ IN CHAR8 **Argv
-+ );
-
- /**
- Simple arm disassembler via a library
-@@ -416,6 +422,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mLibCmdTemplate[] = - " list all the Device Paths",
- NULL,
- EblDevicePaths
-+ },
-+ {
-+ "dumpfdt",
-+ " dump the current fdt or the one defined in the arguments",
-+ NULL,
-+ EblDumpFdt
- }
- };
-
-diff --git a/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf b/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf -old mode 100644 -new mode 100755 -index 0eb71a0..9f84c07 ---- a/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf -+++ b/ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.inf -@@ -30,12 +30,14 @@ - [Sources.common]
- EblCmdLib.c
- EblCmdMmu.c
-+ EblCmdFdt.c
-
- [Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- ArmPkg/ArmPkg.dec
-+ ArmPlatformPkg/ArmPlatformPkg.dec
-
- [LibraryClasses]
- BaseLib
-@@ -45,6 +47,7 @@ - PerformanceLib
- TimerLib
- BdsLib
-+ FdtLib
-
- [Protocols]
- gEfiDebugSupportProtocolGuid
-@@ -53,3 +56,6 @@ -
- [Guids]
- gEfiDebugImageInfoTableGuid
-+
-+[Pcd]
-+ gArmPlatformTokenSpaceGuid.PcdFdtDevicePath
--- -1.7.0.4 - diff --git a/edk2/EmbeddedPkg/Library/FdtLib/FdtLib.inf b/edk2/EmbeddedPkg/Library/FdtLib/FdtLib.inf index 9753ed8dd..aee99bd99 100644 --- a/edk2/EmbeddedPkg/Library/FdtLib/FdtLib.inf +++ b/edk2/EmbeddedPkg/Library/FdtLib/FdtLib.inf @@ -1,5 +1,5 @@ #/* @file
-# Copyright (c) 2011, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
diff --git a/edk2/EmbeddedPkg/Library/FdtLib/Makefile.libfdt b/edk2/EmbeddedPkg/Library/FdtLib/Makefile.libfdt index d55a6f852..91126c000 100644 --- a/edk2/EmbeddedPkg/Library/FdtLib/Makefile.libfdt +++ b/edk2/EmbeddedPkg/Library/FdtLib/Makefile.libfdt @@ -4,7 +4,7 @@ # be easily embeddable into other systems of Makefiles. # LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1 -LIBFDT_INCLUDES = fdt.h libfdt.h +LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h LIBFDT_VERSION = version.lds -LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c +LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o) diff --git a/edk2/EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c b/edk2/EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c new file mode 100644 index 000000000..f72d13b1d --- /dev/null +++ b/edk2/EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c @@ -0,0 +1,84 @@ +/* + * libfdt - Flat Device Tree manipulation + * Copyright (C) 2012 David Gibson, IBM Corporation. + * + * libfdt is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * + * a) This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301 USA + * + * Alternatively, + * + * b) Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * 2. 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 OWNER 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. + */ +#include "libfdt_env.h" + +#include <fdt.h> +#include <libfdt.h> + +#include "libfdt_internal.h" + +int fdt_create_empty_tree(void *buf, int bufsize) +{ + int err; + + err = fdt_create(buf, bufsize); + if (err) + return err; + + err = fdt_finish_reservemap(buf); + if (err) + return err; + + err = fdt_begin_node(buf, ""); + if (err) + return err; + + err = fdt_end_node(buf); + if (err) + return err; + + err = fdt_finish(buf); + if (err) + return err; + + return fdt_open_into(buf, buf, bufsize); +} + diff --git a/edk2/EmbeddedPkg/Library/FdtLib/fdt_ro.c b/edk2/EmbeddedPkg/Library/FdtLib/fdt_ro.c index 02b6d6875..95fdbeadd 100644 --- a/edk2/EmbeddedPkg/Library/FdtLib/fdt_ro.c +++ b/edk2/EmbeddedPkg/Library/FdtLib/fdt_ro.c @@ -267,7 +267,8 @@ const struct fdt_property *fdt_get_property_namelen(const void *fdt, (offset = fdt_next_property_offset(fdt, offset))) { const struct fdt_property *prop; - if (!(prop = fdt_get_property_by_offset(fdt, offset, lenp))) { + prop = fdt_get_property_by_offset(fdt, offset, lenp); + if (!prop) { offset = -FDT_ERR_INTERNAL; break; } @@ -494,7 +495,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle) { int offset; - if ((phandle == 0) || (phandle == -1)) + if ((phandle == 0) || (phandle == (uint32_t)-1)) return -FDT_ERR_BADPHANDLE; FDT_CHECK_HEADER(fdt); diff --git a/edk2/EmbeddedPkg/Library/FdtLib/fdt_rw.c b/edk2/EmbeddedPkg/Library/FdtLib/fdt_rw.c index 24437dfc3..878a775a7 100644 --- a/edk2/EmbeddedPkg/Library/FdtLib/fdt_rw.c +++ b/edk2/EmbeddedPkg/Library/FdtLib/fdt_rw.c @@ -126,7 +126,8 @@ static int _fdt_splice_struct(void *fdt, void *p, int delta = newlen - oldlen; int err; - if ((err = _fdt_splice(fdt, p, oldlen, newlen))) + err = _fdt_splice(fdt, p, oldlen, newlen); + if (err) return err; fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta); @@ -140,7 +141,8 @@ static int _fdt_splice_string(void *fdt, int newlen) + fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt); int err; - if ((err = _fdt_splice(fdt, p, 0, newlen))) + err = _fdt_splice(fdt, p, 0, newlen); + if (err) return err; fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen); @@ -212,8 +214,9 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, if (! (*prop)) return oldlen; - if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen), - FDT_TAGALIGN(len)))) + err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen), + FDT_TAGALIGN(len)); + if (err) return err; (*prop)->len = cpu_to_fdt32(len); diff --git a/edk2/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.c b/edk2/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.c index 9cc2b79a8..0110189ab 100644 --- a/edk2/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.c +++ b/edk2/EmbeddedPkg/Library/TemplateSerialPortLib/TemplateSerialPortLib.c @@ -2,6 +2,7 @@ Serial I/O Port library functions with no library constructor/destructor
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+ Copyright (c) 2012, ARM Ltd. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -17,8 +18,9 @@ #include <Library/SerialPortLib.h>
+#include <Library/SerialPortExtLib.h>
-/*
+/**
Programmed hardware of Serial port.
@@ -35,6 +37,65 @@ SerialPortInitialize ( }
/**
+ Set the serial device control bits.
+
+ @return Always return EFI_UNSUPPORTED.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortSetControl (
+ IN UINT32 Control
+ )
+{
+ return RETURN_UNSUPPORTED;
+}
+
+/**
+ Get the serial device control bits.
+
+ @param Control Control signals read from the serial device.
+
+ @retval EFI_SUCCESS The control bits were read from the serial device.
+ @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortGetControl (
+ OUT UINT32 *Control
+ )
+{
+ if (SerialPortPoll ()) {
+ // If a character is pending don't set EFI_SERIAL_INPUT_BUFFER_EMPTY
+ *Control = EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
+ } else {
+ *Control = EFI_SERIAL_INPUT_BUFFER_EMPTY | EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Set the serial device attributes.
+
+ @return Always return EFI_UNSUPPORTED.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortSetAttributes (
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT UINT32 *Timeout,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
+ )
+{
+ return RETURN_UNSUPPORTED;
+}
+
+/**
Write data to serial device.
@param Buffer Point of data buffer which need to be written.
@@ -49,7 +110,7 @@ EFIAPI SerialPortWrite (
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
-)
+ )
{
return 0;
}
@@ -70,7 +131,7 @@ EFIAPI SerialPortRead (
OUT UINT8 *Buffer,
IN UINTN NumberOfBytes
-)
+ )
{
return 0;
}
diff --git a/edk2/EmbeddedPkg/License.txt b/edk2/EmbeddedPkg/License.txt new file mode 100755 index 000000000..05dbd3606 --- /dev/null +++ b/edk2/EmbeddedPkg/License.txt @@ -0,0 +1,26 @@ +Copyright (c) 2009-2010, Apple Inc. All rights reserved.
+Copyright (c) 2011-2012, ARM Limited. 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/EmbeddedPkg/MetronomeDxe/Metronome.c b/edk2/EmbeddedPkg/MetronomeDxe/Metronome.c index f8b1fcb8d..8388c4d19 100644 --- a/edk2/EmbeddedPkg/MetronomeDxe/Metronome.c +++ b/edk2/EmbeddedPkg/MetronomeDxe/Metronome.c @@ -1,6 +1,7 @@ /** @file
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+ Copyright (c) 2012, ARM Ltd. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -89,7 +90,7 @@ WaitForTick ( **/
EFI_METRONOME_ARCH_PROTOCOL gMetronome = {
WaitForTick,
- 100
+ FixedPcdGet32 (PcdMetronomeTickPeriod)
};
diff --git a/edk2/EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf b/edk2/EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf index 25194ffd0..37aea8571 100644 --- a/edk2/EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf +++ b/edk2/EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf @@ -2,7 +2,9 @@ #
# Component description file for Bds module
#
-# Copyright (c) 2008, Apple Inc. All rights reserved.<BR>
+# Copyright (c) 2008, Apple Inc. All rights reserved.
+# Copyright (c) 2012, ARM Ltd. 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
@@ -22,13 +24,12 @@ ENTRY_POINT = MetronomeInitialize
-
[Sources.common]
Metronome.c
-
[Packages]
MdePkg/MdePkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
[LibraryClasses]
BaseLib
@@ -39,9 +40,9 @@ UefiDriverEntryPoint
TimerLib
-[Guids]
+[FixedPcd]
+ gEmbeddedTokenSpaceGuid.PcdMetronomeTickPeriod
-
[Protocols]
gEfiMetronomeArchProtocolGuid
diff --git a/edk2/EmbeddedPkg/SerialDxe/SerialDxe.inf b/edk2/EmbeddedPkg/SerialDxe/SerialDxe.inf index e0aa57d31..37e8e0e00 100644 --- a/edk2/EmbeddedPkg/SerialDxe/SerialDxe.inf +++ b/edk2/EmbeddedPkg/SerialDxe/SerialDxe.inf @@ -22,13 +22,12 @@ ENTRY_POINT = SerialDxeInitialize
-
[Sources.common]
SerialIo.c
-
[Packages]
MdePkg/MdePkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
[LibraryClasses]
BaseLib
@@ -41,9 +40,6 @@ UefiDriverEntryPoint
SerialPortLib
-[Guids]
-
-
[Protocols]
gEfiSerialIoProtocolGuid
gEfiDevicePathProtocolGuid
@@ -54,6 +50,5 @@ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
-
[Depex]
TRUE
diff --git a/edk2/EmbeddedPkg/SerialDxe/SerialIo.c b/edk2/EmbeddedPkg/SerialDxe/SerialIo.c index 59d904c19..a94bacaf4 100644 --- a/edk2/EmbeddedPkg/SerialDxe/SerialIo.c +++ b/edk2/EmbeddedPkg/SerialDxe/SerialIo.c @@ -23,10 +23,35 @@ #include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Library/SerialPortLib.h>
+#include <Library/SerialPortExtLib.h>
#include <Library/PcdLib.h>
#include <Protocol/SerialIo.h>
+typedef struct {
+ VENDOR_DEVICE_PATH Guid;
+ UART_DEVICE_PATH Uart;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} SIMPLE_TEXT_OUT_DEVICE_PATH;
+
+SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {
+ {
+ { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH), 0},
+ EFI_CALLER_ID_GUID // Use the drivers GUID
+ },
+ {
+ { MESSAGING_DEVICE_PATH, MSG_UART_DP, sizeof (UART_DEVICE_PATH), 0},
+ 0, // Reserved
+ FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
+ FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
+ FixedPcdGet8 (PcdUartDefaultParity), // Parity (N)
+ FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
+ },
+ { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (EFI_DEVICE_PATH_PROTOCOL), 0}
+};
+
+EFI_HANDLE gHandle = NULL;
+
/**
Reset the serial device.
@@ -42,8 +67,60 @@ SerialReset ( IN EFI_SERIAL_IO_PROTOCOL *This
)
{
- SerialPortInitialize ();
- return EFI_SUCCESS;
+ EFI_STATUS Status;
+ EFI_TPL Tpl;
+
+ Status = SerialPortInitialize ();
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Set the Serial I/O mode and update the device path
+ //
+
+ Tpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ //
+ // Set the Serial I/O mode
+ //
+ This->Mode->ReceiveFifoDepth = 0;
+ This->Mode->Timeout = 1000000;
+ This->Mode->BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
+ This->Mode->DataBits = (UINT32)PcdGet8 (PcdUartDefaultDataBits);
+ This->Mode->Parity = (UINT32)PcdGet8 (PcdUartDefaultParity);
+ This->Mode->StopBits = (UINT32)PcdGet8 (PcdUartDefaultStopBits);
+
+ //
+ // Check if the device path has actually changed
+ //
+ if (mDevicePath.Uart.BaudRate == This->Mode->BaudRate &&
+ mDevicePath.Uart.DataBits == (UINT8)This->Mode->DataBits &&
+ mDevicePath.Uart.Parity == (UINT8)This->Mode->Parity &&
+ mDevicePath.Uart.StopBits == (UINT8)This->Mode->StopBits
+ ) {
+ gBS->RestoreTPL (Tpl);
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Update the device path
+ //
+ mDevicePath.Uart.BaudRate = This->Mode->BaudRate;
+ mDevicePath.Uart.DataBits = (UINT8)This->Mode->DataBits;
+ mDevicePath.Uart.Parity = (UINT8)This->Mode->Parity;
+ mDevicePath.Uart.StopBits = (UINT8)This->Mode->StopBits;
+
+ Status = gBS->ReinstallProtocolInterface (
+ gHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mDevicePath,
+ &mDevicePath
+ );
+
+ gBS->RestoreTPL (Tpl);
+
+ return Status;
}
@@ -85,7 +162,60 @@ SerialSetAttributes ( IN EFI_STOP_BITS_TYPE StopBits
)
{
- return EFI_UNSUPPORTED;
+ EFI_STATUS Status;
+ EFI_TPL Tpl;
+
+ Status = SerialPortSetAttributes (BaudRate, ReceiveFifoDepth, Timeout, Parity, DataBits, StopBits);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Set the Serial I/O mode and update the device path
+ //
+
+ Tpl = gBS->RaiseTPL (TPL_NOTIFY);
+
+ //
+ // Set the Serial I/O mode
+ //
+ This->Mode->BaudRate = BaudRate;
+ This->Mode->ReceiveFifoDepth = ReceiveFifoDepth;
+ This->Mode->Timeout = Timeout;
+ This->Mode->Parity = (UINT32)Parity;
+ This->Mode->DataBits = (UINT32)DataBits;
+ This->Mode->StopBits = (UINT32)StopBits;
+
+ //
+ // Check if the device path has actually changed
+ //
+ if (mDevicePath.Uart.BaudRate == BaudRate &&
+ mDevicePath.Uart.Parity == (UINT8)Parity &&
+ mDevicePath.Uart.DataBits == DataBits &&
+ mDevicePath.Uart.StopBits == (UINT8)StopBits
+ ) {
+ gBS->RestoreTPL (Tpl);
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Update the device path
+ //
+ mDevicePath.Uart.BaudRate = BaudRate;
+ mDevicePath.Uart.DataBits = DataBits;
+ mDevicePath.Uart.Parity = (UINT8) Parity;
+ mDevicePath.Uart.StopBits = (UINT8) StopBits;
+
+ Status = gBS->ReinstallProtocolInterface (
+ gHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mDevicePath,
+ &mDevicePath
+ );
+
+ gBS->RestoreTPL (Tpl);
+
+ return Status;
}
@@ -107,7 +237,7 @@ SerialSetControl ( IN UINT32 Control
)
{
- return EFI_UNSUPPORTED;
+ return SerialPortSetControl(Control);
}
@@ -128,13 +258,7 @@ SerialGetControl ( OUT UINT32 *Control
)
{
- if (SerialPortPoll ()) {
- // If a character is pending don't set EFI_SERIAL_INPUT_BUFFER_EMPTY
- *Control = EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
- } else {
- *Control = EFI_SERIAL_INPUT_BUFFER_EMPTY | EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
- }
- return EFI_SUCCESS;
+ return SerialPortGetControl(Control);
}
@@ -162,12 +286,17 @@ SerialWrite ( UINTN Count;
Count = SerialPortWrite (Buffer, *BufferSize);
- *BufferSize = Count;
- return (Count == 0) ? EFI_DEVICE_ERROR : EFI_SUCCESS;
+
+ if (Count != *BufferSize) {
+ *BufferSize = Count;
+ return EFI_TIMEOUT;
+ }
+
+ return EFI_SUCCESS;
}
/**
- Writes data to a serial device.
+ Reads data from a serial device.
@param This Protocol instance pointer.
@param BufferSize On input, the size of the Buffer. On output, the amount of
@@ -189,21 +318,19 @@ SerialRead ( )
{
UINTN Count = 0;
-
+
if (SerialPortPoll()) {
Count = SerialPortRead (Buffer, *BufferSize);
+ }
+
+ if (Count != *BufferSize) {
*BufferSize = Count;
- return (Count == 0) ? EFI_DEVICE_ERROR : EFI_SUCCESS;
+ return EFI_TIMEOUT;
}
-
- // No data to return
- *BufferSize = 0;
+
return EFI_SUCCESS;
}
-
-EFI_HANDLE gHandle = NULL;
-
//
// Template used to initialize the GDB Serial IO protocols
//
@@ -228,29 +355,6 @@ EFI_SERIAL_IO_PROTOCOL gSerialIoTemplate = { SerialRead,
&gSerialIoMode
};
-
-typedef struct {
- VENDOR_DEVICE_PATH Guid;
- UART_DEVICE_PATH Uart;
- EFI_DEVICE_PATH_PROTOCOL End;
-} SIMPLE_TEXT_OUT_DEVICE_PATH;
-
-SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {
- {
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH), 0},
- EFI_CALLER_ID_GUID // Use the drivers GUID
- },
- {
- { MESSAGING_DEVICE_PATH, MSG_UART_DP, sizeof (UART_DEVICE_PATH), 0},
- 0, // Reserved
- FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
- FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
- FixedPcdGet8 (PcdUartDefaultParity), // Parity (N)
- FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
- },
- { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (EFI_DEVICE_PATH_PROTOCOL), 0}
-};
-
/**
Initialize the state information for the Serial Io Protocol
@@ -272,7 +376,6 @@ SerialDxeInitialize ( {
EFI_STATUS Status;
-
// Make a new handle with Serial IO protocol and its device path on it.
Status = gBS->InstallMultipleProtocolInterfaces (
&gHandle,
diff --git a/edk2/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/edk2/EmbeddedPkg/Universal/MmcDxe/Mmc.h index c7e8c7e9f..0c51428e9 100644 --- a/edk2/EmbeddedPkg/Universal/MmcDxe/Mmc.h +++ b/edk2/EmbeddedPkg/Universal/MmcDxe/Mmc.h @@ -69,7 +69,7 @@ typedef struct { UINT32 V270_V360: 9; // 2.70V - 3.60V
UINT32 RESERVED_1: 5; // Reserved
UINT32 AccessMode: 2; // 00b (byte mode), 10b (sector mode)
- UINT32 Busy: 1; // This bit is set to LOW if the card has not finished the power up routine
+ UINT32 PowerUp: 1; // This bit is set to LOW if the card has not finished the power up routine
} OCR;
typedef struct {
diff --git a/edk2/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/edk2/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c index 47f4aebcd..c33705c80 100644 --- a/edk2/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c +++ b/edk2/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c @@ -1,6 +1,6 @@ /** @file
*
-* Copyright (c) 2011, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -40,7 +40,9 @@ PrintOCR ( IN UINT32 Ocr
)
{
- UINTN minv, maxv, volts;
+ UINTN minv;
+ UINTN maxv;
+ UINTN volts;
UINTN loop;
minv = 36; // 3.6
@@ -83,16 +85,17 @@ VOID PrintCID ( DEBUG((EFI_D_ERROR, "\t- OEM ID: %c%c\n",(Cid[3] >> 8) & 0xFF,(Cid[3] >> 16) & 0xFF));
}
+#if !defined(MDEPKG_NDEBUG)
+CONST CHAR8* mStrUnit[] = { "100kbit/s","1Mbit/s","10Mbit/s","100MBit/s","Unkbown","Unkbown","Unkbown","Unkbown" };
+CONST CHAR8* mStrValue[] = { "1.0","1.2","1.3","1.5","2.0","2.5","3.0","3.5","4.0","4.5","5.0","Unknown","Unknown","Unknown","Unknown" };
+#endif
+
VOID
PrintCSD (
IN UINT32* Csd
)
{
UINTN Value;
-#if !defined(MDEPKG_NDEBUG)
- CONST CHAR8* str_unit[] = { "100kbit/s","1Mbit/s","10Mbit/s","100MBit/s","Unkbown","Unkbown","Unkbown","Unkbown" };
- CONST CHAR8* str_value[] = { "1.0","1.2","1.3","1.5","2.0","2.5","3.0","3.5","4.0","4.5","5.0","Unknown","Unknown","Unknown","Unknown" };
-#endif
if (((Csd[2] >> 30) & 0x3) == 0) {
DEBUG((EFI_D_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n"));
@@ -103,7 +106,7 @@ PrintCSD ( }
DEBUG((EFI_D_ERROR, "\t- Supported card command class: 0x%X\n",MMC_CSD_GET_CCC(Csd)));
- DEBUG((EFI_D_ERROR, "\t- Speed: %a %a\n",str_value[(MMC_CSD_GET_TRANSPEED(Csd) >> 3) & 0xF],str_unit[MMC_CSD_GET_TRANSPEED(Csd) & 7]));
+ DEBUG((EFI_D_ERROR, "\t- Speed: %a %a\n",mStrValue[(MMC_CSD_GET_TRANSPEED(Csd) >> 3) & 0xF],mStrUnit[MMC_CSD_GET_TRANSPEED(Csd) & 7]));
DEBUG((EFI_D_ERROR, "\t- Maximum Read Data Block: %d\n",2 << (MMC_CSD_GET_READBLLEN(Csd)-1)));
DEBUG((EFI_D_ERROR, "\t- Maximum Write Data Block: %d\n",2 << (MMC_CSD_GET_WRITEBLLEN(Csd)-1)));
@@ -134,7 +137,7 @@ PrintResponseR1 ( )
{
DEBUG((EFI_D_INFO, "Response: 0x%X\n",Response));
- if (Response & (1 << 8)) DEBUG((EFI_D_INFO, "\t- READY_FOR_DATA\n"));
+ if (Response & MMC_R0_READY_FOR_DATA) DEBUG((EFI_D_INFO, "\t- READY_FOR_DATA\n"));
if (((Response >> 9) & 0xF) == 0) DEBUG((EFI_D_INFO, "\t- State: Idle\n"));
else if (((Response >> 9) & 0xF) == 1) DEBUG((EFI_D_INFO, "\t- State: Ready\n"));
@@ -212,13 +215,12 @@ MmcIdentificationMode ( DEBUG((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcHwInitializationState\n"));
return Status;
}
- } else {
- //Note: Could even be used in all cases. But it looks this command could put the state machine into inactive for some cards
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD0, 0);
- if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n"));
- return Status;
- }
+ } + + Status = MmcHost->SendCommand (MmcHost, MMC_CMD0, 0); + if (EFI_ERROR(Status)) { + DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n")); + return Status; }
Status = MmcNotifyState (MmcHostInstance, MmcIdleState);
@@ -229,6 +231,12 @@ MmcIdentificationMode ( // Are we using SDIO ?
Status = MmcHost->SendCommand (MmcHost, MMC_CMD5, 0);
+ +#if 1 // Added for Panda Board + /* It seems few SD cards need some time to recover from this command? */ + MicroSecondDelay(1000); +#endif + if (Status == EFI_SUCCESS) {
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported.\n"));
return EFI_UNSUPPORTED;
@@ -251,7 +259,7 @@ MmcIdentificationMode ( DEBUG ((EFI_D_ERROR, "Not a SD2.0 Card\n"));
}
- // We need to wait for the MMC or SD card is ready => (gCardInfo.OCRData.Busy == 1)
+ // We need to wait for the MMC or SD card is ready => (gCardInfo.OCRData.PowerUp == 1)
Timeout = MAX_RETRY_COUNT;
while (Timeout > 0) {
// SD Card or MMC Card ? CMD55 indicates to the card that the next command is an application specific command
@@ -286,7 +294,7 @@ MmcIdentificationMode ( }
if (!EFI_ERROR(Status)) {
- if (MmcHostInstance->CardInfo.OCRData.Busy == 0) {
+ if (!MmcHostInstance->CardInfo.OCRData.PowerUp) {
MicroSecondDelay(1);
Timeout--;
} else {
@@ -543,7 +551,9 @@ MmcIoBlocks ( CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Response[0] = 0;
Timeout = 20;
- while(!(Response[0] & MMC_R0_READY_FOR_DATA) && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN) && Timeout--) {
+ while( (!(Response[0] & MMC_R0_READY_FOR_DATA))
+ && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN)
+ && Timeout--) {
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
if (!EFI_ERROR(Status)) {
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
@@ -579,7 +589,7 @@ MmcIoBlocks ( }
Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD%d): Error %r\n",Cmd, Status));
+ DEBUG((EFI_D_ERROR, "MmcIoBlocks(MMC_CMD%d): Error %r\n",Cmd, Status));
return Status;
}
@@ -588,16 +598,16 @@ MmcIoBlocks ( // Read one block of Data
Status = MmcHost->ReadBlockData (MmcHost, Lba,This->Media->BlockSize,Buffer);
if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Read Block Data and Status = %r\n", Status));
+ DEBUG((EFI_D_BLKIO, "MmcIoBlocks(): Error Read Block Data and Status = %r\n", Status));
return Status;
}
#else
- //TODO: Read a steam
+ //TODO: Read a stream
ASSERT(0);
#endif
Status = MmcNotifyState (MmcHostInstance, MmcProgrammingState);
if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcProgrammingState\n"));
+ DEBUG((EFI_D_ERROR, "MmcIoBlocks() : Error MmcProgrammingState\n"));
return Status;
}
} else {
@@ -605,11 +615,11 @@ MmcIoBlocks ( // Write one block of Data
Status = MmcHost->WriteBlockData (MmcHost, Lba,This->Media->BlockSize,Buffer);
if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Write Block Data and Status = %r\n", Status));
+ DEBUG((EFI_D_BLKIO, "MmcIoBlocks(): Error Write Block Data and Status = %r\n", Status));
return Status;
}
#else
- //TODO: Write a steam
+ //TODO: Write a stream
ASSERT(0);
#endif
}
@@ -624,18 +634,22 @@ MmcIoBlocks ( Timeout = MMCI0_TIMEOUT;
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Response[0] = 0;
- while(!(Response[0] & MMC_R0_READY_FOR_DATA) && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN) && Timeout--) {
+ while( (!(Response[0] & MMC_R0_READY_FOR_DATA))
+ && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN)
+ && Timeout--) {
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
if (!EFI_ERROR(Status)) {
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
+ MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
+ if ((Response[0] & MMC_R0_READY_FOR_DATA)) {
+ break; // Prevents delay once finished
+ }
}
NanoSecondDelay(100);
- Timeout--;
}
Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
if (EFI_ERROR(Status)) {
- DEBUG((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcTransferState\n"));
+ DEBUG((EFI_D_ERROR, "MmcIoBlocks() : Error MmcTransferState\n"));
return Status;
}
|