]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/BaseLib.h
MdePkg/BaseLib: BaseLib for RISCV64 architecture
[mirror_edk2.git] / MdePkg / Include / Library / BaseLib.h
index 2a75bc023f56adb4d6a1c88ed6493550815f3cd4..b0bbe8cef83430015499cfd7c216228b30fd2a42 100644 (file)
@@ -4,6 +4,9 @@
 \r
 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+Copyright (c) Microsoft Corporation.<BR>\r
+Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>\r
+\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -124,6 +127,30 @@ typedef struct {
 \r
 #endif  // defined (MDE_CPU_AARCH64)\r
 \r
+#if defined (MDE_CPU_RISCV64)\r
+///\r
+/// The RISC-V architecture context buffer used by SetJump() and LongJump().\r
+///\r
+typedef struct {\r
+  UINT64                            RA;\r
+  UINT64                            S0;\r
+  UINT64                            S1;\r
+  UINT64                            S2;\r
+  UINT64                            S3;\r
+  UINT64                            S4;\r
+  UINT64                            S5;\r
+  UINT64                            S6;\r
+  UINT64                            S7;\r
+  UINT64                            S8;\r
+  UINT64                            S9;\r
+  UINT64                            S10;\r
+  UINT64                            S11;\r
+  UINT64                            SP;\r
+} BASE_LIBRARY_JUMP_BUFFER;\r
+\r
+#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r
+\r
+#endif // defined (MDE_CPU_RISCV64)\r
 \r
 //\r
 // String Services\r
@@ -2972,6 +2999,32 @@ PathCleanUpDirectories(
 **/\r
 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)  {&(ListHead), &(ListHead)}\r
 \r
+/**\r
+  Iterates over each node in a doubly linked list using each node's forward link.\r
+\r
+  @param  Entry     A pointer to a list node used as a loop cursor during iteration\r
+  @param  ListHead  The head node of the doubly linked list\r
+\r
+**/\r
+#define BASE_LIST_FOR_EACH(Entry, ListHead)    \\r
+  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)\r
+\r
+/**\r
+  Iterates over each node in a doubly linked list using each node's forward link\r
+  with safety against node removal.\r
+\r
+  This macro uses NextEntry to temporarily store the next list node so the node\r
+  pointed to by Entry may be deleted in the current loop iteration step and\r
+  iteration can continue from the node pointed to by NextEntry.\r
+\r
+  @param  Entry     A pointer to a list node used as a loop cursor during iteration\r
+  @param  NextEntry A pointer to a list node used to temporarily store the next node\r
+  @param  ListHead  The head node of the doubly linked list\r
+\r
+**/\r
+#define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)            \\r
+  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\\r
+      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)\r
 \r
 /**\r
   Checks whether FirstEntry and SecondEntry are part of the same doubly-linked\r
@@ -5387,10 +5440,19 @@ typedef union {
     UINT32  OSXMMEXCPT:1;   ///< Operating System Support for\r
                             ///< Unmasked SIMD Floating Point\r
                             ///< Exceptions.\r
-    UINT32  Reserved_2:1;   ///< Reserved.\r
+    UINT32  UMIP:1;         ///< User-Mode Instruction Prevention.\r
     UINT32  LA57:1;         ///< Linear Address 57bit.\r
-    UINT32  VMXE:1;         ///< VMX Enable\r
-    UINT32  Reserved_1:18;  ///< Reserved.\r
+    UINT32  VMXE:1;         ///< VMX Enable.\r
+    UINT32  SMXE:1;         ///< SMX Enable.\r
+    UINT32  Reserved_3:1;   ///< Reserved.\r
+    UINT32  FSGSBASE:1;     ///< FSGSBASE Enable.\r
+    UINT32  PCIDE:1;        ///< PCID Enable.\r
+    UINT32  OSXSAVE:1;      ///< XSAVE and Processor Extended States Enable.\r
+    UINT32  Reserved_4:1;   ///< Reserved.\r
+    UINT32  SMEP:1;         ///< SMEP Enable.\r
+    UINT32  SMAP:1;         ///< SMAP Enable.\r
+    UINT32  PKE:1;          ///< Protection-Key Enable.\r
+    UINT32  Reserved_5:9;   ///< Reserved.\r
   } Bits;\r
   UINTN     UintN;\r
 } IA32_CR4;\r