static void wakeup_tracer_close(struct trace_iterator *iter)
{
	/* forget about any processes we were recording */
	if (save_tracer_enabled) {
		wakeup_reset(iter->tr);
		tracer_enabled = 1;
	}
}
示例#2
0
static void wakeup_tracer_reset(struct trace_array *tr)
{
    stop_wakeup_tracer(tr);
    /* make sure we put back any tasks we are tracing */
    wakeup_reset(tr);

    if (!save_lat_flag)
        trace_flags &= ~TRACE_ITER_LATENCY_FMT;
}
示例#3
0
static void start_wakeup_tracer(struct trace_array *tr)
{
    int ret;

    ret = register_trace_sched_wakeup(probe_wakeup);
    if (ret) {
        pr_info("wakeup trace: Couldn't activate tracepoint"
                " probe to kernel_sched_wakeup\n");
        return;
    }

    ret = register_trace_sched_wakeup_new(probe_wakeup);
    if (ret) {
        pr_info("wakeup trace: Couldn't activate tracepoint"
                " probe to kernel_sched_wakeup_new\n");
        goto fail_deprobe;
    }

    ret = register_trace_sched_switch(probe_wakeup_sched_switch);
    if (ret) {
        pr_info("sched trace: Couldn't activate tracepoint"
                " probe to kernel_sched_switch\n");
        goto fail_deprobe_wake_new;
    }

    ret = register_trace_sched_migrate_task(probe_wakeup_migrate_task);
    if (ret) {
        pr_info("wakeup trace: Couldn't activate tracepoint"
                " probe to kernel_sched_migrate_task\n");
        return;
    }

    wakeup_reset(tr);

    /*
     * Don't let the tracer_enabled = 1 show up before
     * the wakeup_task is reset. This may be overkill since
     * wakeup_reset does a spin_unlock after setting the
     * wakeup_task to NULL, but I want to be safe.
     * This is a slow path anyway.
     */
    smp_wmb();

    register_ftrace_function(&trace_ops);

    if (tracing_is_enabled())
        tracer_enabled = 1;
    else
        tracer_enabled = 0;

    return;
fail_deprobe_wake_new:
    unregister_trace_sched_wakeup_new(probe_wakeup);
fail_deprobe:
    unregister_trace_sched_wakeup(probe_wakeup);
}
示例#4
0
static void wakeup_tracer_start(struct trace_array *tr)
{
    wakeup_reset(tr);
    tracer_enabled = 1;
}
示例#5
0
int main(void)
{
	uint8_t buf[HID_OUT_BUFFER_SIZE-1], RepeatCounter = 0;
	IRMP_DATA myIRData;
	int8_t ret;
	/* first wakeup slot empty? */
	uint8_t learn_wakeup = eeprom_restore(buf, (MACRO_DEPTH + 1) * SIZEOF_IR/2 * MACRO_SLOTS);

	USB_HID_Init();
	LED_Switch_init();
	IRMP_Init();
	irsnd_init();
	FLASH_Unlock();
	EE_Init();
	Systick_Init();

	while (1) {
		if (!AlarmValue)
			Wakeup();

		wakeup_reset();

		/* test if USB is connected to PC and command is received */
		if (USB_HID_GetStatus() == USB_HID_CONNECTED && USB_HID_ReceiveData(buf) == RX_READY && buf[0] == STAT_CMD) {

			switch ((enum access) buf[1]) {
			case ACC_GET:
				ret = get_handler(buf);
				break;
			case ACC_SET:
				ret = set_handler(buf);
				break;
			case ACC_RESET:
				ret = reset_handler(buf);
				break;
			default:
				ret = -1;
			}

			if (ret == -1) {
				buf[0] = STAT_FAILURE;
				ret = 3;
			} else {
				buf[0] = STAT_SUCCESS;
			}

			/* send configuration data */
			USB_HID_SendData(REPORT_ID_CONFIG, buf, ret);
			toggle_LED();
		}

		/* poll IR-data */
		if (irmp_get_data(&myIRData)) {
			if (learn_wakeup) {
				/* store received wakeup IRData in first wakeup slot */
				eeprom_store((MACRO_DEPTH + 1) * SIZEOF_IR/2 * MACRO_SLOTS, (uint8_t *) &myIRData);
				learn_wakeup = 0;
			}

			if (!(myIRData.flags)) {
				RepeatCounter = 0;
			} else {
				RepeatCounter++;
			}

			if (RepeatCounter == 0 || RepeatCounter >= MIN_REPEATS) {
				toggle_LED();
				/* if macros are sent already, while the trigger IR data are still repeated,
				 * the receiving device may crash */
				check_macros(&myIRData);
				check_wakeups(&myIRData);
			}

			/* send IR-data */
			memcpy(buf, &myIRData, sizeof(myIRData));
			USB_HID_SendData(REPORT_ID_IR, buf, sizeof(myIRData));
		}
	}
}
示例#6
0
文件: main.c 项目: j1rie/IRMP_STM32
int main(void)
{
	uint8_t buf[HID_OUT_BUFFER_SIZE-1];
	IRMP_DATA myIRData;
	int8_t ret;

	LED_Switch_init();
	Systick_Init();
	USB_Reset();
	USB_HID_Init();
	USB_DISC_release();
	IRMP_Init();
	irsnd_init();
	FLASH_Unlock();
	EE_Init();
	irmp_set_callback_ptr (led_callback);

	while (1) {
		if (!AlarmValue)
			Wakeup();

		if (!send_ir_on_delay)
			send_magic();

		wakeup_reset();

		/* test if USB is connected to PC, sendtransfer is complete and configuration command is received */
		if (USB_HID_GetStatus() == CONFIGURED && PrevXferComplete && USB_HID_ReceiveData(buf) == RX_READY && buf[0] == STAT_CMD) {

			switch ((enum access) buf[1]) {
			case ACC_GET:
				ret = get_handler(buf);
				break;
			case ACC_SET:
				ret = set_handler(buf);
				break;
			case ACC_RESET:
				ret = reset_handler(buf);
				break;
			default:
				ret = -1;
			}

			if (ret == -1) {
				buf[0] = STAT_FAILURE;
				ret = 3;
			} else {
				buf[0] = STAT_SUCCESS;
			}

			/* send configuration data */
			USB_HID_SendData(REPORT_ID_CONFIG, buf, ret);
			blink_LED();
			if(Reboot)
				reboot();
		}

		/* poll IR-data */
		if (irmp_get_data(&myIRData)) {
			myIRData.flags = myIRData.flags & IRMP_FLAG_REPETITION;
			if (!(myIRData.flags)) {
				store_wakeup(&myIRData);
				check_macros(&myIRData);
				check_wakeups(&myIRData);
				check_resets(&myIRData);
				check_reboot(&myIRData);
			}

			/* send IR-data */
			USB_HID_SendData(REPORT_ID_IR, (uint8_t *) &myIRData, sizeof(myIRData));
		}
	}
}
static void wakeup_tracer_reset(struct trace_array *tr)
{
	stop_wakeup_tracer(tr);
	/* make sure we put back any tasks we are tracing */
	wakeup_reset(tr);
}