\r
@param[out] Ring The virtio ring to set up.\r
\r
- @retval EFI_OUT_OF_RESOURCES AllocatePages() failed to allocate contiguous\r
- pages for the requested QueueSize. Fields of\r
- Ring have indeterminate value.\r
+ @return Status codes propagated from\r
+ VirtIo->AllocateSharedPages().\r
\r
@retval EFI_SUCCESS Allocation and setup successful. Ring->Base\r
(and nothing else) is responsible for\r
#include <Library/BaseLib.h>\r
#include <Library/BaseMemoryLib.h>\r
#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
\r
#include <Library/VirtioLib.h>\r
\r
@param[out] Ring The virtio ring to set up.\r
\r
- @retval EFI_OUT_OF_RESOURCES AllocatePages() failed to allocate contiguous\r
- pages for the requested QueueSize. Fields of\r
- Ring have indeterminate value.\r
+ @return Status codes propagated from\r
+ VirtIo->AllocateSharedPages().\r
\r
@retval EFI_SUCCESS Allocation and setup successful. Ring->Base\r
(and nothing else) is responsible for\r
OUT VRING *Ring\r
)\r
{\r
+ EFI_STATUS Status;\r
UINTN RingSize;\r
volatile UINT8 *RingPagesPtr;\r
\r
sizeof *Ring->Used.AvailEvent,\r
EFI_PAGE_SIZE);\r
\r
+ //\r
+ // Allocate a shared ring buffer\r
+ //\r
Ring->NumPages = EFI_SIZE_TO_PAGES (RingSize);\r
- Ring->Base = AllocatePages (Ring->NumPages);\r
- if (Ring->Base == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
+ Status = VirtIo->AllocateSharedPages (\r
+ VirtIo,\r
+ Ring->NumPages,\r
+ &Ring->Base\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
}\r
SetMem (Ring->Base, RingSize, 0x00);\r
RingPagesPtr = Ring->Base;\r
IN OUT VRING *Ring\r
)\r
{\r
- FreePages (Ring->Base, Ring->NumPages);\r
+ VirtIo->FreeSharedPages (VirtIo, Ring->NumPages, Ring->Base);\r
SetMem (Ring, sizeof *Ring, 0x00);\r
}\r
\r