Example #1
0
int
ikev2_msg_send(struct iked *env, struct iked_message *msg)
{
	struct iked_sa		*sa = msg->msg_sa;
	struct ibuf		*buf = msg->msg_data;
	u_int32_t		 natt = 0x00000000;
	int			 isnatt = 0;
	struct ike_header	*hdr;
	struct iked_message	*m;

	if (buf == NULL || (hdr = ibuf_seek(msg->msg_data,
	    msg->msg_offset, sizeof(*hdr))) == NULL)
		return (-1);

	isnatt = (msg->msg_natt || (msg->msg_sa && msg->msg_sa->sa_natt));

	log_info("%s: %s from %s to %s, %ld bytes%s", __func__,
	    print_map(hdr->ike_exchange, ikev2_exchange_map),
	    print_host(&msg->msg_local, NULL, 0),
	    print_host(&msg->msg_peer, NULL, 0),
	    ibuf_length(buf), isnatt ? ", NAT-T" : "");

	if (isnatt) {
		if (ibuf_prepend(buf, &natt, sizeof(natt)) == -1) {
			log_debug("%s: failed to set NAT-T", __func__);
			return (-1);
		}
		msg->msg_offset += sizeof(natt);
	}

	if ((sendto(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0,
	    (struct sockaddr *)&msg->msg_peer, msg->msg_peerlen)) == -1) {
		log_warn("%s: sendto", __func__);
		return (-1);
	}

	if (!sa)
		return (0);

	if ((m = ikev2_msg_copy(env, msg)) == NULL) {
		log_debug("%s: failed to copy a message", __func__);
		return (-1);
	}
	m->msg_exchange = hdr->ike_exchange;

	if (hdr->ike_flags & IKEV2_FLAG_RESPONSE) {
		TAILQ_INSERT_TAIL(&sa->sa_responses, m, msg_entry);
		timer_initialize(env, &m->msg_timer,
		    ikev2_msg_response_timeout, m);
		timer_register(env, &m->msg_timer, IKED_RESPONSE_TIMEOUT);
	} else {
		TAILQ_INSERT_TAIL(&sa->sa_requests, m, msg_entry);
		timer_initialize(env, &m->msg_timer,
		    ikev2_msg_retransmit_timeout, m);
		timer_register(env, &m->msg_timer, IKED_RETRANSMIT_TIMEOUT);
	}

	return (0);
}
/*
 * Function to turn on vibrator.
 * vibrate_time - the time of phone vibrate.
 */
void vib_timed_turn_on(const uint32_t vibrate_time)
{
	vib_turn_on();
	vib_timeout=0;
	timer_initialize(&vib_timer);
	timer_set_oneshot(&vib_timer, vibrate_time, vib_timer_func, NULL);
}
Example #3
0
int main(void)
{
	static console_command_t commands[2];
	commands[0].callback = command_callback;
	commands[1].callback = branch_hub_command_callback;
	commands[1].help_callback = branch_hub_help_callback;
	ADCON1 = 0x0F;
	CMCON = 0x07;
	TRISA = 0x00;
	PORTA = 0x00;
	
	interrupt_initialize();
	timer_initialize();

	timer_register(timer_callback, 1000, &timer_id);
	timer_enable(timer_id);
	
	console_initialize();

	console_register_command(commands[0], "main");
	console_register_command(commands[1], "hub");

	hub_init(HUB_ADDRESS);
	
	while(1)
	{
		console_process_tasks();
	}
}
void ssbi_keypad_init(struct qwerty_keypad_info  *qwerty_kp)
{
    unsigned int mach_id;
    int len;

    len = sizeof(struct gpio_qwerty_kp);
    qwerty_keypad = malloc(len);
    ASSERT(qwerty_keypad);

    memset(qwerty_keypad, 0, len);
    qwerty_keypad->keypad_info = qwerty_kp;

    event_init(&qwerty_keypad->full_scan, false, EVENT_FLAG_AUTOUNSIGNAL);
    timer_initialize(&qwerty_keypad->timer);

    mach_id = board_machtype();
    ssbi_gpio_init(mach_id);

    if(mach_id == LINUX_MACHTYPE_8660_QT)
    {
        mdelay((qwerty_keypad->keypad_info)->settle_time);
#ifdef QT_8660_KEYPAD_HW_BUG
        timer_set_oneshot(&qwerty_keypad->timer, 0, scan_qt_keypad, NULL);
#endif
    }
    else
        timer_set_oneshot(&qwerty_keypad->timer, 0, scan_qwerty_keypad, NULL);

    /* wait for the keypad to complete one full scan */
    event_wait(&qwerty_keypad->full_scan);
}
Example #5
0
void
_kernel_call_inirtn(void)
{
	KzAttIni( (VP_INT)(0) );
	timer_initialize( (VP_INT)(0) );
	serial_initialize( (VP_INT)(0) );
}
Example #6
0
void gpio_keypad_init(struct gpio_keypad_info *kpinfo)
{
	int key_count;
	int output_val;
	int output_cfg;
	int i;
	int len;

	ASSERT(kpinfo->keymap && kpinfo->input_gpios && kpinfo->output_gpios);
	key_count = kpinfo->ninputs * kpinfo->noutputs;

	len = sizeof(struct gpio_kp) + (sizeof(unsigned long) *	BITMAP_NUM_WORDS(key_count));
	keypad = malloc(len);
	ASSERT(keypad);

	memset(keypad, 0, len);
	keypad->keypad_info = kpinfo;

	output_val = (!!(kpinfo->flags & GPIOKPF_ACTIVE_HIGH))^(!!(kpinfo->flags & GPIOKPF_DRIVE_INACTIVE));
	output_cfg = kpinfo->flags & GPIOKPF_DRIVE_INACTIVE ? GPIO_OUTPUT : 0;
	for (i = 0; i < kpinfo->noutputs; i++) {
		gpio_set(kpinfo->output_gpios[i], output_val);
		gpio_config(kpinfo->output_gpios[i], output_cfg);
	}
	for (i = 0; i < kpinfo->ninputs; i++) {
		gpio_config(kpinfo->input_gpios[i], GPIO_INPUT);
	}
	keypad->current_output = kpinfo->noutputs;
	
	timer_initialize(&keypad->timer);
	timer_set_oneshot(&keypad->timer, 0, gpio_keypad_timer_func, NULL);
}
Example #7
0
/*
 * Create the ZRTP transport.
 */
PJ_DEF(pj_status_t) pjmedia_transport_zrtp_create(pjmedia_endpt *endpt,
        const char *name,
        pjmedia_transport *transport,
        pjmedia_transport **p_tp,
        pj_bool_t close_slave)
{
    pj_pool_t *pool;
    struct tp_zrtp *zrtp;
    pj_status_t rc;

    if (name == NULL)
        name = "tzrtp%p";

    /* Create the pool and initialize the adapter structure */
    pool = pjmedia_endpt_create_pool(endpt, name, 5*1024, 512);
    zrtp = PJ_POOL_ZALLOC_T(pool, struct tp_zrtp);
    zrtp->pool = pool;
    pj_ansi_strncpy(zrtp->base.name, pool->obj_name,
                    sizeof(zrtp->base.name));
    zrtp->base.type = (pjmedia_transport_type)
                      (PJMEDIA_TRANSPORT_TYPE_USER + 2);
    zrtp->base.op = &tp_zrtp_op;

#ifndef DYNAMIC_TIMER
    if (timer_pool == NULL)
    {
        timer_pool = pjmedia_endpt_create_pool(endpt, "zrtp_timer", 256, 256);
        rc = timer_initialize();
        if (rc != PJ_SUCCESS)
        {
            pj_pool_release(timer_pool);
            pj_pool_release(zrtp->pool);
            return rc;
        }
    }
#else
    zrtp->timer_heap = pjsip_endpt_get_timer_heap(pjsua_var.endpt);
#endif

    /* Create the empty wrapper */
    zrtp->zrtpCtx = zrtp_CreateWrapper();

    /* Initialize standard values */
    zrtp->clientIdString = clientId;    /* Set standard name */
    zrtp->zrtpSeq = 1;                  /* TODO: randomize */
    rc = pj_mutex_create_simple(zrtp->pool, "zrtp", &zrtp->zrtpMutex);
    zrtp->zrtpBuffer = pj_pool_zalloc(pool, MAX_ZRTP_SIZE);
    zrtp->sendBuffer = pj_pool_zalloc(pool, MAX_RTP_BUFFER_LEN);
    zrtp->sendBufferCtrl = pj_pool_zalloc(pool, MAX_RTCP_BUFFER_LEN);

    zrtp->slave_tp = transport;
    zrtp->close_slave = close_slave;
    zrtp->mitmMode = PJ_FALSE;

    /* Done */
    zrtp->refcount++;
    *p_tp = &zrtp->base;
    return PJ_SUCCESS;
}
Example #8
0
void
_kernel_call_inirtn(void)
{
	macaddr_init( (VP_INT)(0) );
	application_init( (VP_INT)(0) );
	sdev_init( (VP_INT)(0) );
	stdfile_init( (VP_INT)(0) );
	rtc_init( (VP_INT)(0) );
	mci_init( (VP_INT)(0) );
	dma_init( (VP_INT)(0) );
	timer_initialize( (VP_INT)(0) );
	serial_initialize( (VP_INT)(0) );
}
Example #9
0
File: sched.c Project: texane/muk
error_t sched_start(void)
{
    if (g_sched.is_started == true)
        return ERROR_FAILURE;

    cpu_cli();

    g_sched.is_started = true;

    timer_initialize(SCHED_TIMER_FREQ);

    cpu_sti();

    return ERROR_SUCCESS;
}
Example #10
0
int main(void)
{
    imask_initialize();
    clock_initialize();
    sci_initialize(INTERRUPT_PRIORITY_COMMUNICATION, 38400);
    timer_initialize(INTERRUPT_PRIORITY_TIMER);
    set_imask_exr(0);

    timer_set_interval_function(timer_handler);
    timer_start();

    sci_write("0\r\n", 3);

    while (1) {
        ;
    }
}
Example #11
0
File: debug.c Project: jbush001/lk
static int cmd_threadload(int argc, const cmd_args *argv)
{
	static bool showthreadload = false;
	static timer_t tltimer;

	if (showthreadload == false) {
		// start the display
		timer_initialize(&tltimer);
		timer_set_periodic(&tltimer, 1000, &threadload, NULL);
		showthreadload = true;
	} else {
		timer_cancel(&tltimer);
		showthreadload = false;
	}

	return 0;
}
Example #12
0
void main() {
  bt_initialize();
  trace_initialize();
  i386_initialize_descriptor_tables();
  i8259_initialize();
  exceptions_initialize();
  timer_initialize();
  mem_initialize();
  dma_initialize();
  keyboard_initialize();  
  floppy_initialize();  
  tty_initialize();  
  sys_initialize();   
  loader_initialize();  
  clear_display();
  printk("Start running processes!!!\nStartup Communications\n Press ALT-LSHIFT for next terminal\n");  
  i8259_start();
  while(1);  
}
void ssbi_gpio_keypad_init(struct qwerty_keypad_info  *qwerty_kp)
{
	int len;

	len = sizeof(struct gpio_qwerty_kp);
	qwerty_keypad = malloc(len);
	ASSERT(qwerty_keypad);

	memset(qwerty_keypad, 0, len);
	qwerty_keypad->keypad_info = qwerty_kp;

	event_init(&qwerty_keypad->full_scan, false, EVENT_FLAG_AUTOUNSIGNAL);
	timer_initialize(&qwerty_keypad->timer);

	timer_set_oneshot(&qwerty_keypad->timer, 0, scan_qwerty_gpio_keypad, NULL);

	/* wait for the keypad to complete one full scan */
	event_wait(&qwerty_keypad->full_scan);
}
Example #14
0
void gpio_keys_init(struct gpio_keys_pdata *kpdata)
{
	if(kpdata == NULL) {
		printf("FAILED: platform data is NULL!\n");
		return;
	} else if (pdata != NULL) {
		printf("FAILED: platform data is set already!\n");
		return;
	} else if (!kpdata->nr_keys || (!(kpdata->nr_keys < BITMAP_BITS_PER_WORD)) ) {
		printf("WARN: %d keys not supported, First 32 keys will be served.\n", (unsigned)kpdata->nr_keys);
		kpdata->nr_keys = 32;
	}

	pdata = kpdata;
	
	some_key_pressed = 0;
	memset(&gpio_keys_bitmap, 0, sizeof(unsigned long));

	timer_initialize(&gpio_keys_poll);
	timer_set_oneshot(&gpio_keys_poll, 0, gpio_keys_poll_fn, NULL);
}
/*
 * Function to support for shutdown detection
 * If below condition is met, the function will shut down
 * the device. Otherwise it will do nothing and return to
 * normal boot.
 * condition:
 * 1. it is triggered by power key &&
 * 2. the power key is released before
 * (PWRKEY_LONG_PRESS_COUNT/MPM_SLEEP_TIMETICK_COUNT) seconds.
 */
void shutdown_detect()
{
	/*
	 * If it is booted by power key tirigger.
	 * Initialize pon_timer and call long_press_pwrkey_timer_func
	 * function to check if the power key is last press long enough.
	 */
	if (is_pwrkey_pon_reason() && is_pwrkey_time_expired()) {
		timer_initialize(&pon_timer);
		timer_set_oneshot(&pon_timer, 0, long_press_pwrkey_timer_func, NULL);

		/*
		 * Wait until long press power key timeout
		 *
		 * It will be confused to end users if we shutdown the device
		 * after the splash screen displayed. But it can be moved the
		 * wait here if the boot time is much more considered.
		 */
		wait_for_long_pwrkey_pressed();
	}
}
Example #16
0
static int cmd_threadload(int argc, const cmd_args * argv)
{
	static bool showthreadload = false;
	static timer_t tltimer;

	enter_critical_section();

	if (showthreadload == false) {
		// start the display
		timer_initialize(&tltimer);
		timer_set_oneshot(&tltimer, 1000, &threadload, NULL);
		showthreadload = true;
	} else {
		timer_cancel(&tltimer);
		showthreadload = false;
	}

	exit_critical_section();

	return 0;
}
Example #17
0
void RECEIVE_Initialize(void) {
    traces(RECEIVE_INIT_ENTER);
    // Create queue, 80 slots, each one byte in size
    rcvData.rcvQueue = xQueueCreate(80, sizeof (char));
    // Verifies queue created
    if (rcvData.rcvQueue == 0)
        error('c');

    // Initialize parameters
    rcvData.currentIndex = 0;
    
    timer_initialize(100);
    DRV_USART0_Initialize();
    rcvData.clock = 0;
    rcvData.sequence = 0;
    rcvData.x_in = 0; 
    
    
    RGB_Initialize();
    
    traces(RECEIVE_INIT_EXIT);
}
Example #18
0
int main(void)
{
	ADCON1 = 0x0F;
	CMCON = 0x07;
	TRISA = 0x00;
	PORTA = 0x00;
	
	interrupt_initialize();
	timer_initialize();

	nrf_initialize(nrf_transmit_mode, nrf_channel_0, CAFE_ADDRESS | NODE_ID);

	nrf_packet_t packet;
	uint8_t differ = 0x00;

	PORTA = 0x00;

	while(1)
	{
#if CONSTANT_TRANSMIT
	#if SEND_TO_APP
		packet.address = CAFE_ADDRESS | HUB_ID;
		packet.payload_length = 18;
		packet.payload[0] = 0x05;	// Branch
		packet.payload[1] = (NODE_ID >> 8);	// Source ID
		packet.payload[2] = (NODE_ID & 0xFF);
		packet.payload[3] = (HUB_ID >> 8);	// Destination ID
		packet.payload[4] = (HUB_ID & 0xFF);
		packet.payload[5] = 0x00;	// Source App
		packet.payload[6] = 0x00;
		packet.payload[7] = 0x80;	// Destination App
		packet.payload[8] = 0x41;
		packet.payload[9] = 0x07;	// Command
		packet.payload[10] = 0x00;	// Sub-Command
		packet.payload[11] = 0x06;	// Payload Length
		packet.payload[12] = 0xba;	// Payload
		packet.payload[13] = 0xba;
		packet.payload[14] = 0xde;
		packet.payload[15] = 0xca;
		packet.payload[16] = 0xfe;
		packet.payload[17] = differ++;
		nrf_set_mode(nrf_transmit_mode, true);
		nrf_flush_fifo(true);
		nrf_transmit_packet(packet, false);
		while(!(nrf_read_register(NRF_REG_FIFO_STATUS) & 0x10));
		PORTA ^= 0x01;
		timer_delay_ms(1000);
	#endif
	#if SEND_TO_HUB_APP
		packet.address = CAFE_ADDRESS | HUB_ID;
		packet.payload_length = 12;
		packet.payload[0] = 0x05;	// Branch
		packet.payload[1] = (NODE_ID >> 8);	// Source ID
		packet.payload[2] = (NODE_ID & 0xFF);
		packet.payload[3] = (HUB_ID >> 8);	// Destination ID
		packet.payload[4] = (HUB_ID & 0xFF);
		packet.payload[5] = 0x00;	// Source App
		packet.payload[6] = 0x00;
		packet.payload[7] = 0x00;	// Destination App
		packet.payload[8] = 0x00;
		packet.payload[9] = 0x04;	// Command
		packet.payload[10] = 0x05;	// Sub-Command
		packet.payload[11] = 0x00;	// Payload Length
		nrf_set_mode(nrf_transmit_mode, true);
		nrf_flush_fifo(true);
		nrf_transmit_packet(packet, false);
		while(!(nrf_read_register(NRF_REG_FIFO_STATUS) & 0x10));
		PORTA ^= 0x02;
		timer_delay_ms(1000);
	#endif
	#if SEND_TO_HUB
		packet.address = CAFE_ADDRESS;
		packet.payload_length = 13;
		packet.payload[0] = 0x05;	// Branch
		packet.payload[1] = (NODE_ID >> 8);	// Source ID
		packet.payload[2] = (NODE_ID & 0xFF);
		packet.payload[3] = 0x00;	// Destination ID
		packet.payload[4] = 0x00;
		packet.payload[5] = 0x00;	// Source App
		packet.payload[6] = 0x00;
		packet.payload[7] = 0x00;	// Destination App
		packet.payload[8] = 0x00;
		packet.payload[9] = 0x05;	// Command
		packet.payload[10] = 0x05;	// Sub-Command
		packet.payload[11] = 0x01;	// Payload Length
		packet.payload[11] = differ;	// Payload
		nrf_set_mode(nrf_transmit_mode, true);
		nrf_flush_fifo(true);
		nrf_transmit_packet(packet, false);
		while(!(nrf_read_register(NRF_REG_FIFO_STATUS) & 0x10));
		PORTA ^= 0x02;
		timer_delay_ms(1000);
	#endif
	#if SEND_HUB_ID_REQUEST
		packet.address = CAFE_ADDRESS | HUB_ID;
		packet.payload_length = 13;
		packet.payload[0] = 0x05;	// Branch
		packet.payload[1] = (NODE_ID >> 8);	// Source ID
		packet.payload[2] = (NODE_ID & 0xFF);
		packet.payload[3] = (HUB_ID >> 8);	// Destination ID
		packet.payload[4] = (HUB_ID & 0xFF);
		packet.payload[5] = 0x00;	// Source App
		packet.payload[6] = 0x00;
		packet.payload[7] = 0x00;	// Destination App
		packet.payload[8] = 0x00;
		packet.payload[9] = 0x06;	// Command
		packet.payload[10] = 0x05;	// Sub-Command
		packet.payload[11] = 0x01;	// Payload Length
		packet.payload[12] = 0x01;	// Payload
		nrf_set_mode(nrf_transmit_mode, true);
		nrf_flush_fifo(true);
		nrf_transmit_packet(packet, false);
		while(!(nrf_read_register(NRF_REG_FIFO_STATUS) & 0x10));
		PORTA ^= 0x02;
		timer_delay_ms(1000);
	#endif
#elif SEND_PACKETS
		packet.address = CAFE_ADDRESS | HUB_ID;
		packet.payload_length = 18;
		packet.payload[0] = 0x05;	// Branch
		packet.payload[1] = (NODE_ID >> 8);	// Source ID
		packet.payload[2] = (NODE_ID & 0xFF);
		packet.payload[3] = (HUB_ID >> 8);	// Destination ID
		packet.payload[4] = (HUB_ID & 0xFF);
		packet.payload[5] = 0x00;	// Source App
		packet.payload[6] = 0x00;
		packet.payload[7] = 0x00;	// Destination App
		packet.payload[8] = 0x02;
		packet.payload[9] = 0x01;	// Command
		packet.payload[10] = 0x00;	// Sub-Command
		packet.payload[11] = 0x00;	// Payload Length
		PORTA ^= 0x01;
		nrf_set_mode(nrf_transmit_mode, true);
		nrf_flush_fifo(true);
		nrf_transmit_packet(packet, false);
		while(!(nrf_read_register(NRF_REG_FIFO_STATUS) & 0x10));
		PORTA ^= 0x01;

		nrf_set_mode(nrf_receive_mode, true);
		nrf_flush_fifo(false);

		uint8_t delay_count = 0;
		PORTA ^= 0x02;
		while((nrf_read_register(NRF_REG_FIFO_STATUS) & 0x01) && (delay_count < 40))
		{
			timer_delay_ms(25);
			delay_count++;
		}
		PORTA ^= 0x02;

		if(delay_count < 40)
		{
			if(nrf_read_packet(&packet) != SUCCESS)
				delay_count = 40;
			else
				PORTA ^= 0x04;
		}

		if(delay_count < 40)
			timer_delay_ms(2000);

		timer_delay_ms(2000);
#elif RECEIVE_PACKETS
		nrf_set_mode(nrf_receive_mode, false);
		while(!(nrf_read_register(NRF_REG_FIFO_STATUS) & 0x01))
		{
			timer_delay_ms(50);
			PORTA ^= 0x02;
			nrf_read_packet(&packet);
			uint16_t temp;
			temp = (packet.payload[1] << 8);
			temp |= packet.payload[2];
			packet.address = CAFE_ADDRESS | temp;
			packet.payload_length = 12;
			packet.payload[1] = (NODE_ID >> 8);
			packet.payload[2] = (NODE_ID & 0xFF);
			packet.payload[3] = (temp >> 8);
			packet.payload[4] = (temp & 0xFF);
			temp = (packet.payload[5] << 8);
			temp |= packet.payload[6];
			packet.payload[5] = packet.payload[7];
			packet.payload[6] = packet.payload[8];
			packet.payload[7] = (temp >> 8);
			packet.payload[8] = (temp & 0xFF);
			packet.payload[9] ^= 0x80;
			packet.payload[10] = differ++;
			packet.payload[11] = 0x00;
			PORTA ^= 0x01;
			nrf_set_mode(nrf_transmit_mode, true);
			nrf_flush_fifo(true);
			nrf_transmit_packet(packet, false);
			while(!(nrf_read_register(NRF_REG_FIFO_STATUS) & 0x10));
			PORTA ^= 0x01;
			nrf_set_mode(nrf_receive_mode, false);
			nrf_write_register(NRF_REG_STATUS, 0x20);
		}
#endif
	}
}
Example #19
0
int
ikev2_pld_notify(struct iked *env, struct ikev2_payload *pld,
    struct iked_message *msg, off_t offset)
{
	struct ikev2_notify	*n;
	u_int8_t		*buf, md[SHA_DIGEST_LENGTH];
	size_t			 len;
	u_int32_t		 spi32;
	u_int64_t		 spi64;
	struct iked_spi		*rekey;
	u_int16_t		 type;
	u_int16_t		 group;

	if ((n = ibuf_seek(msg->msg_data, offset, sizeof(*n))) == NULL)
		return (-1);
	type = betoh16(n->n_type);

	log_debug("%s: protoid %s spisize %d type %s",
	    __func__,
	    print_map(n->n_protoid, ikev2_saproto_map), n->n_spisize,
	    print_map(type, ikev2_n_map));

	len = betoh16(pld->pld_length) - sizeof(*pld) - sizeof(*n);
	if ((buf = ibuf_seek(msg->msg_data, offset + sizeof(*n), len)) == NULL)
		return (-1);

	print_hex(buf, 0, len);

	if (!ikev2_msg_frompeer(msg))
		return (0);

	switch (type) {
	case IKEV2_N_NAT_DETECTION_SOURCE_IP:
	case IKEV2_N_NAT_DETECTION_DESTINATION_IP:
		if (ikev2_nat_detection(env, msg, md, sizeof(md), type) == -1)
			return (-1);
		if (len != sizeof(md) || memcmp(buf, md, len) != 0) {
			log_debug("%s: %s detected NAT, enabling "
			    "UDP encapsulation", __func__,
			    print_map(type, ikev2_n_map));

			/*
			 * Enable UDP encapsulation of ESP packages if
			 * the check detected NAT.
			 */
			if (msg->msg_sa != NULL)
				msg->msg_sa->sa_udpencap = 1;
		}
		print_hex(md, 0, sizeof(md));
		break;
	case IKEV2_N_INVALID_KE_PAYLOAD:
		if (len != sizeof(group)) {
			log_debug("%s: malformed notification", __func__);
			return (-1);
		}
		if (!msg->msg_sa->sa_hdr.sh_initiator) {
			log_debug("%s: not an initiator", __func__);
			sa_free(env, msg->msg_sa);
			msg->msg_sa = NULL;
			return (-1);
		}
		memcpy(&group, buf, len);
		group = betoh16(group);
		if ((msg->msg_policy->pol_peerdh = group_get(group))
		    == NULL) {
			log_debug("%s: unable to select DH group %d", __func__,
			    group);
			return (-1);
		}
		log_debug("%s: responder selected DH group %d", __func__,
		    group);
		sa_free(env, msg->msg_sa);
		msg->msg_sa = NULL;
		timer_initialize(env, &env->sc_inittmr, ikev2_init_ike_sa,
		    NULL);
		timer_register(env, &env->sc_inittmr, IKED_INITIATOR_INITIAL);
		break;
	case IKEV2_N_NO_ADDITIONAL_SAS:
		/* This makes sense for Child SAs only atm */
		if (msg->msg_sa->sa_stateflags & IKED_REQ_CHILDSA) {
			ikev2_disable_rekeying(env, msg->msg_sa);
			msg->msg_sa->sa_stateflags &= ~IKED_REQ_CHILDSA;
		}
		break;
	case IKEV2_N_REKEY_SA:
		if (len != n->n_spisize) {
			log_debug("%s: malformed notification", __func__);
			return (-1);
		}
		rekey = &msg->msg_parent->msg_rekey;
		if (rekey->spi != 0) {
			log_debug("%s: rekeying of multiple SAs not supported",
			    __func__);
			return (-1);
		}
		switch (n->n_spisize) {
		case 4:
			memcpy(&spi32, buf, len);
			rekey->spi = betoh32(spi32);
			break;
		case 8:
			memcpy(&spi64, buf, len);
			rekey->spi = betoh64(spi64);
			break;
		default:
			log_debug("%s: invalid spi size %d", __func__,
			    n->n_spisize);
			return (-1);
		}
		rekey->spi_size = n->n_spisize;
		rekey->spi_protoid = n->n_protoid;

		log_debug("%s: rekey %s spi %s", __func__,
		    print_map(n->n_protoid, ikev2_saproto_map),
		    print_spi(rekey->spi, n->n_spisize));
		break;
	}

	return (0);
}
Example #20
0
void os_start(void)
{
  int i;

  slldbg("Entry\n");

  /* Initialize all task lists */

  dq_init(&g_readytorun);
  dq_init(&g_pendingtasks);
  dq_init(&g_waitingforsemaphore);
#ifndef CONFIG_DISABLE_SIGNALS
  dq_init(&g_waitingforsignal);
#endif
#ifndef CONFIG_DISABLE_MQUEUE
  dq_init(&g_waitingformqnotfull);
  dq_init(&g_waitingformqnotempty);
#endif
#ifdef CONFIG_PAGING
  dq_init(&g_waitingforfill);
#endif
  dq_init(&g_inactivetasks);
  sq_init(&g_delayeddeallocations);

  /* Initialize the logic that determine unique process IDs. */

  g_lastpid = 0;
  for (i = 0; i < CONFIG_MAX_TASKS; i++)
    {
      g_pidhash[i].tcb = NULL;
      g_pidhash[i].pid = INVALID_PROCESS_ID;
    }

  /* Assign the process ID of ZERO to the idle task */

  g_pidhash[ PIDHASH(0)].tcb = &g_idletcb;
  g_pidhash[ PIDHASH(0)].pid = 0;

  /* Initialize a TCB for this thread of execution.  NOTE:  The default
   * value for most components of the g_idletcb are zero.  The entire
   * structure is set to zero.  Then only the (potentially) non-zero
   * elements are initialized. NOTE:  The idle task is the only task in
   * that has pid == 0 and sched_priority == 0.
   */

  bzero((void*)&g_idletcb, sizeof(_TCB));
  g_idletcb.task_state = TSTATE_TASK_RUNNING;
  g_idletcb.entry.main = (main_t)os_start;

#if CONFIG_TASK_NAME_SIZE > 0
  strncpy(g_idletcb.name, g_idlename, CONFIG_TASK_NAME_SIZE-1);
  g_idletcb.argv[0] = g_idletcb.name;
#else
  g_idletcb.argv[0] = (char*)g_idlename;
#endif /* CONFIG_TASK_NAME_SIZE */

  /* Then add the idle task's TCB to the head of the ready to run list */

  dq_addfirst((FAR dq_entry_t*)&g_idletcb, (FAR dq_queue_t*)&g_readytorun);

  /* Initialize the processor-specific portion of the TCB */

  g_idletcb.flags = TCB_FLAG_TTYPE_KERNEL;
  up_initial_state(&g_idletcb);

  /* Initialize the semaphore facility(if in link).  This has to be done
   * very early because many subsystems depend upon fully functional
   * semaphores.
   */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (sem_initialize != NULL)
#endif
    {
      sem_initialize();
    }

  /* Initialize the memory manager */

#ifndef CONFIG_HEAP_BASE
  {
    FAR void *heap_start;
    size_t heap_size;
    up_allocate_heap(&heap_start, &heap_size);
    kmm_initialize(heap_start, heap_size);
  }
#else
  kmm_initialize((void*)CONFIG_HEAP_BASE, CONFIG_HEAP_SIZE);
#endif

  /* Initialize the interrupt handling subsystem (if included) */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (irq_initialize != NULL)
#endif
    {
      irq_initialize();
    }

  /* Initialize the watchdog facility (if included in the link) */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (wd_initialize != NULL)
#endif
    {
      wd_initialize();
    }

  /* Initialize the POSIX timer facility (if included in the link) */

#ifndef CONFIG_DISABLE_CLOCK
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (clock_initialize != NULL)
#endif
    {
      clock_initialize();
    }
#endif

#ifndef CONFIG_DISABLE_POSIX_TIMERS
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (timer_initialize != NULL)
#endif
    {
      timer_initialize();
    }
#endif

  /* Initialize the signal facility (if in link) */

#ifndef CONFIG_DISABLE_SIGNALS
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (sig_initialize != NULL)
#endif
    {
      sig_initialize();
    }
#endif

  /* Initialize the named message queue facility (if in link) */

#ifndef CONFIG_DISABLE_MQUEUE
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (mq_initialize != NULL)
#endif
    {
      mq_initialize();
    }
#endif

  /* Initialize the thread-specific data facility (if in link) */

#ifndef CONFIG_DISABLE_PTHREAD
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (pthread_initialize != NULL)
#endif
    {
      pthread_initialize();
    }
#endif

  /* Initialize the file system (needed to support device drivers) */

#if CONFIG_NFILE_DESCRIPTORS > 0
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (fs_initialize != NULL)
#endif
    {
      fs_initialize();
    }
#endif

  /* Initialize the network system */

#ifdef CONFIG_NET
#if 0
  if (net_initialize != NULL)
#endif
    {
      net_initialize();
    }
#endif

  /* The processor specific details of running the operating system
   * will be handled here.  Such things as setting up interrupt
   * service routines and starting the clock are some of the things
   * that are different for each  processor and hardware platform.
   */

  up_initialize();

  /* Initialize the C libraries (if included in the link).  This
   * is done last because the libraries may depend on the above.
   */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (lib_initialize != NULL)
#endif
    {
      lib_initialize();
    }

  /* Create stdout, stderr, stdin on the IDLE task.  These will be
   * inherited by all of the threads created by the IDLE task.
   */

  (void)sched_setupidlefiles(&g_idletcb);

  /* Create initial tasks and bring-up the system */

  (void)os_bringup();

  /* When control is return to this point, the system is idle. */

  sdbg("Beginning Idle Loop\n");
  for (;;)
    {
      /* Perform garbage collection (if it is not being done by the worker
       * thread).  This cleans-up memory de-allocations that were queued
       * because they could not be freed in that execution context (for
       * example, if the memory was freed from an interrupt handler).
       */

#ifndef CONFIG_SCHED_WORKQUEUE
      /* We must have exclusive access to the memory manager to do this
       * BUT the idle task cannot wait on a semaphore.  So we only do
       * the cleanup now if we can get the semaphore -- this should be
       * possible because if the IDLE thread is running, no other task is!
       */

      if (kmm_trysemaphore() == 0)
        {
          sched_garbagecollection();
          kmm_givesemaphore();
        }
#endif

      /* Perform any processor-specific idle state operations */

      up_idle();
    }
}
Example #21
0
/**
* @fn                   :tc_timer_timer_initialize
* @brief                :Boot up configuration of the POSIX timer facility.
* @brief                :Boot up configuration of the POSIX timer facility.
* API's covered         :timer_initialize
* Preconditions         :Creation of timer_id(timer_create)
* Postconditions        :none
* @return               :void
*/
static void tc_timer_timer_initialize(void)
{
	timer_t timer_id;
	clockid_t clockid = CLOCK_REALTIME;
	struct sigevent st_sigevent;
	FAR struct posix_timer_s *timer;
	FAR struct posix_timer_s *next;

	int initalloc_cnt = 0;
	int initfree_cnt = 0;
	int createalloc_cnt = 0;
	int createfree_cnt = 0;
	int finalalloc_cnt = 0;
	int finalfree_cnt = 0;

	/* Set and enable alarm */
	st_sigevent.sigev_notify = SIGEV_SIGNAL;
	st_sigevent.sigev_signo = sig_no;
	st_sigevent.sigev_value.sival_ptr = &timer_id;

	/* check the count for g_alloctimers and g_freetimers after timer_initialize */
	timer_initialize();

	for (timer = (FAR struct posix_timer_s *)g_alloctimers.head; timer; timer = next) {
		next = timer->flink;
		initalloc_cnt++;
	}

	for (timer = (FAR struct posix_timer_s *)g_freetimers.head; timer; timer = next) {
		next = timer->flink;
		initfree_cnt++;
	}

	/* check the count for g_alloctimers and g_freetimers after create now they change */
	timer_create(clockid, &st_sigevent, &timer_id);

	for (timer = (FAR struct posix_timer_s *)g_alloctimers.head; timer; timer = next) {
		next = timer->flink;
		createalloc_cnt++;
	}

	for (timer = (FAR struct posix_timer_s *)g_freetimers.head; timer; timer = next) {
		next = timer->flink;
		createfree_cnt++;
	}

	/* check the count for g_alloctimers and g_freetimers after timer_initialize now they change to original value */
	timer_initialize();

	for (timer = (FAR struct posix_timer_s *)g_alloctimers.head; timer; timer = next) {
		next = timer->flink;
		finalalloc_cnt++;
	}

	for (timer = (FAR struct posix_timer_s *)g_freetimers.head; timer; timer = next) {
		next = timer->flink;
		finalfree_cnt++;
	}

	TC_ASSERT_EQ_CLEANUP("timer_initialise", initalloc_cnt, finalalloc_cnt, timer_delete(timer_id));
	TC_ASSERT_EQ_CLEANUP("timer_initialise", initfree_cnt, finalfree_cnt, timer_delete(timer_id));
	TC_ASSERT_NEQ_CLEANUP("timer_initialise", createalloc_cnt, finalalloc_cnt, timer_delete(timer_id));
	TC_ASSERT_NEQ_CLEANUP("timer_initialise", createfree_cnt, finalfree_cnt, timer_delete(timer_id));

	timer_delete(timer_id);
	TC_SUCCESS_RESULT();
}
Example #22
0
int fastboot_init(void *base, unsigned size)
{
	thread_t *thr;

	dprintf(ALWAYS, "fastboot_init()\n");

	download_base = base;
	download_max = size;

	//mtk_wdt_disable(); /*It will re-enable during continue boot*/
	timer_initialize(&wdt_timer);
	timer_set_periodic(&wdt_timer, 5000, (timer_callback)mtk_wdt_restart, NULL);

	fastboot_register("getvar:", cmd_getvar, TRUE);
	fastboot_publish("version", "0.5");
#ifndef USER_BUILD
	fastboot_register("boot", cmd_boot, FALSE);
#endif
	fastboot_register("signature", cmd_install_sig, FALSE);
#ifdef USE_G_ORIGINAL_PROTOCOL

	fastboot_register("flash:", cmd_flash_mmc, TRUE);
	#ifndef USER_BUILD
	fastboot_register("erase:", cmd_erase_mmc, TRUE);
	#endif
#else
#ifdef MTK_EMMC_SUPPORT
	fastboot_register("flash:", cmd_flash_emmc, TRUE);
	#ifndef USER_BUILD
	fastboot_register("erase:", cmd_erase_emmc, TRUE);
	#endif
#else
	fastboot_register("flash:", cmd_flash_nand, TRUE);
	#ifndef USER_BUILD
	fastboot_register("erase:", cmd_erase_nand, TRUE);
	#endif
#endif

#endif


	fastboot_register("continue", cmd_continue, FALSE);
	fastboot_register("reboot", cmd_reboot, FALSE);
	fastboot_register("reboot-bootloader", cmd_reboot_bootloader, FALSE);
	fastboot_publish("product", TARGET(BOARD));
	fastboot_publish("kernel", "lk");
	register_secure_unlocked_var();
#ifdef MTK_OFF_MODE_CHARGE_SUPPORT
	register_off_mode_charge_var();
#endif
	//fastboot_publish("serialno", sn_buf);

	register_parition_var();


	/*LXO: Download related command*/
	fastboot_register("download:", cmd_download, TRUE);
	fastboot_publish("max-download-size", "0x8000000"); //128M = 134217728
	/*LXO: END!Download related command*/

	fastboot_oem_register();

    fastboot_register("oem p2u", cmd_oem_p2u, FALSE);
    fastboot_register("oem reboot-recovery",cmd_oem_reboot2recovery, FALSE);
    fastboot_register("oem append-cmdline",cmd_oem_append_cmdline,FALSE);
#ifdef MTK_OFF_MODE_CHARGE_SUPPORT
	fastboot_register("oem off-mode-charge",cmd_oem_off_mode_charge,FALSE);
#endif
    #ifdef MTK_TC7_COMMON_DEVICE_INTERFACE
    fastboot_register("oem auto-ADB",cmd_oem_ADB_Auto_Enable,FALSE);
    #endif
#if defined(MTK_SECURITY_SW_SUPPORT) && defined(MTK_SEC_FASTBOOT_UNLOCK_SUPPORT)
    fastboot_register("oem unlock",fastboot_oem_unlock, TRUE);
    fastboot_register("oem lock",fastboot_oem_lock, TRUE);
    fastboot_register("oem key",fastboot_oem_key,TRUE);
    fastboot_register("oem lks",fastboot_oem_query_lock_state,TRUE);
#endif
	event_init(&usb_online, 0, EVENT_FLAG_AUTOUNSIGNAL);
	event_init(&txn_done, 0, EVENT_FLAG_AUTOUNSIGNAL);

	in = udc_endpoint_alloc(UDC_TYPE_BULK_IN, 512);
	if (!in)
		goto fail_alloc_in;
	out = udc_endpoint_alloc(UDC_TYPE_BULK_OUT, 512);
	if (!out)
		goto fail_alloc_out;

	fastboot_endpoints[0] = in;
	fastboot_endpoints[1] = out;

	req = udc_request_alloc();
	if (!req)
		goto fail_alloc_req;

	if (udc_register_gadget(&fastboot_gadget))
		goto fail_udc_register;

	thr = thread_create("fastboot", fastboot_handler, 0, DEFAULT_PRIORITY, 4096);
	if (!thr)
	{
		goto fail_alloc_in;
	}
	thread_resume(thr);
	return 0;

fail_udc_register:
	udc_request_free(req);
fail_alloc_req:
	udc_endpoint_free(out);
fail_alloc_out:
	udc_endpoint_free(in);
fail_alloc_in:
	return -1;
}
Example #23
0
void
_kernel_call_inirtn(void)
{
	app_init( (VP_INT)(0) );
	timer_initialize( (VP_INT)(0) );
}
Example #24
0
void os_start(void)
{
  int i;

  slldbg("Entry\n");

  /* Initialize RTOS Data ***************************************************/
  /* Initialize all task lists */

  dq_init(&g_readytorun);
  dq_init(&g_pendingtasks);
  dq_init(&g_waitingforsemaphore);
#ifndef CONFIG_DISABLE_SIGNALS
  dq_init(&g_waitingforsignal);
#endif
#ifndef CONFIG_DISABLE_MQUEUE
  dq_init(&g_waitingformqnotfull);
  dq_init(&g_waitingformqnotempty);
#endif
#ifdef CONFIG_PAGING
  dq_init(&g_waitingforfill);
#endif
  dq_init(&g_inactivetasks);
  sq_init(&g_delayed_kufree);
#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \
     defined(CONFIG_MM_KERNEL_HEAP)
  sq_init(&g_delayed_kfree);
#endif

  /* Initialize the logic that determine unique process IDs. */

  g_lastpid = 0;
  for (i = 0; i < CONFIG_MAX_TASKS; i++)
    {
      g_pidhash[i].tcb = NULL;
      g_pidhash[i].pid = INVALID_PROCESS_ID;
    }

  /* Assign the process ID of ZERO to the idle task */

  g_pidhash[PIDHASH(0)].tcb = &g_idletcb.cmn;
  g_pidhash[PIDHASH(0)].pid = 0;

  /* Initialize the IDLE task TCB *******************************************/
  /* Initialize a TCB for this thread of execution.  NOTE:  The default
   * value for most components of the g_idletcb are zero.  The entire
   * structure is set to zero.  Then only the (potentially) non-zero
   * elements are initialized. NOTE:  The idle task is the only task in
   * that has pid == 0 and sched_priority == 0.
   */

  bzero((void*)&g_idletcb, sizeof(struct task_tcb_s));
  g_idletcb.cmn.task_state = TSTATE_TASK_RUNNING;
  g_idletcb.cmn.entry.main = (main_t)os_start;
  g_idletcb.cmn.flags      = TCB_FLAG_TTYPE_KERNEL;

  /* Set the IDLE task name */

#if CONFIG_TASK_NAME_SIZE > 0
  strncpy(g_idletcb.cmn.name, g_idlename, CONFIG_TASK_NAME_SIZE);
  g_idletcb.cmn.name[CONFIG_TASK_NAME_SIZE] = '\0';
#endif /* CONFIG_TASK_NAME_SIZE */

  /* Configure the task name in the argument list.  The IDLE task does
   * not really have an argument list, but this name is still useful
   * for things like the NSH PS command.
   *
   * In the kernel mode build, the arguments are saved on the task's stack
   * and there is no support that yet.
   */

#if CONFIG_TASK_NAME_SIZE > 0
  g_idleargv[0]  = g_idletcb.cmn.name;
#else
  g_idleargv[0]  = (FAR char *)g_idlename;
#endif /* CONFIG_TASK_NAME_SIZE */
  g_idleargv[1]  = NULL;
  g_idletcb.argv = g_idleargv;

  /* Then add the idle task's TCB to the head of the ready to run list */

  dq_addfirst((FAR dq_entry_t*)&g_idletcb, (FAR dq_queue_t*)&g_readytorun);

  /* Initialize the processor-specific portion of the TCB */

  up_initial_state(&g_idletcb.cmn);

  /* Initialize RTOS facilities *********************************************/
  /* Initialize the semaphore facility.  This has to be done very early
   * because many subsystems depend upon fully functional semaphores.
   */

  sem_initialize();

#if defined(MM_KERNEL_USRHEAP_INIT) || defined(CONFIG_MM_KERNEL_HEAP) || defined(CONFIG_MM_PGALLOC)
  /* Initialize the memory manager */

  {
    FAR void *heap_start;
    size_t heap_size;

#ifdef MM_KERNEL_USRHEAP_INIT
    /* Get the user-mode heap from the platform specific code and configure
     * the user-mode memory allocator.
     */

    up_allocate_heap(&heap_start, &heap_size);
    kumm_initialize(heap_start, heap_size);
#endif

#ifdef CONFIG_MM_KERNEL_HEAP
    /* Get the kernel-mode heap from the platform specific code and configure
     * the kernel-mode memory allocator.
     */

    up_allocate_kheap(&heap_start, &heap_size);
    kmm_initialize(heap_start, heap_size);
#endif

#ifdef CONFIG_MM_PGALLOC
    /* If there is a page allocator in the configuration, then get the page
     * heap information from the platform-specific code and configure the
     * page allocator.
     */

    up_allocate_pgheap(&heap_start, &heap_size);
    mm_pginitialize(heap_start, heap_size);
#endif
  }
#endif

#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
  /* Initialize tasking data structures */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (task_initialize != NULL)
#endif
    {
      task_initialize();
    }
#endif

  /* Initialize the interrupt handling subsystem (if included) */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (irq_initialize != NULL)
#endif
    {
      irq_initialize();
    }

  /* Initialize the watchdog facility (if included in the link) */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (wd_initialize != NULL)
#endif
    {
      wd_initialize();
    }

  /* Initialize the POSIX timer facility (if included in the link) */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (clock_initialize != NULL)
#endif
    {
      clock_initialize();
    }

#ifndef CONFIG_DISABLE_POSIX_TIMERS
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (timer_initialize != NULL)
#endif
    {
      timer_initialize();
    }
#endif

#ifndef CONFIG_DISABLE_SIGNALS
  /* Initialize the signal facility (if in link) */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (sig_initialize != NULL)
#endif
    {
      sig_initialize();
    }
#endif

#ifndef CONFIG_DISABLE_MQUEUE
  /* Initialize the named message queue facility (if in link) */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (mq_initialize != NULL)
#endif
    {
      mq_initialize();
    }
#endif

#ifndef CONFIG_DISABLE_PTHREAD
  /* Initialize the thread-specific data facility (if in link) */

#ifdef CONFIG_HAVE_WEAKFUNCTIONS
  if (pthread_initialize != NULL)
#endif
    {
      pthread_initialize();
    }
#endif

#if CONFIG_NFILE_DESCRIPTORS > 0
  /* Initialize the file system (needed to support device drivers) */

  fs_initialize();
#endif

#ifdef CONFIG_NET
  /* Initialize the networking system.  Network initialization is
   * performed in two steps:  (1) net_setup() initializes static
   * configuration of the network support.  This must be done prior
   * to registering network drivers by up_initialize().  This step
   * cannot require upon any hardware-depending features such as
   * timers or interrupts.
   */

  net_setup();
#endif

  /* The processor specific details of running the operating system
   * will be handled here.  Such things as setting up interrupt
   * service routines and starting the clock are some of the things
   * that are different for each  processor and hardware platform.
   */

  up_initialize();

#ifdef CONFIG_NET
  /* Complete initialization the networking system now that interrupts
   * and timers have been configured by up_initialize().
   */

  net_initialize();
#endif

#ifdef CONFIG_MM_SHM
  /* Initialize shared memory support */

  shm_initialize();
#endif

  /* Initialize the C libraries.  This is done last because the libraries
   * may depend on the above.
   */

  lib_initialize();

  /* IDLE Group Initialization **********************************************/
#ifdef HAVE_TASK_GROUP
  /* Allocate the IDLE group */

  DEBUGVERIFY(group_allocate(&g_idletcb, g_idletcb.cmn.flags));
#endif

#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
  /* Create stdout, stderr, stdin on the IDLE task.  These will be
   * inherited by all of the threads created by the IDLE task.
   */

  DEBUGVERIFY(group_setupidlefiles(&g_idletcb));
#endif

#ifdef HAVE_TASK_GROUP
  /* Complete initialization of the IDLE group.  Suppress retention
   * of child status in the IDLE group.
   */

  DEBUGVERIFY(group_initialize(&g_idletcb));
  g_idletcb.cmn.group->tg_flags = GROUP_FLAG_NOCLDWAIT;
#endif

  /* Bring Up the System ****************************************************/
  /* Create initial tasks and bring-up the system */

  DEBUGVERIFY(os_bringup());

  /* The IDLE Loop **********************************************************/
  /* When control is return to this point, the system is idle. */

  sdbg("Beginning Idle Loop\n");
  for (;;)
    {
      /* Perform garbage collection (if it is not being done by the worker
       * thread).  This cleans-up memory de-allocations that were queued
       * because they could not be freed in that execution context (for
       * example, if the memory was freed from an interrupt handler).
       */

#ifndef CONFIG_SCHED_WORKQUEUE
      /* We must have exclusive access to the memory manager to do this
       * BUT the idle task cannot wait on a semaphore.  So we only do
       * the cleanup now if we can get the semaphore -- this should be
       * possible because if the IDLE thread is running, no other task is!
       *
       * WARNING: This logic could have undesirable side-effects if priority
       * inheritance is enabled.  Imaginee the possible issues if the
       * priority of the IDLE thread were to get boosted!  Moral: If you
       * use priority inheritance, then you should also enable the work
       * queue so that is done in a safer context.
       */

      if (kmm_trysemaphore() == 0)
        {
          sched_garbagecollection();
          kmm_givesemaphore();
        }
#endif

      /* Perform any processor-specific idle state operations */

      up_idle();
    }
}
Example #25
0
void
_kernel_call_inirtn(void)
{
	timer_initialize( (VP_INT)(0) );
	serial_initialize( (VP_INT)(& hw_serial_rsc_def) );
}