# vc_vchi_gencmd.c has a type-punning problem in vc_gencmd_read_response
add_definitions(-fno-strict-aliasing)
-include_directories(${VMCS_TARGET}/vcfiled)
-
add_library(vchostif
${VMCS_TARGET}/vcfilesys.c ${VMCS_TARGET}/vcmisc.c
vc_vchi_gencmd.c vc_vchi_filesys.c vc_vchi_gpuserv.c
target_link_libraries(vcilcs brcmEGL brcmGLESv2 khrn_client vchiq_arm vcos)
# vchostif needs ilcore as well (vmcs_main pulls it in)
-target_link_libraries(vchostif vchiq_arm vcos vcfiled_check)
+target_link_libraries(vchostif vchiq_arm vcos)
#target_link_libraries(bufman WFC)
-add_subdirectory(linux/vcfiled)
install(TARGETS vchostif vcilcs DESTINATION lib)
+++ /dev/null
-
-add_definitions(-Werror)
-
-# vcfiled - serves files to videocore. used for media handlers from
-# OpenMAX/IL and loading VLLs.
-add_executable(vcfiled vcfiled.c)
-
-# library to check if vcfiled is running or not
-add_library(vcfiled_check vcfiled_check.c)
-
-target_link_libraries(vcfiled
- vcfiled_check
- vchostif
- vchiq_arm
- vcos)
-
-install(TARGETS vcfiled
- RUNTIME DESTINATION sbin)
-
-configure_file (etc/init.d/vcfiled ${PROJECT_BINARY_DIR}/etc/init.d/vcfiled)
-
-# script to start up vcfiled at start of day
-install(PROGRAMS ${PROJECT_BINARY_DIR}/etc/init.d/vcfiled
- DESTINATION /etc/init.d)
-# install locally to the installation directory too
-install(PROGRAMS ${PROJECT_BINARY_DIR}/etc/init.d/vcfiled
- DESTINATION ${VMCS_INSTALL_PREFIX}/share/install)
-
-# test program for vcfiled_check library
-add_executable(vcfiled_lock_test vcfiled_lock_test.c)
-target_link_libraries(vcfiled_lock_test vcfiled_check)
-
-install(TARGETS vcfiled_check DESTINATION lib)
+++ /dev/null
-#! /bin/sh
-### BEGIN INIT INFO
-# Provides: vcfiled
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Required-Start: udev
-# Required-Stop: udev
-# Short-Description: VideoCore file server daemon
-### END INIT INFO
-
-# Author: Luke Diamand <luked@broadcom.com>
-#
-# Please remove the "Author" lines above and replace them
-# with your own name if you copy and modify this script.
-
-# Do NOT "set -e"
-
-# PATH should only include /usr/* if it runs after the mountnfs.sh script
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
-DESC="VideoCore file server daemon"
-NAME=vcfiled
-VCROOT=${CMAKE_INSTALL_PREFIX}
-DAEMON=$VCROOT/sbin/$NAME
-DAEMON_ARGS=""
-PIDFILE=/var/run/$NAME/$NAME
-SCRIPTNAME=/etc/init.d/$NAME
-
-# Exit if the package is not installed
-[ -x "$DAEMON" ] || exit 0
-
-# Read configuration variable file if it is present
-[ -r /etc/default/$NAME ] && . /etc/default/$NAME
-
-# Load the VERBOSE setting and other rcS variables
-. /lib/init/vars.sh
-
-# Define LSB log_* functions.
-# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
-. /lib/lsb/init-functions
-
-#
-# Function that starts the daemon/service
-#
-do_start()
-{
- # Return
- # 0 if daemon has been started
- # 1 if daemon was already running
- # 2 if daemon could not be started
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
- || return 1
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
- $DAEMON_ARGS \
- || return 2
-}
-
-#
-# Function that stops the daemon/service
-#
-do_stop()
-{
- # Return
- # 0 if daemon has been stopped
- # 1 if daemon was already stopped
- # 2 if daemon could not be stopped
- # other if a failure occurred
- start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
- RETVAL="$?"
- [ "$RETVAL" = 2 ] && return 2
- start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
- [ "$?" = 2 ] && return 2
- # Many daemons don't delete their pidfiles when they exit.
- rm -f $PIDFILE
- return "$RETVAL"
-}
-
-case "$1" in
- start)
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
- do_start
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- stop)
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- #reload|force-reload)
- #
- # If do_reload() is not implemented then leave this commented out
- # and leave 'force-reload' as an alias for 'restart'.
- #
- #log_daemon_msg "Reloading $DESC" "$NAME"
- #do_reload
- #log_end_msg $?
- #;;
- restart|force-reload)
- #
- # If the "reload" option is implemented then remove the
- # 'force-reload' alias
- #
- log_daemon_msg "Restarting $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1)
- do_start
- case "$?" in
- 0) log_end_msg 0 ;;
- 1) log_end_msg 1 ;; # Old process is still running
- *) log_end_msg 1 ;; # Failed to start
- esac
- ;;
- *)
- # Failed to stop
- log_end_msg 1
- ;;
- esac
- ;;
- *)
- #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
- echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
- exit 3
- ;;
-esac
-
-:
+++ /dev/null
-/*
-Copyright (c) 2012, Broadcom Europe Ltd
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the copyright holder nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/**
- * @file
- *
- * Daemon serving files to VideoCore from the host filing system.
- *
- */
-
-#include <stdio.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <getopt.h>
-#include <syslog.h>
-#include <fcntl.h>
-#ifdef ANDROID
-#include <android/log.h>
-#endif
-
-#include "vchiq.h"
-#include "interface/vchi/vchi.h"
-#include "interface/vcos/vcos.h"
-#include "interface/vmcs_host/vc_vchi_filesys.h"
-#include "vchost.h"
-#include "vcfiled_check.h"
-
-static int log_stderr; /** Debug output to stderr? */
-static int foreground; /** Don't fork - run in foreground? */
-static const char *work_dir = "/"; /** Working directory */
-static const char *lock_prefix = ""; /** Lock file prefix */
-static int lock_prefix_set = 0;
-static const char *progname;
-
-VCHI_INSTANCE_T global_initialise_instance;
-VCHI_CONNECTION_T *global_connection;
-
-void vc_host_get_vchi_state(VCHI_INSTANCE_T *initialise_instance, VCHI_CONNECTION_T **connection)
-{
- *initialise_instance = global_initialise_instance;
- *connection = global_connection;
-}
-
-static void logmsg(int level, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
-
- if (log_stderr)
- {
- vfprintf(stderr, fmt, ap);
- }
- else
- {
-#ifdef ANDROID
- __android_log_vprint(level, "vcfiled", fmt, ap);
-#else
- vsyslog(level | LOG_DAEMON, fmt, ap);
-#endif
- }
- va_end(ap);
-}
-
-static void usage(const char *progname)
-{
-
- fprintf(stderr,"usage: %s [-debug] [-foreground] [-root dir] [-lock prefix]\n",
- progname);
- fprintf(stderr," --debug - debug to stderr rather than syslog\n");
- fprintf(stderr," --foreground - do not fork, stay in foreground\n");
- fprintf(stderr," --root dir - chdir to this directory first\n");
- fprintf(stderr," --lock prefix - prefix to append to VCFILED_LOCKFILE\n");
-}
-
-enum { OPT_DEBUG, OPT_FG, OPT_ROOT, OPT_LOCK };
-
-static void parse_args(int argc, char *const *argv)
-{
- int finished = 0;
- static struct option long_options[] =
- {
- {"debug", no_argument, &log_stderr, 1},
- {"foreground", no_argument, &foreground, 1},
- {"root", required_argument, NULL, OPT_ROOT},
- {"lock", required_argument, NULL, OPT_LOCK},
- {0, 0, 0, 0},
- };
- while (!finished)
- {
- int option_index = 0;
- int c = getopt_long_only(argc, argv, "", long_options, &option_index);
-
- switch (c)
- {
- case 0:
- // debug or foreground options, just sets flags directly
- break;
- case OPT_ROOT:
- work_dir = optarg;
- // sanity check directory
- if (chdir(work_dir) < 0)
- {
- fprintf(stderr,"cannot chdir to %s: %s\n", work_dir, strerror(errno));
- exit(-1);
- }
- break;
- case OPT_LOCK:
- lock_prefix = optarg;
- lock_prefix_set = 1;
- break;
-
- default:
- case '?':
- usage(argv[0]);
- exit(-1);
- break;
-
- case -1:
- finished = 1;
- break;
- }
-
- }
-}
-
-int main(int argc, char *const *argv)
-{
- VCHIQ_INSTANCE_T vchiq_instance;
- int success;
- char lockfile[128];
-
- progname = argv[0];
- const char *sep = strrchr(progname, '/');
- if (sep)
- progname = sep+1;
-
- parse_args(argc, argv);
-
- if (!foreground)
- {
- if ( daemon( 0, 1 ) != 0 )
- {
- fprintf( stderr, "Failed to daemonize: errno = %d", errno );
- return -1;
- }
- log_stderr = 0;
- }
- if ( lock_prefix_set )
- {
- vcos_safe_sprintf( lockfile, sizeof(lockfile), 0, "%s/%s", lock_prefix, VCFILED_LOCKFILE );
- }
- else
- {
- vcos_safe_sprintf( lockfile, sizeof(lockfile), 0, "%s", VCFILED_LOCKFILE );
- }
- success = vcfiled_lock(lockfile, logmsg);
- if (success != 0)
- {
- return -1;
- }
-
- logmsg( LOG_INFO, "vcfiled started" );
-
- vcos_init();
-
- if (vchiq_initialise(&vchiq_instance) != VCHIQ_SUCCESS)
- {
- logmsg(LOG_ERR, "%s: failed to open vchiq instance\n", argv[0]);
- return -1;
- }
-
- success = vchi_initialise( &global_initialise_instance);
- vcos_assert(success == 0);
- vchiq_instance = (VCHIQ_INSTANCE_T)global_initialise_instance;
-
- global_connection = vchi_create_connection(single_get_func_table(),
- vchi_mphi_message_driver_func_table());
-
- vchi_connect(&global_connection, 1, global_initialise_instance);
-
- vc_vchi_filesys_init (global_initialise_instance, &global_connection, 1);
-
- for (;;)
- {
- sleep(INT_MAX);
- }
-
- vcos_deinit ();
-
- return 0;
-}
-
+++ /dev/null
-/*
-Copyright (c) 2012, Broadcom Europe Ltd
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the copyright holder nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/** Very simple test code for the vcfiled locking
- */
-#include "vcfiled_check.h"
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-
-static void usage(const char *prog)
-{
- fprintf(stderr, "usage: %s lock|check <lockfile>\n", prog);
- exit(1);
-}
-
-static void logmsg(int level, const char *fmt, ...)
-{
- (void)level;
-
- va_list ap;
- va_start(ap, fmt);
- vprintf(fmt, ap);
- va_end(ap);
-}
-
-int main(int argc, const char **argv)
-{
- if (argc != 3)
- {
- usage(argv[0]);
- }
- const char *lockfile = argv[2];
- if (strcmp(argv[1], "lock") == 0)
- {
- int rc = vcfiled_lock(lockfile, logmsg);
- if (rc)
- {
- printf("failed to lock %s\n", lockfile);
- exit(1);
- }
- sleep(300);
- }
- else if (strcmp(argv[1], "check") == 0)
- {
- printf("%s\n",
- vcfiled_is_running(lockfile) ?
- "running" : "not running");
- }
- else
- {
- usage(argv[0]);
- }
- return 0;
-}
-