]>
git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/QemuVideoDxe/VbeShim.sh
4 # Shell script to assemble and dump the fake Int10h handler from NASM source to
7 # Copyright (C) 2014, Red Hat, Inc.
8 # Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
10 # SPDX-License-Identifier: BSD-2-Clause-Patent
16 STEM
=$
(dirname -- "$0")/$
(basename -- "$0" .sh
)
19 # Install exit handler -- remove temporary files.
23 rm -f -- "$STEM".bin
"$STEM".disasm
"$STEM".offsets
"$STEM".insns \
26 trap exit_handler EXIT
29 # Assemble the source file.
31 nasm
-o "$STEM".bin
-- "$STEM".asm
34 # Disassemble it, in order to get a binary dump associated with the source.
35 # (ndisasm doesn't recognize the "--" end-of-options delimiter.)
37 ndisasm
"$STEM".bin
>"$STEM".disasm
40 # Create three files, each with one column of the disassembly.
42 # The first column contains the offsets, and it starts the comment.
44 cut
-c 1-8 -- "$STEM".disasm \
45 |
sed -e 's,^, /* ,' >"$STEM".offsets
48 # The second column contains the assembly-language instructions, and it closes
49 # the comment. We first pad it to 30 characters.
51 cut
-c 29- -- "$STEM".disasm \
53 -e 's,^\(.\{30\}\).*$,\1 */,' >"$STEM".insns
56 # The third column contains the bytes corresponding to the instruction,
57 # represented as C integer constants. First strip trailing whitespace from the
58 # middle column of the input disassembly, then process pairs of nibbles.
60 cut
-c 11-28 -- "$STEM".disasm \
61 |
sed -e 's, \+$,,' -e 's/\(..\)/ 0x\1,/g' >"$STEM".bytes
64 # Write the output file, recombining the columns. The output should have CRLF
69 printf '// THIS FILE WAS GENERATED BY "%s". DO NOT EDIT.\n' \
72 printf '#ifndef _VBE_SHIM_H_\n'
73 printf '#define _VBE_SHIM_H_\n'
74 printf 'STATIC CONST UINT8 mVbeShim[] = {\n'
75 paste -d ' ' -- "$STEM".offsets
"$STEM".insns
"$STEM".bytes