1 | /** @file
|
---|
2 | Routines supporting partition discovery and
|
---|
3 | logical device reading
|
---|
4 |
|
---|
5 | Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
|
---|
6 |
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 |
|
---|
9 | **/
|
---|
10 |
|
---|
11 | #include "FatLitePeim.h"
|
---|
12 |
|
---|
13 | /**
|
---|
14 | This function finds Eltorito partitions. Main algorithm
|
---|
15 | is ported from DXE partition driver.
|
---|
16 |
|
---|
17 | @param[in] PrivateData The global memory map
|
---|
18 | @param[in] ParentBlockDevNo The parent block device
|
---|
19 |
|
---|
20 | @retval TRUE New partitions are detected and logical block devices
|
---|
21 | are added to block device array
|
---|
22 | @retval FALSE No new partitions are added
|
---|
23 |
|
---|
24 | **/
|
---|
25 | BOOLEAN
|
---|
26 | FatFindEltoritoPartitions (
|
---|
27 | IN PEI_FAT_PRIVATE_DATA *PrivateData,
|
---|
28 | IN UINTN ParentBlockDevNo
|
---|
29 | );
|
---|
30 |
|
---|
31 | /**
|
---|
32 | This function finds Mbr partitions. Main algorithm
|
---|
33 | is ported from DXE partition driver.
|
---|
34 |
|
---|
35 | @param[in] PrivateData The global memory map
|
---|
36 | @param[in] ParentBlockDevNo The parent block device
|
---|
37 |
|
---|
38 | @retval TRUE New partitions are detected and logical block devices
|
---|
39 | are added to block device array
|
---|
40 | @retval FALSE No new partitions are added
|
---|
41 |
|
---|
42 | **/
|
---|
43 | BOOLEAN
|
---|
44 | FatFindMbrPartitions (
|
---|
45 | IN PEI_FAT_PRIVATE_DATA *PrivateData,
|
---|
46 | IN UINTN ParentBlockDevNo
|
---|
47 | );
|
---|
48 |
|
---|
49 | /**
|
---|
50 | This function is used for finding GPT partition on block device.
|
---|
51 | As follow UEFI spec we should check protective MBR first and then
|
---|
52 | try to check both primary/backup GPT structures.
|
---|
53 |
|
---|
54 | @param[in] PrivateData The global memory map
|
---|
55 | @param[in] ParentBlockDevNo The parent block device
|
---|
56 |
|
---|
57 | @retval TRUE New partitions are detected and logical block devices
|
---|
58 | are added to block device array
|
---|
59 | @retval FALSE No new partitions are added
|
---|
60 |
|
---|
61 | **/
|
---|
62 | BOOLEAN
|
---|
63 | FatFindGptPartitions (
|
---|
64 | IN PEI_FAT_PRIVATE_DATA *PrivateData,
|
---|
65 | IN UINTN ParentBlockDevNo
|
---|
66 | );
|
---|
67 |
|
---|
68 | /**
|
---|
69 | This function finds partitions (logical devices) in physical block devices.
|
---|
70 |
|
---|
71 | @param PrivateData Global memory map for accessing global variables.
|
---|
72 |
|
---|
73 | **/
|
---|
74 | VOID
|
---|
75 | FatFindPartitions (
|
---|
76 | IN PEI_FAT_PRIVATE_DATA *PrivateData
|
---|
77 | )
|
---|
78 | {
|
---|
79 | BOOLEAN Found;
|
---|
80 | UINTN Index;
|
---|
81 |
|
---|
82 | do {
|
---|
83 | Found = FALSE;
|
---|
84 |
|
---|
85 | for (Index = 0; Index < PrivateData->BlockDeviceCount; Index++) {
|
---|
86 | if (!PrivateData->BlockDevice[Index].PartitionChecked) {
|
---|
87 | if (FatFindGptPartitions (PrivateData, Index)) {
|
---|
88 | Found = TRUE;
|
---|
89 | continue;
|
---|
90 | }
|
---|
91 |
|
---|
92 | if (FatFindMbrPartitions (PrivateData, Index)) {
|
---|
93 | Found = TRUE;
|
---|
94 | continue;
|
---|
95 | }
|
---|
96 |
|
---|
97 | if (FatFindEltoritoPartitions (PrivateData, Index)) {
|
---|
98 | Found = TRUE;
|
---|
99 | continue;
|
---|
100 | }
|
---|
101 | }
|
---|
102 | }
|
---|
103 | } while (Found && PrivateData->BlockDeviceCount <= PEI_FAT_MAX_BLOCK_DEVICE);
|
---|
104 | }
|
---|