1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <fmap_config.h>
5 #if CONFIG(CBFS_VERIFICATION)
6 #error "walkcbfs_asm is not safe to use with CBFS verification!"
9 /* we use this instead of CBFS_HEADER_ALIGN because the latter is retired. */
10 #define CBFS_ALIGNMENT 64
12 #define CBFS_FILE_MAGIC 0
13 #define CBFS_FILE_LEN (CBFS_FILE_MAGIC + 8)
14 #define CBFS_FILE_TYPE (CBFS_FILE_LEN + 4)
15 #define CBFS_FILE_CHECKSUM (CBFS_FILE_TYPE + 4)
16 #define CBFS_FILE_OFFSET (CBFS_FILE_CHECKSUM + 4)
18 #define CBFS_FILE_STRUCTSIZE (CBFS_FILE_OFFSET + 4)
20 #if FMAP_SECTION_COREBOOT_START < (0xffffffff - CONFIG_ROM_SIZE + 1)
21 #define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START)
23 #define COREBOOT_CBFS_START FMAP_SECTION_COREBOOT_START
31 * input %esi: filename
32 * input %esp: return address (not pointer to return address!)
33 * output %eax: pointer to CBFS header
34 * clobbers %ebx, %ecx, %edi
39 movl $COREBOOT_CBFS_START, %ebx
41 /* determine filename length */
51 mov 0(%ebx), %edi /* Check for LARCHIVE header */
58 /* LARCHIVE header found */
60 add $CBFS_FILE_STRUCTSIZE, %edi /* edi = address of first byte after
65 /* zero flag set if strings are equal */
74 sub $CBFS_FILE_STRUCTSIZE, %edi /* edi = # of walked bytes */
75 sub %edi, %esi /* esi = start of filename */
77 /* ebx = ecx = (current+offset+len+ALIGN-1) & ~(ALIGN-1) */
78 mov CBFS_FILE_OFFSET(%ebx), %ecx
81 mov CBFS_FILE_LEN(%ebx), %edi
84 /* round by 64 bytes */
85 add $(CBFS_ALIGNMENT - 1), %ecx
86 and $~(CBFS_ALIGNMENT - 1), %ecx
88 /* if oldaddr >= addr, leave */
95 /* if addr <= COREBOOT_END - 1, continue */
96 #define FMAP_SECTION_COREBOOT_END (FMAP_SECTION_COREBOOT_START - 1 + FMAP_SECTION_COREBOOT_SIZE)
98 movl $FMAP_SECTION_COREBOOT_END, %ecx
108 /* if filemagic isn't found, move forward 64 bytes */
109 add $CBFS_ALIGNMENT, %ebx