	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function cxl_read_vsec
_cxl_read_vsec:                         ## @cxl_read_vsec
	.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	%rbx
	subq	$40, %rsp
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r15
	movq	%rdi, %r14
	movq	%rsi, %rdi
	callq	_find_cxl_vsec
	testl	%eax, %eax
	je	LBB0_1
## %bb.3:
	movl	%eax, %ebx
	leaq	-56(%rbp), %rdx
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_CXL_READ_VSEC_LENGTH
	movq	-56(%rbp), %rax
	movq	_CXL_VSEC_MIN_SIZE@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jge	LBB0_5
## %bb.4:
	leaq	L_.str.1(%rip), %rsi
	movq	%r15, %rdi
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	jmp	LBB0_2
LBB0_1:
	leaq	L_.str(%rip), %rsi
	movq	%r15, %rdi
	callq	_dev_err
	movq	_ENODEV@GOTPCREL(%rip), %rcx
LBB0_2:
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_6
LBB0_5:
	leaq	48(%r14), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_STATUS
	leaq	44(%r14), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_PSL_REVISION
	leaq	40(%r14), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_CAIA_MAJOR
	leaq	36(%r14), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_CAIA_MINOR
	leaq	32(%r14), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_BASE_IMAGE
	leaq	-28(%rbp), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_IMAGE_STATE
	movl	-28(%rbp), %eax
	movq	_CXL_VSEC_USER_IMAGE_LOADED@GOTPCREL(%rip), %rcx
	xorl	%edx, %edx
	movl	(%rcx), %esi
	andl	%eax, %esi
	setne	%dl
	movl	%edx, (%r14)
	xorl	%edx, %edx
	movl	(%rcx), %ecx
	andl	%eax, %ecx
	setne	%dl
	movl	%edx, 4(%r14)
	movq	_CXL_VSEC_PERST_LOADS_IMAGE@GOTPCREL(%rip), %rcx
	xorl	%edx, %edx
	andl	(%rcx), %eax
	setne	%dl
	movl	%edx, 8(%r14)
	leaq	12(%r14), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_NAFUS
	leaq	-44(%rbp), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_AFU_DESC_OFF
	leaq	-40(%rbp), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_AFU_DESC_SIZE
	leaq	-36(%rbp), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_PS_OFF
	leaq	-32(%rbp), %rdx
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_CXL_READ_VSEC_PS_SIZE
	movl	-36(%rbp), %eax
	shll	$16, %eax
	movq	24(%r14), %rcx
	movl	%eax, (%rcx)
	movl	-32(%rbp), %eax
	shll	$16, %eax
	movl	%eax, 16(%r14)
	movl	-44(%rbp), %eax
	shll	$16, %eax
	movl	%eax, 4(%rcx)
	movl	-40(%rbp), %eax
	shll	$16, %eax
	movl	%eax, 8(%rcx)
	movq	%r15, %rdi
	callq	_pnv_cxl_get_irq_count
	movl	12(%r14), %ecx
	addl	%ecx, %ecx
	notl	%ecx
	addl	%eax, %ecx
	movl	%ecx, 20(%r14)
	xorl	%eax, %eax
LBB0_6:
	addq	$40, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"ABORTING: CXL VSEC not found!\n"

	.comm	_ENODEV,4,2                     ## @ENODEV
	.comm	_CXL_VSEC_MIN_SIZE,8,3          ## @CXL_VSEC_MIN_SIZE
L_.str.1:                               ## @.str.1
	.asciz	"ABORTING: CXL VSEC too short\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_CXL_VSEC_USER_IMAGE_LOADED,4,2 ## @CXL_VSEC_USER_IMAGE_LOADED
	.comm	_CXL_VSEC_PERST_LOADS_IMAGE,4,2 ## @CXL_VSEC_PERST_LOADS_IMAGE
	.no_dead_strip	_cxl_read_vsec
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function cxl_read_vsec
_cxl_read_vsec:                         ; @cxl_read_vsec
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	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
	mov	x20, x1
	mov	x19, x0
	mov	x0, x1
	bl	_find_cxl_vsec
	cbz	w0, LBB0_3
; %bb.1:
	mov	x21, x0
	add	x2, sp, #8
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_LENGTH
	ldr	x8, [sp, #8]
Lloh0:
	adrp	x9, _CXL_VSEC_MIN_SIZE@GOTPAGE
Lloh1:
	ldr	x9, [x9, _CXL_VSEC_MIN_SIZE@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ge	LBB0_5
; %bb.2:
Lloh3:
	adrp	x1, l_.str.1@PAGE
Lloh4:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x20
	bl	_dev_err
Lloh5:
	adrp	x8, _EINVAL@GOTPAGE
Lloh6:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_4
LBB0_3:
Lloh7:
	adrp	x1, l_.str@PAGE
Lloh8:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	bl	_dev_err
Lloh9:
	adrp	x8, _ENODEV@GOTPAGE
Lloh10:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
LBB0_4:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_6
LBB0_5:
	add	x2, x19, #48
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_STATUS
	add	x2, x19, #44
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_PSL_REVISION
	add	x2, x19, #40
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_CAIA_MAJOR
	add	x2, x19, #36
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_CAIA_MINOR
	add	x2, x19, #32
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_BASE_IMAGE
	add	x2, sp, #4
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_IMAGE_STATE
	ldr	w8, [sp, #4]
Lloh11:
	adrp	x9, _CXL_VSEC_USER_IMAGE_LOADED@GOTPAGE
Lloh12:
	ldr	x9, [x9, _CXL_VSEC_USER_IMAGE_LOADED@GOTPAGEOFF]
	ldr	w10, [x9]
	tst	w10, w8
	cset	w10, ne
	str	w10, [x19]
	ldr	w9, [x9]
	tst	w9, w8
	cset	w9, ne
Lloh13:
	adrp	x10, _CXL_VSEC_PERST_LOADS_IMAGE@GOTPAGE
Lloh14:
	ldr	x10, [x10, _CXL_VSEC_PERST_LOADS_IMAGE@GOTPAGEOFF]
Lloh15:
	ldr	w10, [x10]
	tst	w10, w8
	cset	w8, ne
	stp	w9, w8, [x19, #4]
	add	x2, x19, #12
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_NAFUS
	add	x2, sp, #28
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_AFU_DESC_OFF
	add	x2, sp, #24
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_AFU_DESC_SIZE
	add	x2, sp, #20
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_PS_OFF
	add	x2, sp, #16
	mov	x0, x20
	mov	x1, x21
	bl	_CXL_READ_VSEC_PS_SIZE
	ldr	w8, [sp, #20]
	lsl	w8, w8, #16
	ldr	x9, [x19, #24]
	str	w8, [x9]
	ldr	w8, [sp, #16]
	lsl	w8, w8, #16
	str	w8, [x19, #16]
	ldp	w10, w8, [sp, #24]
	lsl	w8, w8, #16
	lsl	w10, w10, #16
	stp	w8, w10, [x9, #4]
	mov	x0, x20
	bl	_pnv_cxl_get_irq_count
	mov	x8, x0
	mov	w0, #0
	ldr	w9, [x19, #12]
	mov	w10, #-1
	eor	w9, w10, w9, lsl #1
	add	w8, w9, w8
	str	w8, [x19, #20]
LBB0_6:
	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
	add	sp, sp, #80
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh11, Lloh12
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"ABORTING: CXL VSEC not found!\n"

	.comm	_ENODEV,4,2                     ; @ENODEV
	.comm	_CXL_VSEC_MIN_SIZE,8,3          ; @CXL_VSEC_MIN_SIZE
l_.str.1:                               ; @.str.1
	.asciz	"ABORTING: CXL VSEC too short\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_CXL_VSEC_USER_IMAGE_LOADED,4,2 ; @CXL_VSEC_USER_IMAGE_LOADED
	.comm	_CXL_VSEC_PERST_LOADS_IMAGE,4,2 ; @CXL_VSEC_PERST_LOADS_IMAGE
	.no_dead_strip	_cxl_read_vsec
.subsections_via_symbols
