Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit 7f46bd0

Browse files
committed
Implement config parsing, and fix lwext4
1 parent 0584a7b commit 7f46bd0

File tree

23 files changed

+958
-46
lines changed

23 files changed

+958
-46
lines changed

Abm.dec

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,96 @@
44
PACKAGE_GUID = aba6ea83-69e9-4345-b074-01f3626b389f
55
PACKAGE_VERSION = 0.0.1
66

7+
[Guids.common]
8+
gQcomTokenSpaceGuid = { 0x882f8c2b, 0x9646, 0x435f, { 0x8d, 0xe5, 0xf2, 0x08, 0xff, 0x80, 0xc1, 0xbd } }
9+
gEfiPartitionTypeGuid = { 0x6848de61, 0xeb61, 0x4def, { 0x9a, 0x8e, 0x38, 0x17, 0xcb, 0xeb, 0x8f, 0x1c } }
10+
gEfiEmmcUserPartitionGuid = { 0xb615f1f5, 0x5088, 0x43cd, { 0x80, 0x9c, 0xa1, 0x6e, 0x52, 0x48, 0x7d, 0x00 } }
11+
gEfiEmmcBootPartition1Guid = { 0x12c55b20, 0x25d3, 0x41c9, { 0x8e, 0x06, 0x28, 0x2d, 0x94, 0xc6, 0x76, 0xad } }
12+
gEfiEmmcBootPartition2Guid = { 0x6b76a6db, 0x0257, 0x48a9, { 0xaa, 0x99, 0xf6, 0xb1, 0x65, 0x5f, 0x7b, 0x00 } }
13+
gEfiEmmcRpmbPartitionGuid = { 0xc49551ea, 0xd6bc, 0x4966, { 0x94, 0x99, 0x87, 0x1e, 0x39, 0x31, 0x33, 0xcd } }
14+
gEfiEmmcGppPartition1Guid = { 0xb9251ea5, 0x3462, 0x4807, { 0x86, 0xc6, 0x89, 0x48, 0xb1, 0xb3, 0x61, 0x63 } }
15+
gEfiEmmcGppPartition2Guid = { 0x24f906cd, 0xee11, 0x43e1, { 0x84, 0x27, 0xdc, 0x7a, 0x36, 0xf4, 0xc0, 0x59 } }
16+
gEfiEmmcGppPartition3Guid = { 0x5a5709a9, 0xac40, 0x4f72, { 0x88, 0x62, 0x5b, 0x01, 0x04, 0x16, 0x6e, 0x76 } }
17+
gEfiEmmcGppPartition4Guid = { 0xa44e27c9, 0x258e, 0x406e, { 0xbf, 0x33, 0x77, 0xf5, 0xf2, 0x44, 0xc4, 0x87 } }
18+
gEfiSdRemovableGuid = { 0xd1531d41, 0x3f80, 0x4091, { 0x8d, 0x0a, 0x54, 0x1f, 0x59, 0x23, 0x6d, 0x66 } }
19+
gEfiUfsLU0Guid = { 0x860845c1, 0xbe09, 0x4355, { 0x8b, 0xc1, 0x30, 0xd6, 0x4f, 0xf8, 0xe6, 0x3a } }
20+
gEfiUfsLU1Guid = { 0x8d90d477, 0x39a3, 0x4a38, { 0xab, 0x9e, 0x58, 0x6f, 0xf6, 0x9e, 0xd0, 0x51 } }
21+
gEfiUfsLU2Guid = { 0xedf85868, 0x87ec, 0x4f77, { 0x9c, 0xda, 0x5f, 0x10, 0xdf, 0x2f, 0xe6, 0x01 } }
22+
gEfiUfsLU3Guid = { 0x1ae69024, 0x8aeb, 0x4df8, { 0xbc, 0x98, 0x00, 0x32, 0xdb, 0xdf, 0x50, 0x24 } }
23+
gEfiUfsLU4Guid = { 0xd33f1985, 0xf107, 0x4a85, { 0xbe, 0x38, 0x68, 0xdc, 0x7a, 0xd3, 0x2c, 0xea } }
24+
gEfiUfsLU5Guid = { 0x4ba1d05f, 0x088e, 0x483f, { 0xa9, 0x7e, 0xb1, 0x9b, 0x9c, 0xcf, 0x59, 0xb0 } }
25+
gEfiUfsLU6Guid = { 0x4acf98f6, 0x26fa, 0x44d2, { 0x81, 0x32, 0x28, 0x2f, 0x2d, 0x19, 0xa4, 0xc5 } }
26+
gEfiUfsLU7Guid = { 0x8598155f, 0x34de, 0x415c, { 0x8b, 0x55, 0x84, 0x3e, 0x33, 0x22, 0xd3, 0x6f } }
27+
gEfiUfsRPMBGuid = { 0x5397474e, 0xf75d, 0x44b3, { 0x8e, 0x57, 0xd9, 0x32, 0x4f, 0xcf, 0x6f, 0xe1 } }
28+
gEfiNandUserPartitionGuid = { 0x03ef84a9, 0x60ce, 0x4371, { 0x97, 0xcf, 0x04, 0x84, 0x5a, 0x86, 0x5b, 0x79 } }
29+
30+
gEfiPlatPartitionTypeGuid = { 0x543c031a, 0x4cb6, 0x4897, { 0xbf, 0xfe, 0x4b, 0x48, 0x57, 0x68, 0xa8, 0xad } }
31+
gQcomKeypadDeviceGuid = { 0xd7f58a0e, 0xbed2, 0x4b5a, { 0xbb, 0x43, 0x8a, 0xb2, 0x3d, 0xd0, 0xe2, 0xb0 } }
32+
gEfiPlatformInfoGuid= { 0x3351baf7, 0x0820, 0x40df, { 0xb3, 0xfd, 0x4b, 0x7a, 0x3d, 0x43, 0x81, 0x88 } }
33+
gEfiLogFSPartitionGuid = { 0xBC0330EB, 0x3410, 0x4951, { 0xA6, 0x17, 0x03, 0x89, 0x8D, 0xBE, 0x33, 0x72 } }
34+
gEfiAblFvNameGuid= { 0x046fae99, 0xcf2e, 0x49ed, { 0xA6, 0xA8, 0xA1, 0x48, 0x8b, 0x7E, 0x80, 0xd3 } }
35+
gEfiMiscPartitionGuid = { 0x82ACC91F, 0x357C, 0x4A68, { 0x9C, 0x8F, 0x68, 0x9E, 0x1B, 0x1A, 0x23, 0xA1 } }
36+
gEfiBootImgPartitionGuid = { 0x20117f86, 0xe985, 0x4357, { 0xb9, 0xee, 0x37, 0x4b, 0xc1, 0xd8, 0x48, 0x7d } }
37+
gEfiRecoveryImgPartitionGuid = { 0x9D72D4E4, 0x9958, 0x42DA, { 0xAC, 0x26, 0xBE, 0xA7, 0xA9, 0x0B, 0x04, 0x34 } }
38+
gEfiSystemPartitionGuid = { 0x97D7B011, 0x54DA, 0x4835, { 0xB3, 0xC4, 0x91, 0x7A, 0xD6, 0xE7, 0x3D, 0x74 } }
39+
gEfiVbmetaPartitionGuid = { 0x4b7a15d6, 0x322c, 0x42ac, { 0x81, 0x10, 0x88, 0xb7, 0xda, 0x0c, 0x5d, 0x77 } }
40+
gEfiDtboPartitionGuid = { 0x24d0d418, 0xd31d, 0x4d8d, { 0xac, 0x2c, 0x4d, 0x43, 0x05, 0x18, 0x84, 0x50 } }
41+
gEfiDipPartitionGuid = { 0x4114B077, 0x005D, 0x4E12, { 0xAC, 0x8C, 0xB4, 0x93, 0xBD, 0xA6, 0x84, 0xFB } }
42+
gEfiMdtpPartitionGuid = { 0x3878408A, 0xE263, 0x4B67, { 0xB8, 0x78, 0x63, 0x40, 0xB3, 0x5B, 0x11, 0xE3 } }
43+
gBlockIoRefreshGuid = { 0xb1eb3d10, 0x9d67, 0x40ca, { 0x95, 0x59, 0xf1, 0x48, 0x8b, 0x1b, 0x2d, 0xdb } }
44+
gEfiRNGAlgRawGuid = { 0xe43176d7, 0xb6e8, 0x4827, { 0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61 } }
45+
46+
[Protocols]
47+
# SCM
48+
gQcomScmProtocolGuid = { 0x77ed108d, 0x8524, 0x4b8b, { 0x9d, 0x2e, 0x34, 0x98, 0x7a, 0xec, 0xb9, 0xc1 } }
49+
# PlatformInfo
50+
gEfiPlatformInfoProtocolGuid = { 0x157a5c45, 0x21b2, 0x43c5, { 0xba, 0x7c, 0x82, 0x2f, 0xee, 0x5f, 0xe5, 0x99 } }
51+
# Sdcc Card Info
52+
gEfiMemCardInfoProtocolGuid = { 0x85c1f7d2, 0xbce6, 0x4f31, { 0x8f, 0x4d, 0xd3, 0x7e, 0x03, 0xd0, 0x5e, 0xaa } }
53+
# USB Function
54+
gEfiUsbfnIoProtocolGuid = { 0x32d2963a, 0xfe5d, 0x4f30, { 0xb6, 0x33, 0x6e, 0x5d, 0xc5, 0x58, 0x3, 0xcc } }
55+
# ChipInfo
56+
gEfiChipInfoProtocolGuid = { 0xb0760469, 0x970c, 0x487a, { 0xa4, 0xb5, 0x28, 0xdb, 0x7b, 0x45, 0xce, 0xf1 } }
57+
gEfiPartitionRecordGuid = { 0xfe2555be, 0xd716, 0x4686, { 0xb9, 0xd0, 0x79, 0xdb, 0x59, 0x21, 0xb7, 0x0d } }
58+
# PMIC VERSION
59+
gQcomPmicVersionProtocolGuid = { 0x4684800a, 0x2755, 0x4edc, { 0xb4, 0x43, 0x7f, 0x8c, 0xeb, 0x32, 0x39, 0xd3 } }
60+
# Guid for Fastboot
61+
gEfiUsbDeviceProtocolGuid = { 0xd9d9ce48, 0x44b8, 0x4f49, { 0x8e, 0x3e, 0x2a, 0x3b, 0x92, 0x7d, 0xc6, 0xc1 } }
62+
#RAM Partitions Protocol
63+
gEfiRamPartitionProtocolGuid = { 0x5172FFB5, 0x4253, 0x7D51, { 0xC6, 0x41, 0xA7, 0x01, 0xF9, 0x73, 0x10, 0x3C } }
64+
#Erase Block Protocol
65+
gEfiEraseBlockProtocolGuid = { 0x95A9A93E, 0xA86E, 0x4926, { 0xaa, 0xef, 0x99, 0x18, 0xe7, 0x72, 0xd9, 0x87 } }
66+
# ResetReasonProtocol
67+
gEfiResetReasonProtocolGuid = { 0xA022155A, 0x4828, 0x4535, { 0xA4, 0x99, 0x11, 0xF1, 0x52, 0x40, 0xB9, 0x1B } }
68+
# Charger Detection Protocol
69+
gChargerExProtocolGuid = { 0x6edc8a6d, 0x2663, 0x43cd, { 0x90, 0xff, 0x46, 0x21, 0xff, 0xd1, 0x0d, 0xf5 } }
70+
# Pon Reason Protocol
71+
gQcomPmicPonProtocolGuid = { 0x97044b58, 0xfea4, 0x4ad0, { 0x9d, 0xb, 0xe4, 0x17, 0xd6, 0xf, 0x11, 0xa1 }}
72+
# Throttle limit Protocol
73+
gEfiLimitsProtocolGuid = { 0x79d6c879, 0x725e, 0x489e, { 0xa0, 0xa9, 0x27, 0xef, 0xa5, 0xdf, 0xcb, 0x35 } }
74+
# VerifiedBoot Protocol
75+
gEfiQcomVerifiedBootProtocolGuid = { 0x8e5eff91, 0x21b6, 0x47d3, { 0xaf, 0x2b, 0xc1, 0x5a, 0x1, 0xe0, 0x20, 0xec } }
76+
# Scm mode switch Protocol
77+
gQcomScmModeSwithProtocolGuid = { 0xf57f73ed, 0x0afc, 0x4723, { 0x93, 0x74, 0x2c, 0xeb, 0xc0, 0x19, 0x8e, 0xf9 } }
78+
# Qseecom Protocol
79+
gQcomQseecomProtocolGuid = { 0xa74862ce, 0x680f, 0x4fe1, { 0xa3, 0x11, 0xdf, 0x41, 0xf4, 0x3, 0x3, 0x91 } }
80+
# Mdtp Protocol
81+
gQcomMdtpProtocolGuid = { 0x71746E63, 0x65F9, 0x41EC, { 0xAC, 0x08, 0xCD, 0xD1, 0xF2, 0xD0, 0x22, 0x98 } }
82+
# Partition Type Protocol
83+
gEfiPartitionTypeGuid = { 0x6848de61, 0xeb61, 0x4def, { 0x9a, 0x8e, 0x38, 0x17, 0xcb, 0xeb, 0x8f, 0x1c } }
84+
# Sha256 Protocol
85+
gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, {0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } }
86+
#Nand Partition GUID Protocol
87+
gEfiNandPartiGuidProtocolGuid = { 0xd68edce2, 0xa314, 0x457b, { 0x96, 0x2a, 0x1d, 0x99, 0xbb, 0xfc, 0xbb, 0xfb } }
88+
# Rng Protocol guid
89+
gQcomRngProtocolGuid = { 0x3152bca5, 0xeade, 0x433d, { 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } }
90+
#UBI flasher protocol Guid
91+
gEfiUbiFlasherProtocolGuid = { 0xe3eef434, 0x22c9, 0xe33b, { 0x8f, 0x5d, 0x0e, 0x81, 0x68, 0x6a, 0x68, 0xcb } }
92+
93+
gEfiQcomASN1X509ProtocolGuid = { 0x408ec123, 0x134e, 0x4b80, { 0x91, 0x42, 0xb8, 0x9a, 0xe, 0x08, 0xf8, 0xb3 } }
94+
95+
gEfiQcomSecRSAProtocolGuid = { 0xeb7a442a, 0xcef4, 0x40a7, {0xa8, 0xae, 0x5a, 0x2e, 0x7f, 0x48, 0xe1, 0x72 } }
96+
797
#[Includes]
898
# StdLib/Include
999
[Includes.common]

Abm.dsc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
AbmLib|AbmPkg/Library/AbmLib/AbmLib.inf
8484

8585
lwext4Lib|AbmPkg/Library/lwext4Lib/lwext4Lib.inf
86-
86+
FastbootLib|QcomModulePkg/Library/FastbootLib/FastbootLib.inf
87+
8788
[LibraryClasses.AARCH64]
8889
CompilerIntrinsicsLib|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
8990

Include/Library/abm_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
void test_lvgl(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable);
1+
void test_lvgl (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable, EFI_BLOCK_IO_PROTOCOL *BlockIo);

Include/ext4_debug.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void ext4_dmask_clr(uint32_t m);
141141
* @return debug mask*/
142142
uint32_t ext4_dmask_get(void);
143143

144-
#if CONFIG_DEBUG_PRINTF
144+
145145
#include <stdio.h>
146146

147147
/**@brief Debug printf.*/
@@ -153,32 +153,21 @@ uint32_t ext4_dmask_get(void);
153153
printf("l: %d ", __LINE__); \
154154
} \
155155
printf(__VA_ARGS__); \
156-
fflush(stdout); \
157156
} \
158157
} while (0)
159-
#else
160-
#define ext4_dbg(m, ...) do { } while (0)
161-
#endif
158+
162159

163160
#if CONFIG_DEBUG_ASSERT
164161
/**@brief Debug assertion.*/
165162
#if CONFIG_HAVE_OWN_ASSERT
166163
#include <stdio.h>
167164

168-
#define ext4_assert(_v) \
169-
do { \
170-
if (!(_v)) { \
171-
printf("assertion failed:\nfile: %s\nline: %d\n", \
172-
__FILE__, __LINE__); \
173-
while (1) \
174-
; \
175-
} \
176-
} while (0)
165+
#define ext4_assert(_v)
177166
#else
178-
#define ext4_assert(_v) assert(_v)
167+
#define ext4_assert(_v)
179168
#endif
180169
#else
181-
#define ext4_assert(_v) ((void)(_v))
170+
#define ext4_assert(_v)
182171
#endif
183172

184173
#ifdef __cplusplus

Include/string.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@
1616
#define memset(s, c, n) SetMem((s), (UINTN)(n), (UINT8)(c))
1717
#define memcpy(s1, s2, n) CopyMem((s1), (s2), (n))
1818

19+
static inline char *
20+
strcat (char *dest, const char *src)
21+
{
22+
char *p = dest;
23+
while (*p)
24+
p++;
25+
while ((*p = *src) != '\0')
26+
{
27+
p++;
28+
src++;
29+
}
30+
31+
return dest;
32+
}
33+
1934
static inline char *strncpy(char *dest, const char *src, size_t n)
2035
{
2136
RETURN_STATUS Status = AsciiStrCpyS(dest, n, src);

Library/AbmLib/AbmLib.inf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,38 @@
3232
BootLib
3333
EfiFileLib
3434
lwext4Lib
35+
FastbootLib
36+
37+
[Protocols]
38+
gEfiSimpleTextInProtocolGuid
39+
gEfiDevicePathToTextProtocolGuid
40+
gEfiSimpleTextOutProtocolGuid
41+
gEfiBlockIoProtocolGuid
42+
gEfiDiskIoProtocolGuid
43+
gEfiPartitionRecordGuid
44+
gEfiUsbDeviceProtocolGuid
45+
gEfiUsbfnIoProtocolGuid
46+
gEfiMemCardInfoProtocolGuid
47+
gEfiEraseBlockProtocolGuid
48+
49+
[Guids]
50+
gEfiUfsLU0Guid
51+
gEfiUfsLU1Guid
52+
gEfiUfsLU2Guid
53+
gEfiUfsLU3Guid
54+
gEfiUfsLU4Guid
55+
gEfiUfsLU5Guid
56+
gEfiUfsLU6Guid
57+
gEfiUfsLU7Guid
58+
gEfiBootImgPartitionGuid
59+
gEfiRecoveryImgPartitionGuid
60+
gQcomTokenSpaceGuid
61+
gBlockIoRefreshGuid
3562

3663
[Sources.common]
3764
abm_base.h
3865
abm_base.c
66+
abm_fs.h
67+
abm_fs.c
68+
config.c
69+
fs_utils.c

Library/AbmLib/abm_base.c

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
11
#include <Uefi.h>
22
#include <Protocol/GraphicsOutput.h>
33
#include <Library/UefiLib.h>
4+
#include <Library/BaseLib.h>
5+
#include <Library/BaseMemoryLib.h>
6+
#include <Library/DebugLib.h>
7+
#include <Library/MemoryAllocationLib.h>
8+
#include <Library/PcdLib.h>
9+
#include <Library/UefiApplicationEntryPoint.h>
10+
#include <Library/UefiBootServicesTableLib.h>
11+
#include <Library/UefiRuntimeServicesTableLib.h>
12+
413
//TODO: fix this include
514
#include <../Include/lvgl.h>
615
#include <../Include/lv_misc/lv_log.h>
716
#include <string.h>
8-
17+
#include <Protocol/BlockIo.h>
918
EFI_SYSTEM_TABLE *gST1;
1019
EFI_BOOT_SERVICES *gBS1;
1120
EFI_GRAPHICS_OUTPUT_PROTOCOL *mGop;
1221
lv_disp_drv_t mDispDrv;
1322
lv_indev_drv_t mFakeInputDrv;
1423
lv_disp_t * disp;
1524
bool abm_running=true;
25+
#include <ext4.h>
26+
#include "abm_fs.h"
27+
#include <ext4_mkfs.h>
28+
#include "config.h"
29+
30+
struct boot_entry *entry_list;
31+
32+
static struct ext4_mkfs_info info = {
33+
.block_size = 4096,
34+
.journal = false,
35+
};
36+
static int fs_type = F_SET_EXT2;
37+
static struct ext4_fs fs;
38+
static struct ext4_blockdev *bd;
39+
1640
static void event_handler(lv_obj_t * obj, lv_event_t event)
1741
{
1842
if(event == LV_EVENT_CLICKED) {
@@ -65,13 +89,22 @@ bool key_read(lv_indev_drv_t * drv, lv_indev_data_t*data)
6589
//
6690
EFI_STATUS
6791
EFIAPI
68-
test_lvgl (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
92+
test_lvgl (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable, EFI_BLOCK_IO_PROTOCOL *BlockIo)
6993
{
7094
gST1 = SystemTable;
7195
gBS1 = gST1->BootServices;
7296
gBS1->LocateProtocol(
7397
&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&mGop);
7498

99+
// Setup lwext4 lib, based on UEFI BlockIo protocol
100+
uefi_dev_set(BlockIo);
101+
bd = uefi_dev_get();
102+
if (!bd) {
103+
DebugAssert("abm_base.c", 92, "open_filedev: fail\n");
104+
}
105+
106+
mount_meta(bd);
107+
entry_list = parse_boot_entries(&entry_list);
75108

76109
// Prepare LittleVGL
77110
lv_init();
@@ -104,11 +137,11 @@ test_lvgl (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
104137

105138
lv_obj_t * list_btn;
106139
lv_obj_set_state(list1, LV_STATE_DEFAULT);
107-
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "Example 1");
108-
lv_obj_set_event_cb(list_btn, event_handler);
109-
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "Example 2");
110-
lv_obj_set_event_cb(list_btn, event_handler);
140+
for(int i=0; i<get_entry_count(); i++){
141+
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, (entry_list+i)->title);
142+
}
111143
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "Extras");
144+
lv_obj_set_event_cb(list_btn, event_handler);
112145
lv_list_set_anim_time(list1, 500);
113146

114147
while (abm_running) {

Library/AbmLib/abm_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
void test_lvgl(IN EFI_SYSTEM_TABLE *SystemTable);
1+
void test_lvgl (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable, EFI_BLOCK_IO_PROTOCOL *BlockIo);

0 commit comments

Comments
 (0)