2 ** Sample autoboot code fragment
4 ** These are the calling conventions for the Diag routine
6 ** A7 -- points to at least 2K of stack
9 ** A3 -- your board's ConfigDev structure
10 ** A2 -- Base of diag/init area that was copied
11 ** A0 -- Base of your board
13 ** Your Diag routine should return a non-zero value in D0 for success.
14 ** If this value is NULL, then the diag/init area that was copied
15 ** will be returned to the free memory pool.
18 INCLUDE "exec/types.i"
19 INCLUDE "exec/nodes.i"
20 INCLUDE "exec/resident.i"
21 INCLUDE "libraries/configvars.i"
22 INCLUDE "libraries/expansionbase.i"
24 ; LVO's resolved by linking with library amiga.lib
30 * ROMINFO defines whether you want the AUTOCONFIG information in
31 * the beginning of your ROM (set to 0 if you instead have PALS
32 * providing the AUTOCONFIG information instead)
34 * ROMOFFS is the offset from your board base where your ROMs appear.
35 * Your ROMs might appear at offset 0 and contain your AUTOCONFIG
36 * information in the high nibbles of the first $40 words ($80 bytes).
37 * Or, your autoconfig ID information may be in a PAL, with your
38 * ROMs possibly being addressed at some offset (for example $2000)
39 * from your board base. This ROMOFFS constant will be used as an
40 * additional offset from your configured board address when patching
41 * structures which require absolute pointers to ROM code or data.
43 *----- We'll store Version and Revision in serial number
44 VERSION EQU 37 ; also the high word of serial number
45 REVISION EQU 1 ; also the low word of serial number
47 * See the Addison-Wesley Amiga Hardware Manual for more info.
49 MANUF_ID EQU 2011 ; CBM assigned (2011 for hackers only)
50 PRODUCT_ID EQU 1 ; Manufacturer picks product ID
52 BOARDSIZE EQU $10000 ; How much address space board decodes
53 SIZE_FLAG EQU 3 ; Autoconfig 3-bit flag for BOARDSIZE
54 ; 0=$800000(8meg) 4=$80000(512K)
55 ; 1=$10000(64K) 5=$100000(1meg)
56 ; 2=$20000(128K) 6=$200000(2meg)
57 ; 3=$40000(256K) 7=$400000(4meg)
66 OpenResource EQU -$1F2
77 PiSCSIAddr1 EQU $80000010
78 PiSCSIAddr2 EQU $80000014
79 PiSCSIAddr3 EQU $80000018
80 PiSCSIAddr4 EQU $8000001C
81 PiSCSIDebugMe EQU $80000020
82 PiSCSIDriver EQU $80000040
83 PiSCSINextPart EQU $80000044
84 PiSCSIGetPart EQU $80000048
85 PiSCSIGetPrio EQU $8000004C
86 PiSCSIGetFS EQU $80000060
87 PiSCSINextFS EQU $80000064
88 PiSCSICopyFS EQU $80000068
89 PiSCSIFSSize EQU $8000006C
90 PiSCSISetFSH EQU $80000070
91 PiSCSIDbg1 EQU $80001010
92 PiSCSIDbg2 EQU $80001014
93 PiSCSIDbg3 EQU $80001018
94 PiSCSIDbg4 EQU $8000101C
95 PiSCSIDbg5 EQU $80001020
96 PiSCSIDbg6 EQU $80001024
97 PiSCSIDbg7 EQU $80001028
98 PiSCSIDbg8 EQU $8000102C
99 PiSCSIDbgMsg EQU $80001000
101 ******* RomStart ***************************************************
102 **********************************************************************
106 ******* DiagStart **************************************************
107 DiagStart: ; This is the DiagArea structure whose relative offset from
108 ; your board base appears as the Init Diag vector in your
109 ; autoconfig ID information. This structure is designed
110 ; to use all relative pointers (no patching needed).
111 dc.b DAC_WORDWIDE+DAC_CONFIGTIME ; da_Config
114 dc.w DiagEntry-DiagStart ; da_DiagPoint
115 dc.w BootEntry-DiagStart ; da_BootPoint
116 dc.w DevName-DiagStart ; da_Name
117 dc.w 0 ; da_Reserved01
118 dc.w 0 ; da_Reserved02
120 ******* Resident Structure *****************************************
122 dc.w RTC_MATCHWORD ; UWORD RT_MATCHWORD
123 rt_Match: dc.l Romtag-DiagStart ; APTR RT_MATCHTAG
124 rt_End: dc.l EndCopy-DiagStart ; APTR RT_ENDSKIP
125 dc.b RTW_COLDSTART ; UBYTE RT_FLAGS
126 dc.b VERSION ; UBYTE RT_VERSION
127 dc.b NT_DEVICE ; UBYTE RT_TYPE
128 dc.b 20 ; BYTE RT_PRI
129 rt_Name: dc.l DevName-DiagStart ; APTR RT_NAME
130 rt_Id: dc.l IdString-DiagStart ; APTR RT_IDSTRING
131 rt_Init: dc.l Init-RomStart ; APTR RT_INIT
134 ******* Strings referenced in Diag Copy area ************************
135 DevName: dc.b 'pi-scsi.device',0,0 ; Name string
136 IdString dc.b 'PISCSI v0.8',0 ; Id string
138 DosName: dc.b 'dos.library',0 ; DOS library name
139 ExpansionName: dc.b "expansion.library",0
140 LibName: dc.b "pi-scsi.device",0,0
142 DosDevName: dc.b 'ABC',0 ; dos device name for MakeDosNode()
143 ; (dos device will be ABC:)
147 ******* DiagEntry **************************************************
148 **********************************************************************
150 * success = DiagEntry(BoardBase,DiagCopy, configDev)
153 * Called by expansion architecture to relocate any pointers
154 * in the copied diagnostic area. We will patch the romtag.
155 * If you have pre-coded your MakeDosNode packet, BootNode,
156 * or device initialization structures, they would also need
157 * to be within this copy area, and patched by this routine.
159 **********************************************************************
166 move.l #1,PiSCSIDebugMe
167 move.l a3,PiSCSIAddr1
175 lea patchTable-RomStart(a0),a1 ; find patch table
176 adda.l #ROMOFFS,a1 ; adjusting for ROMOFFS
178 * Patch relative pointers to labels within DiagCopy area
179 * by adding Diag RAM copy address. These pointers were coded as
180 * long relative offsets from base of the DiagArea structure.
183 move.l a2,d1 ;d1=base of ram Diag copy
185 move.w (a1)+,d0 ;d0=word offs. into Diag needing patch
186 bmi.s bpatches ;-1 is end of word patch offset table
187 add.l d1,0(a2,d0.w) ;add DiagCopy addr to coded rel. offset
190 * Patches relative pointers to labels within the ROM by adding
191 * the board base address + ROMOFFS. These pointers were coded as
192 * long relative offsets from RomStart.
195 move.l a0,d1 ;d1 = board base address
196 add.l #ROMOFFS,d1 ;add offset to where your ROMs are
198 move.w (a1)+,d0 ;d0=word offs. into Diag needing patch
199 bmi.s endpatches ;-1 is end of patch offset table
200 add.l d1,0(a2,d0.w) ;add ROM address to coded relative offset
204 moveq.l #1,d0 ; indicate "success"
208 ******* BootEntry **************************************************
209 **********************************************************************
213 move.l #2,PiSCSIDebugMe
219 move.l RT_INIT(a0),a0
222 moveq.l #1,d0 ; indicate "success"
226 * End of the Diag copy area which is copied to RAM
229 *************************************************************************
231 *************************************************************************
233 * Beginning of ROM driver code and data that is accessed only in
234 * the ROM space. This must all be position-independent.
238 * Word offsets into Diag area where pointers need Diag copy address added
239 dc.w rt_Match-DiagStart
240 dc.w rt_End-DiagStart
241 dc.w rt_Name-DiagStart
245 * Word offsets into Diag area where pointers need boardbase+ROMOFFS added
246 dc.w rt_Init-DiagStart
249 ******* Romtag InitEntry **********************************************
250 *************************************************************************
252 Init: ; After Diag patching, our romtag will point to this
253 ; routine in ROM so that it can be called at Resident
254 ; initialization time.
255 ; This routine will be similar to a normal expansion device
256 ; initialization routine, but will MakeDosNode then set up a
257 ; BootNode, and Enqueue() on eb_MountList.
260 move.l a6,-(a7) ; Push A6 to stack
261 move.w #$00B8,$dff09a ; Disable interrupts during init
262 move.l #3,PiSCSIDebugMe
263 move.l a3,PiSCSIAddr4
268 move.l #$feffeeff,$10000040
274 move.l #$8000000,d0 ; Add some Z3 fast RAM if it hasn't been moved (Kick 1.3)
282 move.l #11,PiSCSIDebugMe
285 move.l #10,PiSCSIDebugMe
287 bne.s SkipDriverLoad ; Library is already loaded, jump straight to partitions
289 move.l #4,PiSCSIDebugMe
293 jsr AllocMem(a6) ; Allocate memory for the PiStorm to copy the driver to
295 move.l d0,PiSCSIDriver ; Copy the PiSCSI driver to allocated memory and patch offsets
297 move.l #5,PiSCSIDebugMe
302 jsr InitResident(a6) ; Initialize the PiSCSI driver
305 move.l #9,PiSCSIDebugMe
306 bra.w LoadFileSystems
309 lea ExpansionName(pc),a1
311 jsr OpenLibrary(a6) ; Open expansion.library to make this work, somehow
315 move.l #7,PiSCSIDebugMe
317 move.l PiSCSIGetPart,d0 ; Get the available partition in the current slot
318 beq.w EndPartitions ; If the next partition returns 0, there's no additional partitions
321 move.l d0,PiSCSISetFSH
322 move.l d0,PiSCSIAddr2 ; Put DeviceNode address in PiSCSIAddr2, because I'm useless
324 move.l PiSCSIGetPrio,d0
326 move.l PiSCSIAddr1,a1
328 * Uncomment these lines to test AddDosNode/Enqueue stuff
329 * Or comment them out all the way down to and including SkipEnqueue: to use the AddBootNode method instead.
333 * BOOL AddDosNode( LONG bootPri, ULONG flags, struct DeviceNode *deviceNode );
334 * amicall(ExpansionBase, 0x96, AddDosNode(d0,d1,a0))
335 move.l #38,PiSCSIDebugMe
338 * VOID Enqueue( struct List *list, struct Node *node );
339 * amicall(SysBase, 0x10e, Enqueue(a0,a1))
343 move.l #35,PiSCSIDebugMe
344 move.l #BootNode_SIZEOF,PiSCSIDebugMe
345 move.l #NT_BOOTNODE,PiSCSIDebugMe
346 move.l #LN_TYPE,PiSCSIDebugMe
347 move.l #LN_PRI,PiSCSIDebugMe
348 move.l #LN_NAME,PiSCSIDebugMe
349 move.l #eb_MountList,PiSCSIDebugMe
350 move.l #35,PiSCSIDebugMe
352 move.l #BootNode_SIZEOF,d0
354 jsr AllocMem(a6) ; Allocate memory for the BootNode
356 move.l d0,PiSCSIAddr3
357 move.l #36,PiSCSIDebugMe
360 move.b #NT_BOOTNODE,LN_TYPE(a1)
361 move.l PiSCSIGetPrio,d0
363 move.l PiSCSIAddr2,bn_DeviceNode(a1)
364 move.l PiSCSIAddr1,LN_NAME(a1)
366 lea eb_MountList(a4),a0
372 * BOOL AddBootNode( LONG bootPri, ULONG flags, struct DeviceNode *deviceNode, struct ConfigDev *configDev );
373 * amicall(ExpansionBase, 0x24, AddBootNode(d0,d1,a0,a1))
374 * Comment out the line below to test AddDosNode/Enqueue stuff
375 * jsr AddBootNode(a6)
376 move.l #1,PiSCSINextPart ; Switch to the next partition
381 move.l #8,PiSCSIDebugMe
383 move.l #800,PiSCSIDebugMe
385 move.l #801,PiSCSIDebugMe
387 move.l #802,PiSCSIDebugMe
389 move.l (a7)+,a6 ; Pop A6 from stack
390 move.l #803,PiSCSIDebugMe
392 move.w #$80B8,$dff09a ; Re-enable interrupts
393 move.l #804,PiSCSIDebugMe
394 moveq.l #1,d0 ; indicate "success"
395 move.l #805,PiSCSIDebugMe
399 FileSysName dc.b 'FileSystem.resource',0
400 FileSysCreator dc.b 'PiStorm',0
407 movem.l d0-d7/a0-a6,-(sp) ; Push registers to stack
408 move.l #30,PiSCSIDebugMe
410 lea FileSysName(pc),a1
415 move.l #33,PiSCSIDebugMe ; FileSystem.resource isn't open, create it
416 ; Code based on WinUAE filesys.asm
418 moveq #32,d0 ; sizeof(FileSysResource)
422 move.b #8,8(a2) ; NT_RESOURCE
423 lea FileSysName(pc),a0
424 move.l a0,10(a2) ; node name
425 lea FileSysCreator(pc),a0
426 move.l a0,14(a2) ; fsr_Creator
428 move.l a0,(a0) ; NewList() fsr_FileSysEntries
431 lea $150(a6),a0 ; ResourceList
433 jsr -$f6(a6) ; AddTail
438 move.l d0,PiSCSIAddr2 ; PiSCSIAddr2 is now FileSystem.resource
439 move.l #31,PiSCSIDebugMe
440 move.l PiSCSIAddr2,a0
441 move.l PiSCSIGetFS,d0
447 move.l #45,PiSCSIDebugMe
448 lea fsr_FileSysEntries(a0),a0
450 move.l LH_HEAD(a0),d0
454 move.l #34,PiSCSIDebugMe
456 move.l #35,PiSCSIDebugMe
457 cmp.l fse_DosType(a1),d7
458 move.l #36,PiSCSIDebugMe
460 move.l #37,PiSCSIDebugMe
461 move.l LN_SUCC(a1),d0
463 move.l #390,PiSCSIDebugMe
468 move.l #39,PiSCSIDebugMe
469 move.l PiSCSIFSSize,d0
470 move.l #40,PiSCSIDebugMe
472 move.l #41,PiSCSIDebugMe
474 move.l d0,PiSCSIAddr3
475 move.l #1,PiSCSICopyFS
478 move.l #480,PiSCSIDebugMe
479 move.l PiSCSIAddr2,a0
480 move.l #1,PiSCSINextFS
481 move.l PiSCSIGetFS,d0
486 FSDone: move.l #37,PiSCSIDebugMe
487 move.l #32,PiSCSIDebugMe ; Couldn't open FileSystem.resource, Kick 1.2/1.3?
489 movem.l (sp)+,d0-d7/a0-a6 ; Pop registers from stack