With boot patch

This commit is contained in:
Zane Kaminski 2020-06-29 21:08:50 -04:00
parent eb34dbb0a3
commit 8600f9ef0e
6 changed files with 70 additions and 38 deletions

View File

@ -45,8 +45,13 @@ bin/driver.bin: bin obj/driver.o
$(OBJCOPY) -O binary obj/driver.o $@ $(OBJCOPY) -O binary obj/driver.o $@
bin/rom.bin: baserom.bin RDisk1M5.dsk bin bin/driver.bin obj/entry_rel.sym bin/rom.bin: baserom.bin RDisk1M5.dsk bin bin/driver.bin obj/driver_abs.sym obj/entry_rel.sym
cp baserom.bin $@ # copy base rom cp baserom.bin $@ # Copy base rom
# Patch boot
printf '\x4E' | dd of=$@ bs=1 seek=5888 count=1 conv=notrunc # Copy JSR opcode into IsFloppy boot routine
printf '\xF9' | dd of=$@ bs=1 seek=5889 count=1 conv=notrunc # Copy JSR opcode second byte
cat obj/driver_abs.sym | grep "BootCheckEntry" | cut -c1-8 | xxd -r -p - | dd of=$@ bs=1 seek=5890 count=4 conv=notrunc
# Patch driver
dd if=bin/driver.bin of=$@ bs=1 seek=335248 skip=32 conv=notrunc # Copy driver code dd if=bin/driver.bin of=$@ bs=1 seek=335248 skip=32 conv=notrunc # Copy driver code
printf '\x78' | dd of=$@ bs=1 seek=335168 count=1 conv=notrunc # Set resource flags printf '\x78' | dd of=$@ bs=1 seek=335168 count=1 conv=notrunc # Set resource flags
printf '\x4F' | dd of=$@ bs=1 seek=335216 count=1 conv=notrunc # Set driver flags printf '\x4F' | dd of=$@ bs=1 seek=335216 count=1 conv=notrunc # Set driver flags

Binary file not shown.

Binary file not shown.

30
entry.s
View File

@ -1,16 +1,30 @@
.EQU killCode, 1
.EQU noQueueBit, 9
.EQU kioTrap, 6
.EQU kioResult, 16
.EQU kcsCode, 26
.EQU JIODone, 0x08FC
dc.l 0x00000000, 0x00000000, 0x00000000, 0x00000000 dc.l 0x00000000, 0x00000000, 0x00000000, 0x00000000
dc.l 0x00000000, 0x00000000, 0x00000000, 0x00000000 dc.l 0x00000000, 0x00000000, 0x00000000, 0x00000000
.ascii "\9GWROMDisk\0" .ascii "\9GWROMDisk\0"
.align 4 .align 4
.EQU killCode, 1 BootCheckEntry:
.EQU noQueueBit, 9 * Boot if reference number == -5
cmp #-5, 8(%A2)
.EQU kioTrap, 6 beq.b BootCheckRet
.EQU kioResult, 16 * Otherwise don't boot if reference number != -50
.EQU kcsCode, 26 cmp #-50, 8(%A2)
bne.b BootCheckRet
.EQU JIODone, 0x08FC * Call to check PRAM
movem.l %A0-%A7/%D0-%D7, -(%SP)
jsr RDiskBootCheckPRAM
cmp #0, %D0
movem.l (%SP)+, %A0-%A7/%D0-%D7
BootCheckRet:
rts
jmp BootCheckEntry
DOpen: DOpen:
movem.l %A0-%A1, -(%SP) movem.l %A0-%A1, -(%SP)

36
rdisk.c
View File

@ -78,6 +78,13 @@ const long RDiskIcon[65] = {
0 0
}; };
#pragma parameter __D0 RDiskBootCheckPRAM()
short RDiskBootCheckPRAM() {
char mount;
RDiskReadXPRAM(1, 4, &mount);
return mount == 0x5D;
}
// Switch to 24-bit mode and copy // Switch to 24-bit mode and copy
void RDiskCopy24(Ptr sourcePtr, Ptr destPtr, unsigned long byteCount) { void RDiskCopy24(Ptr sourcePtr, Ptr destPtr, unsigned long byteCount) {
char mode = true32b; char mode = true32b;
@ -116,7 +123,9 @@ OSErr RDiskOpen(IOParamPtr p, DCtlPtr d) {
c = *(RDiskStorage_t**)d->dCtlStorage; c = *(RDiskStorage_t**)d->dCtlStorage;
// Initialize storage struct fields // Initialize storage struct fields
c->init_done = 0; c->initialized = 0;
c->offline = 0;
c->forceMount = 0;
c->ramdisk = NULL; c->ramdisk = NULL;
c->copy24 = (RDiskCopy_t)copy24; c->copy24 = (RDiskCopy_t)copy24;
@ -138,22 +147,22 @@ OSErr RDiskOpen(IOParamPtr p, DCtlPtr d) {
return noErr; return noErr;
} }
OSErr RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) { static OSErr RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
char startup = 0, ram = 0; char mount = 0, ram = 0;
// Mark init done // Mark init done
c->init_done = 1; c->initialized = 1;
// Read PRAM // Read PRAM
RDiskReadXPRAM(1, 4, &startup); RDiskReadXPRAM(1, 4, &mount);
RDiskReadXPRAM(1, 5, &ram); RDiskReadXPRAM(1, 5, &ram);
// Either enable ROM disk or remove ourselves from the drive queue // Either enable ROM disk or remove ourselves from the drive queue
if (startup || RDiskIsRPressed()) { // If ROM disk boot set in PRAM or R pressed,*/ if (c->forceMount || mount || RDiskIsRPressed()) { // If ROM disk boot set in PRAM or R pressed,
// Set ROM disk attributes // Set ROM disk attributes
c->status.writeProt = -1; // Set write protected c->status.writeProt = -1; // Set write protected
// If RAM disk set in PRAM or A pressed, enable RAM disk // If RAM disk set in PRAM or A pressed, enable RAM disk
if (ram || RDiskIsAPressed() || c->mount) { if (ram || RDiskIsAPressed()) { // If RAM disk set in PRAM or A pressed
// Try to allocate RAM disk buffer // Try to allocate RAM disk buffer
if (*MMU32bit) { // 32-bit mode if (*MMU32bit) { // 32-bit mode
unsigned long minBufPtr, newBufPtr; unsigned long minBufPtr, newBufPtr;
@ -161,7 +170,7 @@ OSErr RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
minBufPtr = ((unsigned long)*MemTop / 2) + 1024; minBufPtr = ((unsigned long)*MemTop / 2) + 1024;
newBufPtr = (unsigned long)*BufPtr - RDiskSize; newBufPtr = (unsigned long)*BufPtr - RDiskSize;
if (newBufPtr > minBufPtr && (unsigned long)*BufPtr > newBufPtr) { if (newBufPtr > minBufPtr && (unsigned long)*BufPtr > newBufPtr) {
// Allocate RAM disk buffer by lowering BufPtrå // Allocate RAM disk buffer by lowering BufPtra
*BufPtr = (Ptr)newBufPtr; *BufPtr = (Ptr)newBufPtr;
// Set RAM disk buffer pointer. // Set RAM disk buffer pointer.
c->ramdisk = *BufPtr; c->ramdisk = *BufPtr;
@ -200,9 +209,8 @@ OSErr RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
// If we found our driver, remove it from the queue // If we found our driver, remove it from the queue
if (dq->dQRefNum == d->dCtlRefNum) { if (dq->dQRefNum == d->dCtlRefNum) {
Dequeue((QElemPtr)dq, head); Dequeue((QElemPtr)dq, head);
DisposeHandle(d->dCtlStorage);
} }
d->dCtlStorage = NULL; c->offline = 1;
// Return disk offline error // Return disk offline error
return offLinErr; return offLinErr;
} }
@ -219,9 +227,11 @@ OSErr RDiskPrime(IOParamPtr p, DCtlPtr d) {
if (!d->dCtlStorage) { return offLinErr; } if (!d->dCtlStorage) { return offLinErr; }
// Dereference dCtlStorage to get pointer to our context // Dereference dCtlStorage to get pointer to our context
c = *(RDiskStorage_t**)d->dCtlStorage; c = *(RDiskStorage_t**)d->dCtlStorage;
// Return disk offline error if marked offline
if (c->offline) { return offLinErr; }
// Initialize if this is the first prime call // Initialize if this is the first prime call
if (!c->init_done) { if (!c->initialized) {
OSErr ret = RDiskInit(p, d, c); OSErr ret = RDiskInit(p, d, c);
if (ret != noErr) { return ret; } if (ret != noErr) { return ret; }
} }
@ -291,7 +301,7 @@ OSErr RDiskControl(CntrlParamPtr p, DCtlPtr d) {
case 21: case 22: case 21: case 22:
*(Ptr*)&p->csParam = (Ptr)&RDiskIcon; *(Ptr*)&p->csParam = (Ptr)&RDiskIcon;
return noErr; return noErr;
case 128: c->mount = 1; return noErr; case 128: c->forceMount = 1; return noErr;
default: return controlErr; default: return controlErr;
} }
} }
@ -303,6 +313,8 @@ OSErr RDiskStatus(CntrlParamPtr p, DCtlPtr d) {
if (!d->dCtlStorage) { return statusErr; } if (!d->dCtlStorage) { return statusErr; }
// Dereference dCtlStorage to get pointer to our context // Dereference dCtlStorage to get pointer to our context
c = *(RDiskStorage_t**)d->dCtlStorage; c = *(RDiskStorage_t**)d->dCtlStorage;
// Fail if offline
if (c->offline) { return statusErr; }
// Handle status request based on csCode // Handle status request based on csCode
switch (p->csCode) { switch (p->csCode) {
case drvStsCode: case drvStsCode:

View File

@ -37,10 +37,11 @@ typedef void (*RDiskCopy_t)(Ptr, Ptr, unsigned long);
typedef struct RDiskStorage_s { typedef struct RDiskStorage_s {
DrvSts2 status; DrvSts2 status;
unsigned long init_done; char initialized;
char offline;
char forceMount;
char *ramdisk; char *ramdisk;
RDiskCopy_t copy24; RDiskCopy_t copy24;
char mount;
} RDiskStorage_t; } RDiskStorage_t;
#endif #endif