void runBlinkTexts(struct stBlinkTextsGroup *stBlinkTexts) { stBlinkTexts->intThreadId=LWP_THREAD_NULL; stBlinkTexts->mtxThread=LWP_MUTEX_NULL; if (!LWP_MutexInit(&stBlinkTexts->mtxThread,false)) { LWP_CreateThread(&stBlinkTexts->intThreadId,(void *(*)(void *)) updateBlinkTexts,(void *)stBlinkTexts,NULL,0,64); } }
int ntfsInitVolume (ntfs_vd *vd) { // Sanity check if (!vd) { errno = ENODEV; return -1; } #ifndef LIBXENON // Initialise the volume lock LWP_MutexInit(&vd->lock, false); #endif // Reset the volumes name cache vd->name[0] = '\0'; // Reset the volumes current directory vd->cwd_ni = NULL; // Reset open directory and file stats vd->openDirCount = 0; vd->openFileCount = 0; vd->firstOpenDir = NULL; vd->firstOpenFile = NULL; return 0; }
void USBGeckoOutput() { LWP_MutexInit(&gecko_mutex, false); gecko = usb_isgeckoalive(1); devoptab_list[STD_OUT] = &gecko_out; devoptab_list[STD_ERR] = &gecko_out; }
GuiElement::GuiElement() { xoffset = 0; yoffset = 0; zoffset = 0; xmin = 0; xmax = 0; ymin = 0; ymax = 0; width = 0; height = 0; alpha = 255; scale = 1; state = STATE_DEFAULT; stateChan = -1; trigger[0] = NULL; trigger[1] = NULL; trigger[2] = NULL; trigger[3] = NULL; trigger[4] = NULL; trigger[5] = NULL; parentElement = NULL; rumble = true; selectable = false; clickable = false; holdable = false; visible = true; updateCB = NULL; yoffsetDyn = 0; xoffsetDyn = 0; yoffsetDynFloat = 0; alphaDyn = -1; scaleDyn = 1; effects = 0; effectAmount = 0; effectTarget = 0; effectsOver = 0; effectAmountOver = 0; effectTargetOver = 0; frequency = 0.0f; changervar = 0; degree = -90.0f; circleamount = 360.0f; Radius = 150; angleDyn = 0.0f; anglespeed = 0.0f; // default alignment - align to top left alignmentVert = ALIGN_TOP; alignmentHor = ALIGN_LEFT; // if(mutex == LWP_MUTEX_NULL) LWP_MutexInit(&mutex, true); if (_lock_mutex == LWP_MUTEX_NULL) LWP_MutexInit(&_lock_mutex, true); _lock_thread = LWP_THREAD_NULL; _lock_count = 0; _lock_queue = LWP_TQUEUE_NULL; }
bool DIP::Initialize() { LWP_MutexInit(&Mutex, false); if (Device_Handle < 0) { Device_Handle = IOS_Open("/dev/di", 0); } return (Device_Handle >= 0) ? true : false; }
void CMEM2Alloc::init(unsigned int size) { m_baseAddress = (SBlock *) std::max(((u32)SYS_GetArena2Lo() + 31) & ~31, IOS_RELOAD_AREA); m_endAddress = (SBlock *) ((char *)m_baseAddress + std::min(size * 0x100000, SYS_GetArena2Size() & ~31)); if (m_endAddress > (SBlock *) 0x93300000) //rest is reserved for usb/usb2/network and other stuff... (0xE0000 bytes) m_endAddress = (SBlock *) 0x93300000; SYS_SetArena2Lo(m_endAddress); LWP_MutexInit(&m_mutex, 0); }
u32 GuiImageAsync::ThreadInit() { if (Thread == LWP_THREAD_NULL) { LWP_MutexInit(&ListLock, false); LWP_CreateThread(&Thread, GuiImageAsyncThread, NULL, NULL, 32768, 80); } return ++ThreadCount; }
/**************************************************************************** * AllocSaveBuffer () * Clear and allocate the savebuffer ***************************************************************************/ void AllocSaveBuffer () { if(bufferLock == LWP_MUTEX_NULL) LWP_MutexInit(&bufferLock, false); if(bufferLock != LWP_MUTEX_NULL) LWP_MutexLock(bufferLock); memset (savebuffer, 0, SAVEBUFFERSIZE); }
void Output::WiiSetConsole() { LWP_MutexInit(&usbgecko_mutex, false); usbgecko = usb_isgeckoalive(1); if (usbgecko) { devoptab_list[STD_OUT] = &dotab_geckoout; devoptab_list[STD_ERR] = &dotab_geckoout; } else { devoptab_list[STD_OUT] = &dotab_stdnull; devoptab_list[STD_ERR] = &dotab_stdnull; } }
int __libogc_lock_init(int *lock,int recursive) { s32 ret; mutex_t retlck = LWP_MUTEX_NULL; if(!lock) return -1; ret = LWP_MutexInit(&retlck,(recursive?TRUE:FALSE)); *lock = (int)retlck; return ret; }
OSystem::MutexRef OSystem_Wii::createMutex() { mutex_t *mutex = (mutex_t *) malloc(sizeof(mutex_t)); s32 res = LWP_MutexInit(mutex, true); if (res) { printf("ERROR creating mutex\n"); free(mutex); return NULL; } return (MutexRef) mutex; }
void log_console_init(GXRModeObj *vmode, u16 logsize) { u16 i; LWP_MutexInit(&console_mutex, false); #ifndef WIILIB CON_InitEx(vmode, 20, 30, vmode->fbWidth - 40, vmode->xfbHeight - 60); //CON_InitEx(vmode, 10, 10 , (vmode->fbWidth / 2)-80, vmode->xfbHeight - 40); #endif rcb = VIDEO_SetPostRetraceCallback(NULL); VIDEO_SetPostRetraceCallback(rcb); /* VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK); VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK); VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); */ gecko = usb_isgeckoalive(1); if (log_size && log) { for (i = 0; i < log_size; ++i) if (log[i]) free(log[i]); free(log); } log_size = logsize; log_next = 0; if (log_size) { log = (char **) malloc(log_size * sizeof(char *)); for (i = 0; i < log_size; ++i) log[i] = NULL; } log_active = log_size > 0; dot_video = devoptab_list[STD_OUT]; video_active = true; devoptab_list[STD_OUT] = &dot_out; devoptab_list[STD_ERR] = &dot_out; }
static void system_init(void) { #ifdef HW_RVL IOS_ReloadIOS(IOS_GetVersion()); L2Enhance(); #ifndef IS_SALAMANDER gx_init_mem2(); #endif #endif #ifndef DEBUG __exception_setreload(8); #endif fatInitDefault(); #ifdef HAVE_LOGGER inl_logger_init(); devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_net; #elif defined(HAVE_FILE_LOGGER) inl_logger_init(); #ifndef IS_SALAMANDER devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_file; #endif #endif #if defined(HW_RVL) && !defined(IS_SALAMANDER) lwp_t gx_device_thread; gx_devices[GX_DEVICE_SD].interface = &__io_wiisd; gx_devices[GX_DEVICE_SD].name = "sd"; gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface); gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage; gx_devices[GX_DEVICE_USB].name = "usb"; gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface); LWP_MutexInit(&gx_device_mutex, false); LWP_CreateThread(&gx_device_thread, gx_devthread, NULL, NULL, 0, 66); #endif }
mutex() noexcept { LWP_MutexInit(&mutex_, false); }
bor_mutex *mutex_create(void) { mutex_t *mutex = malloc(sizeof(mutex_t)); if (LWP_MutexInit(mutex, 0) != 0) return NULL; return mutex; }
void CMEM2Alloc::init(void *addr, void *end) { m_baseAddress = (SBlock *)(((u32)addr + 31) & ~31); m_endAddress = (SBlock *)((u32)end & ~31); LWP_MutexInit(&m_mutex, 0); }
DiHandler::DiHandler() { LWP_MutexInit( &mutex, false ); LWP_CreateThread( &thread, ThreadMain, NULL, NULL, 32768, 80); }
s32 WBFS_Init_Dev(u32 device) { s32 ret = -1; if (wbfs_disc_mutex == LWP_MUTEX_NULL) { LWP_MutexInit(&wbfs_disc_mutex, true); } /* Try to mount device */ switch (device) { case WBFS_DEVICE_USB: { long long t1 = TIME_D(usb_init); long long t2; get_time(&TIME.usb_retry1); /* Initialize USB storage */ ret = USBStorage_Init(); if (ret >= 0) { /* Setup callbacks */ readCallback = __WBFS_ReadUSB; writeCallback = __WBFS_WriteUSB; /* Device info */ nb_sectors = USBStorage_GetCapacity(&wbfs_dev_sector_size); get_time(&TIME.usb_retry2); t2 = TIME_D(usb_init); TIME.usb_retry2 -= (t2 - t1); goto out; } } break; case WBFS_DEVICE_SDHC: { /* Initialize SDHC */ ret = SDHC_Init(); // returns true=ok false=error if (!ret && !sdhc_mode_sd) { // try normal SD sdhc_mode_sd = 1; ret = SDHC_Init(); } if (ret) { /* Setup callbacks */ readCallback = __WBFS_ReadSDHC; writeCallback = __WBFS_WriteSDHC; /* Device info */ nb_sectors = 0; wbfs_dev_sector_size = SDHC_SECTOR_SIZE; goto out; } ret = -1; } break; default: return -1; } out: return ret; }
s32 USBStorageOGC_Open(usbstorage_handle *dev, s32 device_id, u16 vid, u16 pid) { s32 retval = -1; u8 conf = -1; u8 *max_lun; u32 iConf, iInterface, iEp; usb_devdesc udd; usb_configurationdesc *ucd; usb_interfacedesc *uid; usb_endpointdesc *ued; max_lun = __lwp_heap_allocate(&__heap, 1); if (!max_lun) return IPC_ENOMEM; memset(dev, 0, sizeof(*dev)); dev->usb_fd = -1; dev->tag = TAG_START; if (LWP_MutexInit(&dev->lock, false) < 0) goto free_and_return; if (SYS_CreateAlarm(&dev->alarm) < 0) goto free_and_return; retval = USB_OGC_OpenDevice(device_id, vid, pid, &dev->usb_fd); if (retval < 0) goto free_and_return; retval = USB_OGC_GetDescriptors(dev->usb_fd, &udd); if (retval < 0) goto free_and_return; for (iConf = 0; iConf < udd.bNumConfigurations; iConf++) { ucd = &udd.configurations[iConf]; for (iInterface = 0; iInterface < ucd->bNumInterfaces; iInterface++) { uid = &ucd->interfaces[iInterface]; if(uid->bInterfaceClass == USB_CLASS_MASS_STORAGE && /* (uid->bInterfaceSubClass == MASS_STORAGE_SCSI_COMMANDS || uid->bInterfaceSubClass == MASS_STORAGE_RBC_COMMANDS || uid->bInterfaceSubClass == MASS_STORAGE_ATA_COMMANDS || uid->bInterfaceSubClass == MASS_STORAGE_QIC_COMMANDS || uid->bInterfaceSubClass == MASS_STORAGE_UFI_COMMANDS || uid->bInterfaceSubClass == MASS_STORAGE_SFF8070_COMMANDS) &&*/ uid->bInterfaceProtocol == MASS_STORAGE_BULK_ONLY) { if (uid->bNumEndpoints < 2) continue; dev->ep_in = dev->ep_out = 0; for (iEp = 0; iEp < uid->bNumEndpoints; iEp++) { ued = &uid->endpoints[iEp]; if (ued->bmAttributes != USB_ENDPOINT_BULK) continue; if (ued->bEndpointAddress & USB_ENDPOINT_IN) { dev->ep_in = ued->bEndpointAddress; } else { dev->ep_out = ued->bEndpointAddress; if(ued->wMaxPacketSize > 64 && (dev->usb_fd>=0x20 || dev->usb_fd<-1)) usb2_mode=true; else usb2_mode=false; } } if (dev->ep_in != 0 && dev->ep_out != 0) { dev->configuration = ucd->bConfigurationValue; dev->interface = uid->bInterfaceNumber; dev->altInterface = uid->bAlternateSetting; goto found; } } } } USB_OGC_FreeDescriptors(&udd); retval = USBSTORAGE_ENOINTERFACE; goto free_and_return; found: dev->bInterfaceSubClass = uid->bInterfaceSubClass; USB_OGC_FreeDescriptors(&udd); retval = USBSTORAGE_EINIT; // some devices return an error, ignore it USB_OGC_GetConfiguration(dev->usb_fd, &conf); if (conf != dev->configuration) USB_OGC_SetConfiguration(dev->usb_fd, dev->configuration); if (dev->altInterface !=0) USB_OGC_SetAlternativeInterface(dev->usb_fd, dev->interface, dev->altInterface); if(!usb2_mode) retval = USBStorageOGC_Reset(dev); dev->suspended = 0; LWP_MutexLock(dev->lock); retval = __USB_CtrlMsgTimeout(dev, (USB_CTRLTYPE_DIR_DEVICE2HOST | USB_CTRLTYPE_TYPE_CLASS | USB_CTRLTYPE_REC_INTERFACE), USBSTORAGE_GET_MAX_LUN, 0, dev->interface, 1, max_lun); LWP_MutexUnlock(dev->lock); if (retval < 0) dev->max_lun = 1; else dev->max_lun = *max_lun + 1; if (retval == USBSTORAGE_ETIMEDOUT) goto free_and_return; retval = USBSTORAGE_OK; dev->sector_size = (u32 *) calloc(dev->max_lun, sizeof(u32)); if(!dev->sector_size) { retval = IPC_ENOMEM; goto free_and_return; } /* taken from linux usbstorage module (drivers/usb/storage/transport.c) * * Some devices (i.e. Iomega Zip100) need this -- apparently * the bulk pipes get STALLed when the GetMaxLUN request is * processed. This is, in theory, harmless to all other devices * (regardless of if they stall or not). * * 8/9/10: If anyone wants to actually use a Zip100, they can add this back. * But for now, it seems to be breaking things more than it is helping. */ //USB_ClearHalt(dev->usb_fd, dev->ep_in); //USB_ClearHalt(dev->usb_fd, dev->ep_out); if(!dev->buffer) dev->buffer = __lwp_heap_allocate(&__heap, MAX_TRANSFER_SIZE_V5); if(!dev->buffer) { retval = IPC_ENOMEM; } else { USB_OGC_DeviceRemovalNotifyAsync(dev->usb_fd,__usb_deviceremoved_cb,dev); retval = USBSTORAGE_OK; } free_and_return: if (max_lun) __lwp_heap_free(&__heap, max_lun); if (retval < 0) { USBStorageOGC_Close(dev); return retval; } return 0; }
int main(int argc, char *argv[]) { #ifdef HW_RVL IOS_ReloadIOS(IOS_GetVersion()); L2Enhance(); gx_init_mem2(); #endif fatInitDefault(); #ifdef HAVE_LOGGER g_extern.verbose = true; logger_init(); devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_net; #elif defined(HAVE_FILE_LOGGER) g_extern.verbose = true; log_fp = fopen("/retroarch-log.txt", "w"); devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_file; #endif #ifdef HW_RVL lwp_t gx_device_thread; gx_devices[GX_DEVICE_SD].interface = &__io_wiisd; gx_devices[GX_DEVICE_SD].name = "sd"; gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface); gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage; gx_devices[GX_DEVICE_USB].name = "usb"; gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface); LWP_MutexInit(&gx_device_mutex, false); LWP_CreateThread(&gx_device_thread, gx_devthread, NULL, NULL, 0, 66); #endif get_environment_settings(); make_directories(); config_set_defaults(); input_gx.init(); video_gx.start(); driver.video = &video_gx; gx_video_t *gx = (gx_video_t*)driver.video_data; gx->menu_data = (uint32_t *) menu_framebuf; char tmp_path[PATH_MAX]; const char *extension = default_paths.executable_extension; snprintf(tmp_path, sizeof(tmp_path), "%s/", default_paths.core_dir); const char *path_prefix = tmp_path; char full_path[1024]; snprintf(full_path, sizeof(full_path), "%sCORE%s", path_prefix, extension); bool find_libretro_file = rarch_configure_libretro_core(full_path, path_prefix, path_prefix, default_paths.config_file, extension); rarch_settings_set_default(&input_gx); rarch_config_load(default_paths.config_file, path_prefix, extension, find_libretro_file); char core_name[64]; rarch_console_name_from_id(core_name, sizeof(core_name)); char input_path[1024]; snprintf(input_path, sizeof(input_path), "%s/%s.cfg", default_paths.input_presets_dir, core_name); config_read_keybinds(input_path); init_libretro_sym(); input_gx.post_init(); menu_init(); if (argc > 2 && argv[1] != NULL && argv[2] != NULL) { char rom[PATH_MAX]; g_console.external_launcher_support = EXTERN_LAUNCHER_CHANNEL; snprintf(rom, sizeof(rom), "%s%s", argv[1], argv[2]); g_console.zip_extract_mode = ZIP_EXTRACT_TO_CURRENT_DIR_AND_LOAD_FIRST_FILE; rarch_console_load_game_wrap(rom, g_console.zip_extract_mode, S_DELAY_1); rgui_iterate(rgui, RGUI_ACTION_MESSAGE); gx->menu_render = true; rarch_render_cached_frame(); gx->menu_render = false; rarch_startup(default_paths.config_file); } else { g_console.external_launcher_support = EXTERN_LAUNCHER_SALAMANDER; } begin_loop: if(g_console.mode_switch == MODE_EMULATION) { bool repeat = false; input_gx.poll(NULL); video_set_aspect_ratio_func(g_console.aspect_ratio_index); audio_start_func(); do{ repeat = rarch_main_iterate(); }while(repeat && !g_console.frame_advance_enable); audio_stop_func(); } else if(g_console.mode_switch == MODE_MENU) { menu_loop(); if (g_console.mode_switch != MODE_EXIT) rarch_startup(default_paths.config_file); } else goto begin_shutdown; goto begin_loop; begin_shutdown: rarch_config_save(default_paths.config_file); config_save_keybinds(input_path); if(g_console.emulator_initialized) rarch_main_deinit(); input_gx.free(NULL); video_gx.stop(); menu_free(); #ifdef HAVE_LOGGER logger_shutdown(); #elif defined(HAVE_FILE_LOGGER) fclose(log_fp); #endif if(g_console.return_to_launcher) rarch_console_exec(g_console.launch_app_on_exit); exit(0); }