On 29 April 2016 at 02:23, Marcin Wojtas mw@semihalf.com wrote:
From: Bartosz Szczepanek bsz@semihalf.com
MarvellResetSystemLib implements functionality required to restart the platform.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Bartosz Szczepanek bsz@semihalf.com Signed-off-by: Marcin Wojtas mw@semihalf.com
I don't see any virtual remapping code in this library. Does this library implement reset in a way that is compatible with the ResetSystem() runtime service?
Documentation/Marvell/PortingGuide/Reset.txt | 7 ++ Documentation/Marvell/UserGuide.txt | 1 + Platforms/Marvell/Armada/Armada7040_rz.dsc | 4 + .../MarvellResetSystemLib/MarvellResetSystemLib.c | 85 ++++++++++++++++++++++ .../MarvellResetSystemLib.inf | 56 ++++++++++++++ Platforms/Marvell/Marvell.dec | 4 + 6 files changed, 157 insertions(+) create mode 100644 Documentation/Marvell/PortingGuide/Reset.txt create mode 100644 Platforms/Marvell/Armada/Library/MarvellResetSystemLib/MarvellResetSystemLib.c create mode 100644 Platforms/Marvell/Armada/Library/MarvellResetSystemLib/MarvellResetSystemLib.inf
diff --git a/Documentation/Marvell/PortingGuide/Reset.txt b/Documentation/Marvell/PortingGuide/Reset.txt new file mode 100644 index 0000000..1430fc0 --- /dev/null +++ b/Documentation/Marvell/PortingGuide/Reset.txt @@ -0,0 +1,7 @@ +MarvellResetSystemLib configuration +----------------------------------- +This simple library allows to mask given bits in given reg at UEFI 'reset' +command call. These variables are configurable through PCDs:
- gMarvellTokenSpaceGuid.PcdResetRegAddress
- gMarvellTokenSpaceGuid.PcdResetRegMask
diff --git a/Documentation/Marvell/UserGuide.txt b/Documentation/Marvell/UserGuide.txt index 28f78dc..9b2e9a8 100644 --- a/Documentation/Marvell/UserGuide.txt +++ b/Documentation/Marvell/UserGuide.txt @@ -10,6 +10,7 @@ Table of contents: i2c - PortingGuide/I2c.txt mpp - PortingGuide/Mpp.txt ramdisk - PortingGuide/Ramdisk.txt
- reset library - PortingGuide/Reset.txt spi - PortingGuide/Spi.txt spi flash - PortingGuide/SpiFlash.txt
diff --git a/Platforms/Marvell/Armada/Armada7040_rz.dsc b/Platforms/Marvell/Armada/Armada7040_rz.dsc index 24ab412..b8926ef 100644 --- a/Platforms/Marvell/Armada/Armada7040_rz.dsc +++ b/Platforms/Marvell/Armada/Armada7040_rz.dsc @@ -94,3 +94,7 @@
#RamDisk gMarvellTokenSpaceGuid.PcdRamDiskSize|64 #64MB
- #ResetLib
- gMarvellTokenSpaceGuid.PcdResetRegAddress|0xf06f0084
- gMarvellTokenSpaceGuid.PcdResetRegMask|0x1
diff --git a/Platforms/Marvell/Armada/Library/MarvellResetSystemLib/MarvellResetSystemLib.c b/Platforms/Marvell/Armada/Library/MarvellResetSystemLib/MarvellResetSystemLib.c new file mode 100644 index 0000000..f9dbd5d --- /dev/null +++ b/Platforms/Marvell/Armada/Library/MarvellResetSystemLib/MarvellResetSystemLib.c @@ -0,0 +1,85 @@ +/******************************************************************************** +Copyright (C) 2016 Marvell International Ltd.
+Marvell BSD License Option
+If you received this File from Marvell, you may opt to use, redistribute and/or +modify this File under the following licensing terms. +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.
- Neither the name of Marvell nor the names of its contributors may be
- used to endorse or promote products derived from this software without
- specific prior written permission.
+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 <PiDxe.h>
+#include <Library/BaseLib.h> +#include <Library/DebugLib.h> +#include <Library/IoLib.h> +#include <Library/EfiResetSystemLib.h>
+EFI_STATUS +EFIAPI +LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
- )
+{
- UINT64 Address;
- UINT32 Data;
- DEBUG((DEBUG_WARN, "reset system\n"));
- switch (ResetType) {
- case EfiResetCold:
- case EfiResetWarm:
- Address = PcdGet64 (PcdResetRegAddress);
- Data = MmioRead32 (Address);
- Data &= ~PcdGet32 (PcdResetRegMask);
- MmioWrite32 (Address, Data);
- break;
- case EfiResetShutdown:
- return EFI_UNSUPPORTED;
- break;
- default:
- return EFI_INVALID_PARAMETER;
- }
- return EFI_DEVICE_ERROR;
+}
+EFI_STATUS +EFIAPI +LibInitializeResetSystem (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- return EFI_SUCCESS;
+}
diff --git a/Platforms/Marvell/Armada/Library/MarvellResetSystemLib/MarvellResetSystemLib.inf b/Platforms/Marvell/Armada/Library/MarvellResetSystemLib/MarvellResetSystemLib.inf new file mode 100644 index 0000000..089f65b --- /dev/null +++ b/Platforms/Marvell/Armada/Library/MarvellResetSystemLib/MarvellResetSystemLib.inf @@ -0,0 +1,56 @@ +# Copyright (C) 2016 Marvell International Ltd. +# +# Marvell BSD License Option +# +# If you received this File from Marvell, you may opt to use, redistribute and/or +# modify this File under the following licensing terms. +# 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. +# +# * Neither the name of Marvell nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# 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. +#
+[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = MarvellResetSystemLib
- FILE_GUID = 13370566-097f-4ff6-ad24-c818f1b47a88
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = EfiResetSystemLib
+[Sources.common]
- MarvellResetSystemLib.c
+[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- OpenPlatformPkg/Platforms/Marvell/Marvell.dec
+[LibraryClasses]
- IoLib
- DebugLib
+[Pcd]
- gMarvellTokenSpaceGuid.PcdResetRegAddress
- gMarvellTokenSpaceGuid.PcdResetRegMask
diff --git a/Platforms/Marvell/Marvell.dec b/Platforms/Marvell/Marvell.dec index 788e56b..6ef6ec1 100644 --- a/Platforms/Marvell/Marvell.dec +++ b/Platforms/Marvell/Marvell.dec @@ -128,6 +128,10 @@ #Ramdisk gMarvellTokenSpaceGuid.PcdRamDiskSize|0|UINT32|0x23000057 #MB
+#ResetLib
- gMarvellTokenSpaceGuid.PcdResetRegAddress|0|UINT64|0x40000050
- gMarvellTokenSpaceGuid.PcdResetRegMask|0|UINT32|0x4000051
[Protocols] gEfiEepromProtocolGuid = { 0xcd728a1f, 0x45b5, 0x4feb, { 0x98, 0xc8, 0x31, 0x3d, 0xa8, 0x11, 0x74, 0x62 }} gEfiSpiMasterProtocolGuid = { 0x23de66a3, 0xf666, 0x4b3e, { 0xaa, 0xa2, 0x68, 0x9b, 0x18, 0xae, 0x2e, 0x19 }} -- 1.8.3.1