	.file	"extr_if_run.c_run_load_microcode.c"
	.intel_syntax noprefix
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"RT2870"
.LC1:
	.string	"RT3071"
.LC2:
	.string	"runfw"
	.section	.rodata.str1.8,"aMS",@progbits,1
	.align 8
.LC3:
	.string	"failed loadfirmware of file %s\n"
	.align 8
.LC4:
	.string	"invalid firmware size (should be 8KB)\n"
	.section	.rodata.str1.1
.LC5:
	.string	"firmware checksum failed\n"
.LC6:
	.string	"firmware reset failed\n"
	.section	.rodata.str1.8
	.align 8
.LC7:
	.string	"firmware %s ver. %u.%u loaded\n"
	.align 8
.LC8:
	.string	"timeout waiting for MCU to initialize\n"
	.text
	.p2align 4
	.type	run_load_microcode, @function
run_load_microcode:
.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
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	mov	rbx, rdi
	sub	rsp, 56
	.cfi_def_cfa_offset 112
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR 40[rsp], rax
	xor	eax, eax
	call	RUN_UNLOCK@PLT
	lea	rdi, .LC2[rip]
	call	firmware_get@PLT
	mov	rdi, rbx
	mov	rbp, rax
	call	RUN_LOCK@PLT
	test	rbp, rbp
	je	.L31
	cmp	DWORD PTR 0[rbp], 8192
	jne	.L32
	mov	eax, DWORD PTR [rbx]
	mov	rdx, QWORD PTR 8[rbp]
	cmp	eax, 10336
	setne	sil
	cmp	eax, 10354
	setne	cl
	test	sil, cl
	je	.L16
	lea	r15, 32768[rdx]
	cmp	eax, 12400
	jne	.L6
.L16:
	mov	r15, rdx
.L6:
	mov	r12, QWORD PTR [rdx]
	mov	edi, 271057424
	call	be64toh@PLT
	cmp	rax, r12
	jne	.L33
	mov	eax, DWORD PTR 4[rbx]
	test	DWORD PTR RUN_FLAG_FWLOAD_NEEDED[rip], eax
	jne	.L34
.L8:
	mov	eax, DWORD PTR UT_WRITE_VENDOR_DEVICE[rip]
	mov	edi, DWORD PTR 24[rsp]
	mov	esi, 8
	mov	DWORD PTR 32[rsp], eax
	mov	eax, DWORD PTR RT2870_RESET[rip]
	mov	DWORD PTR 28[rsp], eax
	call	USETW@PLT
	mov	edi, DWORD PTR 20[rsp]
	xor	esi, esi
	call	USETW@PLT
	mov	edi, DWORD PTR 16[rsp]
	xor	esi, esi
	call	USETW@PLT
	mov	edi, DWORD PTR 16[rbx]
	lea	rdx, 16[rsp]
	xor	ecx, ecx
	lea	rsi, 12[rbx]
	call	usbd_do_request@PLT
	mov	r12d, eax
	test	eax, eax
	jne	.L35
	mov	esi, 10
	mov	rdi, rbx
	call	run_delay@PLT
	mov	esi, DWORD PTR RT2860_H2M_BBPAGENT[rip]
	xor	edx, edx
	mov	rdi, rbx
	call	run_write@PLT
	mov	esi, DWORD PTR RT2860_H2M_MAILBOX[rip]
	xor	edx, edx
	mov	rdi, rbx
	call	run_write@PLT
	mov	esi, DWORD PTR RT2860_H2M_INTSRC[rip]
	xor	edx, edx
	mov	rdi, rbx
	call	run_write@PLT
	mov	esi, DWORD PTR RT2860_MCU_CMD_RFRESET[rip]
	xor	edx, edx
	mov	rdi, rbx
	call	run_mcu_cmd@PLT
	mov	r12d, eax
	test	eax, eax
	jne	.L5
	mov	r13d, 1000
	lea	r14, 12[rsp]
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L37:
	mov	eax, DWORD PTR 12[rsp]
	test	DWORD PTR RT2860_MCU_READY[rip], eax
	jne	.L10
	mov	esi, 10
	mov	rdi, rbx
	call	run_delay@PLT
	sub	r13d, 1
	je	.L36
.L11:
	mov	esi, DWORD PTR RT2860_SYS_CTRL[rip]
	mov	rdx, r14
	mov	rdi, rbx
	call	run_read@PLT
	mov	r12d, eax
	test	eax, eax
	je	.L37
	.p2align 4,,10
	.p2align 3
.L5:
	mov	esi, DWORD PTR FIRMWARE_UNLOAD[rip]
	mov	rdi, rbp
	call	firmware_put@PLT
.L1:
	mov	rax, QWORD PTR 40[rsp]
	xor	rax, QWORD PTR fs:40
	jne	.L38
	add	rsp, 56
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	mov	eax, r12d
	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
.L32:
	.cfi_restore_state
	mov	edi, DWORD PTR 8[rbx]
	lea	rsi, .LC4[rip]
	xor	eax, eax
	call	device_printf@PLT
	mov	r12d, DWORD PTR EINVAL[rip]
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L33:
	mov	edi, DWORD PTR 8[rbx]
	lea	rsi, .LC5[rip]
	xor	eax, eax
	call	device_printf@PLT
	mov	r12d, DWORD PTR EINVAL[rip]
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L35:
	mov	edi, DWORD PTR 8[rbx]
	lea	rsi, .LC6[rip]
	xor	eax, eax
	call	device_printf@PLT
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L34:
	mov	esi, DWORD PTR RT2870_FW_BASE[rip]
	mov	ecx, 4096
	mov	rdx, r15
	mov	rdi, rbx
	call	run_write_region_1@PLT
	mov	esi, DWORD PTR RT2860_H2M_MAILBOX_CID[rip]
	mov	rdi, rbx
	mov	edx, -1
	call	run_write@PLT
	mov	esi, DWORD PTR RT2860_H2M_MAILBOX_STATUS[rip]
	mov	edx, -1
	mov	rdi, rbx
	call	run_write@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L31:
	mov	edi, DWORD PTR 8[rbx]
	lea	rdx, .LC2[rip]
	lea	rsi, .LC3[rip]
	xor	eax, eax
	call	device_printf@PLT
	mov	r12d, DWORD PTR ENOENT[rip]
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L10:
	cmp	QWORD PTR 8[rbp], r15
	lea	rax, .LC1[rip]
	mov	edi, DWORD PTR 8[rbx]
	lea	rdx, .LC0[rip]
	cmovne	rdx, rax
	mov	rcx, QWORD PTR 32736[r15]
	mov	r8, QWORD PTR 32744[r15]
	xor	eax, eax
	lea	rsi, .LC7[rip]
	call	device_printf@PLT
	jmp	.L5
.L36:
	mov	edi, DWORD PTR 8[rbx]
	lea	rsi, .LC8[rip]
	xor	eax, eax
	call	device_printf@PLT
	mov	r12d, DWORD PTR ETIMEDOUT[rip]
	jmp	.L5
.L38:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	run_load_microcode, .-run_load_microcode
	.comm	UT_WRITE_VENDOR_DEVICE,4,4
	.comm	RUN_FLAG_FWLOAD_NEEDED,4,4
	.comm	RT2870_RESET,4,4
	.comm	RT2870_FW_BASE,4,4
	.comm	RT2860_SYS_CTRL,4,4
	.comm	RT2860_MCU_READY,4,4
	.comm	RT2860_MCU_CMD_RFRESET,4,4
	.comm	RT2860_H2M_MAILBOX_STATUS,4,4
	.comm	RT2860_H2M_MAILBOX_CID,4,4
	.comm	RT2860_H2M_MAILBOX,4,4
	.comm	RT2860_H2M_INTSRC,4,4
	.comm	RT2860_H2M_BBPAGENT,4,4
	.comm	FIRMWARE_UNLOAD,4,4
	.comm	ETIMEDOUT,4,4
	.comm	ENOENT,4,4
	.comm	EINVAL,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_if_run.c_run_load_microcode.c"
	.text
	.section	.rodata.str1.4,"aMS",%progbits,1
	.align	2
.LC0:
	.ascii	"RT2870\000"
	.align	2
.LC1:
	.ascii	"RT3071\000"
	.align	2
.LC2:
	.ascii	"runfw\000"
	.align	2
.LC3:
	.ascii	"failed loadfirmware of file %s\012\000"
	.align	2
.LC4:
	.ascii	"invalid firmware size (should be 8KB)\012\000"
	.align	2
.LC5:
	.ascii	"firmware checksum failed\012\000"
	.align	2
.LC6:
	.ascii	"firmware reset failed\012\000"
	.align	2
.LC7:
	.ascii	"firmware %s ver. %u.%u loaded\012\000"
	.align	2
.LC8:
	.ascii	"timeout waiting for MCU to initialize\012\000"
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC9:
	.word	__stack_chk_guard
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	run_load_microcode, %function
run_load_microcode:
	@ args = 0, pretend = 0, frame = 32
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, lr}
	ldr	r3, .L32
	sub	sp, sp, #40
	ldr	r3, [r3]
	str	r3, [sp, #36]
	mov	r3,#0
	mov	r5, r0
	bl	RUN_UNLOCK
	ldr	r0, .L32+4
	bl	firmware_get
	mov	r6, r0
	mov	r0, r5
	bl	RUN_LOCK
	cmp	r6, #0
	beq	.L24
	ldr	r3, [r6]
	cmp	r3, #8192
	bne	.L25
	ldr	r3, .L32+8
	ldr	r2, [r5]
	ldr	r0, .L32+12
	ldr	r1, .L32+16
	cmp	r2, r3
	cmpne	r2, r0
	movne	r3, #1
	moveq	r3, #0
	cmp	r2, r1
	moveq	r3, #0
	andne	r3, r3, #1
	cmp	r3, #0
	ldr	r3, [r6, #4]
	ldr	r0, .L32+20
	moveq	r10, r3
	ldr	r4, [r3]
	addne	r10, r3, #16384
	bl	be64toh
	cmp	r0, r4
	bne	.L26
	ldr	r3, .L32+24
	ldr	r2, [r5, #4]
	ldr	r3, [r3]
	tst	r2, r3
	bne	.L27
.L8:
	ldr	r2, .L32+28
	ldr	r3, .L32+32
	ldr	r2, [r2]
	ldr	r3, [r3]
	mov	r1, #8
	ldr	r0, [sp, #24]
	str	r2, [sp, #32]
	str	r3, [sp, #28]
	bl	USETW
	mov	r1, #0
	ldr	r0, [sp, #20]
	bl	USETW
	mov	r1, #0
	ldr	r0, [sp, #16]
	bl	USETW
	mov	r3, #0
	ldr	r0, [r5, #16]
	add	r2, sp, #16
	add	r1, r5, #12
	bl	usbd_do_request
	subs	r4, r0, #0
	bne	.L28
	mov	r1, #10
	mov	r0, r5
	bl	run_delay
	ldr	r3, .L32+36
	mov	r2, r4
	ldr	r1, [r3]
	mov	r0, r5
	bl	run_write
	ldr	r3, .L32+40
	mov	r2, r4
	ldr	r1, [r3]
	mov	r0, r5
	bl	run_write
	ldr	r3, .L32+44
	mov	r2, r4
	ldr	r1, [r3]
	mov	r0, r5
	bl	run_write
	ldr	r3, .L32+48
	mov	r2, r4
	mov	r0, r5
	ldr	r1, [r3]
	bl	run_mcu_cmd
	subs	r4, r0, #0
	bne	.L5
	mov	r7, #1000
	ldr	r8, .L32+52
	ldr	r9, .L32+56
	b	.L11
.L30:
	ldr	r2, [sp, #12]
	ldr	r3, [r9]
	tst	r2, r3
	bne	.L10
	mov	r1, #10
	mov	r0, r5
	bl	run_delay
	subs	r7, r7, #1
	beq	.L29
.L11:
	mov	r0, r5
	ldr	r1, [r8]
	add	r2, sp, #12
	bl	run_read
	subs	r4, r0, #0
	beq	.L30
.L5:
	ldr	r3, .L32+60
	mov	r0, r6
	ldr	r1, [r3]
	bl	firmware_put
.L1:
	ldr	r3, .L32
	ldr	r2, [r3]
	ldr	r3, [sp, #36]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L31
	mov	r0, r4
	add	sp, sp, #40
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, pc}
.L25:
	ldr	r0, [r5, #8]
	ldr	r1, .L32+64
	bl	device_printf
	ldr	r3, .L32+68
	ldr	r4, [r3]
	b	.L5
.L26:
	ldr	r0, [r5, #8]
	ldr	r1, .L32+72
	bl	device_printf
	ldr	r3, .L32+68
	ldr	r4, [r3]
	b	.L5
.L28:
	ldr	r0, [r5, #8]
	ldr	r1, .L32+76
	bl	device_printf
	b	.L5
.L27:
	ldr	r2, .L32+80
	mov	r3, #4096
	ldr	r1, [r2]
	mov	r0, r5
	mov	r2, r10
	bl	run_write_region_1
	ldr	r3, .L32+84
	mvn	r2, #0
	ldr	r1, [r3]
	mov	r0, r5
	bl	run_write
	ldr	r3, .L32+88
	mvn	r2, #0
	mov	r0, r5
	ldr	r1, [r3]
	bl	run_write
	b	.L8
.L24:
	ldr	r0, [r5, #8]
	ldr	r2, .L32+4
	ldr	r1, .L32+92
	bl	device_printf
	ldr	r3, .L32+96
	ldr	r4, [r3]
	b	.L1
.L10:
	add	r2, r10, #12288
	ldr	ip, [r6, #4]
	ldr	lr, [r2, #4084]
	ldr	r1, .L32+100
	cmp	ip, r10
	ldr	r3, [r2, #4080]
	ldr	r0, [r5, #8]
	ldr	r2, .L32+104
	str	lr, [sp]
	movne	r2, r1
	ldr	r1, .L32+108
	bl	device_printf
	b	.L5
.L29:
	ldr	r0, [r5, #8]
	ldr	r1, .L32+112
	bl	device_printf
	ldr	r3, .L32+116
	ldr	r4, [r3]
	b	.L5
.L31:
	bl	__stack_chk_fail
.L33:
	.align	2
.L32:
	.word	.LC9
	.word	.LC2
	.word	10336
	.word	10354
	.word	12400
	.word	271057424
	.word	RUN_FLAG_FWLOAD_NEEDED
	.word	UT_WRITE_VENDOR_DEVICE
	.word	RT2870_RESET
	.word	RT2860_H2M_BBPAGENT
	.word	RT2860_H2M_MAILBOX
	.word	RT2860_H2M_INTSRC
	.word	RT2860_MCU_CMD_RFRESET
	.word	RT2860_SYS_CTRL
	.word	RT2860_MCU_READY
	.word	FIRMWARE_UNLOAD
	.word	.LC4
	.word	EINVAL
	.word	.LC5
	.word	.LC6
	.word	RT2870_FW_BASE
	.word	RT2860_H2M_MAILBOX_CID
	.word	RT2860_H2M_MAILBOX_STATUS
	.word	.LC3
	.word	ENOENT
	.word	.LC1
	.word	.LC0
	.word	.LC7
	.word	.LC8
	.word	ETIMEDOUT
	.size	run_load_microcode, .-run_load_microcode
	.comm	UT_WRITE_VENDOR_DEVICE,4,4
	.comm	RUN_FLAG_FWLOAD_NEEDED,4,4
	.comm	RT2870_RESET,4,4
	.comm	RT2870_FW_BASE,4,4
	.comm	RT2860_SYS_CTRL,4,4
	.comm	RT2860_MCU_READY,4,4
	.comm	RT2860_MCU_CMD_RFRESET,4,4
	.comm	RT2860_H2M_MAILBOX_STATUS,4,4
	.comm	RT2860_H2M_MAILBOX_CID,4,4
	.comm	RT2860_H2M_MAILBOX,4,4
	.comm	RT2860_H2M_INTSRC,4,4
	.comm	RT2860_H2M_BBPAGENT,4,4
	.comm	FIRMWARE_UNLOAD,4,4
	.comm	ETIMEDOUT,4,4
	.comm	ENOENT,4,4
	.comm	EINVAL,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
