coreboot-kgpe-d16/src/arch/x86/walkcbfs.S
Patrick Georgi 6b5bc77c9b treewide: Remove "this file is part of" lines
Stefan thinks they don't add value.

Command used:
sed -i -e '/file is part of /d' $(git grep "file is part of " |egrep ":( */\*.*\*/\$|#|;#|-- | *\* )" | cut -d: -f1 |grep -v crossgcc |grep -v gcov | grep -v /elf.h |grep -v nvramtool)

The exceptions are for:
 - crossgcc (patch file)
 - gcov (imported from gcc)
 - elf.h (imported from GNU's libc)
 - nvramtool (more complicated header)

The removed lines are:
-       fmt.Fprintln(f, "/* This file is part of the coreboot project. */")
-# This file is part of a set of unofficial pre-commit hooks available
-/* This file is part of coreboot */
-# This file is part of msrtool.
-/* This file is part of msrtool. */
- * This file is part of ncurses, designed to be appended after curses.h.in
-/* This file is part of pgtblgen. */
- * This file is part of the coreboot project.
- /* This file is part of the coreboot project. */
-#  This file is part of the coreboot project.
-# This file is part of the coreboot project.
-## This file is part of the coreboot project.
--- This file is part of the coreboot project.
-/* This file is part of the coreboot project */
-/* This file is part of the coreboot project. */
-;## This file is part of the coreboot project.
-# This file is part of the coreboot project. It originated in the
- * This file is part of the coreinfo project.
-## This file is part of the coreinfo project.
- * This file is part of the depthcharge project.
-/* This file is part of the depthcharge project. */
-/* This file is part of the ectool project. */
- * This file is part of the GNU C Library.
- * This file is part of the libpayload project.
-## This file is part of the libpayload project.
-/* This file is part of the Linux kernel. */
-## This file is part of the superiotool project.
-/* This file is part of the superiotool project */
-/* This file is part of uio_usbdebug */

Change-Id: I82d872b3b337388c93d5f5bf704e9ee9e53ab3a9
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41194
Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-05-11 17:11:40 +00:00

122 lines
2.7 KiB
ArmAsm

/* SPDX-License-Identifier: GPL-2.0-only */
#define CBFS_HEADER_PTR 0xfffffffc
#define CBFS_HEADER_MAGIC 0
#define CBFS_HEADER_VERSION (CBFS_HEADER_MAGIC + 4)
#define CBFS_HEADER_ROMSIZE (CBFS_HEADER_VERSION + 4)
#define CBFS_HEADER_BOOTBLOCKSIZE (CBFS_HEADER_ROMSIZE + 4)
#define CBFS_HEADER_ALIGN (CBFS_HEADER_BOOTBLOCKSIZE + 4)
#define CBFS_HEADER_OFFSET (CBFS_HEADER_ALIGN + 4)
/* we use this instead of CBFS_HEADER_ALIGN because the latter is retired. */
#define CBFS_ALIGNMENT 64
#define CBFS_FILE_MAGIC 0
#define CBFS_FILE_LEN (CBFS_FILE_MAGIC + 8)
#define CBFS_FILE_TYPE (CBFS_FILE_LEN + 4)
#define CBFS_FILE_CHECKSUM (CBFS_FILE_TYPE + 4)
#define CBFS_FILE_OFFSET (CBFS_FILE_CHECKSUM + 4)
#define CBFS_FILE_STRUCTSIZE (CBFS_FILE_OFFSET + 4)
.section .text
.global walkcbfs_asm
/*
* input %esi: filename
* input %esp: return address (not pointer to return address!)
* output %eax: pointer to CBFS header
* clobbers %ebx, %ecx, %edi
*/
walkcbfs_asm:
cld
mov CBFS_HEADER_PTR, %eax
mov CBFS_HEADER_ROMSIZE(%eax), %ecx
bswap %ecx
mov $0, %ebx
sub %ecx, %ebx /* ROM base address in ebx */
mov CBFS_HEADER_OFFSET(%eax), %ecx
bswap %ecx
add %ecx, %ebx /* address where we start looking for LARCHIVEs */
/* determine filename length */
mov $0, %eax
1:
cmpb $0, (%eax,%esi)
jz 2f
add $1, %eax
jmp 1b
2:
add $1, %eax
walker:
mov 0(%ebx), %edi /* Check for LARCHIVE header */
cmp %edi, filemagic
jne searchfile
mov 4(%ebx), %edi
cmp %edi, filemagic+4
jne searchfile
/* LARCHIVE header found */
mov %ebx, %edi
add $CBFS_FILE_STRUCTSIZE, %edi /* edi = address of first byte after
* struct cbfs_file
*/
mov %eax, %ecx
repe cmpsb
/* zero flag set if strings are equal */
jnz tryharder
/* we found it! */
mov %ebx, %eax
jmp *%esp
tryharder:
sub %ebx, %edi
sub $CBFS_FILE_STRUCTSIZE, %edi /* edi = # of walked bytes */
sub %edi, %esi /* esi = start of filename */
/* ebx = ecx = (current+offset+len+ALIGN-1) & ~(ALIGN-1) */
mov CBFS_FILE_OFFSET(%ebx), %ecx
bswap %ecx
add %ebx, %ecx
mov CBFS_FILE_LEN(%ebx), %edi
bswap %edi
add %edi, %ecx
/* round by 64 bytes */
add $(CBFS_ALIGNMENT - 1), %ecx
and $~(CBFS_ALIGNMENT - 1), %ecx
/* if oldaddr >= addr, leave */
cmp %ebx, %ecx
jbe out
mov %ecx, %ebx
check_for_exit:
/* look if we should exit: did we pass into the bootblock already? */
mov CBFS_HEADER_PTR, %ecx
mov CBFS_HEADER_BOOTBLOCKSIZE(%ecx), %ecx
bswap %ecx
not %ecx
add $1, %ecx
cmp %ecx, %ebx
/* if bootblockstart >= addr (==we're still in the data area),
* jump back
*/
jbe walker
out:
mov $0, %eax
jmp *%esp
searchfile:
/* if filemagic isn't found, move forward 64 bytes */
add $CBFS_ALIGNMENT, %ebx
jmp check_for_exit
filemagic:
.ascii "LARCHIVE"