allow emmc writes (to write warmboot to emusd), allow unaligned emmc writes

This commit is contained in:
Christoph Baumann
2025-05-20 23:52:02 +02:00
parent b301bba5e7
commit 77a01f0a9b
7 changed files with 12 additions and 14 deletions

View File

@@ -32,8 +32,7 @@ bool diskio_read_system(void *dst, size_t size, size_t sector_index, size_t sect
}
bool diskio_write_system(size_t sector_index, size_t sector_count, const void *src, size_t size) {
/* Don't allow writes to eMMC GPP partition */
return false;
return R_SUCCEEDED(::ams::nxboot::WriteMmc(::ams::sdmmc::MmcPartition::MmcPartition_UserData, sector_index, sector_count, src, size));
}
bool diskio_read_boot1(void *dst, size_t size, size_t sector_index, size_t sector_count) {

View File

@@ -241,7 +241,7 @@ namespace ams::fs {
private:
void EnsureFile(int id);
public:
MultiFileStorage(const char *base_path);
MultiFileStorage(const char *base_path, OpenMode mode);
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result Flush() override;
virtual Result GetSize(s64 *out) override;

View File

@@ -34,7 +34,7 @@ namespace ams::fs {
}
}
MultiFileStorage::MultiFileStorage(const char *base_path) {
MultiFileStorage::MultiFileStorage(const char *base_path, fs::OpenMode mode) {
util::Strlcpy(m_base_path, base_path, sizeof(m_base_path) - 2);
m_file_path_ofs = strlen(m_base_path);
@@ -44,7 +44,7 @@ namespace ams::fs {
std::memcpy(m_base_path + m_file_path_ofs, "00", 3);
Result r;
if (R_FAILED(r = fs::OpenFile(std::addressof(m_handles[0]), m_base_path, fs::OpenMode_Read))) {
if (R_FAILED(r = fs::OpenFile(std::addressof(m_handles[0]), m_base_path, mode))) {
nxboot::ShowFatalError("Failed to open part %02d (%s): 0x%08" PRIx32 "!\n", 0, m_base_path, r.GetValue());
}

View File

@@ -191,7 +191,7 @@ namespace ams::nxboot {
/* Create partition */
/* TODO: construct boot0 storage from path instead */
g_boot0_storage = AllocateObject<fs::FileHandleStorage>(boot0_file);
g_user_storage = AllocateObject<EmummcFileStorage>(path);
g_user_storage = AllocateObject<EmummcFileStorage>(path, fs::OpenMode_Read);
} else {
ShowFatalError("Unknown emummc type %d\n", static_cast<int>(emummc_cfg.base_cfg.type));
}

View File

@@ -117,7 +117,7 @@ namespace ams::nxboot {
memcpy(path + strlen(path), "/SD/", 5);
path[sizeof(path) - 1] = '\x00';
g_emusd_storage = AllocateObject<fs::MultiFileStorage>(path);
g_emusd_storage = AllocateObject<fs::MultiFileStorage>(path, fs::OpenMode_ReadWrite);
} else {
ShowFatalError("Invalid emuSD config!\n");
}

View File

@@ -622,7 +622,7 @@ namespace ams::nxboot {
/* Determine whether we're using emummc. */
const bool emummc_driver_enabled = ConfigureEmummc();
const bool emummc_enabled = GetEmummcConfig().emmc_cfg.IsActive();
const bool emummc_enabled = GetEmummcConfig().emmc_cfg.IsActive();
/* Initialize emummc. */
/* NOTE: SYSTEM:/ accessible past this point. */