Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boot Record and FSINFO Signature Corrections #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions common/src/fx_media_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,17 +443,24 @@ UINT sectors_per_fat, f, s;
_fx_utility_memory_set(&byte_ptr[j + i], ' ', (11 - i));
#endif /* FX_DISABLE_FORCE_MEMORY_OPERATION */


/* Set bootrecord signature. */
#ifdef FX_FORCE_512_BYTE_BOOT_SECTOR

/* Set bootrecord signature. */
byte_ptr[510] = 0x55;
byte_ptr[511] = 0xAA;
/* Put the boot signature in the standard position. */
byte_ptr[FX_SIG_OFFSET] = FX_SIG_BYTE_1;
byte_ptr[FX_SIG_OFFSET + 1] = FX_SIG_BYTE_2;
#else

/* Set bootrecord signature. */
byte_ptr[bytes_per_sector - 2] = 0x55;
byte_ptr[bytes_per_sector - 1] = 0xAA;
if (bytes_per_sector < 512)
{
/* Put the boot signature at the end of the sector. */
byte_ptr[bytes_per_sector - 2] = FX_SIG_BYTE_1;
byte_ptr[bytes_per_sector - 1] = FX_SIG_BYTE_2;
}
else
{
/* Put the boot signature in the standard position. */
byte_ptr[FX_SIG_OFFSET] = FX_SIG_BYTE_1;
byte_ptr[FX_SIG_OFFSET + 1] = FX_SIG_BYTE_2;
}
#endif

/* Select the boot record write command. */
Expand Down Expand Up @@ -510,8 +517,8 @@ UINT sectors_per_fat, f, s;
byte_ptr[487] = 0x61;

/* Build the final signature word, this too is used to help verify that this is a FSINFO sector. */
byte_ptr[508] = 0x55;
byte_ptr[509] = 0xAA;
byte_ptr[FX_SIG_OFFSET] = FX_SIG_BYTE_1;
byte_ptr[FX_SIG_OFFSET + 1] = FX_SIG_BYTE_2;

/* Setup the total available clusters on the media. We need to subtract 1 for the FAT32 root directory. */
_fx_utility_32_unsigned_write(&byte_ptr[488], (total_clusters - 1));
Expand Down