예제 #1
0
파일: at91sam9_wdt.c 프로젝트: avagin/linux
static int of_at91wdt_init(struct device_node *np, struct at91wdt *wdt)
{
	u32 min = 0;
	u32 max = WDT_COUNTER_MAX_SECS;
	const char *tmp;

	/* Get the interrupts property */
	wdt->irq = irq_of_parse_and_map(np, 0);
	if (!wdt->irq)
		dev_warn(wdt->wdd.parent, "failed to get IRQ from DT\n");

	if (!of_property_read_u32_index(np, "atmel,max-heartbeat-sec", 0,
					&max)) {
		if (!max || max > WDT_COUNTER_MAX_SECS)
			max = WDT_COUNTER_MAX_SECS;

		if (!of_property_read_u32_index(np, "atmel,min-heartbeat-sec",
						0, &min)) {
			if (min >= max)
				min = max - 1;
		}
	}

	min = secs_to_ticks(min);
	max = secs_to_ticks(max);

	wdt->mr_mask = 0x3FFFFFFF;
	wdt->mr = 0;
	if (!of_property_read_string(np, "atmel,watchdog-type", &tmp) &&
	    !strcmp(tmp, "software")) {
		wdt->mr |= AT91_WDT_WDFIEN;
		wdt->mr_mask &= ~AT91_WDT_WDRPROC;
	} else {
		wdt->mr |= AT91_WDT_WDRSTEN;
	}

	if (!of_property_read_string(np, "atmel,reset-type", &tmp) &&
	    !strcmp(tmp, "proc"))
		wdt->mr |= AT91_WDT_WDRPROC;

	if (of_property_read_bool(np, "atmel,disable")) {
		wdt->mr |= AT91_WDT_WDDIS;
		wdt->mr_mask &= AT91_WDT_WDDIS;
	}

	if (of_property_read_bool(np, "atmel,idle-halt"))
		wdt->mr |= AT91_WDT_WDIDLEHLT;

	if (of_property_read_bool(np, "atmel,dbg-halt"))
		wdt->mr |= AT91_WDT_WDDBGHLT;

	wdt->mr |= max | ((max - min) << 16);

	return 0;
}
예제 #2
0
파일: slice.hpp 프로젝트: isidorn/test2
 explicit btree_stats_t(perfmon_collection_t *parent, const std::string &identifier)
     : btree_collection(),
       btree_collection_membership(parent, &btree_collection, "btree-" + identifier),
       pm_keys_read(secs_to_ticks(1)),
       pm_keys_set(secs_to_ticks(1)),
       pm_keys_expired(secs_to_ticks(1)),
       pm_keys_membership(&btree_collection,
           &pm_keys_read, "keys_read",
           &pm_keys_set, "keys_set",
           &pm_keys_expired, "keys_expired",
           NULLPTR)
 { }
예제 #3
0
파일: disc.c 프로젝트: smurk-too/wodebrew
void __Disc_SetTime(void) {
    /* Extern */
    extern void settime(u64);

    /* Set proper time */
    settime(secs_to_ticks(time(NULL) - 946684800));
}
void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode,
                            int aspectRatio, u32 returnTo, u8 BootType, bool use_led)
{
    normalCFG.vidMode = vidMode;
    normalCFG.vipatch = vipatch;
    normalCFG.countryString = countryString;
    normalCFG.patchVidMode = patchVidMode;
    normalCFG.aspectRatio = aspectRatio;
    normalCFG.returnTo = returnTo;
    normalCFG.configbytes[0] = configbytes[0];
    normalCFG.configbytes[1] = configbytes[1];
    normalCFG.IOS = CurrentIOS;
    normalCFG.codelist = codelist;
    normalCFG.codelistend = codelistend;
    normalCFG.cheats = code_buf;
    normalCFG.cheatSize = code_size;
    normalCFG.hooktype = hooktype;
    normalCFG.debugger = debuggerselect;
    normalCFG.gameconf = gameconf;
    normalCFG.gameconfsize = gameconfsize;
    normalCFG.BootType = BootType;
    normalCFG.use_led = use_led;
    normalCFG.wip_list = get_wip_list();
    normalCFG.wip_count = get_wip_count();
    /* Copy CFG Into lower MEM1 so it doesnt get destroyed */
    DCFlushRange(&normalCFG, sizeof(the_CFG));
    the_CFG *lowCFG = (the_CFG*)MEM1_lo_alloc(sizeof(the_CFG));
    memcpy(lowCFG, &normalCFG, sizeof(the_CFG));
    DCFlushRange(&lowCFG, sizeof(the_CFG));
    *EXT_ADDR_CFG = ((u32)lowCFG);
    /* Unmount devices etc */
    ShutdownBeforeExit();
    /* Wii Games will need it */
    net_wc24cleanup();
    /* Set proper time */
    settime(secs_to_ticks(time(NULL) - 946684800));
    /* Copy in booter */
    memcpy(EXT_ADDR, booter_ptr, booter_size);
    DCFlushRange(EXT_ADDR, booter_size);
    /* Loader just for the booter */
    memcpy(LDR_ADDR, extldr_ptr, extldr_size);
    DCFlushRange(LDR_ADDR, extldr_size);
    /* Boot it */
    JumpToEntry(LDR_ENTRY);
}
예제 #5
0
파일: pertest.c 프로젝트: Amon-X/yabause
u64 GetTickFreq() 
{
	u64 tickfreq;
#ifdef WIN32
	QueryPerformanceFrequency((LARGE_INTEGER *)&tickfreq);
#elif defined(_arch_dreamcast)
	tickfreq = 1000;
#elif defined(GEKKO)
	tickfreq = secs_to_ticks(1);
#elif defined(PSP)
	tickfreq = 1000000;
#elif defined(HAVE_GETTIMEOFDAY)
	tickfreq = 1000000;
#elif defined(HAVE_LIBSDL)
	tickfreq = 1000;
#endif
	return tickfreq;
}
예제 #6
0
static bool __usbstorage_IsInserted(void)
{
	usb_device_entry *buffer;
	u8 device_count;
	u8 i, j;
	u16 vid, pid;
	s32 maxLun;
	s32 retval;
	u32 sectorsize, numSectors;

	if(__mounted)
	{
		// device is not a USB DVD drive - always return true
		if (__usbfd.sector_size[__lun] != 2048)
			return true;

		// check if DVD is inserted
		if (USBStorageOGC_ReadCapacity(&__usbfd, __lun, &sectorsize, &numSectors) < 0)
			return false;
		else
			return true;
	}

	if(!__inited)
		return false;

	buffer = (usb_device_entry*)__lwp_heap_allocate(&__heap, DEVLIST_MAXSIZE * sizeof(usb_device_entry));
	if (!buffer)
		return false;

	memset(buffer, 0, DEVLIST_MAXSIZE * sizeof(usb_device_entry));

	if (USB_OGC_GetDeviceList(buffer, DEVLIST_MAXSIZE, USB_CLASS_MASS_STORAGE, &device_count) < 0)
	{
		if (__vid != 0 || __pid != 0)
			USBStorageOGC_Close(&__usbfd);

		__lwp_heap_free(&__heap, buffer);
		return false;
	}

	usleep(100);

	if (__vid != 0 || __pid != 0) {
		for(i = 0; i < device_count; i++) {
			vid = buffer[i].vid;
			pid = buffer[i].pid;
			if(vid != 0 || pid != 0) {
				if((vid == __vid) && (pid == __pid)) {
					__mounted = true;
					__lwp_heap_free(&__heap,buffer);
					usleep(50); // I don't know why I have to wait but it's needed
					return true;
				}
			}
		}
		USBStorageOGC_Close(&__usbfd); // device changed or unplugged, return false the first time to notify to the client that he must unmount devices
		__lwp_heap_free(&__heap,buffer);
		return false;
	}
	for (i = 0; i < device_count; i++) {
		vid = buffer[i].vid;
		pid = buffer[i].pid;
		if (vid == 0 || pid == 0)
			continue;
			
		if (vid == 0x0b95 && pid == 0x7720) // USB LAN
			continue;

		if (USBStorageOGC_Open(&__usbfd, buffer[i].device_id, vid, pid) < 0)
			continue;

		maxLun = USBStorageOGC_GetMaxLUN(&__usbfd);
		for (j = 0; j < maxLun; j++) {
			retval = USBStorageOGC_MountLUN(&__usbfd, j);

			if (retval == INVALID_LUN)
				continue;

			if (retval < 0)
			{
				__usbstorage_reset(&__usbfd);
				continue;
			}

			__mounted = true;
			__lun = j;
			__vid = vid;
			__pid = pid;
			usb_last_used = gettime()-secs_to_ticks(100);
			usleep(10000);
			break;
		}

		if (__mounted)
			break;

		USBStorageOGC_Close(&__usbfd);
	}
	__lwp_heap_free(&__heap, buffer);

	return __mounted;
}
예제 #7
0
void __Disc_SetTime(void)
{
	/* Set proper time */
	settime(secs_to_ticks(time(NULL) - 946684800));
}
예제 #8
0
 int estimate_qps() {
     ticks_t time_span = get_ticks() - time_of_last_qps_sample;
     return running_qps_estimate / 2 +
         requests_since_last_qps_sample * secs_to_ticks(1) / time_span;
 }
예제 #9
0
static bool __usbstorage_IsInserted(void)
{
	usb_device_entry *buffer;
	u8 device_count;
	u8 i, j;
	u16 vid, pid;
	s32 maxLun;
	s32 retval;

#ifdef DEBUG_USB		
	usb_log("__usbstorage_IsInserted\n");
	if(__mounted)
		usb_log("device previously mounted.\n");
#endif

	if(__mounted)
		return true;

	if(!__inited)
		return false;

	buffer = (usb_device_entry*)__lwp_heap_allocate(&__heap, DEVLIST_MAXSIZE * sizeof(usb_device_entry));
	if (!buffer)
		return false;

	memset(buffer, 0, DEVLIST_MAXSIZE * sizeof(usb_device_entry));

	if (USB_GetDeviceList(buffer, DEVLIST_MAXSIZE, USB_CLASS_MASS_STORAGE, &device_count) < 0)
	{
		if (__vid != 0 || __pid != 0)
			USBStorage_Close(&__usbfd);

		__lwp_heap_free(&__heap, buffer);
		usb_log("Error in USB_GetDeviceList\n");
		return false;
	}

	usleep(100);

	if (__vid != 0 || __pid != 0) {
		for(i = 0; i < device_count; i++) {
			vid = buffer[i].vid;
			pid = buffer[i].pid;
			if(vid != 0 || pid != 0) {
				if((vid == __vid) && (pid == __pid)) {
					__mounted = true;
					__lwp_heap_free(&__heap,buffer);
					usleep(50); // I don't know why I have to wait but it's needed
					return true;
				}
			}
		}
		USBStorage_Close(&__usbfd);  // device changed or unplugged, return false the first time to notify to the client that he must unmount devices
		__lwp_heap_free(&__heap,buffer);
		usb_log("USB_GetDeviceList. device_count: %i\n",device_count);
		return false;
	}
	usb_log("USB_GetDeviceList. device_count: %i\n",device_count);
	for (i = 0; i < device_count; i++) {
		vid = buffer[i].vid;
		pid = buffer[i].pid;
		if (vid == 0 || pid == 0)
			continue;

		if (USBStorage_Open(&__usbfd, buffer[i].device_id, vid, pid) < 0)
		{
			usb_log("Error USBStorage_Open (%i,%i)\n",vid, pid);
			continue;
		}

		maxLun = USBStorage_GetMaxLUN(&__usbfd);
		usb_log("GetMaxLUN: %i\n",maxLun);
		for (j = 0; j < maxLun; j++) {
			retval = USBStorage_MountLUN(&__usbfd, j);
			if(retval<0)
				usb_log("Error USBStorage_MountLUN(%i): %i\n",j,retval);
			else
				usb_log("USBStorage_MountLUN(%i) Ok\n",j);
			//if (retval == USBSTORAGE_ETIMEDOUT)
			//	break;

			if (retval < 0)
			{
				__usbstorage_reset(&__usbfd);
				continue;
			}

			__mounted = true;
			__lun = j;
			__vid = vid;
			__pid = pid;
			usb_last_used = gettime()-secs_to_ticks(100);
			usleep(100);
#ifdef DEBUG_USB
			{
				u8 bf[2048];
				if(USBStorage_Read(&__usbfd, __lun, 0, 1, bf)<0)
				{
					usb_log("Error reading sector 0\n");
					USBStorage_Close(&__usbfd);
					return false;
				}
				else
					usb_log("Read sector 0 ok\n");
			}
#endif
			break;
		}

		if (__mounted)
			break;

		USBStorage_Close(&__usbfd);
	}
	__lwp_heap_free(&__heap, buffer);
	return __mounted;
}
예제 #10
0
void Timer::SetTimerSeconds(u32 t) 
{ 
	SetTimerTicks( Util::timer_gettime() + secs_to_ticks(t) );
}