]>
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 # This program and the accompanying materials are licensed and made available
11 # under the terms and conditions of the BSD License which accompanies this
12 # distribution. The full text of the license may be found at
13 # http://opensource.org/licenses/bsd-license.php
15 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
16 # WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 STEM
=$
(dirname -- "$0")/$
(basename -- "$0" .sh
)
25 # Install exit handler -- remove temporary files.
29 rm -f -- "$STEM".bin
"$STEM".disasm
"$STEM".offsets
"$STEM".insns \
32 trap exit_handler EXIT
35 # Assemble the source file.
37 nasm
-o "$STEM".bin
-- "$STEM".asm
40 # Disassemble it, in order to get a binary dump associated with the source.
41 # (ndisasm doesn't recognize the "--" end-of-options delimiter.)
43 ndisasm
"$STEM".bin
>"$STEM".disasm
46 # Create three files, each with one column of the disassembly.
48 # The first column contains the offsets, and it starts the comment.
50 cut
-c 1-8 -- "$STEM".disasm \
51 |
sed -e 's,^, /* ,' >"$STEM".offsets
54 # The second column contains the assembly-language instructions, and it closes
55 # the comment. We first pad it to 30 characters.
57 cut
-c 29- -- "$STEM".disasm \
59 -e 's,^\(.\{30\}\).*$,\1 */,' >"$STEM".insns
62 # The third column contains the bytes corresponding to the instruction,
63 # represented as C integer constants. First strip trailing whitespace from the
64 # middle column of the input disassembly, then process pairs of nibbles.
66 cut
-c 11-28 -- "$STEM".disasm \
67 |
sed -e 's, \+$,,' -e 's/\(..\)/ 0x\1,/g' >"$STEM".bytes
70 # Write the output file, recombining the columns. The output should have CRLF
75 printf '// THIS FILE WAS GENERATED BY "%s". DO NOT EDIT.\n' \
78 printf '#ifndef _VBE_SHIM_H_\n'
79 printf '#define _VBE_SHIM_H_\n'
80 printf 'STATIC CONST UINT8 mVbeShim[] = {\n'
81 paste -d ' ' -- "$STEM".offsets
"$STEM".insns
"$STEM".bytes