Copyright (C) 2006, Cambridge University\r
Copyright (C) 2014, Citrix Ltd.\r
\r
- Redistribution and use in source and binary forms, with or without\r
- modification, are permitted provided that the following conditions\r
- are met:\r
- 1. Redistributions of source code must retain the above copyright\r
- notice, this list of conditions and the following disclaimer.\r
- 2. Redistributions in binary form must reproduce the above copyright\r
- notice, this list of conditions and the following disclaimer in the\r
- documentation and/or other materials provided with the distribution.\r
-\r
- THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\r
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- SUCH DAMAGE.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
**/\r
#include "XenBusDxe.h"\r
\r
#include <IndustryStandard/Xen/memory.h>\r
\r
-#include "XenHypercall.h"\r
+#include <Library/XenHypercallLib.h>\r
+#include <Library/SynchronizationLib.h>\r
\r
#include "GrantTable.h"\r
-#include "InterlockedCompareExchange16.h"\r
\r
#define NR_RESERVED_ENTRIES 8\r
\r
\r
VOID\r
XenGrantTableInit (\r
- IN XENBUS_DEVICE *Dev,\r
- IN UINT64 MmioAddr\r
+ IN XENBUS_DEVICE *Dev\r
)\r
{\r
xen_add_to_physmap_t Parameters;\r
XenGrantTablePutFreeEntry ((grant_ref_t)Index);\r
}\r
\r
- GrantTable = (VOID*)(UINTN) MmioAddr;\r
+ GrantTable = (VOID*)(UINTN) Dev->XenIo->GrantTableAddress;\r
for (Index = 0; Index < NR_GRANT_FRAMES; Index++) {\r
Parameters.domid = DOMID_SELF;\r
Parameters.idx = Index;\r
Parameters.space = XENMAPSPACE_grant_table;\r
- Parameters.gpfn = (((xen_pfn_t) GrantTable) >> EFI_PAGE_SHIFT) + Index;\r
- ReturnCode = XenHypercallMemoryOp (Dev, XENMEM_add_to_physmap, &Parameters);\r
+ Parameters.gpfn = (xen_pfn_t) ((UINTN) GrantTable >> EFI_PAGE_SHIFT) + Index;\r
+ ReturnCode = XenHypercallMemoryOp (XENMEM_add_to_physmap, &Parameters);\r
if (ReturnCode != 0) {\r
- DEBUG ((EFI_D_ERROR, "Xen GrantTable, add_to_physmap hypercall error: %d\n", ReturnCode));\r
+ DEBUG ((EFI_D_ERROR,\r
+ "Xen GrantTable, add_to_physmap hypercall error: %Ld\n",\r
+ (INT64)ReturnCode));\r
}\r
}\r
}\r
\r
for (Index = NR_GRANT_FRAMES - 1; Index >= 0; Index--) {\r
Parameters.domid = DOMID_SELF;\r
- Parameters.gpfn = (((xen_pfn_t) GrantTable) >> EFI_PAGE_SHIFT) + Index;\r
- DEBUG ((EFI_D_INFO, "Xen GrantTable, removing %X\n", Parameters.gpfn));\r
- ReturnCode = XenHypercallMemoryOp (Dev, XENMEM_remove_from_physmap, &Parameters);\r
+ Parameters.gpfn = (xen_pfn_t) ((UINTN) GrantTable >> EFI_PAGE_SHIFT) + Index;\r
+ DEBUG ((EFI_D_INFO, "Xen GrantTable, removing %Lx\n",\r
+ (UINT64)Parameters.gpfn));\r
+ ReturnCode = XenHypercallMemoryOp (XENMEM_remove_from_physmap, &Parameters);\r
if (ReturnCode != 0) {\r
- DEBUG ((EFI_D_ERROR, "Xen GrantTable, remove_from_physmap hypercall error: %d\n", ReturnCode));\r
+ DEBUG ((EFI_D_ERROR,\r
+ "Xen GrantTable, remove_from_physmap hypercall error: %Ld\n",\r
+ (INT64)ReturnCode));\r
}\r
}\r
GrantTable = NULL;\r