Newer
Older
AMI-Aptio-BIOS-Reversed / Build / GuidArtifacts / 117828F1-DA7D-4BC1-8B58-9A954FED5121 / Disk.c
@Ajax Dong Ajax Dong 2 days ago 6 KB Full restructure
#include "117828F1-DA7D-4BC1-8B58-9A954FED5121.h"

// Disk.c - Disk operations
// Extracted from 117828F1-DA7D-4BC1-8B58-9A954FED5121.c

// Function: RstDeviceProbe @ 0x6c10 (0x7f bytes)
// Index: 178/906

__int64 __fastcall RstDeviceProbe(__int64 a1)
{
  __int64 v2; // rcx
  __int64 v4; // rax
  __int64 v5; // rcx
  int v6; // eax

  v2 = *(_QWORD *)(a1 + 184); /*0x6c19*/
  if ( !v2 ) /*0x6c23*/
    return 0x8000000000000007uLL; /*0x6c25*/
  *(_DWORD *)(a1 + 88) = 0; /*0x6c31*/
  *(_BYTE *)(a1 + 92) = 0; /*0x6c35*/
  *(_BYTE *)(a1 + 93) = 1; /*0x6c39*/
  *(_BYTE *)(a1 + 94) = 0; /*0x6c3d*/
  *(_BYTE *)(a1 + 95) = 0; /*0x6c41*/
  *(_BYTE *)(a1 + 96) = 0; /*0x6c45*/
  *(_DWORD *)(a1 + 104) = 4; /*0x6c49*/
  v4 = sub_A29C(v2); /*0x6c50*/
  v5 = *(_QWORD *)(a1 + 184); /*0x6c55*/
  *(_QWORD *)(a1 + 112) = v4 - 1; /*0x6c5f*/
  v6 = j_HiiLibReturnZero(v5); /*0x6c63*/
  *(_QWORD *)(a1 + 120) = 0; /*0x6c68*/
  *(_DWORD *)(a1 + 100) = v6; /*0x6c77*/
  *(_DWORD *)(a1 + 128) = 1; /*0x6c7a*/
  return sub_7D50(a1, (__int64)&unk_277C0); /*0x6c89*/
}

// Function: RstDeviceConfigure @ 0x6c90 (0x1a0 bytes)
// Index: 179/906

EFI_STATUS __fastcall RstDeviceConfigure(RST_DEVICE *Device)
{
  uint8_t v2; // di
  __int64 v4; // rax
  _BYTE *i; // rcx
  __int64 v6; // rcx
  const CHAR8 *Intel; // rax
  unsigned __int16 v8; // ax
  unsigned int v9; // eax
  __int64 v10; // rcx

  v2 = -1; /*0x6cba*/
  if ( !*(_QWORD *)&Device->reserved_090[40] ) /*0x6ca9*/
    return 0x8000000000000007uLL; /*0x6cc0*/
  *(_QWORD *)&Device->reserved_170[24] = MemAllocPages(12); /*0x6ce2*/
  *(_QWORD *)&Device->reserved_170[32] = MemAllocPages(40); /*0x6cf2*/
  v4 = MemAllocPages(42); /*0x6cf9*/
  i = *(_BYTE **)&Device->reserved_170[24]; /*0x6cfe*/
  *(_QWORD *)&Device->reserved_170[40] = v4; /*0x6d0b*/
  MemZero(i, 0, 12); /*0x6d12*/
  MemZero(*(_BYTE **)&Device->reserved_170[32], 0, 40); /*0x6d23*/
  MemZero(*(_BYTE **)&Device->reserved_170[40], 0, 42); /*0x6d35*/
  StrHexToDecimal("Intel", *(CHAR16 **)&Device->reserved_170[24]); /*0x6d48*/
  v6 = *(_QWORD *)&Device->reserved_090[40]; /*0x6d4d*/
  if ( !v6 ) /*0x6d57*/
    goto LABEL_8; /*0x6d57*/
  Intel = (const CHAR8 *)sub_A2AC(v6); /*0x6d59*/
  if ( Intel ) /*0x6d61*/
    StrHexToDecimal(Intel, *(CHAR16 **)&Device->reserved_170[40]); /*0x6d6d*/
  v8 = sub_A31C(*(_QWORD *)&Device->reserved_090[40]); /*0x6d79*/
  v2 = v8; /*0x6d7e*/
  if ( v8 == 0xFFFF ) /*0x6d85*/
LABEL_8:
    StrHexToDecimal("VROC Volume", *(CHAR16 **)&Device->reserved_170[32]); /*0x6db1*/
  else
    HiiCfgArraySet(*(CHAR8 **)&Device->reserved_170[32], 0x28u, "VROC %d Volume", v8); /*0x6d9c*/
  v9 = j_HiiLibReturnZero(*(_QWORD *)&Device->reserved_090[40]); /*0x6dbd*/
  v10 = *(_QWORD *)&Device->reserved_090[40]; /*0x6dc2*/
  Device->reserved_170[64] = v2; /*0x6dc9*/
  *(_QWORD *)&Device->reserved_170[56] = v9; /*0x6dd3*/
  *(_QWORD *)&Device->reserved_170[48] = sub_A29C(v10); /*0x6de5*/
  Device->reserved_170[65] = 2; /*0x6dec*/
  return (*(__int64 (__fastcall **)(void **, void *, uint8_t *, _QWORD, _QWORD))(qword_58070 + 328))( /*0x6e29*/
           &Device->Destructor,
           &unk_27910,
           &Device->reserved_170[24],
           0,
           0);
}

// Function: RstDeviceCheck @ 0x6e30 (0x79 bytes)
// Index: 180/906

__int64 __fastcall RstDeviceCheck(__int64 a1)
{
  __int64 v2; // rbx

  v2 = (*(__int64 (__fastcall **)(_QWORD, void *, __int64))(qword_58070 + 144))( /*0x6e61*/
         *(_QWORD *)(a1 + 8),
         &unk_27910,
         a1 + 392);
  if ( !v2 ) /*0x6e67*/
  {
    MemZeroThenFree(*(_BYTE **)(a1 + 400), 40); /*0x6e73*/
    MemZeroThenFree(*(_BYTE **)(a1 + 392), 12); /*0x6e82*/
    MemZeroThenFree(*(_BYTE **)(a1 + 408), 42); /*0x6e91*/
  }
  return v2; /*0x6ea3*/
}

// Function: RstDeviceRead @ 0x7ed4 (0x82 bytes)
// Index: 202/906

__int64 __fastcall RstDeviceRead(__int64 a1, int a2, unsigned __int64 a3, unsigned __int64 a4, unsigned __int64 a5)
{
  unsigned __int64 v8; // rbp
  __int64 v9; // rsi
  unsigned __int64 v10; // [rsp+40h] [rbp+8h] BYREF

  v10 = 0; /*0x7ee8*/
  if ( !a1 ) /*0x7ef6*/
    return 0x8000000000000002uLL; /*0x7ef8*/
  v8 = a5; /*0x7f04*/
  v9 = a1 - 40; /*0x7f09*/
  if ( RstSetBrowserData(a1 - 40, a2, a3, a4, a5, &v10) ) /*0x7f1f*/
    return (*(__int64 (__fastcall **)(__int64, unsigned __int64, unsigned __int64, unsigned __int64))(*(_QWORD *)v9 + 32LL))( /*0x7f3e*/
             v9,
             a3,
             a4,
             v8);
  else
    return v10; /*0x7f28*/
}

// Function: RstDeviceWrite @ 0x7f58 (0x94 bytes)
// Index: 203/906

__int64 __fastcall RstDeviceWrite(__int64 a1, int a2, unsigned __int64 a3, unsigned __int64 a4, unsigned __int64 a5)
{
  unsigned __int64 v8; // rbp
  _BYTE *v9; // rbx
  unsigned __int64 v10; // [rsp+40h] [rbp+8h] BYREF

  v10 = 0; /*0x7f6c*/
  if ( !a1 ) /*0x7f7a*/
    return 0x8000000000000002uLL; /*0x7f7c*/
  v8 = a5; /*0x7f88*/
  v9 = (_BYTE *)(a1 - 40); /*0x7f8d*/
  if ( !RstSetBrowserData(a1 - 40, a2, a3, a4, a5, &v10) ) /*0x7fa3*/
    return v10; /*0x7fac*/
  if ( v9[95] ) /*0x7fb3*/
    return 0x8000000000000008uLL; /*0x7fb9*/
  return (*(__int64 (__fastcall **)(_BYTE *, unsigned __int64, unsigned __int64, unsigned __int64))(*(_QWORD *)v9 + 40LL))( /*0x7fe6*/
           v9,
           a3,
           a4,
           v8);
}

// Function: RstDeviceGetStatus @ 0x7fec (0x26 bytes)
// Index: 204/906

__int64 __fastcall RstDeviceGetStatus(__int64 a1)
{
  __int64 v2; // rcx

  if ( a1 && (v2 = a1 - 40) != 0 ) /*0x8005*/
    return (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v2 + 48LL))(v2); /*0x800a*/
  else
    return 0x8000000000000007uLL; /*0x7ff5*/
}

// Function: RstDeviceSetFlags @ 0x1022c (0x28 bytes)
// Index: 424/906

__int64 __fastcall RstDeviceSetFlags(__int64 a1, unsigned int a2)
{
  __int64 result; // rax

  result = a2 & *(_DWORD *)(a1 + 136); /*0x1023a*/
  if ( (_DWORD)result != a2 ) /*0x1023e*/
  {
    *(_DWORD *)(a1 + 136) |= a2; /*0x10243*/
    return sub_10178(a1); /*0x1024a*/
  }
  return result; /*0x1024f*/
}

// Function: RstDeviceClearFlags @ 0x10254 (0x22 bytes)
// Index: 425/906

__int64 __fastcall RstDeviceClearFlags(__int64 a1, int a2)
{
  __int64 result; // rax

  result = *(unsigned int *)(a1 + 136); /*0x10258*/
  if ( ((unsigned int)result & a2) != 0 ) /*0x10260*/
  {
    *(_DWORD *)(a1 + 136) = result & ~a2; /*0x10266*/
    return sub_10178(a1); /*0x1026c*/
  }
  return result; /*0x10271*/
}