int OraDBRequest::selectConditionerBind() { const char sql_stmt[] = "select id, tran_type, msisdn, promo_code, promo_value, promo_name, service_id, cluster_node, brand" " from conditioner_log where brand = :brand and cluster_node = :cluster_node and status = :status" " and rownum < :limit order by id"; _sth_select_conditioner = SQLO_STH_INIT; if ((_sth_select_conditioner = sqlo_prepare(_dbh, sql_stmt)) < 0) { LOG_CRITICAL("%s: Failed to prepare statement handle for SELECT_CONDITIONER.", __func__); return -1; } if (SQLO_SUCCESS != ( sqlo_bind_by_name(_sth_select_conditioner, ":brand", SQLOT_STR, &_var_brand, sizeof(_var_brand), 0, 0) || sqlo_bind_by_name(_sth_select_conditioner, ":cluster_node", SQLOT_INT, &_var_cluster_node, sizeof(_var_cluster_node), 0, 0) || sqlo_bind_by_name(_sth_select_conditioner, ":status", SQLOT_INT, &_var_status, sizeof(_var_status), 0, 0) || sqlo_bind_by_name(_sth_select_conditioner, ":limit", SQLOT_INT, &_var_limit, sizeof(_var_limit), 0, 0) || sqlo_define_by_pos(_sth_select_conditioner, 1, SQLOT_INT, &_request.id, sizeof(_request.id), 0, 0, 0) || sqlo_define_by_pos(_sth_select_conditioner, 2, SQLOT_INT, &_request.tran_type, sizeof(_request.tran_type), 0, 0, 0) || sqlo_define_by_pos(_sth_select_conditioner, 3, SQLOT_STR, &_request.a_no, sizeof(_request.a_no), &_ind_a_no, 0, 0) || sqlo_define_by_pos(_sth_select_conditioner, 4, SQLOT_STR, &_request.promo_code, sizeof(_request.promo_code), &_ind_promo_code, 0, 0) || sqlo_define_by_pos(_sth_select_conditioner, 5, SQLOT_STR, &_request.promo_value, sizeof(_request.promo_value), &_ind_promo_value, 0, 0) || sqlo_define_by_pos(_sth_select_conditioner, 6, SQLOT_STR, &_request.promo_name, sizeof(_request.promo_name), &_ind_promo_name, 0, 0) || sqlo_define_by_pos(_sth_select_conditioner, 7, SQLOT_STR, &_request.service_id, sizeof(_request.service_id), &_ind_service_id, 0, 0) || sqlo_define_by_pos(_sth_select_conditioner, 8, SQLOT_INT, &_request.cluster_node, sizeof(_request.cluster_node), 0, 0, 0) || sqlo_define_by_pos(_sth_select_conditioner, 9, SQLOT_STR, &_request.brand, sizeof(_request.brand), &_ind_brand, 0, 0) )) { LOG_CRITICAL("%s: Failed to bind variables for SELECT_CONDITIONER statement handle.", __func__); return -2; } return 0; }
int OraDBRequest::usurfActivationBind() { const char sql_stmt[] = "BEGIN" " SP_USURF_ACTIVATION(:p_retr, :p_partner, :p_exptime, :p_expdate, :p_msisdn, :p_country, :p_duration, :p_nf_status);" " END;"; _sth_ua = SQLO_STH_INIT; if ((_sth_ua = sqlo_prepare(_dbh, sql_stmt)) < 0) { LOG_CRITICAL("%s: Failed to prepare statement handle for SP_USURF_ACTIVATION.", __func__); return -1; } if (SQLO_SUCCESS != ( sqlo_bind_by_name(_sth_ua, ":p_retr", SQLOT_INT, &_var_retr, sizeof(_var_retr), 0, 0) || sqlo_bind_by_name(_sth_ua, ":p_partner", SQLOT_STR, &_var_extra_o_1, sizeof(_var_extra_o_1), &_ind_extra_1, 0) || sqlo_bind_by_name(_sth_ua, ":p_exptime", SQLOT_STR, &_var_extra_o_2, sizeof(_var_extra_o_2), &_ind_extra_2, 0) || sqlo_bind_by_name(_sth_ua, ":p_expdate", SQLOT_STR, &_var_extra_o_3, sizeof(_var_extra_o_3), &_ind_extra_3, 0) || sqlo_bind_by_name(_sth_ua, ":p_msisdn", SQLOT_STR, &_var_msisdn, sizeof(_var_msisdn), 0, 0) || sqlo_bind_by_name(_sth_ua, ":p_country", SQLOT_STR, &_var_country, sizeof(_var_country), 0, 0) || sqlo_bind_by_name(_sth_ua, ":p_duration", SQLOT_INT, &_var_duration, sizeof(_var_duration), 0, 0) || sqlo_bind_by_name(_sth_ua, ":p_nf_status", SQLOT_INT, &_var_status, sizeof(_var_status), 0, 0) )) { LOG_CRITICAL("%s: Failed to bind variables for SP_USURF_ACTIVATION statement handle.", __func__); return -2; } return 0; }
int OraDBRequest::selectManualBind() { //-- ACTIVATION, DEACTIVATION, EXTENSION, CANCEL const char sql_stmt[] = "select id, msisdn, enrollment_type, cluster_node, customer_type, link_to, silent, request_origin, imsi" " from manual_enrollment_log where tx_date <= sysdate" " and cluster_node = :cluster_node and status = :status" " and rownum < :limit order by id"; _sth_select2 = SQLO_STH_INIT; if ((_sth_select2 = sqlo_prepare(_dbh, sql_stmt)) < 0) { LOG_CRITICAL("%s: Failed to prepare statement handle for SELECT_MANUAL_REQUEST.", __func__); return -1; } if (SQLO_SUCCESS != ( sqlo_bind_by_name(_sth_select2, ":cluster_node", SQLOT_INT, &_var_cluster_node, sizeof(_var_cluster_node), 0, 0) || sqlo_bind_by_name(_sth_select2, ":status", SQLOT_INT, &_var_status, sizeof(_var_status), 0, 0) || sqlo_bind_by_name(_sth_select2, ":limit", SQLOT_INT, &_var_limit, sizeof(_var_limit), 0, 0) || sqlo_define_by_pos(_sth_select2, 1, SQLOT_INT, &_request.id, sizeof(_request.id), 0, 0, 0) || sqlo_define_by_pos(_sth_select2, 2, SQLOT_STR, &_request.a_no, sizeof(_request.a_no), &_ind_a_no, 0, 0) || sqlo_define_by_pos(_sth_select2, 3, SQLOT_STR, &_request.msg, sizeof(_request.msg), &_ind_msg, 0, 0) || sqlo_define_by_pos(_sth_select2, 4, SQLOT_INT, &_request.cluster_node, sizeof(_request.cluster_node), 0, 0, 0) || sqlo_define_by_pos(_sth_select2, 5, SQLOT_STR, &_request.customer_type, sizeof(_request.customer_type), &_ind_customer_type, 0, 0) || sqlo_define_by_pos(_sth_select2, 6, SQLOT_STR, &_request.gsm_num, sizeof(_request.gsm_num), &_ind_gsm_num, 0, 0) || sqlo_define_by_pos(_sth_select2, 7, SQLOT_INT, &_request.silent, sizeof(_request.silent), &_ind_silent, 0, 0) || sqlo_define_by_pos(_sth_select2, 8, SQLOT_STR, &_request.request_origin, sizeof(_request.request_origin), &_ind_request_origin, 0, 0) || sqlo_define_by_pos(_sth_select2, 9, SQLOT_STR, &_request.imsi, sizeof(_request.imsi), &_ind_imsi, 0, 0) )) { LOG_CRITICAL("%s: Failed to bind variables for SELECT_MANUAL_REQUEST statement handle.", __func__); return -2; } return 0; }
int NSN::initialize() { if (_param.logh) { LOG_SET_HANDLE(_param.logh); } if (OraDB::init_lib(true) < 0) { LOG_CRITICAL("%s::%s: Unable to initialize OCI!!!", __class__, __func__); return -1; } *username = 0; *password = 0; *host = 0; port = 0; timeout = 0; *nsnUsername = 0; *nsnExpirationDate = 0; buffer = (char*)malloc(buffer_size); if (! buffer) { LOG_CRITICAL("%s::%s: Unable to allocate memory fo buffer!", __class__, __func__); return -1; } memset(buffer, 0, buffer_size); LOG_INFO("%s::%s: ...", __class__, __func__); #if 0 LOG_INFO("%s::%s: host: %s, port: %d, nsn_user: %s, nsn_pass: %s, nsn_name: %s, nsn_expiry: %s, timeout: %d", __class__, __func__, host, port, username, password, nsnUsername, nsnExpirationDate, timeout); #endif return 0; }
int OraDBRequest::processTranBind() { const char sql_stmt[] = "BEGIN" " SP_PROCESS_TRAN(:p_retr, :p_extra_o_1, :p_extra_o_2, :p_extra_o_3," " :p_trantype, :p_msisdn, :p_req_id, :p_ref_id, :p_extra_i_1, :p_extra_i_2, :p_extra_i_3);" " END;"; _sth_pt = SQLO_STH_INIT; if ((_sth_pt = sqlo_prepare(_dbh, sql_stmt)) < 0) { LOG_CRITICAL("%s: Failed to prepare statement handle for SP_PROCESS_TRAN.", __func__); return -1; } if (SQLO_SUCCESS != ( sqlo_bind_by_name(_sth_pt, ":p_retr", SQLOT_INT, &_var_retr, sizeof(_var_retr), 0, 0) || sqlo_bind_by_name(_sth_pt, ":p_extra_o_1", SQLOT_STR, &_var_extra_o_1, sizeof(_var_extra_o_1), &_ind_extra_1, 0) || sqlo_bind_by_name(_sth_pt, ":p_extra_o_2", SQLOT_STR, &_var_extra_o_2, sizeof(_var_extra_o_2), &_ind_extra_2, 0) || sqlo_bind_by_name(_sth_pt, ":p_extra_o_3", SQLOT_STR, &_var_extra_o_3, sizeof(_var_extra_o_3), &_ind_extra_3, 0) || sqlo_bind_by_name(_sth_pt, ":p_trantype", SQLOT_INT, &_var_trantype, sizeof(_var_trantype), 0, 0) || sqlo_bind_by_name(_sth_pt, ":p_msisdn", SQLOT_STR, &_var_msisdn, sizeof(_var_msisdn), 0, 0) || sqlo_bind_by_name(_sth_pt, ":p_req_id", SQLOT_INT, &_var_req_id, sizeof(_var_req_id), 0, 0) || sqlo_bind_by_name(_sth_pt, ":p_ref_id", SQLOT_INT, &_var_ref_id, sizeof(_var_ref_id), 0, 0) || sqlo_bind_by_name(_sth_pt, ":p_extra_i_1", SQLOT_STR, &_var_extra_i_1, sizeof(_var_extra_i_1), 0, 0) || sqlo_bind_by_name(_sth_pt, ":p_extra_i_2", SQLOT_STR, &_var_extra_i_2, sizeof(_var_extra_i_2), 0, 0) || sqlo_bind_by_name(_sth_pt, ":p_extra_i_3", SQLOT_STR, &_var_extra_i_3, sizeof(_var_extra_i_3), 0, 0) )) { LOG_CRITICAL("%s: Failed to bind variables for SP_PROCESS_TRAN statement handle.", __func__); return -2; } return 0; }
uint64_t get_random_seed(uint64_t seed) { Logger::init(); static const char* device = "/dev/urandom"; int fd = open(device, O_RDONLY); if (fd < 0) { char buf[STRERROR_BUFSIZE_]; char* err = strerror_r(errno, buf, sizeof(buf)); LOG_CRITICAL("Unable to open random device (%s): %s", device, err); return seed; } ssize_t num_bytes = read(fd, reinterpret_cast<char*>(&seed), sizeof(seed)); if (num_bytes < 0) { char buf[STRERROR_BUFSIZE_]; char* err = strerror_r(errno, buf, sizeof(buf)); LOG_CRITICAL("Unable to read from random device (%s): %s", device, err); } else if (num_bytes != sizeof(seed)) { char buf[STRERROR_BUFSIZE_]; char* err = strerror_r(errno, buf, sizeof(buf)); LOG_CRITICAL("Unable to read full seed value (expected: %u read: %u) " "from random device (%s): %s", static_cast<unsigned int>(sizeof(seed)), static_cast<unsigned int>(num_bytes), device, err); } close(fd); return seed; }
int OraDBRequest::processShampooBind() { const char sql_stmt[] = "BEGIN" " SP_PROCESS_SHAMPOO(:p_retr, :p_type, :p_msisdn, :p_plan, :p_start, :p_end);" " END;"; _sth_process_shampoo = SQLO_STH_INIT; if ((_sth_process_shampoo = sqlo_prepare(_dbh, sql_stmt)) < 0) { LOG_CRITICAL("%s: Failed to prepare statement handle for SP_PROCESS_SHAMPOO.", __func__); return -1; } if (SQLO_SUCCESS != ( sqlo_bind_by_name(_sth_process_shampoo, ":p_retr", SQLOT_INT, &_var_retr, sizeof(_var_retr), 0, 0) || sqlo_bind_by_name(_sth_process_shampoo, ":p_type", SQLOT_STR, &_request.svc_type, sizeof(_request.svc_type), 0, 0) || sqlo_bind_by_name(_sth_process_shampoo, ":p_msisdn", SQLOT_STR, &_request.svc_msisdn, sizeof(_request.svc_msisdn), 0, 0) || sqlo_bind_by_name(_sth_process_shampoo, ":p_plan", SQLOT_STR, &_request.svc_plan, sizeof(_request.svc_plan), 0, 0) || sqlo_bind_by_name(_sth_process_shampoo, ":p_start", SQLOT_STR, &_request.svc_start, sizeof(_request.svc_start), 0, 0) || sqlo_bind_by_name(_sth_process_shampoo, ":p_end", SQLOT_STR, &_request.svc_end, sizeof(_request.svc_end), 0, 0) )) { LOG_CRITICAL("%s: Failed to bind variables for SP_PROCESS_SHAMPOO statement handle.", __func__); return -2; } return 0; }
int FliVariableObjHdl::initialise(std::string &name) { /* Pre allocte buffers on signal type basis */ m_fli_type = mti_GetTypeKind(mti_GetVarType(m_fli_hdl)); switch (m_fli_type) { case MTI_TYPE_ENUM: m_val_len = 1; break; case MTI_TYPE_SCALAR: case MTI_TYPE_PHYSICAL: m_val_len = 32; break; case MTI_TYPE_ARRAY: m_val_len = mti_TickLength(mti_GetVarType(m_fli_hdl)); m_mti_buff = (mtiInt32T*)malloc(sizeof(*m_mti_buff) * m_val_len); if (!m_mti_buff) { LOG_CRITICAL("Unable to alloc mem for signal mti read buffer: ABORTING"); } break; default: LOG_ERROR("Unable to handle object type for %s (%d)", name.c_str(), m_fli_type); } m_val_buff = (char*)malloc(m_val_len+1); if (!m_val_buff) { LOG_CRITICAL("Unable to alloc mem for signal read buffer: ABORTING"); } m_val_buff[m_val_len] = '\0'; GpiObjHdl::initialise(name); return 0; }
static void MemoryFill(const Regs::MemoryFillConfig& config) { const PAddr start_addr = config.GetStartAddress(); const PAddr end_addr = config.GetEndAddress(); // TODO: do hwtest with these cases if (!Memory::IsValidPhysicalAddress(start_addr)) { LOG_CRITICAL(HW_GPU, "invalid start address 0x%08X", start_addr); return; } if (!Memory::IsValidPhysicalAddress(end_addr)) { LOG_CRITICAL(HW_GPU, "invalid end address 0x%08X", end_addr); return; } if (end_addr <= start_addr) { LOG_CRITICAL(HW_GPU, "invalid memory range from 0x%08X to 0x%08X", start_addr, end_addr); return; } u8* start = Memory::GetPhysicalPointer(start_addr); u8* end = Memory::GetPhysicalPointer(end_addr); // TODO: Consider always accelerating and returning vector of // regions that the accelerated fill did not cover to // reduce/eliminate the fill that the cpu has to do. // This would also mean that the flush below is not needed. // Fill should first flush all surfaces that touch but are // not completely within the fill range. // Then fill all completely covered surfaces, and return the // regions that were between surfaces or within the touching // ones for cpu to manually fill here. if (VideoCore::g_renderer->Rasterizer()->AccelerateFill(config)) return; Memory::RasterizerFlushAndInvalidateRegion(config.GetStartAddress(), config.GetEndAddress() - config.GetStartAddress()); if (config.fill_24bit) { // fill with 24-bit values for (u8* ptr = start; ptr < end; ptr += 3) { ptr[0] = config.value_24bit_r; ptr[1] = config.value_24bit_g; ptr[2] = config.value_24bit_b; } } else if (config.fill_32bit) { // fill with 32-bit values if (end > start) { u32 value = config.value_32bit; size_t len = (end - start) / sizeof(u32); for (size_t i = 0; i < len; ++i) memcpy(&start[i * sizeof(u32)], &value, sizeof(u32)); } } else { // fill with 16-bit values u16 value_16bit = config.value_16bit.Value(); for (u8* ptr = start; ptr < end; ptr += sizeof(u16)) memcpy(ptr, &value_16bit, sizeof(u16)); } }
int OraDBRequest::processMlpBind() { const char sql_stmt[] = "BEGIN" " SP_PROCESS_MLP(:p_retr, :p_msisdn, :p_transaction_code, :p_transaction_id, :p_bill_cycle, :p_type, :p_soc, :p_effdate);" " END;"; _sth_process_mlp = SQLO_STH_INIT; if ((_sth_process_mlp = sqlo_prepare(_dbh, sql_stmt)) < 0) { LOG_CRITICAL("%s: Failed to prepare statement handle for SP_PROCESS_MLP.", __func__); return -1; } if (SQLO_SUCCESS != ( sqlo_bind_by_name(_sth_process_mlp, ":p_retr", SQLOT_INT, &_var_retr, sizeof(_var_retr), 0, 0) || sqlo_bind_by_name(_sth_process_mlp, ":p_msisdn", SQLOT_STR, &_request.svc_msisdn, sizeof(_request.svc_msisdn), 0, 0) || sqlo_bind_by_name(_sth_process_mlp, ":p_transaction_code", SQLOT_STR, &_request.svc_txcode, sizeof(_request.svc_txcode), 0, 0) || sqlo_bind_by_name(_sth_process_mlp, ":p_transaction_id", SQLOT_STR, &_request.svc_txid, sizeof(_request.svc_txid), 0, 0) || sqlo_bind_by_name(_sth_process_mlp, ":p_bill_cycle", SQLOT_STR, &_request.svc_bill_cycle, sizeof(_request.svc_bill_cycle), 0, 0) || sqlo_bind_by_name(_sth_process_mlp, ":p_type", SQLOT_STR, &_request.svc_type, sizeof(_request.svc_type), 0, 0) || sqlo_bind_by_name(_sth_process_mlp, ":p_soc", SQLOT_STR, &_request.svc_soc, sizeof(_request.svc_soc), 0, 0) || sqlo_bind_by_name(_sth_process_mlp, ":p_effdate", SQLOT_STR, &_request.svc_eff_date, sizeof(_request.svc_eff_date), 0, 0) )) { LOG_CRITICAL("%s: Failed to bind variables for SP_PROCESS_MLP statement handle.", __func__); return -2; } return 0; }
int VpiCbHdl::cleanup_callback(void) { if (m_state == GPI_FREE) return 0; /* If the one-time callback has not come back then * remove it, it is has then free it. The remove is done * internally */ if (m_state == GPI_PRIMED) { if (!m_obj_hdl) { LOG_CRITICAL("VPI: passed a NULL pointer : ABORTING"); } if (!(vpi_remove_cb(get_handle<vpiHandle>()))) { LOG_CRITICAL("VPI: unbale to remove callback : ABORTING"); } check_vpi_error(); } else { #ifndef MODELSIM /* This is disabled for now, causes a small leak going to put back in */ if (!(vpi_free_object(get_handle<vpiHandle>()))) { LOG_CRITICAL("VPI: unbale to free handle : ABORTING"); } #endif } m_obj_hdl = NULL; m_state = GPI_FREE; return 0; }
SDL2Sink::SDL2Sink() : impl(std::make_unique<Impl>()) { if (SDL_Init(SDL_INIT_AUDIO) < 0) { LOG_CRITICAL(Audio_Sink, "SDL_Init(SDL_INIT_AUDIO) failed"); impl->audio_device_id = 0; return; } SDL_AudioSpec desired_audiospec; SDL_zero(desired_audiospec); desired_audiospec.format = AUDIO_S16; desired_audiospec.channels = 2; desired_audiospec.freq = native_sample_rate; desired_audiospec.samples = 1024; desired_audiospec.userdata = impl.get(); desired_audiospec.callback = &Impl::Callback; SDL_AudioSpec obtained_audiospec; SDL_zero(obtained_audiospec); impl->audio_device_id = SDL_OpenAudioDevice(nullptr, false, &desired_audiospec, &obtained_audiospec, 0); if (impl->audio_device_id <= 0) { LOG_CRITICAL(Audio_Sink, "SDL_OpenAudioDevice failed"); return; } impl->sample_rate = obtained_audiospec.freq; // SDL2 audio devices start out paused, unpause it: SDL_PauseAudioDevice(impl->audio_device_id, 0); }
ResultCode SaveDataArchive::DeleteFile(const Path& path) const { const PathParser path_parser(path); if (!path_parser.IsValid()) { LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); return ERROR_INVALID_PATH; } const auto full_path = path_parser.BuildHostPath(mount_point); switch (path_parser.GetHostStatus(mount_point)) { case PathParser::InvalidMountPoint: LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); return ERROR_FILE_NOT_FOUND; case PathParser::PathNotFound: LOG_ERROR(Service_FS, "Path not found {}", full_path); return ERROR_PATH_NOT_FOUND; case PathParser::FileInPath: case PathParser::DirectoryFound: case PathParser::NotFound: LOG_ERROR(Service_FS, "File not found {}", full_path); return ERROR_FILE_NOT_FOUND; case PathParser::FileFound: break; // Expected 'success' case } if (FileUtil::Delete(full_path)) { return RESULT_SUCCESS; } LOG_CRITICAL(Service_FS, "(unreachable) Unknown error deleting {}", full_path); return ERROR_FILE_NOT_FOUND; }
/// Application entry point int main(int argc, char **argv) { Log::Filter log_filter(Log::Level::Debug); Log::SetFilter(&log_filter); if (argc < 2) { LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); return -1; } Config config; log_filter.ParseFilterString(Settings::values.log_filter); std::string boot_filename = argv[1]; EmuWindow_GLFW* emu_window = new EmuWindow_GLFW; VideoCore::g_hw_renderer_enabled = Settings::values.use_hw_renderer; System::Init(emu_window); Loader::ResultStatus load_result = Loader::LoadFile(boot_filename); if (Loader::ResultStatus::Success != load_result) { LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result); return -1; } while (emu_window->IsOpen()) { Core::RunLoop(); } System::Shutdown(); delete emu_window; return 0; }
ResultVal<std::unique_ptr<FileBackend>> SaveDataArchive::OpenFile(const Path& path, const Mode& mode) const { LOG_DEBUG(Service_FS, "called path={} mode={:01X}", path.DebugStr(), mode.hex); const PathParser path_parser(path); if (!path_parser.IsValid()) { LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); return ERROR_INVALID_PATH; } if (mode.hex == 0) { LOG_ERROR(Service_FS, "Empty open mode"); return ERROR_UNSUPPORTED_OPEN_FLAGS; } if (mode.create_flag && !mode.write_flag) { LOG_ERROR(Service_FS, "Create flag set but write flag not set"); return ERROR_UNSUPPORTED_OPEN_FLAGS; } const auto full_path = path_parser.BuildHostPath(mount_point); switch (path_parser.GetHostStatus(mount_point)) { case PathParser::InvalidMountPoint: LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); return ERROR_FILE_NOT_FOUND; case PathParser::PathNotFound: LOG_ERROR(Service_FS, "Path not found {}", full_path); return ERROR_PATH_NOT_FOUND; case PathParser::FileInPath: case PathParser::DirectoryFound: LOG_ERROR(Service_FS, "Unexpected file or directory in {}", full_path); return ERROR_UNEXPECTED_FILE_OR_DIRECTORY; case PathParser::NotFound: if (!mode.create_flag) { LOG_ERROR(Service_FS, "Non-existing file {} can't be open without mode create.", full_path); return ERROR_FILE_NOT_FOUND; } else { // Create the file FileUtil::CreateEmptyFile(full_path); } break; case PathParser::FileFound: break; // Expected 'success' case } FileUtil::IOFile file(full_path, mode.write_flag ? "r+b" : "rb"); if (!file.IsOpen()) { LOG_CRITICAL(Service_FS, "(unreachable) Unknown error opening {}", full_path); return ERROR_FILE_NOT_FOUND; } std::unique_ptr<DelayGenerator> delay_generator = std::make_unique<SaveDataDelayGenerator>(); auto disk_file = std::make_unique<DiskFile>(std::move(file), mode, std::move(delay_generator)); return MakeResult<std::unique_ptr<FileBackend>>(std::move(disk_file)); }
System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) { app_loader = Loader::GetLoader(filepath); if (!app_loader) { LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); return ResultStatus::ErrorGetLoader; } std::pair<std::optional<u32>, Loader::ResultStatus> system_mode = app_loader->LoadKernelSystemMode(); if (system_mode.second != Loader::ResultStatus::Success) { LOG_CRITICAL(Core, "Failed to determine system mode (Error {})!", static_cast<int>(system_mode.second)); switch (system_mode.second) { case Loader::ResultStatus::ErrorEncrypted: return ResultStatus::ErrorLoader_ErrorEncrypted; case Loader::ResultStatus::ErrorInvalidFormat: return ResultStatus::ErrorLoader_ErrorInvalidFormat; default: return ResultStatus::ErrorSystemMode; } } ASSERT(system_mode.first); ResultStatus init_result{Init(emu_window, *system_mode.first)}; if (init_result != ResultStatus::Success) { LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", static_cast<u32>(init_result)); System::Shutdown(); return init_result; } std::shared_ptr<Kernel::Process> process; const Loader::ResultStatus load_result{app_loader->Load(process)}; kernel->SetCurrentProcess(process); if (Loader::ResultStatus::Success != load_result) { LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<u32>(load_result)); System::Shutdown(); switch (load_result) { case Loader::ResultStatus::ErrorEncrypted: return ResultStatus::ErrorLoader_ErrorEncrypted; case Loader::ResultStatus::ErrorInvalidFormat: return ResultStatus::ErrorLoader_ErrorInvalidFormat; default: return ResultStatus::ErrorLoader; } } memory->SetCurrentPageTable(&kernel->GetCurrentProcess()->vm_manager.page_table); cheat_engine = std::make_unique<Cheats::CheatEngine>(*this); status = ResultStatus::Success; m_emu_window = &emu_window; m_filepath = filepath; return status; }
bool GMainWindow::LoadROM(const std::string& filename) { std::unique_ptr<Loader::AppLoader> app_loader = Loader::GetLoader(filename); if (!app_loader) { LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filename.c_str()); QMessageBox::critical(this, tr("Error while loading ROM!"), tr("The ROM format is not supported.")); return false; } boost::optional<u32> system_mode = app_loader->LoadKernelSystemMode(); if (!system_mode) { LOG_CRITICAL(Frontend, "Failed to load ROM!"); QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Could not determine the system mode.")); return false; } if (!InitializeSystem(system_mode.get())) return false; Loader::ResultStatus result = app_loader->Load(); if (Loader::ResultStatus::Success != result) { System::Shutdown(); LOG_CRITICAL(Frontend, "Failed to load ROM!"); switch (result) { case Loader::ResultStatus::ErrorEncrypted: { // Build the MessageBox ourselves to have clickable link QMessageBox popup_error; popup_error.setTextFormat(Qt::RichText); popup_error.setWindowTitle(tr("Error while loading ROM!")); popup_error.setText( tr("The game that you are trying to load must be decrypted before being used with " "Citra.<br/><br/>" "For more information on dumping and decrypting games, please see: <a " "href='https://citra-emu.org/wiki/Dumping-Game-Cartridges'>https://" "citra-emu.org/wiki/Dumping-Game-Cartridges</a>")); popup_error.setIcon(QMessageBox::Critical); popup_error.exec(); break; } case Loader::ResultStatus::ErrorInvalidFormat: QMessageBox::critical(this, tr("Error while loading ROM!"), tr("The ROM format is not supported.")); break; case Loader::ResultStatus::Error: default: QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Unknown error!")); break; } return false; } return true; }
EmuWindow_SDL2::EmuWindow_SDL2() { keyboard_id = KeyMap::NewDeviceId(); ReloadSetKeymaps(); SDL_SetMainReady(); // Initialize the window if (SDL_Init(SDL_INIT_VIDEO) < 0) { LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting..."); exit(1); } SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); render_window = SDL_CreateWindow( window_title.c_str(), SDL_WINDOWPOS_UNDEFINED, // x position SDL_WINDOWPOS_UNDEFINED, // y position VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); if (render_window == nullptr) { LOG_CRITICAL(Frontend, "Failed to create SDL2 window! Exiting..."); exit(1); } gl_context = SDL_GL_CreateContext(render_window); if (gl_context == nullptr) { LOG_CRITICAL(Frontend, "Failed to create SDL2 GL context! Exiting..."); exit(1); } if (!gladLoadGLLoader(static_cast<GLADloadproc>(SDL_GL_GetProcAddress))) { LOG_CRITICAL(Frontend, "Failed to initialize GL functions! Exiting..."); exit(1); } OnResize(); OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); SDL_PumpEvents(); SDL_GL_SetSwapInterval(Settings::values.use_vsync); DoneCurrent(); }
bool StorageAdapter::init() { FUNCTION_CALL_TRACE; // ** Process properties from client/server plugin // ** Process properties from storage plugin QMap<QString, QString> pluginProperties; iPlugin->getProperties( pluginProperties ); LOG_DEBUG( "StorageAdapter: dumping storage properties:" ); LOG_DEBUG( pluginProperties ); // Preferred format QString preferredFormat = pluginProperties.value( STORAGE_DEFAULT_MIME_PROP ); QString preferredVersion = pluginProperties.value( STORAGE_DEFAULT_MIME_VERSION_PROP ); if( preferredFormat.isEmpty() || preferredVersion.isEmpty() ) { LOG_CRITICAL( "No STORAGE_DEFAULT_MIME_PROP or STORAGE_DEFAULT_MIME_VERSION_PROP" <<"found for storage: " << iPlugin->getPluginName() ); return false; } // Currently we support only one format per storage DataSync::ContentFormat format; format.iType = preferredFormat; format.iVersion = preferredVersion; iFormats.setPreferredRx( format ); iFormats.setPreferredTx( format ); iFormats.rx().append( format ); iFormats.tx().append( format ); // Source URI iSourceDB = pluginProperties.value( STORAGE_SOURCE_URI ); if( iSourceDB.isEmpty() ) { LOG_CRITICAL( "No STORAGE_SOURCE_URI prop found for storage: " << iPlugin->getPluginName() ); return false; } // Target URI iTargetDB = pluginProperties[STORAGE_REMOTE_URI]; // ** Own initialization iType = preferredFormat; QString dbFilePath = SyncMLConfig::getDatabasePath() + ADAPTERDBFILE; iIdMapper.init( dbFilePath, iPlugin->getPluginName() ); return true; }
static void MemoryFill(const Regs::MemoryFillConfig& config) { const PAddr start_addr = config.GetStartAddress(); const PAddr end_addr = config.GetEndAddress(); // TODO: do hwtest with these cases if (!Memory::IsValidPhysicalAddress(start_addr)) { LOG_CRITICAL(HW_GPU, "invalid start address {:#010X}", start_addr); return; } if (!Memory::IsValidPhysicalAddress(end_addr)) { LOG_CRITICAL(HW_GPU, "invalid end address {:#010X}", end_addr); return; } if (end_addr <= start_addr) { LOG_CRITICAL(HW_GPU, "invalid memory range from {:#010X} to {:#010X}", start_addr, end_addr); return; } u8* start = Memory::GetPhysicalPointer(start_addr); u8* end = Memory::GetPhysicalPointer(end_addr); if (VideoCore::g_renderer->Rasterizer()->AccelerateFill(config)) return; Memory::RasterizerInvalidateRegion(config.GetStartAddress(), config.GetEndAddress() - config.GetStartAddress()); if (config.fill_24bit) { // fill with 24-bit values for (u8* ptr = start; ptr < end; ptr += 3) { ptr[0] = config.value_24bit_r; ptr[1] = config.value_24bit_g; ptr[2] = config.value_24bit_b; } } else if (config.fill_32bit) { // fill with 32-bit values if (end > start) { u32 value = config.value_32bit; size_t len = (end - start) / sizeof(u32); for (size_t i = 0; i < len; ++i) memcpy(&start[i * sizeof(u32)], &value, sizeof(u32)); } } else { // fill with 16-bit values u16 value_16bit = config.value_16bit.Value(); for (u8* ptr = start; ptr < end; ptr += sizeof(u16)) memcpy(ptr, &value_16bit, sizeof(u16)); } }
int VhpiSignalObjHdl::initialise(std::string &name) { // Determine the type of object, either scalar or vector m_value.format = vhpiObjTypeVal; m_value.bufSize = 0; m_value.value.str = NULL; vhpi_get_value(GpiObjHdl::get_handle<vhpiHandleT>(), &m_value); check_vhpi_error(); switch (m_value.format) { case vhpiEnumVal: case vhpiLogicVal: { m_value.value.enumv = vhpi0; break; } case vhpiEnumVecVal: case vhpiLogicVecVal: { m_size = vhpi_get(vhpiSizeP, GpiObjHdl::get_handle<vhpiHandleT>()); m_value.bufSize = m_size*sizeof(vhpiEnumT); m_value.value.enumvs = (vhpiEnumT *)malloc(m_value.bufSize); if (!m_value.value.enumvs) { LOG_CRITICAL("Unable to alloc mem for write buffer: ABORTING"); } break; } default: { LOG_ERROR("Unable to determine property for %s (%d) format object", ((VhpiImpl*)GpiObjHdl::m_impl)->format_to_string(m_value.format), m_value.format); } } /* We also alloc a second value member for use with read string operations */ m_binvalue.format = vhpiBinStrVal; m_binvalue.bufSize = 0; m_binvalue.value.str = NULL; int new_size = vhpi_get_value(GpiObjHdl::get_handle<vhpiHandleT>(), &m_binvalue); m_binvalue.bufSize = new_size*sizeof(vhpiCharT) + 1; m_binvalue.value.str = (vhpiCharT *)calloc(m_binvalue.bufSize, m_binvalue.bufSize); if (!m_value.value.str) { LOG_CRITICAL("Unable to alloc mem for read buffer: ABORTING"); } GpiObjHdl::initialise(name); return 0; }
static char char_at(obj* self, va_list* args) { int i = va_arg(*args, int); if (i < 0) { LOG_CRITICAL("Attempt to access index %d of string with length %d", i, get_d(self, "length")); abort(); } else if (i >= get_d(self, "length")) { LOG_CRITICAL("Attempt to access index %d of string with length %d", i, get_d(self, "length")); abort(); } return get_s(self, "value")[i]; }
System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& filepath) { app_loader = Loader::GetLoader(filepath); if (!app_loader) { LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); return ResultStatus::ErrorGetLoader; } std::pair<boost::optional<u32>, Loader::ResultStatus> system_mode = app_loader->LoadKernelSystemMode(); if (system_mode.second != Loader::ResultStatus::Success) { LOG_CRITICAL(Core, "Failed to determine system mode (Error {})!", static_cast<int>(system_mode.second)); switch (system_mode.second) { case Loader::ResultStatus::ErrorEncrypted: return ResultStatus::ErrorLoader_ErrorEncrypted; case Loader::ResultStatus::ErrorInvalidFormat: return ResultStatus::ErrorLoader_ErrorInvalidFormat; default: return ResultStatus::ErrorSystemMode; } } ResultStatus init_result{Init(emu_window, system_mode.first.get())}; if (init_result != ResultStatus::Success) { LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", static_cast<u32>(init_result)); System::Shutdown(); return init_result; } const Loader::ResultStatus load_result{app_loader->Load(Kernel::g_current_process)}; if (Loader::ResultStatus::Success != load_result) { LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<u32>(load_result)); System::Shutdown(); switch (load_result) { case Loader::ResultStatus::ErrorEncrypted: return ResultStatus::ErrorLoader_ErrorEncrypted; case Loader::ResultStatus::ErrorInvalidFormat: return ResultStatus::ErrorLoader_ErrorInvalidFormat; default: return ResultStatus::ErrorLoader; } } Memory::SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table); status = ResultStatus::Success; return status; }
GpiObjHdl *VpiImpl::get_root_handle(const char* name) { vpiHandle root; vpiHandle iterator; GpiObjHdl *rv; std::string root_name = name; // vpi_iterate with a ref of NULL returns the top level module iterator = vpi_iterate(vpiModule, NULL); check_vpi_error(); for (root = vpi_scan(iterator); root != NULL; root = vpi_scan(iterator)) { if (name == NULL || !strcmp(name, vpi_get_str(vpiFullName, root))) break; } if (!root) { check_vpi_error(); goto error; } //Need to free the iterator if it didn't return NULL if (iterator && !vpi_free_object(iterator)) { LOG_WARN("VPI: Attempting to free root iterator failed!"); check_vpi_error(); } rv = new GpiObjHdl(this, root); rv->initialise(root_name); return rv; error: LOG_CRITICAL("VPI: Couldn't find root handle %s", name); iterator = vpi_iterate(vpiModule, NULL); for (root = vpi_scan(iterator); root != NULL; root = vpi_scan(iterator)) { LOG_CRITICAL("VPI: Toplevel instances: %s != %s...", name, vpi_get_str(vpiFullName, root)); if (name == NULL || !strcmp(name, vpi_get_str(vpiFullName, root))) break; } return NULL; }
/// EmuWindow_GLFW constructor EmuWindow_GLFW::EmuWindow_GLFW() { keyboard_id = KeyMap::NewDeviceId(); ReloadSetKeymaps(); glfwSetErrorCallback([](int error, const char *desc){ LOG_ERROR(Frontend, "GLFW 0x%08x: %s", error, desc); }); // Initialize the window if(glfwInit() != GL_TRUE) { LOG_CRITICAL(Frontend, "Failed to initialize GLFW! Exiting..."); exit(1); } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); // GLFW on OSX requires these window hints to be set to create a 3.2+ GL context. glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); m_render_window = glfwCreateWindow(VideoCore::kScreenTopWidth, (VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight), window_title.c_str(), nullptr, nullptr); if (m_render_window == nullptr) { LOG_CRITICAL(Frontend, "Failed to create GLFW window! Exiting..."); exit(1); } glfwSetWindowUserPointer(m_render_window, this); // Notify base interface about window state int width, height; glfwGetFramebufferSize(m_render_window, &width, &height); OnFramebufferResizeEvent(m_render_window, width, height); glfwGetWindowSize(m_render_window, &width, &height); OnClientAreaResizeEvent(m_render_window, width, height); // Setup callbacks glfwSetKeyCallback(m_render_window, OnKeyEvent); glfwSetMouseButtonCallback(m_render_window, OnMouseButtonEvent); glfwSetCursorPosCallback(m_render_window, OnCursorPosEvent); glfwSetFramebufferSizeCallback(m_render_window, OnFramebufferResizeEvent); glfwSetWindowSizeCallback(m_render_window, OnClientAreaResizeEvent); DoneCurrent(); }
int OraDBRequest::selectBind() { const char sql_stmt[] = "select id, msg, a_no, b_no, step_no, last_step_no" ", tran_type, cluster_node, customer_type, request_origin, ref_id, imsi" ", activation_date, deactivation_date, duration, gsm_num, result_code, silent" ", nsn_flag, brand from request_log" " where tran_dt > trunc(sysdate-3) and brand = :brand and cluster_node = :cluster_node and step_no = :step_no and status = :status" " and rownum < :limit order by id"; _sth_select = SQLO_STH_INIT; if ((_sth_select = sqlo_prepare(_dbh, sql_stmt)) < 0) { LOG_CRITICAL("%s: Failed to prepare statement handle for SELECT_REQUEST.", __func__); return -1; } if (SQLO_SUCCESS != ( sqlo_bind_by_name(_sth_select, ":brand", SQLOT_STR, &_var_brand, sizeof(_var_brand), 0, 0) || sqlo_bind_by_name(_sth_select, ":cluster_node", SQLOT_INT, &_var_cluster_node, sizeof(_var_cluster_node), 0, 0) || sqlo_bind_by_name(_sth_select, ":step_no", SQLOT_INT, &_var_step_no, sizeof(_var_step_no), 0, 0) || sqlo_bind_by_name(_sth_select, ":status", SQLOT_INT, &_var_status, sizeof(_var_status), 0, 0) || sqlo_bind_by_name(_sth_select, ":limit", SQLOT_INT, &_var_limit, sizeof(_var_limit), 0, 0) || sqlo_define_by_pos(_sth_select, 1, SQLOT_INT, &_request.id, sizeof(_request.id), 0, 0, 0) || sqlo_define_by_pos(_sth_select, 2, SQLOT_STR, &_request.msg, sizeof(_request.msg), &_ind_msg, 0, 0) || sqlo_define_by_pos(_sth_select, 3, SQLOT_STR, &_request.a_no, sizeof(_request.a_no), &_ind_a_no, 0, 0) || sqlo_define_by_pos(_sth_select, 4, SQLOT_STR, &_request.b_no, sizeof(_request.b_no), &_ind_b_no, 0, 0) || sqlo_define_by_pos(_sth_select, 5, SQLOT_INT, &_request.step_no, sizeof(_request.step_no), 0, 0, 0) || sqlo_define_by_pos(_sth_select, 6, SQLOT_INT, &_request.last_step_no, sizeof(_request.last_step_no), 0, 0, 0) || sqlo_define_by_pos(_sth_select, 7, SQLOT_INT, &_request.tran_type, sizeof(_request.tran_type), 0, 0, 0) || sqlo_define_by_pos(_sth_select, 8, SQLOT_INT, &_request.cluster_node, sizeof(_request.cluster_node), 0, 0, 0) || sqlo_define_by_pos(_sth_select, 9, SQLOT_STR, &_request.customer_type, sizeof(_request.customer_type), &_ind_customer_type, 0, 0) || sqlo_define_by_pos(_sth_select, 10, SQLOT_STR, &_request.request_origin, sizeof(_request.request_origin), &_ind_request_origin, 0, 0) || sqlo_define_by_pos(_sth_select, 11, SQLOT_INT, &_request.ref_id, sizeof(_request.ref_id), 0, 0, 0) || sqlo_define_by_pos(_sth_select, 12, SQLOT_STR, &_request.imsi, sizeof(_request.imsi), &_ind_imsi, 0, 0) || sqlo_define_by_pos(_sth_select, 13, SQLOT_STR, &_request.activation_date, sizeof(_request.activation_date), &_ind_activation_date, 0, 0) || sqlo_define_by_pos(_sth_select, 14, SQLOT_STR, &_request.deactivation_date, sizeof(_request.deactivation_date), &_ind_deactivation_date, 0, 0) || sqlo_define_by_pos(_sth_select, 15, SQLOT_INT, &_request.duration, sizeof(_request.duration), &_ind_duration, 0, 0) || sqlo_define_by_pos(_sth_select, 16, SQLOT_STR, &_request.gsm_num, sizeof(_request.gsm_num), &_ind_gsm_num, 0, 0) || sqlo_define_by_pos(_sth_select, 17, SQLOT_INT, &_request.result_code, sizeof(_request.result_code), &_ind_result_code, 0, 0) || sqlo_define_by_pos(_sth_select, 18, SQLOT_INT, &_request.silent, sizeof(_request.silent), &_ind_silent, 0, 0) || sqlo_define_by_pos(_sth_select, 19, SQLOT_INT, &_request.nsn_flag, sizeof(_request.nsn_flag), &_ind_nsn_flag, 0, 0) || sqlo_define_by_pos(_sth_select, 20, SQLOT_STR, &_request.brand, sizeof(_request.brand), &_ind_brand, 0, 0) )) { LOG_CRITICAL("%s: Failed to bind variables for SELECT_REQUEST statement handle.", __func__); return -2; } return 0; }
// Value related functions int VhpiSignalObjHdl::set_signal_value(int value) { switch (m_value.format) { case vhpiEnumVal: case vhpiLogicVal: { m_value.value.enumv = value ? vhpi1 : vhpi0; break; } case vhpiEnumVecVal: case vhpiLogicVecVal: { unsigned int i; for (i=0; i<m_size; i++) m_value.value.enumvs[m_size-i-1] = value&(1<<i) ? vhpi1 : vhpi0; break; } default: { LOG_CRITICAL("VHPI type of object has changed at runtime: ABORTING"); } } vhpi_put_value(GpiObjHdl::get_handle<vhpiHandleT>(), &m_value, vhpiForcePropagate); check_vhpi_error(); return 0; }
ResultStatus LoadFile(const std::string& filename) { FileUtil::IOFile file(filename, "rb"); if (!file.IsOpen()) { LOG_ERROR(Loader, "Failed to load file %s", filename.c_str()); return ResultStatus::Error; } std::string filename_filename, filename_extension; Common::SplitPath(filename, nullptr, &filename_filename, &filename_extension); FileType type = IdentifyFile(file); FileType filename_type = GuessFromExtension(filename_extension); if (type != filename_type) { LOG_WARNING(Loader, "File %s has a different type than its extension.", filename.c_str()); if (FileType::Unknown == type) type = filename_type; } LOG_INFO(Loader, "Loading file %s as %s...", filename.c_str(), GetFileTypeString(type)); std::unique_ptr<AppLoader> app_loader = GetLoader(std::move(file), type, filename_filename, filename); switch (type) { // 3DSX file format... // or NCCH/NCSD container formats... case FileType::THREEDSX: case FileType::CXI: case FileType::CCI: { // Load application and RomFS ResultStatus result = app_loader->Load(); if (ResultStatus::Success == result) { Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(*app_loader), Service::FS::ArchiveIdCode::RomFS); return ResultStatus::Success; } return result; } // Standard ELF file format... case FileType::ELF: return app_loader->Load(); // CIA file format... case FileType::CIA: return ResultStatus::ErrorNotImplemented; // Error occurred durring IdentifyFile... case FileType::Error: // IdentifyFile could know identify file type... case FileType::Unknown: { LOG_CRITICAL(Loader, "File %s is of unknown type.", filename.c_str()); return ResultStatus::ErrorInvalidFormat; } } return ResultStatus::Error; }
ResultVal<std::unique_ptr<DirectoryBackend>> SaveDataArchive::OpenDirectory( const Path& path) const { const PathParser path_parser(path); if (!path_parser.IsValid()) { LOG_ERROR(Service_FS, "Invalid path {}", path.DebugStr()); return ERROR_INVALID_PATH; } const auto full_path = path_parser.BuildHostPath(mount_point); switch (path_parser.GetHostStatus(mount_point)) { case PathParser::InvalidMountPoint: LOG_CRITICAL(Service_FS, "(unreachable) Invalid mount point {}", mount_point); return ERROR_FILE_NOT_FOUND; case PathParser::PathNotFound: case PathParser::NotFound: LOG_ERROR(Service_FS, "Path not found {}", full_path); return ERROR_PATH_NOT_FOUND; case PathParser::FileInPath: case PathParser::FileFound: LOG_ERROR(Service_FS, "Unexpected file in path {}", full_path); return ERROR_UNEXPECTED_FILE_OR_DIRECTORY; case PathParser::DirectoryFound: break; // Expected 'success' case } auto directory = std::make_unique<DiskDirectory>(full_path); return MakeResult<std::unique_ptr<DirectoryBackend>>(std::move(directory)); }
// Main re-entry point for callbacks from simulator void handle_fli_callback(void *data) { fflush(stderr); FliProcessCbHdl *cb_hdl = (FliProcessCbHdl*)data; if (!cb_hdl) { LOG_CRITICAL("FLI: Callback data corrupted: ABORTING"); } gpi_cb_state_e old_state = cb_hdl->get_call_state(); if (old_state == GPI_PRIMED) { cb_hdl->set_call_state(GPI_CALL); cb_hdl->run_callback(); gpi_cb_state_e new_state = cb_hdl->get_call_state(); /* We have re-primed in the handler */ if (new_state != GPI_PRIMED) if (cb_hdl->cleanup_callback()) delete cb_hdl; } else { /* Issue #188 seems to appear via FLI as well */ cb_hdl->cleanup_callback(); } };