Improve CDFileSystem support

- Adds support for loading a filesystem without the need for a
  resident struct.
- Factor out debugging functions from the mounter code finding CDFS:
  scan_filesystems --> list_filesystems & find_cdfs
- Properly Forbid/Permit when operating on FileSystemEntries
This commit is contained in:
Stefan Reinauer 2023-11-11 08:52:37 -08:00
parent a2837bfe32
commit 58de877be8
2 changed files with 77 additions and 32 deletions

View File

@ -879,9 +879,30 @@ static LONG ScanRDSK(struct MountData *md)
return ret;
}
static struct FileSysEntry *scan_filesystems(void)
static struct FileSysEntry *find_cdfs(void)
{
struct FileSysEntry *fse, *cdfs=NULL;
Forbid();
if ((FileSysResBase = (struct FileSysResource *)OpenResource(FSRNAME))) {
for (fse = (struct FileSysEntry *)FileSysResBase->fsr_FileSysEntries.lh_Head;
fse->fse_Node.ln_Succ;
fse = (struct FileSysEntry *)fse->fse_Node.ln_Succ) {
if (fse->fse_DosType==0x43443031) {
cdfs=fse;
break;
}
}
}
Permit();
return cdfs;
}
static void list_filesystems(void)
{
#ifdef DEBUG_MOUNTER
struct FileSysEntry *fse;
/* NOTE - you should actually be in a Forbid while accessing any
* system list for which no other method of arbitration is available.
@ -898,7 +919,6 @@ static struct FileSysEntry *scan_filesystems(void)
for ( fse = (struct FileSysEntry *)FileSysResBase->fsr_FileSysEntries.lh_Head;
fse->fse_Node.ln_Succ;
fse = (struct FileSysEntry *)fse->fse_Node.ln_Succ) {
#ifdef DEBUG_MOUNTER
int x;
for (x=24; x>=8; x-=8)
putchar((fse->fse_DosType >> x) & 0xFF);
@ -906,7 +926,7 @@ static struct FileSysEntry *scan_filesystems(void)
putchar((fse->fse_DosType & 0xFF) < 0x30
? (fse->fse_DosType & 0xFF) + 0x30
: (fse->fse_DosType & 0xFF));
#endif
printf(" %s%d",(fse->fse_Version >> 16)<10 ? " " : "", (fse->fse_Version >> 16));
printf(".%d%s",(fse->fse_Version & 0xFFFF), (fse->fse_Version & 0xFFFF)<10 ? " " : "");
if(fse->fse_Node.ln_Name[0])
@ -914,16 +934,10 @@ static struct FileSysEntry *scan_filesystems(void)
else
printf(" N/A\n");
if (fse->fse_DosType==0x43443031) {
cdfs=fse;
#ifndef ALL_FILESYSTEMS
break;
#endif
}
}
}
return cdfs;
#endif
}
// CheckPVD
@ -1012,7 +1026,7 @@ static LONG ScanCDROM(struct MountData *md)
pp.de.de_DosType = 0x43443031; // CD01
pp.de.de_BootPri = bootPri;
fse=scan_filesystems();
fse=find_cdfs();
if (!fse) {
printf("Could not load filesystem\n");
return -1;

View File

@ -8,6 +8,8 @@
#include "device.h"
#include "attach.h"
#include "reloc.h"
#include <resources/filesysres.h>
#include "version.h"
static uint32_t RomFetch32(uint32_t offset)
{
@ -61,40 +63,69 @@ void parse_romfiles(void)
}
}
const char cdfs_id_string[] = "CDFileSystem (A4091)";
int add_cdromfilesystem(void)
{
uint32_t cdfs_seglist = 0;
struct Resident *r;
struct Resident *r = NULL;
struct FileSysResource *FileSysResBase;
struct FileSysEntry *fse;
printf("CDFS in Kickstart... ");
r=FindResident("cdfs");
if (r == NULL) {
int i;
printf("Not found\nCDFS in A4091 ROM... ");
printf("not found.\nCDFS in A4091 ROM... ");
if (asave->romfile_len[1])
if (asave->romfile_len[1])
cdfs_seglist = relocate(asave->romfile[1], (uint32_t)asave->as_addr);
if (cdfs_seglist == 0) {
// baserel does not like rErrno
printf("Not found\nToo bad.\n");
return 0;
printf("%sfound.\n", cdfs_seglist?"":"not ");
// baserel does not like rErrno
if (cdfs_seglist == 0)
return 0;
printf("Resident struct... ");
for (i=cdfs_seglist; i<cdfs_seglist + asave->romfile_len[1]; i+=2) {
if(*(uint16_t *)i == 0x4afc) {
r = (struct Resident *)i;
break;
}
}
printf("Found\nResident struct... ");
for (i=cdfs_seglist; i<cdfs_seglist + asave->romfile_len[1]; i+=2)
if(*(uint16_t *)i == 0x4afc)
break;
if (*(uint16_t *)i == 0x4afc)
r = (struct Resident *)i;
}
if (r) {
printf("Found\nInitializing CDFS @%p... ", r);
InitResident(r, cdfs_seglist);
printf("Done\n");
} else {
printf("Not found\nToo bad.\n");
printf("%sfound.\n", r?"":"not ");
if (r != NULL) {
if (r && r->rt_Init) {
printf("Initializing CDFS @%p... ", r);
InitResident(r, cdfs_seglist);
printf("done.\n");
return 1;
} else
printf("No rt_Init.\n");
}
return (r!=NULL);
FileSysResBase = (struct FileSysResource *)OpenResource(FSRNAME);
if (!FileSysResBase)
return 0;
fse = AllocMem(sizeof(struct FileSysEntry), MEMF_PUBLIC | MEMF_CLEAR);
if (!fse)
return 0;
fse->fse_Node.ln_Name = (UBYTE*)cdfs_id_string;
fse->fse_DosType = 0x43443031;
fse->fse_Version = ((LONG)DEVICE_VERSION) << 16 | DEVICE_REVISION;
fse->fse_PatchFlags = 0x190; // SegList and GlobalVec
fse->fse_SegList = cdfs_seglist >> 2;
fse->fse_GlobalVec = -1;
fse->fse_StackSize = 5120;
fse->fse_Priority = 10;
Forbid();
AddHead(&FileSysResBase->fsr_FileSysEntries,&fse->fse_Node);
Permit();
return (1);
}