	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_qedr_mmap                      ## -- Begin function qedr_mmap
	.p2align	4, 0x90
_qedr_mmap:                             ## @qedr_mmap
	.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
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r13
	movq	%rdi, %rbx
	callq	_get_qedr_ucontext
	movq	%rax, %r12
	movl	(%rbx), %edi
	callq	_get_qedr_dev
	movq	%rax, %rdi
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	movq	(%r13), %r9
	movq	8(%r13), %r8
	movq	%r9, %rbx
	shlq	%cl, %rbx
	movq	16(%r13), %rcx
	movq	%r8, %r15
	subq	%rcx, %r15
	movq	8(%r12), %rax
	movq	(%r12), %r14
	imulq	%rax, %r14
	addq	(%rdi), %r14
	movq	_QEDR_MSG_INIT@GOTPCREL(%rip), %rdx
	movl	(%rdx), %esi
	leaq	L_.str(%rip), %rdx
	movq	%rdi, -48(%rbp)                 ## 8-byte Spill
	pushq	%rax
	pushq	%r14
	callq	_DP_DEBUG
	addq	$16, %rsp
	movq	16(%r13), %rdx
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rax
	movslq	(%rax), %rax
	decq	%rax
	movq	%rdx, %rcx
	orq	%r15, %rcx
	testq	%rax, %rcx
	jne	LBB0_1
## %bb.2:
	movq	%r12, -56(%rbp)                 ## 8-byte Spill
	movq	%r12, %rdi
	movq	%rbx, %rsi
	movq	%r15, %rdx
	callq	_qedr_search_mmap
	testl	%eax, %eax
	je	LBB0_3
## %bb.4:
	movq	%rbx, %rdx
	cmpq	%r14, %rbx
	jae	LBB0_6
## %bb.5:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	8(%rax), %r8
	jmp	LBB0_7
LBB0_1:
	movq	8(%r13), %rcx
	leaq	L_.str.1(%rip), %rsi
	xorl	%ebx, %ebx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	xorl	%eax, %eax
	callq	_DP_ERR
	jmp	LBB0_10
LBB0_3:
	movq	(%r13), %rdx
	leaq	L_.str.2(%rip), %rsi
	xorl	%ebx, %ebx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	xorl	%eax, %eax
	callq	_DP_ERR
	jmp	LBB0_10
LBB0_6:
	leaq	(%r15,%rdx), %rax
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	movq	8(%rcx), %r8
	leaq	(%r8,%r14), %rcx
	cmpq	%rcx, %rax
	jbe	LBB0_8
LBB0_7:
	leaq	L_.str.3(%rip), %rsi
	xorl	%ebx, %ebx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	movq	%r14, %rcx
	xorl	%eax, %eax
	callq	_DP_ERR
LBB0_10:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_8:
	movq	_VM_READ@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, 24(%r13)
	je	LBB0_11
## %bb.9:
	leaq	L_.str.4(%rip), %rsi
	xorl	%ebx, %ebx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	xorl	%eax, %eax
	callq	_DP_ERR
	jmp	LBB0_10
LBB0_11:
	movl	28(%r13), %edi
	callq	_pgprot_writecombine
	movl	%eax, 28(%r13)
	movl	16(%r13), %esi
	movq	(%r13), %rdx
	movq	%r13, %rdi
	movq	%r15, %rcx
	movl	%eax, %r8d
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_io_remap_pfn_range             ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_PAGE_SHIFT,8,3                 ## @PAGE_SHIFT
	.comm	_QEDR_MSG_INIT,4,2              ## @QEDR_MSG_INIT
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"mmap invoked with vm_start=0x%pK, vm_end=0x%pK,vm_pgoff=0x%pK; dpi_start=0x%pK dpi_size=0x%x\n"

	.comm	_PAGE_SIZE,4,2                  ## @PAGE_SIZE
L_.str.1:                               ## @.str.1
	.asciz	"failed mmap, addresses must be page aligned: start=0x%pK, end=0x%pK\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
L_.str.2:                               ## @.str.2
	.asciz	"failed mmap, vm_pgoff=0x%lx is not authorized\n"

L_.str.3:                               ## @.str.3
	.asciz	"failed mmap, pages are outside of dpi; page address=0x%pK, dpi_start=0x%pK, dpi_size=0x%x\n"

	.comm	_VM_READ,4,2                    ## @VM_READ
L_.str.4:                               ## @.str.4
	.asciz	"failed mmap, cannot map doorbell bar for read\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_qedr_mmap                      ; -- Begin function qedr_mmap
	.p2align	2
_qedr_mmap:                             ; @qedr_mmap
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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	x20, x1
	mov	x19, x0
	bl	_get_qedr_ucontext
	mov	x22, x0
	ldr	w0, [x19]
	bl	_get_qedr_dev
	mov	x19, x0
Lloh0:
	adrp	x8, _PAGE_SHIFT@GOTPAGE
Lloh1:
	ldr	x8, [x8, _PAGE_SHIFT@GOTPAGEOFF]
Lloh2:
	ldr	x25, [x8]
	ldp	x24, x4, [x20]
	ldr	x3, [x20, #16]
	sub	x21, x4, x3
	ldr	x8, [x0]
	ldp	x9, x7, [x22]
	madd	x23, x7, x9, x8
Lloh3:
	adrp	x8, _QEDR_MSG_INIT@GOTPAGE
Lloh4:
	ldr	x8, [x8, _QEDR_MSG_INIT@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
Lloh6:
	adrp	x2, l_.str@PAGE
Lloh7:
	add	x2, x2, l_.str@PAGEOFF
	mov	x5, x24
	mov	x6, x23
	bl	_DP_DEBUG
	ldr	x8, [x20, #16]
Lloh8:
	adrp	x9, _PAGE_SIZE@GOTPAGE
Lloh9:
	ldr	x9, [x9, _PAGE_SIZE@GOTPAGEOFF]
Lloh10:
	ldrsw	x9, [x9]
	sub	x9, x9, #1
	orr	x10, x8, x21
	tst	x10, x9
	b.ne	LBB0_4
; %bb.1:
	lsl	x24, x24, x25
	mov	x0, x22
	mov	x1, x24
	mov	x2, x21
	bl	_qedr_search_mmap
	cbz	w0, LBB0_5
; %bb.2:
	cmp	x24, x23
	b.hs	LBB0_6
; %bb.3:
	ldr	x8, [x22, #8]
	b	LBB0_7
LBB0_4:
	ldr	x9, [x20, #8]
	stp	x8, x9, [sp]
Lloh11:
	adrp	x1, l_.str.1@PAGE
Lloh12:
	add	x1, x1, l_.str.1@PAGEOFF
	b	LBB0_8
LBB0_5:
	ldr	x8, [x20]
	str	x8, [sp]
Lloh13:
	adrp	x1, l_.str.2@PAGE
Lloh14:
	add	x1, x1, l_.str.2@PAGEOFF
	b	LBB0_8
LBB0_6:
	add	x9, x21, x24
	ldr	x8, [x22, #8]
	add	x10, x8, x23
	cmp	x9, x10
	b.ls	LBB0_9
LBB0_7:
	stp	x23, x8, [sp, #8]
	str	x24, [sp]
Lloh15:
	adrp	x1, l_.str.3@PAGE
Lloh16:
	add	x1, x1, l_.str.3@PAGEOFF
LBB0_8:
	mov	x0, x19
	bl	_DP_ERR
Lloh17:
	adrp	x8, _EINVAL@GOTPAGE
Lloh18:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	neg	w0, w8
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_9:
	ldr	w8, [x20, #24]
Lloh20:
	adrp	x9, _VM_READ@GOTPAGE
Lloh21:
	ldr	x9, [x9, _VM_READ@GOTPAGEOFF]
Lloh22:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_11
; %bb.10:
Lloh23:
	adrp	x1, l_.str.4@PAGE
Lloh24:
	add	x1, x1, l_.str.4@PAGEOFF
	b	LBB0_8
LBB0_11:
	ldr	w0, [x20, #28]
	bl	_pgprot_writecombine
	mov	x4, x0
	str	w0, [x20, #28]
	ldr	w1, [x20, #16]
	ldr	x2, [x20]
	mov	x0, x20
	mov	x3, x21
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #112
	b	_io_remap_pfn_range
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpAdd	Lloh23, Lloh24
	.cfi_endproc
                                        ; -- End function
	.comm	_PAGE_SHIFT,8,3                 ; @PAGE_SHIFT
	.comm	_QEDR_MSG_INIT,4,2              ; @QEDR_MSG_INIT
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"mmap invoked with vm_start=0x%pK, vm_end=0x%pK,vm_pgoff=0x%pK; dpi_start=0x%pK dpi_size=0x%x\n"

	.comm	_PAGE_SIZE,4,2                  ; @PAGE_SIZE
l_.str.1:                               ; @.str.1
	.asciz	"failed mmap, addresses must be page aligned: start=0x%pK, end=0x%pK\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
l_.str.2:                               ; @.str.2
	.asciz	"failed mmap, vm_pgoff=0x%lx is not authorized\n"

l_.str.3:                               ; @.str.3
	.asciz	"failed mmap, pages are outside of dpi; page address=0x%pK, dpi_start=0x%pK, dpi_size=0x%x\n"

	.comm	_VM_READ,4,2                    ; @VM_READ
l_.str.4:                               ; @.str.4
	.asciz	"failed mmap, cannot map doorbell bar for read\n"

.subsections_via_symbols
