Ejemplo n.º 1
0
static int watchdog_probe(struct platform_device *pdev)
{
	wd_clk = clk_get(NULL, "watchdog");
	BUG_ON(!wd_clk);
	clk_enable(wd_clk);

	spin_lock_init(&wdt_lock);

	/* watchdog can be disabled by providing either
	 * "exynos4210_watchdog.sec_pet=0" or
	 * "exynos4210_watchdog.sec_reset=0" to CMDLINE */
	if (!watchdog_reset || !watchdog_pet) {
		clk_disable(wd_clk);
		return -ENODEV;
	}

#if defined(PET_BY_WORKQUEUE)
	watchdog_wq = create_singlethread_workqueue("pet_watchdog");
	watchdog_start();
#elif defined(PET_BY_DIRECT_TIMER)
	init_timer(&pet_watchdog_timer);
	pet_watchdog_timer.function = pet_watchdog_timer_fn;
	watchdog_start();
#else
	hrtimer_init(&watchdog_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	watchdog_timer.function = watchdog_timerfunc;
	watchdog_start();
#endif

	return 0;
}
static int watchdog_open(struct inode *inode, struct file *file)
{
	int err = -EBUSY;

	/* the watchdog is single open! */
	if (test_and_set_bit(WDOG_DEV_OPEN, &wdd->status))
		return -EBUSY;

	/*
	 * If the /dev/watchdog device is open, we don't want the module
	 * to be unloaded.
	 */
	if (!try_module_get(wdd->ops->owner))
		goto out;

	err = watchdog_start(wdd);
	if (err < 0)
		goto out_mod;

	/* dev/watchdog is a virtual (and thus non-seekable) filesystem */
	return nonseekable_open(inode, file);

out_mod:
	module_put(wdd->ops->owner);
out:
	clear_bit(WDOG_DEV_OPEN, &wdd->status);
	return err;
}
Ejemplo n.º 3
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(burn_process, ev, data)
{
  PROCESS_BEGIN();

  etimer_set(&etimer, 5*CLOCK_SECOND);
  PROCESS_WAIT_UNTIL(etimer_expired(&etimer));

  watchdog_stop();
  leds_on(LEDS_RED);
#if NODEID
  printf("Burning node id %d\n", NODEID);
  node_id_burn(NODEID);
  leds_on(LEDS_BLUE);
  node_id_restore();
  printf("Restored node id %d\n", node_id);
#else
#error "burn-nodeid must be compiled with nodeid=<the ID of the node>"
  node_id_restore();
  printf("Restored node id %d\n", node_id);
#endif
  leds_off(LEDS_RED + LEDS_BLUE);
  watchdog_start();
  while(1) {
    PROCESS_WAIT_EVENT();
  }
  PROCESS_END();
}
Ejemplo n.º 4
0
void AppColdStart(void)
{
  /* default startup */
  init_hardware();

  buzzer_init();
  rgb_leds_init();
  sseg_init();

  process_init();
  init_net();

  /* start the main processes */
  procinit_init();
  autostart_start(autostart_processes);
  jts_init();

  /* enable watchdog on JN5148, there is none on JN5139 */
  watchdog_start();

  /* default main loop */
  while(1)
  {
    process_run();
    etimer_request_poll();
    watchdog_periodic();
  }
}
Ejemplo n.º 5
0
void
AppColdStart(void)
{
  /* default startup */
  init_hardware();
  process_init();
  procinit_init();
  init_net();
  jts_init();

  /* application startup */
  autostart_start(autostart_processes);

  /* enable watchdog on JN5148, there is none on JN5139 */
#ifdef __BA2__
  watchdog_start();
#endif

  /* default main loop */
  while(1)
  {
    process_run();
    etimer_request_poll();

#ifdef __BA2__
    watchdog_periodic();
#endif
  }
}
Ejemplo n.º 6
0
/*---------------------------------------------------------------------------*/
int
xmem_erase(long size, unsigned long addr)
{
  unsigned long end = addr + size;

  if(size % XMEM_ERASE_UNIT_SIZE != 0) {
    PRINTF("xmem_erase: bad size\n");
    return -1;
  }

  if(addr % XMEM_ERASE_UNIT_SIZE != 0) {
    PRINTF("xmem_erase: bad offset\n");
    return -1;
  }

  watchdog_stop();

  for (; addr < end; addr += XMEM_ERASE_UNIT_SIZE) {
    erase_sector(addr);
  }

  watchdog_start();

  return size;
}
static int watchdog_probe(struct platform_device *pdev)
{
	watchdog_wq = alloc_workqueue("pet_watchdog",
					WQ_UNBOUND | WQ_HIGHPRI, 1);
	watchdog_start();
	return 0;
}
Ejemplo n.º 8
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_nodeid_process, ev, data)
{
    uint16_t nodeid;
    char buf[20];
    const char *newptr;
    PROCESS_BEGIN();

    nodeid = shell_strtolong(data, &newptr);

    /* If no node ID was given on the command line, we print out the
       current channel. Else we burn the new node ID. */
    if(newptr == data) {
        nodeid = node_id;
    } else {
        nodeid = shell_strtolong(data, &newptr);
        watchdog_stop();
        leds_on(LEDS_RED);
        node_id_burn(nodeid);
        leds_on(LEDS_BLUE);
        node_id_restore();
        leds_off(LEDS_RED + LEDS_BLUE);
        watchdog_start();
    }

    snprintf(buf, sizeof(buf), "%d", nodeid);
    shell_output_str(&nodeid_command, "Node ID: ", buf);

    PROCESS_END();
}
Ejemplo n.º 9
0
/**
 * bmc_reset_watchdog is used for starting and restarting the watchdog
 *
 * \param rq pointer to request message
 * \param rs pointer to response message
 */
void bmc_reset_watchdog(ipmbMSG_t *rq, ipmbMSG_t *rs)
{
	if (!wd_set)
	{
		/* the BMC watchdog timer is not initialized */
		rs->data[0] = CC_SET_WDT_COMMAND_NOT_ISSUED;
	}
	/* only enable timer start if configured */
	else
	{
		taskENTER_CRITICAL();

		/* start or restart watchdog timer */
		watchdog_start();

		/* reset countdown value */
		wd_timer.present_count = wd_timer.initial_count;

		/* delete pre timeout flag */
		wd_timer.pretimeout_flag &= ~IPMB_WD_PRETO_FLAG;

		/* set wdt running */
		wd_timer.timer_use |= WD_TIMER_START;

		taskEXIT_CRITICAL();

		rs->data[0] = CC_COMPLETED_NORMALLY;
	}

	/* set response data length */
	rs->data_len = 1;
}
Ejemplo n.º 10
0
/*---------------------------------------------------------------------------*/
void
flash_done(void)
{
  /* Enable interrupts. */
  SFRIE1 = sfrie;
  eint();
  watchdog_start();
}
Ejemplo n.º 11
0
/*---------------------------------------------------------------------------*/
void
flash_done(void)
{
  /* Enable interrupts. */
  IE1 = ie1;
  IE2 = ie2;
  _EINT();
  watchdog_start();
}
Ejemplo n.º 12
0
/*---------------------------------------------------------------------------*/
static struct file *
reserve(const char *name, coffee_page_t pages,
	int allow_duplicates, unsigned flags)
{
  struct file_header hdr;
  coffee_page_t page;
  struct file *file;

  watchdog_stop();

  if(!allow_duplicates && find_file(name) != NULL) {
    watchdog_start();
    return NULL;
  }

  page = find_contiguous_pages(pages);
  if(page == INVALID_PAGE) {
    if(*gc_wait) {
      return NULL;
    }
    collect_garbage(GC_GREEDY);
    page = find_contiguous_pages(pages);
    if(page == INVALID_PAGE) {
      watchdog_start();
      *gc_wait = 1;
      return NULL;
    }
  }

  memset(&hdr, 0, sizeof(hdr));
  memcpy(hdr.name, name, sizeof(hdr.name) - 1);
  hdr.max_pages = pages;
  hdr.flags = HDR_FLAG_ALLOCATED | flags;
  write_header(&hdr, page);

  PRINTF("Coffee: Reserved %u pages starting from %u for file %s\n",
      pages, page, name);

  file = load_file(page, &hdr);
  file->end = 0;
  watchdog_start();

  return file;
}
Ejemplo n.º 13
0
int
main() {
    const struct CMUnitTest tests[] = {
            cmocka_unit_test_setup_teardown(sysrepo_daemon_test, test_setup, test_teardown),
    };

    watchdog_start(300);
    int ret = cmocka_run_group_tests(tests, NULL, NULL);
    watchdog_stop();
    return ret;
}
Ejemplo n.º 14
0
main(int unused_argc, char **unused_argv)
{
    WATCHDOG *wp;

    msg_verbose = 1;

    wp = watchdog_create(10, (WATCHDOG_FN) 0, (char *) 0);
    watchdog_start(wp);
    do {
	watchdog_pat();
    } while (VSTREAM_GETCHAR() != VSTREAM_EOF);
    watchdog_destroy(wp);
}
Ejemplo n.º 15
0
/*---------------------------------------------------------------------------*/
void
watchdog_reboot(void)
{
#if WATCHDOG_ENABLED == 1
	watchdog_start();
	if(MAP_WatchdogLockState(WATCHDOG0_BASE) == true)
	{
		MAP_WatchdogUnlock(WATCHDOG0_BASE);
	}
	MAP_WatchdogReloadSet(WATCHDOG0_BASE, (MAP_SysCtlClockGet() / 4)); // 250ms
	while(1); //loop
#endif
}
Ejemplo n.º 16
0
void
initialize(void)
{
  watchdog_init();
  watchdog_start();
  
#if STACKMONITOR
  /* Simple stack pointer highwater monitor. Checks for magic numbers in the main
   * loop. In conjuction with TESTRTIMER, never-used stack will be printed
   * every STACKMONITOR seconds.
   */
{
extern uint16_t __bss_end;
uint16_t p=(uint16_t)&__bss_end;
    do {
      *(uint16_t *)p = 0x4242;
      p+=4;
    } while (p<SP-4); //don't overwrite our own stack
}
#endif

  /* rtimers needed for radio cycling */
  rtimer_init();

  rs232_init(RS232_PORT_0, BAUD_RATE(38400), USART_DATA_BITS_8 | USART_PARITY_NONE | USART_STOP_BITS_1);
  rs232_redirect_stdout(RS232_PORT_0);

  clock_init();
  sei();

  /* Initialize drivers and event kernel */
  process_init();
 
  led_init();

#if 0
  procinit_init();
#else
  process_start(&etimer_process, NULL);
  process_start(&led_process, NULL);
  process_start(&led2_process, NULL);
#endif

  PRINTA(CONTIKI_VERSION_STRING " started\r\n");

  /* Comment this out if autostart_processes not defined at link */
  /* Note AUTOSTART_PROCESSES(...) is only effective in the .co module */
  autostart_start(autostart_processes);
  
}
Ejemplo n.º 17
0
int
main() {
    const struct CMUnitTest tests[] = {
            cmocka_unit_test_setup_teardown(cm_session_test, cm_setup, cm_teardown),
            cmocka_unit_test_setup_teardown(cm_session_neg_test, cm_setup, NULL),
            cmocka_unit_test_setup_teardown(cm_buffers_test, cm_setup, cm_teardown),
            cmocka_unit_test_setup_teardown(cm_signals_test, cm_setup, cm_teardown),
    };

    watchdog_start(300);
    int ret = cmocka_run_group_tests(tests, NULL, NULL);
    watchdog_stop();
    return ret;
}
Ejemplo n.º 18
0
/*--------------------------------------------------------------------------*/
ISR(TIMER0_A1, rtimer_a01_isr)
{
  /* store the IV register as any read/write resets interrupt flags */
  uint16_t ivreg = TA0IV;

  if(ivreg & TA0IV_TACCR1) {
    /* rtimer interrupt */
    TA0CCTL1 &= ~CCIFG;
    watchdog_start();

    /* check for and run any pending rtimers */
    rtimer_run_next();

    /* also check for any pending events and wake up if needed */
    if(process_nevents() > 0) {
      LPM4_EXIT;
    }
    watchdog_stop();




  } else if(ivreg & TA0IV_TACCR2) {
    /* simple pwm interrupt */
    TA0CCTL2 &= ~CCIFG;

    if(spwm.on_time > 0) {
      if(spwm.on_time == period) {
        TA0CCTL2 &= ~CCIE;  /* no need for interrupt, is at 100% DC */
/*        SIMPLE_PWM_PORT(OUT) |= (1 << spwm.pin);*/
        pwm_on_cb();

      } else {
        /* normal on-case */
        if(period_end) {
          period_end = 0;
          TA0CCR2 = TAR + spwm.on_time;
/*          SIMPLE_PWM_PORT(OUT) |= (1 << spwm.pin);*/
          pwm_off_cb();

        } else {
          period_end = 1;
          TA0CCR2 = TAR + (period - spwm.on_time);
/*          SIMPLE_PWM_PORT(OUT) &= ~(1 << spwm.pin);*/
          pwm_on_cb();
        }
      }
    }
  }
}
Ejemplo n.º 19
0
static void watchdog_workfunc(struct work_struct *work)
{
	struct watchdog_data *wd;

	wd = container_of(work, struct watchdog_data, work.work);

	pr_debug("%s: pet watchdog\n", __func__);

	/* stop watchdog and restart it */
	watchdog_stop(wd);
	watchdog_start(wd);

	/* reschedule to clear it again in the future */
	queue_delayed_work(wd->wq, &wd->work, wd->pet_interval);
}
Ejemplo n.º 20
0
 timera0 (void) {
  ENERGEST_ON(ENERGEST_TYPE_IRQ);

  watchdog_start();

  rtimer_run_next();

  if(process_nevents() > 0) {
    LPM4_EXIT;
  }

  watchdog_stop();

  ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
Ejemplo n.º 21
0
/*---------------------------------------------------------------------------*/
ISR(TIMERA1, timera1)
{
  ENERGEST_ON(ENERGEST_TYPE_IRQ);

  watchdog_start();

  if(TAIV == 2) {

    /* HW timer bug fix: Interrupt handler called before TR==CCR.
     * Occurs when timer state is toggled between STOP and CONT. */
    while(TACTL & MC1 && TACCR1 - TAR == 1);

    /* Make sure interrupt time is future */
    do {
      TACCR1 += INTERVAL;
      ++count;

      /* Make sure the CLOCK_CONF_SECOND is a power of two, to ensure
	 that the modulo operation below becomes a logical and and not
	 an expensive divide. Algorithm from Wikipedia:
	 http://en.wikipedia.org/wiki/Power_of_two */
#if (CLOCK_CONF_SECOND & (CLOCK_CONF_SECOND - 1)) != 0
#error CLOCK_CONF_SECOND must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...).
#error Change CLOCK_CONF_SECOND in contiki-conf.h.
#endif
      if(count % CLOCK_CONF_SECOND == 0) {
	++seconds;
        energest_flush();
      }
    } while((TACCR1 - TAR) > INTERVAL);

    last_tar = TAR;

    if(etimer_pending() &&
       (etimer_next_expiration_time() - count - 1) > MAX_TICKS) {
      etimer_request_poll();
      LPM4_EXIT;
    }

  }
  /*  if(process_nevents() >= 0) {
    LPM4_EXIT;
    }*/

  watchdog_stop();

  ENERGEST_OFF(ENERGEST_TYPE_IRQ);
}
Ejemplo n.º 22
0
static int watchdog_open(struct inode *inode, struct file *file)
{
	struct watchdog_core_data *wd_data;
	struct watchdog_device *wdd;
	bool hw_running;
	int err;

	/* Get the corresponding watchdog device */
	if (imajor(inode) == MISC_MAJOR)
		wd_data = old_wd_data;
	else
		wd_data = container_of(inode->i_cdev, struct watchdog_core_data,
				       cdev);

	/* the watchdog is single open! */
	if (test_and_set_bit(_WDOG_DEV_OPEN, &wd_data->status))
		return -EBUSY;

	wdd = wd_data->wdd;

	/*
	 * If the /dev/watchdog device is open, we don't want the module
	 * to be unloaded.
	 */
	hw_running = watchdog_hw_running(wdd);
	if (!hw_running && !try_module_get(wdd->ops->owner)) {
		err = -EBUSY;
		goto out_clear;
	}

	err = watchdog_start(wdd);
	if (err < 0)
		goto out_mod;

	file->private_data = wd_data;

	if (!hw_running)
		kref_get(&wd_data->kref);

	/* dev/watchdog is a virtual (and thus non-seekable) filesystem */
	return stream_open(inode, file);

out_mod:
	module_put(wd_data->wdd->ops->owner);
out_clear:
	clear_bit(_WDOG_DEV_OPEN, &wd_data->status);
	return err;
}
Ejemplo n.º 23
0
/*---------------------------------------------------------------------------*/
static void
collect_garbage(int mode)
{
  uint16_t sector;
  struct sector_status stats;
  coffee_page_t first_page, isolation_count;

  watchdog_stop();

  PRINTF("Coffee: Running the file system garbage collector in %s mode\n",
	 mode == GC_RELUCTANT ? "reluctant" : "greedy");
  /*
   * The garbage collector erases as many sectors as possible. A sector is
   * erasable if there are only free or obsolete pages in it.
   */
  for(sector = 0; sector < COFFEE_SECTOR_COUNT; sector++) {
    isolation_count = get_sector_status(sector, &stats);
    PRINTF("Coffee: Sector %u has %u active, %u obsolete, and %u free pages.\n",
        sector, (unsigned)stats.active,
	(unsigned)stats.obsolete, (unsigned)stats.free);

    if(stats.active > 0) {
      continue;
    }

    if((mode == GC_RELUCTANT && stats.free == 0) ||
       (mode == GC_GREEDY && stats.obsolete > 0)) {
      first_page = sector * COFFEE_PAGES_PER_SECTOR;
      if(first_page < *next_free) {
        *next_free = first_page;
      }

      if(isolation_count > 0) {
        isolate_pages(first_page + COFFEE_PAGES_PER_SECTOR, isolation_count);
      }

      COFFEE_ERASE(sector);
      PRINTF("Coffee: Erased sector %d!\n", sector);

      if(mode == GC_RELUCTANT && isolation_count > 0) {
        break;
      }
    }
  }

  watchdog_start();
}
Ejemplo n.º 24
0
/*---------------------------------------------------------------------------*/
void
LPTMR_IRQHandler(void)
  {
    ENERGEST_ON(ENERGEST_TYPE_IRQ);

    watchdog_start();
    
    PRINTF("rtimer_arch_init compare event at 0x%4x.\n", rtimer_arch_now());

    LPTMR0_CMR = LPTMR_CMR_COMPARE(LPTMR_CMR_COMPARE_MASK);
    LPTMR0_CSR = (uint32_t) ((LPTMR0_CSR
        & (uint32_t) ~(uint32_t) (LPTMR_CSR_TIE_MASK))
    | (uint32_t) (LPTMR_CSR_TCF_MASK)); // Clear interrupt flag and disable interrupt

    rtimer_run_next();

    watchdog_stop();

    ENERGEST_OFF(ENERGEST_TYPE_IRQ);
  }
Ejemplo n.º 25
0
int
main() {
    const struct CMUnitTest tests[] = {
        cmocka_unit_test(sr_new_tree_test),
        cmocka_unit_test(sr_new_trees_test),
        cmocka_unit_test(sr_node_set_name_test),
        cmocka_unit_test(sr_node_set_module_test),
        cmocka_unit_test(sr_node_set_str_data_test),
        cmocka_unit_test(sr_node_build_str_data_test),
        cmocka_unit_test(sr_node_add_child_test),
        cmocka_unit_test(sr_dup_tree_test),
        cmocka_unit_test(sr_dup_trees_test),
        cmocka_unit_test(sr_print_tree_test)
    };

    watchdog_start(300);
    int ret = cmocka_run_group_tests(tests, NULL, NULL);
    watchdog_stop();
    return ret;
}
Ejemplo n.º 26
0
int
start_watchdog(glite_renewal_core_context ctx, pid_t *pid)
{
    pid_t p;

    switch ((p = fork())) {
    case -1:
        edg_wlpr_Log(ctx, LOG_ERR, "fork() failed: %s",
                     strerror(errno));
        return errno;
    case 0:
        watchdog_start(ctx);
        exit(0);
        break;
    default:
        *pid = p;
        return 0;
    }
    /* not reachable */
    exit(0);
}
Ejemplo n.º 27
0
static int watchdog_open(struct inode *inode, struct file *file)
{
	int err = -EBUSY;
	struct watchdog_device *wdd;

	/* Get the corresponding watchdog device */
	if (imajor(inode) == MISC_MAJOR)
		wdd = old_wdd;
	else
		wdd = container_of(inode->i_cdev, struct watchdog_device, cdev);

	/* the watchdog is single open! */
	if (test_and_set_bit(WDOG_DEV_OPEN, &wdd->status))
		return -EBUSY;

	/*
	 * If the /dev/watchdog device is open, we don't want the module
	 * to be unloaded.
	 */
	if (!try_module_get(wdd->ops->owner))
		goto out;

	err = watchdog_start(wdd);
	if (err < 0)
		goto out_mod;

	file->private_data = wdd;

	if (wdd->ops->ref)
		wdd->ops->ref(wdd);

	/* dev/watchdog is a virtual (and thus non-seekable) filesystem */
	return nonseekable_open(inode, file);

out_mod:
	module_put(wdd->ops->owner);
out:
	clear_bit(WDOG_DEV_OPEN, &wdd->status);
	return err;
}
Ejemplo n.º 28
0
/**
 * start wdt internal
 *
 * \param mode watchdog mode
 * \param action action
 * \param count countdown value
 */
void bmc_start_wd_timer(unsigned char use, unsigned char action, unsigned short count)
{
	if (!(wd_timer.timer_use & WD_TIMER_START))
	{
		taskENTER_CRITICAL();

		/* set watchdog timer values */
		wd_timer.timer_use = use;
		wd_timer.timer_action = action;
		wd_timer.initial_count = count;
		wd_timer.present_count = count;
		wd_timer.timer_use |= WD_TIMER_START;

		/* start or restart watchdog timer */
		watchdog_start();

		taskEXIT_CRITICAL();
#ifdef CFG_CPCI
		wd_set = 1;
#endif
	}
}
Ejemplo n.º 29
0
void MXBMESH::begin(channel_t chan,uint16_t localaddress,HardwareSerial *mySerial,bool powermode)
{
#if WITHSINKSOFT
	sinkSerial=mySerial;
#endif
	NODEINFO.localAddress=localaddress;
	NODEINFO.localChannel=chan;
	NODEINFO.islowpower=powermode;
	MxTimer2::set(TIMER2TICKS*1000, timer2function); // call every 30s for broadcast ,resolution must >=1000
	MxTimer2::start();
	if (NODEINFO.LoadCONFIG()) //maybe restart
	{
		MxRadio.begin(NODEINFO.localChannel,0xffff,NODEINFO.localAddress,true,true,true,15);
		MxRadio.setParam(phyTransmitPower,(txpwr_t)(NODEINFO.txPower-TXPOWERSHIFT));
	}
	else
	{
		NODEINFO.SaveCONFIG();
		MxRadio.begin(NODEINFO.localChannel,0xffff,NODEINFO.localAddress,true,true,true,15);
	}
	randomSeed(NODEINFO.localAddress);

	MxRadio.attachReceiveFrame(recievehandler);
	//MxRadio.attachError(errHandle);
	MxRadio.attachTxDone(onXmitDone);
	for (int nbindex=0;nbindex<MAX_NB;nbindex++)
	{
		NODEINFO.neigbour[nbindex].nodeid=BROADCASTADDR;
	}
	rxqueue.init_queue();
	txqueue.init_queue();


	if (NODEINFO.dataupload_interval==0xffff)
		NODEINFO.dataupload_interval=0;
	watchdog_init();
	watchdog_start();
}
Ejemplo n.º 30
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(preload_process, ev, data)
{
  PROCESS_BEGIN();

  etimer_set(&etimer, 5 * CLOCK_SECOND);
  PROCESS_WAIT_UNTIL(etimer_expired(&etimer));

  watchdog_stop();
  leds_on(LEDS_RED);
  
  preload();
  
  leds_on(LEDS_BLUE);
  
  printf("done\n");
  
  leds_off(LEDS_RED + LEDS_BLUE);
  watchdog_start();
  while(1) {
    PROCESS_WAIT_EVENT();
  }
  PROCESS_END();
}