VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Bhyve/BhyveRfbDxe/VbeShim.sh@ 109019

Last change on this file since 109019 was 89983, checked in by vboxsync, 4 years ago

Devices/EFI: Merge edk-stable202105 and openssl 1.1.1j and make it build, bugref:4643

  • Property svn:eol-style set to LF
File size: 2.1 KB
Line 
1#!/bin/sh
2###
3# @file
4# Shell script to assemble and dump the fake Int10h handler from NASM source to
5# a C array.
6#
7# Copyright (C) 2020, Rebecca Cran <[email protected]>
8# Copyright (C) 2014, Red Hat, Inc.
9# Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
10#
11# SPDX-License-Identifier: BSD-2-Clause-Patent
12#
13###
14
15set -e -u
16
17STEM=$(dirname -- "$0")/$(basename -- "$0" .sh)
18
19#
20# Install exit handler -- remove temporary files.
21#
22exit_handler()
23{
24 rm -f -- "$STEM".bin "$STEM".disasm "$STEM".offsets "$STEM".insns \
25 "$STEM".bytes
26}
27trap exit_handler EXIT
28
29#
30# Assemble the source file.
31#
32nasm -o "$STEM".bin -- "$STEM".asm
33
34#
35# Disassemble it, in order to get a binary dump associated with the source.
36# (ndisasm doesn't recognize the "--" end-of-options delimiter.)
37#
38ndisasm "$STEM".bin >"$STEM".disasm
39
40#
41# Create three files, each with one column of the disassembly.
42#
43# The first column contains the offsets, and it starts the comment.
44#
45cut -c 1-8 -- "$STEM".disasm \
46| sed -e 's,^, /* ,' >"$STEM".offsets
47
48#
49# The second column contains the assembly-language instructions, and it closes
50# the comment. We first pad it to 30 characters.
51#
52cut -c 29- -- "$STEM".disasm \
53| sed -e 's,$, ,' \
54 -e 's,^\(.\{30\}\).*$,\1 */,' >"$STEM".insns
55
56#
57# The third column contains the bytes corresponding to the instruction,
58# represented as C integer constants. First strip trailing whitespace from the
59# middle column of the input disassembly, then process pairs of nibbles.
60#
61cut -c 11-28 -- "$STEM".disasm \
62| sed -e 's, \+$,,' -e 's/\(..\)/ 0x\1,/g' | sed 's/0x ,//g' >"$STEM".bytes
63
64#
65# Write the output file, recombining the columns. The output should have CRLF
66# line endings.
67#
68{
69 printf '//\n'
70 printf '// THIS FILE WAS GENERATED BY "%s". DO NOT EDIT.\n' \
71 "$(basename -- "$0")"
72 printf '//\n'
73 printf '#ifndef _VBE_SHIM_H_\n'
74 printf '#define _VBE_SHIM_H_\n'
75 printf 'STATIC CONST UINT8 mVbeShim[] = {\n'
76 paste -d ' ' -- "$STEM".offsets "$STEM".insns "$STEM".bytes
77 printf '};\n'
78 printf '#endif\n'
79} \
80| unix2dos >"$STEM".h
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette