Esempio n. 1
0
void HardwareSetup(void)
{
// Initialize routine
	sci_init(SCI_NO_1, BitRate_type_br9600);
	exp_memory_init();

}
Esempio n. 2
0
int main(int argc,char **argv){
    byte port;
    int i;
    
    if(argc != 3 ){
        fprintf(stderr,"usage: %s com tx_data\t(com: B0=USB0, A0=AMA0)\n",argv[0]);
        return -1;
    }
    if( atoi(argv[1]) < 0 ){
        port = 0x9F + (byte)(-atoi(argv[1])) ;
    }else  if( ( argv[1][0]=='b' || argv[1][0]=='B' )&& argv[1][1]!='\0' ){
        port = 0xB0 + ( argv[1][1] - '0');
    }else  if( ( argv[1][0]=='a' || argv[1][0]=='A' )&& argv[1][1]!='\0' ){
        port = 0xA0 + ( argv[1][1] - '0');
    }else port = (byte)(atoi(argv[1]));
    if( sci_init(port) ==0 ){
        fprintf(stderr,"Serial Open ERROR\n");
        return -1;
    }
    if(strncmp(argv[2],"+++",3)==0){
        puts_serial_port("+++");
        sleep(1);
        usleep(100000);
    }else{
        puts_serial_port(argv[2]);
        puts_serial_port("\r");
    }
    do{
        i=gets_serial_port(rx_data,RX_MAX);
        if(i) printf("%s\n",rx_data);
    }while(i);
    close_serial_port();
    return 0;
}
Esempio n. 3
0
void main(void)
{
	unsigned long int i;
	char str[18] ={0,};

	exp_memory_init();
	sci_init(SCI_NO_1, BitRate_type_br9600);
	sci_write_str(SCI_NO_1, "This is DRAM test!!\r\n");

	// 外部RAM確認
	*(short*)0x410000 = 0x5678;
	sci_write(SCI_NO_1, *(char*)(0x410000 + 0));
	sci_write(SCI_NO_1, *(char*)(0x410000 + 1));

	for(i = 0; i < 0x1FFFFF; i++)
	{
		*(char*)(0x400000 + i) = i % 0xFF;
	}

	for(i = 0; i < 0x1FFFFF; i++)
	{
		sci_write(SCI_NO_1, *(char*)(0x400000 + i));
	}

	while(1);
}
int main(void) {

    sci_init();                 // Initialize the SCI port
    

    while (1) {               // Loop forever
    }

    return 0;   /* never reached */
}
Esempio n. 5
0
// 全体の初期化
void init( void )
{
	// シリアル通信、カウンタ、PWM出力の初期化
	sci_init( 38400 );

	// コンペアマッチタイマの初期化
	setIntMask( 9 );							// レベル10〜15は割り込み許可
	initServo(  );
	noPWM_brake(  );

	initCounter(  );							// エンコーダカウンタの初期化
	initAD(  );
}
Esempio n. 6
0
void main(void)
{
	char c;

	sci_init(SCI_NO_1, BitRate_type_br9600);

	sci_write(SCI_NO_1, 'A');
	sci_write_str(SCI_NO_1,"Hello world!!\n");

	while(1)
	{
		c = sci_read_byte(SCI_NO_1);
		sci_write(SCI_NO_1, c);
	}

}
Esempio n. 7
0
void init()
{
	extern int bss_start, bss_end, data_start, data_end, rodata_end;

	memset(&bss_start, 0, (long)&bss_end - (long)&bss_start);					// Bssセクション初期化
	memcpy(&data_start, &rodata_end, (long)&data_end - (long)&data_start);		// dataセクション初期化
	memset(&buf_start, 0, (long*)0x600);										// bufセクション初期化

	// 割り込みDISABLE
	INTERUUPT_DISABLE

	// ソフト割り込み初期化
	softvec_init();

	// シリアル通信初期化
	sci_init(SCI_NO_1, BitRate_type_br9600);

	boot_main();
}
Esempio n. 8
0
void main(void) {
    
    //byte b;
    
    DDRS_DDRS2 = 1; DDRS_DDRS3 = 1; // Enable LEDs
    DDRJ_DDRJ6 = 0; DDRJ_DDRJ7 = 0; // Enable switches
    
    timer_init();
    CANinit(MSCAN_NODE_ID);
    
    // Clear all MSCAN receiver flags (by setting bits)
    CANRFLG = (CANRFLG_RXF_MASK | CANRFLG_OVRIF_MASK | CANRFLG_CSCIF_MASK | CANRFLG_WUPIF_MASK);
    
    sci_init();
    
#ifdef USE_LCD
    msleep(16); // wait 16ms before init LCD
    LCDinit();  // initialize LCD, cursor should be visible with blink after
#endif
    
#ifdef USE_LCD2
    lcd_init();
#endif
    
#ifdef USE_LED7
    led7_init();
    led7_write(LED7_HBARS);
#endif
    
    EnableInterrupts;
    
    sci_sendBytes((byte*)"Ready", 6);   // Send ready message indicator via serial
    
    for(;;) {
        /*
        while ( sci_bytesAvailable() ) {
            sci_readByte(&b);
            lcd_putc(b);  
        }*/
        RUN();
    }
}
Esempio n. 9
0
void TestApp_Init(void)
{
    uint_8   error;
    
    DisableInterrupts;
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_dis();
#endif
    
#if !(defined _MC9S08JS16_H)
#if (defined MCU_mcf51jf128)
    sci1_init();
#else
    sci_init();
#endif
#endif /* _MC9S08JS16_H */
    
#if  ((defined __MCF52xxx_H__) || (defined __MK_xxx_H__))
    pit1_init();
#elif (defined _MC9S08JM60_H) || (defined _MC9S08JM16_H) || (defined _MC9S08JS16_H)
    rtc_init();
#elif (defined MCU_mcf51jf128)
    ftm0_init();
#else
    cmt_init();
#endif
    
    pwm_init();
    /* Initialize the USB interface */
    error = USB_Class_Audio_Init(CONTROLLER_ID,USB_App_Callback,
                                 NULL,NULL);
    UNUSED(error);
    
    EnableInterrupts;
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_en();
#endif
}
Esempio n. 10
0
//===============================================
//===============================================
//===============================================
//===============================================
void main(void)
{

t0_init();


ei();
PEIE=1;

di();



ei();

TRISB=0x00;
PORTB=0x00;
PORTC|=(1<<led_ERR);
sci_init();


while (1)
	{
	if(bRXIN)
		{
		bRXIN=0;
		UART_IN();
		}
	if(bit_100Hz)
		{
		bit_100Hz=0;

          in_read();
          step_contr();
          mdvr_drv();
		but_drv();
		but_an();
		}
	if(bit_10Hz)
		{
		bit_10Hz=0;
         // out_out();
         	led_out();
         	err_drv();
          prog_drv();

        //	if(prog==p1) OUT(3,CMND,eeprom_read(DELAY1),eeprom_read(DELAY2)/*3,3*/,0,0,0);
        //	else if(prog==p2) OUT(3,CMND,eeprom_read(DELAY3),eeprom_read(DELAY4),0,0,0);
        	if(prog==p3)
        		{
        		if(!sub_ind)adress=DELAY1;
        		else adress=DELAY2;
        		}
        	else if(prog==p4)
        		{
        		if(!sub_ind)adress=DELAY3;
        		else adress=DELAY4;
        		}
        	else if(prog==p1)
        		{
        		if(!sub_ind)adress=DELAY5;
        		else adress=DELAY6;
        		}
        	else if(prog==p2)
        		{
        		if(!sub_ind)adress=DELAY7;
        		else adress=DELAY8;
        		}
          OUT(3,CMND,/*prog*/eeprom_read(adress),sub_ind+1,0,0,0);
		}
	if(bit_1Hz)
		{
		bit_1Hz=0;




		}


	}
}
Esempio n. 11
0
File: gavt2.c Progetto: pal73/GAVT
//===============================================
//===============================================
//===============================================
//===============================================
void main(void)
{

t0_init();


ei();
PEIE=1;

di();



ei();

TRISB=0x00;
PORTB=0x00;
PORTC|=(1<<led_ERR);
sci_init();


while (1)
	{
	if(bRXIN)
		{
		bRXIN=0;
		UART_IN();
		}
	if(bit_100Hz)
		{
		bit_100Hz=0;

          in_read();
          step_contr();
          mdvr_drv();
		but_drv();
		but_an();
		}
	if(bit_10Hz)
		{
		bit_10Hz=0;
         // out_out();
         	led_out();
         	err_drv();
          prog_drv();

        	if(prog==p1) OUT(3,CMND,eeprom_read(DELAY1),eeprom_read(DELAY2),0,0,0);
        	else if(prog==p1) OUT(3,CMND,eeprom_read(DELAY3),eeprom_read(DELAY4),0,0,0);

		}
	if(bit_1Hz)
		{
		bit_1Hz=0;




		}


	}
}
Esempio n. 12
0
int
main(int argc, char *argv[])
{
	int c, error, dbg_port, gdb_port, err, bvmcons;
	int max_vcpus, mptgen, memflags;
	int rtc_localtime;
	bool gdb_stop;
	struct vmctx *ctx;
	uint64_t rip;
	size_t memsize;
	char *optstr;

	bvmcons = 0;
	progname = basename(argv[0]);
	dbg_port = 0;
	gdb_port = 0;
	gdb_stop = false;
	guest_ncpus = 1;
	sockets = cores = threads = 1;
	maxcpus = 0;
	memsize = 256 * MB;
	mptgen = 1;
	rtc_localtime = 1;
	memflags = 0;

	optstr = "abehuwxACHIPSWYp:g:G:c:s:m:l:U:";
	while ((c = getopt(argc, argv, optstr)) != -1) {
		switch (c) {
		case 'a':
			x2apic_mode = 0;
			break;
		case 'A':
			acpi = 1;
			break;
		case 'b':
			bvmcons = 1;
			break;
		case 'p':
                        if (pincpu_parse(optarg) != 0) {
                            errx(EX_USAGE, "invalid vcpu pinning "
                                 "configuration '%s'", optarg);
                        }
			break;
                case 'c':
			if (topology_parse(optarg) != 0) {
			    errx(EX_USAGE, "invalid cpu topology "
				"'%s'", optarg);
			}
			break;
		case 'C':
			memflags |= VM_MEM_F_INCORE;
			break;
		case 'g':
			dbg_port = atoi(optarg);
			break;
		case 'G':
			if (optarg[0] == 'w') {
				gdb_stop = true;
				optarg++;
			}
			gdb_port = atoi(optarg);
			break;
		case 'l':
			if (lpc_device_parse(optarg) != 0) {
				errx(EX_USAGE, "invalid lpc device "
				    "configuration '%s'", optarg);
			}
			break;
		case 's':
			if (pci_parse_slot(optarg) != 0)
				exit(1);
			else
				break;
		case 'S':
			memflags |= VM_MEM_F_WIRED;
			break;
                case 'm':
			error = vm_parse_memsize(optarg, &memsize);
			if (error)
				errx(EX_USAGE, "invalid memsize '%s'", optarg);
			break;
		case 'H':
			guest_vmexit_on_hlt = 1;
			break;
		case 'I':
			/*
			 * The "-I" option was used to add an ioapic to the
			 * virtual machine.
			 *
			 * An ioapic is now provided unconditionally for each
			 * virtual machine and this option is now deprecated.
			 */
			break;
		case 'P':
			guest_vmexit_on_pause = 1;
			break;
		case 'e':
			strictio = 1;
			break;
		case 'u':
			rtc_localtime = 0;
			break;
		case 'U':
			guest_uuid_str = optarg;
			break;
		case 'w':
			strictmsr = 0;
			break;
		case 'W':
			virtio_msix = 0;
			break;
		case 'x':
			x2apic_mode = 1;
			break;
		case 'Y':
			mptgen = 0;
			break;
		case 'h':
			usage(0);			
		default:
			usage(1);
		}
	}
	argc -= optind;
	argv += optind;

	if (argc != 1)
		usage(1);

	vmname = argv[0];
	ctx = do_open(vmname);

	max_vcpus = num_vcpus_allowed(ctx);
	if (guest_ncpus > max_vcpus) {
		fprintf(stderr, "%d vCPUs requested but only %d available\n",
			guest_ncpus, max_vcpus);
		exit(1);
	}

	fbsdrun_set_capabilities(ctx, BSP);

	vm_set_memflags(ctx, memflags);
	err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
	if (err) {
		fprintf(stderr, "Unable to setup memory (%d)\n", errno);
		exit(1);
	}

	error = init_msr();
	if (error) {
		fprintf(stderr, "init_msr error %d", error);
		exit(1);
	}

	init_mem();
	init_inout();
	atkbdc_init(ctx);
	pci_irq_init(ctx);
	ioapic_init(ctx);

	rtc_init(ctx, rtc_localtime);
	sci_init(ctx);

	/*
	 * Exit if a device emulation finds an error in its initilization
	 */
	if (init_pci(ctx) != 0)
		exit(1);

	if (dbg_port != 0)
		init_dbgport(dbg_port);

	if (gdb_port != 0)
		init_gdb(ctx, gdb_port, gdb_stop);

	if (bvmcons)
		init_bvmcons();

	if (lpc_bootrom()) {
		if (vm_set_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, 1)) {
			fprintf(stderr, "ROM boot failed: unrestricted guest "
			    "capability not available\n");
			exit(1);
		}
		error = vcpu_reset(ctx, BSP);
		assert(error == 0);
	}

	error = vm_get_register(ctx, BSP, VM_REG_GUEST_RIP, &rip);
	assert(error == 0);

	/*
	 * build the guest tables, MP etc.
	 */
	if (mptgen) {
		error = mptable_build(ctx, guest_ncpus);
		if (error)
			exit(1);
	}

	error = smbios_build(ctx);
	assert(error == 0);

	if (acpi) {
		error = acpi_build(ctx, guest_ncpus);
		assert(error == 0);
	}

	if (lpc_bootrom())
		fwctl_init();

#ifndef WITHOUT_CAPSICUM
	caph_cache_catpages();

	if (caph_limit_stdout() == -1 || caph_limit_stderr() == -1)
		errx(EX_OSERR, "Unable to apply rights for sandbox");

	if (cap_enter() == -1 && errno != ENOSYS)
		errx(EX_OSERR, "cap_enter() failed");
#endif

	/*
	 * Change the proc title to include the VM name.
	 */
	setproctitle("%s", vmname); 
	
	/*
	 * Add CPU 0
	 */
	fbsdrun_addcpu(ctx, BSP, BSP, rip);

	/*
	 * Head off to the main event dispatch loop
	 */
	mevent_dispatch();

	exit(1);
}
Esempio n. 13
0
void
main(int argc, char ** argv)
{
  struct rcfile contents;
  char * sb_base = NULL,
       * sb = NULL,
       * sbrc_file = NULL,
       * symbolic_name = NULL,
       * submit_set = NULL,
       * set = NULL,
       * file;
  SCI_LIST file_set;
  SCI_ELEM sci_ptr;
  int ct;
  char curdir [PATH_LEN];
  char src_dir [PATH_LEN];
  char lock_file [PATH_LEN];
  int missing_revs;
  char *xlog_rev;
  BOOLEAN xlog_op;

  /* Initialize */
  ui_init ( argc, argv, MAX_ARGS, init, 0, NULL );

  sb = ui_arg_value ( SB_OP, 1, 1 );
  set = ui_arg_value ( SET_OP, 1, 1 );
  sbrc_file = NULL;

  if ( getcwd ( curdir, sizeof(curdir) ) == NULL )
	uquit ( ERROR, FALSE, "Could not get the current working directory.\n");

  handle_switches ();

  symbolic_name = set;
  if ( sci_init ( &contents, &sb, &sb_base, &symbolic_name, &submit_set,
                  &sbrc_file, file_mode, FALSE ) != OK ) {
    exit ( ERROR );
  } /* if */
  if (sci_copyright_init ( &contents, sb_base, sb) != OK) {
       exit( ERROR );
  }

  if ( strcmp ( submit_set, symbolic_name ) == 0 ) {
    ui_print ( VWARN, "User's set cannot be the same as the submit set.\n" );
    ui_print ( VCONT, "User's set and submit set are both: %s\n",
                      submit_set );
    ui_print ( VCONT, "Aborting bci.\n" );
    exit(1);
  } /* if */

  /* src_path is the source directory of the sandbox derived from sci_init() */
  strcpy (sandboxdir, src_path);

  /* Lock the sandbox. */
  concat (src_dir, sizeof(src_dir), sb_base, "/", sb, "/src", NULL);
  concat (lock_file, sizeof(lock_file), src_dir, "/", BCSLOCK, NULL);
  if ( ! lock_sb (src_dir, BCSLOCK, getenv ("USER")) )
	exit (ERROR);


  /* Build up file list of files to process. */
  if ( ui_is_set ( ALL_OP )) {
    sci_all_list ( &file_set, symbolic_name );
  } else {

    sci_new_list ( &file_set );
    for ( ct = 1; ( file = ui_entry_value ( ARGS_OP, ct++ )) != NULL; ) {
      if (file_exists (file, curdir) == TRUE)
      	sci_add_to_list ( file_set, file );
      else {
	ui_print (VWARN, "Could not find file %s in the current sandbox.\n",
		file);
      }
    }

  }
  if ( sci_lookup_leader_list ( file_set ) == ERROR ) {
    exit (-1);
  } /* if */
  if ( sci_lookup_user_rev_list 
		( file_set, symbolic_name, &missing_revs ) == ERROR)
	exit(1);
  if (missing_revs == TRUE) {
    ui_print (VFATAL, "The following files are not in the set %s.\n", symbolic_name);
    for ( sci_ptr = sci_first ( file_set); sci_ptr != NULL;
          sci_ptr = sci_next ( sci_ptr ) ) {
	if (sci_ptr->ver_user == NULL)
		ui_print (VNORMAL, "%s\n", sci_ptr->name);
    }
    exit(1);
  }
  if ( ui_is_set ( XLOG_OP ) ) {
	xlog_op = TRUE;
        if ( ui_is_set ( REVISION_OP ) ) {
	  xlog_rev = ui_arg_value ( REVISION_OP, 1, 1 );
        } else {
          xlog_rev = symbolic_name;
        } /* if */
  } else {
	xlog_op = FALSE;
	xlog_rev = NULL;
  }
  if ( ui_is_set ( MSG_OP ) && ui_is_auto () )
    sci_check_in_list2 ( file_set, symbolic_name, ui_arg_value ( MSG_OP, 1, 1 ),
                         ui_is_set ( DEFUNCT_OP ), xlog_op, xlog_rev );
  else {
    for ( sci_ptr = sci_first ( file_set); sci_ptr != NULL;
          sci_ptr = sci_next ( sci_ptr ) ) {
      if ( sci_check_in_file ( sci_ptr, symbolic_name,
                               ui_arg_value ( MSG_OP, 1, 1 ),
                               ui_is_set ( DEFUNCT_OP ), xlog_op, xlog_rev ) == ABORT ) {
        exit (0);
      } /* if */
    } /* for */
  } /* if */
  exit(0);
}
Esempio n. 14
0
void main(void) {
	unsigned long delay;
	char exit = 'o';
	
  /* Initialization code */
    clock_init(BUS_CLK);
    sci_init(9600, BUS_CLK, SCI0);
    LIN_PHY_ENABLE;
    sci_init(9600, BUS_CLK, SCI1);
    gpio_init();
    LS_Module_Init();
    HS_Module_Init();
    HS0_On();
    PWM_init();
    ADC_init(BUS_CLK);
    
    /* Test serial communication */
    send_string("\n\rSerial Test, press any key\n\r", SCI1);
    echo(SCI1);
    send_string("\n\rTest successful\n\r",SCI1);

	/* Test Relay */
	send_string("\n\rPress u to activate the relay up and d to activate it down\n\r", SCI1);
	send_string("\n\rPres e to exit relay test\n\r", SCI1);
	
	while(exit != 'e'){
		exit = get_char(SCI1);
		put_char(exit, SCI1);
		if(exit == 'u'){
			send_string("\r\nRelay Low side driver 0 active\r\n", SCI1);
			LS0_On();
			for(delay = 0; delay < 30000; ++delay);
			send_string("\r\nRelay Low side driver 0 inactive\r\n", SCI1);
			LS0_Off();
			exit = 'a';	
		} else if (exit == 'd') {
			send_string("\r\nRelay Low side driver 1 active\r\n", SCI1);
			LS1_On();
			for(delay = 0; delay < 30000; ++delay);
			send_string("\r\nRelay Low side driver 1 inactive\r\n", SCI1);
			LS1_Off();
			exit = 'a';
		}		
	}
	
	put_char('\n', SCI1);
	EnableInterrupts;


  for(;;) {
    _FEED_COP(); /* feeds the dog */
    if(read_sw2){
    	LS0_On();
    	send_string("\r\nSwitch 2 pressed\r\n", SCI1);	
    } else {
    	LS0_Off();
    }
    if(read_sw3){
    	LS1_On();
    	send_string("\r\nSwitch 3 pressed\r\n", SCI1);	
    } else {
    	LS1_Off();
    }
    for(delay = 0; delay < 30000; ++delay);
    send_string("\rADC value:   ", SCI1);
    send_string("\b\b\b", SCI1);
    DisplayInt((unsigned char) ADC_read(POT), SCI1);
    put_char(0x55,SCI0);	/* Send stuff through LIN */
  } /* loop forever */
  /* please make sure that you never leave main */
}
Esempio n. 15
0
int
main(int argc, char *argv[])
{
	int c, error, gdb_port, err, bvmcons;
	int dump_guest_memory, max_vcpus, mptgen;
	int rtc_localtime;
	struct vmctx *ctx;
	uint64_t rip;
	size_t memsize;

	bvmcons = 0;
	dump_guest_memory = 0;
	progname = basename(argv[0]);
	gdb_port = 0;
	guest_ncpus = 1;
	memsize = 256 * MB;
	mptgen = 1;
	rtc_localtime = 1;

	while ((c = getopt(argc, argv, "abehuwxACHIPWYp:g:c:s:m:l:U:")) != -1) {
		switch (c) {
		case 'a':
			x2apic_mode = 0;
			break;
		case 'A':
			acpi = 1;
			break;
		case 'b':
			bvmcons = 1;
			break;
		case 'p':
                        if (pincpu_parse(optarg) != 0) {
                            errx(EX_USAGE, "invalid vcpu pinning "
                                 "configuration '%s'", optarg);
                        }
			break;
                case 'c':
			guest_ncpus = atoi(optarg);
			break;
		case 'C':
			dump_guest_memory = 1;
			break;
		case 'g':
			gdb_port = atoi(optarg);
			break;
		case 'l':
			if (lpc_device_parse(optarg) != 0) {
				errx(EX_USAGE, "invalid lpc device "
				    "configuration '%s'", optarg);
			}
			break;
		case 's':
			if (pci_parse_slot(optarg) != 0)
				exit(1);
			else
				break;
                case 'm':
			error = vm_parse_memsize(optarg, &memsize);
			if (error)
				errx(EX_USAGE, "invalid memsize '%s'", optarg);
			break;
		case 'H':
			guest_vmexit_on_hlt = 1;
			break;
		case 'I':
			/*
			 * The "-I" option was used to add an ioapic to the
			 * virtual machine.
			 *
			 * An ioapic is now provided unconditionally for each
			 * virtual machine and this option is now deprecated.
			 */
			break;
		case 'P':
			guest_vmexit_on_pause = 1;
			break;
		case 'e':
			strictio = 1;
			break;
		case 'u':
			rtc_localtime = 0;
			break;
		case 'U':
			guest_uuid_str = optarg;
			break;
		case 'w':
			strictmsr = 0;
			break;
		case 'W':
			virtio_msix = 0;
			break;
		case 'x':
			x2apic_mode = 1;
			break;
		case 'Y':
			mptgen = 0;
			break;
		case 'h':
			usage(0);			
		default:
			usage(1);
		}
	}
	argc -= optind;
	argv += optind;

	if (argc != 1)
		usage(1);

	vmname = argv[0];

	ctx = vm_open(vmname);
	if (ctx == NULL) {
		perror("vm_open");
		exit(1);
	}

	if (guest_ncpus < 1) {
		fprintf(stderr, "Invalid guest vCPUs (%d)\n", guest_ncpus);
		exit(1);
	}

	max_vcpus = num_vcpus_allowed(ctx);
	if (guest_ncpus > max_vcpus) {
		fprintf(stderr, "%d vCPUs requested but only %d available\n",
			guest_ncpus, max_vcpus);
		exit(1);
	}

	fbsdrun_set_capabilities(ctx, BSP);

	if (dump_guest_memory)
		vm_set_memflags(ctx, VM_MEM_F_INCORE);
	err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
	if (err) {
		fprintf(stderr, "Unable to setup memory (%d)\n", err);
		exit(1);
	}

	error = init_msr();
	if (error) {
		fprintf(stderr, "init_msr error %d", error);
		exit(1);
	}

	init_mem();
	init_inout();
	pci_irq_init(ctx);
	ioapic_init(ctx);

	rtc_init(ctx, rtc_localtime);
	sci_init(ctx);

	/*
	 * Exit if a device emulation finds an error in it's initilization
	 */
	if (init_pci(ctx) != 0)
		exit(1);

	if (gdb_port != 0)
		init_dbgport(gdb_port);

	if (bvmcons)
		init_bvmcons();

	error = vm_get_register(ctx, BSP, VM_REG_GUEST_RIP, &rip);
	assert(error == 0);

	/*
	 * build the guest tables, MP etc.
	 */
	if (mptgen) {
		error = mptable_build(ctx, guest_ncpus);
		if (error)
			exit(1);
	}

	error = smbios_build(ctx);
	assert(error == 0);

	if (acpi) {
		error = acpi_build(ctx, guest_ncpus);
		assert(error == 0);
	}

	/*
	 * Change the proc title to include the VM name.
	 */
	setproctitle("%s", vmname); 
	
	/*
	 * Add CPU 0
	 */
	fbsdrun_addcpu(ctx, BSP, BSP, rip);

	/*
	 * Head off to the main event dispatch loop
	 */
	mevent_dispatch();

	exit(1);
}
Esempio n. 16
0
File: sd.c Progetto: histat/dc-nx
static
void power_on (void)
{
        sci_init();
		wait_ms(20);
}
Esempio n. 17
0
static int
vm_init_vdevs(struct vmctx *ctx)
{
	int ret;

	init_mem();
	init_inout();
	pci_irq_init(ctx);
	atkbdc_init(ctx);
	ioapic_init(ctx);

	/*
	 * We don't care ioc_init return value so far.
	 * Will add return value check once ioc is full function.
	 */
	ret = ioc_init(ctx);

	ret = vrtc_init(ctx);
	if (ret < 0)
		goto vrtc_fail;

	ret = vpit_init(ctx);
	if (ret < 0)
		goto vpit_fail;

	ret = vhpet_init(ctx);
	if (ret < 0)
		goto vhpet_fail;

	sci_init(ctx);

	if (debugexit_enabled)
		init_debugexit();

	ret = monitor_init(ctx);
	if (ret < 0)
		goto monitor_fail;

	ret = init_pci(ctx);
	if (ret < 0)
		goto pci_fail;

	init_vtpm2(ctx);

	return 0;

pci_fail:
	monitor_close();
monitor_fail:
	if (debugexit_enabled)
		deinit_debugexit();

	vhpet_deinit(ctx);
vhpet_fail:
	vpit_deinit(ctx);
vpit_fail:
	vrtc_deinit(ctx);
vrtc_fail:
	ioc_deinit(ctx);
	atkbdc_deinit(ctx);
	pci_irq_deinit(ctx);
	ioapic_deinit();
	return -1;
}