Exemplo n.º 1
0
/**
* @brief	从保存终端系统参数的存储模块中读取参数保存到全局变量中
* @param[in]  none
* @param[out] 存储终端参数的全局变量
* @return     unsigned char  0  :SUCCESS   else : 错误代码
* @note
*/
int ReadTerminalPara(void)
{
    unsigned long			checkvalue;
    int		ret;

    if (param_mod_state == 0)
    {
        ret = param_init(sizeof(TTerminalPara));
        if (ret)
        {
            if (ret == -3 || ret == -4 || ret == -6)
            {
                ret = param_format(sizeof(TTerminalPara));
                if (ret)
                {
                    return ret;
                }
            }
            else
            {
                return ret;
            }
        }

        param_mod_state = 1;
    }

    ret = param_read((unsigned char*)&g_param,sizeof(TTerminalPara));
    if(ret)
    {
        return ret;
    }



#if 1
    //计算校验值是否正确
    checkvalue = crc32(0,(unsigned char*)&g_param.line_after_mark,sizeof(TTerminalPara) - 4);
    if (g_param.checkvalue != checkvalue)
    {
        //参数的校验值不对
        return 2;
    }

    // 检查参数是否正确
    if ((g_param.endtag[0] != 0x55)||(g_param.endtag[1] != 0xAA)||(g_param.endtag[2] != 0x5A)||(g_param.struct_ver != 1))
    {
        //参数的结束标记不对
        return 3;
    }


    //检查其余参数是否正确
    //@todo....
#endif
    return 0;
}
Exemplo n.º 2
0
void init_once()
{
	_shell_task_id = pthread_self();
	//printf("[init] shell id: %lu\n", (unsigned long)_shell_task_id);
	work_queues_init();
	hrt_work_queue_init();
	hrt_init();
	param_init();
}
Exemplo n.º 3
0
int pbc_param_init_i(pbc_param_ptr p, struct symtab_s *tab) {
    param_init(p);
    params *param = p->data;
    int err = 0;
    err += lookup_int(&param->m, tab, "m");
    err += lookup_int(&param->t, tab, "t");
    err += lookup_mpz(param->n, tab, "n");
    err += lookup_mpz(param->n2, tab, "n2");
    return err;
}
Exemplo n.º 4
0
void user_init(void)
{
#ifdef DEBUG
	uart_init(115200, 115200);
#endif
	INFO("\r\nWelcom to Noduino Open miniK Plug!\r\n");
	INFO("Current firmware is user%d.bin\r\n", system_upgrade_userbin_check()+1);
	INFO("%s", noduino_banner);

	param_init();
	led_init();
	relay_init();
	xkey_init();

	// restore the relay status quickly
	relay_set_status(param_get_status());

	system_init_done_cb(init_yun);
}
Exemplo n.º 5
0
static void 
agurim_init(void)
{
	param_init();
}
Exemplo n.º 6
0
__EXPORT int board_app_initialize(uintptr_t arg)
{

#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)

	/* run C++ ctors before we go any further */

	up_cxxinitialize();

#	if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE)
#  		error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE.
#	endif

#else
#  error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined.
#endif

	/* configure the high-resolution time/callout interface */
	hrt_init();

	param_init();

	/* configure the DMA allocator */

	if (board_dma_alloc_init() < 0) {
		message("DMA alloc FAILED");
	}

	/* configure CPU load estimation */
#ifdef CONFIG_SCHED_INSTRUMENTATION
	cpuload_initialize_once();
#endif

	/* set up the serial DMA polling */
	static struct hrt_call serial_dma_call;
	struct timespec ts;

	/*
	 * Poll at 1ms intervals for received bytes that have not triggered
	 * a DMA event.
	 */
	ts.tv_sec = 0;
	ts.tv_nsec = 1000000;

	hrt_call_every(&serial_dma_call,
		       ts_to_abstime(&ts),
		       ts_to_abstime(&ts),
		       (hrt_callout)stm32_serial_dma_poll,
		       NULL);

#if defined(CONFIG_STM32_BBSRAM)

	/* NB. the use of the console requires the hrt running
	 * to poll the DMA
	 */

	/* Using Battery Backed Up SRAM */

	int filesizes[CONFIG_STM32_BBSRAM_FILES + 1] = BSRAM_FILE_SIZES;

	stm32_bbsraminitialize(BBSRAM_PATH, filesizes);

#if defined(CONFIG_STM32_SAVE_CRASHDUMP)

	/* Panic Logging in Battery Backed Up Files */

	/*
	 * In an ideal world, if a fault happens in flight the
	 * system save it to BBSRAM will then reboot. Upon
	 * rebooting, the system will log the fault to disk, recover
	 * the flight state and continue to fly.  But if there is
	 * a fault on the bench or in the air that prohibit the recovery
	 * or committing the log to disk, the things are too broken to
	 * fly. So the question is:
	 *
	 * Did we have a hard fault and not make it far enough
	 * through the boot sequence to commit the fault data to
	 * the SD card?
	 */

	/* Do we have an uncommitted hard fault in BBSRAM?
	 *  - this will be reset after a successful commit to SD
	 */
	int hadCrash = hardfault_check_status("boot");

	if (hadCrash == OK) {

		message("[boot] There is a hard fault logged. Hold down the SPACE BAR," \
			" while booting to halt the system!\n");

		/* Yes. So add one to the boot count - this will be reset after a successful
		 * commit to SD
		 */

		int reboots = hardfault_increment_reboot("boot", false);

		/* Also end the misery for a user that holds for a key down on the console */

		int bytesWaiting;
		ioctl(fileno(stdin), FIONREAD, (unsigned long)((uintptr_t) &bytesWaiting));

		if (reboots > 2 || bytesWaiting != 0) {

			/* Since we can not commit the fault dump to disk. Display it
			 * to the console.
			 */

			hardfault_write("boot", fileno(stdout), HARDFAULT_DISPLAY_FORMAT, false);

			message("[boot] There were %d reboots with Hard fault that were not committed to disk - System halted %s\n",
				reboots,
				(bytesWaiting == 0 ? "" : " Due to Key Press\n"));


			/* For those of you with a debugger set a break point on up_assert and
			 * then set dbgContinue = 1 and go.
			 */

			/* Clear any key press that got us here */

			static volatile bool dbgContinue = false;
			int c = '>';

			while (!dbgContinue) {

				switch (c) {

				case EOF:


				case '\n':
				case '\r':
				case ' ':
					continue;

				default:

					putchar(c);
					putchar('\n');

					switch (c) {

					case 'D':
					case 'd':
						hardfault_write("boot", fileno(stdout), HARDFAULT_DISPLAY_FORMAT, false);
						break;

					case 'C':
					case 'c':
						hardfault_rearm("boot");
						hardfault_increment_reboot("boot", true);
						break;

					case 'B':
					case 'b':
						dbgContinue = true;
						break;

					default:
						break;
					} // Inner Switch

					message("\nEnter B - Continue booting\n" \
						"Enter C - Clear the fault log\n" \
						"Enter D - Dump fault log\n\n?>");
					fflush(stdout);

					if (!dbgContinue) {
						c = getchar();
					}

					break;

				} // outer switch
			} // for

		} // inner if
	} // outer if

#endif // CONFIG_STM32_SAVE_CRASHDUMP
#endif // CONFIG_STM32_BBSRAM

	/* initial LED state */
	drv_led_start();
	led_off(LED_RED);
	led_off(LED_GREEN);
	led_off(LED_BLUE);

#ifdef CONFIG_SPI
	int ret = stm32_spi_bus_initialize();

	if (ret != OK) {
		board_autoled_on(LED_RED);
		return ret;
	}

#endif

#ifdef CONFIG_MMCSD
	ret = stm32_sdio_initialize();

	if (ret != OK) {
		board_autoled_on(LED_RED);
		return ret;
	}

#endif

	return OK;
}
Exemplo n.º 7
0
const char *param (const char *key) /* {{{ */
{
  param_init ();

  return (param_get (pl_global, key));
} /* }}} const char *param */
Exemplo n.º 8
0
int main(int argc, char *argv[])
{
    int rc = 0;
    volatile int disassemble = 0;
    volatile int flags = 0;

    volatile int opened = 0;
    char outfname[1044];
    FILE * volatile out = stdout;

    struct param_state *params = NULL;
    param_init(&params);

    if ((rc = setjmp(errbuf))) {
        if (rc == DISPLAY_USAGE)
            usage(argv[0]);
        if (opened && out)
            // Technically there is a race condition here ; we would like to be
            // able to remove a file by a stream connected to it, but there is
            // apparently no portable way to do this.
            remove(outfname);
        return EXIT_FAILURE;
    }

    const struct format *f = &tenyr_asm_formats[0];

    int ch;
    while ((ch = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
        switch (ch) {
            case 'd': disassemble = 1; break;
            case 'f': if (find_format(optarg, &f)) usage(argv[0]), exit(EXIT_FAILURE); break;
            case 'o': out = fopen(strncpy(outfname, optarg, sizeof outfname - 1), "wb"); opened = 1; break;
            case 'p': param_add(params, optarg); break;
            case 'q': flags |= ASM_QUIET; break;
            case 'v': flags |= ASM_VERBOSE; break;

            case 'V': puts(version()); return EXIT_SUCCESS;
            case 'h':
                usage(argv[0]);
                return EXIT_FAILURE;
            default:
                usage(argv[0]);
                return EXIT_FAILURE;
        }
    }

    if (optind >= argc)
        fatal(DISPLAY_USAGE, "No input files specified on the command line");

#if _WIN32
    if (!disassemble)
        // ensure we are in binary mode on Windows
        if (out == stdout && setmode(1, O_BINARY) == -1)
            fatal(0, "Failed to set binary mode on stdout ; use -ofilename to avoid corrupted binaries.");
#endif

    for (int i = optind; i < argc; i++) {
        FILE *in = NULL;
        if (!out)
            fatal(PRINT_ERRNO, "Failed to open output file");

        if (!strcmp(argv[i], "-")) {
            in = stdin;
        } else {
            in = fopen(argv[i], "rb");
            if (!in)
                fatal(PRINT_ERRNO, "Failed to open input file `%s'", argv[i]);
        }

        param_set(params, "assembling", (int[]){ !disassemble }, 1, false, false);
        void *ud = NULL;
        FILE *stream = disassemble ? in : out;
        if (f->init)
            if (f->init(stream, params, &ud))
                fatal(0, "Error during initialisation for format '%s'", f->name);

        if (disassemble) {
            // This output might be consumed by a tool that needs a line at a time
            setvbuf(out, NULL, _IOLBF, 0);
            if (f->in) {
                rc = do_disassembly(in, out, f, ud, flags);
            } else {
                fatal(0, "Format `%s' does not support disassembly", f->name);
            }
        } else {
            if (f->out) {
                rc = do_assembly(in, out, f, ud);
            } else {
                fatal(0, "Format `%s' does not support assembly", f->name);
            }
        }

        if (!rc && f->emit)
            rc |= f->emit(stream, &ud);
        else if (rc)
            remove(outfname); // race condition ?

        if (f->fini)
            rc |= f->fini(stream, &ud);

        fflush(out);

        fclose(in);
    }
Exemplo n.º 9
0
static int set_params(struct pcm *pcm)
{
     struct snd_pcm_hw_params *params;
     struct snd_pcm_sw_params *sparams;

     unsigned long periodSize, bufferSize, reqBuffSize;
     unsigned int periodTime, bufferTime;
     unsigned int requestedRate = pcm->rate;
     int channels = (pcm->flags & PCM_MONO) ? 1 : ((pcm->flags & PCM_5POINT1)? 6 : 2 );

     params = (struct snd_pcm_hw_params*) calloc(1, sizeof(struct snd_pcm_hw_params));
     if (!params) {
          fprintf(stderr, "Aplay:Failed to allocate ALSA hardware parameters!");
          return -ENOMEM;
     }

     param_init(params);

     param_set_mask(params, SNDRV_PCM_HW_PARAM_ACCESS,
                    (pcm->flags & PCM_MMAP)? SNDRV_PCM_ACCESS_MMAP_INTERLEAVED : SNDRV_PCM_ACCESS_RW_INTERLEAVED);
     param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT, pcm->format);
     param_set_mask(params, SNDRV_PCM_HW_PARAM_SUBFORMAT,
                    SNDRV_PCM_SUBFORMAT_STD);
     if (period)
         param_set_min(params, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, period);
     else
         param_set_min(params, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 10);
     param_set_int(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 16);
     param_set_int(params, SNDRV_PCM_HW_PARAM_FRAME_BITS,
                    pcm->channels * 16);
     param_set_int(params, SNDRV_PCM_HW_PARAM_CHANNELS,
                    pcm->channels);
     param_set_int(params, SNDRV_PCM_HW_PARAM_RATE, pcm->rate);
     param_set_hw_refine(pcm, params);

     if (param_set_hw_params(pcm, params)) {
         fprintf(stderr, "Aplay:cannot set hw params\n");
         return -errno;
     }
     if (debug)
         param_dump(params);

     pcm->buffer_size = pcm_buffer_size(params);
     pcm->period_size = pcm_period_size(params);
     pcm->period_cnt = pcm->buffer_size/pcm->period_size;
     if (debug) {
        fprintf (stderr,"period_cnt = %d\n", pcm->period_cnt);
        fprintf (stderr,"period_size = %d\n", pcm->period_size);
        fprintf (stderr,"buffer_size = %d\n", pcm->buffer_size);
     }
     sparams = (struct snd_pcm_sw_params*) calloc(1, sizeof(struct snd_pcm_sw_params));
     if (!sparams) {
         fprintf(stderr, "Aplay:Failed to allocate ALSA software parameters!\n");
         return -ENOMEM;
     }
     // Get the current software parameters
    sparams->tstamp_mode = SNDRV_PCM_TSTAMP_NONE;
    sparams->period_step = 1;

    sparams->avail_min = pcm->period_size/(channels * 2) ;
    sparams->start_threshold =  pcm->period_size/(channels * 2) ;
    sparams->stop_threshold =  pcm->buffer_size ;
    sparams->xfer_align =  pcm->period_size/(channels * 2) ; /* needed for old kernels */

    sparams->silence_size = 0;
    sparams->silence_threshold = 0;

    if (param_set_sw_params(pcm, sparams)) {
        fprintf(stderr, "Aplay:cannot set sw params");
        return -errno;
    }
    if (debug) {
       fprintf (stderr,"sparams->avail_min= %lu\n", sparams->avail_min);
       fprintf (stderr," sparams->start_threshold= %lu\n", sparams->start_threshold);
       fprintf (stderr," sparams->stop_threshold= %lu\n", sparams->stop_threshold);
       fprintf (stderr," sparams->xfer_align= %lu\n", sparams->xfer_align);
       fprintf (stderr," sparams->boundary= %lu\n", sparams->boundary);
    }
    return 0;
}
Exemplo n.º 10
0
int start(void)
{
    int i, result;

    printf("mm_init()\n");
    result = mm_init();
    if (result != 0)
        goto error;

    printf("param_init()\n");
    result = param_init();
    if (result != 0)
        goto error;

    printf("gelic_init()\n");
    result = gelic_init();
    if (result != 0)
        goto error;

    printf("gelic_xmit_test()\n");
    result = gelic_xmit_test();
    if (result != 0)
        goto error;

    /*
    printf("gelic_recv_test()\n");
    result = gelic_recv_test();
    if (result != 0)
    	goto error;
    */

    /*
    printf("dump_lv2()\n");
    result = dump_lv2(0x8000000000000000ULL, 64 * 1024 * 1024);
    if (result != 0)
    	goto error;
    */

    /*
    printf("dump_slb()\n");
    result = dump_slb();
    if (result != 0)
    	goto error;
    */

    /*
    printf("dump_sprg0()\n");
    result = dump_sprg0();
    if (result != 0)
    	goto error;
    */

    /*
    printf("dump_htab()\n");
    result = dump_htab();
    if (result != 0)
    	goto error;
    */

    /*
    printf("dump_stor()\n");
    result = dump_stor();
    if (result != 0)
    	goto error;
    */

    printf("dump_flash()\n");
    result = dump_flash();
    if (result != 0)
        goto error;

    /*
    printf("dump_repo_nodes()\n");
    result = dump_repo_nodes();
    if (result != 0)
    	goto error;
    */

    /*
    printf("dump_repo_nodes_spu()\n");
    result = dump_repo_nodes_spu();
    if (result != 0)
    	goto error;
    */

    /*
    printf("dump_profile()\n");
    result = dump_profile();
    if (result != 0)
    	goto error;
    */

    /*
    printf("decrypt_profile()\n");
    result = decrypt_profile();
    if (result != 0)
    	goto error;
    */

    /*
    printf("vuart_sysmgr()\n");
    result = vuart_sysmgr();
    if (result != 0)
    	goto error;
    */

    /*
    printf("vuart_dispmgr()\n");
    result = vuart_dispmgr();
    if (result != 0)
    	goto error;
    */

    /*
    printf("decrypt_usb_dongle_master_key()\n");
    result = decrypt_usb_dongle_master_key();
    if (result != 0)
    	goto error;
    */

    /*
    printf("update_mgr_inspect_pkg()\n");
    result = update_mgr_inspect_pkg();
    if (result != 0)
    	goto error;
    */

    /*
    printf("query_lpar_address()\n");
    result = query_lpar_address();
    if (result != 0)
    	goto error;
    */

    /*
    printf("decrypt_pkg()\n");
    result = decrypt_pkg();
    if (result != 0)
    	goto error;
    */

    return 0;

error:
    return -1;
}
Exemplo n.º 11
0
int main(void)
{
	int i, result;

	result = mm_init();
	if (result != 0)
		goto error;

	result = param_init();
	if (result != 0)
		goto error;

	result = gelic_init();
	if (result != 0)
		goto error;

	patch_dispmgr();

	/*
	result = gelic_xmit_test();
	if (result != 0)
		goto error;
	*/

	/*
	result = gelic_recv_test();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_lv2(0x8000000000000000ULL, 8 * 1024 * 1024);
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_slb();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_sprg0();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_htab();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_stor();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_flash();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_repo_nodes();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_repo_nodes_spu();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_profile();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_profile();
	if (result != 0)
		goto error;
	*/

	/*
	result = vuart_sysmgr();
	if (result != 0)
		goto error;
	*/

	/*
	result = vuart_dispmgr();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_usb_dongle_master_key();
	if (result != 0)
		goto error;
	*/

	/*
	result = update_mgr_qa_flag();
	if (result != 0)
		goto error;
	*/

	/*
	result = update_mgr_get_token_seed();
	if (result != 0)
		goto error;
	*/

	/*
	result = update_mgr_set_token();
	if (result != 0)
		goto error;
	*/

	/*
	result = update_mgr_inspect_pkg();
	if (result != 0)
		goto error;
	*/

	/*
	result = query_lpar_address();
	if (result != 0)
		goto error;
	*/

	/*
	result = update_mgr_calc_token();
	if (result != 0)
		goto error;
	*/

	/*
	result = update_mgr_verify_token();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_pkg();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_self();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_hvcall99_param();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_npdrm();
	if (result != 0)
		goto error;
	*/

	/*
	result = self_decrypter_hook();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_game();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_lv2_direct();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_lv2_direct_355();
	if (result != 0)
		goto error;
	*/

	/*
	result = usb_dongle_auth();
	if (result != 0)
		goto error;
	*/

	/*
	result = product_mode_off();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_self_direct();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_self_direct_355();
	if (result != 0)
		goto error;
	*/

	/*
	result = vuart_hook();
	if (result != 0)
		goto error;
	*/

	/*
	result = stor_hook();
	if (result != 0)
		goto error;
	*/

	/*
	result = hvcall209_hook();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_lpar_ra();
	if (result != 0)
		goto error;
	*/

	/*
	result = hv_mmap_exploit();
	if (result != 0)
		goto error;
	*/

	/*
	result = dump_lv1();
	if (result != 0)
		goto error;
	*/

	/*
	result = sc_mgr_read_eprom();
	if (result != 0)
		goto error;
	*/

	/*
	result = sc_mgr_get_region_data();
	if (result != 0)
		goto error;
	*/

	/*
	result = sc_mgr_get_sc_status();
	if (result != 0)
		goto error;
	*/

	/*
	result = sc_mgr_get_srh();
	if (result != 0)
		goto error;
	*/

	/*
	result = aim_get_device_type();
	if (result != 0)
		goto error;
	*/

	/*
	result = aim_get_device_id();
	if (result != 0)
		goto error;
	*/

	/*
	result = aim_get_ps_code();
	if (result != 0)
		goto error;
	*/

	/*
	result = aim_get_open_ps_id();
	if (result != 0)
		goto error;
	*/

	/*
	result = decrypt_profile_direct();
	if (result != 0)
		goto error;
	*/

	/*
	result = sc_iso_sc_binary_patch();
	if (result != 0)
		goto error;
	*/

	/*
	result = sc_iso_get_sc_status();
	if (result != 0)
		goto error;
	*/

	/*
	result = sc_iso_get_property();
	if (result != 0)
		goto error;
	*/

	/*
	result = sb_iso_get_rnd();
	if (result != 0)
		goto error;
	*/

	/*
	result = sb_iso_encdec_key();
	if (result != 0)
		goto error;
	*/

	/*
	result = edec_kgen1();
	if (result != 0)
		goto error;
	*/

	/*
	result = store_file_on_flash();
	if (result != 0)
		goto error;
	*/

	/*
	result = replace_lv2();
	if (result != 0)
		goto error;
	*/

	result = dump_dev_flash();
	if (result != 0)
		goto error;

	return 0;

done:

	lv1_panic(0);

	return 0;

error:

	lv1_panic(1);
}
Exemplo n.º 12
0
__EXPORT int board_app_initialize(uintptr_t arg)
{
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)

	/* run C++ ctors before we go any further */

	up_cxxinitialize();

#       if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE)
#               error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE.
#       endif

#else
#  error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined.
#endif

	/* configure the high-resolution time/callout interface */
	hrt_init();

	param_init();

	/* configure the DMA allocator */

	if (board_dma_alloc_init() < 0) {
		message("DMA alloc FAILED");
	}

	/* configure CPU load estimation */
#ifdef CONFIG_SCHED_INSTRUMENTATION
	cpuload_initialize_once();
#endif

	/* set up the serial DMA polling */
	static struct hrt_call serial_dma_call;
	struct timespec ts;

	/*
	 * Poll at 1ms intervals for received bytes that have not triggered
	 * a DMA event.
	 */
	ts.tv_sec = 0;
	ts.tv_nsec = 1000000;

	hrt_call_every(&serial_dma_call,
		       ts_to_abstime(&ts),
		       ts_to_abstime(&ts),
		       (hrt_callout)stm32_serial_dma_poll,
		       NULL);

	/* initial LED state */
	drv_led_start();
	led_off(LED_AMBER);

	/* Configure SPI-based devices */

	spi3 = px4_spibus_initialize(3);

	if (!spi3) {
		message("[boot] FAILED to initialize SPI port 3\n");
		board_autoled_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI3 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi3, 10000000);
	SPI_SETBITS(spi3, 8);
	SPI_SETMODE(spi3, SPIDEV_MODE3);
	SPI_SELECT(spi3, PX4_SPIDEV_GYRO, false);
	SPI_SELECT(spi3, PX4_SPIDEV_ACCEL_MAG, false);
	SPI_SELECT(spi3, PX4_SPIDEV_BARO, false);
	up_udelay(20);

	/* Get the SPI port for the FRAM */

	spi4 = px4_spibus_initialize(4);

	if (!spi4) {
		message("[boot] FAILED to initialize SPI port 4\n");
		board_autoled_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI4 to 37.5 MHz (40 MHz rounded to nearest valid divider, F4 max)
	 * and de-assert the known chip selects. */

	// XXX start with 10.4 MHz in FRAM usage and go up to 37.5 once validated
	SPI_SETFREQUENCY(spi4, 12 * 1000 * 1000);
	SPI_SETBITS(spi4, 8);
	SPI_SETMODE(spi4, SPIDEV_MODE3);
	SPI_SELECT(spi4, SPIDEV_FLASH(0), false);

	return OK;
}
Exemplo n.º 13
0
void pbc_param_init_i_gen(pbc_param_ptr par, int group_size) {
    param_init(par);
    params *p = par->data;
    if (group_size <= 150) {
        p->m = 97;
        p->t = 12;
        mpz_set_str(p->n, "2726865189058261010774960798134976187171462721", 10);
        mpz_set_str(p->n2, "7", 10);
    } else if (group_size <= 206) {
        p->m = 199;
        p->t = 164;
        mpz_set_str(p->n, "167725321489096000055336949742738378351010268990525380470313869", 10);
        mpz_set_str(p->n2, "527874953560391326545598291952743", 10);
    } else if (group_size <= 259) {
        p->m = 235;
        p->t = 26;
        mpz_set_str(p->n, "1124316700897695330265827797088699345032488681307846555184025129863722718180241", 10);
        mpz_set_str(p->n2, "11819693021332914275777073321995059", 10);
    } else if (group_size <= 316) {
        p->m = 385;
        p->t = 22;
        mpz_set_str(p->n, "140884762419712839999909157778648717913595360839856026704744558309545986970238264714753014287541", 10);
        mpz_set_str(p->n2, "34899486997246711147841377458771182755186809219564106252058066150110543296498189654810187", 10);
    } else if (group_size <= 376) {
        p->m = 337;
        p->t = 30;
        mpz_set_str(p->n, "250796519030408069744426774377542635685621984993105288007781750196791322190409525696108840742205849171229571431053", 10);
        mpz_set_str(p->n2, "245777055088325363697128811262733732423405120899", 10);
    } else if (group_size <= 430) {
        p->m = 373;
        p->t = 198;
        mpz_set_str(p->n, "2840685307599487500956683789051368080919805957805957356540760731597378326586402072132959867084691357708217739285576524329854284197", 10);
        mpz_set_str(p->n2, "3256903458766749542151641063558247849550904613763", 10);
    } else if (group_size <= 484) {
        p->m = 395;
        p->t = 338;
        mpz_set_str(p->n, "80172097064154181257340545445945701478615643539554910656655431171167598268341527430200810544156625333601812351266052856520678455274751591367269291", 10);
        mpz_set_str(p->n2, "3621365590261279902324876775553649595261567", 10);
    } else if (group_size <= 552) {
        p->m = 433;
        p->t = 120;
        mpz_set_str(p->n, "15699907553631673835088720676147779193076555382157913339177784853763686462870506492752576492212322736133645158157557950634628006965882177348385366381692092784577773463", 10);
        mpz_set_str(p->n2, "24980791723059119877470531054938874784049", 10);
    } else if (group_size <= 644) {
        p->m = 467;
        p->t = 48;
        mpz_set_str(p->n, "108220469499363631995525712756135494735252733492048868417164002000654321383482753640072319529019505742300964525569770933946381504691909098938045089999753901375631613294579329433690943459352138231", 10);
        mpz_set_str(p->n2, "60438898450096967424971813347", 10);
    } else if (group_size <= 696) {
        p->m = 503;
        p->t = 104;
        mpz_set_str(p->n, "545523657676112447260904563578912738373307867219686215849632469801471112426878939776725222290437653718473962733760874627315930933126581248465899651120481066111839081575164964589811985885719017214938514563804313", 10);
        mpz_set_str(p->n2, "1799606423432800810122901025413", 10);
    } else if (group_size <= 803) {
        p->m = 509;
        p->t = 358;
        mpz_set_str(p->n, "102239946202586852409809887418093021457150612495255706614733003327526279081563687830782748305746187060264985869283524441819589592750998086186315250781067131293823177124077445718802216415539934838376431091001197641295264650596195201747790167311", 10);
        mpz_set_str(p->n2, "7", 10);
    } else if (group_size <= 892) {
        p->m = 617;
        p->t = 88;
        mpz_set_str(p->n, "57591959284219511220590893724691916802833742568034971006633345422620650391172287893878655658086794200963521584019889327992536532560877385225451713282279597074750857647455565899702728629166541223955196002755787520206774906606158388947359746178875040401304783332742806641", 10);
        mpz_set_str(p->n2, "42019638181715250622338241", 10);
    } else
        pbc_die("unsupported group size");
}
Exemplo n.º 14
0
__EXPORT int board_app_initialize(uintptr_t arg)
{

#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)

	/* run C++ ctors before we go any further */

	up_cxxinitialize();

#	if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE)
#  		error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE.
#	endif

#else
#  error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined.
#endif

	/* configure the high-resolution time/callout interface */

	hrt_init();

	param_init();

	/* configure the DMA allocator */

	if (board_dma_alloc_init() < 0) {
		message("DMA alloc FAILED");
	}

	/* configure CPU load estimation */
#ifdef CONFIG_SCHED_INSTRUMENTATION
	cpuload_initialize_once();
#endif

	/* set up the serial DMA polling */
	static struct hrt_call serial_dma_call;
	struct timespec ts;

	/*
	 * Poll at 1ms intervals for received bytes that have not triggered
	 * a DMA event.
	 */
	ts.tv_sec = 0;
	ts.tv_nsec = 1000000;

	hrt_call_every(&serial_dma_call,
		       ts_to_abstime(&ts),
		       ts_to_abstime(&ts),
		       (hrt_callout)stm32_serial_dma_poll,
		       NULL);

#if defined(CONFIG_STM32_BBSRAM)

	/* NB. the use of the console requires the hrt running
	 * to poll the DMA
	 */

	/* Using Battery Backed Up SRAM */

	int filesizes[CONFIG_STM32_BBSRAM_FILES + 1] = BSRAM_FILE_SIZES;

	stm32_bbsraminitialize(BBSRAM_PATH, filesizes);

#if defined(CONFIG_STM32_SAVE_CRASHDUMP)

	/* Panic Logging in Battery Backed Up Files */

	/*
	 * In an ideal world, if a fault happens in flight the
	 * system save it to BBSRAM will then reboot. Upon
	 * rebooting, the system will log the fault to disk, recover
	 * the flight state and continue to fly.  But if there is
	 * a fault on the bench or in the air that prohibit the recovery
	 * or committing the log to disk, the things are too broken to
	 * fly. So the question is:
	 *
	 * Did we have a hard fault and not make it far enough
	 * through the boot sequence to commit the fault data to
	 * the SD card?
	 */

	/* Do we have an uncommitted hard fault in BBSRAM?
	 *  - this will be reset after a successful commit to SD
	 */
	int hadCrash = hardfault_check_status("boot");

	if (hadCrash == OK) {

		message("[boot] There is a hard fault logged. Hold down the SPACE BAR," \
			" while booting to halt the system!\n");

		/* Yes. So add one to the boot count - this will be reset after a successful
		 * commit to SD
		 */

		int reboots = hardfault_increment_reboot("boot", false);

		/* Also end the misery for a user that holds for a key down on the console */

		int bytesWaiting;
		ioctl(fileno(stdin), FIONREAD, (unsigned long)((uintptr_t) &bytesWaiting));

		if (reboots > 2 || bytesWaiting != 0) {

			/* Since we can not commit the fault dump to disk. Display it
			 * to the console.
			 */

			hardfault_write("boot", fileno(stdout), HARDFAULT_DISPLAY_FORMAT, false);

			message("[boot] There were %d reboots with Hard fault that were not committed to disk - System halted %s\n",
				reboots,
				(bytesWaiting == 0 ? "" : " Due to Key Press\n"));


			/* For those of you with a debugger set a break point on up_assert and
			 * then set dbgContinue = 1 and go.
			 */

			/* Clear any key press that got us here */

			static volatile bool dbgContinue = false;
			int c = '>';

			while (!dbgContinue) {

				switch (c) {

				case EOF:


				case '\n':
				case '\r':
				case ' ':
					continue;

				default:

					putchar(c);
					putchar('\n');

					switch (c) {

					case 'D':
					case 'd':
						hardfault_write("boot", fileno(stdout), HARDFAULT_DISPLAY_FORMAT, false);
						break;

					case 'C':
					case 'c':
						hardfault_rearm("boot");
						hardfault_increment_reboot("boot", true);
						break;

					case 'B':
					case 'b':
						dbgContinue = true;
						break;

					default:
						break;
					} // Inner Switch

					message("\nEnter B - Continue booting\n" \
						"Enter C - Clear the fault log\n" \
						"Enter D - Dump fault log\n\n?>");
					fflush(stdout);

					if (!dbgContinue) {
						c = getchar();
					}

					break;

				} // outer switch
			} // for

		} // inner if
	} // outer if

#endif // CONFIG_STM32_SAVE_CRASHDUMP
#endif // CONFIG_STM32_BBSRAM

	/* initial LED state */
	drv_led_start();
	led_off(LED_AMBER);

	/* Configure SPI-based devices */

	spi4 = px4_spibus_initialize(4);

	if (!spi4) {
		message("[boot] FAILED to initialize SPI port 4\n");
		board_autoled_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI4 to 10MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi4, 10000000);
	SPI_SETBITS(spi4, 8);
	SPI_SETMODE(spi4, SPIDEV_MODE3);
	SPI_SELECT(spi4, PX4_SPIDEV_GYRO, false);
	SPI_SELECT(spi4, PX4_SPIDEV_ACCEL_MAG, false);
	SPI_SELECT(spi4, PX4_SPIDEV_BARO, false);
	SPI_SELECT(spi4, PX4_SPIDEV_MPU, false);
	up_udelay(20);

	/* Get the SPI port for the FRAM */

	spi1 = stm32_spibus_initialize(1);

	if (!spi1) {
		message("[boot] FAILED to initialize SPI port 1\n");
		board_autoled_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI1 to 37.5 MHz (40 MHz rounded to nearest valid divider, F4 max)
	 * and de-assert the known chip selects. */

	// XXX start with 10.4 MHz in FRAM usage and go up to 37.5 once validated
	SPI_SETFREQUENCY(spi1, 24 * 1000 * 1000);
	SPI_SETBITS(spi1, 8);
	SPI_SETMODE(spi1, SPIDEV_MODE3);
	SPI_SELECT(spi1, SPIDEV_FLASH, false);


	spi2 = px4_spibus_initialize(2);

	/* Default SPI2 to 10MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi2, 10000000);
	SPI_SETBITS(spi2, 8);
	SPI_SETMODE(spi2, SPIDEV_MODE3);
	SPI_SELECT(spi2, PX4_SPIDEV_EXT0, false);


#ifdef CONFIG_MMCSD
	/* First, get an instance of the SDIO interface */

	sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);

	if (!sdio) {
		message("[boot] Failed to initialize SDIO slot %d\n",
			CONFIG_NSH_MMCSDSLOTNO);
		return -ENODEV;
	}

	/* Now bind the SDIO interface to the MMC/SD driver */
	int ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio);

	if (ret != OK) {
		message("[boot] Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
		return ret;
	}

	/* Then let's guess and say that there is a card in the slot. There is no card detect GPIO. */
	sdio_mediachange(sdio, true);

#endif

	return OK;
}
Exemplo n.º 15
0
__EXPORT int board_app_initialize(uintptr_t arg)
{

	/* configure ADC pins */

	/* configure power supply control/sense pins */

#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)

	/* run C++ ctors before we go any further */

	up_cxxinitialize();

#	if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE)
#  		error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE.
#	endif

#else
#  error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined.
#endif

	/* configure the high-resolution time/callout interface */
	hrt_init();

	param_init();

	/* configure the DMA allocator */

	if (board_dma_alloc_init() < 0) {
		message("DMA alloc FAILED");
	}

	/* configure CPU load estimation */
#ifdef CONFIG_SCHED_INSTRUMENTATION
	cpuload_initialize_once();
#endif


	/* initial LED state */
	drv_led_start();
	led_on(LED_AMBER);
	led_off(LED_AMBER);

	/* Configure SPI-based devices */

	spi0 = px4_spibus_initialize(PX4_SPI_BUS_SENSORS);

	if (!spi0) {
		message("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_SENSORS);
		board_autoled_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI1 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi0, 10000000);
	SPI_SETBITS(spi0, 8);
	SPI_SETMODE(spi0, SPIDEV_MODE3);
	SPI_SELECT(spi0, PX4_SPIDEV_GYRO, false);
	SPI_SELECT(spi0, PX4_SPIDEV_ACCEL_MAG, false);
	SPI_SELECT(spi0, PX4_SPIDEV_BARO, false);
	SPI_SELECT(spi0, PX4_SPIDEV_MPU, false);
	up_udelay(20);

#if defined(CONFIG_SAMV7_SPI1_MASTER)
	spi1 = px4_spibus_initialize(PX4_SPI_BUS_MEMORY);

	/* Default SPI4 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi1, 10000000);
	SPI_SETBITS(spi1, 8);
	SPI_SETMODE(spi1, SPIDEV_MODE3);
	SPI_SELECT(spi1, PX4_SPIDEV_EXT0, false);
	SPI_SELECT(spi1, PX4_SPIDEV_EXT1, false);
#endif

#ifdef CONFIG_MMCSD
	/* First, get an instance of the SDIO interface */

	sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);

	if (!sdio) {
		message("[boot] Failed to initialize SDIO slot %d\n",
			CONFIG_NSH_MMCSDSLOTNO);
		return -ENODEV;
	}

	/* Now bind the SDIO interface to the MMC/SD driver */
	int ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio);

	if (ret != OK) {
		message("[boot] Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
		return ret;
	}

	/* Then let's guess and say that there is a card in the slot. There is no card detect GPIO. */
	sdio_mediachange(sdio, true);

#endif

	return OK;
}