	.file	"extr_aic79xx_osm.c_ahd_execute_scb.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	ahd_execute_scb, @function
ahd_execute_scb:
.LFB0:
	.cfi_startproc
	endbr64
	push	r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	push	r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	push	r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	push	r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	push	rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	mov	rbp, rdi
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	mov	ebx, edx
	sub	rsp, 24
	.cfi_def_cfa_offset 80
	mov	r14, QWORD PTR 48[rdi]
	mov	r13, QWORD PTR 40[rdi]
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR 8[rsp], rax
	xor	eax, eax
	test	ecx, ecx
	jne	.L42
	mov	QWORD PTR 32[rdi], 0
	test	edx, edx
	jne	.L43
	call	aic_get_transaction_status@PLT
	cmp	rax, QWORD PTR CAM_REQ_INPROG[rip]
	je	.L25
.L26:
	mov	rdi, r13
	mov	rsi, rbp
	call	ahd_free_scb@PLT
	mov	rdi, r14
	call	xpt_done@PLT
.L1:
	mov	rax, QWORD PTR 8[rsp]
	xor	rax, QWORD PTR fs:40
	jne	.L44
	add	rsp, 24
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L43:
	.cfi_restore_state
	mov	rdx, QWORD PTR 24[rdi]
	mov	r12, rsi
	jle	.L11
	.p2align 4,,10
	.p2align 3
.L8:
	cmp	ebx, 1
	mov	ecx, DWORD PTR 4[r12]
	mov	r8d, DWORD PTR [r12]
	mov	rsi, rbp
	sete	r9b
	mov	rdi, r13
	add	r12, 8
	movzx	r9d, r9b
	call	ahd_sg_setup@PLT
	mov	rdx, rax
	sub	ebx, 1
	jne	.L8
.L11:
	mov	eax, DWORD PTR [r14]
	and	eax, DWORD PTR CAM_DIR_MASK[rip]
	cmp	eax, DWORD PTR CAM_DIR_IN[rip]
	mov	edx, DWORD PTR BUS_DMASYNC_PREREAD[rip]
	je	.L12
	mov	edx, DWORD PTR BUS_DMASYNC_PREWRITE[rip]
.L12:
	mov	esi, DWORD PTR 16[rbp]
	mov	edi, DWORD PTR 12[r13]
	call	bus_dmamap_sync@PLT
	mov	rax, QWORD PTR XPT_CONT_TARGET_IO[rip]
	cmp	QWORD PTR 8[r14], rax
	je	.L45
.L13:
	mov	rdi, rbp
	call	aic_get_transaction_status@PLT
	cmp	rax, QWORD PTR CAM_REQ_INPROG[rip]
	jne	.L24
.L25:
	mov	rax, QWORD PTR 8[rbp]
	mov	rdi, r13
	mov	esi, DWORD PTR 12[rax]
	call	SCSIID_TARGET@PLT
	mov	r15d, eax
	mov	rax, QWORD PTR 8[rbp]
	mov	edi, DWORD PTR 12[rax]
	call	SCSIID_OUR_ID@PLT
	mov	rdi, r13
	mov	r12d, eax
	mov	rax, QWORD PTR 8[rbp]
	mov	esi, DWORD PTR 12[rax]
	call	SCSIID_CHANNEL@PLT
	mov	ecx, r15d
	mov	edx, r12d
	mov	r8, rsp
	mov	esi, eax
	mov	rdi, r13
	call	ahd_fetch_transinfo@PLT
	mov	rsi, rbp
	mov	rdi, r13
	mov	rbx, rax
	call	SCB_GET_TARGET_MASK@PLT
	mov	rdx, QWORD PTR [rsp]
	mov	ecx, DWORD PTR [r14]
	test	DWORD PTR [rdx], eax
	je	.L16
	test	DWORD PTR CAM_DIS_DISCONNECT[rip], ecx
	jne	.L16
	mov	rsi, QWORD PTR 8[rbp]
	mov	edi, DWORD PTR DISCENB[rip]
	or	DWORD PTR 8[rsi], edi
.L16:
	mov	esi, DWORD PTR 24[rbx]
	test	DWORD PTR MSG_EXT_PPR_IU_REQ[rip], esi
	je	.L18
	mov	esi, DWORD PTR SCB_PACKETIZED[rip]
	or	DWORD PTR 0[rbp], esi
	mov	rsi, QWORD PTR 8[rbp]
	cmp	QWORD PTR [rsi], 0
	je	.L18
	mov	edi, DWORD PTR MK_MESSAGE[rip]
	not	edi
	and	DWORD PTR 8[rsi], edi
.L18:
	test	DWORD PTR CAM_NEGOTIATE[rip], ecx
	jne	.L46
.L20:
	test	DWORD PTR 4[rdx], eax
	je	.L22
	mov	eax, DWORD PTR SCB_AUTO_NEGOTIATE[rip]
	or	DWORD PTR 0[rbp], eax
	mov	rax, QWORD PTR 8[rbp]
	mov	edx, DWORD PTR MK_MESSAGE[rip]
	or	DWORD PTR 8[rax], edx
.L22:
	mov	edx, DWORD PTR pending_links[rip]
	lea	rdi, 8[r13]
	mov	rsi, rbp
	call	LIST_INSERT_HEAD@PLT
	mov	eax, DWORD PTR CAM_SIM_QUEUED[rip]
	or	DWORD PTR 16[r14], eax
	mov	rdi, rbp
	call	aic_scb_timer_start@PLT
	mov	eax, DWORD PTR 0[rbp]
	test	DWORD PTR SCB_TARGET_IMMEDIATE[rip], eax
	je	.L23
	mov	rbx, QWORD PTR 0[r13]
	mov	rdi, rbp
	call	SCB_GET_TAG@PLT
	mov	rdi, r13
	mov	QWORD PTR [rbx+rax*8], rbp
	call	ahd_pause@PLT
	mov	rdi, rbp
	call	SCB_GET_TAG@PLT
	mov	rdi, r13
	mov	rsi, rax
	call	ahd_set_scbptr@PLT
	mov	edx, DWORD PTR CONT_MSG_LOOP_TARG[rip]
	mov	esi, DWORD PTR RETURN_1[rip]
	mov	rdi, r13
	call	ahd_outb@PLT
	mov	rdi, r13
	call	ahd_unpause@PLT
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L42:
	cmp	DWORD PTR EFBIG[rip], ecx
	je	.L47
	mov	esi, DWORD PTR CAM_REQ_CMP_ERR[rip]
	call	aic_set_transaction_status@PLT
.L4:
	test	ebx, ebx
	je	.L26
.L24:
	mov	esi, DWORD PTR 16[rbp]
	mov	edi, DWORD PTR 12[r13]
	call	bus_dmamap_unload@PLT
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L46:
	cmp	QWORD PTR [rbx], 0
	jne	.L21
	cmp	QWORD PTR 8[rbx], 0
	je	.L48
.L21:
	mov	eax, DWORD PTR SCB_NEGOTIATE[rip]
	or	DWORD PTR 0[rbp], eax
	mov	rax, QWORD PTR 8[rbp]
	mov	edx, DWORD PTR MK_MESSAGE[rip]
	or	DWORD PTR 8[rax], edx
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L47:
	mov	esi, DWORD PTR CAM_REQ_TOO_BIG[rip]
	call	aic_set_transaction_status@PLT
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L45:
	mov	rdx, QWORD PTR 8[rbp]
	mov	eax, DWORD PTR DPHASE_PENDING[rip]
	or	DWORD PTR 20[rdx], eax
	mov	eax, DWORD PTR [r14]
	and	eax, DWORD PTR CAM_DIR_MASK[rip]
	cmp	eax, DWORD PTR CAM_DIR_OUT[rip]
	je	.L49
	mov	eax, DWORD PTR P_DATAIN[rip]
	mov	DWORD PTR 16[rdx], eax
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L23:
	mov	rsi, rbp
	mov	rdi, r13
	call	ahd_queue_scb@PLT
	jmp	.L1
.L48:
	cmp	QWORD PTR 16[rbx], 0
	je	.L20
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L49:
	mov	eax, DWORD PTR P_DATAOUT[rip]
	mov	DWORD PTR 16[rdx], eax
	jmp	.L13
.L44:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	ahd_execute_scb, .-ahd_execute_scb
	.comm	pending_links,4,4
	.comm	XPT_CONT_TARGET_IO,8,8
	.comm	SCB_TARGET_IMMEDIATE,4,4
	.comm	SCB_PACKETIZED,4,4
	.comm	SCB_NEGOTIATE,4,4
	.comm	SCB_AUTO_NEGOTIATE,4,4
	.comm	RETURN_1,4,4
	.comm	P_DATAOUT,4,4
	.comm	P_DATAIN,4,4
	.comm	MSG_EXT_PPR_IU_REQ,4,4
	.comm	MK_MESSAGE,4,4
	.comm	EFBIG,4,4
	.comm	DPHASE_PENDING,4,4
	.comm	DISCENB,4,4
	.comm	CONT_MSG_LOOP_TARG,4,4
	.comm	CAM_SIM_QUEUED,4,4
	.comm	CAM_REQ_TOO_BIG,4,4
	.comm	CAM_REQ_INPROG,8,8
	.comm	CAM_REQ_CMP_ERR,4,4
	.comm	CAM_NEGOTIATE,4,4
	.comm	CAM_DIS_DISCONNECT,4,4
	.comm	CAM_DIR_OUT,4,4
	.comm	CAM_DIR_MASK,4,4
	.comm	CAM_DIR_IN,4,4
	.comm	BUS_DMASYNC_PREWRITE,4,4
	.comm	BUS_DMASYNC_PREREAD,4,4
	.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_aic79xx_osm.c_ahd_execute_scb.c"
	.text
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC0:
	.word	__stack_chk_guard
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	ahd_execute_scb, %function
ahd_execute_scb:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, lr}
	mov	r4, r2
	ldr	r2, .L54
	sub	sp, sp, #16
	cmp	r3, #0
	mov	r6, r0
	ldr	r2, [r2]
	str	r2, [sp, #12]
	mov	r2,#0
	ldr	r8, [r0, #24]
	ldr	r7, [r0, #20]
	bne	.L49
	cmp	r4, #0
	str	r3, [r0, #16]
	bne	.L50
	bl	aic_get_transaction_status
	ldr	r3, .L54+4
	ldr	r3, [r3]
	cmp	r0, r3
	beq	.L26
.L27:
	mov	r1, r6
	mov	r0, r7
	bl	ahd_free_scb
	mov	r0, r8
	bl	xpt_done
.L1:
	ldr	r3, .L54
	ldr	r2, [r3]
	ldr	r3, [sp, #12]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L51
	add	sp, sp, #16
	@ sp needed
	pop	{r4, r5, r6, r7, r8, pc}
.L50:
	ldr	r2, [r0, #12]
	addgt	r5, r1, #8
	ble	.L12
.L11:
	sub	r1, r4, #1
	clz	r1, r1
	lsr	r1, r1, #5
	ldr	r3, [r5, #-4]
	str	r1, [sp, #4]
	ldr	r1, [r5, #-8]
	mov	r0, r7
	str	r1, [sp]
	mov	r1, r6
	bl	ahd_sg_setup
	subs	r4, r4, #1
	mov	r2, r0
	add	r5, r5, #8
	bne	.L11
.L12:
	ldr	r4, .L54+8
	ldr	r2, .L54+12
	ldr	r1, [r4]
	ldr	r3, [r8]
	ldr	r2, [r2]
	and	r3, r3, r1
	cmp	r3, r2
	beq	.L52
	ldr	r3, .L54+16
	ldr	r2, [r3]
.L13:
	ldr	r1, [r6, #8]
	ldr	r0, [r7, #8]
	bl	bus_dmamap_sync
	ldr	r3, .L54+20
	ldr	r2, [r8, #4]
	ldr	r3, [r3]
	cmp	r2, r3
	bne	.L14
	ldr	r3, .L54+24
	ldr	r2, [r8]
	ldr	ip, [r4]
	ldr	r1, [r6, #4]
	ldr	r3, [r3]
	ldr	r0, .L54+28
	and	r2, r2, ip
	cmp	r2, r3
	ldr	r0, [r0]
	ldr	r3, [r1, #16]
	orr	r3, r3, r0
	str	r3, [r1, #16]
	ldreq	r3, .L54+32
	ldrne	r3, .L54+36
	ldr	r3, [r3]
	str	r3, [r1, #12]
.L14:
	mov	r0, r6
	bl	aic_get_transaction_status
	ldr	r3, .L54+4
	ldr	r3, [r3]
	cmp	r0, r3
	bne	.L25
.L26:
	ldr	r3, [r6, #4]
	mov	r0, r7
	ldr	r1, [r3, #8]
	bl	SCSIID_CHANNEL
	ldr	r3, [r6, #4]
	mov	r4, r0
	ldr	r0, [r3, #8]
	bl	SCSIID_OUR_ID
	ldr	r3, [r6, #4]
	mov	r5, r0
	ldr	r1, [r3, #8]
	mov	r0, r7
	bl	SCSIID_TARGET
	add	ip, sp, #8
	mov	r3, r0
	mov	r2, r5
	mov	r1, r4
	str	ip, [sp]
	mov	r0, r7
	bl	ahd_fetch_transinfo
	mov	r1, r6
	mov	r4, r0
	mov	r0, r7
	bl	SCB_GET_TARGET_MASK
	ldr	r3, [sp, #8]
	ldr	r2, [r3]
	tst	r0, r2
	bne	.L16
	ldr	r2, [r8]
.L17:
	ldr	r1, .L54+40
	ldr	ip, [r4, #12]
	ldr	r1, [r1]
	tst	ip, r1
	beq	.L19
	ldr	ip, [r6, #4]
	ldr	r1, .L54+44
	ldr	lr, [ip]
	ldr	r5, [r1]
	cmp	lr, #0
	ldr	r1, [r6]
	ldrne	lr, .L54+48
	orr	r1, r1, r5
	str	r1, [r6]
	ldrne	lr, [lr]
	ldrne	r1, [ip, #4]
	bicne	r1, r1, lr
	strne	r1, [ip, #4]
.L19:
	ldr	r1, .L54+52
	ldr	r1, [r1]
	tst	r2, r1
	beq	.L21
	ldr	r2, [r4]
	cmp	r2, #0
	bne	.L22
	ldr	r2, [r4, #4]
	cmp	r2, #0
	beq	.L53
.L22:
	ldr	r3, .L54+56
.L47:
	ldr	r3, [r3]
	ldr	r2, [r6]
	ldr	r1, [r6, #4]
	ldr	r0, .L54+48
	orr	r2, r2, r3
	ldr	r0, [r0]
	ldr	r3, [r1, #4]
	str	r2, [r6]
	orr	r3, r3, r0
	str	r3, [r1, #4]
.L23:
	ldr	r3, .L54+60
	mov	r1, r6
	ldr	r2, [r3]
	add	r0, r7, #4
	bl	LIST_INSERT_HEAD
	ldr	r2, .L54+64
	ldr	r3, [r8, #8]
	ldr	r2, [r2]
	mov	r0, r6
	orr	r3, r3, r2
	str	r3, [r8, #8]
	bl	aic_scb_timer_start
	ldr	r3, .L54+68
	ldr	r2, [r6]
	ldr	r3, [r3]
	tst	r2, r3
	beq	.L24
	mov	r0, r6
	ldr	r4, [r7]
	bl	SCB_GET_TAG
	mov	r3, r0
	mov	r0, r7
	str	r6, [r4, r3, lsl #2]
	bl	ahd_pause
	mov	r0, r6
	bl	SCB_GET_TAG
	mov	r1, r0
	mov	r0, r7
	bl	ahd_set_scbptr
	ldr	r3, .L54+72
	ldr	r2, .L54+76
	mov	r0, r7
	ldr	r2, [r2]
	ldr	r1, [r3]
	bl	ahd_outb
	mov	r0, r7
	bl	ahd_unpause
	b	.L1
.L49:
	ldr	r2, .L54+80
	ldr	r2, [r2]
	cmp	r2, r3
	ldreq	r3, .L54+84
	ldrne	r3, .L54+88
	ldr	r1, [r3]
	bl	aic_set_transaction_status
	cmp	r4, #0
	beq	.L27
.L25:
	ldr	r1, [r6, #8]
	ldr	r0, [r7, #8]
	bl	bus_dmamap_unload
	b	.L27
.L16:
	ldr	r1, .L54+92
	ldr	r2, [r8]
	ldr	r1, [r1]
	tst	r2, r1
	bne	.L17
	ldr	ip, [r6, #4]
	ldr	lr, .L54+96
	ldr	r1, [ip, #4]
	ldr	lr, [lr]
	orr	r1, r1, lr
	str	r1, [ip, #4]
	b	.L17
.L53:
	ldr	r2, [r4, #8]
	cmp	r2, #0
	bne	.L22
.L21:
	ldr	r3, [r3, #4]
	tst	r0, r3
	beq	.L23
	ldr	r3, .L54+100
	b	.L47
.L52:
	ldr	r3, .L54+104
	ldr	r2, [r3]
	b	.L13
.L24:
	mov	r1, r6
	mov	r0, r7
	bl	ahd_queue_scb
	b	.L1
.L51:
	bl	__stack_chk_fail
.L55:
	.align	2
.L54:
	.word	.LC0
	.word	CAM_REQ_INPROG
	.word	CAM_DIR_MASK
	.word	CAM_DIR_IN
	.word	BUS_DMASYNC_PREWRITE
	.word	XPT_CONT_TARGET_IO
	.word	CAM_DIR_OUT
	.word	DPHASE_PENDING
	.word	P_DATAOUT
	.word	P_DATAIN
	.word	MSG_EXT_PPR_IU_REQ
	.word	SCB_PACKETIZED
	.word	MK_MESSAGE
	.word	CAM_NEGOTIATE
	.word	SCB_NEGOTIATE
	.word	pending_links
	.word	CAM_SIM_QUEUED
	.word	SCB_TARGET_IMMEDIATE
	.word	RETURN_1
	.word	CONT_MSG_LOOP_TARG
	.word	EFBIG
	.word	CAM_REQ_TOO_BIG
	.word	CAM_REQ_CMP_ERR
	.word	CAM_DIS_DISCONNECT
	.word	DISCENB
	.word	SCB_AUTO_NEGOTIATE
	.word	BUS_DMASYNC_PREREAD
	.size	ahd_execute_scb, .-ahd_execute_scb
	.comm	pending_links,4,4
	.comm	XPT_CONT_TARGET_IO,4,4
	.comm	SCB_TARGET_IMMEDIATE,4,4
	.comm	SCB_PACKETIZED,4,4
	.comm	SCB_NEGOTIATE,4,4
	.comm	SCB_AUTO_NEGOTIATE,4,4
	.comm	RETURN_1,4,4
	.comm	P_DATAOUT,4,4
	.comm	P_DATAIN,4,4
	.comm	MSG_EXT_PPR_IU_REQ,4,4
	.comm	MK_MESSAGE,4,4
	.comm	EFBIG,4,4
	.comm	DPHASE_PENDING,4,4
	.comm	DISCENB,4,4
	.comm	CONT_MSG_LOOP_TARG,4,4
	.comm	CAM_SIM_QUEUED,4,4
	.comm	CAM_REQ_TOO_BIG,4,4
	.comm	CAM_REQ_INPROG,4,4
	.comm	CAM_REQ_CMP_ERR,4,4
	.comm	CAM_NEGOTIATE,4,4
	.comm	CAM_DIS_DISCONNECT,4,4
	.comm	CAM_DIR_OUT,4,4
	.comm	CAM_DIR_MASK,4,4
	.comm	CAM_DIR_IN,4,4
	.comm	BUS_DMASYNC_PREWRITE,4,4
	.comm	BUS_DMASYNC_PREREAD,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
