Beispiel #1
0
int main(void)
{
	// Create the GLFW window
	window = Window::create_window(640, 480);
	// Print OpenGL and GLSL versions
	print_versions();
	// Setup callbacks
	setup_callbacks();
	// Setup OpenGL settings, including lighting, materials, etc.
	setup_opengl_settings();
	// Initialize objects/pointers for rendering
	Window::initialize_objects();

	// Loop while GLFW window should stay open
	while (!glfwWindowShouldClose(window))
	{
		// Main render display callback. Rendering of objects is done here.
		Window::display_callback(window);
		// Idle callback. Updating objects, etc. can be done here.
		Window::idle_callback();
	}

	Window::clean_up();
	// Destroy the window
	glfwDestroyWindow(window);
	// Terminate GLFW
	glfwTerminate();

	exit(EXIT_SUCCESS);
}
Beispiel #2
0
void Summary::print()
{
    print_versions();
    print_pools();
    print_bind();
    print_commands();
}
Beispiel #3
0
void Summary::print()
{
    print_versions();
    print_memory();
    print_cpu();
    print_threads();
    print_pools();

#   ifndef XMRIG_NO_API
    print_api();
#   endif

    print_commands();
}
Beispiel #4
0
void Summary::print(xmrig::Controller *controller)
{
    print_versions(controller);
    print_mode(controller);
    print_algo(controller);
    printPools(controller->config());
    print_bind(controller);

#   ifndef XMRIG_NO_API
    print_api(controller);
#   endif

    print_commands(controller);
}
Beispiel #5
0
int update_main(int argc, char **argv)
{
	int ret = 0;
	copyright_header("software update");

	if (!parse_options(argc, argv)) {
		free_globals();
		return EXIT_FAILURE;
	}

	if (cmd_line_status) {
		print_versions();
	} else {
		ret = main_update();
	}
	free_globals();
	return ret;
}
Beispiel #6
0
int log_init(const char *output)
{
	int new_logfd, fd;

	gettimeofday(&start, NULL);
	reset_buf_off();

	if (output && !strncmp(output, "-", 2)) {
		new_logfd = dup(STDOUT_FILENO);
		if (new_logfd < 0) {
			pr_perror("Can't dup stdout stream");
			return -1;
		}
	} else if (output) {
		new_logfd = open(output, O_CREAT|O_TRUNC|O_WRONLY|O_APPEND, 0600);
		if (new_logfd < 0) {
			pr_perror("Can't create log file %s", output);
			return -1;
		}
	} else {
		new_logfd = dup(DEFAULT_LOGFD);
		if (new_logfd < 0) {
			pr_perror("Can't dup log file");
			return -1;
		}
	}

	fd = install_service_fd(LOG_FD_OFF, new_logfd);
	if (fd < 0)
		goto err;

	print_versions();

	return 0;

err:
	pr_perror("Log engine failure, can't duplicate descriptor");
	return -1;
}
Beispiel #7
0
static void print_usage()
{
    print_versions();
    printf("Usage :\n");
    printf("    -h                          : Print usage infomation\n");
    printf("    -v                          : Print version infomation\n");
#ifdef IPC_IP
    printf("    -ipc_port=<filename>        : Socket port to listen on. Default: %d\n", PORT_NUMBER_Q);
#endif
#ifdef IPC_CHARDEVICE
    printf("    -dev=<filename>     : Char device to open. Default: %s\n", CHAR_DEVICE_Q);
#ifdef CSR_AMP_ENABLE
    printf("    -paldatadev=<filename>      : Char device to open. Default: %s\n", PALDATA_CHAR_DEVICE_Q);
    printf("    -paldisablesecurity >       : disable security handshake if already enabled\n");
#endif
#endif

#ifdef CSR_AMP_ENABLE
    printf("    -palselectchannel=<number>  : channel to select\n");
    printf("    -paldisableqos >            : disable qos support in PAL\n");
#ifdef IPC_IP
        printf("    -ipc_hciport=<portnumber>        : Socket port for AMP HCI to listen on. Default: %d\n", HCI_PORT_NUMBER_Q);
        printf("    -ipc_aclport=<portnumber>        : Socket port for AMP ACL to listen on. Default: %d\n", ACL_PORT_NUMBER_Q);
#endif
#endif
    printf("    -cal=<filename>             : Calibration Data file.\n");
    printf("                                : The file is read at startup and write updates to it\n");
    printf("    -mib=<filename>             : Load a mib file on startup.\n");
    printf("                                : Upto %d files can be passed on commandline\n", MAX_MIB_FILES);
    printf("    -mac=<filename>             : Load a file containing a MAC address with the format XX:XX:XX:XX:XX:XX.\n");
    printf("    -wifion                     : Automatically start the SME.\n");
    printf("    -flightmode                 : Boot into flightmode and exit.\n");
    printf("    -exitOnError                : Development option. Exit rather than restart on error\n");
    printf("    -stopOnError                : Development option. Do not restart on error\n");
    (void)fflush(stdout);
}
Beispiel #8
0
static void modules_init()
{
    int ret;
    struct partition_entry *p;
    flash_desc_t fl;

    /*
     * Initialize wmstdio prints
     */
    ret = wmstdio_init(UART0_ID, 115200);
    if (ret != WM_SUCCESS) {
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    /* Initialize time subsystem.
     *
     * Initializes time to 1/1/1970 epoch 0.
     */
    ret = wmtime_init();
    if (ret != WM_SUCCESS) {
        wmprintf("Error: wmtime_init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    /*
     * Initialize CLI Commands
     */
    ret = cli_init();
    if (ret != WM_SUCCESS) {
        LOG_ERROR("Error: cli_init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    /* Initialize the partition module */
    ret = part_init();
    if (ret != 0) {
        LOG_ERROR("Failed to initialize partition\r\n");
        appln_critical_error_handler((void *) -WM_FAIL);
    }
    p = part_get_layout_by_id(FC_COMP_PSM, NULL);
    if (!p) {
        LOG_ERROR("Error: no psm partition found");
        appln_critical_error_handler((void *) -WM_FAIL);
    }
    part_to_flash_desc(p, &fl);

#if defined CONFIG_CPU_MC200 && defined CONFIG_WiFi_8801
    //check psm _format
    psm_format_check(&fl);
#endif
    /* Initilize psm module */
    ret = app_psm_init();
    if (ret != 0) {
        LOG_ERROR("Failed to initialize psm module\r\n");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    wmprintf("\n\r");
    wmprintf("_|      _|  _|_|_|  _|_|_|    _|_|  \n\r");
    wmprintf("_|_|  _|_|    _|      _|    _|    _|\n\r");
    wmprintf("_|  _|  _|    _|      _|    _|    _|\n\r");
    wmprintf("_|      _|    _|      _|    _|    _|\n\r");
    wmprintf("_|      _|  _|_|_|  _|_|_|    _|_|  \n\r");
    print_versions();

    read_provision_status();

#ifndef RELEASE
    /* Initilize cli for psm module */
    ret = psm_cli_init();
    if (ret != 0) {
        LOG_ERROR("Failed to register psm-cli commands\r\n");
        appln_critical_error_handler((void *) -WM_FAIL);
    }
#endif

    ret = gpio_drv_init();
    if (ret != WM_SUCCESS) {
        LOG_ERROR("Error: gpio_drv_init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    ret = aes_drv_init();
    if (ret != WM_SUCCESS) {
        LOG_ERROR("Error: aes drv init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    ret = factory_cli_init();
    if (ret != 0) {
        LOG_ERROR("Error: factory_cli_init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    ret = miio_chip_rpc_init();
    if (ret != 0) {
        LOG_ERROR("Error: miio_chip_rpc_cli_init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

#ifndef RELEASE
    ret = appln_cli_init();
    if (ret != 0) {
        LOG_ERROR("Error: appln init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }
#endif

    /* init add on interface */
    init_addon_interface();

    ret = ota_init();
    if (ret != 0) {
        LOG_ERROR("Error: ota init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

#ifdef MIIO_COMMANDS
    ret = mcmd_create(UART1_ID);
    if (ret < 0) {
        LOG_ERROR("Error: miio command init failed(%d)\r\n", ret);
        appln_critical_error_handler((void *) -WM_FAIL);
    }
#endif

    /*
	* Initialize Power Management Subsystem
	*/
	ret = pm_init();
	if (ret != WM_SUCCESS) {
		LOG_ERROR("Error: pm_init failed");
		appln_critical_error_handler((void *) -WM_FAIL);
	}

}
Beispiel #9
0
static void sme_schedule_init(LinuxUserSpaceContext* context, int argc, char **argv)
{
    CsrBool wifion = FALSE;
    CsrBool flightmode = FALSE;
    int i;
#ifdef IPC_IP
    CsrUint32 ipc_portNumber = PORT_NUMBER_Q;
#ifdef CSR_AMP_ENABLE
    CsrUint32 ipc_hciPortNumber = HCI_PORT_NUMBER_Q;
    CsrUint32 ipc_aclPortNumber = ACL_PORT_NUMBER_Q;
#endif
#endif

#ifdef IPC_CHARDEVICE
    const char* connectStr = CHAR_DEVICE_Q;
#endif

    sme_trace_entry((TR_FSM, "sme_schedule_init()"));


    CsrMemSet(&getMainData(linuxContext)->address, 0xFF, sizeof(unifi_MACAddress));
    getMainData(linuxContext)->mibfiles.numElements = 0;
    getMainData(linuxContext)->mibfiles.dataList = (unifi_DataBlock*)CsrPmalloc(sizeof(unifi_DataBlock) * MAX_MIB_FILES);
    getMainData(linuxContext)->calibrationDataFile = NULL;
    getMainData(linuxContext)->calibrationData.length = 0;
    getMainData(linuxContext)->calibrationData.data = NULL;
    getMainData(linuxContext)->nextCaldataSaveTime = fsm_get_time_of_day_ms(context->fsmContext) + CALDATA_SAVE_INTERVAL_MS;
    getMainData(linuxContext)->exitOnError = FALSE;
    getMainData(linuxContext)->stopOnError = FALSE;

#ifdef CSR_AMP_ENABLE
    context->palDataFsmContext = paldata_init(linuxContext);
    sme_install_wakeup_callback(context->palDataFsmContext, fsm_wakeup_callback);
#endif

    /* Initialise basic constructs used by the SME */
    context->fsmContext = sme_init(context, NULL);
    sme_install_wakeup_callback(context->fsmContext, fsm_wakeup_callback);

#ifdef CSR_WIFI_NME_ENABLE
    context->nmeFsmContext = csr_wifi_nme_init(linuxContext, NULL);
    csr_wifi_nme_install_wakeup_callback(context->nmeFsmContext, fsm_wakeup_callback);
#endif

#ifdef FSM_DEBUG
    fsm_install_on_transition_callback(context->fsmContext, fsm_on_transition_trace_callback);
    fsm_install_unhandled_event_callback(context->fsmContext, fsm_on_unhandled_trace_callback);
    fsm_install_save_event_callback(context->fsmContext, fsm_on_saved_trace_callback);
    fsm_install_invalid_event_callback(context->fsmContext, fsm_on_invalid_trace_callback);
    fsm_install_ignore_event_callback(context->fsmContext, fsm_on_ignored_trace_callback);

#ifdef CSR_WIFI_NME_ENABLE
    fsm_install_on_transition_callback(context->nmeFsmContext, nme_on_transition_trace_callback);
    fsm_install_unhandled_event_callback(context->nmeFsmContext, nme_on_unhandled_trace_callback);
    fsm_install_save_event_callback(context->nmeFsmContext, nme_on_saved_trace_callback);
    fsm_install_invalid_event_callback(context->nmeFsmContext, nme_on_invalid_trace_callback);
    fsm_install_ignore_event_callback(context->nmeFsmContext, nme_on_ignored_trace_callback);
#endif

#endif

    registerSignalHandlers();

    /* If no args print the usage incase the user does not know what the help option is */
    if (argc == 1)
    {
        print_usage();
    }

    for (i = 1; i < argc; i++) {

        if (CsrStrNCmp(argv[i], "-ipc_port:", 10) == 0)
        {
#ifdef IPC_IP
            ipc_portNumber = (CsrUint32)atoi(&argv[i][10]);
            sme_trace_info((TR_IPC, "sme_schedule_init() : IPC Port override -> %s :: %d", argv[i], ipc_portNumber));
#endif
            continue;
        }

#ifdef CSR_AMP_ENABLE
        if (CsrStrNCmp(argv[i], "-ipc_hciport:", 13) == 0)
        {
#ifdef IPC_IP
            ipc_hciPortNumber = (CsrUint32)atoi(&argv[i][13]);
            sme_trace_info((TR_IPC, "sme_schedule_init() : HCI IPC Port override -> %s :: %d", argv[i], ipc_hciPortNumber));
#endif
            continue;
        }

        if (CsrStrNCmp(argv[i], "-ipc_aclport:", 13) == 0)
        {
#ifdef IPC_IP
            ipc_aclPortNumber = (CsrUint32)atoi(&argv[i][13]);
            sme_trace_info((TR_IPC, "sme_schedule_init() : ACL IPC Port override -> %s :: %d", argv[i], ipc_aclPortNumber));
#endif
            continue;
        }
#endif

        /* TODO :: This is depricated... Remove! */
        if (CsrStrNCmp(argv[i], "-ipc_connect=", 13) == 0)
        {
#ifdef IPC_CHARDEVICE
            connectStr = &argv[i][13];
            sme_trace_crit((TR_IPC, "sme_schedule_init() : -ipc_connect option is depricated. DO NOT USE!"));
            sme_trace_info((TR_IPC, "sme_schedule_init() : IPC Connect String -> %s :: %s", argv[i], connectStr));
#endif
            continue;
        }

        if (CsrStrNCmp(argv[i], "-dev=", 5) == 0)
        {
#ifdef IPC_CHARDEVICE
            connectStr = &argv[i][5];
            sme_trace_info((TR_IPC, "sme_schedule_init() : char device -> %s :: %s", argv[i], connectStr));
#endif
            continue;
        }
        if (CsrStrNCmp(argv[i], "-paldatadev=", 12) == 0)
        {
            continue;
        }
#ifdef CSR_AMP_ENABLE
        if (CsrStrNCmp(argv[i], "-palselectchannel=", 18) == 0)
        {
            int len = CsrStrLen(argv[i]);
            char* str = (char*)CsrPmalloc(len);
            CsrMemCpy(str,&(argv[i][1]), len-1);
            str[len-1] = '\0';

            sme_trace_info((TR_IPC, "sme_schedule_init() : pal channel to select -> %s :: %d , len-%d,str-%s", argv[i], (CsrUint8)atoi(&argv[i][18]),len,str));
            unifi_dbg_cmd_req(context->fsmContext, str);
            continue;
        }

        if (CsrStrNCmp(argv[i], "-paldisableqos", 18) == 0)
        {
            int len = CsrStrLen(argv[i]);
            char* str = (char*)CsrPmalloc(len);
            CsrMemCpy(str,&(argv[i][1]), len-1);
            str[len-1] = '\0';

            sme_trace_info((TR_IPC, "sme_schedule_init() : disable qos to select -%s , len-%d,str-%s", argv[i],len,str));
            unifi_dbg_cmd_req(context->fsmContext, str);

            continue;
        }

        if (CsrStrNCmp(argv[i], "-paldisablesecurity", 18) == 0)
        {
            int len = CsrStrLen(argv[i]);
            char* str = (char*)CsrPmalloc(len);
            CsrMemCpy(str,&(argv[i][1]), len-1);
            str[len-1] = '\0';

            sme_trace_info((TR_IPC, "sme_schedule_init() : disable qos to select -%s", argv[i]));
            unifi_dbg_cmd_req(context->fsmContext, str);

            continue;
        }
#endif
        if (CsrStrNCmp(argv[i], "-flightmode", 11) == 0)
        {
            flightmode = TRUE;
            sme_trace_info((TR_IPC, "sme_schedule_init() : unifi_mgt_wifi_flightmode_req will be sent on connect -> %s", argv[i]));
            continue;
        }

        if (CsrStrNCmp(argv[i], "-wifion", 7) == 0)
        {
            wifion = TRUE;
            sme_trace_info((TR_IPC, "sme_schedule_init() : unifi_mgt_wifi_on_req will be sent on connect -> %s", argv[i]));
            continue;
        }

        if (CsrStrNCmp(argv[i], "-mac=", 5) == 0)
        {
            loadMacAddress(&argv[i][5], &getMainData(linuxContext)->address);
            sme_trace_info((TR_IPC, "sme_schedule_init() : macAddress file -> %s", argv[i]));
            sme_trace_info((TR_IPC, "sme_schedule_init() : macAddress -> %s", trace_unifi_MACAddress(getMainData(linuxContext)->address, getMainData(linuxContext)->traceMacAddressBuffer)));
            continue;
        }
        if (CsrStrNCmp(argv[i], "-mib=", 5) == 0)
        {
            loadMibfile(&argv[i][5], &getMainData(linuxContext)->mibfiles);
            sme_trace_info((TR_IPC, "sme_schedule_init() : mib file -> %s", argv[i]));
            continue;
        }
        if (CsrStrNCmp(argv[i], "-cal=", 5) == 0)
        {
            getMainData(linuxContext)->calibrationDataFile = &argv[i][5];
            (void)loadfile(getMainData(linuxContext)->calibrationDataFile, &getMainData(linuxContext)->calibrationData);
            sme_trace_info((TR_IPC, "sme_schedule_init() : cal file -> %s", getMainData(linuxContext)->calibrationDataFile));
            continue;
        }
        /* Skip -sme_trace:... as the sme trace module will handle these */
        if (CsrStrNCmp(argv[i], "-sme_trace:", 11) == 0)
        {
            continue;
        }

        if (CsrStrNCmp(argv[i], "-v", CsrStrLen(argv[i])) == 0)
        {
            print_versions();
            exit(EXIT_CODE_NORMAL_EXIT);
        }

        if (CsrStrNCmp(argv[i], "-exitOnError", CsrStrLen(argv[i])) == 0)
        {
            getMainData(linuxContext)->exitOnError = TRUE;
            continue;
        }

        if (CsrStrNCmp(argv[i], "-stopOnError", CsrStrLen(argv[i])) == 0)
        {
            getMainData(linuxContext)->stopOnError = TRUE;
            continue;
        }

        if (CsrStrNCmp(argv[i], "-h", CsrStrLen(argv[i])) == 0)
        {
            print_usage();
            exit(EXIT_CODE_WIFION_ERROR);
        }

        print_usage();
        sme_trace_error((TR_IPC, "error : Unknown commandline option : %s", argv[i]));
        exit(EXIT_CODE_WIFION_ERROR);
    }

#ifdef IPC_CHARDEVICE
    if (connectStr)
    {
        getMainData(context)->charIpcCon = ipc_chardevice_connect(connectStr, NULL, NULL, NULL, NULL);
        if (getMainData(context)->charIpcCon == NULL)
        {
            sme_trace_crit((TR_IPC, "sme_schedule_init() : char device connect to %s failed", connectStr));
            exit(EXIT_CODE_WIFION_ERROR);
        }
    }
#endif

#ifdef IPC_IP
    getMainData(context)->ipIpcCon = ipc_ip_create((int)ipc_portNumber, NULL, NULL, NULL, NULL);
    if (getMainData(context)->ipIpcCon == NULL)
    {
        sme_trace_crit((TR_IPC, "sme_schedule_init() : ipc_create(port:%d) failed", ipc_portNumber));
        exit(EXIT_CODE_WIFION_ERROR);
    }

#ifdef CSR_AMP_ENABLE
    getMainData(context)->ipHciIpcCon = ipc_ip_create((int)ipc_hciPortNumber, NULL, NULL, NULL, NULL);
    if (getMainData(context)->ipHciIpcCon == NULL)
    {
        sme_trace_crit((TR_IPC, "sme_schedule_init() : ipc_create(port:%d) failed", ipc_hciPortNumber));
        exit(EXIT_CODE_WIFION_ERROR);
    }
    getMainData(context)->ipAclIpcCon = ipc_ip_create((int)ipc_aclPortNumber, NULL, NULL, NULL, NULL);
    if (getMainData(context)->ipAclIpcCon == NULL)
    {
        sme_trace_crit((TR_IPC, "sme_schedule_init() : ipc_create(port:%d) failed", ipc_aclPortNumber));
        exit(EXIT_CODE_WIFION_ERROR);
    }
#endif

#endif

    if (getMainData(linuxContext)->calibrationData.length)
    {
        unifi_AppValue appValue;
        appValue.id = unifi_CalibrationDataValue;
        appValue.unifi_Value_union.calibrationData = getMainData(linuxContext)->calibrationData;
        unifi_mgt_claim_sync_access(linuxContext->fsmContext);
        (void)unifi_mgt_set_value(linuxContext->fsmContext, &appValue);
        unifi_mgt_release_sync_access(linuxContext->fsmContext);
    }

    if (flightmode)
    {
        unifi_mgt_wifi_flightmode_req(linuxContext->fsmContext, NULL,
                                      &getMainData(context)->address,
                                      getMainData(linuxContext)->mibfiles.numElements,
                                      getMainData(linuxContext)->mibfiles.dataList);

    }

    if (wifion)
    {
        /* Set the nextCaldataSaveTime to 1 minute from now */
        getMainData(linuxContext)->nextCaldataSaveTime = fsm_get_time_of_day_ms(context->fsmContext) + CALDATA_INITIAL_SAVE_INTERVAL_MS;
        unifi_mgt_wifi_on_req(linuxContext->fsmContext, NULL,
                              &getMainData(context)->address,
                              getMainData(linuxContext)->mibfiles.numElements,
                              getMainData(linuxContext)->mibfiles.dataList);
    }
}