<commit_before>
	include 68kdefines.i
	include	exec/exec_lib.i
	include exec/initializers.i
	include	exec/nodes.i
	include exec/libraries.i
	include exec/resident.i
	include	exec/memory.i
	include pci.i
	include	libraries/expansion_lib.i
	include	libraries/configvars.i
	include	exec/execbase.i
	include powerpc/powerpc.i
	include powerpc/tasksPPC.i
	include	dos/dostags.i
	include dos/dos_lib.i
	include intuition/intuition_lib.i
	include exec/ports.i
	include dos/dosextens.i
	include	exec/interrupts.i
	include hardware/intbits.i
	include	exec/tasks.i
	include sonnet_lib.i

	XREF	SetExcMMU,ClearExcMMU,InsertPPC,AddHeadPPC,AddTailPPC
	XREF	RemovePPC,RemHeadPPC,RemTailPPC,EnqueuePPC,FindNamePPC,ResetPPC,NewListPPC
	XREF	AddTimePPC,SubTimePPC,CmpTimePPC,AllocVecPPC,FreeVecPPC,GetInfo,GetSysTimePPC
	XREF	NextTagItemPPC,GetTagDataPPC,FindTagItemPPC,FreeSignalPPC
	XREF	AllocXMsgPPC,FreeXMsgPPC,CreateMsgPortPPC,DeleteMsgPortPPC,AllocSignalPPC
	XREF	SetSignalPPC,LockTaskList,UnLockTaskList
	XREF	InitSemaphorePPC,FreeSemaphorePPC,ObtainSemaphorePPC,AttemptSemaphorePPC
	XREF	ReleaseSemaphorePPC,AddSemaphorePPC,RemSemaphorePPC,FindSemaphorePPC
	XREF	AddPortPPC,RemPortPPC,FindPortPPC,WaitPortPPC,Super,User
	XREF	PutXMsgPPC,WaitFor68K,Run68K,Signal68K,CopyMemPPC,SetReplyPortPPC
	XREF	TrySemaphorePPC,CreatePoolPPC

	XREF	SPrintF,Run68KLowLevel,CreateTaskPPC,DeleteTaskPPC,FindTaskPPC,SignalPPC
	XREF	WaitPPC,SetTaskPriPPC,SetCache,SetExcHandler,RemExcHandler,SetHardware
	XREF	ModifyFPExc,WaitTime,ChangeStack,ChangeMMU,PutMsgPPC,GetMsgPPC,ReplyMsgPPC
	XREF	FreeAllMem,SnoopTask,EndSnoopTask,GetHALInfo,SetScheduling,FindTaskByID
	XREF	SetNiceValue,AllocPrivateMem,FreePrivateMem,SetExceptPPC,ObtainSemaphoreSharedPPC
	XREF	AttemptSemaphoreSharedPPC,ProcurePPC,VacatePPC,CauseInterrupt,DeletePoolPPC
	XREF	AllocPooledPPC,FreePooledPPC,RawDoFmtPPC,PutPublicMsgPPC,AddUniquePortPPC
	XREF	AddUniqueSemaphorePPC,IsExceptionMode,CreateMsgFramePPC,SendMsgFramePPC
	XREF	FreeMsgFramePPC
	
	IFD	_IFUSION_
	
	XREF	WarpIllegal
	
	ENDC

	XREF 	PPCCode,PPCLen,MCPort,Init,SysBase,PowerPCBase,DOSBase,sonnet_PosSize
	XDEF	_PowerPCBase,FunctionsLen,LibFunctions

;********************************************************************************************

	SECTION LibBody,CODE

;********************************************************************************************


		moveq.l #-1,d0
		rts

ROMTAG:
		dc.w	RTC_MATCHWORD
		dc.l	ROMTAG
		dc.l	ENDSKIP
		dc.b	0					;WAS RTF_AUTOINIT
		dc.b	17					;RT_VERSION
		dc.b	NT_LIBRARY				;RT_TYPE
		dc.b	0					;RT_PRI
		dc.l	LibName
		dc.l	IDString
		dc.l	LIBINIT

ENDSKIP:
		ds.w	1

LIBINIT:
		movem.l d1-a6,-(a7)
		move.l 4.w,a6
		lea Buffer(pc),a4
		move.l a0,(a4)				;SegList
		move.l a6,LExecBase-Buffer(a4)

		lea LibList(a6),a0
		lea PowerName(pc),a1			;Check for WarpOS
		jsr _LVOFindName(a6)
		tst.l d0
		beq.s NoWOS

		lea PowerPCError(pc),a2
		bra PrintError

NoWOS		lea DosLib(pc),a1
		moveq.l #37,d0
		jsr _LVOOpenLibrary(a6)
		tst.l d0
		bne GotDOS				;Open dos.library
		
		lea LDOSError(pc),a2
		bra PrintError
		
GotDOS		move.l d0,DosBase-Buffer(a4)
		lea ExpLib(pc),a1
		moveq.l #37,d0
		jsr _LVOOpenLibrary(a6)			;Open expansion.library
		tst.l d0
		bne.s GotExp

		lea LExpError(pc),a2
		bra PrintError		
	
GotExp		move.l d0,ExpBase-Buffer(a4)
		move.l d0,a6
		sub.l a0,a0
		move.l #VENDOR_ELBOX,d0			;ELBOX
		moveq.l #MEDIATOR_MKII,d1		;Mediator MKII
		jsr _LVOFindConfigDev(a6)		;Find A3000/A4000 mediator
		tst.l d0
		bne.s FoundMed
		
WeirdMed	lea MedError(pc),a2
		bra PrintError

FoundMed	sub.l a0,a0
		move.l #VENDOR_ELBOX,d0			;ELBOX
		move.l #MEDIATOR_LOGIC,d1		;Mediator Logic board for A3/4000
		jsr _LVOFindConfigDev(a6)
		tst.l d0
		beq.s WeirdMed

		move.l d0,a1
		move.l LExecBase(pc),a6
		move.l cd_BoardAddr(a1),d0		;Start address Configspace Mediator
		cmp.l #$60000000,d0			;MemorySpace at default position?
		beq CorrectConfigJ

		lea MedConfigJ(pc),a2
		bra PrintError

CorrectConfigJ	move.l cd_BoardSize(a1),d0
		cmp.l #$20000000,d0			;WindowSize 512MB?
		beq CorrectWindowJ

		lea MedWindowJ(pc),a2
		bra PrintError

CorrectWindowJ	lea MemList(a6),a0
		lea MemName(pc),a1
		jsr _LVOFindName(a6)			;Check for sonnet memory
		tst.l d0
		bne.s Clean

		moveq.l #PCI_VERSION,d0			;Minimal version of pci.library
		lea pcilib(pc),a1
		jsr _LVOOpenLibrary(a6)
		move.l d0,PCIBase-Buffer(a4)

		lea MemList(a6),a0
		lea PCIMem(pc),a1			;Check for PCI DMA (GFX) memory
		jsr _LVOFindName(a6)
		tst.l d0
		bne.s FndMem

		lea MemMedError(pc),a2
		bra PrintError
<commit_msg>Check for windowsize first, then configspace. Configspace is always wrong when windowsize is incorrect.<commit_after>
	include 68kdefines.i
	include	exec/exec_lib.i
	include exec/initializers.i
	include	exec/nodes.i
	include exec/libraries.i
	include exec/resident.i
	include	exec/memory.i
	include pci.i
	include	libraries/expansion_lib.i
	include	libraries/configvars.i
	include	exec/execbase.i
	include powerpc/powerpc.i
	include powerpc/tasksPPC.i
	include	dos/dostags.i
	include dos/dos_lib.i
	include intuition/intuition_lib.i
	include exec/ports.i
	include dos/dosextens.i
	include	exec/interrupts.i
	include hardware/intbits.i
	include	exec/tasks.i
	include sonnet_lib.i

	XREF	SetExcMMU,ClearExcMMU,InsertPPC,AddHeadPPC,AddTailPPC
	XREF	RemovePPC,RemHeadPPC,RemTailPPC,EnqueuePPC,FindNamePPC,ResetPPC,NewListPPC
	XREF	AddTimePPC,SubTimePPC,CmpTimePPC,AllocVecPPC,FreeVecPPC,GetInfo,GetSysTimePPC
	XREF	NextTagItemPPC,GetTagDataPPC,FindTagItemPPC,FreeSignalPPC
	XREF	AllocXMsgPPC,FreeXMsgPPC,CreateMsgPortPPC,DeleteMsgPortPPC,AllocSignalPPC
	XREF	SetSignalPPC,LockTaskList,UnLockTaskList
	XREF	InitSemaphorePPC,FreeSemaphorePPC,ObtainSemaphorePPC,AttemptSemaphorePPC
	XREF	ReleaseSemaphorePPC,AddSemaphorePPC,RemSemaphorePPC,FindSemaphorePPC
	XREF	AddPortPPC,RemPortPPC,FindPortPPC,WaitPortPPC,Super,User
	XREF	PutXMsgPPC,WaitFor68K,Run68K,Signal68K,CopyMemPPC,SetReplyPortPPC
	XREF	TrySemaphorePPC,CreatePoolPPC

	XREF	SPrintF,Run68KLowLevel,CreateTaskPPC,DeleteTaskPPC,FindTaskPPC,SignalPPC
	XREF	WaitPPC,SetTaskPriPPC,SetCache,SetExcHandler,RemExcHandler,SetHardware
	XREF	ModifyFPExc,WaitTime,ChangeStack,ChangeMMU,PutMsgPPC,GetMsgPPC,ReplyMsgPPC
	XREF	FreeAllMem,SnoopTask,EndSnoopTask,GetHALInfo,SetScheduling,FindTaskByID
	XREF	SetNiceValue,AllocPrivateMem,FreePrivateMem,SetExceptPPC,ObtainSemaphoreSharedPPC
	XREF	AttemptSemaphoreSharedPPC,ProcurePPC,VacatePPC,CauseInterrupt,DeletePoolPPC
	XREF	AllocPooledPPC,FreePooledPPC,RawDoFmtPPC,PutPublicMsgPPC,AddUniquePortPPC
	XREF	AddUniqueSemaphorePPC,IsExceptionMode,CreateMsgFramePPC,SendMsgFramePPC
	XREF	FreeMsgFramePPC
	
	IFD	_IFUSION_
	
	XREF	WarpIllegal
	
	ENDC

	XREF 	PPCCode,PPCLen,MCPort,Init,SysBase,PowerPCBase,DOSBase,sonnet_PosSize
	XDEF	_PowerPCBase,FunctionsLen,LibFunctions

;********************************************************************************************

	SECTION LibBody,CODE

;********************************************************************************************


		moveq.l #-1,d0
		rts

ROMTAG:
		dc.w	RTC_MATCHWORD
		dc.l	ROMTAG
		dc.l	ENDSKIP
		dc.b	0					;WAS RTF_AUTOINIT
		dc.b	17					;RT_VERSION
		dc.b	NT_LIBRARY				;RT_TYPE
		dc.b	0					;RT_PRI
		dc.l	LibName
		dc.l	IDString
		dc.l	LIBINIT

ENDSKIP:
		ds.w	1

LIBINIT:
		movem.l d1-a6,-(a7)
		move.l 4.w,a6
		lea Buffer(pc),a4
		move.l a0,(a4)				;SegList
		move.l a6,LExecBase-Buffer(a4)

		lea LibList(a6),a0
		lea PowerName(pc),a1			;Check for WarpOS
		jsr _LVOFindName(a6)
		tst.l d0
		beq.s NoWOS

		lea PowerPCError(pc),a2
		bra PrintError

NoWOS		lea DosLib(pc),a1
		moveq.l #37,d0
		jsr _LVOOpenLibrary(a6)
		tst.l d0
		bne GotDOS				;Open dos.library
		
		lea LDOSError(pc),a2
		bra PrintError
		
GotDOS		move.l d0,DosBase-Buffer(a4)
		lea ExpLib(pc),a1
		moveq.l #37,d0
		jsr _LVOOpenLibrary(a6)			;Open expansion.library
		tst.l d0
		bne.s GotExp

		lea LExpError(pc),a2
		bra PrintError		
	
GotExp		move.l d0,ExpBase-Buffer(a4)
		move.l d0,a6
		sub.l a0,a0
		move.l #VENDOR_ELBOX,d0			;ELBOX
		moveq.l #MEDIATOR_MKII,d1		;Mediator MKII
		jsr _LVOFindConfigDev(a6)		;Find A3000/A4000 mediator
		tst.l d0
		bne.s FoundMed
		
WeirdMed	lea MedError(pc),a2
		bra PrintError

FoundMed	sub.l a0,a0
		move.l #VENDOR_ELBOX,d0			;ELBOX
		move.l #MEDIATOR_LOGIC,d1		;Mediator Logic board for A3/4000
		jsr _LVOFindConfigDev(a6)
		tst.l d0
		beq.s WeirdMed

		move.l d0,a1
		move.l LExecBase(pc),a6
		move.l cd_BoardSize(a1),d0		;Start address Configspace Mediator
		cmp.l #$20000000,d0
		beq CorrectWindowJ			;WindowSize 512MB?

		lea MedWindowJ(pc),a2
		bra PrintError

CorrectWindowJ	move.l cd_BoardAddr(a1),d0
		cmp.l #$60000000,d0
		beq CorrectConfigJ			;MemorySpace at default position?

		lea MedConfigJ(pc),a2
		bra PrintError

CorrectConfigJ	lea MemList(a6),a0
		lea MemName(pc),a1
		jsr _LVOFindName(a6)			;Check for sonnet memory
		tst.l d0
		bne.s Clean

		moveq.l #PCI_VERSION,d0			;Minimal version of pci.library
		lea pcilib(pc),a1
		jsr _LVOOpenLibrary(a6)
		move.l d0,PCIBase-Buffer(a4)

		lea MemList(a6),a0
		lea PCIMem(pc),a1			;Check for PCI DMA (GFX) memory
		jsr _LVOFindName(a6)
		tst.l d0
		bne.s FndMem

		lea MemMedError(pc),a2
		bra PrintError

{'fraction_non_alphanumeric': 0.11484868277814064, 'fraction_numerical': 0.027215327672545177, 'mean_word_length': 5.327134986225896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1732425', 'n_tokens_mistral': 4380, 'n_tokens_neox': 4011, 'n_words': 657}