- UINTN Size;\r
- UINTN Size1;\r
- UINTN Size2;\r
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath2;\r
-\r
- //\r
- // If there's only 1 path, just duplicate it.\r
- //\r
- if (FirstDevicePath == NULL) {\r
- return DuplicateDevicePath ((SecondDevicePath != NULL) ? SecondDevicePath : &mUefiDevicePathLibEndDevicePath);\r
- }\r
-\r
- if (SecondDevicePath == NULL) {\r
- return DuplicateDevicePath (FirstDevicePath);\r
- }\r
-\r
- //\r
- // Allocate space for the combined device path. It only has one end node of\r
- // length EFI_DEVICE_PATH_PROTOCOL.\r
- //\r
- Size1 = GetDevicePathSize (FirstDevicePath);\r
- Size2 = GetDevicePathSize (SecondDevicePath);\r
- Size = Size1 + Size2 - EFI_END_DEVICE_PATH_LENGTH;\r
-\r
- NewDevicePath = AllocatePool (Size);\r
-\r
- if (NewDevicePath != NULL) {\r
- NewDevicePath = CopyMem (NewDevicePath, FirstDevicePath, Size1);\r
- //\r
- // Over write FirstDevicePath EndNode and do the copy\r
- //\r
- DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath +\r
- (Size1 - EFI_END_DEVICE_PATH_LENGTH));\r
- CopyMem (DevicePath2, SecondDevicePath, Size2);\r
- }\r
-\r
- return NewDevicePath;\r