Esempio n. 1
0
int main(void)
{
	printf("hello git! \n");
	printf("test cup is big endian ro little endian. \n");
	printf("the result is %d \n", check_cpu());
	return 0;
}
Esempio n. 2
0
int validate_cpu(void)
{
	u32 *err_flags;
	int cpu_level, req_level;
	const unsigned char *msg_strs;

	check_cpu(&cpu_level, &req_level, &err_flags);

	if (cpu_level < req_level) {
		printf("This kernel requires an %s CPU, ",
		       cpu_name(req_level));
		printf("but only detected an %s CPU.\n",
		       cpu_name(cpu_level));
		return -1;
	}

	if (err_flags) {
		int i, j;
		puts("This kernel requires the following features "
		     "not present on the CPU:\n");

		msg_strs = (const unsigned char *)x86_cap_strs;

		for (i = 0; i < NCAPINTS; i++) {
			u32 e = err_flags[i];

			for (j = 0; j < 32; j++) {
				if (msg_strs[0] < i ||
				    (msg_strs[0] == i && msg_strs[1] < j)) {
					/* Skip to the next string */
					msg_strs += 2;
					while (*msg_strs++)
						;
				}
				if (e & 1) {
					if (msg_strs[0] == i &&
					    msg_strs[1] == j &&
					    msg_strs[2])
						printf("%s ", msg_strs+2);
					else
						printf("%d:%d ", i, j);
				}
				e >>= 1;
			}
		}
		putchar('\n');
		return -1;
	} else {
		return 0;
Esempio n. 3
0
int uip_init(t_uipinfo * uipinfo)
{
  uip_uipinfo = uipinfo;
  check_cpu();
  printf("Initialising %s - %s (%d:%d:%d:%d:%d)\n", allegro_id, cpu_vendor,
         cpu_family, cpu_model, cpu_fpu ? 1 : 0, cpu_mmx ? 1 : 0,
         cpu_3dnow ? 1 : 0);
  printf("\nNote: Allegro can take at least 5 seconds to quit!\n");
  sleep(2);
  if (allegro_init()) {
    LOG_CRITICAL(("Failed to initialise allegro"));
    return 1;
  }
  LOCK_VARIABLE(ui_info);
  LOCK_VARIABLE(vdp_overseas);
  LOCK_VARIABLE(ui_vdpsimple);
  LOCK_VARIABLE(ui_vsync);
  LOCK_VARIABLE(ui_clearnext);
  LOCK_VARIABLE(ui_fullscreen);
  LOCK_VARIABLE(ui_fkeys);
  LOCK_FUNCTION(uip_keyboardhandler);
  return 0;
}
Esempio n. 4
0
plc_tag ab_tag_create(attr attribs)
{
    ab_tag_p tag = AB_TAG_NULL;
    const char *path;
	int rc;
	int debug = attr_get_int(attribs,"debug",0);

    pdebug(debug,"Starting.");


    /*
     * allocate memory for the new tag.  Do this first so that
     * we have a vehicle for returning status.
     */

    tag = (ab_tag_p)mem_alloc(sizeof(struct ab_tag_t));

    if(!tag) {
    	pdebug(debug,"Unable to allocate memory for AB EIP tag!");
    	return PLC_TAG_NULL;
    }

    /* store the debug status */
    tag->debug = debug;

    /*
     * check the CPU type.
     *
     * This determines the protocol type.
     */
    if(check_cpu(tag, attribs) != PLCTAG_STATUS_OK) {
        tag->status = PLCTAG_ERR_BAD_DEVICE;
        return (plc_tag)tag;
    }

    /* AB PLCs are little endian. */
    tag->endian = PLCTAG_DATA_LITTLE_ENDIAN;

    /* allocate memory for the data */
    tag->elem_count = attr_get_int(attribs,"elem_count",1);
    tag->elem_size = attr_get_int(attribs,"elem_size",0);
    tag->size = (tag->elem_count) * (tag->elem_size);

    if(tag->size == 0) {
    	/* failure! Need data_size! */
    	tag->status = PLCTAG_ERR_BAD_PARAM;
    	return (plc_tag)tag;
    }

    tag->data = (uint8_t*)mem_alloc(tag->size);

    if(tag->data == NULL) {
    	tag->status = PLCTAG_ERR_NO_MEM;
    	return (plc_tag)tag;
    }

    /* get the connection path, punt if there is not one and we have a Logix-class PLC. */
    path = attr_get_str(attribs,"path",NULL);

    if(path == NULL && tag->protocol_type == AB_PROTOCOL_LGX) {
    	tag->status = PLCTAG_ERR_BAD_PARAM;
    	return (plc_tag)tag;
    }

    /* make sure the global mutex is set up */
    rc = check_mutex(tag->debug);
    if(rc != PLCTAG_STATUS_OK) {
    	tag->status = rc;
    	return (plc_tag)tag;
    }

    tag->first_read = 1;

	/*
	 * now we start the part that might conflict with other threads.
	 *
	 * The rest of this is inside a locked block.
	 */
	pdebug(debug,"Locking mutex");
	critical_block(io_thread_mutex) {
		/*
		 * set up tag vtable.  This is protocol specific
		 */
		tag->vtable = set_tag_vtable(tag);

		if(!tag->vtable) {
			pdebug(debug,"Unable to set tag vtable!");
			tag->status = PLCTAG_ERR_BAD_PARAM;
			break;
		}

		/*
		 * Check the request IO handler thread.
		 */
		if(!io_handler_thread) {
			rc = thread_create((thread_p*)&io_handler_thread,request_handler_func, 32*1024, NULL);
			if(rc != PLCTAG_STATUS_OK) {
				pdebug(debug,"Unable to create request handler thread!");
				tag->status = rc;
				break;
			}
		}

		/*
		 * Find or create a session.
		 */
		if(find_or_create_session(tag, attribs) != PLCTAG_STATUS_OK) {
			pdebug(debug,"Unable to create session!");
			tag->status = PLCTAG_ERR_BAD_GATEWAY;
			break;
		}

		/*
		 * parse the link path into the tag.  Note that it must
		 * pad the byte string to a multiple of 16-bit words. The function
		 * also adds the protocol/PLC specific routing information to the
		 * links specified.  This fills in fields in the connection about
		 * any DH+ special data.
		 * 
		 * Skip this if we don't have a path.
		 */
		if(path && cip_encode_path(tag,path) != PLCTAG_STATUS_OK) {
			pdebug(debug,"Unable to convert links strings to binary path!");
			tag->status = PLCTAG_ERR_BAD_PARAM;
			break;
		}


		/*
		 * check the tag name, this is protocol specific.
		 */

		if(check_tag_name(tag, attr_get_str(attribs,"name","NONE")) != PLCTAG_STATUS_OK) {
			pdebug(debug,"Bad tag name!");
			tag->status = PLCTAG_ERR_BAD_PARAM;
			break;
		}

		/*
		 * add the tag to the session's list.
		 */
		if(session_add_tag_unsafe(tag, tag->session) != PLCTAG_STATUS_OK) {
			pdebug(debug,"unable to add new tag to connection!");

			tag->status = PLCTAG_ERR_CREATE;
			break;
		}
    }

    pdebug(debug,"Done.");

    return (plc_tag)tag;
}
Esempio n. 5
0
static void
check_gpu(int fd, uint32_t handle, uint32_t val)
{
	gem_read(fd, handle, 0, linear, sizeof(linear));
	check_cpu(linear, val);
}
Esempio n. 6
0
int main(int argc, char * const argv[]){

	/* Parse the command line arguments */
	MFC.fork = TRUE;
	parse_options(argc, argv);

	signal(SIGHUP,Signal_Handler);		/* hangup signal */
	signal(SIGTERM,Signal_Handler);		/* software termination signal from kill */

	struct timespec timx,tim1;

	openlog("mfc-daemon", LOG_PID, LOG_DAEMON);
	MFC.syslog = TRUE;


	/* check machine and pidfile*/
	MFC.total_cpus = check_cpu();
	MFC.total_fans = check_fan();
	check_pidfile();
	write_pidfile();
	MFC.pidfile = TRUE;

	if (MFC.fork) {
		start_daemon();
	}

	int fan;
	for (fan = 1; fan <= MFC.total_fans; ++fan) {
		write_fan_manual(fan, 1);
	}

	tim1.tv_sec = TV_SEC;
	tim1.tv_nsec = TV_NSEC;

	//init
	int wr_manual=0;
	int change_number=0;
	int old_fan_speed=-1;

	INFO("Start");

	int temp = get_cpu_temperature();
	int old_temp_change = 0;
	int fan_speed=GET_FAN_SPEED(temp);

	fan_speed=set_min_max_fan_speed(fan_speed);

	for (fan = 1; fan <= MFC.total_fans; ++fan) {
		write_fan_speed(fan, fan_speed);
	}

	while (1){

		wr_manual++;
		if (wr_manual==9){
			for (fan = 1; fan <= MFC.total_fans; ++fan) {
				write_fan_manual(fan, 1);
			}
			wr_manual=0;
		}

		temp = get_cpu_temperature();

                int diff = abs(temp - old_temp_change);

		if (diff >= 2){
			//	temp = average of both cpu's
			fan_speed=GET_FAN_SPEED(temp);
			fan_speed=set_min_max_fan_speed(fan_speed);

			if (fan_speed!=old_fan_speed){
				for (fan = 1; fan <= MFC.total_fans; ++fan) {
					write_fan_speed(fan, fan_speed);
				}
				change_number=log_fan_speed(fan_speed,change_number,temp);
				old_fan_speed=fan_speed;
			}
			old_temp_change = temp;
		}

		if (nanosleep(&tim1,&timx) == -1){
			QUIT_DAEMON("Error nanosleep");
		}
	}
}
Esempio n. 7
0
/* _install_allegro:
 *  Initialises the Allegro library, activating the system driver.
 */
static int _install_allegro(int system_id, int *errno_ptr, int (*atexit_ptr)(void (*func)(void)))
{
   RGB black_rgb = {0, 0, 0, 0};
   char tmp1[64], tmp2[64];
   int i;

   #ifndef ALLEGRO_USE_CONSTRUCTOR
      /* call constructor functions manually */
      extern void _initialize_datafile_types();
      extern void _midi_constructor();
      extern void _mouse_constructor();

      _initialize_datafile_types();
      _midi_constructor();
      _mouse_constructor();
      _register_bitmap_file_type_init();
      _register_sample_file_type_init();
      _register_font_file_type_init();
   #endif

   if (errno_ptr)
      allegro_errno = errno_ptr;
   else
      allegro_errno = &errno;

   /* set up default palette structures */
   for (i=0; i<256; i++)
      black_palette[i] = black_rgb;

   for (i=16; i<256; i++)
      desktop_palette[i] = desktop_palette[i & 15];

   /* lock some important variables */
   LOCK_VARIABLE(screen);
   LOCK_VARIABLE(gfx_driver);
   LOCK_VARIABLE(gfx_capabilities);
   LOCK_VARIABLE(_last_bank_1);
   LOCK_VARIABLE(_last_bank_2);
   LOCK_VARIABLE(_gfx_bank);
   LOCK_VARIABLE(_drawing_mode);
   LOCK_VARIABLE(_drawing_pattern);
   LOCK_VARIABLE(_drawing_x_anchor);
   LOCK_VARIABLE(_drawing_y_anchor);
   LOCK_VARIABLE(_drawing_x_mask);
   LOCK_VARIABLE(_drawing_y_mask);
   LOCK_VARIABLE(_current_palette);
   LOCK_VARIABLE(os_type);

   /* nasty stuff to set up the config system before the system driver */
   system_driver = _system_driver_list[0].driver;

   /* needed in case set_config_file was called before allegro_init */
   _reload_config();

   reload_config_texts(NULL);

   if (system_id == SYSTEM_AUTODETECT)
      system_id = get_config_id(uconvert_ascii("system", tmp1), uconvert_ascii("system", tmp2), SYSTEM_AUTODETECT);

   system_driver = NULL;

   /* initialise the system driver */
   usetc(allegro_error, 0);

   for (i=0; _system_driver_list[i].driver; i++) {
      if ((_system_driver_list[i].id == system_id) ||
	  ((_system_driver_list[i].autodetect) && (system_id == SYSTEM_AUTODETECT))) {
	 system_driver = _system_driver_list[i].driver;
	 system_driver->name = system_driver->desc = get_config_text(system_driver->ascii_name);
	 if (system_driver->init() != 0) {
	    system_driver = NULL;
	    if (system_id != SYSTEM_AUTODETECT)
	       break;
	 }
	 else
	    break;
      }
   }

   if (!system_driver)
      return -1;

   /* disable close button */
   set_close_button_callback(NULL);

   /* detect CPU type */
   check_cpu();

#if defined(ALLEGRO_UNIX) || defined(ALLEGRO_WINDOWS)
   /* detect filename encoding used by libc */
   /* XXX This should be done for all platforms but I'm not set up to check
    * that all platforms have been covered before making the 4.2.3 release.
    * --pw
    */
   _al_detect_filename_encoding();
#endif

   /* set up screensaver policy */
   _screensaver_policy = get_config_int(uconvert_ascii("system", tmp1),
                                        uconvert_ascii("disable_screensaver", tmp2),
                                        FULLSCREEN_DISABLED);

   /* install shutdown handler */
   if (_allegro_count == 0) {
      if (atexit_ptr)
	 atexit_ptr(allegro_exit_stub);
   }

   _allegro_count++;

   TRACE(PREFIX_I "Allegro initialised (instance %d)\n", _allegro_count);
   return 0;
}