Set DDTv2 as 64-bit and remove concept of multiple sizes of DDTs.

This commit is contained in:
2025-10-10 02:39:57 +01:00
parent 421d5ada72
commit 17e1c0f2bd
15 changed files with 107 additions and 150 deletions

View File

@@ -689,7 +689,7 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
if(ctx->sector_prefix_ddt2 == NULL)
{
ctx->sector_prefix_ddt2 =
calloc(1, sizeof(uint32_t) * (ctx->user_data_ddt_header.negative + ctx->image_info.Sectors +
calloc(1, sizeof(uint64_t) * (ctx->user_data_ddt_header.negative + ctx->image_info.Sectors +
ctx->user_data_ddt_header.overflow));
if(ctx->sector_prefix_ddt2 == NULL)
@@ -705,7 +705,7 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
if(ctx->sector_suffix_ddt2 == NULL)
{
ctx->sector_suffix_ddt2 =
calloc(1, sizeof(uint32_t) * (ctx->user_data_ddt_header.negative + ctx->image_info.Sectors +
calloc(1, sizeof(uint64_t) * (ctx->user_data_ddt_header.negative + ctx->image_info.Sectors +
ctx->user_data_ddt_header.overflow));
if(ctx->sector_suffix_ddt2 == NULL)
@@ -783,13 +783,13 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
}
if(prefix_correct)
ctx->sector_prefix_ddt2[corrected_sector_address] = SectorStatusMode1Correct << 28;
ctx->sector_prefix_ddt2[corrected_sector_address] = (uint64_t)SectorStatusMode1Correct << 60;
else
{
// Copy CD prefix from data buffer to prefix buffer
memcpy(ctx->sector_prefix + ctx->sector_prefix_offset, data, 16);
ctx->sector_prefix_ddt2[corrected_sector_address] = (uint32_t)(ctx->sector_prefix_offset / 16);
ctx->sector_prefix_ddt2[corrected_sector_address] |= SectorStatusErrored << 28;
ctx->sector_prefix_ddt2[corrected_sector_address] = (uint64_t)(ctx->sector_prefix_offset / 16);
ctx->sector_prefix_ddt2[corrected_sector_address] |= (uint64_t)SectorStatusErrored << 60;
ctx->sector_prefix_offset += 16;
// Grow prefix buffer if needed
@@ -811,13 +811,13 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
const bool suffix_correct = aaruf_ecc_cd_is_suffix_correct(context, data);
if(suffix_correct)
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode1Correct << 28;
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode1Correct << 60;
else
{
// Copy CD suffix from data buffer to suffix buffer
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2064, 288);
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint32_t)(ctx->sector_suffix_offset / 288);
ctx->sector_suffix_ddt2[corrected_sector_address] |= SectorStatusErrored << 28;
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint64_t)(ctx->sector_suffix_offset / 288);
ctx->sector_suffix_ddt2[corrected_sector_address] |= SectorStatusErrored << 60;
ctx->sector_suffix_offset += 288;
// Grow suffix buffer if needed
@@ -845,7 +845,7 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
if(ctx->sector_prefix_ddt2 == NULL)
{
ctx->sector_prefix_ddt2 =
calloc(1, sizeof(uint32_t) * (ctx->user_data_ddt_header.negative + ctx->image_info.Sectors +
calloc(1, sizeof(uint64_t) * (ctx->user_data_ddt_header.negative + ctx->image_info.Sectors +
ctx->user_data_ddt_header.overflow));
if(ctx->sector_prefix_ddt2 == NULL)
@@ -861,7 +861,7 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
if(ctx->sector_suffix_ddt2 == NULL)
{
ctx->sector_suffix_ddt2 =
calloc(1, sizeof(uint32_t) * (ctx->user_data_ddt_header.negative + ctx->image_info.Sectors +
calloc(1, sizeof(uint64_t) * (ctx->user_data_ddt_header.negative + ctx->image_info.Sectors +
ctx->user_data_ddt_header.overflow));
if(ctx->sector_suffix_ddt2 == NULL)
@@ -942,13 +942,13 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
if(prefix_correct)
ctx->sector_prefix_ddt2[corrected_sector_address] =
(form2 ? SectorStatusMode2Form2Ok : SectorStatusMode2Form1Ok) << 28;
(form2 ? SectorStatusMode2Form2Ok : SectorStatusMode2Form1Ok) << 60;
else
{
// Copy CD prefix from data buffer to prefix buffer
memcpy(ctx->sector_prefix + ctx->sector_prefix_offset, data, 16);
ctx->sector_prefix_ddt2[corrected_sector_address] = (uint32_t)(ctx->sector_prefix_offset / 16);
ctx->sector_prefix_ddt2[corrected_sector_address] |= SectorStatusErrored << 28;
ctx->sector_prefix_ddt2[corrected_sector_address] |= (uint64_t)SectorStatusErrored << 60;
ctx->sector_prefix_offset += 16;
// Grow prefix buffer if needed
@@ -990,16 +990,16 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
const bool correct_edc = computed_edc == edc;
if(correct_edc)
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode2Form2Ok << 28;
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode2Form2Ok << 60;
else if(edc == 0)
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode2Form2NoCrc << 28;
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode2Form2NoCrc << 60;
else
{
// Copy CD suffix from data buffer to suffix buffer
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2348, 4);
ctx->sector_suffix_ddt2[corrected_sector_address] =
(uint32_t)(ctx->sector_suffix_offset / 288);
ctx->sector_suffix_ddt2[corrected_sector_address] |= SectorStatusErrored << 28;
(uint64_t)(ctx->sector_suffix_offset / 288);
ctx->sector_suffix_ddt2[corrected_sector_address] |= SectorStatusErrored << 60;
ctx->sector_suffix_offset += 288;
// Grow suffix buffer if needed
@@ -1034,13 +1034,13 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
const bool correct_edc = computed_edc == edc;
if(correct_ecc && correct_edc)
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode2Form1Ok << 28;
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode2Form1Ok << 60;
else
{
// Copy CD suffix from data buffer to suffix buffer
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2072, 280);
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint32_t)(ctx->sector_suffix_offset / 288);
ctx->sector_suffix_ddt2[corrected_sector_address] |= SectorStatusErrored << 28;
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint64_t)(ctx->sector_suffix_offset / 288);
ctx->sector_suffix_ddt2[corrected_sector_address] |= SectorStatusErrored << 60;
ctx->sector_suffix_offset += 288;
// Grow suffix buffer if needed