fix device path length

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2019-12-11 16:13:31 +03:00
parent 90148880ac
commit 3b4ce81052

View File

@ -67,13 +67,15 @@ CHAR8 *get_pci_dev_path(pci_dt_t *PciDt)
CHAR8* tmp; CHAR8* tmp;
CHAR16* devpathstr = NULL; CHAR16* devpathstr = NULL;
EFI_DEVICE_PATH_PROTOCOL* DevicePath = NULL; EFI_DEVICE_PATH_PROTOCOL* DevicePath = NULL;
UINTN Size;
DevicePath = DevicePathFromHandle (PciDt->DeviceHandle); DevicePath = DevicePathFromHandle (PciDt->DeviceHandle);
if (!DevicePath) if (!DevicePath)
return NULL; return NULL;
devpathstr = FileDevicePathToStr(DevicePath); devpathstr = FileDevicePathToStr(DevicePath);
tmp = AllocateZeroPool((StrLen(devpathstr)+1)*sizeof(CHAR16)); Size = StrLen(devpathstr) + 1;
UnicodeStrToAsciiStrS(devpathstr, tmp, (StrLen(devpathstr)+1)); tmp = AllocateZeroPool(Size);
UnicodeStrToAsciiStrS(devpathstr, tmp, Size);
return tmp; return tmp;
} }
@ -411,11 +413,11 @@ BOOLEAN set_eth_props(pci_dt_t *eth_dev)
devprop_add_value(device, "compatible", (UINT8*)&compatible[0], 12); devprop_add_value(device, "compatible", (UINT8*)&compatible[0], 12);
FakeID = gSettings.FakeLAN & 0xFFFF; FakeID = gSettings.FakeLAN & 0xFFFF;
devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4); devprop_add_value(device, "vendor-id", (UINT8*)&FakeID, 4);
} }
else if (eth_dev->vendor_id == 0x11AB && eth_dev->device_id == 0x4364) else if (eth_dev->vendor_id == 0x11AB && eth_dev->device_id == 0x4364)
{ {
UINT32 FakeID = 0x4354; UINT32 FakeID = 0x4354;
devprop_add_value(device, "device-id", (UINT8*)&FakeID, 4); devprop_add_value(device, "device-id", (UINT8*)&FakeID, 4);
} }
@ -492,7 +494,7 @@ BOOLEAN set_usb_props(pci_dt_t *usb_dev)
fake_devid = usb_dev->device_id & 0xFFFF; fake_devid = usb_dev->device_id & 0xFFFF;
if ((fake_devid & 0xFF00) == 0x2900) { if ((fake_devid & 0xFF00) == 0x2900) {
// fake_devid &= 0xFEFF; // fake_devid &= 0xFEFF;
fake_devid &= ~0xFF00; fake_devid &= ~0xFF00;
fake_devid |= 0x3A00; fake_devid |= 0x3A00;
devprop_add_value(device, "device-id", (UINT8*)&fake_devid, 4); devprop_add_value(device, "device-id", (UINT8*)&fake_devid, 4);
} }