mirror of
https://github.com/garrettsworkshop/MacIIROMDiskDriver.git
synced 2024-11-24 17:32:39 +00:00
With boot patch
This commit is contained in:
parent
eb34dbb0a3
commit
8600f9ef0e
9
Makefile
9
Makefile
@ -45,8 +45,13 @@ bin/driver.bin: bin obj/driver.o
|
||||
$(OBJCOPY) -O binary obj/driver.o $@
|
||||
|
||||
|
||||
bin/rom.bin: baserom.bin RDisk1M5.dsk bin bin/driver.bin obj/entry_rel.sym
|
||||
cp baserom.bin $@ # copy base rom
|
||||
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
|
||||
# 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
|
||||
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
|
||||
|
BIN
bin/driver.bin
BIN
bin/driver.bin
Binary file not shown.
BIN
bin/rom.bin
BIN
bin/rom.bin
Binary file not shown.
58
entry.s
58
entry.s
@ -1,51 +1,65 @@
|
||||
.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
|
||||
.ascii "\9GWROMDisk\0"
|
||||
.align 4
|
||||
|
||||
.EQU killCode, 1
|
||||
.EQU noQueueBit, 9
|
||||
|
||||
.EQU kioTrap, 6
|
||||
.EQU kioResult, 16
|
||||
.EQU kcsCode, 26
|
||||
|
||||
.EQU JIODone, 0x08FC
|
||||
BootCheckEntry:
|
||||
* Boot if reference number == -5
|
||||
cmp #-5, 8(%A2)
|
||||
beq.b BootCheckRet
|
||||
* Otherwise don't boot if reference number != -50
|
||||
cmp #-50, 8(%A2)
|
||||
bne.b BootCheckRet
|
||||
* 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:
|
||||
movem.l %A0-%A1,-(%SP)
|
||||
movem.l %A0-%A1, -(%SP)
|
||||
bsr RDiskOpen
|
||||
movem.l (%SP)+,%A0-%A1
|
||||
movem.l (%SP)+, %A0-%A1
|
||||
rts
|
||||
|
||||
DClose:
|
||||
movem.l %A0-%A1,-(%SP)
|
||||
movem.l %A0-%A1, -(%SP)
|
||||
bsr RDiskClose
|
||||
movem.l (%SP)+,%A0-%A1
|
||||
movem.l (%SP)+, %A0-%A1
|
||||
rts
|
||||
|
||||
DPrime:
|
||||
movem.l %A0-%A1,-(%SP)
|
||||
movem.l %A0-%A1, -(%SP)
|
||||
bsr RDiskPrime
|
||||
movem.l (%SP)+,%A0-%A1
|
||||
movem.l (%SP)+, %A0-%A1
|
||||
bra.b IOReturn
|
||||
|
||||
DControl:
|
||||
movem.l %A0-%A1,-(%SP)
|
||||
movem.l %A0-%A1, -(%SP)
|
||||
bsr RDiskControl
|
||||
movem.l (%SP)+,%A0-%A1
|
||||
movem.l (%SP)+, %A0-%A1
|
||||
cmpi.w #killCode, kcsCode(%A0)
|
||||
bne.b IOReturn
|
||||
rts
|
||||
|
||||
DStatus:
|
||||
movem.l %A0-%A1,-(%SP)
|
||||
movem.l %A0-%A1, -(%SP)
|
||||
bsr RDiskStatus
|
||||
movem.l (%SP)+,%A0-%A1
|
||||
movem.l (%SP)+, %A0-%A1
|
||||
|
||||
IOReturn:
|
||||
move.w kioTrap(%A0),%D1
|
||||
btst #noQueueBit,%D1
|
||||
move.w kioTrap(%A0), %D1
|
||||
btst #noQueueBit, %D1
|
||||
beq.b Queued
|
||||
|
||||
NotQueued:
|
||||
@ -54,7 +68,7 @@ NotQueued:
|
||||
clr.w %D0
|
||||
|
||||
ImmedRTS:
|
||||
move.w %D0,kioResult(%A0)
|
||||
move.w %D0, kioResult(%A0)
|
||||
rts
|
||||
|
||||
Queued:
|
||||
@ -64,5 +78,5 @@ Queued:
|
||||
rts
|
||||
|
||||
MyIODone:
|
||||
move.l JIODone,-(%SP)
|
||||
move.l JIODone, -(%SP)
|
||||
rts
|
||||
|
36
rdisk.c
36
rdisk.c
@ -78,6 +78,13 @@ const long RDiskIcon[65] = {
|
||||
0
|
||||
};
|
||||
|
||||
#pragma parameter __D0 RDiskBootCheckPRAM()
|
||||
short RDiskBootCheckPRAM() {
|
||||
char mount;
|
||||
RDiskReadXPRAM(1, 4, &mount);
|
||||
return mount == 0x5D;
|
||||
}
|
||||
|
||||
// Switch to 24-bit mode and copy
|
||||
void RDiskCopy24(Ptr sourcePtr, Ptr destPtr, unsigned long byteCount) {
|
||||
char mode = true32b;
|
||||
@ -116,7 +123,9 @@ OSErr RDiskOpen(IOParamPtr p, DCtlPtr d) {
|
||||
c = *(RDiskStorage_t**)d->dCtlStorage;
|
||||
|
||||
// Initialize storage struct fields
|
||||
c->init_done = 0;
|
||||
c->initialized = 0;
|
||||
c->offline = 0;
|
||||
c->forceMount = 0;
|
||||
c->ramdisk = NULL;
|
||||
c->copy24 = (RDiskCopy_t)copy24;
|
||||
|
||||
@ -138,22 +147,22 @@ OSErr RDiskOpen(IOParamPtr p, DCtlPtr d) {
|
||||
return noErr;
|
||||
}
|
||||
|
||||
OSErr RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
|
||||
char startup = 0, ram = 0;
|
||||
static OSErr RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
|
||||
char mount = 0, ram = 0;
|
||||
|
||||
// Mark init done
|
||||
c->init_done = 1;
|
||||
c->initialized = 1;
|
||||
|
||||
// Read PRAM
|
||||
RDiskReadXPRAM(1, 4, &startup);
|
||||
RDiskReadXPRAM(1, 4, &mount);
|
||||
RDiskReadXPRAM(1, 5, &ram);
|
||||
|
||||
// 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
|
||||
c->status.writeProt = -1; // Set write protected
|
||||
// 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
|
||||
if (*MMU32bit) { // 32-bit mode
|
||||
unsigned long minBufPtr, newBufPtr;
|
||||
@ -161,7 +170,7 @@ OSErr RDiskInit(IOParamPtr p, DCtlPtr d, RDiskStorage_t *c) {
|
||||
minBufPtr = ((unsigned long)*MemTop / 2) + 1024;
|
||||
newBufPtr = (unsigned long)*BufPtr - RDiskSize;
|
||||
if (newBufPtr > minBufPtr && (unsigned long)*BufPtr > newBufPtr) {
|
||||
// Allocate RAM disk buffer by lowering BufPtrå
|
||||
// Allocate RAM disk buffer by lowering BufPtra
|
||||
*BufPtr = (Ptr)newBufPtr;
|
||||
// Set RAM disk buffer pointer.
|
||||
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 (dq->dQRefNum == d->dCtlRefNum) {
|
||||
Dequeue((QElemPtr)dq, head);
|
||||
DisposeHandle(d->dCtlStorage);
|
||||
}
|
||||
d->dCtlStorage = NULL;
|
||||
c->offline = 1;
|
||||
// Return disk offline error
|
||||
return offLinErr;
|
||||
}
|
||||
@ -219,9 +227,11 @@ OSErr RDiskPrime(IOParamPtr p, DCtlPtr d) {
|
||||
if (!d->dCtlStorage) { return offLinErr; }
|
||||
// Dereference dCtlStorage to get pointer to our context
|
||||
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
|
||||
if (!c->init_done) {
|
||||
if (!c->initialized) {
|
||||
OSErr ret = RDiskInit(p, d, c);
|
||||
if (ret != noErr) { return ret; }
|
||||
}
|
||||
@ -291,7 +301,7 @@ OSErr RDiskControl(CntrlParamPtr p, DCtlPtr d) {
|
||||
case 21: case 22:
|
||||
*(Ptr*)&p->csParam = (Ptr)&RDiskIcon;
|
||||
return noErr;
|
||||
case 128: c->mount = 1; return noErr;
|
||||
case 128: c->forceMount = 1; return noErr;
|
||||
default: return controlErr;
|
||||
}
|
||||
}
|
||||
@ -303,6 +313,8 @@ OSErr RDiskStatus(CntrlParamPtr p, DCtlPtr d) {
|
||||
if (!d->dCtlStorage) { return statusErr; }
|
||||
// Dereference dCtlStorage to get pointer to our context
|
||||
c = *(RDiskStorage_t**)d->dCtlStorage;
|
||||
// Fail if offline
|
||||
if (c->offline) { return statusErr; }
|
||||
// Handle status request based on csCode
|
||||
switch (p->csCode) {
|
||||
case drvStsCode:
|
||||
|
Loading…
Reference in New Issue
Block a user