aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2022-01-29 17:01:28 +0100
committerJavier <dev.git@javispedro.com>2022-01-29 23:07:56 +0100
commit54b754ce040d5549d5c58428d2b9c095601e98dc (patch)
tree1b35f1dca54088b967fe5587ec43b98cf72e3825 /scripts
downloadvmusic-54b754ce040d5549d5c58428d2b9c095601e98dc.tar.gz
vmusic-54b754ce040d5549d5c58428d2b9c095601e98dc.zip
initial import
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.kmk186
-rwxr-xr-xscripts/enable.sh9
-rwxr-xr-xscripts/install.sh8
-rw-r--r--scripts/logenv.sh7
-rwxr-xr-xscripts/try.sh14
5 files changed, 224 insertions, 0 deletions
diff --git a/scripts/Makefile.kmk b/scripts/Makefile.kmk
new file mode 100644
index 0000000..6e788f4
--- /dev/null
+++ b/scripts/Makefile.kmk
@@ -0,0 +1,186 @@
+# $Id: Makefile.kmk $
+## @file
+# Sub-Makefile for the Skeleton Extension Pack Sample.
+#
+
+#
+# Copyright (C) 2010-2020 Oracle Corporation
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+
+SUB_DEPTH = VirtualBox
+include $(KBUILD_PATH)/subheader.kmk
+
+#
+# Extend the extension pack templates.
+#
+TEMPLATE_VBoxR3ExtPackVMusic = For the ring-3 context modules in the VMusic extension pack.
+TEMPLATE_VBoxR3ExtPackVMusic_EXTENDS = VBoxR3ExtPack
+TEMPLATE_VBoxR3ExtPackVMusic_INST = $(INST_EXTPACK)VMusic/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
+
+TEMPLATE_VBoxR0ExtPackVMusic = For the ring-0 context modules in the VMusic extension pack.
+TEMPLATE_VBoxR0ExtPackVMusic_EXTENDS = VBoxR0ExtPack
+TEMPLATE_VBoxR0ExtPackVMusic_INST = $(INST_EXTPACK)VMusic/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
+
+TEMPLATE_VBoxRcExtPackVMusic = For the raw-mode context modules in the VMusic extension pack.
+TEMPLATE_VBoxRcExtPackVMusic_EXTENDS = VBoxRcExtPack
+TEMPLATE_VBoxRcExtPackVMusic_INST = $(INST_EXTPACK)VMusic/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
+
+TEMPLATE_VBoxInsExtPackVMusic = For the install targets of an extension pack.
+TEMPLATE_VBoxInsExtPackVMusic_EXTENDS = VBoxR0ExtPack
+TEMPLATE_VBoxInsExtPackVMusic_INST = $(INST_EXTPACK)VMusic/
+
+#
+# Globals.
+#
+VMUSIC_NAME = VMusic
+VMUSIC_MANGLED_NAME = VMusic
+VBOX_PATH_EXTPACK_VMUSIC = $(PATH_STAGE)/$(INST_EXTPACK)VMusic
+
+
+#
+# VMusicMain - The module which the VirtualBox Main API talks to.
+#
+DLLS += VMusicMain
+VMusicMain_TEMPLATE = VBoxR3ExtPackVMusic
+VMusicMain_SOURCES = VMusicMain.cpp
+VMusicMain_DEFS =
+
+#
+# VMusicMainVM - The module in a VM which the VirtualBox Main API talks to.
+#
+DLLS += VMusicMainVM
+VMusicMainVM_TEMPLATE = VBoxR3ExtPackVMusic
+VMusicMainVM_SOURCES = VMusicMainVM.cpp
+VMusicMainVM_DEFS =
+
+#
+# Adlib device code.
+#
+DLLS += AdlibR3
+AdlibR3_TEMPLATE = VBoxR3ExtPackVMusic
+AdlibR3_SOURCES = Adlib.cpp opl3.c pcmalsa.cpp
+AdlibR3_LIBS = asound
+
+#
+# Adlib device code.
+#
+DLLS += Mpu401R3
+Mpu401R3_TEMPLATE = VBoxR3ExtPackVMusic
+Mpu401R3_SOURCES = Mpu401.cpp midialsa.cpp
+Mpu401R3_LIBS = asound
+
+#
+# Install the description.
+#
+INSTALLS += VMusicIns
+VMusicIns_TEMPLATE = VBoxInsExtPackVMusic
+VMusicIns_SOURCES = \
+ $(VMusicIns_0_OUTDIR)/ExtPack.xml
+$(call VBOX_EDIT_VERSION_RULE_FN,VMusicIns,ExtPack.xml)
+
+
+#
+# Packing.
+#
+PACKING += $(VBOX_PATH_PACKAGES)/$(VMUSIC_MANGLED_NAME)-$(VBOX_VERSION_STRING)r$(VBOX_SVN_REV).vbox-extpack
+
+ifndef VBOX_WITH_EXTPACK_OS_ARCHS
+ # At least pack in the binary for the current arch...
+ VBOX_WITH_EXTPACK_OS_ARCHS = $(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)
+endif
+
+# Build the file list. The macro takes 1=darwin.x86, 2=dist/VirtualBox.app/Contents/MacOS, 3=dylib
+VMUSIC_FILES_MACRO = \
+ $(PATH_OUT_BASE)/$(1)/$(KBUILD_TYPE)/$(2)/ExtensionPacks/$(VMUSIC_MANGLED_NAME)/$(1)/VMusicMain.$(3)=>$(1)/VMusicMain.$(3) \
+ $(PATH_OUT_BASE)/$(1)/$(KBUILD_TYPE)/$(2)/ExtensionPacks/$(VMUSIC_MANGLED_NAME)/$(1)/VMusicMainVM.$(3)=>$(1)/VMusicMainVM.$(3) \
+ $(PATH_OUT_BASE)/$(1)/$(KBUILD_TYPE)/$(2)/ExtensionPacks/$(VMUSIC_MANGLED_NAME)/$(1)/AdlibR3.$(3)=>$(1)/AdlibR3.$(3) \
+ $(PATH_OUT_BASE)/$(1)/$(KBUILD_TYPE)/$(2)/ExtensionPacks/$(VMUSIC_MANGLED_NAME)/$(1)/Mpu401R3.$(3)=>$(1)/Mpu401R3.$(3)
+
+VMUSIC_FILES := \
+ $(VBOX_PATH_EXTPACK_VMUSIC)/ExtPack.xml=>ExtPack.xml
+
+if1of (darwin.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,darwin.amd64,dist/VirtualBox.app/Contents/MacOS,dylib)
+endif
+if1of (darwin.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,darwin.x86,dist/VirtualBox.app/Contents/MacOS,dylib)
+endif
+if1of (freebsd.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,freebsd.amd64,bin,so)
+endif
+if1of (freebsd.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,freebsd.x86,bin,so)
+endif
+if1of (linux.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,linux.amd64,bin,so)
+endif
+if1of (linux.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,linux.x86,bin,so)
+endif
+if1of (os2.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,os2.x86,bin,so)
+endif
+if1of (solaris.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,solaris.amd64,bin,so)
+endif
+if1of (solaris.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,solaris.x86,bin,so)
+endif
+if1of (win.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,win.amd64,bin,dll)
+endif
+if1of (win.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+ VMUSIC_FILES += $(call VMUSIC_FILES_MACRO,win.x86,bin,dll)
+endif
+
+# Pack it all up using a temporary staging directory.
+$(VBOX_PATH_PACKAGES)/$(VMUSIC_MANGLED_NAME)-$(VBOX_VERSION_STRING)r$(VBOX_SVN_REV).vbox-extpack: \
+ $$(foreach file, $$(VMUSIC_FILES), $$(firstword $$(subst =>,$$(SP),$$(file)))) \
+ | $(VBOX_PATH_PACKAGES)/
+ $(RM) -f $(wildcard $(VBOX_PATH_PACKAGES)/$(VMUSIC_MANGLED_NAME)-*.vbox-extpack) \
+ $(VMusicIns_0_OUTDIR)/ExtPack.manifest \
+ $(VMusicIns_0_OUTDIR)/ExtPack.signature
+# Stage all the files
+ $(RM) -Rf $(VMusicIns_0_OUTDIR)/Stage/
+ $(foreach file, $(VMUSIC_FILES),\
+ $(NLTAB)$(MKDIR) -p $(dir $(lastword $(subst =>,$(SP)$(VMusicIns_0_OUTDIR)/Stage/,$(file)))) \
+ $(NLTAB)$(CP) $(subst =>,$(SP)$(VMusicIns_0_OUTDIR)/Stage/,$(file)) )
+# Create the manifest
+ $(VBOX_RTMANIFEST) \
+ --manifest $(VMusicIns_0_OUTDIR)/Stage/ExtPack.manifest \
+ --chdir $(VMusicIns_0_OUTDIR)/Stage/ \
+ $(foreach file, $(VMUSIC_FILES), $(lastword $(subst =>,$(SP),$(file))))
+ $(APPEND) $(VMusicIns_0_OUTDIR)/Stage/ExtPack.signature "todo"
+ $(CHMOD) a+r \
+ $(VMusicIns_0_OUTDIR)/Stage/ExtPack.manifest \
+ $(VMusicIns_0_OUTDIR)/Stage/ExtPack.signature
+# Tar it up.
+ tar --format=ustar -cvf - -C $(VMusicIns_0_OUTDIR)/Stage/ . | gzip -9c > $@
+# Clean up
+ $(RM) -Rf $(VMusicIns_0_OUTDIR)/Stage/
+
+BLDDIRS += $(VBOX_PATH_PACKAGES)/
+
+include $(FILE_KBUILD_SUB_FOOTER)
+
diff --git a/scripts/enable.sh b/scripts/enable.sh
new file mode 100755
index 0000000..24763bb
--- /dev/null
+++ b/scripts/enable.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -ex
+
+vm="$1"
+
+VBoxManage setextradata "$vm" VBoxInternal/Devices/adlib/0/Trusted 1
+VBoxManage setextradata "$vm" VBoxInternal/Devices/adlib/0/Config/MirrorPort "0x220"
+VBoxManage setextradata "$vm" VBoxInternal/Devices/mpu401/0/Trusted 1
diff --git a/scripts/install.sh b/scripts/install.sh
new file mode 100755
index 0000000..30e38b3
--- /dev/null
+++ b/scripts/install.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set -e
+
+src_path=out/linux.amd64
+tgt_path=/usr/lib/virtualbox/ExtensionPacks/VMusic/linux.amd64
+
+install -m 0644 -v $src_path/*.so "$tgt_path"
diff --git a/scripts/logenv.sh b/scripts/logenv.sh
new file mode 100644
index 0000000..054acee
--- /dev/null
+++ b/scripts/logenv.sh
@@ -0,0 +1,7 @@
+export VBOX_LOG_DEST="nofile stderr"
+export VBOX_LOG_FLAGS="thread time"
+export VBOX_LOG="+dev_sb16.e.l.f.l3"
+export VBOX_RELEASE_LOG_DEST="nofile stderr"
+export VBOX_RELEASE_LOG="-all +dev_sb16.e.l.f"
+
+#export VBOX_LOG=""
diff --git a/scripts/try.sh b/scripts/try.sh
new file mode 100755
index 0000000..0f88c1d
--- /dev/null
+++ b/scripts/try.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+
+vm="$1"
+
+if [[ -z "$vm" ]]; then
+ echo "Usage: $0 <VM>"
+ exit 1
+fi
+
+source scripts/logenv.sh
+
+exec /usr/lib/virtualbox/VirtualBoxVM --startvm "$vm"