*
*
* $Header: DH0:src/omti/dist/src/startup/2.0/boot20.a,v 1.1 92/11/25 02:12:14 Barnard Exp $
*
* Die folgende Routine bootet innerhalb des
* Omti-Starttracks von der angegebenen Unit
*
* (C) bsf 1992
*

				NOLIST

				include		"exec/types.i"
				include		"exec/resident.i"
				include		"exec/alerts.i"
				include		"libraries/expansion.i"
				include		"libraries/filehandler.i"

				LIST

SECSIZE			equ 512
NOF_SEC			equ 26

NOF_BOOTNODES	equ	8

SysBase			equ 4

FindResident	equ -96
InitResident	equ -102
Alert			equ	-108
CloseLibrary	equ -414
OpenLibrary		equ -552

MakeDosNode		equ -144
AddDosNode		equ -150


				dc.b	'BOOT'				; Bootbarer Code

*
* startcode wird vom Bootblock oder vom internen Resident
* aufgerufen Code-Pointer in A0
*

* Zuerst das Device initialisieren

startcode		lea		16*SECSIZE-4(a0),a1		; A1 zeigt auf das Device

				move.l	a1,d1				; D1 zeigt auf's Device
				addq.l	#4,d1				; Offset fuer Ladeadresse
				add.l	#8,a1				; 4 Bytes 'fake Seglist' und 4 Bytes Startup-Code
				move.l	SysBase,a6

				move.l	RT_MATCHTAG(a1),d0
				add.l	d1,d0				; Pointer auf Matchtag anpassen
				move.l	d0,RT_MATCHTAG(a1)

				move.l	RT_ENDSKIP(a1),d0
				add.l	d1,d0				; Pointer auf Matchtag anpassen
				move.l	d0,RT_ENDSKIP(a1)

				move.l	RT_NAME(a1),d0
				add.l	d1,d0				; Pointer auf Matchtag anpassen
				move.l	d0,RT_NAME(a1)

				move.l	RT_IDSTRING(a1),d0
				add.l	d1,d0				; Pointer auf Matchtag anpassen
				move.l	d0,RT_IDSTRING(a1)

				move.l	RT_INIT(a1),d0
				add.l	d1,d0				; Pointer auf Matchtag anpassen
				move.l	d0,RT_INIT(a1)

				move.l	d0,a0				; A0 zeigt auf die Init-Tabelle

				move.l	8(a0),d0			; Pointer to DataTab anpassen
				add.l	d1,d0
				move.l	d0,8(a0)

				move.l	12(a0),d0			; Pointer to Init-Routine anpassen
				add.l	d1,d0
				move.l	d0,12(a0)

				move.l	4(a0),d0			; Adresse der Funktions-Tabelle holen
				add.l	d1,d0				; Verschieben
				move.l	d0,4(a0)

				move.l	d0,a0				; A2 zeigt auf die Funktionstabelle
funcloop		move.l	(a0),d0
				cmp.l	#-1,d0				; Ende-Kennung?
				beq.s	endfunctab
				add.l	d1,d0
				move.l	d0,(a0)+
				bra.s	funcloop

endfunctab		jsr		InitResident(a6)	; Device initialisieren

*
* Jetzt die diversen Drives eintragen
*

				lea		ExpansionName(pc),a1
				moveq.l	#0,d0					; Expansion-Lib aufmachen
				jsr		OpenLibrary(a6)
				tst.l	d0
				beq.s	Error
				move.l	d0,a6					; A6 zeigt auf Expansion Lib

				lea		BootNodes(pc),a2
				moveq.l	#NOF_BOOTNODES-1,d2

mountloop		cmp.l	#-1,(a2)				; Mount-Entry ungültig?
				beq.s	nomount

				lea		12(a2),a0				; A0 zeigt auf das Package
				move.l	a2,(a0)					; Name des Drives in das Package
				lea		OmtiName(pc),a1
				move.l	a1,4(a0)				; Name des Devices in das Package
				jsr		MakeDosNode(a6)

				move.l	d0,a0					; A0: Device-Node
				move.l	8(a2),d0				; D0: Boot-Priority
				move.l	#ADNF_STARTPROC,d1		; D1: Flags

				jsr		AddDosNode(a6)			; Dos-Node einbinden

nomount			add.l	#(17+4+1+2)*4,a2		; Size of DosEnVec, 4 Langworte für Package, 1 Langwort für Bootpriority und 8 Zeichen für Device-Name
				dbra.w	d2,mountloop

				move.l	a6,a1
				move.l	SysBase,a6
				jsr		CloseLibrary(a6)

				lea		DosName(pc),a1
				jsr		FindResident(a6)
				move.l	d0,a0
				move.l	RT_INIT(a0),a0
				jsr		(a0)

				rts

Error:			move.l	#AT_DeadEnd!AG_OpenLib!AO_ExpansionLib,d7
				move.l	SysBase,a6
				sub.l	a5,a5
				jmp		Alert(a6)			; Software Error: GURU Meditation...
errloop:		bra.s	errloop

				cnop	0,4

***** Hier folgen die 8 Boot-Nodes *****

BootNodes:

***** Unit 0 ****

part0			dc.b	'DH1',0,0,0,0,0

				dc.l	20			; Boot-Priority

				dc.l	0			; Name of the Drive
				dc.l	0			; Name of the Device
				dc.l	0			; Unit for omti.device (Unit 0)
				dc.l	0			; Flags für OpenDevice

				;STRUCTURE DosEnvec
				dc.l	16			;     ULONG de_TableSize	     ; Size of Environment vector
				dc.l	128			;     ULONG de_SizeBlock	     ; in longwords: standard value is 128
				dc.l	0			;     ULONG de_SecOrg		     ; not used; must be 0
				dc.l	4			;     ULONG de_Surfaces		     ; # of heads (surfaces). drive specific
				dc.l	1			;     ULONG de_SectorPerBlock	 ; not used; must be 1
				dc.l	26			;     ULONG de_BlocksPerTrack	 ; blocks per track. drive specific
				dc.l	2			;     ULONG de_Reserved		     ; DOS reserved blocks at start of partition.
				dc.l	0			;     ULONG de_PreAlloc		     ; DOS reserved blocks at end of partition
				dc.l	0			;     ULONG de_Interleave	     ; usually 0
				dc.l	1			;     ULONG de_LowCyl		     ; starting cylinder. typically 0
				dc.l	300			;     ULONG de_HighCyl		     ; max cylinder. drive specific
				dc.l	30			;     ULONG de_NumBuffers	     ; Initial # DOS of buffers.
				dc.l	1			;     ULONG de_BufMemType	     ; type of mem to allocate for buffers
				dc.l	256			;     ULONG de_MaxTransfer	     ; Max number of bytes to transfer at a time
				dc.l	$fffffffe	;     ULONG de_Mask			     ; Address Mask to block out certain memory
				dc.l	0			;     LONG  de_BootPri		     ; Boot priority for autoboot
				dc.l	$444f5301	;     ULONG de_DosType		     ; ASCII (HEX) string showing filesystem type;

				cnop	0,4
part1			dc.b	'DH2',0,0,0,0,0

				dc.l	-128		; Boot-Priority

				dc.l	0			; Name of the Drive
				dc.l	0			; Name of the Device
				dc.l	0			; Unit for omti.device (Unit 0)
				dc.l	0			; Flags für OpenDevice

				;STRUCTURE DosEnvec
				dc.l	16			;     ULONG de_TableSize	     ; Size of Environment vector
				dc.l	128			;     ULONG de_SizeBlock	     ; in longwords: standard value is 128
				dc.l	0			;     ULONG de_SecOrg		     ; not used; must be 0
				dc.l	4			;     ULONG de_Surfaces		     ; # of heads (surfaces). drive specific
				dc.l	1			;     ULONG de_SectorPerBlock	 ; not used; must be 1
				dc.l	26			;     ULONG de_BlocksPerTrack	 ; blocks per track. drive specific
				dc.l	2			;     ULONG de_Reserved		     ; DOS reserved blocks at start of partition.
				dc.l	0			;     ULONG de_PreAlloc		     ; DOS reserved blocks at end of partition
				dc.l	0			;     ULONG de_Interleave	     ; usually 0
				dc.l	301			;     ULONG de_LowCyl		     ; starting cylinder. typically 0
				dc.l	520			;     ULONG de_HighCyl		     ; max cylinder. drive specific
				dc.l	10			;     ULONG de_NumBuffers	     ; Initial # DOS of buffers.
				dc.l	1			;     ULONG de_BufMemType	     ; type of mem to allocate for buffers
				dc.l	256			;     ULONG de_MaxTransfer	     ; Max number of bytes to transfer at a time
				dc.l	$fffffffe	;     ULONG de_Mask			     ; Address Mask to block out certain memory
				dc.l	0			;     LONG  de_BootPri		     ; Boot priority for autoboot
				dc.l	$444f5301	;     ULONG de_DosType		     ; ASCII (HEX) string showing filesystem type;

				cnop	0,4
part2			dc.b	'DH3',0,0,0,0,0

				dc.l	-128		; Boot-Priority

				dc.l	0			; Name of the Drive
				dc.l	0			; Name of the Device
				dc.l	0			; Unit for omti.device (Unit 0)
				dc.l	0			; Flags für OpenDevice

				;STRUCTURE DosEnvec
				dc.l	16			;     ULONG de_TableSize	     ; Size of Environment vector
				dc.l	128			;     ULONG de_SizeBlock	     ; in longwords: standard value is 128
				dc.l	0			;     ULONG de_SecOrg		     ; not used; must be 0
				dc.l	4			;     ULONG de_Surfaces		     ; # of heads (surfaces). drive specific
				dc.l	1			;     ULONG de_SectorPerBlock	 ; not used; must be 1
				dc.l	26			;     ULONG de_BlocksPerTrack	 ; blocks per track. drive specific
				dc.l	2			;     ULONG de_Reserved		     ; DOS reserved blocks at start of partition.
				dc.l	0			;     ULONG de_PreAlloc		     ; DOS reserved blocks at end of partition
				dc.l	0			;     ULONG de_Interleave	     ; usually 0
				dc.l	521			;     ULONG de_LowCyl		     ; starting cylinder. typically 0
				dc.l	614			;     ULONG de_HighCyl		     ; max cylinder. drive specific
				dc.l	10			;     ULONG de_NumBuffers	     ; Initial # DOS of buffers.
				dc.l	1			;     ULONG de_BufMemType	     ; type of mem to allocate for buffers
				dc.l	256			;     ULONG de_MaxTransfer	     ; Max number of bytes to transfer at a time
				dc.l	$fffffffe	;     ULONG de_Mask			     ; Address Mask to block out certain memory
				dc.l	0			;     LONG  de_BootPri		     ; Boot priority for autoboot
				dc.l	$444f5301	;     ULONG de_DosType		     ; ASCII (HEX) string showing filesystem type;

				cnop	0,4
part3			dc.b	$ff,$ff,$ff,$ff,0,0,0,0

				dc.l	-128		; Boot-Priority

				dc.l	0			; Name of the Drive
				dc.l	0			; Name of the Device
				dc.l	0			; Unit for omti.device (Unit 0)
				dc.l	0			; Flags für OpenDevice

				;STRUCTURE DosEnvec
				dc.l	0 			;     ULONG de_TableSize	     ; Size of Environment vector
				dc.l	0  			;     ULONG de_SizeBlock	     ; in longwords: standard value is 128
				dc.l	0			;     ULONG de_SecOrg		     ; not used; must be 0
				dc.l	0 			;     ULONG de_Surfaces		     ; # of heads (surfaces). drive specific
				dc.l	0			;     ULONG de_SectorPerBlock	 ; not used; must be 1
				dc.l	0 			;     ULONG de_BlocksPerTrack	 ; blocks per track. drive specific
				dc.l	0			;     ULONG de_Reserved		     ; DOS reserved blocks at start of partition.
				dc.l	0			;     ULONG de_PreAlloc		     ; DOS reserved blocks at end of partition
				dc.l	0			;     ULONG de_Interleave	     ; usually 0
				dc.l	0			;     ULONG de_LowCyl		     ; starting cylinder. typically 0
				dc.l	000			;     ULONG de_HighCyl		     ; max cylinder. drive specific
				dc.l	000			;     ULONG de_NumBuffers	     ; Initial # DOS of buffers.
				dc.l	0			;     ULONG de_BufMemType	     ; type of mem to allocate for buffers
				dc.l	000			;     ULONG de_MaxTransfer	     ; Max number of bytes to transfer at a time
				dc.l	0        	;     ULONG de_Mask			     ; Address Mask to block out certain memory
				dc.l	0			;     LONG  de_BootPri		     ; Boot priority for autoboot
				dc.l	0        	;     ULONG de_DosType		     ; ASCII (HEX) string showing filesystem type;

***** Unit 1 ****

				cnop	0,4
part4			dc.b	'DH0',0,0,0,0,0

				dc.l	-128		; Boot-Priority

				dc.l	0			; Name of the Drive
				dc.l	0			; Name of the Device
				dc.l	1			; Unit for omti.device (Unit 0)
				dc.l	0			; Flags für OpenDevice

				;STRUCTURE DosEnvec
				dc.l	16			;     ULONG de_TableSize	     ; Size of Environment vector
				dc.l	128			;     ULONG de_SizeBlock	     ; in longwords: standard value is 128
				dc.l	0			;     ULONG de_SecOrg		     ; not used; must be 0
				dc.l	6			;     ULONG de_Surfaces		     ; # of heads (surfaces). drive specific
				dc.l	1			;     ULONG de_SectorPerBlock	 ; not used; must be 1
				dc.l	26			;     ULONG de_BlocksPerTrack	 ; blocks per track. drive specific
				dc.l	2			;     ULONG de_Reserved		     ; DOS reserved blocks at start of partition.
				dc.l	0			;     ULONG de_PreAlloc		     ; DOS reserved blocks at end of partition
				dc.l	0			;     ULONG de_Interleave	     ; usually 0
				dc.l	1			;     ULONG de_LowCyl		     ; starting cylinder. typically 0
				dc.l	328			;     ULONG de_HighCyl		     ; max cylinder. drive specific
				dc.l	30			;     ULONG de_NumBuffers	     ; Initial # DOS of buffers.
				dc.l	1			;     ULONG de_BufMemType	     ; type of mem to allocate for buffers
				dc.l	256			;     ULONG de_MaxTransfer	     ; Max number of bytes to transfer at a time
				dc.l	$fffffffe	;     ULONG de_Mask			     ; Address Mask to block out certain memory
				dc.l	0			;     LONG  de_BootPri		     ; Boot priority for autoboot
				dc.l	$444f5301	;     ULONG de_DosType		     ; ASCII (HEX) string showing filesystem type;

				cnop	0,4
part5			dc.b	'DH4',0,0,0,0,0

				dc.l	-128		; Boot-Priority

				dc.l	0			; Name of the Drive
				dc.l	0			; Name of the Device
				dc.l	1			; Unit for omti.device (Unit 0)
				dc.l	0			; Flags für OpenDevice

				;STRUCTURE DosEnvec
				dc.l	16			;     ULONG de_TableSize	     ; Size of Environment vector
				dc.l	128			;     ULONG de_SizeBlock	     ; in longwords: standard value is 128
				dc.l	0			;     ULONG de_SecOrg		     ; not used; must be 0
				dc.l	6			;     ULONG de_Surfaces		     ; # of heads (surfaces). drive specific
				dc.l	1			;     ULONG de_SectorPerBlock	 ; not used; must be 1
				dc.l	26			;     ULONG de_BlocksPerTrack	 ; blocks per track. drive specific
				dc.l	2			;     ULONG de_Reserved		     ; DOS reserved blocks at start of partition.
				dc.l	0			;     ULONG de_PreAlloc		     ; DOS reserved blocks at end of partition
				dc.l	0			;     ULONG de_Interleave	     ; usually 0
				dc.l	329			;     ULONG de_LowCyl		     ; starting cylinder. typically 0
				dc.l	812			;     ULONG de_HighCyl		     ; max cylinder. drive specific
				dc.l	100			;     ULONG de_NumBuffers	     ; Initial # DOS of buffers.
				dc.l	1			;     ULONG de_BufMemType	     ; type of mem to allocate for buffers
				dc.l	256			;     ULONG de_MaxTransfer	     ; Max number of bytes to transfer at a time
				dc.l	$fffffffe	;     ULONG de_Mask			     ; Address Mask to block out certain memory
				dc.l	0			;     LONG  de_BootPri		     ; Boot priority for autoboot
				dc.l	$444f5301	;     ULONG de_DosType		     ; ASCII (HEX) string showing filesystem type;

				cnop	0,4
part6			dc.b	$ff,$ff,$ff,$ff,0,0,0,0

				dc.l	-128		; Boot-Priority

				dc.l	0			; Name of the Drive
				dc.l	0			; Name of the Device
				dc.l	0			; Unit for omti.device (Unit 0)
				dc.l	0			; Flags für OpenDevice

				;STRUCTURE DosEnvec
				dc.l	0 			;     ULONG de_TableSize	     ; Size of Environment vector
				dc.l	0  			;     ULONG de_SizeBlock	     ; in longwords: standard value is 128
				dc.l	0			;     ULONG de_SecOrg		     ; not used; must be 0
				dc.l	0 			;     ULONG de_Surfaces		     ; # of heads (surfaces). drive specific
				dc.l	0			;     ULONG de_SectorPerBlock	 ; not used; must be 1
				dc.l	0 			;     ULONG de_BlocksPerTrack	 ; blocks per track. drive specific
				dc.l	0			;     ULONG de_Reserved		     ; DOS reserved blocks at start of partition.
				dc.l	0			;     ULONG de_PreAlloc		     ; DOS reserved blocks at end of partition
				dc.l	0			;     ULONG de_Interleave	     ; usually 0
				dc.l	0			;     ULONG de_LowCyl		     ; starting cylinder. typically 0
				dc.l	000			;     ULONG de_HighCyl		     ; max cylinder. drive specific
				dc.l	000			;     ULONG de_NumBuffers	     ; Initial # DOS of buffers.
				dc.l	0			;     ULONG de_BufMemType	     ; type of mem to allocate for buffers
				dc.l	000			;     ULONG de_MaxTransfer	     ; Max number of bytes to transfer at a time
				dc.l	0        	;     ULONG de_Mask			     ; Address Mask to block out certain memory
				dc.l	0			;     LONG  de_BootPri		     ; Boot priority for autoboot
				dc.l	0        	;     ULONG de_DosType		     ; ASCII (HEX) string showing filesystem type;

				cnop	0,4
part7			dc.b	$ff,$ff,$ff,$ff,0,0,0,0

				dc.l	-128		; Boot-Priority

				dc.l	0			; Name of the Drive
				dc.l	0			; Name of the Device
				dc.l	0			; Unit for omti.device (Unit 0)
				dc.l	0			; Flags für OpenDevice

				;STRUCTURE DosEnvec
				dc.l	0 			;     ULONG de_TableSize	     ; Size of Environment vector
				dc.l	0  			;     ULONG de_SizeBlock	     ; in longwords: standard value is 128
				dc.l	0			;     ULONG de_SecOrg		     ; not used; must be 0
				dc.l	0 			;     ULONG de_Surfaces		     ; # of heads (surfaces). drive specific
				dc.l	0			;     ULONG de_SectorPerBlock	 ; not used; must be 1
				dc.l	0 			;     ULONG de_BlocksPerTrack	 ; blocks per track. drive specific
				dc.l	0			;     ULONG de_Reserved		     ; DOS reserved blocks at start of partition.
				dc.l	0			;     ULONG de_PreAlloc		     ; DOS reserved blocks at end of partition
				dc.l	0			;     ULONG de_Interleave	     ; usually 0
				dc.l	0			;     ULONG de_LowCyl		     ; starting cylinder. typically 0
				dc.l	000			;     ULONG de_HighCyl		     ; max cylinder. drive specific
				dc.l	000			;     ULONG de_NumBuffers	     ; Initial # DOS of buffers.
				dc.l	0			;     ULONG de_BufMemType	     ; type of mem to allocate for buffers
				dc.l	000			;     ULONG de_MaxTransfer	     ; Max number of bytes to transfer at a time
				dc.l	0        	;     ULONG de_Mask			     ; Address Mask to block out certain memory
				dc.l	0			;     LONG  de_BootPri		     ; Boot priority for autoboot
				dc.l	0        	;     ULONG de_DosType		     ; ASCII (HEX) string showing filesystem type;

				cnop	0,2
DosName:		dc.b	'dos.library',0
				cnop	0,2
ExpansionName:	dc.b	'expansion.library',0
				cnop	0,2
OmtiName:		dc.b	'omti.device',0

				END
