	.file	"extr_mvs.c_mvs_begin_transaction.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	mvs_begin_transaction, @function
mvs_begin_transaction:
.LFB0:
	.cfi_startproc
	endbr64
	push	r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	mov	r13d, edi
	push	r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	mov	r12, rsi
	push	rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	push	rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	sub	rsp, 8
	.cfi_def_cfa_offset 48
	call	device_get_softc@PLT
	mov	edx, DWORD PTR [rax]
	mov	rbx, rax
	test	edx, edx
	jle	.L2
	mov	edi, r13d
	call	mvs_ch_pm_wake@PLT
.L2:
	mov	rsi, QWORD PTR XPT_ATA_IO[rip]
	cmp	QWORD PTR [r12], rsi
	je	.L32
	mov	eax, DWORD PTR 4[rbx]
	not	eax
	bsf	edx, eax
	mov	eax, -1
	cmovne	eax, edx
	xor	edx, edx
.L5:
	cdqe
	lea	rcx, [rax+rax*2]
	mov	rax, QWORD PTR 112[rbx]
	lea	rbp, [rax+rcx*8]
	mov	rax, QWORD PTR 24[rbx]
	mov	QWORD PTR 16[rbp], r12
	mov	DWORD PTR 0[rbp], edx
	test	rax, rax
	je	.L33
.L6:
	mov	ecx, DWORD PTR 4[rbp]
	mov	edi, 1
	add	rax, 1
	mov	edx, edi
	mov	QWORD PTR 24[rbx], rax
	mov	rax, QWORD PTR 96[rbx]
	sal	edx, cl
	or	DWORD PTR 4[rbx], edx
	mov	rdx, QWORD PTR 8[r12]
	add	DWORD PTR [rax+rdx*4], 1
	mov	rdx, QWORD PTR [r12]
	cmp	rdx, rsi
	je	.L34
	mov	eax, DWORD PTR 16[r12]
	test	DWORD PTR CAM_CDB_POINTER[rip], eax
	je	.L35
.L13:
	add	QWORD PTR 40[rbx], 1
	and	eax, DWORD PTR CAM_DIR_MASK[rip]
	cmp	eax, DWORD PTR CAM_DIR_NONE[rip]
	je	.L14
	mov	rcx, QWORD PTR 8[r12]
	mov	rax, QWORD PTR 64[rbx]
	mov	rsi, QWORD PTR ATA_DMA[rip]
	cmp	QWORD PTR [rax+rcx*8], rsi
	jl	.L14
	mov	eax, DWORD PTR 8[rbx]
	test	DWORD PTR MVS_Q_SOC[rip], eax
	jne	.L14
	mov	ecx, DWORD PTR [rdx]
	mov	eax, ecx
	and	eax, -35
	cmp	eax, 8
	sete	dl
	sub	ecx, 136
	xor	eax, eax
	cmp	ecx, 54
	ja	.L15
	movabs	rax, 18014419984318469
	shr	rax, cl
	and	eax, 1
.L15:
	test	dl, dl
	jne	.L22
	test	al, al
	je	.L14
.L22:
	mov	DWORD PTR 52[rbx], 1
	.p2align 4,,10
	.p2align 3
.L14:
	mov	esi, DWORD PTR MVS_EDMA_OFF[rip]
	mov	edi, r13d
	call	mvs_set_edma_mode@PLT
.L11:
	cmp	QWORD PTR 40[rbx], 0
	je	.L17
	mov	eax, DWORD PTR 52[rbx]
	test	eax, eax
	je	.L18
.L17:
	mov	eax, DWORD PTR MVS_SLOT_LOADING[rip]
	mov	esi, DWORD PTR 8[rbp]
	mov	r8, rbp
	mov	rdx, r12
	mov	edi, DWORD PTR 56[rbx]
	mov	ecx, DWORD PTR mvs_dmasetprd[rip]
	xor	r9d, r9d
	mov	DWORD PTR 12[rbp], eax
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	jmp	bus_dmamap_load_ccb@PLT
	.p2align 4,,10
	.p2align 3
.L33:
	.cfi_restore_state
	cmp	DWORD PTR [rbx], 3
	jle	.L6
	lea	rdi, 104[rbx]
	call	callout_stop@PLT
	mov	rax, QWORD PTR 24[rbx]
	mov	rsi, QWORD PTR XPT_ATA_IO[rip]
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L35:
	mov	rdx, QWORD PTR 8[r12]
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L18:
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	mov	rdi, rbp
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	jmp	mvs_legacy_execute_transaction@PLT
	.p2align 4,,10
	.p2align 3
.L32:
	.cfi_restore_state
	mov	edx, DWORD PTR [r12]
	test	DWORD PTR CAM_ATAIO_CONTROL[rip], edx
	jne	.L36
	mov	eax, DWORD PTR 4[rbx]
	mov	ecx, -1
	not	eax
	bsf	eax, eax
	cmove	eax, ecx
	and	edx, DWORD PTR CAM_ATAIO_FPDMA[rip]
	je	.L5
	mov	edi, DWORD PTR 8[rbx]
	mov	edx, eax
	test	DWORD PTR MVS_Q_GENIIE[rip], edi
	je	.L5
	mov	rdi, QWORD PTR 8[r12]
	mov	rdx, QWORD PTR 16[rbx]
	mov	edx, DWORD PTR [rdx+rdi*4]
	not	edx
	bsf	edx, edx
	cmove	edx, ecx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L34:
	mov	eax, DWORD PTR [r12]
	test	DWORD PTR CAM_ATAIO_FPDMA[rip], eax
	jne	.L37
	test	DWORD PTR CAM_ATAIO_DMA[rip], eax
	jne	.L38
	add	QWORD PTR 40[rbx], 1
	mov	esi, DWORD PTR MVS_EDMA_OFF[rip]
	mov	edi, r13d
	call	mvs_set_edma_mode@PLT
.L9:
	mov	eax, DWORD PTR CAM_ATAIO_CONTROL[rip]
	or	eax, DWORD PTR CAM_ATAIO_NEEDRESULT[rip]
	test	DWORD PTR [r12], eax
	je	.L11
	mov	ecx, DWORD PTR 4[rbp]
	mov	eax, 1
	sal	eax, cl
	or	DWORD PTR 48[rbx], eax
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L38:
	add	DWORD PTR 72[rbx], 1
	mov	esi, DWORD PTR MVS_EDMA_ON[rip]
	mov	edi, r13d
	call	mvs_set_edma_mode@PLT
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L37:
	mov	rdx, QWORD PTR 8[r12]
	mov	ecx, DWORD PTR 0[rbp]
	mov	rax, QWORD PTR 16[rbx]
	sal	edi, cl
	or	DWORD PTR [rax+rdx*4], edi
	mov	rax, QWORD PTR 80[rbx]
	mov	edi, r13d
	mov	rdx, QWORD PTR 8[r12]
	add	DWORD PTR 88[rbx], 1
	add	DWORD PTR [rax+rdx*4], 1
	mov	rax, QWORD PTR 8[r12]
	mov	esi, DWORD PTR MVS_EDMA_NCQ[rip]
	mov	QWORD PTR 32[rbx], rax
	call	mvs_set_edma_mode@PLT
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L36:
	add	rsp, 8
	.cfi_def_cfa_offset 40
	mov	rsi, r12
	mov	edi, r13d
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	jmp	mvs_softreset@PLT
	.cfi_endproc
.LFE0:
	.size	mvs_begin_transaction, .-mvs_begin_transaction
	.comm	mvs_dmasetprd,4,4
	.comm	XPT_ATA_IO,8,8
	.comm	MVS_SLOT_LOADING,4,4
	.comm	MVS_Q_SOC,4,4
	.comm	MVS_Q_GENIIE,4,4
	.comm	MVS_EDMA_ON,4,4
	.comm	MVS_EDMA_OFF,4,4
	.comm	MVS_EDMA_NCQ,4,4
	.comm	CAM_DIR_NONE,4,4
	.comm	CAM_DIR_MASK,4,4
	.comm	CAM_CDB_POINTER,4,4
	.comm	CAM_ATAIO_NEEDRESULT,4,4
	.comm	CAM_ATAIO_FPDMA,4,4
	.comm	CAM_ATAIO_DMA,4,4
	.comm	CAM_ATAIO_CONTROL,4,4
	.comm	ATA_DMA,8,8
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_mvs.c_mvs_begin_transaction.c"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	mvs_begin_transaction, %function
mvs_begin_transaction:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, lr}
	sub	sp, sp, #8
	mov	r6, r1
	mov	r8, r0
	bl	device_get_softc
	ldr	r3, [r0]
	mov	r4, r0
	cmp	r3, #0
	ble	.L2
	mov	r0, r8
	bl	mvs_ch_pm_wake
.L2:
	ldr	r10, .L38
	ldr	r3, [r6]
	ldr	r1, [r10]
	cmp	r3, r1
	beq	.L32
	ldr	r0, [r4, #4]
	mov	ip, #0
	add	r3, r0, #1
	bic	r3, r3, r0
	clz	r3, r3
	rsb	r3, r3, #31
.L5:
	ldr	r9, [r4, #64]
	ldr	r2, [r4, #16]
	add	r3, r3, r3, lsl #2
	add	r7, r9, r3, lsl #2
	lsl	r5, r3, #2
	cmp	r2, #0
	str	r6, [r7, #16]
	str	ip, [r9, r5]
	beq	.L33
.L6:
	mov	ip, #1
	ldr	r3, [r7, #4]
	ldr	lr, [r6, #4]
	ldr	r10, [r4, #56]
	orr	r0, r0, ip, lsl r3
	str	r0, [r4, #4]
	ldr	r3, [r10, lr, lsl #2]
	add	r2, r2, ip
	add	r3, r3, ip
	str	r2, [r4, #16]
	str	r3, [r10, lr, lsl #2]
	ldr	r2, [r6]
	cmp	r2, r1
	beq	.L34
	ldr	r1, .L38+4
	ldr	r3, [r6, #8]
	ldr	r1, [r1]
	ldr	r0, .L38+8
	tst	r3, r1
	movne	r1, r2
	ldr	r2, .L38+12
	ldr	r0, [r0]
	ldr	r2, [r2]
	ldreq	r1, [r6, #4]
	and	r3, r3, r2
	ldr	r2, [r4, #24]
	cmp	r3, r0
	add	r3, r2, #1
	str	r3, [r4, #24]
	beq	.L14
	ldr	r0, [r6, #4]
	ldr	r2, [r4, #40]
	ldr	r3, .L38+16
	ldr	r2, [r2, r0, lsl #2]
	ldr	r3, [r3]
	cmp	r2, r3
	blt	.L14
	ldr	r3, .L38+20
	ldr	r2, [r4, #8]
	ldr	r3, [r3]
	tst	r2, r3
	beq	.L35
.L14:
	ldr	r3, .L38+24
	mov	r0, r8
	ldr	r1, [r3]
	bl	mvs_set_edma_mode
.L11:
	ldr	r3, [r4, #24]
	cmp	r3, #0
	beq	.L15
	ldr	r3, [r4, #32]
	cmp	r3, #0
	beq	.L16
.L15:
	mov	ip, #0
	ldr	r3, .L38+28
	ldr	r0, [r4, #36]
	ldr	r3, [r3]
	ldr	r1, [r7, #8]
	str	r3, [r7, #12]
	stm	sp, {r7, ip}
	ldr	r3, .L38+32
	mov	r2, r6
	ldr	r3, [r3]
	bl	bus_dmamap_load_ccb
	add	sp, sp, #8
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, pc}
.L33:
	ldr	r3, [r4]
	cmp	r3, #3
	ble	.L6
	add	r0, r4, #60
	bl	callout_stop
	ldr	r1, [r10]
	ldr	r2, [r4, #16]
	ldr	r0, [r4, #4]
	b	.L6
.L16:
	mov	r0, r7
	add	sp, sp, #8
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, lr}
	b	mvs_legacy_execute_transaction
.L32:
	ldr	r2, .L38+36
	ldr	r2, [r2]
	tst	r3, r2
	bne	.L36
	ldr	r0, [r4, #4]
	ldr	r2, .L38+40
	add	r3, r0, #1
	bic	r3, r3, r0
	clz	r3, r3
	ldr	ip, [r2]
	rsb	r3, r3, #31
	ands	ip, r1, ip
	beq	.L5
	ldr	r2, .L38+44
	ldr	ip, [r4, #8]
	ldr	r2, [r2]
	tst	ip, r2
	ldrne	ip, [r6, #4]
	ldrne	r2, [r4, #12]
	moveq	ip, r3
	ldrne	r2, [r2, ip, lsl #2]
	addne	ip, r2, #1
	bicne	ip, ip, r2
	clzne	ip, ip
	rsbne	ip, ip, #31
	b	.L5
.L34:
	ldr	r3, .L38+40
	ldr	r3, [r3]
	tst	r1, r3
	bne	.L37
	ldr	r3, .L38+48
	ldr	r3, [r3]
	tst	r1, r3
	ldrne	r3, [r4, #44]
	ldreq	r3, [r4, #24]
	ldrne	r2, .L38+52
	ldreq	r2, .L38+24
	addne	r3, r3, #1
	strne	r3, [r4, #44]
	addeq	r3, r3, #1
	movne	r0, r8
	moveq	r0, r8
	ldr	r1, [r2]
	streq	r3, [r4, #24]
	bl	mvs_set_edma_mode
.L9:
	ldr	r2, .L38+56
	ldr	r3, .L38+36
	ldr	r1, [r2]
	ldr	r3, [r3]
	ldr	r2, [r6]
	orr	r3, r3, r1
	tst	r3, r2
	beq	.L11
	mov	r1, #1
	ldr	r2, [r7, #4]
	ldr	r3, [r4, #28]
	orr	r3, r3, r1, lsl r2
	str	r3, [r4, #28]
	b	.L11
.L35:
	ldr	r2, [r1]
	bic	r3, r2, #34
	cmp	r3, #8
	cmpne	r3, #136
	moveq	r3, #1
	movne	r3, #0
	cmp	r2, #190
	orreq	r3, r3, #1
	cmp	r3, #0
	movne	r3, #1
	strne	r3, [r4, #32]
	b	.L14
.L37:
	ldr	r1, [r6, #4]
	ldr	r2, [r4, #12]
	ldr	lr, [r9, r5]
	ldr	r3, [r2, r1, lsl #2]
	mov	r0, r8
	orr	ip, r3, ip, lsl lr
	str	ip, [r2, r1, lsl #2]
	ldr	r3, [r4, #52]
	ldr	r1, [r6, #4]
	ldr	r2, [r4, #48]
	add	r3, r3, #1
	str	r3, [r4, #52]
	ldr	r3, [r2, r1, lsl #2]
	ldr	ip, .L38+60
	add	r3, r3, #1
	str	r3, [r2, r1, lsl #2]
	ldr	r3, [r6, #4]
	ldr	r1, [ip]
	str	r3, [r4, #20]
	bl	mvs_set_edma_mode
	b	.L9
.L36:
	mov	r1, r6
	mov	r0, r8
	add	sp, sp, #8
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, lr}
	b	mvs_softreset
.L39:
	.align	2
.L38:
	.word	XPT_ATA_IO
	.word	CAM_CDB_POINTER
	.word	CAM_DIR_NONE
	.word	CAM_DIR_MASK
	.word	ATA_DMA
	.word	MVS_Q_SOC
	.word	MVS_EDMA_OFF
	.word	MVS_SLOT_LOADING
	.word	mvs_dmasetprd
	.word	CAM_ATAIO_CONTROL
	.word	CAM_ATAIO_FPDMA
	.word	MVS_Q_GENIIE
	.word	CAM_ATAIO_DMA
	.word	MVS_EDMA_ON
	.word	CAM_ATAIO_NEEDRESULT
	.word	MVS_EDMA_NCQ
	.size	mvs_begin_transaction, .-mvs_begin_transaction
	.comm	mvs_dmasetprd,4,4
	.comm	XPT_ATA_IO,4,4
	.comm	MVS_SLOT_LOADING,4,4
	.comm	MVS_Q_SOC,4,4
	.comm	MVS_Q_GENIIE,4,4
	.comm	MVS_EDMA_ON,4,4
	.comm	MVS_EDMA_OFF,4,4
	.comm	MVS_EDMA_NCQ,4,4
	.comm	CAM_DIR_NONE,4,4
	.comm	CAM_DIR_MASK,4,4
	.comm	CAM_CDB_POINTER,4,4
	.comm	CAM_ATAIO_NEEDRESULT,4,4
	.comm	CAM_ATAIO_FPDMA,4,4
	.comm	CAM_ATAIO_DMA,4,4
	.comm	CAM_ATAIO_CONTROL,4,4
	.comm	ATA_DMA,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
