]> git.proxmox.com Git - mirror_edk2.git/commitdiff
QemuFwCfgLib: Add QemuFwCfgWriteBytes() function
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 28 Jan 2013 16:54:55 +0000 (16:54 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 28 Jan 2013 16:54:55 +0000 (16:54 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14109 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Include/Library/QemuFwCfgLib.h
OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.S
OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.asm
OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.S
OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.asm

index 3776d79ea97b43445ac015459d199836d2cce90b..9d023777c9d8cd8d00d38fff5dda997983b24baf 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   QEMU/KVM Firmware Configuration access\r
 \r
-  Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -102,6 +102,25 @@ QemuFwCfgReadBytes (
   );\r
 \r
 \r
+/**\r
+  Writes firmware configuration bytes from a buffer\r
+\r
+  If called multiple times, then the data written will\r
+  continue at the offset of the firmware configuration\r
+  item where the previous write ended.\r
+\r
+  @param[in] Size - Size in bytes to write\r
+  @param[in] Buffer - Buffer to read data from\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+QemuFwCfgWriteBytes (\r
+  IN UINTN                  Size,\r
+  IN VOID                   *Buffer\r
+  );\r
+\r
+\r
 /**\r
   Reads a UINT8 firmware configuration value\r
 \r
index a32b2c60c492cc0bb8b58f54b230ec6c4c6c86a8..c2735d2c65183eef5adc275653bbfa9da9994573 100644 (file)
@@ -1,6 +1,6 @@
 #------------------------------------------------------------------------------\r
 #\r
-# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -30,3 +30,23 @@ rep insb
     popl    %edi\r
     ret\r
 \r
+\r
+#------------------------------------------------------------------------------\r
+#  VOID\r
+#  EFIAPI\r
+#  IoWriteFifo8 (\r
+#    IN UINTN                  Port,\r
+#    IN UINTN                  Size,\r
+#    IN VOID                   *Buffer\r
+#    );\r
+#------------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(IoWriteFifo8)\r
+ASM_PFX(IoWriteFifo8):\r
+    movw    4(%esp), %dx\r
+    movl    8(%esp), %ecx\r
+    pushl   %esi\r
+    movl    16(%esp), %esi\r
+rep outsb\r
+    popl    %esi\r
+    ret\r
+\r
index 248d52237ec9bbfdbf53b20186d9a07ecb7cb5e5..f7d65c49afe959a915479816481dced0d506f3ee 100644 (file)
@@ -1,6 +1,6 @@
 ;------------------------------------------------------------------------------\r
 ;\r
-; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 ; This program and the accompanying materials\r
 ; are licensed and made available under the terms and conditions of the BSD License\r
 ; which accompanies this distribution.  The full text of the license may be found at\r
@@ -36,5 +36,27 @@ rep insb
 \r
 IoReadFifo8 ENDP\r
 \r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EFIAPI\r
+;  IoWriteFifo8 (\r
+;    IN UINTN                  Port,\r
+;    IN UINTN                  Size,\r
+;    IN VOID                   *Buffer\r
+;    );\r
+;------------------------------------------------------------------------------\r
+IoWriteFifo8 PROC\r
+\r
+    mov     dx, [esp + 4]\r
+    mov     ecx, [esp + 8]\r
+    push    esi\r
+    mov     esi, [esp + 16]\r
+rep outsb\r
+    pop     esi\r
+    ret\r
+\r
+IoWriteFifo8 ENDP\r
+\r
     END\r
 \r
index 8caab42e8b0a9c27c574aed09dbf63cafd07ad6b..7e5ea00bf96b061f6804d6e714a6b8efb4f5da4f 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -50,6 +50,32 @@ IoReadFifo8 (
   OUT     VOID                      *Buffer\r
   );\r
 \r
+/**\r
+  Writes an 8-bit I/O port fifo from a block of memory.\r
+\r
+  Writes the 8-bit I/O fifo port specified by Port.\r
+\r
+  The port is written Count times, and the data are obtained\r
+  from the provided Buffer.\r
+\r
+  This function must guarantee that all I/O read and write operations are\r
+  serialized.\r
+\r
+  If 8-bit I/O port operations are not supported, then ASSERT().\r
+\r
+  @param  Port    The I/O port to read.\r
+  @param  Count   The number of times to read I/O port.\r
+  @param  Buffer  The buffer to store the read data into.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+IoWriteFifo8 (\r
+  IN      UINTN                     Port,\r
+  IN      UINTN                     Count,\r
+  OUT     VOID                      *Buffer\r
+  );\r
+\r
 \r
 /**\r
   Returns a boolean indicating if the firmware configuration interface\r
@@ -132,6 +158,29 @@ QemuFwCfgReadBytes (
   }\r
 }\r
 \r
+/**\r
+  Write firmware configuration bytes from a buffer\r
+\r
+  If called multiple times, then the data written will\r
+  continue at the offset of the firmware configuration\r
+  item where the previous write ended.\r
+\r
+  @param[in] Size - Size in bytes to write\r
+  @param[in] Buffer - Buffer to read data from\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+QemuFwCfgWriteBytes (\r
+  IN UINTN                  Size,\r
+  IN VOID                   *Buffer\r
+  )\r
+{\r
+  if (mQemuFwCfgSupported) {\r
+    IoWriteFifo8 (0x511, Size, Buffer);\r
+  }\r
+}\r
+\r
 \r
 /**\r
   Reads a UINT8 firmware configuration value\r
index b1125ed7da31931a075218b6a163f6036125d376..69167b708147f0f501d8aa830a1b120b27377583 100644 (file)
@@ -1,6 +1,6 @@
 #------------------------------------------------------------------------------\r
 #\r
-# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -28,3 +28,20 @@ rep insb
     mov     %r8, %rdi           # restore rdi\r
     ret\r
 \r
+#------------------------------------------------------------------------------\r
+#  VOID\r
+#  EFIAPI\r
+#  IoWriteFifo8 (\r
+#    IN UINTN                  Port,              // rcx\r
+#    IN UINTN                  Size,              // rdx\r
+#    IN VOID                   *Buffer            // r8\r
+#    );\r
+#------------------------------------------------------------------------------\r
+ASM_GLOBAL ASM_PFX(IoWriteFifo8)\r
+ASM_PFX(IoWriteFifo8):\r
+    xchg    %rcx, %rdx\r
+    xchg    %r8, %rsi           # rdi: buffer address; r8: save rsi\r
+rep outsb\r
+    mov     %r8, %rsi           # restore rsi\r
+    ret\r
+\r
index c60ad2c5d4486f90aeb578f0b6fc69b8ece1948d..47ac158f851bd37198680d21e40cc5ba86780d93 100644 (file)
@@ -1,6 +1,6 @@
 ;------------------------------------------------------------------------------\r
 ;\r
-; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 ; This program and the accompanying materials\r
 ; are licensed and made available under the terms and conditions of the BSD License\r
 ; which accompanies this distribution.  The full text of the license may be found at\r
@@ -32,5 +32,25 @@ rep insb
 \r
 IoReadFifo8 ENDP\r
 \r
+\r
+;------------------------------------------------------------------------------\r
+;  VOID\r
+;  EFIAPI\r
+;  IoWriteFifo8 (\r
+;    IN UINTN                  Port,              // rcx\r
+;    IN UINTN                  Size,              // rdx\r
+;    IN VOID                   *Buffer            // r8\r
+;    );\r
+;------------------------------------------------------------------------------\r
+IoWriteFifo8 PROC\r
+\r
+    xchg    rcx, rdx\r
+    xchg    rsi, r8             ; rdi: buffer address; r8: save rdi\r
+rep outsb\r
+    mov     rsi, r8             ; restore rdi\r
+    ret\r
+\r
+IoWriteFifo8 ENDP\r
+\r
     END\r
 \r