As always remove more uneeded stuff

This commit is contained in:
Kostas Missos 2018-07-09 22:13:56 +03:00
parent 828b616468
commit 33457ad8f8
3 changed files with 33 additions and 65 deletions

View file

@ -3290,11 +3290,11 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
} while (LD2PT(vol) == 0 && fmt >= 2 && ++i < 4); } while (LD2PT(vol) == 0 && fmt >= 2 && ++i < 4);
} }
if (fmt == 4) { if (fmt == 4) {
EFSPRINTF("Disk I/O error - Could not load boot record!"); EFSPRINTF("Could not load boot record!");
return FR_DISK_ERR; /* An error occured in the disk I/O layer */ return FR_DISK_ERR; /* An error occured in the disk I/O layer */
} }
if (fmt >= 2) { if (fmt >= 2) {
EFSPRINTF("No FAT/FAT32/exFAT filesystem found!"); EFSPRINTF("No FAT/FAT32/exFAT found!");
return FR_NO_FILESYSTEM; /* No FAT volume is found */ return FR_NO_FILESYSTEM; /* No FAT volume is found */
} }
@ -3312,7 +3312,7 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
return FR_NO_FILESYSTEM; /* Check exFAT version (must be version 1.0) */ return FR_NO_FILESYSTEM; /* Check exFAT version (must be version 1.0) */
if (1 << fs->win[BPB_BytsPerSecEx] != SS(fs)) { /* (BPB_BytsPerSecEx must be equal to the physical sector size) */ if (1 << fs->win[BPB_BytsPerSecEx] != SS(fs)) { /* (BPB_BytsPerSecEx must be equal to the physical sector size) */
EFSPRINTF("exFAT - Bytes per sector does not match physical sector size!"); EFSPRINTF("exFAT - Sector size does not match physical sector size!");
return FR_NO_FILESYSTEM; return FR_NO_FILESYSTEM;
} }
@ -3330,15 +3330,13 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
fs->csize = 1 << fs->win[BPB_SecPerClusEx]; /* Cluster size */ fs->csize = 1 << fs->win[BPB_SecPerClusEx]; /* Cluster size */
if (fs->csize == 0) { if (fs->csize == 0) {
EFSPRINTF("exFAT - Cluster size is not between 1KB - 32KB!"); EFSPRINTF("exFAT - Sectors per clusters!");
return FR_NO_FILESYSTEM; /* (Must be 1..32768) */ return FR_NO_FILESYSTEM; /* (Must be 1..32768) */
} }
nclst = ld_dword(fs->win + BPB_NumClusEx); /* Number of clusters */ nclst = ld_dword(fs->win + BPB_NumClusEx); /* Number of clusters */
if (nclst > MAX_EXFAT) { if (nclst > MAX_EXFAT)
EFSPRINTF("exFAT - Total clusters exceed allowed!");
return FR_NO_FILESYSTEM; /* (Too many clusters) */ return FR_NO_FILESYSTEM; /* (Too many clusters) */
}
fs->n_fatent = nclst + 2; fs->n_fatent = nclst + 2;
/* Boundaries and Limits */ /* Boundaries and Limits */
@ -3351,7 +3349,7 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
/* Check if bitmap location is in assumption (at the first cluster) */ /* Check if bitmap location is in assumption (at the first cluster) */
if (move_window(fs, clst2sect(fs, fs->dirbase)) != FR_OK) { if (move_window(fs, clst2sect(fs, fs->dirbase)) != FR_OK) {
EFSPRINTF("exFAT - Bitmap location not at first cluster!"); EFSPRINTF("exFAT - Bitmap location not at 1st cluster!");
return FR_DISK_ERR; return FR_DISK_ERR;
} }
for (i = 0; i < SS(fs); i += SZDIRE) { for (i = 0; i < SS(fs); i += SZDIRE) {
@ -3369,7 +3367,7 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
#endif /* FF_FS_EXFAT */ #endif /* FF_FS_EXFAT */
{ {
if (ld_word(fs->win + BPB_BytsPerSec) != SS(fs)) { if (ld_word(fs->win + BPB_BytsPerSec) != SS(fs)) {
EFSPRINTF("FAT - Bytes per sector does not match physical sector size!"); EFSPRINTF("FAT - Sector size does not match physical sector size!");
return FR_NO_FILESYSTEM; /* (BPB_BytsPerSec must be equal to the physical sector size) */ return FR_NO_FILESYSTEM; /* (BPB_BytsPerSec must be equal to the physical sector size) */
} }
@ -3378,10 +3376,8 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
fs->fsize = fasize; fs->fsize = fasize;
fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FATs */ fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FATs */
if (fs->n_fats != 1 && fs->n_fats != 2) { if (fs->n_fats != 1 && fs->n_fats != 2)
EFSPRINTF("FAT - No or more than 2 file allocation tables found!");
return FR_NO_FILESYSTEM; /* (Must be 1 or 2) */ return FR_NO_FILESYSTEM; /* (Must be 1 or 2) */
}
fasize *= fs->n_fats; /* Number of sectors for FAT area */ fasize *= fs->n_fats; /* Number of sectors for FAT area */
fs->csize = fs->win[BPB_SecPerClus]; /* Cluster size */ fs->csize = fs->win[BPB_SecPerClus]; /* Cluster size */
@ -3389,10 +3385,8 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
return FR_NO_FILESYSTEM; /* (Must be power of 2) */ return FR_NO_FILESYSTEM; /* (Must be power of 2) */
fs->n_rootdir = ld_word(fs->win + BPB_RootEntCnt); /* Number of root directory entries */ fs->n_rootdir = ld_word(fs->win + BPB_RootEntCnt); /* Number of root directory entries */
if (fs->n_rootdir % (SS(fs) / SZDIRE)) { if (fs->n_rootdir % (SS(fs) / SZDIRE))
EFSPRINTF("FAT - Root directory entries are not sector aligned!");
return FR_NO_FILESYSTEM; /* (Must be sector aligned) */ return FR_NO_FILESYSTEM; /* (Must be sector aligned) */
}
tsect = ld_word(fs->win + BPB_TotSec16); /* Number of sectors on the volume */ tsect = ld_word(fs->win + BPB_TotSec16); /* Number of sectors on the volume */
if (tsect == 0) tsect = ld_dword(fs->win + BPB_TotSec32); if (tsect == 0) tsect = ld_dword(fs->win + BPB_TotSec32);
@ -3403,23 +3397,17 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
/* Determine the FAT sub type */ /* Determine the FAT sub type */
sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZDIRE); /* RSV + FAT + DIR */ sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZDIRE); /* RSV + FAT + DIR */
if (tsect < sysect) { if (tsect < sysect)
EFSPRINTF("FAT - Invalid volume size!");
return FR_NO_FILESYSTEM; /* (Invalid volume size) */ return FR_NO_FILESYSTEM; /* (Invalid volume size) */
}
nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ nclst = (tsect - sysect) / fs->csize; /* Number of clusters */
if (nclst == 0) { if (nclst == 0)
EFSPRINTF("FAT - Invalid volume size!");
return FR_NO_FILESYSTEM; /* (Invalid volume size) */ return FR_NO_FILESYSTEM; /* (Invalid volume size) */
}
fmt = 0; fmt = 0;
if (nclst <= MAX_FAT32) fmt = FS_FAT32; if (nclst <= MAX_FAT32) fmt = FS_FAT32;
if (nclst <= MAX_FAT16) fmt = FS_FAT16; if (nclst <= MAX_FAT16) fmt = FS_FAT16;
if (nclst <= MAX_FAT12) fmt = FS_FAT12; if (nclst <= MAX_FAT12) fmt = FS_FAT12;
if (fmt == 0) { if (fmt == 0)
EFSPRINTF("FAT - Not compatible FAT12/16/32 filesystem!");
return FR_NO_FILESYSTEM; return FR_NO_FILESYSTEM;
}
/* Boundaries and Limits */ /* Boundaries and Limits */
fs->n_fatent = nclst + 2; /* Number of FAT entries */ fs->n_fatent = nclst + 2; /* Number of FAT entries */
@ -3429,25 +3417,19 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
if (fmt == FS_FAT32) { if (fmt == FS_FAT32) {
if (ld_word(fs->win + BPB_FSVer32) != 0) if (ld_word(fs->win + BPB_FSVer32) != 0)
return FR_NO_FILESYSTEM; /* (Must be FAT32 revision 0.0) */ return FR_NO_FILESYSTEM; /* (Must be FAT32 revision 0.0) */
if (fs->n_rootdir != 0) { if (fs->n_rootdir != 0)
EFSPRINTF("FAT32 - Root entry sector is not 0!");
return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */
}
fs->dirbase = ld_dword(fs->win + BPB_RootClus32); /* Root directory start cluster */ fs->dirbase = ld_dword(fs->win + BPB_RootClus32); /* Root directory start cluster */
szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ szbfat = fs->n_fatent * 4; /* (Needed FAT size) */
} else { } else {
if (fs->n_rootdir == 0) { if (fs->n_rootdir == 0)
EFSPRINTF("FAT - Root entry sector is 0!");
return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */
}
fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */
szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */
fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1);
} }
if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) { if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs))
EFSPRINTF("FAT - FAT size is not the required size!");
return FR_NO_FILESYSTEM; /* (BPB_FATSz must not be less than the size needed) */ return FR_NO_FILESYSTEM; /* (BPB_FATSz must not be less than the size needed) */
}
#if !FF_FS_READONLY #if !FF_FS_READONLY
/* Get FSInfo if available */ /* Get FSInfo if available */
@ -3880,7 +3862,7 @@ FRESULT f_read (
} }
#endif #endif
if (disk_read(fs->pdrv, fp->buf, sect, 1) != RES_OK) { if (disk_read(fs->pdrv, fp->buf, sect, 1) != RES_OK) {
EFSPRINTF("Read - Low level disk I/O!\n(fill sector cache)"); EFSPRINTF("Read - Fill sector cache");
ABORT(fs, FR_DISK_ERR); /* Fill sector cache */ ABORT(fs, FR_DISK_ERR); /* Fill sector cache */
} }
} }
@ -3977,10 +3959,8 @@ FRESULT f_write (
if (fs->winsect == fp->sect && sync_window(fs) != FR_OK) ABORT(fs, FR_DISK_ERR); /* Write-back sector cache */ if (fs->winsect == fp->sect && sync_window(fs) != FR_OK) ABORT(fs, FR_DISK_ERR); /* Write-back sector cache */
#else #else
if (fp->flag & FA_DIRTY) { /* Write-back sector cache */ if (fp->flag & FA_DIRTY) { /* Write-back sector cache */
if (disk_write(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK) { if (disk_write(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK)
EFSPRINTF("Write-back sector cache!");
ABORT(fs, FR_DISK_ERR); ABORT(fs, FR_DISK_ERR);
}
fp->flag &= (BYTE)~FA_DIRTY; fp->flag &= (BYTE)~FA_DIRTY;
} }
#endif #endif
@ -4023,10 +4003,8 @@ FRESULT f_write (
#else #else
if (fp->sect != sect && /* Fill sector cache with file data */ if (fp->sect != sect && /* Fill sector cache with file data */
fp->fptr < fp->obj.objsize && fp->fptr < fp->obj.objsize &&
disk_read(fs->pdrv, fp->buf, sect, 1) != RES_OK) { disk_read(fs->pdrv, fp->buf, sect, 1) != RES_OK)
EFSPRINTF("Read - Low level disk I/O!\n(Could not fill sector cache with file data)");
ABORT(fs, FR_DISK_ERR); ABORT(fs, FR_DISK_ERR);
}
#endif #endif
fp->sect = sect; fp->sect = sect;
} }

View file

@ -605,13 +605,13 @@ int hos_launch(ini_sec_t *cfg)
// Lock SE before starting 'SecureMonitor'. // Lock SE before starting 'SecureMonitor'.
_se_lock(); _se_lock();
//< 4.0.0 Signals. 0: Nothing ready, 1: BCT ready, 2: DRAM and pkg2 ready, 3: Continue boot // < 4.0.0 Signals - 0: Nothing ready, 1: BCT ready, 2: DRAM and pkg2 ready, 3: Continue boot.
//>=4.0.0 Signals. 0: Nothing ready, 1: BCT ready, 2: DRAM ready, 4: pkg2 ready and continue boot // >= 4.0.0 Signals - 0: Nothing ready, 1: BCT ready, 2: DRAM ready, 4: pkg2 ready and continue boot.
vu32 *mb_in = (vu32 *)0x40002EF8; vu32 *mb_in = (vu32 *)0x40002EF8;
//Non-zero: Secmon ready //Non-zero: Secmon ready
vu32 *mb_out = (vu32 *)0x40002EFC; vu32 *mb_out = (vu32 *)0x40002EFC;
//Start from DRAM ready signal // Start from DRAM ready signal.
*mb_in = bootStateDramPkg2; *mb_in = bootStateDramPkg2;
*mb_out = 0; *mb_out = 0;
@ -634,7 +634,7 @@ int hos_launch(ini_sec_t *cfg)
if (end_di) if (end_di)
display_end(); display_end();
//Signal to pkg2 ready and continue boot. // Signal pkg2 ready and continue boot.
*mb_in = bootStatePkg2Continue; *mb_in = bootStatePkg2Continue;
// Halt ourselves in waitevent state and resume if there's JTAG activity. // Halt ourselves in waitevent state and resume if there's JTAG activity.

View file

@ -394,9 +394,7 @@ void print_fuseinfo()
f_mkdir("Backup/Dumps"); f_mkdir("Backup/Dumps");
memcpy(fuseFilename, "Backup/Dumps/fuses.bin", 23); memcpy(fuseFilename, "Backup/Dumps/fuses.bin", 23);
if (sd_save_to_file((u8 *)0x7000F900, 0x2FC, fuseFilename)) if (!sd_save_to_file((u8 *)0x7000F900, 0x2FC, fuseFilename))
EPRINTF("\nError creating fuse.bin file.");
else
gfx_puts(&gfx_con, "\nDone!\n"); gfx_puts(&gfx_con, "\nDone!\n");
sd_unmount(); sd_unmount();
} }
@ -429,9 +427,7 @@ void print_kfuseinfo()
f_mkdir("Backup/Dumps"); f_mkdir("Backup/Dumps");
memcpy(kfuseFilename, "Backup/Dumps/kfuses.bin", 24); memcpy(kfuseFilename, "Backup/Dumps/kfuses.bin", 24);
if (sd_save_to_file((u8 *)buf, KFUSE_NUM_WORDS * 4, kfuseFilename)) if (!sd_save_to_file((u8 *)buf, KFUSE_NUM_WORDS * 4, kfuseFilename))
EPRINTF("\nError creating kfuse.bin file.");
else
gfx_puts(&gfx_con, "\nDone!\n"); gfx_puts(&gfx_con, "\nDone!\n");
sd_unmount(); sd_unmount();
} }
@ -1566,34 +1562,28 @@ void dump_package1()
gfx_printf(&gfx_con, "%kWarmboot addr: %k0x%05X\n", 0xFFC7EA46, 0xFFCCCCCC, pkg1_id->warmboot_base); gfx_printf(&gfx_con, "%kWarmboot addr: %k0x%05X\n", 0xFFC7EA46, 0xFFCCCCCC, pkg1_id->warmboot_base);
gfx_printf(&gfx_con, "%kWarmboot size: %k0x%05X\n\n", 0xFFC7EA46, 0xFFCCCCCC, hdr->wb_size); gfx_printf(&gfx_con, "%kWarmboot size: %k0x%05X\n\n", 0xFFC7EA46, 0xFFCCCCCC, hdr->wb_size);
// Dump package1. // Create folders if they do not exist.
f_mkdir("Backup"); f_mkdir("Backup");
f_mkdir("Backup/pkg1"); f_mkdir("Backup/pkg1");
if (sd_save_to_file(pkg1, 0x40000, "Backup/pkg1/pkg1_decr.bin")) {
EPRINTF("\nFailed to create pkg1_decr.bin"); // Dump package1.1.
if (sd_save_to_file(pkg1, 0x40000, "Backup/pkg1/pkg1_decr.bin"))
goto out; goto out;
}
gfx_puts(&gfx_con, "\nFull package1 dumped to pkg1_decr.bin\n"); gfx_puts(&gfx_con, "\nFull package1 dumped to pkg1_decr.bin\n");
// Dump nxbootloader. // Dump nxbootloader.
if (sd_save_to_file(loader, hdr->ldr_size, "Backup/pkg1/nxloader.bin")) { if (sd_save_to_file(loader, hdr->ldr_size, "Backup/pkg1/nxloader.bin"))
EPRINTF("\nFailed to create nxloader.bin");
goto out; goto out;
}
gfx_puts(&gfx_con, "NX Bootloader dumped to nxloader.bin\n"); gfx_puts(&gfx_con, "NX Bootloader dumped to nxloader.bin\n");
// Dump secmon. // Dump secmon.
if (sd_save_to_file(secmon, hdr->sm_size, "Backup/pkg1/secmon.bin")) { if (sd_save_to_file(secmon, hdr->sm_size, "Backup/pkg1/secmon.bin"))
EPRINTF("\nFailed to create secmon.bin");
goto out; goto out;
}
gfx_puts(&gfx_con, "Secure Monitor dumped to secmon.bin\n"); gfx_puts(&gfx_con, "Secure Monitor dumped to secmon.bin\n");
// Dump warmboot. // Dump warmboot.
if (sd_save_to_file(warmboot, hdr->wb_size, "Backup/pkg1/warmboot.bin")) { if (sd_save_to_file(warmboot, hdr->wb_size, "Backup/pkg1/warmboot.bin"))
EPRINTF("\nFailed to create warmboot.bin");
goto out; goto out;
}
gfx_puts(&gfx_con, "Warmboot dumped to warmboot.bin\n"); gfx_puts(&gfx_con, "Warmboot dumped to warmboot.bin\n");
gfx_puts(&gfx_con, "\nDone. Press any key...\n"); gfx_puts(&gfx_con, "\nDone. Press any key...\n");