37#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
39STATIC CONST CHAR8 mBhyveSig[4] = {
'B',
'H',
'Y',
'V' };
43STATIC INT32 mBhyveFwCtlTxid = 0xa5;
101 for (i = 0; b[i].Base !=
NULL; i++) {
102 tLen += ROUNDUP (b[i].Len,
sizeof (UINT32));
127 cdata = (UINT8 *)Data;
130 for (i = 0; i < Len; i++) {
150 LData = (UINT32 *)Data;
152 while (Len >
sizeof (UINT32)) {
154 Len -=
sizeof (UINT32);
174 for (i = 0; b[i].Base; i++) {
196 for (i = 0; i < 3; i++) {
197 hIov[i].Base = &Hdr[i];
198 hIov[i].Len =
sizeof (Hdr[0]);
205 Hdr[0] = BIov_WLen (hIov) + BIov_WLen (Data);
206 Hdr[1] = (UINT32)OpCode;
207 Hdr[2] = mBhyveFwCtlTxid;
225 RETURN_STATUS Status;
243 Status = BhyveFwCtl_CvtErr (Rhdr->Err);
255 Dp = (UINT32 *)Data[0].Base;
257 if (remLen > Data[0].Len) {
259 xLen = remLen - Data[0].Len;
260 oLen = remLen = Data[0].Len;
265 remLen -=
sizeof (UINT32);
280 xLen -=
sizeof (UINT32);
296 RETURN_STATUS Status;
317 RETURN_STATUS Status;
319 Req[0].Base = (VOID *)Name;
324 Resp[0].Len =
sizeof (UINT32);
327 Status = BhyveFwCtl_Msg (OP_GET_LEN, Req, Resp);
335 UINT32 fData[FMAXSZ];
349 RETURN_STATUS Status;
352 if (*Size >
sizeof (FwGetvalBuf.fData)) {
356 Req[0].Base = (VOID *)Name;
360 Resp[0].Base = &FwGetvalBuf;
361 Resp[0].Len =
sizeof (UINT64) + *Size;
364 Status = BhyveFwCtl_Msg (OP_GET, Req, Resp);
372 *Size = (UINT32)FwGetvalBuf.fSize;
373 CopyMem (Item, FwGetvalBuf.fData, *Size);
390 RETURN_STATUS Status;
392 if (mBhyveFwCtlSupported ==
FALSE) {
397 Status = BhyveFwCtlGetLen (Name, (UINT32 *)Size);
399 Status = BhyveFwCtlGetVal (Name, Item, (UINT32 *)Size);
418 DEBUG ((DEBUG_INFO,
"FwCtlInitialize\n"));
421 for (i = 0; i < 4; i++) {
423 if (ch != mBhyveSig[i]) {
424 DEBUG ((DEBUG_INFO,
"Host f/w sig mismatch %c/%c\n", ch, mBhyveSig[i]));
429 mBhyveFwCtlSupported =
TRUE;
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
RETURN_STATUS EFIAPI BhyveFwCtlInitialize(VOID)
STATIC VOID EFIAPI BhyveFwCtl_MsgSend(IN UINT32 OpCode, IN BIO_VEC Data[])
STATIC VOID BIov_SendAll(IN BIO_VEC b[])
STATIC RETURN_STATUS EFIAPI BhyveFwCtl_MsgRecv(OUT MSG_RX_HDR *Rhdr, OUT BIO_VEC Data[])
STATIC UINT32 BIov_Send_Rem(IN UINT32 *Data, IN UINT32 Len)
STATIC VOID BIov_Send(IN char *Data, IN UINT32 Len)
RETURN_STATUS EFIAPI BhyveFwCtlGet(IN CONST CHAR8 *Name, OUT VOID *Item, IN OUT UINTN *Size)
UINT8 EFIAPI IoRead8(IN UINTN Port)
UINT32 EFIAPI IoRead32(IN UINTN Port)
UINT32 EFIAPI IoWrite32(IN UINTN Port, IN UINT32 Value)
UINT16 EFIAPI IoWrite16(IN UINTN Port, IN UINT16 Value)
#define RETURN_BUFFER_TOO_SMALL
#define RETURN_PROTOCOL_ERROR
#define RETURN_UNSUPPORTED
#define RETURN_INVALID_PARAMETER
#define DEBUG(Expression)