	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function uninorth_agp_enable
_uninorth_agp_enable:                   ## @uninorth_agp_enable
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %r14d
	movq	%rdi, %rbx
	movq	(%rdi), %rdi
	movq	_PCI_AGP_STATUS@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	8(%rbx), %rsi
	leaq	-44(%rbp), %rdx
	callq	_pci_read_config_dword
	movl	-44(%rbp), %edx
	movq	%rbx, %rdi
	movl	%r14d, %esi
	callq	_agp_collect_device_status
	movq	_PCI_AGP_COMMAND_AGP@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movq	_uninorth_rev@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	cmpl	$33, %ecx
	movq	_AGPSTAT2_4X@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	notl	%edx
	movl	$-1, %r14d
	cmovel	%edx, %r14d
	andl	%eax, %r14d
	andl	$-4, %ecx
	cmpl	$48, %ecx
	jne	LBB0_3
## %bb.1:
	movq	_AGPSTAT_RQ_DEPTH_SHIFT@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movl	%r14d, %eax
	sarl	%cl, %eax
	cmpl	$8, %eax
	jl	LBB0_3
## %bb.2:
	movq	_AGPSTAT_RQ_DEPTH@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	notl	%eax
	andl	%eax, %r14d
	movl	$7, %eax
                                        ## kill: def $cl killed $cl killed $ecx
	shll	%cl, %eax
	orl	%eax, %r14d
LBB0_3:
	xorl	%r12d, %r12d
	xorl	%edi, %edi
	callq	_uninorth_tlbflush
	movq	_PCI_AGP_COMMAND@GOTPCREL(%rip), %r13
	leaq	-48(%rbp), %r15
	.p2align	4, 0x90
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	movq	(%rbx), %rdi
	movq	(%r13), %rsi
	addq	8(%rbx), %rsi
	movl	%r14d, %edx
	callq	_pci_write_config_dword
	movq	(%rbx), %rdi
	movq	(%r13), %rsi
	addq	8(%rbx), %rsi
	movq	%r15, %rdx
	callq	_pci_read_config_dword
	movq	_PCI_AGP_COMMAND_AGP@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	andl	-48(%rbp), %eax
	jne	LBB0_6
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=1
	leal	1(%r12), %ecx
	cmpl	$999, %r12d                     ## imm = 0x3E7
	movl	%ecx, %r12d
	jb	LBB0_4
LBB0_6:
	testl	%eax, %eax
	jne	LBB0_8
## %bb.7:
	movq	(%rbx), %rdi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
LBB0_8:
	xorl	%esi, %esi
	movq	_uninorth_rev@GOTPCREL(%rip), %rax
	cmpl	$48, (%rax)
	jl	LBB0_10
## %bb.9:
	movq	_AGPSTAT_MODE_3_0@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	xorl	%esi, %esi
	testl	%eax, -44(%rbp)
	setne	%sil
LBB0_10:
	movl	%r14d, %edi
	callq	_agp_device_command
	xorl	%edi, %edi
	callq	_uninorth_tlbflush
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_PCI_AGP_STATUS,8,3             ## @PCI_AGP_STATUS
	.comm	_PCI_AGP_COMMAND_AGP,4,2        ## @PCI_AGP_COMMAND_AGP
	.comm	_uninorth_rev,4,2               ## @uninorth_rev
	.comm	_AGPSTAT2_4X,4,2                ## @AGPSTAT2_4X
	.comm	_AGPSTAT_RQ_DEPTH_SHIFT,4,2     ## @AGPSTAT_RQ_DEPTH_SHIFT
	.comm	_AGPSTAT_RQ_DEPTH,4,2           ## @AGPSTAT_RQ_DEPTH
	.comm	_PCI_AGP_COMMAND,8,3            ## @PCI_AGP_COMMAND
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"can't write UniNorth AGP command register\n"

	.comm	_AGPSTAT_MODE_3_0,4,2           ## @AGPSTAT_MODE_3_0
	.no_dead_strip	_uninorth_agp_enable
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function uninorth_agp_enable
_uninorth_agp_enable:                   ; @uninorth_agp_enable
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	mov	x20, x1
	mov	x19, x0
	ldr	x0, [x0]
	ldr	x8, [x19, #8]
Lloh0:
	adrp	x9, _PCI_AGP_STATUS@GOTPAGE
Lloh1:
	ldr	x9, [x9, _PCI_AGP_STATUS@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	add	x1, x9, x8
	add	x2, sp, #8
	bl	_pci_read_config_dword
	ldr	w2, [sp, #8]
	mov	x0, x19
	mov	x1, x20
	bl	_agp_collect_device_status
Lloh3:
	adrp	x22, _PCI_AGP_COMMAND_AGP@GOTPAGE
Lloh4:
	ldr	x22, [x22, _PCI_AGP_COMMAND_AGP@GOTPAGEOFF]
	ldr	w8, [x22]
	orr	w8, w8, w0
Lloh5:
	adrp	x21, _uninorth_rev@GOTPAGE
Lloh6:
	ldr	x21, [x21, _uninorth_rev@GOTPAGEOFF]
	ldr	w9, [x21]
Lloh7:
	adrp	x10, _AGPSTAT2_4X@GOTPAGE
Lloh8:
	ldr	x10, [x10, _AGPSTAT2_4X@GOTPAGEOFF]
Lloh9:
	ldr	w10, [x10]
	cmp	w9, #33
	mov	w11, #-1
	csinv	w10, w11, w10, ne
	and	w20, w10, w8
	and	w8, w9, #0xfffffffc
	cmp	w8, #48
	b.ne	LBB0_3
; %bb.1:
Lloh10:
	adrp	x8, _AGPSTAT_RQ_DEPTH_SHIFT@GOTPAGE
Lloh11:
	ldr	x8, [x8, _AGPSTAT_RQ_DEPTH_SHIFT@GOTPAGEOFF]
Lloh12:
	ldr	w8, [x8]
	asr	w9, w20, w8
	cmp	w9, #8
	b.lt	LBB0_3
; %bb.2:
Lloh13:
	adrp	x9, _AGPSTAT_RQ_DEPTH@GOTPAGE
Lloh14:
	ldr	x9, [x9, _AGPSTAT_RQ_DEPTH@GOTPAGEOFF]
Lloh15:
	ldr	w9, [x9]
	bic	w9, w20, w9
	mov	w10, #7
	lsl	w8, w10, w8
	orr	w20, w9, w8
LBB0_3:
	mov	x0, #0
	bl	_uninorth_tlbflush
	mov	w23, #0
Lloh16:
	adrp	x24, _PCI_AGP_COMMAND@GOTPAGE
Lloh17:
	ldr	x24, [x24, _PCI_AGP_COMMAND@GOTPAGEOFF]
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldp	x0, x8, [x19]
	ldr	x9, [x24]
	add	x1, x9, x8
	mov	x2, x20
	bl	_pci_write_config_dword
	ldp	x0, x8, [x19]
	ldr	x9, [x24]
	add	x1, x9, x8
	add	x2, sp, #12
	bl	_pci_read_config_dword
	ldr	w8, [sp, #12]
	ldr	w9, [x22]
	ands	w8, w9, w8
	b.ne	LBB0_6
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	add	w9, w23, #1
	cmp	w23, #999
	mov	x23, x9
	b.lo	LBB0_4
LBB0_6:
	cbnz	w8, LBB0_8
; %bb.7:
	ldr	x0, [x19]
Lloh18:
	adrp	x1, l_.str@PAGE
Lloh19:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
LBB0_8:
	ldr	w8, [x21]
	cmp	w8, #48
	b.lt	LBB0_10
; %bb.9:
	ldr	w8, [sp, #8]
Lloh20:
	adrp	x9, _AGPSTAT_MODE_3_0@GOTPAGE
Lloh21:
	ldr	x9, [x9, _AGPSTAT_MODE_3_0@GOTPAGEOFF]
Lloh22:
	ldr	w9, [x9]
	tst	w9, w8
	cset	w1, ne
	b	LBB0_11
LBB0_10:
	mov	w1, #0
LBB0_11:
	mov	x0, x20
	bl	_agp_device_command
	mov	x0, #0
	bl	_uninorth_tlbflush
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.cfi_endproc
                                        ; -- End function
	.comm	_PCI_AGP_STATUS,8,3             ; @PCI_AGP_STATUS
	.comm	_PCI_AGP_COMMAND_AGP,4,2        ; @PCI_AGP_COMMAND_AGP
	.comm	_uninorth_rev,4,2               ; @uninorth_rev
	.comm	_AGPSTAT2_4X,4,2                ; @AGPSTAT2_4X
	.comm	_AGPSTAT_RQ_DEPTH_SHIFT,4,2     ; @AGPSTAT_RQ_DEPTH_SHIFT
	.comm	_AGPSTAT_RQ_DEPTH,4,2           ; @AGPSTAT_RQ_DEPTH
	.comm	_PCI_AGP_COMMAND,8,3            ; @PCI_AGP_COMMAND
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"can't write UniNorth AGP command register\n"

	.comm	_AGPSTAT_MODE_3_0,4,2           ; @AGPSTAT_MODE_3_0
	.no_dead_strip	_uninorth_agp_enable
.subsections_via_symbols
