Skip to content

Commit d68cf74

Browse files
authored
Merge pull request #422 from citrus-it/bhyve
Add bhyve firmware and packages required to build.
2 parents 2386883 + 4129c8f commit d68cf74

File tree

10 files changed

+411
-4
lines changed

10 files changed

+411
-4
lines changed

build/acpica/build.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/bash
2+
#
3+
# {{{ CDDL HEADER
4+
#
5+
# This file and its contents are supplied under the terms of the
6+
# Common Development and Distribution License ("CDDL"), version 1.0.
7+
# You may only use this file in accordance with the terms of version
8+
# 1.0 of the CDDL.
9+
#
10+
# A full copy of the text of the CDDL should have accompanied this
11+
# source. A copy of the CDDL is also available via the Internet at
12+
# http://www.illumos.org/license/CDDL.
13+
# }}}
14+
15+
# Copyright 2017 OmniOS Community Edition (OmniOSce) Association.
16+
17+
#
18+
# Load support functions
19+
. ../../lib/functions.sh
20+
21+
PROG=acpica-unix
22+
VER=20171110
23+
VERHUMAN=$VER
24+
PKG=developer/acpi/compiler
25+
SUMMARY="ACPI Component Architecture compiler"
26+
DESC="$SUMMARY"
27+
28+
BUILDARCH=32
29+
30+
extract_licence() {
31+
# Horrible - need to extract the licence from a source file.
32+
# We choose the BSD licence
33+
logmsg "-- extracting licence"
34+
sed -n < $TMPDIR/$BUILDDIR/source/compiler/aslmain.c \
35+
> $TMPDIR/$BUILDDIR/LICENCE '
36+
/Redistribution and use in source and binary/,/DAMAGE/p
37+
'
38+
}
39+
40+
# No configure
41+
configure32() {
42+
export CC=gcc
43+
}
44+
45+
make_prog32() {
46+
# Build expects m4 to be the GNU version
47+
PATH=/usr/gnu/bin:$PATH logcmd $MAKE CC=$CC iasl \
48+
|| logerr "--- Build failed"
49+
}
50+
51+
52+
init
53+
download_source acpica $PROG $VER
54+
cp $SRCDIR/files/acsolaris.h $TMPDIR/$BUILDDIR/source/include/platform
55+
patch_source
56+
prep_build
57+
build
58+
extract_licence
59+
make_package
60+
clean_up
61+
62+
# Vim hints
63+
# vim:ts=4:sw=4:et:fdm=marker

build/acpica/files/acsolaris.h

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* CDDL HEADER START
3+
*
4+
* The contents of this file are subject to the terms of the
5+
* Common Development and Distribution License (the "License").
6+
* You may not use this file except in compliance with the License.
7+
*
8+
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9+
* or http://www.opensolaris.org/os/licensing.
10+
* See the License for the specific language governing permissions
11+
* and limitations under the License.
12+
*
13+
* When distributing Covered Code, include this CDDL HEADER in each
14+
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15+
* If applicable, add the following below this CDDL HEADER, with the
16+
* fields enclosed by brackets "[]" replaced with your own identifying
17+
* information: Portions Copyright [yyyy] [name of copyright owner]
18+
*
19+
* CDDL HEADER END
20+
*/
21+
/*
22+
* Copyright 2017 OmniOS Community Edition (OmniOSce) Association.
23+
* Copyright 2016 Joyent, Inc.
24+
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25+
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26+
* Use is subject to license terms.
27+
*/
28+
29+
#ifndef _ACSOLARIS_H_
30+
#define _ACSOLARIS_H_
31+
32+
#ifdef __cplusplus
33+
extern "C" {
34+
#endif
35+
36+
#define __EXTENSIONS__
37+
38+
#include <sys/types.h>
39+
#include <sys/sunddi.h>
40+
#include <sys/varargs.h>
41+
#include <sys/cpu.h>
42+
#include <sys/thread.h>
43+
44+
//#include <sys/ctype.h>
45+
#include <ctype.h>
46+
#include <strings.h>
47+
#include <stdlib.h>
48+
#include <sys/signal.h>
49+
#include <sys/ucontext.h>
50+
51+
/* Function name used for debug output. */
52+
#define ACPI_GET_FUNCTION_NAME __func__
53+
54+
uint32_t __acpi_acquire_global_lock(void *);
55+
uint32_t __acpi_release_global_lock(void *);
56+
void __acpi_wbinvd(void);
57+
uint32_t acpi_strtoul(const char *, char **, int);
58+
59+
#ifdef _ILP32
60+
#define ACPI_MACHINE_WIDTH 32
61+
#elif defined(_LP64)
62+
#define ACPI_MACHINE_WIDTH 64
63+
#endif
64+
65+
#define COMPILER_DEPENDENT_INT64 int64_t
66+
#define COMPILER_DEPENDENT_UINT64 uint64_t
67+
68+
#define ACPI_CAST_PTHREAD_T(pthread) ((ACPI_THREAD_ID) (pthread))
69+
70+
#define ACPI_PRINTF_LIKE_FUNC
71+
//#define ACPI_UNUSED_VAR
72+
#define ACPI_USE_NATIVE_DIVIDE
73+
#define ACPI_FLUSH_CPU_CACHE() (__acpi_wbinvd())
74+
75+
//#define ACPI_DISASSEMBLER
76+
#define ACPI_PACKED_POINTERS_NOT_SUPPORTED
77+
78+
/*
79+
* Calling conventions:
80+
*
81+
* ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
82+
* ACPI_EXTERNAL_XFACE - External ACPI interfaces
83+
* ACPI_INTERNAL_XFACE - Internal ACPI interfaces
84+
* ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
85+
*/
86+
#define ACPI_SYSTEM_XFACE
87+
#define ACPI_EXTERNAL_XFACE
88+
#define ACPI_INTERNAL_XFACE
89+
#define ACPI_INTERNAL_VAR_XFACE
90+
91+
/*
92+
* The ACPI headers shipped from Intel define a bunch of functions which are
93+
* already provided by the kernel. The variables below prevent those from
94+
* being loaded as part of accommon.h.
95+
*/
96+
#define ACPI_USE_SYSTEM_CLIBRARY
97+
#define ACPI_USE_STANDARD_HEADERS
98+
99+
#define ACPI_ASM_MACROS
100+
#define BREAKPOINT3
101+
#define ACPI_DISABLE_IRQS() cli()
102+
#define ACPI_ENABLE_IRQS() sti()
103+
#define ACPI_ACQUIRE_GLOBAL_LOCK(Facs, Acq) \
104+
((Acq) = __acpi_acquire_global_lock(Facs))
105+
106+
#define ACPI_RELEASE_GLOBAL_LOCK(Facs, Acq) \
107+
((Acq) = __acpi_release_global_lock(Facs))
108+
109+
#ifdef __cplusplus
110+
}
111+
#endif
112+
113+
#endif /* _ACSOLARIS_H_ */

build/acpica/local.mog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file and its contents are supplied under the terms of the
2+
# Common Development and Distribution License ("CDDL"), version 1.0.
3+
# You may only use this file in accordance with the terms of version
4+
# 1.0 of the CDDL.
5+
#
6+
# A full copy of the text of the CDDL should have accompanied this
7+
# source. A copy of the CDDL is also available via the Internet at
8+
# http://www.illumos.org/license/CDDL.
9+
10+
# Copyright 2017 OmniOS Community Edition (OmniOSce) Association.
11+
12+
# Move binary to /usr/sbin
13+
<transform file -> edit path usr/bin usr/sbin>
14+
15+
license LICENCE license=BSD
16+

build/bhyve-fw/build.sh

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#!/usr/bin/bash
2+
#
3+
# {{{ CDDL HEADER
4+
#
5+
# This file and its contents are supplied under the terms of the
6+
# Common Development and Distribution License ("CDDL"), version 1.0.
7+
# You may only use this file in accordance with the terms of version
8+
# 1.0 of the CDDL.
9+
#
10+
# A full copy of the text of the CDDL should have accompanied this
11+
# source. A copy of the CDDL is also available via the Internet at
12+
# http://www.illumos.org/license/CDDL.
13+
# }}}
14+
15+
# Copyright 2017 OmniOS Community Edition (OmniOSce) Association.
16+
17+
#
18+
# Load support functions
19+
. ../../lib/functions.sh
20+
21+
BUILD_DEPENDS_IPS="
22+
developer/acpi/compiler
23+
developer/nasm
24+
"
25+
26+
PROG=uefi-edk2
27+
PKG=system/bhyve/firmware
28+
VER=20160525
29+
VERHUMAN=$VER
30+
SUMMARY="UEFI-EDK2(+CSM) firmware for bhyve"
31+
DESC="$SUMMARY"
32+
33+
# Respect environmental overrides for these to ease development.
34+
: ${PKG_SOURCE_REPO:=https://github.com/omniosorg/$PROG}
35+
: ${PKG_SOURCE_BRANCH:=bhyve/UDK2014.SP1}
36+
37+
# Extend VER so that the temporary build directory is branch specific.
38+
# Branches can include '/' so remove them.
39+
VER+="-${PKG_SOURCE_BRANCH//\//_}"
40+
41+
clone_source(){
42+
logmsg "$PROG -> $TMPDIR/$BUILDDIR/$PROG"
43+
logcmd mkdir -p $TMPDIR/$BUILDDIR
44+
pushd $TMPDIR/$BUILDDIR > /dev/null
45+
if [ ! -d $PROG ]; then
46+
if [ -n "$EDK2_CLONE" -a -d "$EDK2_CLONE" ]; then
47+
logmsg "-- pulling $PROG from local clone"
48+
logcmd rsync -ar $EDK2_CLONE/ $PROG/
49+
else
50+
logmsg "-- cloning $PKG_SOURCE_REPO"
51+
logcmd $GIT clone --depth 1 -b $PKG_SOURCE_BRANCH \
52+
$PKG_SOURCE_REPO $PROG
53+
fi
54+
fi
55+
if [ -z "$EDK2_CLONE" ]; then
56+
logcmd $GIT -C $PROG pull || logerr "--- Failed to pull repo"
57+
fi
58+
popd > /dev/null
59+
}
60+
61+
build() {
62+
pushd $TMPDIR/$BUILDDIR/$PROG >/dev/null || logerr "--- chdir failed"
63+
64+
export GCCPATH=/opt/gcc-4.4.4
65+
66+
MAKE_ARGS="
67+
AS=/usr/bin/gas
68+
AR=/usr/bin/gar
69+
LD=/usr/bin/gld
70+
OBJCOPY=/usr/bin/gobjcopy
71+
CC=${GCCPATH}/bin/gcc
72+
CXX=${GCCPATH}/bin/g++
73+
"
74+
75+
logmsg "-- Cleaning source tree"
76+
77+
logcmd gmake $MAKE_ARGS ARCH=X64 -C BaseTools clean
78+
rm -f Build Conf/{target,build_rule,tools_def}.txt Conf/.cache 2>/dev/null
79+
80+
logmsg "-- Building tools"
81+
82+
# First build the tools. The code isn't able to detect the build
83+
# architecture - it doesn't expect `uname -m` to return `i86pc`
84+
logcmd gmake $MAKE_ARGS ARCH=X64 -C BaseTools \
85+
|| logerr "--- BaseTools build failed"
86+
87+
BUILD_ARGS="-DDEBUG_ON_SERIAL_PORT=TRUE -DFD_SIZE_2MB -DCSM_ENABLE=TRUE"
88+
89+
(
90+
export OOGCC_BIN=$GCCPATH/bin/
91+
export IASL_PREFIX=/usr/sbin/
92+
export NASM_PREFIX=/usr/bin/i386/
93+
source edksetup.sh
94+
95+
logmsg "-- Building compatibility support module (CSM)"
96+
logcmd gmake $MAKE_ARGS -C BhyvePkg/Csm/BhyveCsm16/ \
97+
|| logerr "--- CSM build failed"
98+
99+
for mode in RELEASE DEBUG; do
100+
logmsg "-- Building $mode firmware"
101+
logcmd `which build` \
102+
-t OOGCC -a X64 -b $mode \
103+
-p BhyvePkg/BhyvePkgX64.dsc \
104+
$BUILD_ARGS || logerr "--- $mode build failed"
105+
done
106+
) || logerr "--- Build failed"
107+
108+
popd >/dev/null
109+
}
110+
111+
install() {
112+
pushd $TMPDIR/$BUILDDIR/$PROG >/dev/null || logerr "--- chdir failed"
113+
logcmd mkdir -p $DESTDIR/usr/share/bhyve/firmware
114+
cp OvmfPkg/License.txt $DESTDIR/LICENCE
115+
for mode in RELEASE DEBUG; do
116+
logcmd cp Build/BhyveX64/${mode}_OOGCC/FV/BHYVE.fd \
117+
$DESTDIR/usr/share/bhyve/firmware/BHYVE_$mode.fd
118+
done
119+
popd >/dev/null
120+
}
121+
122+
init
123+
prep_build
124+
clone_source
125+
build
126+
install
127+
# Reset version for package creation
128+
VER=$VERHUMAN
129+
make_package
130+
clean_up
131+
132+
# Vim hints
133+
# vim:ts=4:sw=4:et:fdm=marker

build/bhyve-fw/local.mog

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file and its contents are supplied under the terms of the
2+
# Common Development and Distribution License ("CDDL"), version 1.0.
3+
# You may only use this file in accordance with the terms of version
4+
# 1.0 of the CDDL.
5+
#
6+
# A full copy of the text of the CDDL should have accompanied this
7+
# source. A copy of the CDDL is also available via the Internet at
8+
# http://www.illumos.org/license/CDDL.
9+
10+
# Copyright 2017 OmniOS Community Edition (OmniOSce) Association.
11+
12+
license LICENCE license=Intel
13+
<transform file path=LICENCE -> drop>
14+
15+
<transform file -> set mode 0755>
16+
link path=usr/share/bhyve/firmware/BHYVE.fd target=BHYVE_RELEASE.fd
17+

build/nasm/build.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/bash
2+
#
3+
# {{{ CDDL HEADER
4+
#
5+
# This file and its contents are supplied under the terms of the
6+
# Common Development and Distribution License ("CDDL"), version 1.0.
7+
# You may only use this file in accordance with the terms of version
8+
# 1.0 of the CDDL.
9+
#
10+
# A full copy of the text of the CDDL should have accompanied this
11+
# source. A copy of the CDDL is also available via the Internet at
12+
# http://www.illumos.org/license/CDDL.
13+
# }}}
14+
15+
# Copyright 2017 OmniOS Community Edition (OmniOSce) Association.
16+
17+
#
18+
# Load support functions
19+
. ../../lib/functions.sh
20+
21+
PROG=nasm
22+
VER=2.13.02
23+
VERHUMAN=$VER
24+
PKG=developer/nasm
25+
SUMMARY="The Netwide Assembler"
26+
DESC="$SUMMARY"
27+
28+
BUILDARCH=32
29+
30+
# Nasm uses INSTALLROOT instead of the more standard DESTDIR
31+
make_install() {
32+
logmsg "--- make install"
33+
logcmd $MAKE INSTALLROOT=${DESTDIR} install || \
34+
logerr "--- Make install failed"
35+
}
36+
37+
init
38+
download_source $PROG $PROG $VER
39+
patch_source
40+
prep_build
41+
build
42+
make_isa_stub
43+
make_package
44+
clean_up
45+
46+
# Vim hints
47+
# vim:ts=4:sw=4:et:fdm=marker

0 commit comments

Comments
 (0)