示例#1
0
文件: y2r_u.cpp 项目: ajaning/citra
/**
 * Y2R_U::SetConversionParams service function
 */
static void SetConversionParams(Service::Interface* self) {
    u32* cmd_buff = Kernel::GetCommandBuffer();

    auto params = reinterpret_cast<const ConversionParameters*>(&cmd_buff[1]);
    LOG_DEBUG(Service_Y2R,
        "called input_format=%hhu output_format=%hhu rotation=%hhu block_alignment=%hhu "
        "input_line_width=%hu input_lines=%hu standard_coefficient=%hhu "
        "reserved=%hhu alpha=%hX",
        params->input_format, params->output_format, params->rotation, params->block_alignment,
        params->input_line_width, params->input_lines, params->standard_coefficient,
        params->reserved, params->alpha);

    ResultCode result = RESULT_SUCCESS;

    conversion.input_format = params->input_format;
    conversion.output_format = params->output_format;
    conversion.rotation = params->rotation;
    conversion.block_alignment = params->block_alignment;
    result = conversion.SetInputLineWidth(params->input_line_width);
    if (result.IsError()) goto cleanup;
    result = conversion.SetInputLines(params->input_lines);
    if (result.IsError()) goto cleanup;
    result = conversion.SetStandardCoefficient(params->standard_coefficient);
    if (result.IsError()) goto cleanup;
    conversion.alpha = params->alpha;

cleanup:
    cmd_buff[0] = 0x00290040; // TODO verify
    cmd_buff[1] = result.raw;
}
示例#2
0
ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low, VAddr icon_buffer,
                             u32 icon_size, const FileSys::ArchiveFormatInfo& format_info) {
    // Construct the binary path to the archive first
    FileSys::Path path =
        FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);

    auto archive = id_code_map.find(media_type == MediaType::NAND ? ArchiveIdCode::SharedExtSaveData
                                                                  : ArchiveIdCode::ExtSaveData);

    if (archive == id_code_map.end()) {
        return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
    }

    auto ext_savedata = static_cast<FileSys::ArchiveFactory_ExtSaveData*>(archive->second.get());

    ResultCode result = ext_savedata->Format(path, format_info);
    if (result.IsError())
        return result;

    if (!Memory::IsValidVirtualAddress(icon_buffer))
        return ResultCode(-1); // TODO(Subv): Find the right error code

    std::vector<u8> smdh_icon(icon_size);
    Memory::ReadBlock(icon_buffer, smdh_icon.data(), smdh_icon.size());
    ext_savedata->WriteIcon(path, smdh_icon.data(), smdh_icon.size());
    return RESULT_SUCCESS;
}
ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter) {
    ResultCode result = StartImpl(parameter);
    if (result.IsError())
        return result;
    // Schedule the update event
    CoreTiming::ScheduleEvent(usToCycles(applet_update_interval_us), applet_update_event, static_cast<u64>(id));
    return result;
}
示例#4
0
文件: y2r_u.cpp 项目: emmauss/citra
/**
 * Y2R_U::SetPackageParameter service function
 */
static void SetPackageParameter(Interface* self) {
    u32* cmd_buff = Kernel::GetCommandBuffer();

    auto params = reinterpret_cast<const ConversionParameters*>(&cmd_buff[1]);

    conversion.input_format = params->input_format;
    conversion.output_format = params->output_format;
    conversion.rotation = params->rotation;
    conversion.block_alignment = params->block_alignment;

    ResultCode result = conversion.SetInputLineWidth(params->input_line_width);

    if (result.IsError())
        goto cleanup;

    result = conversion.SetInputLines(params->input_lines);

    if (result.IsError())
        goto cleanup;

    result = conversion.SetStandardCoefficient(params->standard_coefficient);

    if (result.IsError())
        goto cleanup;

    conversion.padding = params->padding;
    conversion.alpha = params->alpha;

cleanup:
    cmd_buff[0] = IPC::MakeHeader(0x29, 1, 0);
    cmd_buff[1] = result.raw;

    LOG_DEBUG(
        Service_Y2R,
        "called input_format=%hhu output_format=%hhu rotation=%hhu block_alignment=%hhu "
        "input_line_width=%hu input_lines=%hu standard_coefficient=%hhu reserved=%hhu alpha=%hX",
        params->input_format, params->output_format, params->rotation, params->block_alignment,
        params->input_line_width, params->input_lines, params->standard_coefficient,
        params->padding, params->alpha);
}
示例#5
0
ResultCode ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32 low,
                                             const std::vector<u8>& smdh_icon,
                                             const FileSys::ArchiveFormatInfo& format_info,
                                             u64 program_id) {
    // Construct the binary path to the archive first
    FileSys::Path path =
        FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);

    auto archive = id_code_map.find(media_type == MediaType::NAND ? ArchiveIdCode::SharedExtSaveData
                                                                  : ArchiveIdCode::ExtSaveData);

    if (archive == id_code_map.end()) {
        return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
    }

    auto ext_savedata = static_cast<FileSys::ArchiveFactory_ExtSaveData*>(archive->second.get());

    ResultCode result = ext_savedata->Format(path, format_info, program_id);
    if (result.IsError())
        return result;

    ext_savedata->WriteIcon(path, smdh_icon.data(), smdh_icon.size());
    return RESULT_SUCCESS;
}
示例#6
0
void ConfigureSystem::setConfiguration() {
    enabled = !System::IsPoweredOn();

    if (!enabled) {
        ReadSystemSettings();
        ui->group_system_settings->setEnabled(false);
    } else {
        // This tab is enabled only when game is not running (i.e. all service are not initialized).
        // Temporarily register archive types and load the config savegame file to memory.
        Service::FS::RegisterArchiveTypes();
        ResultCode result = Service::CFG::LoadConfigNANDSaveFile();
        Service::FS::UnregisterArchiveTypes();

        if (result.IsError()) {
            ui->label_disable_info->setText(tr("Failed to load system settings data."));
            ui->group_system_settings->setEnabled(false);
            enabled = false;
            return;
        }

        ReadSystemSettings();
        ui->label_disable_info->hide();
    }
}
示例#7
0
文件: svc.cpp 项目: Cod3Mast3r/citra
/// Map application or GSP heap memory
static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) {
    using namespace Kernel;

    LOG_DEBUG(Kernel_SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=0x%X, permissions=0x%08X",
        operation, addr0, addr1, size, permissions);

    if ((addr0 & Memory::PAGE_MASK) != 0 || (addr1 & Memory::PAGE_MASK) != 0) {
        return ERR_MISALIGNED_ADDRESS;
    }
    if ((size & Memory::PAGE_MASK) != 0) {
        return ERR_MISALIGNED_SIZE;
    }

    u32 region = operation & MEMOP_REGION_MASK;
    operation &= ~MEMOP_REGION_MASK;

    if (region != 0) {
        LOG_WARNING(Kernel_SVC, "ControlMemory with specified region not supported, region=%X", region);
    }

    if ((permissions & (u32)MemoryPermission::ReadWrite) != permissions) {
        return ERR_INVALID_COMBINATION;
    }
    VMAPermission vma_permissions = (VMAPermission)permissions;

    auto& process = *g_current_process;

    switch (operation & MEMOP_OPERATION_MASK) {
    case MEMOP_FREE:
    {
        if (addr0 >= Memory::HEAP_VADDR && addr0 < Memory::HEAP_VADDR_END) {
            ResultCode result = process.HeapFree(addr0, size);
            if (result.IsError()) return result;
        } else if (addr0 >= process.GetLinearHeapBase() && addr0 < process.GetLinearHeapLimit()) {
            ResultCode result = process.LinearFree(addr0, size);
            if (result.IsError()) return result;
        } else {
            return ERR_INVALID_ADDRESS;
        }
        *out_addr = addr0;
        break;
    }

    case MEMOP_COMMIT:
    {
        if (operation & MEMOP_LINEAR) {
            CASCADE_RESULT(*out_addr, process.LinearAllocate(addr0, size, vma_permissions));
        } else {
            CASCADE_RESULT(*out_addr, process.HeapAllocate(addr0, size, vma_permissions));
        }
        break;
    }

    case MEMOP_MAP: // TODO: This is just a hack to avoid regressions until memory aliasing is implemented
    {
        CASCADE_RESULT(*out_addr, process.HeapAllocate(addr0, size, vma_permissions));
        break;
    }

    case MEMOP_UNMAP: // TODO: This is just a hack to avoid regressions until memory aliasing is implemented
    {
        ResultCode result = process.HeapFree(addr0, size);
        if (result.IsError()) return result;
        break;
    }

    case MEMOP_PROTECT:
    {
        ResultCode result = process.vm_manager.ReprotectRange(addr0, size, vma_permissions);
        if (result.IsError()) return result;
        break;
    }

    default:
        LOG_ERROR(Kernel_SVC, "unknown operation=0x%08X", operation);
        return ERR_INVALID_COMBINATION;
    }

    process.vm_manager.LogLayout(Log::Level::Trace);

    return RESULT_SUCCESS;
}