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
76 PiSCSIAddr1 EQU $80000010
77 PiSCSIAddr2 EQU $80000014
78 PiSCSIAddr3 EQU $80000018
79 PiSCSIAddr4 EQU $8000001C
80 PiSCSIDebugMe EQU $80000020
81 PiSCSIDriver EQU $80000040
82 PiSCSINextPart EQU $80000044
83 PiSCSIGetPart EQU $80000048
84 PiSCSIGetPrio EQU $8000004C
85 PiSCSIGetFS EQU $80000060
86 PiSCSINextFS EQU $80000064
87 PiSCSICopyFS EQU $80000068
88 PiSCSIFSSize EQU $8000006C
89 PiSCSISetFSH EQU $80000070
90 PiSCSIDbg1 EQU $80001010
91 PiSCSIDbg2 EQU $80001014
92 PiSCSIDbg3 EQU $80001018
93 PiSCSIDbg4 EQU $8000101C
94 PiSCSIDbg5 EQU $80001020
95 PiSCSIDbg6 EQU $80001024
96 PiSCSIDbg7 EQU $80001028
97 PiSCSIDbg8 EQU $8000102C
98 PiSCSIDbgMsg EQU $80001000
100 ******* RomStart ***************************************************
101 **********************************************************************
105 ******* DiagStart **************************************************
106 DiagStart: ; This is the DiagArea structure whose relative offset from
107 ; your board base appears as the Init Diag vector in your
108 ; autoconfig ID information. This structure is designed
109 ; to use all relative pointers (no patching needed).
110 dc.b DAC_WORDWIDE+DAC_CONFIGTIME ; da_Config
113 dc.w DiagEntry-DiagStart ; da_DiagPoint
114 dc.w BootEntry-DiagStart ; da_BootPoint
115 dc.w DevName-DiagStart ; da_Name
116 dc.w 0 ; da_Reserved01
117 dc.w 0 ; da_Reserved02
119 ******* Resident Structure *****************************************
121 dc.w RTC_MATCHWORD ; UWORD RT_MATCHWORD
122 rt_Match: dc.l Romtag-DiagStart ; APTR RT_MATCHTAG
123 rt_End: dc.l EndCopy-DiagStart ; APTR RT_ENDSKIP
124 dc.b RTW_COLDSTART ; UBYTE RT_FLAGS
125 dc.b VERSION ; UBYTE RT_VERSION
126 dc.b NT_DEVICE ; UBYTE RT_TYPE
127 dc.b 20 ; BYTE RT_PRI
128 rt_Name: dc.l DevName-DiagStart ; APTR RT_NAME
129 rt_Id: dc.l IdString-DiagStart ; APTR RT_IDSTRING
130 rt_Init: dc.l Init-RomStart ; APTR RT_INIT
133 ******* Strings referenced in Diag Copy area ************************
134 DevName: dc.b 'pi-scsi.device',0,0 ; Name string
135 IdString dc.b 'PISCSI v0.8',0 ; Id string
137 DosName: dc.b 'dos.library',0 ; DOS library name
138 ExpansionName: dc.b "expansion.library",0
139 LibName: dc.b "pi-scsi.device",0,0
141 DosDevName: dc.b 'ABC',0 ; dos device name for MakeDosNode()
142 ; (dos device will be ABC:)
146 ******* DiagEntry **************************************************
147 **********************************************************************
149 * success = DiagEntry(BoardBase,DiagCopy, configDev)
152 * Called by expansion architecture to relocate any pointers
153 * in the copied diagnostic area. We will patch the romtag.
154 * If you have pre-coded your MakeDosNode packet, BootNode,
155 * or device initialization structures, they would also need
156 * to be within this copy area, and patched by this routine.
158 **********************************************************************
165 move.l #1,PiSCSIDebugMe
166 move.l a3,PiSCSIAddr1
174 lea patchTable-RomStart(a0),a1 ; find patch table
175 adda.l #ROMOFFS,a1 ; adjusting for ROMOFFS
177 * Patch relative pointers to labels within DiagCopy area
178 * by adding Diag RAM copy address. These pointers were coded as
179 * long relative offsets from base of the DiagArea structure.
182 move.l a2,d1 ;d1=base of ram Diag copy
184 move.w (a1)+,d0 ;d0=word offs. into Diag needing patch
185 bmi.s bpatches ;-1 is end of word patch offset table
186 add.l d1,0(a2,d0.w) ;add DiagCopy addr to coded rel. offset
189 * Patches relative pointers to labels within the ROM by adding
190 * the board base address + ROMOFFS. These pointers were coded as
191 * long relative offsets from RomStart.
194 move.l a0,d1 ;d1 = board base address
195 add.l #ROMOFFS,d1 ;add offset to where your ROMs are
197 move.w (a1)+,d0 ;d0=word offs. into Diag needing patch
198 bmi.s endpatches ;-1 is end of patch offset table
199 add.l d1,0(a2,d0.w) ;add ROM address to coded relative offset
203 moveq.l #1,d0 ; indicate "success"
207 ******* BootEntry **************************************************
208 **********************************************************************
212 move.l #2,PiSCSIDebugMe
219 lea DosName(PC),a1 ; 'dos.library',0
220 jsr FindResident(a6) ; find the DOS resident tag
221 move.l d0,a0 ; in order to bootstrap
222 move.l RT_INIT(A0),a0 ; set vector to DOS INIT
223 jsr (a0) ; and initialize DOS
227 * End of the Diag copy area which is copied to RAM
230 *************************************************************************
232 *************************************************************************
234 * Beginning of ROM driver code and data that is accessed only in
235 * the ROM space. This must all be position-independent.
239 * Word offsets into Diag area where pointers need Diag copy address added
240 dc.w rt_Match-DiagStart
241 dc.w rt_End-DiagStart
242 dc.w rt_Name-DiagStart
246 * Word offsets into Diag area where pointers need boardbase+ROMOFFS added
247 dc.w rt_Init-DiagStart
250 ******* Romtag InitEntry **********************************************
251 *************************************************************************
253 Init: ; After Diag patching, our romtag will point to this
254 ; routine in ROM so that it can be called at Resident
255 ; initialization time.
256 ; This routine will be similar to a normal expansion device
257 ; initialization routine, but will MakeDosNode then set up a
258 ; BootNode, and Enqueue() on eb_MountList.
261 move.l a6,-(a7) ; Push A6 to stack
262 move.w #$00B8,$dff09a ; Disable interrupts during init
263 move.l #3,PiSCSIDebugMe
265 move.l #11,PiSCSIDebugMe
269 move.l #10,PiSCSIDebugMe
271 bne.s SkipDriverLoad ; Library is already loaded, jump straight to partitions
273 move.l #4,PiSCSIDebugMe
277 jsr AllocMem(a6) ; Allocate memory for the PiStorm to copy the driver to
279 move.l d0,PiSCSIDriver ; Copy the PiSCSI driver to allocated memory and patch offsets
281 move.l #5,PiSCSIDebugMe
286 jsr InitResident(a6) ; Initialize the PiSCSI driver
289 move.l #9,PiSCSIDebugMe
290 bra.w LoadFileSystems
293 lea ExpansionName(pc),a1
295 jsr OpenLibrary(a6) ; Open expansion.library to make this work, somehow
299 move.l #7,PiSCSIDebugMe
301 move.l PiSCSIGetPart,d0 ; Get the available partition in the current slot
302 beq.w EndPartitions ; If the next partition returns 0, there's no additional partitions
305 move.l d0,PiSCSISetFSH
307 move.l PiSCSIGetPrio,d0
309 move.l PiSCSIAddr1,a1
311 * Uncomment these lines to test AddDosNode/Enqueue stuff
315 ** BOOL AddDosNode( LONG bootPri, ULONG flags, struct DeviceNode *deviceNode );
316 ** amicall(ExpansionBase, 0x96, AddDosNode(d0,d1,a0))
317 * move.l #38,PiSCSIDebugMe
320 ** VOID Enqueue( struct List *list, struct Node *node );
321 ** amicall(SysBase, 0x10e, Enqueue(a0,a1))
325 * move.l #35,PiSCSIDebugMe
326 * move.l #BootNode_SIZEOF,PiSCSIDebugMe
327 * move.l #NT_BOOTNODE,PiSCSIDebugMe
328 * move.l #LN_TYPE,PiSCSIDebugMe
329 * move.l #LN_PRI,PiSCSIDebugMe
330 * move.l #LN_NAME,PiSCSIDebugMe
331 * move.l #eb_MountList,PiSCSIDebugMe
332 * move.l #35,PiSCSIDebugMe
334 * move.l #BootNode_SIZEOF,d0
336 * jsr AllocMem(a6) ; Allocate memory for the BootNode
339 * move.b #NT_BOOTNODE,LN_TYPE(a1)
340 * move.b PiSCSIGetPrio,LN_PRI(a1)
341 * move.l a0,bn_DeviceNode(a1)
342 * move.l PiSCSIAddr1,LN_NAME(a1)
344 * lea eb_MountList(a4),a0
350 * BOOL AddBootNode( LONG bootPri, ULONG flags, struct DeviceNode *deviceNode, struct ConfigDev *configDev );
351 * amicall(ExpansionBase, 0x24, AddBootNode(d0,d1,a0,a1))
352 * Comment out the line below to test AddDosNode/Enqueue stuff
354 move.l #1,PiSCSINextPart ; Switch to the next partition
359 move.l #8,PiSCSIDebugMe
361 move.l #800,PiSCSIDebugMe
363 move.l #801,PiSCSIDebugMe
365 move.l #802,PiSCSIDebugMe
367 move.l (a7)+,a6 ; Pop A6 from stack
368 move.l #803,PiSCSIDebugMe
370 move.w #$80B8,$dff09a ; Re-enable interrupts
371 move.l #804,PiSCSIDebugMe
372 moveq.l #1,d0 ; indicate "success"
373 move.l #805,PiSCSIDebugMe
377 FileSysName dc.b 'FileSystem.resource',0
378 FileSysCreator dc.b 'PiStorm',0
385 movem.l d0-d7/a0-a6,-(sp) ; Push registers to stack
386 move.l #30,PiSCSIDebugMe
387 lea FileSysName(pc),a1
392 move.l #33,PiSCSIDebugMe ; FileSystem.resource isn't open, create it
400 move.l d0,PiSCSIAddr2 ; PiSCSIAddr2 is now FileSystem.resource
401 move.l #31,PiSCSIDebugMe
402 move.l PiSCSIAddr2,a0
403 move.l PiSCSIGetFS,d0
409 move.l #45,PiSCSIDebugMe
410 lea fsr_FileSysEntries(a0),a0
412 move.l LH_HEAD(a0),d0
416 move.l #34,PiSCSIDebugMe
418 move.l #35,PiSCSIDebugMe
419 cmp.l fse_DosType(a1),d7
420 move.l #36,PiSCSIDebugMe
422 move.l #37,PiSCSIDebugMe
423 move.l LN_SUCC(a1),d0
425 move.l #390,PiSCSIDebugMe
430 move.l #39,PiSCSIDebugMe
431 move.l PiSCSIFSSize,d0
432 move.l #40,PiSCSIDebugMe
434 move.l #41,PiSCSIDebugMe
436 move.l d0,PiSCSIAddr3
437 move.l #1,PiSCSICopyFS
440 move.l #480,PiSCSIDebugMe
441 move.l PiSCSIAddr2,a0
442 move.l #1,PiSCSINextFS
443 move.l PiSCSIGetFS,d0
448 FSDone: move.l #37,PiSCSIDebugMe
449 move.l #32,PiSCSIDebugMe ; Couldn't open FileSystem.resource, Kick 1.2/1.3?
451 movem.l (sp)+,d0-d7/a0-a6 ; Pop registers from stack