示例#1
0
static int init_bus(struct bus *bus)
{
    int ret;
    unsigned int i;

    // Init current bus
    if (bus->driver->init && (ret = bus->driver->init(bus)) != 0) {
        log_error("init bus %d (%d)",  bus->id, ret);
        return ret;
    }
    // Init current bus devices
    for (i = 0; i < bus->dev_count; i++) {
        bus->c_dev[i].parent = bus;
        if ((ret = init_device(&bus->c_dev[i])) != 0) {
            return ret;
        }
        if (bus->driver->init_dev && (ret = bus->driver->init_dev(bus, &bus->c_dev[i])) != 0) {
            log_error("init bus dev %d (%d)",  bus->id, ret);
            return ret;
        }
    }
    // Init current bus buses
    for (i = 0; i < bus->bus_count; i++) {
        bus->c_bus[i].parent = bus;
        if ((ret = init_bus(&bus->c_bus[i])) != 0) {
            return ret;
        }
    }
    return 0;
}
示例#2
0
int init_platform_devices(struct device *devices, unsigned int dev_count, struct bus *buses, unsigned int bus_count)
{
    // Init root device tree
    root_device.c_dev = devices;
    root_device.dev_count = dev_count;
    root_device.c_bus = buses;
    root_device.bus_count = bus_count;

    return init_bus(&root_device);
}
示例#3
0
void init_flashmodule(struct flashmodule *p_fm)
{
	int i;

	init_memory_alloc(&nand_mem_pointer);

	p_fm->power_fail_flag = 0;
	p_fm->buses = nand_mem_pointer.bus;

	for (i = 0; i < NUM_OF_BUS; i++)
	{
		init_bus(&p_fm->buses[i]);
	}
}
示例#4
0
void lcd_init (lcd_t *lcd)
{
	init_bus ();
	lcd_command (LCD_CMD_FUNCTION_SET | LCD_PARAM_LINES(2) | LCD_PARAM_8BIT);
	lcd_command (LCD_CMD_CLEAR_DISPLAY);
	lcd_command (LCD_CMD_DDRAM_ADDR | 0x00);
	lcd_command (LCD_CMD_ENTRY_MODE | LCD_PARAM_INC);
	lcd_command (LCD_CMD_DISPLAY_CONTROL | LCD_PARAM_DISPLAY_ON /*| LCD_PARAM_CURSOR_ON*/);

	lcd->interface = &lcd_interface;
	
	lcd->esc_mode = 0;
	lcd->unicode_char = 0;
	lcd->col = 0;
	lcd->line = 0;
}
示例#5
0
int do_set_ddr_clock (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
	DECLARE_GLOBAL_DATA_PTR;
	unsigned char a;

	init_bus ();
	set_status_signal ();
	printf ("\t reboot system\n");
 /* pll_reset(); */
	{
		int temp;
		temp = get_status_signal ();
		printf ("temp = %d\n", temp);
	}

	return 1;

}
示例#6
0
int main()
{
  SDL_Surface* background, *background2, *background3, *background4;
  SDL_Rect src, dest;
  int frames;  
  Uint32 colorkey;


  SDL_AudioSpec desired, obtained;
  sound_t bus_sound;

  /*initialize video and sound subsystem*/
  if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0){
    printf("Unable to initialize video: %s\n.", SDL_GetError());
    return 1;
  }

  /*ensure all subsystems exit safely*/
  atexit(SDL_Quit);
  atexit(SDL_CloseAudio);

  /*set video mode*/
  screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF | SDL_HWSURFACE);
  if (screen == NULL) {
    printf("Unable to set video mode: %s\n", SDL_GetError());
    return 1;
  }

  /*load background images*/
  background = SDL_LoadBMP("img/src.bmp");
  if (background == NULL) {
    printf("Unable to load image.");
    return 1;
  }

  background2 = SDL_LoadBMP("img/background2.bmp");
  if (background2 == NULL) {
    printf("Unable to load background2.");
    return 1;
  }

  background3 = SDL_LoadBMP("img/background3.bmp");
  if (background3 == NULL) {
    printf("Unable to load background3.");
    return 1;
  }

  background4 = SDL_LoadBMP("img/background4.bmp");
  if (background4 == NULL) {
    printf("Unable to load background4.");
    return 1;
  }

  /*load bus*/
  bus = SDL_LoadBMP("img/bus.bmp");
  if (bus == NULL) {
    printf("Unable to load image.");
    return 1;
  }
  colorkey = SDL_MapRGB(bus->format, 255, 255, 255);

  /*set color key*/
  SDL_SetColorKey(bus,
		  SDL_SRCCOLORKEY,
		  colorkey);
  
  /*load man*/
  man = SDL_LoadBMP("img/man.bmp");
  if (man == NULL) {
    printf("Unable to load image");
    return 1;
  }

  colorkey = SDL_MapRGB(man->format, 255, 255, 255);

  /*set color key*/
  SDL_SetColorKey(man,
		  SDL_SRCCOLORKEY,
		  colorkey);

  man2 = SDL_LoadBMP("img/man2.bmp");
  if (man2 == NULL) {
    printf("Unable to load image");
    return 1;
  }

  colorkey = SDL_MapRGB(man2->format, 255, 255, 255);

  /*set color key*/
  SDL_SetColorKey(man2,
		  SDL_SRCCOLORKEY,
		  colorkey);

  car1 = SDL_LoadBMP("img/car1.bmp");
  if (car1 == NULL) {
    printf("Unable to load image");
    return 1;
  }

  colorkey = SDL_MapRGB(car1->format, 255, 255, 255);

  /*set color key*/
  SDL_SetColorKey(car1,
		  SDL_SRCCOLORKEY,
		  colorkey);


  car2 = SDL_LoadBMP("img/car2.bmp");
  if (car2 == NULL) {
    printf("Unable to load image");
    return 1;
  }

  colorkey = SDL_MapRGB(car2->format, 255, 255, 255);

  /*set color key*/
  SDL_SetColorKey(car2,
		  SDL_SRCCOLORKEY,
		  colorkey);

  
  //open audio device
  desired.freq = 44100;
  desired.format = AUDIO_S16;
  desired.samples = 4096;
  desired.channels = 2;
  desired.callback = AudioCallback;
  desired.userdata = NULL;

  if (SDL_OpenAudio(&desired, &obtained) < 0) {
    printf("Unable to open audio device: %s\n", SDL_GetError());
    return 1;
  }

  //load sound files and convert them to sound card's format
  if (LoadAndConvertSound("audio/bus-pass.wav", &obtained, &bus_sound) != 0) {
    printf("Unable to load sound.\n");
    return 1;
  }

  ClearPlayingSounds();
  SDL_PauseAudio(0);

  init_bus();
  init_man();
  
  int passenger_in = 0;

  PlaySound(&bus_sound);
  while (psv.x > 0) {
    src.x = 0;
    src.y = 0;
    src.w = background->w;
    src.h = background->h; 
    dest = src;
    SDL_BlitSurface(background, &src, screen, &dest);

    draw_obj(&psv, bus);
    
    if (psv.x < screen->w/2 && !passenger_in) { /*pause bus for passenger to enter*/
      SDL_PauseAudio(1);
      if (passenger.x > psv.x + 40){  /*check if passenger has got in*/
	passenger_in = 1; SDL_PauseAudio(0);
      }

      draw_man();
      SDL_Flip(screen);
      move_obj(&passenger);
    } else {
      SDL_Flip(screen);
      move_obj(&psv);
    }
  }

  psv.x = 639;  psv.y = 320;
  init_cars();
  PlaySound(&bus_sound);
  while (psv.x + bus->w/2 > 0) {
    SDL_BlitSurface(background2, &src, screen, &dest);
    draw_obj(&priv1, car1); draw_obj(&priv2, car2);
    draw_obj(&psv, bus);
    SDL_Flip(screen);
    move_obj(&psv);
    move_obj(&priv1); move_obj(&priv2);
  }

  psv.x = 639; psv.y = 350;
  PlaySound(&bus_sound);
  while (psv.x + bus->w/2 > 0) {
    SDL_BlitSurface(background3, &src, screen, &dest);
    draw_obj(&psv, bus);
    SDL_Flip(screen);
    move_obj(&psv);
  }

  psv.x = 639; psv.y = 267; passenger.y = 270;
  passenger_in = 1;
  int has_paused = 0;
  PlaySound(&bus_sound);
  while (psv.x + bus->w/2 > 0) {
    SDL_BlitSurface(background4, &src, screen, &dest);
    if (screen->w/2 > psv.x && passenger_in == 1) {
      SDL_PauseAudio(1);
      if (has_paused == 0) { SDL_Delay(1000); has_paused = 1;}
      if (passenger.x > 639) {passenger_in = 0; SDL_PauseAudio(0);}
      draw_obj(&psv, bus);
      draw_man();
      SDL_Flip(screen);
      move_obj(&passenger);
    } else {
      draw_obj(&psv, bus);
      SDL_Flip(screen);
      move_obj(&psv);
    }
  }

  //pause and lock sound system
  SDL_PauseAudio(1);
  SDL_LockAudio();

  free(bus_sound.samples);

  SDL_UnlockAudio();


  SDL_FreeSurface(background4);
  SDL_FreeSurface(background3);
  SDL_FreeSurface(background2);
  SDL_FreeSurface(background);
  SDL_FreeSurface(man);
  SDL_FreeSurface(bus);
  return 0;
}
示例#7
0
void SIM_init(){
	sky_pref_t* pref;
	char* welcome_str = get_front_message();
	/* 
	 * get the corrent_config_file and do some initialization 
	 */
	skyeye_config_t* config = get_current_config();
	skyeye_option_init(config);
	/*
	 * initialization of callback data structure, it needs to 
	 * be initialized at very beginning.
	 */
	init_callback();

	/*
	 * initilize the data structure for command
	 * register some default built-in command
	 */
	init_command_list();

	init_stepi();

	/*
	 * initialization of module manangement 
	 */
	init_module_list();

	
	/*
	 * initialization of architecture and cores
	 */
	init_arch();
	
	/*
	 * initialization of bus and memory module
	 */
	init_bus();


	/*
	 * initialization of machine module
	 */
	init_mach();

	
	/*
	 * initialization of breakpoint, that depends on callback module.
	 */
	init_bp();

	/* 
	 * get the current preference for simulator 
	 */
	pref = get_skyeye_pref();

	/* 
	 * loading all the modules in search directory 
	 */
	if(!pref->module_search_dir)
		pref->module_search_dir = skyeye_strdup(default_lib_dir);
	SKY_load_all_modules(pref->module_search_dir, NULL);
	//skyeye_config_t *config;
	//config = malloc(sizeof(skyeye_config_t));
	/*	
	if(pref->autoboot == True){
		SIM_start();
		SIM_run();
	}
	*/
	/*
	 * if we run simulator in GUI or external IDE, we do not need to
	 * launch our CLI.
	 */
	if(pref->interactive_mode == True){
		SIM_cli();		
	}
	else{
		SIM_start();
		SIM_run();
	}
}