mirror of
https://github.com/LIV2/lide.device.git
synced 2025-12-06 00:32:45 +00:00
lideflash: Support RIDE
This commit is contained in:
parent
2a3fc5ec71
commit
6b334e9a6b
@ -39,7 +39,8 @@ struct Config* configure(int argc, char *argv[]) {
|
||||
|
||||
if (config == NULL) return NULL;
|
||||
|
||||
config->cdfs_filename = NULL;
|
||||
config->misc_filename = NULL;
|
||||
config->misc_bank = -1;
|
||||
config->eraseFlash = false;
|
||||
config->rebootRequired = false;
|
||||
config->assumeYes = false;
|
||||
@ -56,7 +57,18 @@ struct Config* configure(int argc, char *argv[]) {
|
||||
|
||||
case 'C':
|
||||
if (i+1 < argc) {
|
||||
config->cdfs_filename = argv[i+1];
|
||||
config->misc_filename = argv[i+1];
|
||||
config->misc_bank = 1;
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
if (i+1 < argc) {
|
||||
config->misc_filename = argv[i+1];
|
||||
config->misc_bank = (BYTE)(argv[i][1] - '0');
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
@ -77,7 +89,7 @@ struct Config* configure(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
if (config->ide_rom_filename == NULL && config->cdfs_filename == NULL && config->eraseFlash == false) {
|
||||
if (config->ide_rom_filename == NULL && config->misc_filename == NULL && config->eraseFlash == false) {
|
||||
error = true;
|
||||
}
|
||||
|
||||
|
||||
@ -20,10 +20,11 @@
|
||||
|
||||
struct Config {
|
||||
char *ide_rom_filename;
|
||||
char *cdfs_filename;
|
||||
char *misc_filename;
|
||||
bool eraseFlash;
|
||||
bool rebootRequired;
|
||||
bool assumeYes;
|
||||
BYTE misc_bank;
|
||||
};
|
||||
|
||||
struct Config* configure(int, char* []);
|
||||
|
||||
@ -35,8 +35,9 @@
|
||||
#define MANUF_ID_BSC 0x082C
|
||||
#define MANUF_ID_OAHR 5194
|
||||
|
||||
#define PROD_ID_CIDER 0x05
|
||||
#define PROD_ID_RIPPLE 0x07
|
||||
#define PROD_ID_CIDER 0x05
|
||||
#define PROD_ID_RIPPLE 0x07
|
||||
#define PROD_ID_RIDE 0x09
|
||||
|
||||
#define SERIAL_LIV2 0x4C495632
|
||||
|
||||
@ -208,8 +209,17 @@ static void setup_liv2_board(struct ideBoard *board) {
|
||||
*pokeReg = 0x00;
|
||||
}
|
||||
|
||||
board->cdfsSupported = (board->cd->cd_Rom.er_Product == PROD_ID_RIPPLE) ? true : false;
|
||||
|
||||
switch (board->cd->cd_Rom.er_Product) {
|
||||
case PROD_ID_RIPPLE:
|
||||
board->banks = 2;
|
||||
break;
|
||||
case PROD_ID_RIDE:
|
||||
board->banks = 4;
|
||||
break;
|
||||
default:
|
||||
board->banks = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,10 +298,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
void *driver_buffer = NULL;
|
||||
void *driver_buffer2 = NULL;
|
||||
void *cdfs_buffer = NULL;
|
||||
void *misc_buffer = NULL;
|
||||
|
||||
ULONG romSize = 0;
|
||||
ULONG cdfsSize = 0;
|
||||
ULONG miscSize = 0;
|
||||
|
||||
if (DosBase == NULL) {
|
||||
return(rc);
|
||||
@ -337,24 +347,24 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (config->cdfs_filename) {
|
||||
if (config->misc_filename) {
|
||||
|
||||
cdfsSize = getFileSize(config->cdfs_filename);
|
||||
miscSize = getFileSize(config->misc_filename);
|
||||
|
||||
if (cdfsSize == 0) {
|
||||
if (miscSize == 0) {
|
||||
rc = 5;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (cdfsSize > 32768) {
|
||||
printf("CDFS too large!\n");
|
||||
if (miscSize > 32768) {
|
||||
printf("File too large!\n");
|
||||
rc = 5;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
cdfs_buffer = AllocMem(cdfsSize,MEMF_ANY|MEMF_CLEAR);
|
||||
if (cdfs_buffer) {
|
||||
if (readFileToBuf(config->cdfs_filename,cdfs_buffer) == false) {
|
||||
misc_buffer = AllocMem(miscSize,MEMF_ANY|MEMF_CLEAR);
|
||||
if (misc_buffer) {
|
||||
if (readFileToBuf(config->misc_filename,misc_buffer) == false) {
|
||||
rc = 5;
|
||||
goto exit;
|
||||
}
|
||||
@ -393,6 +403,10 @@ int main(int argc, char *argv[])
|
||||
printf("Found RIPPLE IDE");
|
||||
setup_liv2_board(&board);
|
||||
break;
|
||||
} else if (cd->cd_Rom.er_Product == PROD_ID_RIDE) {
|
||||
printf("Found RIDE IDE");
|
||||
setup_liv2_board(&board);
|
||||
break;
|
||||
} else {
|
||||
continue; // Skip this board
|
||||
}
|
||||
@ -523,21 +537,21 @@ int main(int argc, char *argv[])
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (config->cdfs_filename) {
|
||||
if (config->misc_filename) {
|
||||
|
||||
if (board.cdfsSupported && sectorSize > 0) {
|
||||
if (config->misc_bank < board.banks && sectorSize > 0) {
|
||||
|
||||
if (board.bankSelect != NULL)
|
||||
board.bankSelect(1,&board);
|
||||
board.bankSelect(config->misc_bank,&board);
|
||||
|
||||
if (config->eraseFlash == false) {
|
||||
printf("Erasing CDFS bank...\n");
|
||||
printf("Erasing bank %d...\n",config->misc_bank);
|
||||
flash_erase_bank(sectorSize);
|
||||
}
|
||||
printf("Writing CDFS.\n");
|
||||
writeBufToFlash(&board,cdfs_buffer,board.flashbase,cdfsSize);
|
||||
printf("Writing bank %d.\n",config->misc_bank);
|
||||
writeBufToFlash(&board,misc_buffer,board.flashbase,miscSize);
|
||||
} else {
|
||||
printf("This board does not support flashing CDFS.\n");
|
||||
printf("This board does not support flashing bank %d.\n",config->misc_bank);
|
||||
}
|
||||
}
|
||||
|
||||
@ -578,7 +592,7 @@ int main(int argc, char *argv[])
|
||||
exit:
|
||||
if (driver_buffer2) FreeMem(driver_buffer2,romSize);
|
||||
if (driver_buffer) FreeMem(driver_buffer,romSize);
|
||||
if (cdfs_buffer) FreeMem(cdfs_buffer,cdfsSize);
|
||||
if (misc_buffer) FreeMem(misc_buffer,miscSize);
|
||||
if (config) FreeMem(config,sizeof(struct Config));
|
||||
if (ExpansionBase) CloseLibrary((struct Library *)ExpansionBase);
|
||||
if (DosBase) CloseLibrary((struct Library *)DosBase);
|
||||
@ -658,8 +672,12 @@ BOOL readFileToBuf(char *filename, void *buffer) {
|
||||
* @param boardBase base address of the IDE board
|
||||
*/
|
||||
void bankSelect(UBYTE bank, struct ideBoard *board) {
|
||||
UBYTE *boardBase = board->cd->cd_BoardAddr;
|
||||
*(boardBase + BANK_SEL_REG) = (bank << 6);
|
||||
UBYTE *bankReg = board->cd->cd_BoardAddr + BANK_SEL_REG;
|
||||
UBYTE regbits = *bankReg;
|
||||
// Preserve the other bits
|
||||
regbits &= 0x3F;
|
||||
regbits |= (bank << 6);
|
||||
*bankReg = regbits;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ struct ideBoard {
|
||||
enum BOOTROM bootrom;
|
||||
void * volatile flashbase;
|
||||
bool rebootRequired;
|
||||
bool cdfsSupported;
|
||||
uint8_t banks;
|
||||
void (*bankSelect)(UBYTE, struct ideBoard *);
|
||||
void (*writeEnable)(struct ideBoard *);
|
||||
};
|
||||
|
||||
@ -87,13 +87,13 @@ void setup_matzetk_board(struct ideBoard *board) {
|
||||
board->bootrom = ATBUS;
|
||||
board->writeEnable = &matzetk_enable_flash;
|
||||
board->rebootRequired = true; // write enable turns off IDE so we must reboot afterwards
|
||||
board->banks = 1;
|
||||
|
||||
if (boardIs68ec020tk(board->cd)) {
|
||||
board->bankSelect = &matzetk_bankSelect;
|
||||
board->cdfsSupported = true;
|
||||
board->banks = 2;
|
||||
} else {
|
||||
board->bankSelect = NULL;
|
||||
board->cdfsSupported = false; // TODO: Support writing 2nd bank of 68020-TK2
|
||||
}
|
||||
|
||||
board->flashbase = board->cd->cd_BoardAddr + 1; // BootROM is on odd addresses
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user