]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/VDiskChain/VDiskChain.h
1.1.07 release
[Ventoy.git] / EDK2 / edk2_mod / edk2-edk2-stable201911 / MdeModulePkg / Application / VDiskChain / VDiskChain.h
1 /******************************************************************************
2 * VDiskChain.h
3 *
4 * Copyright (c) 2021, longpanda <admin@ventoy.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef __VENTOY_H__
22 #define __VENTOY_H__
23
24 #define VDISK_MAGIC_LEN 32
25
26 #define VDISK_BLOCK_DEVICE_PATH_GUID \
27 { 0x6ed2134e, 0xc2ea, 0x4943, { 0x99, 0x54, 0xa7, 0x76, 0xe5, 0x9c, 0x12, 0xc3 }}
28
29 #define VDISK_BLOCK_DEVICE_PATH_NAME L"vdisk"
30
31 #if defined (MDE_CPU_IA32)
32 #define VENTOY_UEFI_DESC L"IA32 UEFI"
33 #elif defined (MDE_CPU_X64)
34 #define VENTOY_UEFI_DESC L"X64 UEFI"
35 #elif defined (MDE_CPU_EBC)
36 #elif defined (MDE_CPU_ARM)
37 #define VENTOY_UEFI_DESC L"ARM UEFI"
38 #elif defined (MDE_CPU_AARCH64)
39 #define VENTOY_UEFI_DESC L"ARM64 UEFI"
40 #else
41 #error Unknown Processor Type
42 #endif
43
44 typedef struct vdisk_block_data
45 {
46 EFI_HANDLE Handle;
47 EFI_BLOCK_IO_MEDIA Media; /* Media descriptor */
48 EFI_BLOCK_IO_PROTOCOL BlockIo; /* Block I/O protocol */
49
50 UINTN DevicePathCompareLen;
51 EFI_DEVICE_PATH_PROTOCOL *Path; /* Device path protocol */
52
53 EFI_HANDLE RawBlockIoHandle;
54 EFI_BLOCK_IO_PROTOCOL *pRawBlockIo;
55 EFI_DEVICE_PATH_PROTOCOL *pDiskDevPath;
56
57 /* ventoy disk part2 ESP */
58 EFI_HANDLE DiskFsHandle;
59 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *pDiskFs;
60 EFI_DEVICE_PATH_PROTOCOL *pDiskFsDevPath;
61
62 EFI_HANDLE IsoDriverImage;
63 }vdisk_block_data;
64
65
66 #define debug(expr, ...) if (gVDiskDebugPrint) VDiskDebug("[VDISK] "expr"\r\n", ##__VA_ARGS__)
67 #define trace(expr, ...) VDiskDebug("[VDISK] "expr"\r\n", ##__VA_ARGS__)
68 #define sleep(sec) gBS->Stall(1000000 * (sec))
69
70 #define vdisk_debug_pause() \
71 if (gVDiskDebugPrint) \
72 { \
73 UINTN __Index = 0; \
74 gST->ConOut->OutputString(gST->ConOut, L"[VDISK] ###### Press Enter to continue... ######\r\n");\
75 gST->ConIn->Reset(gST->ConIn, FALSE); \
76 gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &__Index);\
77 }
78
79 extern BOOLEAN gVDiskDebugPrint;
80 VOID EFIAPI VDiskDebug(IN CONST CHAR8 *Format, ...);
81 EFI_STATUS EFIAPI vdisk_block_io_read
82 (
83 IN EFI_BLOCK_IO_PROTOCOL *This,
84 IN UINT32 MediaId,
85 IN EFI_LBA Lba,
86 IN UINTN BufferSize,
87 OUT VOID *Buffer
88 );
89
90 extern UINT8 *g_disk_buf_addr;
91 extern UINT64 g_disk_buf_size;
92 extern vdisk_block_data gVDiskBlockData;
93 EFI_STATUS EFIAPI vdisk_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 ImgSize);
94 int vdisk_get_vdisk_raw(UINT8 **buf, UINT32 *size);
95
96 #endif
97