	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function vtd_add_device
_vtd_add_device:                        ## @vtd_add_device
	.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, %r12d
	movq	%rdi, %rbx
	movl	%esi, %edi
	callq	_PCI_RID2BUS
	movq	_ctx_tables@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	(%rcx,%rax,8), %r13
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	movl	8(%rbx), %edi
	callq	_vtophys
	movl	%eax, %r15d
	movl	%r12d, %edi
	callq	_VTD_RID2IDX
	movslq	%eax, %r14
	movq	_VTD_CTX_PRESENT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%r13,%r14,4)
	je	LBB0_2
## %bb.1:
	movl	4(%r13,%r14,4), %edx
	sarl	$8, %edx
	leaq	L_.str(%rip), %rdi
	movl	%r12d, %esi
	xorl	%eax, %eax
	callq	_panic
LBB0_2:
	movl	%r12d, %edi
	callq	_vtd_device_scope
	movq	%rax, %rbx
	testq	%rax, %rax
	jne	LBB0_4
## %bb.3:
	leaq	L_.str.1(%rip), %rdi
	movl	%r12d, %esi
	xorl	%eax, %eax
	callq	_panic
LBB0_4:
	movq	-48(%rbp), %rcx                 ## 8-byte Reload
	movl	4(%rcx), %eax
	shll	$8, %eax
	orl	(%rcx), %eax
	movl	%eax, 4(%r13,%r14,4)
	movl	(%rbx), %edi
	callq	_VTD_ECAP_DI
	xorl	%ecx, %ecx
	testq	%rax, %rax
	je	LBB0_6
## %bb.5:
	movq	_VTD_CTX_TT_ALL@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
LBB0_6:
	movl	%ecx, (%r13,%r14,4)
	orl	%ecx, %r15d
	movq	_VTD_CTX_PRESENT@GOTPCREL(%rip), %rax
	orl	(%rax), %r15d
	movl	%r15d, (%r13,%r14,4)
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ctx_tables,8,3                 ## @ctx_tables
	.comm	_VTD_CTX_PRESENT,4,2            ## @VTD_CTX_PRESENT
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"vtd_add_device: device %x is already owned by domain %d"

L_.str.1:                               ## @.str.1
	.asciz	"vtd_add_device: device %x is not in scope for any DMA remapping unit"

	.comm	_VTD_CTX_TT_ALL,4,2             ## @VTD_CTX_TT_ALL
	.no_dead_strip	_vtd_add_device
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function vtd_add_device
_vtd_add_device:                        ; @vtd_add_device
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x21, x1
	mov	x20, x0
	mov	x0, x1
	bl	_PCI_RID2BUS
Lloh0:
	adrp	x8, _ctx_tables@GOTPAGE
Lloh1:
	ldr	x8, [x8, _ctx_tables@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	ldr	x23, [x8, x0, lsl #3]
	ldr	w0, [x20, #8]
	bl	_vtophys
	mov	x19, x0
	mov	x0, x21
	bl	_VTD_RID2IDX
                                        ; kill: def $w0 killed $w0 def $x0
	sxtw	x25, w0
	ldr	w8, [x23, w0, sxtw #2]
Lloh3:
	adrp	x24, _VTD_CTX_PRESENT@GOTPAGE
Lloh4:
	ldr	x24, [x24, _VTD_CTX_PRESENT@GOTPAGEOFF]
	ldr	w9, [x24]
	tst	w9, w8
	b.eq	LBB0_2
; %bb.1:
	add	x8, x23, x25, lsl #2
	ldr	w8, [x8, #4]
	asr	w8, w8, #8
	str	x8, [sp]
Lloh5:
	adrp	x0, l_.str@PAGE
Lloh6:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x21
	bl	_panic
LBB0_2:
	mov	x0, x21
	bl	_vtd_device_scope
	mov	x22, x0
	cbnz	x0, LBB0_4
; %bb.3:
Lloh7:
	adrp	x0, l_.str.1@PAGE
Lloh8:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x1, x21
	bl	_panic
LBB0_4:
	ldp	w8, w9, [x20]
	orr	w8, w8, w9, lsl #8
	add	x20, x23, x25, lsl #2
	str	w8, [x20, #4]
	ldr	w0, [x22]
	bl	_VTD_ECAP_DI
Lloh9:
	adrp	x8, _VTD_CTX_TT_ALL@GOTPAGE
Lloh10:
	ldr	x8, [x8, _VTD_CTX_TT_ALL@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	cmp	x0, #0
	csel	w8, wzr, w8, eq
	str	w8, [x20]
	ldr	w9, [x24]
	orr	w8, w8, w19
	orr	w8, w8, w9
	str	w8, [x20]
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #96
	ret
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_ctx_tables,8,3                 ; @ctx_tables
	.comm	_VTD_CTX_PRESENT,4,2            ; @VTD_CTX_PRESENT
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"vtd_add_device: device %x is already owned by domain %d"

l_.str.1:                               ; @.str.1
	.asciz	"vtd_add_device: device %x is not in scope for any DMA remapping unit"

	.comm	_VTD_CTX_TT_ALL,4,2             ; @VTD_CTX_TT_ALL
	.no_dead_strip	_vtd_add_device
.subsections_via_symbols
