]> git.sesse.net Git - pistorm/blobdiff - platforms/amiga/piscsi/device_driver_amiga/bootrom.s
Map the default 128MB of Z3 Fast on Kick 1.3
[pistorm] / platforms / amiga / piscsi / device_driver_amiga / bootrom.s
index 0696d8367819b420d1b076d46df4ab22aa8885cb..25721255083be884cc49a8aaaeaccca5ced572cb 100644 (file)
@@ -19,6 +19,7 @@
     INCLUDE "exec/nodes.i"
     INCLUDE "exec/resident.i"
     INCLUDE "libraries/configvars.i"
+    INCLUDE "libraries/expansionbase.i"
 
     ; LVO's resolved by linking with library amiga.lib
     XREF   _LVOFindResident
@@ -64,6 +65,8 @@ OpenLibrary     EQU -552
 CloseLibrary    EQU -414
 OpenResource    EQU -$1F2
 AddResource     EQU -$1E6
+Enqueue         EQU -$10E
+AddMemList      EQU -$26A
 
 ; Expansion stuff
 MakeDosNode     EQU -144
@@ -160,7 +163,7 @@ DiagEntry:
             nop
             nop
             nop
-            move.l  #1,PiSCSIDebugMe
+            move.l #1,PiSCSIDebugMe
             move.l a3,PiSCSIAddr1
             nop
             nop
@@ -207,18 +210,16 @@ endpatches:
 
 BootEntry:
             align 2
-            move.l  #2,PiSCSIDebugMe
-            nop
-            nop
-            nop
-            nop
-            nop
-
-            lea     DosName(PC),a1          ; 'dos.library',0
-            jsr     FindResident(a6)        ; find the DOS resident tag
-            move.l  d0,a0                   ; in order to bootstrap
-            move.l  RT_INIT(A0),a0          ; set vector to DOS INIT
-            jsr     (a0)                    ; and initialize DOS
+            move.l #2,PiSCSIDebugMe
+            lea DosName(pc),a1
+            jsr FindResident(a6)
+            tst.l d0
+            beq.b .End
+            move.l d0,a0
+            move.l RT_INIT(a0),a0
+            jmp (a0)
+.End
+            moveq.l #1,d0           ; indicate "success"
             rts
 
 *
@@ -259,9 +260,26 @@ Init:       ; After Diag patching, our romtag will point to this
             move.l a6,-(a7)             ; Push A6 to stack
             move.w #$00B8,$dff09a       ; Disable interrupts during init
             move.l  #3,PiSCSIDebugMe
+            move.l a3,PiSCSIAddr4
 
-            move.l  #11,PiSCSIDebugMe
             movea.l 4,a6
+
+            move.l $10000040,d1
+            move.l #$feffeeff,$10000040
+            move.l $10000040,d0
+            cmp.l #$feffeeff,d0
+            bne.s NoZ3
+            move.l d1,$10000040
+
+            move.l #$8000000,d0         ; Add some Z3 fast RAM if it hasn't been moved (Kick 1.3)
+            move.l #$405,d1
+            move.l #10,d2
+            move.l #$10000000,a0
+            move.l #0,a1
+            jsr AddMemList(a6)
+
+NoZ3:
+            move.l  #11,PiSCSIDebugMe
             lea LibName(pc),a1
             jsr FindResident(a6)
             move.l  #10,PiSCSIDebugMe
@@ -291,40 +309,90 @@ FSLoadExit:
             lea ExpansionName(pc),a1
             moveq #0,d0
             jsr OpenLibrary(a6)         ; Open expansion.library to make this work, somehow
+            move.l a6,a4
             move.l d0,a6
 
             move.l  #7,PiSCSIDebugMe
 PartitionLoop:
             move.l PiSCSIGetPart,d0     ; Get the available partition in the current slot
-            beq.s EndPartitions         ; If the next partition returns 0, there's no additional partitions
+            beq.w EndPartitions         ; If the next partition returns 0, there's no additional partitions
             move.l d0,a0
             jsr MakeDosNode(a6)
             move.l d0,PiSCSISetFSH
+            move.l d0,PiSCSIAddr2       ; Put DeviceNode address in PiSCSIAddr2, because I'm useless
             move.l d0,a0
             move.l PiSCSIGetPrio,d0
             move.l #0,d1
             move.l PiSCSIAddr1,a1
-            jsr AddBootNode(a6)
+
+* Uncomment these lines to test AddDosNode/Enqueue stuff
+* Or comment them out all the way down to and including SkipEnqueue: to use the AddBootNode method instead.
+            cmp.l   #-128,d0
+            bne.s   EnqueueNode
+
+* BOOL AddDosNode( LONG bootPri, ULONG flags, struct DeviceNode *deviceNode );
+* amicall(ExpansionBase, 0x96, AddDosNode(d0,d1,a0))
+            move.l #38,PiSCSIDebugMe
+            jsr AddDosNode(a6)
+            bra.w SkipEnqueue
+* VOID Enqueue( struct List *list, struct Node *node );
+* amicall(SysBase, 0x10e, Enqueue(a0,a1))
+
+EnqueueNode:
+            exg a6,a4
+            move.l #35,PiSCSIDebugMe
+            move.l #BootNode_SIZEOF,PiSCSIDebugMe
+            move.l #NT_BOOTNODE,PiSCSIDebugMe
+            move.l #LN_TYPE,PiSCSIDebugMe
+            move.l #LN_PRI,PiSCSIDebugMe
+            move.l #LN_NAME,PiSCSIDebugMe
+            move.l #eb_MountList,PiSCSIDebugMe
+            move.l #35,PiSCSIDebugMe
+
+            move.l #BootNode_SIZEOF,d0
+            move.l #$10001,d1
+            jsr AllocMem(a6)            ; Allocate memory for the BootNode
+
+            move.l d0,PiSCSIAddr3
+            move.l #36,PiSCSIDebugMe
+
+            move.l d0,a1
+            move.b #NT_BOOTNODE,LN_TYPE(a1)
+            move.l PiSCSIGetPrio,d0
+            move.b d0,LN_PRI(a1)
+            move.l PiSCSIAddr2,bn_DeviceNode(a1)
+            move.l PiSCSIAddr1,LN_NAME(a1)
+
+            lea eb_MountList(a4),a0
+            jsr Enqueue(a6)
+            exg a6,a4
+
+SkipEnqueue:
+
+* BOOL AddBootNode( LONG bootPri, ULONG flags, struct DeviceNode *deviceNode, struct ConfigDev *configDev );
+* amicall(ExpansionBase, 0x24, AddBootNode(d0,d1,a0,a1))
+* Comment out the line below to test AddDosNode/Enqueue stuff
+*            jsr AddBootNode(a6)
             move.l #1,PiSCSINextPart    ; Switch to the next partition
             bra.w PartitionLoop
 
 
 EndPartitions:
-            move.l  #8,PiSCSIDebugMe
+            move.l #8,PiSCSIDebugMe
             move.l a6,a1
-            move.l  #800,PiSCSIDebugMe
+            move.l #800,PiSCSIDebugMe
             movea.l 4,a6
-            move.l  #801,PiSCSIDebugMe
+            move.l #801,PiSCSIDebugMe
             jsr CloseLibrary(a6)
-            move.l  #802,PiSCSIDebugMe
+            move.l #802,PiSCSIDebugMe
 
-            move.l  (a7)+,a6            ; Pop A6 from stack
-            move.l  #803,PiSCSIDebugMe
+            move.l (a7)+,a6             ; Pop A6 from stack
+            move.l #803,PiSCSIDebugMe
 
             move.w #$80B8,$dff09a       ; Re-enable interrupts
-            move.l  #804,PiSCSIDebugMe
+            move.l #804,PiSCSIDebugMe
             moveq.l #1,d0               ; indicate "success"
-            move.l  #805,PiSCSIDebugMe
+            move.l #805,PiSCSIDebugMe
             rts
 
             align 4
@@ -338,17 +406,33 @@ FSResource:     dc.l    $0
 LoadFileSystems:
             movem.l d0-d7/a0-a6,-(sp)       ; Push registers to stack
             move.l #30,PiSCSIDebugMe
+ReloadResource:
             lea FileSysName(pc),a1
             jsr OpenResource(a6)
             tst.l d0
             bne FSRExists
 
             move.l #33,PiSCSIDebugMe        ; FileSystem.resource isn't open, create it
-            lea FSRes(pc),a1
-            move.l a1,-(a7)
-            jsr AddResource(a6)
-            move.l (a7)+,a0
-            move.l a0,d0
+                                            ; Code based on WinUAE filesys.asm
+
+            moveq #32,d0                    ; sizeof(FileSysResource)
+            move.l #$10001,d1
+            jsr AllocMem(a6)
+            move.l d0,a2
+            move.b #8,8(a2)                 ; NT_RESOURCE
+            lea FileSysName(pc),a0
+            move.l a0,10(a2)                ; node name
+            lea FileSysCreator(pc),a0
+            move.l a0,14(a2)                ; fsr_Creator
+            lea 18(a2),a0
+            move.l a0,(a0)                  ; NewList() fsr_FileSysEntries
+            addq.l #4,(a0)
+            move.l a0,8(a0)
+            lea $150(a6),a0                 ; ResourceList
+            move.l a2,a1
+            jsr -$f6(a6)                    ; AddTail
+            move.l a2,a0
+            bra.s ReloadResource
 
 FSRExists:  
             move.l d0,PiSCSIAddr2             ; PiSCSIAddr2 is now FileSystem.resource
@@ -405,7 +489,7 @@ FSDone:     move.l #37,PiSCSIDebugMe
             movem.l (sp)+,d0-d7/a0-a6   ; Pop registers from stack
             bra.w FSLoadExit
 
-FileSysRes
+FSRes
     dc.l    0
     dc.l    0
     dc.b    NT_RESOURCE