	.file	"extr_thunder_bgx.c_thunder_bgx_attach.c"
	.intel_syntax noprefix
	.text
	.section	.rodata.str1.8,"aMS",@progbits,1
	.align 8
.LC0:
	.string	"Could not allocate CSR memory space\n"
	.align 8
.LC1:
	.string	"BGX%d failed to enable lmac%d\n"
	.text
	.p2align 4
	.type	thunder_bgx_attach, @function
thunder_bgx_attach:
.LFB0:
	.cfi_startproc
	endbr64
	push	r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	push	r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	mov	r13d, edi
	mov	edi, 32
	push	r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	push	rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	push	rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	sub	rsp, 16
	.cfi_def_cfa_offset 64
	mov	esi, DWORD PTR M_BGX[rip]
	mov	edx, DWORD PTR M_WAITOK[rip]
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR 8[rsp], rax
	xor	eax, eax
	or	edx, DWORD PTR M_ZERO[rip]
	call	malloc@PLT
	mov	edi, r13d
	mov	DWORD PTR 24[rax], r13d
	mov	rbp, rax
	call	device_get_softc@PLT
	mov	edi, r13d
	mov	QWORD PTR [rax], rbp
	call	pci_enable_busmaster@PLT
	mov	edi, DWORD PTR PCI_CFG_REG_BAR_NUM[rip]
	call	PCIR_BAR@PLT
	mov	ecx, DWORD PTR RF_ACTIVE[rip]
	lea	rdx, 4[rsp]
	mov	edi, r13d
	mov	esi, DWORD PTR SYS_RES_MEMORY[rip]
	mov	DWORD PTR 4[rsp], eax
	call	bus_alloc_resource_any@PLT
	mov	QWORD PTR 16[rbp], rax
	test	rax, rax
	je	.L15
	mov	rdi, rax
	call	rman_get_start@PLT
	mov	ecx, DWORD PTR BGX_NODE_ID_SHIFT[rip]
	mov	rdi, QWORD PTR 16[rbp]
	sar	eax, cl
	and	eax, DWORD PTR BGX_NODE_ID_MASK[rip]
	mov	DWORD PTR 0[rbp], eax
	call	nic_get_node_id@PLT
	mov	rdx, QWORD PTR bgx_vnic[rip]
	imul	eax, DWORD PTR MAX_BGX_PER_CN88XX[rip]
	mov	rdi, rbp
	add	eax, DWORD PTR 0[rbp]
	mov	DWORD PTR 0[rbp], eax
	cdqe
	mov	QWORD PTR [rdx+rax*8], rbp
	call	bgx_get_qlm_mode@PLT
	mov	rdi, rbp
	call	bgx_init_phy@PLT
	mov	r14d, eax
	test	eax, eax
	je	.L16
.L4:
	movsx	rdx, DWORD PTR 0[rbp]
	mov	rax, QWORD PTR bgx_vnic[rip]
	mov	r12, QWORD PTR 16[rbp]
	mov	QWORD PTR [rax+rdx*8], 0
	mov	rdi, r12
	call	rman_get_rid@PLT
	mov	esi, DWORD PTR SYS_RES_MEMORY[rip]
	mov	rcx, r12
	mov	edi, r13d
	mov	edx, eax
	call	bus_release_resource@PLT
.L3:
	mov	esi, DWORD PTR M_BGX[rip]
	mov	rdi, rbp
	call	free@PLT
	mov	edi, r13d
	call	pci_disable_busmaster@PLT
.L1:
	mov	rax, QWORD PTR 8[rsp]
	xor	rax, QWORD PTR fs:40
	jne	.L17
	add	rsp, 16
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	mov	eax, r14d
	pop	rbx
	.cfi_def_cfa_offset 40
	pop	rbp
	.cfi_def_cfa_offset 32
	pop	r12
	.cfi_def_cfa_offset 24
	pop	r13
	.cfi_def_cfa_offset 16
	pop	r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L16:
	.cfi_restore_state
	mov	rdi, rbp
	xor	r12d, r12d
	call	bgx_init_hw@PLT
	cmp	QWORD PTR 8[rbp], 0
	jg	.L5
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L7:
	add	r12, 1
	cmp	QWORD PTR 8[rbp], r12
	jle	.L1
.L5:
	mov	rsi, r12
	mov	rdi, rbp
	call	bgx_lmac_enable@PLT
	mov	ebx, eax
	test	eax, eax
	je	.L7
	mov	edx, DWORD PTR 0[rbp]
	mov	rcx, r12
	lea	rsi, .LC1[rip]
	mov	edi, r13d
	xor	eax, eax
	mov	r14d, ebx
	call	device_printf@PLT
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L15:
	lea	rsi, .LC0[rip]
	mov	edi, r13d
	xor	eax, eax
	call	device_printf@PLT
	mov	r14d, DWORD PTR ENXIO[rip]
	jmp	.L3
.L17:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	thunder_bgx_attach, .-thunder_bgx_attach
	.comm	bgx_vnic,8,8
	.comm	SYS_RES_MEMORY,4,4
	.comm	RF_ACTIVE,4,4
	.comm	PCI_CFG_REG_BAR_NUM,4,4
	.comm	M_ZERO,4,4
	.comm	M_WAITOK,4,4
	.comm	M_BGX,4,4
	.comm	MAX_BGX_PER_CN88XX,4,4
	.comm	ENXIO,4,4
	.comm	BGX_NODE_ID_SHIFT,4,4
	.comm	BGX_NODE_ID_MASK,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_thunder_bgx.c_thunder_bgx_attach.c"
	.text
	.section	.rodata.str1.4,"aMS",%progbits,1
	.align	2
.LC0:
	.ascii	"Could not allocate CSR memory space\012\000"
	.align	2
.LC1:
	.ascii	"BGX%d failed to enable lmac%d\012\000"
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC2:
	.word	__stack_chk_guard
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	thunder_bgx_attach, %function
thunder_bgx_attach:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, lr}
	ldr	r2, .L17
	ldr	r3, .L17+4
	ldr	r2, [r2]
	ldr	r3, [r3]
	ldr	r7, .L17+8
	orr	r2, r2, r3
	ldr	r3, .L17+12
	sub	sp, sp, #8
	mov	r5, r0
	ldr	r1, [r7]
	mov	r0, #16
	ldr	r3, [r3]
	str	r3, [sp, #4]
	mov	r3,#0
	bl	malloc
	mov	r4, r0
	mov	r0, r5
	str	r5, [r4, #12]
	bl	device_get_softc
	mov	r3, r0
	mov	r0, r5
	str	r4, [r3]
	bl	pci_enable_busmaster
	ldr	r3, .L17+16
	ldr	r8, .L17+20
	ldr	r0, [r3]
	bl	PCIR_BAR
	mov	ip, r0
	ldr	r3, .L17+24
	mov	r0, r5
	mov	r2, sp
	ldr	r3, [r3]
	ldr	r1, [r8]
	str	ip, [sp]
	bl	bus_alloc_resource_any
	cmp	r0, #0
	str	r0, [r4, #8]
	beq	.L14
	bl	rman_get_start
	mov	r1, r0
	ldr	r2, .L17+28
	ldr	r3, .L17+32
	ldr	r2, [r2]
	ldr	r3, [r3]
	ldr	r0, [r4, #8]
	and	r3, r3, r1, asr r2
	str	r3, [r4]
	bl	nic_get_node_id
	ldr	r2, .L17+36
	ldr	r3, [r4]
	ldr	r2, [r2]
	ldr	r9, .L17+40
	mla	r0, r2, r0, r3
	ldr	r3, [r9]
	str	r0, [r4]
	str	r4, [r3, r0, lsl #2]
	mov	r0, r4
	bl	bgx_get_qlm_mode
	mov	r0, r4
	bl	bgx_init_phy
	subs	r6, r0, #0
	beq	.L15
.L4:
	mov	r1, #0
	ldr	r3, [r9]
	ldr	r2, [r4]
	ldr	r0, [r4, #8]
	str	r1, [r3, r2, lsl #2]
	ldr	r8, [r8]
	bl	rman_get_rid
	mov	r1, r8
	mov	r2, r0
	ldr	r3, [r4, #8]
	mov	r0, r5
	bl	bus_release_resource
.L3:
	mov	r0, r4
	ldr	r1, [r7]
	bl	free
	mov	r0, r5
	bl	pci_disable_busmaster
.L1:
	ldr	r3, .L17+12
	ldr	r2, [r3]
	ldr	r3, [sp, #4]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L16
	mov	r0, r6
	add	sp, sp, #8
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, pc}
.L15:
	mov	r0, r4
	bl	bgx_init_hw
	ldr	r3, [r4, #4]
	cmp	r3, #0
	ble	.L1
	mov	r10, r6
	b	.L5
.L7:
	ldr	r3, [r4, #4]
	add	r10, r10, #1
	cmp	r3, r10
	ble	.L1
.L5:
	mov	r1, r10
	mov	r0, r4
	bl	bgx_lmac_enable
	subs	ip, r0, #0
	beq	.L7
	mov	r3, r10
	mov	r0, r5
	ldr	r2, [r4]
	ldr	r1, .L17+44
	mov	r6, ip
	bl	device_printf
	b	.L4
.L14:
	mov	r0, r5
	ldr	r1, .L17+48
	bl	device_printf
	ldr	r3, .L17+52
	ldr	r6, [r3]
	b	.L3
.L16:
	bl	__stack_chk_fail
.L18:
	.align	2
.L17:
	.word	M_WAITOK
	.word	M_ZERO
	.word	M_BGX
	.word	.LC2
	.word	PCI_CFG_REG_BAR_NUM
	.word	SYS_RES_MEMORY
	.word	RF_ACTIVE
	.word	BGX_NODE_ID_SHIFT
	.word	BGX_NODE_ID_MASK
	.word	MAX_BGX_PER_CN88XX
	.word	bgx_vnic
	.word	.LC1
	.word	.LC0
	.word	ENXIO
	.size	thunder_bgx_attach, .-thunder_bgx_attach
	.comm	bgx_vnic,4,4
	.comm	SYS_RES_MEMORY,4,4
	.comm	RF_ACTIVE,4,4
	.comm	PCI_CFG_REG_BAR_NUM,4,4
	.comm	M_ZERO,4,4
	.comm	M_WAITOK,4,4
	.comm	M_BGX,4,4
	.comm	MAX_BGX_PER_CN88XX,4,4
	.comm	ENXIO,4,4
	.comm	BGX_NODE_ID_SHIFT,4,4
	.comm	BGX_NODE_ID_MASK,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
