Example #1
0
static int __init lirc_bbb_init_module(void)
{
	int result, i;

	result = lirc_bbb_init();
	if (result)
		return result;

	driver.features = LIRC_CAN_SET_SEND_DUTY_CYCLE |
			  LIRC_CAN_SET_SEND_CARRIER |
			  LIRC_CAN_SEND_PULSE |
			  LIRC_CAN_REC_MODE2;
	driver.dev = &lirc_bbb_dev->dev;
	driver.minor = lirc_register_driver(&driver);
	if (driver.minor < 0) {
		printk(KERN_ERR LIRC_DRIVER_NAME
		       ": device registration failed with %d\n", result);
		result = -EIO;
		goto exit;
	}

	result = init_port();
	if (result < 0)
		goto unregister;

	return 0;

unregister:
	lirc_unregister_driver(driver.minor);

exit:
	lirc_bbb_exit();

	return result;
}
Example #2
0
static void __init brcm_setup_early_printk(void)
{
	char *arg = strstr(arcs_cmdline, "console=");
	int dev = CONFIG_BRCM_CONSOLE_DEVICE;
	const unsigned long base[] = {
		BCHP_UARTA_REG_START, BCHP_UARTB_REG_START,
#ifdef CONFIG_BRCM_HAS_UARTC
		BCHP_UARTC_REG_START,
#endif
		0, 0,
	};

	if (strstr(arcs_cmdline, "login="******"debug=")) {
		cfe_lock_console_in = 0;
	}

	/*
	 * quick command line parse to pick the early printk console
	 * valid formats:
	 *   console=ttyS0,115200
	 *   console=0,115200
	 */
	while (arg && *arg != '\0' && *arg != ' ') {
		if ((*arg >= '0') && (*arg <= '3')) {
			dev = *arg - '0';
			if (base[dev] == 0)
				dev = 0;
			break;
		}
		arg++;
	}
	brcm_early_uart = base[dev];
	init_port();
}
Example #3
0
int main(void) {
	
	init_port();
	init_interrupt();

	sei();

	while(1) {
		
		if( i+j==38 ) {
			
			PORTB = 0x80;
			_delay_ms(300);
			PORTB = 0x00;

			i=0;
			j=0;

		}
	
	}

	return 0;

}
Example #4
0
/* Main routine */
void main(void)
{
    /* Initialize everything */

    init_port();   
    init_devices(); 
    init_adc();

    /* fading(); */
    /* adctest(); */
    
    /* Phase 1: use full power level */
    const_power(POWER_FULL, 1500, LED_ON, NO_DETECT_LV);
    
    /* Phase 2: transit from full level to holding level*/
    transit_power(POWER_FULL, POWER_HOLD, 1);
    
    /* Phase 3: Hold on holding level */
    if (const_power(POWER_HOLD, DEADLOOP, LED_BLINK, DETECT_LV) < 0)
    {
        /* Recommended steps: 
           const_power(POWER_ZERO); 
           delay(sometime, e.g.50ms);
           const_power(max); */
        const_power(POWER_HOLD, DEADLOOP, LED_OFF, NO_DETECT_LV);
    }
}
Example #5
0
/*======================================================================*
                            cstart
 *======================================================================*/
PUBLIC void cstart()
{
	disp_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
		 "-----\"cstart\" begins-----\n");

		 
	/* 将 LOADER 中的 GDT 复制到新的 GDT 中 */
	memcpy(&gdt,     /* New GDT */
	(void*)(*((u32*)(&gdt_ptr[2]))),/* Base  of Old GDT */
	*((u16*)(&gdt_ptr[0])) + 1 /* Limit of Old GDT */
		);
	/* gdt_ptr[6] 共 6 个字节:0~15:Limit  16~47:Base。用作 sgdt/lgdt 的参数。*/
	u16* p_gdt_limit = (u16*)(&gdt_ptr[0]);
	u32* p_gdt_base	 = (u32*)(&gdt_ptr[2]);
	*p_gdt_limit = GDT_SIZE * sizeof(DESCRIPTOR) - 1;
	*p_gdt_base	 = (u32)&gdt;	
	
	/* idt_ptr[6] 共 6 个字节:0~15:Limit  16~47:Base。用作 sidt/lidt 的参数。*/
	u16* p_idt_limit = (u16*)(&idt_ptr[0]);
	u32* p_idt_base  = (u32*)(&idt_ptr[2]);
	*p_idt_limit = IDT_SIZE * sizeof(GATE) - 1;
	*p_idt_base  = (u32)&idt;

	init_port();

	disp_str("-----\"cstart\" ends-----\n");
}
Example #6
0
void 
cstart(void)
{
  uint16_t* p_gdt_limit;
  uint32_t* p_gdt_base;
  uint16_t* p_idt_limit;
  uint32_t* p_idt_base;

  display_str("\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
      "=====<cstart> begins=====\n");

  /* copy GDT from LOADER to new GDT */
  memcpy(&gdt, (void*)(*((uint32_t*)(&gdt_ptr[2]))), /* base of old GDT */
      *((uint16_t*)(&gdt_ptr[0])) + 1); /* limit of old GDT */
  
  p_gdt_limit = (uint16_t*)(&gdt_ptr[0]);
  p_gdt_base  = (uint32_t*)(&gdt_ptr[2]);
  *p_gdt_limit  = GDT_SIZE * sizeof(descriptor_t) - 1;
  *p_gdt_base   = (uint32_t)&gdt;

  p_idt_limit = (uint16_t*)(&idt_ptr[0]);
  p_idt_base  = (uint32_t*)(&idt_ptr[2]);
  *p_idt_limit  = IDT_SIZE * sizeof(gate_t) - 1;
  *p_idt_base   = (uint32_t)&idt;

  init_port();

  display_str("=====<cstart> ends=====\n");
}
Example #7
0
static int __init lirc_rpi_init_module(void)
{
	int result;

	result = lirc_rpi_init();
	if (result)
		return result;

	result = init_port();
	if (result < 0)
		goto exit_rpi;

	driver.features = LIRC_CAN_SET_SEND_DUTY_CYCLE |
			  LIRC_CAN_SET_SEND_CARRIER |
			  LIRC_CAN_SEND_PULSE;

	driver.dev = &lirc_rpi_dev->dev;
	driver.minor = lirc_register_driver(&driver);

	if (driver.minor < 0) {
		printk(KERN_ERR LIRC_DRIVER_NAME
		       ": device registration failed with %d\n", result);
		result = -EIO;
		goto exit_rpi;
	}

	printk(KERN_INFO LIRC_DRIVER_NAME ": driver registered!\n");

	return 0;

	exit_rpi:
	lirc_rpi_exit();

	return result;
}
Example #8
0
File: stdio.c Project: MyEyes/Nos
FILE fs_open(FILE dir, const char *path)
{
	//Set up a port to receive the result
	int portnum = get_free_port();
	init_port(portnum, 128);
	open_port(portnum);
	
	//Have required memory on stack
	ipc_msg_hdr_t curr_msg;
	FILE result;
	result.handle = -1;
	
	char* cmd_buf = malloc(sizeof(char)+sizeof(fs_cmd_getfile_parm)+(strlen(path)+1)*sizeof(char));
	*cmd_buf = FS_CMD_GETFILE;
	fs_cmd_getfile_parm* parm = (fs_cmd_getfile_parm*) (cmd_buf+1);
	parm->dir = dir;
	memcpy(parm->filename, path, strlen(path)+1);
	int res = send_to_port(IPC_PORT_FILESYSTEM, portnum, cmd_buf, sizeof(fs_cmd_getfile_parm)+(strlen(path)+2)*sizeof(char));
	if(res==0)
	{
		while(get_ipc_message(portnum, &curr_msg, (char*)&result, sizeof(FILE))<0)
			yield_control_to_port(IPC_PORT_FILESYSTEM);
	}
	else
		print("Couldn't send to fs port\n");
	free_port(portnum);
	free(parm);
	return result;
}
Example #9
0
//
// Constructor
//
InetSocketAddress::InetSocketAddress(const char* hostname, in_port_t port, bool ipv6)
throw(IllegalArgumentException)
{
    _ipv6 = ipv6;

    // Inicializa el puerto
    init_port(port);

    // Intenta resolver la direccion IP de "hostname"
    InetAddress* inaddr = NULL;
    try
    {
        inaddr = InetAddress::getByName(hostname);
    }
    catch(...)
    {
        _resolved = false;
        init_addr(NULL);
        return;
    }

    // Inicializa la direccion IP y libera el objeto InetAddress
    init_addr(inaddr);
    delete inaddr;
}
Example #10
0
int main(void)
{
  uint16_t i;
  FRESULT rc;

  map_io();
  init_port();

  InitRTCC();

  uart2_init();
  xdev_out(uart2_put);
  xdev_in(uart2_get);

  dbg_printf("$" PROJECT_NAME "\n");
  dbg_printf("$" __DATE__ " " __TIME__ "\n");

  rc = f_mount(&fatfs, "", 1);
  dbg_printf("$FF,f_mount,%s\n", get_rc(rc));

  OpenTimer1(T1_PS_1_256 & T1_GATE_OFF & T1_SOURCE_INT & T1_IDLE_CON &
    T1_ON & T1_SYNC_EXT_OFF, 0xFFFF);
  ConfigIntTimer1(T1_INT_ON & T1_INT_PRIOR_1);
  OpenCapture1(IC_IDLE_STOP & IC_TIMER1_SRC & IC_INT_1CAPTURE & IC_EVERY_RISE_EDGE,
    IC_CASCADE_DISABLE & IC_TRIGGER_ENABLE & IC_UNTRIGGER_TIMER & IC_SYNC_TRIG_IN_DISABLE);
  ConfigIntCapture1(IC_INT_ON & IC_INT_PRIOR_5);
  _IC1IF = 0;
  

  while (1) {
    while (_RTCSYNC == 0);
    while (_RTCSYNC == 1);
    if (gps_pr > 0) {
      _T1IE = 0;
      float f = (float) TMR1 / gps_pr;
      _T1IE = 1;
      xprintf("%u\n", (uint16_t) (f * 1000));
    }
    if (ngpslines > 0) {
      ngpslines--;
      if (xgets(gps_line, 128)) {
        xprintf("$GPS%s\n", gps_line);
      }
    }
  }

  while (0) {
    while (_RTCSYNC == 0);
    while (_RTCSYNC == 1);
    if (gps_pr > 0) {
      _T1IE = 0;
      float f = (float) TMR1 / gps_pr;
      _T1IE = 1;
      xprintf("%u\n", (uint16_t) (f * 1000));
    }
  }

  return (EXIT_SUCCESS);
}
Example #11
0
void SystemInit()
{
	FLASH->ACR = 0x00000012;
	init_clock();
	init_lcd();
	init_port();
	init_usart();
}
Example #12
0
/*---------------------------------------------------------------------------*/
extern void lac_init_system(Lac_system *system)
{
    Lac_port *p;

    p = &system->ports;
    while ((p = p->next) != &system->ports)
        init_port(p, Lacp_enabled);
}
Example #13
0
void m6510_device::device_start()
{
	if(cache_disabled)
		mintf = std::make_unique<mi_6510_nd>(this);
	else
		mintf = std::make_unique<mi_6510_normal>(this);

	init();
	init_port();
}
Example #14
0
/*---------------------------------------------------------------------------*/
extern void lac_init_port(Lac_system *system, Port_no port_no,
                          Boolean lacp_enabled)
{
    Lac_port *p;
    if (find_port(system, port_no, &p))
    {
        init_port(p, lacp_enabled);
        enable_port(p);
    }
}
Example #15
0
/**
 * Main init function for the multi-process server app,
 * calls subfunctions to do each stage of the initialisation.
 */
int
init(int argc, char *argv[])
{
	int retval;
	const struct rte_memzone *mz;
	uint8_t i, total_ports;

	/* init EAL, parsing EAL args */
	retval = rte_eal_init(argc, argv);
	if (retval < 0)
		return -1;
	argc -= retval;
	argv += retval;

	/* initialise the nic drivers */
	retval = init_drivers();
	if (retval != 0)
		rte_exit(EXIT_FAILURE, "Cannot initialise drivers\n");

	/* get total number of ports */
	total_ports = rte_eth_dev_count();

	/* set up array for port data */
	mz = rte_memzone_reserve(MZ_PORT_INFO, sizeof(*ports),
				rte_socket_id(), NO_FLAGS);
	if (mz == NULL)
		rte_exit(EXIT_FAILURE, "Cannot reserve memory zone for port information\n");
	memset(mz->addr, 0, sizeof(*ports));
	ports = mz->addr;

	/* parse additional, application arguments */
	retval = parse_app_args(total_ports, argc, argv);
	if (retval != 0)
		return -1;

	/* initialise mbuf pools */
	retval = init_mbuf_pools();
	if (retval != 0)
		rte_exit(EXIT_FAILURE, "Cannot create needed mbuf pools\n");

	/* now initialise the ports we will use */
	for (i = 0; i < ports->num_ports; i++) {
		retval = init_port(ports->id[i]);
		if (retval != 0)
			rte_exit(EXIT_FAILURE, "Cannot initialise port %u\n",
					(unsigned)i);
	}

	check_all_ports_link_status(ports->num_ports, (~0x0));

	/* initialise the client queues/rings for inter-eu comms */
	init_shm_rings();

	return 0;
}
/* Main function */
int main(int argc, char **argv)
{
	int ret;
	int i;

	/* Create handler for SIGINT for CTRL + C closing and SIGALRM to print stats*/
	signal(SIGINT, sig_handler);
	signal(SIGALRM, alarm_routine);

	/* Initialize DPDK enviroment with args, then shift argc and argv to get application parameters */
	ret = rte_eal_init(argc, argv);
	if (ret < 0) FATAL_ERROR("Cannot init EAL\n");
	argc -= ret;
	argv += ret;

	/* Check if this application can use 1 core*/
	ret = rte_lcore_count ();
	if (ret != 2) FATAL_ERROR("This application needs exactly 2 cores.");

	/* Parse arguments */
	parse_args(argc, argv);
	if (ret < 0) FATAL_ERROR("Wrong arguments\n");

	/* Probe PCI bus for ethernet devices, mandatory only in DPDK < 1.8.0 */
	#if RTE_VER_MAJOR == 1 && RTE_VER_MINOR < 8
		ret = rte_eal_pci_probe();
		if (ret < 0) FATAL_ERROR("Cannot probe PCI\n");
	#endif

	/* Get number of ethernet devices */
	nb_sys_ports = rte_eth_dev_count();
	if (nb_sys_ports <= 0) FATAL_ERROR("Cannot find ETH devices\n");
	
	/* Create a mempool with per-core cache, initializing every element for be used as mbuf, and allocating on the current NUMA node */
	pktmbuf_pool = rte_mempool_create(MEMPOOL_NAME, buffer_size-1, MEMPOOL_ELEM_SZ, MEMPOOL_CACHE_SZ, sizeof(struct rte_pktmbuf_pool_private), rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,rte_socket_id(), 0);
	if (pktmbuf_pool == NULL) FATAL_ERROR("Cannot create cluster_mem_pool. Errno: %d [ENOMEM: %d, ENOSPC: %d, E_RTE_NO_TAILQ: %d, E_RTE_NO_CONFIG: %d, E_RTE_SECONDARY: %d, EINVAL: %d, EEXIST: %d]\n", rte_errno, ENOMEM, ENOSPC, E_RTE_NO_TAILQ, E_RTE_NO_CONFIG, E_RTE_SECONDARY, EINVAL, EEXIST  );
	
	/* Create a ring for exchanging packets between cores, and allocating on the current NUMA node */
	intermediate_ring = rte_ring_create 	(RING_NAME, buffer_size, rte_socket_id(), RING_F_SP_ENQ | RING_F_SC_DEQ );
 	if (intermediate_ring == NULL ) FATAL_ERROR("Cannot create ring");


	/* Operations needed for each ethernet device */			
	for(i=0; i < nb_sys_ports; i++)
		init_port(i);

	/* Start consumer and producer routine on 2 different cores: producer launched first... */
	ret =  rte_eal_mp_remote_launch (main_loop_producer, NULL, SKIP_MASTER);
	if (ret != 0) FATAL_ERROR("Cannot start consumer thread\n");	

	/* ... and then loop in consumer */
	main_loop_consumer ( NULL );	

	return 0;
}
Example #17
0
//
// Constructor
//
InetSocketAddress::InetSocketAddress(in_port_t port, bool ipv6)
throw(IllegalArgumentException)
{
    _ipv6 = ipv6;

    // Inicializa el puerto
    init_port(port);

    // Inicializa la direccion IP
    init_addr(NULL);
}
Example #18
0
// init_all_ports_of_commutator: initialise les ports du commutateur
void init_all_ports_of_commutator () {
	Port* ports;
	ports = commutateur.ports;
	int i;
	// TODO: poser le verrou sur le commutateur 
	// P(COMMUTATOR_VERROU);
	for (i=0; i<NBR_MAX_PORT;i++) {
		ports[i] = *(init_port( i+1));
	}
	// TODO: liberer le verrou sur le commutateur 
	// V(COMMUTATOR_VERROU);
}
Example #19
0
int init_lirc_it87(void)
{
	int retval;
	
	init_waitqueue_head(&lirc_read_queue);
	retval = init_port();
	if (retval < 0)
		return retval;
	init_hardware();
	printk(KERN_INFO LIRC_DRIVER_NAME
	       ": Installed.\n");
	return 0;
}
Example #20
0
void m6508_device::device_start()
{
	if(cache_disabled)
		mintf = std::make_unique<mi_6508_nd>(this);
	else
		mintf = std::make_unique<mi_6508_normal>(this);

	init();
	init_port();

	ram_page = make_unique_clear<uint8_t[]>(256);
	save_pointer(NAME(ram_page), 256);
}
Example #21
0
File: lyc.c Project: panticz/lyc
/*
* main
*/
int main(int argc, char **argv) {
    if(argc == 1) {
        return 1;
    }
        
    fd = open_port();

    if(fd == -1) {
        printf("Error opening serial port\n");
    } else {
        if(init_port() == -1) {  
            sleep(.5);
            printf("Error initializing serial port\n");

            close(fd);
            return 0;
        }

        sleep(.5);
        init_cmd();

/*
        // todo: recive response from reciver
        if (n < 0) {
            fputs("write() of X bytes failed!\n", stderr);
        } else {
            printf("Successfully wrote 8 bytes\n");

            sleep(.5);
            char buffer[200];
            int n = read(fd, buffer, sizeof(buffer));
            sleep(.5);
            if (n < 0) {
                fputs("read failed!\n", stderr);
            } else {
                printf("Successfully read from serial port -- %s\n", buffer);
            }
        }
*/

        sleep(.5);
        if(run_cmd(argv[1], argv[2]) == 1) {
            printf("Command not found\n");
        }

        sleep(.5);
        close(fd);
    }

    return 0;
}
Example #22
0
int main(void)
{
	init_port();
	init_interrupt();
	lcd_init();
	DDRA=0xff;
    while(1)
    {
		received=PINC;

		switch(PINC)
		{
			case decVolume:
			{
				vButton--;
				volume
				break;
			}
			case incVolume:
			{
				vButton++;
				break;
			}
			case decSpeed:
			{
				sButton--;				
				speed(vButton);
				break;
			}
			case incSpeed:
			{
				sButton++;
				speed(vButton);				
				break;
			}
			case bass:
			{
				
			}
			case treble:
			{
				
			}
			
			default:{}
			
		}
        
    } //while ends.
}
Example #23
0
static int __init early_serial8250_setup(char *options)
{
	struct early_serial8250_device *device = &early_device;
	int err;

	if (device->port.membase || device->port.iobase)
		return 0;

	if ((err = parse_options(device, options)) < 0)
		return err;

	init_port(device);
	return 0;
}
void SerialLedController::init(void)
{
  /* port initialize*/
  init_port();

  /* select the communication speed. */
  select_baudrate();

  /* reset the controller. */
  shield_reset();

  /* enable the trigger port. */
  enable_trigger();
}
Example #25
0
int main ( int argc, char** argv )
{
    SchObj robj,ret;
    int    opt;
    char * fname = 0;
    char * expr = 0;

#ifdef USE_BOEHM_GC
    GC_INIT();
#endif
    ensure_init_symtable();
    init_reader();
    init_port();

    flag_use_profiler = 0;

    while ( (opt = getopt(argc,argv,"pf:e:")) != -1 ) {
        switch ( opt ) {
        case 'p': {
            flag_use_profiler = 1;
        } break;
        case 'f': {
            fname = SCH_MALLOC(strlen(optarg) + 1);
            strcpy(fname,optarg);
        } break;
        case 'e':{
            expr = SCH_MALLOC(strlen(optarg) + 1);
            strcpy(expr,optarg);
        }break;
        };
    }

    if ( expr ) {
        robj = sch_read_string(expr);
        ret  = vm_compile(robj);
        SCH_WRITE(ret);
        SCH_DISPLAY(SCH_CHAR('\n'));
    } else if ( fname ) {
        sch_load(SCH_STRING_OBJ(SCH_STRING(fname)));
    } else {
        while ( 1 ) {
            robj = sch_read(NULL);
            ret  = vm_compile(robj);
            SCH_WRITE(ret);
        }
    }

    return 0;

}
Example #26
0
static int __init early_uart_setup(struct console *console, char *options)
{
	struct early_uart_device *device = &early_device;
	int err;

	if (device->port.membase || device->port.iobase)
		return 0;

	if ((err = parse_options(device, options)) < 0)
		return err;

	init_port(device);
	return 0;
}
Example #27
0
int main()
{   int a[] = {0,1,2,3,4};
   p[0].in=0; p[0].out=0;
   p[20].in=0; p[20].out=0;
   p[99].in=0; p[99].out=0;
    init_port();
	printf("\nCreating a client\n");
    start_thread(client, &a[0]);
	printf("\nCreating a client\n");
    start_thread(client1, &a[1]);
	printf("\nCreating a server\n");
    start_thread(server, NULL);
	run();
    while (1) sleep(1);
}   
Example #28
0
int main()
{
	int i=0;
	Init();
	init_port();
	
	while(1)
	{
		sendHTTP(GET,NULL);
		delay(1000);
		sendHTTP(POST,"");
		delay(1000);	
	}
	return 0;
}
Example #29
0
int __init init_module(void)
{
	int result;
	
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
	result = lirc_serial_init();
	if(result) return result;
#endif
	switch(type)
	{
	case LIRC_HOMEBREW:
	case LIRC_IRDEO:
	case LIRC_IRDEO_REMOTE:
	case LIRC_ANIMAX:
	case LIRC_IGOR:
#if defined(LIRC_SERIAL_NSLU2)
	case LIRC_NSLU2:
#endif
		break;
	default:
		return -EINVAL;
	}
	if(!softcarrier)
	{
		switch(type)
		{
		case LIRC_HOMEBREW:
		case LIRC_IGOR:
		case LIRC_NSLU2:
			hardware[type].features&=
				~(LIRC_CAN_SET_SEND_DUTY_CYCLE|
				  LIRC_CAN_SET_SEND_CARRIER);
			break;
		}
	}
	if((result = init_port()) < 0)
	{
		return result;
	}
	plugin.features = hardware[type].features;
	if ((plugin.minor = lirc_register_plugin(&plugin)) < 0) {
		printk(KERN_ERR  LIRC_DRIVER_NAME  
		       ": register_chrdev failed!\n");
		release_region(io, 8);
		return -EIO;
	}
	return 0;
}
Example #30
0
File: main.c Project: GBert/misc
void main(void) {
    unsigned char do_print=0;
    unsigned char ret=0;
    unsigned char TaskB='A';
    char c;

    init_port();
    init_timer();

    //infinite loop
    while(1) {
	if (INTCONbits.TMR0IF) {
	    tick();
	}
    }
}