re-organize the current files into bmc directory

More daemons are being developed in phosphor-bmc-code-mgmt repo as part
of https://github.com/openbmc/docs/blob/master/designs/code-update.md.
For this move the current files for BMC code update into bmc
subdirectory for a better code organization.

Tested:
meson build passes.

Change-Id: I7b5575bcfbe54ac00aa803f94b5d8f6d69ce2f3f
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/activation.cpp b/bmc/activation.cpp
similarity index 100%
rename from activation.cpp
rename to bmc/activation.cpp
diff --git a/activation.hpp b/bmc/activation.hpp
similarity index 100%
rename from activation.hpp
rename to bmc/activation.hpp
diff --git a/detect-slot-aspeed b/bmc/detect-slot-aspeed
similarity index 100%
rename from detect-slot-aspeed
rename to bmc/detect-slot-aspeed
diff --git a/download_manager.cpp b/bmc/download_manager.cpp
similarity index 100%
rename from download_manager.cpp
rename to bmc/download_manager.cpp
diff --git a/download_manager.hpp b/bmc/download_manager.hpp
similarity index 100%
rename from download_manager.hpp
rename to bmc/download_manager.hpp
diff --git a/download_manager_main.cpp b/bmc/download_manager_main.cpp
similarity index 100%
rename from download_manager_main.cpp
rename to bmc/download_manager_main.cpp
diff --git a/flash.hpp b/bmc/flash.hpp
similarity index 100%
rename from flash.hpp
rename to bmc/flash.hpp
diff --git a/force-reboot.service.in b/bmc/force-reboot.service.in
similarity index 100%
rename from force-reboot.service.in
rename to bmc/force-reboot.service.in
diff --git a/gen-bios-tar b/bmc/gen-bios-tar
similarity index 100%
rename from gen-bios-tar
rename to bmc/gen-bios-tar
diff --git a/image_manager.cpp b/bmc/image_manager.cpp
similarity index 100%
rename from image_manager.cpp
rename to bmc/image_manager.cpp
diff --git a/image_manager.hpp b/bmc/image_manager.hpp
similarity index 100%
rename from image_manager.hpp
rename to bmc/image_manager.hpp
diff --git a/image_manager_main.cpp b/bmc/image_manager_main.cpp
similarity index 100%
rename from image_manager_main.cpp
rename to bmc/image_manager_main.cpp
diff --git a/image_verify.cpp b/bmc/image_verify.cpp
similarity index 100%
rename from image_verify.cpp
rename to bmc/image_verify.cpp
diff --git a/image_verify.hpp b/bmc/image_verify.hpp
similarity index 100%
rename from image_verify.hpp
rename to bmc/image_verify.hpp
diff --git a/images.cpp b/bmc/images.cpp
similarity index 100%
rename from images.cpp
rename to bmc/images.cpp
diff --git a/images.hpp b/bmc/images.hpp
similarity index 100%
rename from images.hpp
rename to bmc/images.hpp
diff --git a/item_updater.cpp b/bmc/item_updater.cpp
similarity index 100%
rename from item_updater.cpp
rename to bmc/item_updater.cpp
diff --git a/item_updater.hpp b/bmc/item_updater.hpp
similarity index 100%
rename from item_updater.hpp
rename to bmc/item_updater.hpp
diff --git a/item_updater_helper.hpp b/bmc/item_updater_helper.hpp
similarity index 100%
rename from item_updater_helper.hpp
rename to bmc/item_updater_helper.hpp
diff --git a/item_updater_main.cpp b/bmc/item_updater_main.cpp
similarity index 100%
rename from item_updater_main.cpp
rename to bmc/item_updater_main.cpp
diff --git a/bmc/meson.build b/bmc/meson.build
new file mode 100644
index 0000000..84de1c5
--- /dev/null
+++ b/bmc/meson.build
@@ -0,0 +1,288 @@
+conf = configuration_data()
+
+# DBus information
+conf.set_quoted('BMC_INVENTORY_INTERFACE', 'xyz.openbmc_project.Inventory.Item.Bmc')
+conf.set_quoted('BUSNAME_UPDATER', 'xyz.openbmc_project.Software.BMC.Updater')
+conf.set_quoted('DOWNLOAD_BUSNAME', 'xyz.openbmc_project.Software.Download')
+conf.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath')
+conf.set_quoted('INVENTORY_PATH', '/xyz/openbmc_project/inventory/')
+conf.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper')
+conf.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper')
+conf.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper')
+conf.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software')
+conf.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1')
+conf.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1')
+conf.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager')
+conf.set_quoted('VERSION_BUSNAME', 'xyz.openbmc_project.Software.Version')
+conf.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version')
+conf.set_quoted('EXTENDED_VERSION_IFACE', 'xyz.openbmc_project.Software.ExtendedVersion')
+conf.set_quoted('COMPATIBLE_IFACE', 'xyz.openbmc_project.Inventory.Decorator.Compatible')
+
+# Names of the forward and reverse associations
+conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory')
+conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation')
+conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active')
+conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version')
+conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional')
+conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version')
+conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable')
+conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version')
+
+# Filesystem files and directories
+# The prefix path for the versioned read-only bmc partitions
+conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-')
+# The name of the BMC table of contents file
+conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release')
+# The dir where activation data is stored in files
+conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/')
+
+# Supported BMC layout types
+conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static'))
+conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi'))
+conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
+
+# Configurable features
+conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').allowed())
+conf.set('WANT_SIGNATURE_VERIFY', get_option('verify-signature').allowed())
+conf.set('START_UPDATE_DBUS_INTEFACE', get_option('software-update-dbus-interface').allowed())
+
+# Configurable variables
+conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
+conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
+conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
+conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
+conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
+optional_array = get_option('optional-images')
+optional_images = ''
+foreach optiona_image : optional_array
+    optional_images = ' '.join([optional_images, optiona_image])
+endforeach
+conf.set_quoted('OPTIONAL_IMAGES', optional_images)
+conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
+conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
+conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
+conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
+conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
+conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
+conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
+
+if get_option('host-bios-upgrade').allowed()
+    conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path'))
+endif
+
+if get_option('bmc-static-dual-image').allowed()
+  conf.set('BMC_STATIC_DUAL_IMAGE', get_option('bmc-static-dual-image').allowed())
+  conf.set_quoted('ALT_ROFS_DIR', get_option('alt-rofs-dir'))
+  conf.set_quoted('ALT_RWFS', get_option('alt-rwfs-dir'))
+else
+  conf.set_quoted('ALT_RWFS', '/media/alt/var/persist')
+endif
+
+configure_file(output: 'config.h', configuration: conf)
+
+unit_files = [
+    'obmc-flash-bmc-setenv@.service.in',
+    'reboot-guard-disable.service.in',
+    'reboot-guard-enable.service.in',
+    'force-reboot.service.in',
+    'usr-local.mount.in',
+    'xyz.openbmc_project.Software.Download.service.in',
+    'xyz.openbmc_project.Software.Sync.service.in'
+]
+
+image_updater_sources = files(
+    'activation.cpp',
+    'images.cpp',
+    'item_updater.cpp',
+    'serialize.cpp',
+    'version.cpp',
+    'utils.cpp',
+    'msl_verify.cpp',
+    'update_manager.cpp'
+)
+
+if get_option('bmc-layout').contains('static')
+    image_updater_sources += files(
+        'static/flash.cpp',
+        'static/item_updater_helper.cpp'
+    )
+elif get_option('bmc-layout').contains('ubi')
+    image_updater_sources += files(
+        'ubi/flash.cpp',
+        'ubi/item_updater_helper.cpp'
+    )
+
+    unit_files += [
+        'ubi/obmc-flash-bmc-cleanup.service.in',
+        'ubi/obmc-flash-bmc-mirroruboot.service.in',
+        'ubi/obmc-flash-bmc-ubiremount.service.in',
+        'ubi/obmc-flash-bmc-ubiro@.service.in',
+        'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
+        'ubi/obmc-flash-bmc-ubirw.service.in',
+        'ubi/obmc-flash-bmc-ubirw-remove.service.in',
+        'ubi/obmc-flash-bmc-updateubootvars@.service.in'
+    ]
+elif get_option('bmc-layout').contains('mmc')
+    image_updater_sources += files(
+        'mmc/flash.cpp',
+        'mmc/item_updater_helper.cpp'
+    )
+
+    unit_files += [
+        'mmc/obmc-flash-mmc@.service.in',
+        'mmc/obmc-flash-mmc-mount.service.in',
+        'mmc/obmc-flash-mmc-remove@.service.in',
+        'mmc/obmc-flash-mmc-setprimary@.service.in',
+        'mmc/obmc-flash-mmc-umount.service.in',
+        'mmc/obmc-flash-mmc-mirroruboot.service.in',
+    ]
+endif
+
+if get_option('host-bios-upgrade').allowed()
+    unit_files += 'obmc-flash-host-bios@.service.in'
+endif
+
+if get_option('bmc-static-dual-image').allowed()
+    unit_files += [
+        'static/obmc-flash-bmc-alt@.service.in',
+        'static/obmc-flash-bmc-static-mount-alt.service.in',
+        'static/obmc-flash-bmc-prepare-for-sync.service.in',
+    ]
+endif
+
+if get_option('sync-bmc-files').allowed()
+    executable(
+        'phosphor-sync-software-manager',
+        'sync_manager.cpp',
+        'sync_manager_main.cpp',
+        'sync_watch.cpp',
+        dependencies: deps,
+        install: true
+    )
+
+    install_data('synclist',
+        install_dir:  get_option('sysconfdir')
+    )
+
+    install_data('sync-once.sh',
+        install_mode: 'rwxr-xr-x',
+        install_dir: get_option('bindir')
+    )
+endif
+
+if (get_option('verify-signature').allowed())
+    image_updater_sources += files(
+        'utils.cpp',
+        'image_verify.cpp',
+        'openssl_alloc.cpp'
+    )
+endif
+
+executable(
+    'phosphor-download-manager',
+    'download_manager.cpp',
+    'download_manager_main.cpp',
+    dependencies: deps,
+    install: true
+)
+
+software_common_sources = files(
+    'software_utils.cpp',
+)
+
+if get_option('software-update-dbus-interface').allowed()
+    executable(
+        'phosphor-software-manager',
+        'software_manager.cpp',
+        image_updater_sources,
+        software_common_sources,
+        dependencies: [deps, ssl],
+        install: true
+    )
+    unit_files += [
+        'xyz.openbmc_project.Software.Manager.service.in'
+    ]
+else
+   unit_files += [
+        'xyz.openbmc_project.Software.BMC.Updater.service.in',
+        'xyz.openbmc_project.Software.Version.service.in'
+   ]
+endif
+
+executable(
+    'phosphor-image-updater',
+    image_updater_sources,
+    software_common_sources,
+    'item_updater_main.cpp',
+    dependencies: [deps, ssl, boost_dep],
+    install: true
+)
+
+executable(
+    'phosphor-version-software-manager',
+    'image_manager.cpp',
+    'image_manager_main.cpp',
+    'version.cpp',
+    'watch.cpp',
+    software_common_sources,
+    dependencies: [deps, ssl],
+    install: true
+)
+
+install_data('obmc-flash-bmc',
+    install_mode: 'rwxr-xr-x',
+    install_dir: get_option('bindir')
+)
+
+install_data('detect-slot-aspeed',
+    install_mode: 'rwxr-xr-x',
+    install_dir: get_option('bindir')
+)
+
+install_data('reset-cs0-aspeed',
+    install_mode: 'rwxr-xr-x',
+    install_dir: get_option('bindir')
+)
+
+install_data('software.conf',
+    install_dir: '/usr/lib/tmpfiles.d/'
+)
+
+foreach u : unit_files
+    configure_file(
+        input: u,
+        output: '@BASENAME@',
+        configuration: conf,
+        install: true,
+        install_dir: systemd_system_unit_dir,
+    )
+endforeach
+
+# If test coverage of source files within the root directory are wanted,
+# need to define and build the tests from here
+build_tests = get_option('tests')
+if not build_tests.disabled()
+    gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
+    include_srcs = declare_dependency(sources: [
+        'utils.cpp',
+        'image_verify.cpp',
+        'images.cpp',
+        'version.cpp']
+    )
+
+    test('utest',
+        executable(
+            'utest',
+            './test/utest.cpp',
+            dependencies: [deps, gtest, include_srcs, ssl]
+        )
+)
+endif
+
+if get_option('usb-code-update').allowed()
+    subdir('usb')
+endif
+
+if get_option('side-switch-on-boot').allowed()
+    subdir('side-switch')
+endif
diff --git a/mmc/flash.cpp b/bmc/mmc/flash.cpp
similarity index 100%
rename from mmc/flash.cpp
rename to bmc/mmc/flash.cpp
diff --git a/mmc/item_updater_helper.cpp b/bmc/mmc/item_updater_helper.cpp
similarity index 100%
rename from mmc/item_updater_helper.cpp
rename to bmc/mmc/item_updater_helper.cpp
diff --git a/mmc/obmc-flash-mmc-mirroruboot.service.in b/bmc/mmc/obmc-flash-mmc-mirroruboot.service.in
similarity index 100%
rename from mmc/obmc-flash-mmc-mirroruboot.service.in
rename to bmc/mmc/obmc-flash-mmc-mirroruboot.service.in
diff --git a/mmc/obmc-flash-mmc-mount.service.in b/bmc/mmc/obmc-flash-mmc-mount.service.in
similarity index 100%
rename from mmc/obmc-flash-mmc-mount.service.in
rename to bmc/mmc/obmc-flash-mmc-mount.service.in
diff --git a/mmc/obmc-flash-mmc-remove@.service.in b/bmc/mmc/obmc-flash-mmc-remove@.service.in
similarity index 100%
rename from mmc/obmc-flash-mmc-remove@.service.in
rename to bmc/mmc/obmc-flash-mmc-remove@.service.in
diff --git a/mmc/obmc-flash-mmc-setprimary@.service.in b/bmc/mmc/obmc-flash-mmc-setprimary@.service.in
similarity index 100%
rename from mmc/obmc-flash-mmc-setprimary@.service.in
rename to bmc/mmc/obmc-flash-mmc-setprimary@.service.in
diff --git a/mmc/obmc-flash-mmc-umount.service.in b/bmc/mmc/obmc-flash-mmc-umount.service.in
similarity index 100%
rename from mmc/obmc-flash-mmc-umount.service.in
rename to bmc/mmc/obmc-flash-mmc-umount.service.in
diff --git a/mmc/obmc-flash-mmc@.service.in b/bmc/mmc/obmc-flash-mmc@.service.in
similarity index 100%
rename from mmc/obmc-flash-mmc@.service.in
rename to bmc/mmc/obmc-flash-mmc@.service.in
diff --git a/msl_verify.cpp b/bmc/msl_verify.cpp
similarity index 100%
rename from msl_verify.cpp
rename to bmc/msl_verify.cpp
diff --git a/msl_verify.hpp b/bmc/msl_verify.hpp
similarity index 100%
rename from msl_verify.hpp
rename to bmc/msl_verify.hpp
diff --git a/obmc-flash-bmc b/bmc/obmc-flash-bmc
similarity index 100%
rename from obmc-flash-bmc
rename to bmc/obmc-flash-bmc
diff --git a/obmc-flash-bmc-setenv@.service.in b/bmc/obmc-flash-bmc-setenv@.service.in
similarity index 100%
rename from obmc-flash-bmc-setenv@.service.in
rename to bmc/obmc-flash-bmc-setenv@.service.in
diff --git a/obmc-flash-host-bios@.service.in b/bmc/obmc-flash-host-bios@.service.in
similarity index 100%
rename from obmc-flash-host-bios@.service.in
rename to bmc/obmc-flash-host-bios@.service.in
diff --git a/openssl_alloc.cpp b/bmc/openssl_alloc.cpp
similarity index 100%
rename from openssl_alloc.cpp
rename to bmc/openssl_alloc.cpp
diff --git a/openssl_alloc.hpp b/bmc/openssl_alloc.hpp
similarity index 100%
rename from openssl_alloc.hpp
rename to bmc/openssl_alloc.hpp
diff --git a/reboot-guard-disable.service.in b/bmc/reboot-guard-disable.service.in
similarity index 100%
rename from reboot-guard-disable.service.in
rename to bmc/reboot-guard-disable.service.in
diff --git a/reboot-guard-enable.service.in b/bmc/reboot-guard-enable.service.in
similarity index 100%
rename from reboot-guard-enable.service.in
rename to bmc/reboot-guard-enable.service.in
diff --git a/reset-cs0-aspeed b/bmc/reset-cs0-aspeed
similarity index 100%
rename from reset-cs0-aspeed
rename to bmc/reset-cs0-aspeed
diff --git a/serialize.cpp b/bmc/serialize.cpp
similarity index 100%
rename from serialize.cpp
rename to bmc/serialize.cpp
diff --git a/serialize.hpp b/bmc/serialize.hpp
similarity index 100%
rename from serialize.hpp
rename to bmc/serialize.hpp
diff --git a/side-switch/meson.build b/bmc/side-switch/meson.build
similarity index 100%
rename from side-switch/meson.build
rename to bmc/side-switch/meson.build
diff --git a/side-switch/phosphor-bmc-side-switch.service b/bmc/side-switch/phosphor-bmc-side-switch.service
similarity index 100%
rename from side-switch/phosphor-bmc-side-switch.service
rename to bmc/side-switch/phosphor-bmc-side-switch.service
diff --git a/side-switch/side_switch.cpp b/bmc/side-switch/side_switch.cpp
similarity index 100%
rename from side-switch/side_switch.cpp
rename to bmc/side-switch/side_switch.cpp
diff --git a/side-switch/side_switch.hpp b/bmc/side-switch/side_switch.hpp
similarity index 100%
rename from side-switch/side_switch.hpp
rename to bmc/side-switch/side_switch.hpp
diff --git a/software.conf b/bmc/software.conf
similarity index 100%
rename from software.conf
rename to bmc/software.conf
diff --git a/software_manager.cpp b/bmc/software_manager.cpp
similarity index 100%
rename from software_manager.cpp
rename to bmc/software_manager.cpp
diff --git a/software_utils.cpp b/bmc/software_utils.cpp
similarity index 100%
rename from software_utils.cpp
rename to bmc/software_utils.cpp
diff --git a/software_utils.hpp b/bmc/software_utils.hpp
similarity index 100%
rename from software_utils.hpp
rename to bmc/software_utils.hpp
diff --git a/static/flash.cpp b/bmc/static/flash.cpp
similarity index 100%
rename from static/flash.cpp
rename to bmc/static/flash.cpp
diff --git a/static/item_updater_helper.cpp b/bmc/static/item_updater_helper.cpp
similarity index 100%
rename from static/item_updater_helper.cpp
rename to bmc/static/item_updater_helper.cpp
diff --git a/static/obmc-flash-bmc-alt@.service.in b/bmc/static/obmc-flash-bmc-alt@.service.in
similarity index 100%
rename from static/obmc-flash-bmc-alt@.service.in
rename to bmc/static/obmc-flash-bmc-alt@.service.in
diff --git a/static/obmc-flash-bmc-prepare-for-sync.service.in b/bmc/static/obmc-flash-bmc-prepare-for-sync.service.in
similarity index 100%
rename from static/obmc-flash-bmc-prepare-for-sync.service.in
rename to bmc/static/obmc-flash-bmc-prepare-for-sync.service.in
diff --git a/static/obmc-flash-bmc-static-mount-alt.service.in b/bmc/static/obmc-flash-bmc-static-mount-alt.service.in
similarity index 100%
rename from static/obmc-flash-bmc-static-mount-alt.service.in
rename to bmc/static/obmc-flash-bmc-static-mount-alt.service.in
diff --git a/sync-once.sh b/bmc/sync-once.sh
similarity index 100%
rename from sync-once.sh
rename to bmc/sync-once.sh
diff --git a/sync_manager.cpp b/bmc/sync_manager.cpp
similarity index 100%
rename from sync_manager.cpp
rename to bmc/sync_manager.cpp
diff --git a/sync_manager.hpp b/bmc/sync_manager.hpp
similarity index 100%
rename from sync_manager.hpp
rename to bmc/sync_manager.hpp
diff --git a/sync_manager_main.cpp b/bmc/sync_manager_main.cpp
similarity index 100%
rename from sync_manager_main.cpp
rename to bmc/sync_manager_main.cpp
diff --git a/sync_watch.cpp b/bmc/sync_watch.cpp
similarity index 100%
rename from sync_watch.cpp
rename to bmc/sync_watch.cpp
diff --git a/sync_watch.hpp b/bmc/sync_watch.hpp
similarity index 100%
rename from sync_watch.hpp
rename to bmc/sync_watch.hpp
diff --git a/synclist b/bmc/synclist
similarity index 100%
rename from synclist
rename to bmc/synclist
diff --git a/test/README.md b/bmc/test/README.md
similarity index 100%
rename from test/README.md
rename to bmc/test/README.md
diff --git a/test/utest.cpp b/bmc/test/utest.cpp
similarity index 100%
rename from test/utest.cpp
rename to bmc/test/utest.cpp
diff --git a/ubi/flash.cpp b/bmc/ubi/flash.cpp
similarity index 100%
rename from ubi/flash.cpp
rename to bmc/ubi/flash.cpp
diff --git a/ubi/item_updater_helper.cpp b/bmc/ubi/item_updater_helper.cpp
similarity index 100%
rename from ubi/item_updater_helper.cpp
rename to bmc/ubi/item_updater_helper.cpp
diff --git a/ubi/obmc-flash-bmc-cleanup.service.in b/bmc/ubi/obmc-flash-bmc-cleanup.service.in
similarity index 100%
rename from ubi/obmc-flash-bmc-cleanup.service.in
rename to bmc/ubi/obmc-flash-bmc-cleanup.service.in
diff --git a/ubi/obmc-flash-bmc-mirroruboot.service.in b/bmc/ubi/obmc-flash-bmc-mirroruboot.service.in
similarity index 100%
rename from ubi/obmc-flash-bmc-mirroruboot.service.in
rename to bmc/ubi/obmc-flash-bmc-mirroruboot.service.in
diff --git a/ubi/obmc-flash-bmc-ubiremount.service.in b/bmc/ubi/obmc-flash-bmc-ubiremount.service.in
similarity index 100%
rename from ubi/obmc-flash-bmc-ubiremount.service.in
rename to bmc/ubi/obmc-flash-bmc-ubiremount.service.in
diff --git a/ubi/obmc-flash-bmc-ubiro-remove@.service.in b/bmc/ubi/obmc-flash-bmc-ubiro-remove@.service.in
similarity index 100%
rename from ubi/obmc-flash-bmc-ubiro-remove@.service.in
rename to bmc/ubi/obmc-flash-bmc-ubiro-remove@.service.in
diff --git a/ubi/obmc-flash-bmc-ubiro@.service.in b/bmc/ubi/obmc-flash-bmc-ubiro@.service.in
similarity index 100%
rename from ubi/obmc-flash-bmc-ubiro@.service.in
rename to bmc/ubi/obmc-flash-bmc-ubiro@.service.in
diff --git a/ubi/obmc-flash-bmc-ubirw-remove.service.in b/bmc/ubi/obmc-flash-bmc-ubirw-remove.service.in
similarity index 100%
rename from ubi/obmc-flash-bmc-ubirw-remove.service.in
rename to bmc/ubi/obmc-flash-bmc-ubirw-remove.service.in
diff --git a/ubi/obmc-flash-bmc-ubirw.service.in b/bmc/ubi/obmc-flash-bmc-ubirw.service.in
similarity index 100%
rename from ubi/obmc-flash-bmc-ubirw.service.in
rename to bmc/ubi/obmc-flash-bmc-ubirw.service.in
diff --git a/ubi/obmc-flash-bmc-updateubootvars@.service.in b/bmc/ubi/obmc-flash-bmc-updateubootvars@.service.in
similarity index 100%
rename from ubi/obmc-flash-bmc-updateubootvars@.service.in
rename to bmc/ubi/obmc-flash-bmc-updateubootvars@.service.in
diff --git a/update_manager.cpp b/bmc/update_manager.cpp
similarity index 100%
rename from update_manager.cpp
rename to bmc/update_manager.cpp
diff --git a/update_manager.hpp b/bmc/update_manager.hpp
similarity index 100%
rename from update_manager.hpp
rename to bmc/update_manager.hpp
diff --git a/usb/70-bmc-usb.rules b/bmc/usb/70-bmc-usb.rules
similarity index 100%
rename from usb/70-bmc-usb.rules
rename to bmc/usb/70-bmc-usb.rules
diff --git a/usb/meson.build b/bmc/usb/meson.build
similarity index 100%
rename from usb/meson.build
rename to bmc/usb/meson.build
diff --git a/usb/services/usb-code-update@.service b/bmc/usb/services/usb-code-update@.service
similarity index 100%
rename from usb/services/usb-code-update@.service
rename to bmc/usb/services/usb-code-update@.service
diff --git a/usb/usb_manager.cpp b/bmc/usb/usb_manager.cpp
similarity index 100%
rename from usb/usb_manager.cpp
rename to bmc/usb/usb_manager.cpp
diff --git a/usb/usb_manager.hpp b/bmc/usb/usb_manager.hpp
similarity index 100%
rename from usb/usb_manager.hpp
rename to bmc/usb/usb_manager.hpp
diff --git a/usb/usb_manager_main.cpp b/bmc/usb/usb_manager_main.cpp
similarity index 100%
rename from usb/usb_manager_main.cpp
rename to bmc/usb/usb_manager_main.cpp
diff --git a/usr-local.mount.in b/bmc/usr-local.mount.in
similarity index 100%
rename from usr-local.mount.in
rename to bmc/usr-local.mount.in
diff --git a/utils.cpp b/bmc/utils.cpp
similarity index 100%
rename from utils.cpp
rename to bmc/utils.cpp
diff --git a/utils.hpp b/bmc/utils.hpp
similarity index 100%
rename from utils.hpp
rename to bmc/utils.hpp
diff --git a/version.cpp b/bmc/version.cpp
similarity index 100%
rename from version.cpp
rename to bmc/version.cpp
diff --git a/version.hpp b/bmc/version.hpp
similarity index 100%
rename from version.hpp
rename to bmc/version.hpp
diff --git a/watch.cpp b/bmc/watch.cpp
similarity index 100%
rename from watch.cpp
rename to bmc/watch.cpp
diff --git a/watch.hpp b/bmc/watch.hpp
similarity index 100%
rename from watch.hpp
rename to bmc/watch.hpp
diff --git a/xyz.openbmc_project.Software.BMC.Updater.service.in b/bmc/xyz.openbmc_project.Software.BMC.Updater.service.in
similarity index 100%
rename from xyz.openbmc_project.Software.BMC.Updater.service.in
rename to bmc/xyz.openbmc_project.Software.BMC.Updater.service.in
diff --git a/xyz.openbmc_project.Software.Download.service.in b/bmc/xyz.openbmc_project.Software.Download.service.in
similarity index 100%
rename from xyz.openbmc_project.Software.Download.service.in
rename to bmc/xyz.openbmc_project.Software.Download.service.in
diff --git a/xyz.openbmc_project.Software.Manager.service.in b/bmc/xyz.openbmc_project.Software.Manager.service.in
similarity index 100%
rename from xyz.openbmc_project.Software.Manager.service.in
rename to bmc/xyz.openbmc_project.Software.Manager.service.in
diff --git a/xyz.openbmc_project.Software.Sync.service.in b/bmc/xyz.openbmc_project.Software.Sync.service.in
similarity index 100%
rename from xyz.openbmc_project.Software.Sync.service.in
rename to bmc/xyz.openbmc_project.Software.Sync.service.in
diff --git a/xyz.openbmc_project.Software.Version.service.in b/bmc/xyz.openbmc_project.Software.Version.service.in
similarity index 100%
rename from xyz.openbmc_project.Software.Version.service.in
rename to bmc/xyz.openbmc_project.Software.Version.service.in
diff --git a/meson.build b/meson.build
index b697e40..e160d5d 100644
--- a/meson.build
+++ b/meson.build
@@ -22,88 +22,6 @@
 
 cpp = meson.get_compiler('cpp')
 
-conf = configuration_data()
-
-# DBus information
-conf.set_quoted('BMC_INVENTORY_INTERFACE', 'xyz.openbmc_project.Inventory.Item.Bmc')
-conf.set_quoted('BUSNAME_UPDATER', 'xyz.openbmc_project.Software.BMC.Updater')
-conf.set_quoted('DOWNLOAD_BUSNAME', 'xyz.openbmc_project.Software.Download')
-conf.set_quoted('FILEPATH_IFACE', 'xyz.openbmc_project.Common.FilePath')
-conf.set_quoted('INVENTORY_PATH', '/xyz/openbmc_project/inventory/')
-conf.set_quoted('MAPPER_BUSNAME', 'xyz.openbmc_project.ObjectMapper')
-conf.set_quoted('MAPPER_INTERFACE', 'xyz.openbmc_project.ObjectMapper')
-conf.set_quoted('MAPPER_PATH', '/xyz/openbmc_project/object_mapper')
-conf.set_quoted('SOFTWARE_OBJPATH', '/xyz/openbmc_project/software')
-conf.set_quoted('SYSTEMD_BUSNAME', 'org.freedesktop.systemd1')
-conf.set_quoted('SYSTEMD_PATH', '/org/freedesktop/systemd1')
-conf.set_quoted('SYSTEMD_INTERFACE', 'org.freedesktop.systemd1.Manager')
-conf.set_quoted('VERSION_BUSNAME', 'xyz.openbmc_project.Software.Version')
-conf.set_quoted('VERSION_IFACE', 'xyz.openbmc_project.Software.Version')
-conf.set_quoted('EXTENDED_VERSION_IFACE', 'xyz.openbmc_project.Software.ExtendedVersion')
-conf.set_quoted('COMPATIBLE_IFACE', 'xyz.openbmc_project.Inventory.Decorator.Compatible')
-
-# Names of the forward and reverse associations
-conf.set_quoted('ACTIVATION_FWD_ASSOCIATION', 'inventory')
-conf.set_quoted('ACTIVATION_REV_ASSOCIATION', 'activation')
-conf.set_quoted('ACTIVE_FWD_ASSOCIATION', 'active')
-conf.set_quoted('ACTIVE_REV_ASSOCIATION', 'software_version')
-conf.set_quoted('FUNCTIONAL_FWD_ASSOCIATION', 'functional')
-conf.set_quoted('FUNCTIONAL_REV_ASSOCIATION', 'software_version')
-conf.set_quoted('UPDATEABLE_FWD_ASSOCIATION', 'updateable')
-conf.set_quoted('UPDATEABLE_REV_ASSOCIATION', 'software_version')
-
-# Filesystem files and directories
-# The prefix path for the versioned read-only bmc partitions
-conf.set_quoted('BMC_ROFS_PREFIX', get_option('media-dir') + '/rofs-')
-# The name of the BMC table of contents file
-conf.set_quoted('OS_RELEASE_FILE', '/etc/os-release')
-# The dir where activation data is stored in files
-conf.set_quoted('PERSIST_DIR', '/var/lib/phosphor-bmc-code-mgmt/')
-
-# Supported BMC layout types
-conf.set('STATIC_LAYOUT', get_option('bmc-layout').contains('static'))
-conf.set('UBIFS_LAYOUT', get_option('bmc-layout').contains('ubi'))
-conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc'))
-
-# Configurable features
-conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').allowed())
-conf.set('WANT_SIGNATURE_VERIFY', get_option('verify-signature').allowed())
-conf.set('START_UPDATE_DBUS_INTEFACE', get_option('software-update-dbus-interface').allowed())
-
-# Configurable variables
-conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed'))
-conf.set_quoted('HASH_FILE_NAME', get_option('hash-file-name'))
-conf.set_quoted('IMG_UPLOAD_DIR', get_option('img-upload-dir'))
-conf.set_quoted('MANIFEST_FILE_NAME', get_option('manifest-file-name'))
-conf.set_quoted('MEDIA_DIR', get_option('media-dir'))
-optional_array = get_option('optional-images')
-optional_images = ''
-foreach optiona_image : optional_array
-    optional_images = ' '.join([optional_images, optiona_image])
-endforeach
-conf.set_quoted('OPTIONAL_IMAGES', optional_images)
-conf.set_quoted('PUBLICKEY_FILE_NAME', get_option('publickey-file-name'))
-conf.set_quoted('SIGNATURE_FILE_EXT', get_option('signature-file-ext'))
-conf.set_quoted('SIGNED_IMAGE_CONF_PATH', get_option('signed-image-conf-path'))
-conf.set_quoted('SYNC_LIST_DIR_PATH', get_option('sync-list-dir-path'))
-conf.set_quoted('SYNC_LIST_FILE_NAME', get_option('sync-list-file-name'))
-conf.set_quoted('BMC_MSL', get_option('bmc-msl'))
-conf.set_quoted('REGEX_BMC_MSL', get_option('regex-bmc-msl'))
-
-if get_option('host-bios-upgrade').allowed()
-    conf.set_quoted('BIOS_OBJPATH', get_option('bios-object-path'))
-endif
-
-if get_option('bmc-static-dual-image').allowed()
-  conf.set('BMC_STATIC_DUAL_IMAGE', get_option('bmc-static-dual-image').allowed())
-  conf.set_quoted('ALT_ROFS_DIR', get_option('alt-rofs-dir'))
-  conf.set_quoted('ALT_RWFS', get_option('alt-rwfs-dir'))
-else
-  conf.set_quoted('ALT_RWFS', '/media/alt/var/persist')
-endif
-
-configure_file(output: 'config.h', configuration: conf)
-
 boost_dep = dependency('boost')
 
 sdbusplus_dep = dependency('sdbusplus')
@@ -142,209 +60,4 @@
 systemd = dependency('systemd')
 systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir')
 
-unit_files = [
-    'obmc-flash-bmc-setenv@.service.in',
-    'reboot-guard-disable.service.in',
-    'reboot-guard-enable.service.in',
-    'force-reboot.service.in',
-    'usr-local.mount.in',
-    'xyz.openbmc_project.Software.Download.service.in',
-    'xyz.openbmc_project.Software.Sync.service.in'
-]
-
-image_updater_sources = files(
-    'activation.cpp',
-    'images.cpp',
-    'item_updater.cpp',
-    'serialize.cpp',
-    'version.cpp',
-    'utils.cpp',
-    'msl_verify.cpp',
-    'update_manager.cpp'
-)
-
-if get_option('bmc-layout').contains('static')
-    image_updater_sources += files(
-        'static/flash.cpp',
-        'static/item_updater_helper.cpp'
-    )
-elif get_option('bmc-layout').contains('ubi')
-    image_updater_sources += files(
-        'ubi/flash.cpp',
-        'ubi/item_updater_helper.cpp'
-    )
-
-    unit_files += [
-        'ubi/obmc-flash-bmc-cleanup.service.in',
-        'ubi/obmc-flash-bmc-mirroruboot.service.in',
-        'ubi/obmc-flash-bmc-ubiremount.service.in',
-        'ubi/obmc-flash-bmc-ubiro@.service.in',
-        'ubi/obmc-flash-bmc-ubiro-remove@.service.in',
-        'ubi/obmc-flash-bmc-ubirw.service.in',
-        'ubi/obmc-flash-bmc-ubirw-remove.service.in',
-        'ubi/obmc-flash-bmc-updateubootvars@.service.in'
-    ]
-elif get_option('bmc-layout').contains('mmc')
-    image_updater_sources += files(
-        'mmc/flash.cpp',
-        'mmc/item_updater_helper.cpp'
-    )
-
-    unit_files += [
-        'mmc/obmc-flash-mmc@.service.in',
-        'mmc/obmc-flash-mmc-mount.service.in',
-        'mmc/obmc-flash-mmc-remove@.service.in',
-        'mmc/obmc-flash-mmc-setprimary@.service.in',
-        'mmc/obmc-flash-mmc-umount.service.in',
-        'mmc/obmc-flash-mmc-mirroruboot.service.in',
-    ]
-endif
-
-if get_option('host-bios-upgrade').allowed()
-    unit_files += 'obmc-flash-host-bios@.service.in'
-endif
-
-if get_option('bmc-static-dual-image').allowed()
-    unit_files += [
-        'static/obmc-flash-bmc-alt@.service.in',
-        'static/obmc-flash-bmc-static-mount-alt.service.in',
-        'static/obmc-flash-bmc-prepare-for-sync.service.in',
-    ]
-endif
-
-if get_option('sync-bmc-files').allowed()
-    executable(
-        'phosphor-sync-software-manager',
-        'sync_manager.cpp',
-        'sync_manager_main.cpp',
-        'sync_watch.cpp',
-        dependencies: deps,
-        install: true
-    )
-
-    install_data('synclist',
-        install_dir:  get_option('sysconfdir')
-    )
-
-    install_data('sync-once.sh',
-        install_mode: 'rwxr-xr-x',
-        install_dir: get_option('bindir')
-    )
-endif
-
-if (get_option('verify-signature').allowed())
-    image_updater_sources += files(
-        'utils.cpp',
-        'image_verify.cpp',
-        'openssl_alloc.cpp'
-    )
-endif
-
-executable(
-    'phosphor-download-manager',
-    'download_manager.cpp',
-    'download_manager_main.cpp',
-    dependencies: deps,
-    install: true
-)
-
-software_common_sources = files(
-    'software_utils.cpp',
-)
-
-if get_option('software-update-dbus-interface').allowed()
-    executable(
-        'phosphor-software-manager',
-        'software_manager.cpp',
-        image_updater_sources,
-        software_common_sources,
-        dependencies: [deps, ssl],
-        install: true
-    )
-    unit_files += [
-        'xyz.openbmc_project.Software.Manager.service.in'
-    ]
-else
-   unit_files += [
-        'xyz.openbmc_project.Software.BMC.Updater.service.in',
-        'xyz.openbmc_project.Software.Version.service.in'
-   ]
-endif
-
-executable(
-    'phosphor-image-updater',
-    image_updater_sources,
-    software_common_sources,
-    'item_updater_main.cpp',
-    dependencies: [deps, ssl, boost_dep],
-    install: true
-)
-
-executable(
-    'phosphor-version-software-manager',
-    'image_manager.cpp',
-    'image_manager_main.cpp',
-    'version.cpp',
-    'watch.cpp',
-    software_common_sources,
-    dependencies: [deps, ssl],
-    install: true
-)
-
-install_data('obmc-flash-bmc',
-    install_mode: 'rwxr-xr-x',
-    install_dir: get_option('bindir')
-)
-
-install_data('detect-slot-aspeed',
-    install_mode: 'rwxr-xr-x',
-    install_dir: get_option('bindir')
-)
-
-install_data('reset-cs0-aspeed',
-    install_mode: 'rwxr-xr-x',
-    install_dir: get_option('bindir')
-)
-
-install_data('software.conf',
-    install_dir: '/usr/lib/tmpfiles.d/'
-)
-
-foreach u : unit_files
-    configure_file(
-        input: u,
-        output: '@BASENAME@',
-        configuration: conf,
-        install: true,
-        install_dir: systemd_system_unit_dir,
-    )
-endforeach
-
-# If test coverage of source files within the root directory are wanted,
-# need to define and build the tests from here
-build_tests = get_option('tests')
-if not build_tests.disabled()
-    gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
-    include_srcs = declare_dependency(sources: [
-        'utils.cpp',
-        'image_verify.cpp',
-        'images.cpp',
-        'version.cpp']
-    )
-
-    test('utest',
-        executable(
-            'utest',
-            './test/utest.cpp',
-            dependencies: [deps, gtest, include_srcs, ssl]
-        )
-)
-endif
-
-if get_option('usb-code-update').allowed()
-    subdir('usb')
-endif
-
-if get_option('side-switch-on-boot').allowed()
-    subdir('side-switch')
-endif
+subdir('bmc')