]> git.proxmox.com Git - mirror_edk2.git/blob - FatPkg/FatPei/Part.c
8a54e56f5ae6c452003fea6e6de9f0cc741a44a8
[mirror_edk2.git] / FatPkg / FatPei / Part.c
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 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #include "FatLitePeim.h"
18
19 /**
20 This function finds Eltorito partitions. Main algorithm
21 is ported from DXE partition driver.
22
23 @param[in] PrivateData The global memory map
24 @param[in] ParentBlockDevNo The parent block device
25
26 @retval TRUE New partitions are detected and logical block devices
27 are added to block device array
28 @retval FALSE No new partitions are added
29
30 **/
31 BOOLEAN
32 FatFindEltoritoPartitions (
33 IN PEI_FAT_PRIVATE_DATA *PrivateData,
34 IN UINTN ParentBlockDevNo
35 );
36
37 /**
38 This function finds Mbr partitions. Main algorithm
39 is ported from DXE partition driver.
40
41 @param[in] PrivateData The global memory map
42 @param[in] ParentBlockDevNo The parent block device
43
44 @retval TRUE New partitions are detected and logical block devices
45 are added to block device array
46 @retval FALSE No new partitions are added
47
48 **/
49 BOOLEAN
50 FatFindMbrPartitions (
51 IN PEI_FAT_PRIVATE_DATA *PrivateData,
52 IN UINTN ParentBlockDevNo
53 );
54
55 /**
56 This function finds partitions (logical devices) in physical block devices.
57
58 @param PrivateData Global memory map for accessing global variables.
59
60 **/
61 VOID
62 FatFindPartitions (
63 IN PEI_FAT_PRIVATE_DATA *PrivateData
64 )
65 {
66 BOOLEAN Found;
67 UINTN Index;
68
69 do {
70 Found = FALSE;
71
72 for (Index = 0; Index < PrivateData->BlockDeviceCount; Index++) {
73 if (!PrivateData->BlockDevice[Index].PartitionChecked) {
74 Found = FatFindMbrPartitions (PrivateData, Index);
75 if (!Found) {
76 Found = FatFindEltoritoPartitions (PrivateData, Index);
77 }
78 }
79 }
80 } while (Found && PrivateData->BlockDeviceCount <= PEI_FAT_MAX_BLOCK_DEVICE);
81 }
82