	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_octeon_console_send_cmd        ## -- Begin function octeon_console_send_cmd
	.p2align	4, 0x90
_octeon_console_send_cmd:               ## @octeon_console_send_cmd
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edx, %r14d
	movq	%rsi, %rbx
	movq	%rdi, %r12
	movq	%rsi, %rdi
	callq	_strlen
	movl	%eax, %r15d
	movq	(%r12), %rdi
	leaq	L_.str(%rip), %rsi
	movq	%rbx, %rdx
	callq	_dev_dbg
	movq	_BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	cmpl	%edx, %r15d
	jge	LBB0_1
## %bb.2:
	movq	%r12, %rdi
	movl	%r14d, %esi
	callq	_octeon_wait_for_bootloader
	testq	%rax, %rax
	je	LBB0_4
## %bb.3:
	movq	(%r12), %rdi
	leaq	L_.str.2(%rip), %rsi
	jmp	LBB0_6
LBB0_1:
	decl	%edx
	movq	(%r12), %rdi
	leaq	L_.str.1(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_7
LBB0_4:
	xorl	%r14d, %r14d
	xorl	%eax, %eax
	callq	_octeon_remote_lock
	movq	_BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rdi
	movq	%rbx, %rdx
	movl	%r15d, %ecx
	callq	_octeon_pci_write_core_mem
	movq	_BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rdi
	movl	%r15d, %edx
	callq	_octeon_write_device_mem32
	movq	_BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_OCTEON_PCI_IO_BUF_OWNER_OCTEON@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	callq	_octeon_write_device_mem32
	movq	%r12, %rdi
	movl	$200, %esi
	callq	_octeon_wait_for_bootloader
	movq	%rax, %rbx
	xorl	%eax, %eax
	callq	_octeon_remote_unlock
	testq	%rbx, %rbx
	je	LBB0_8
## %bb.5:
	movq	(%r12), %rdi
	leaq	L_.str.3(%rip), %rsi
LBB0_6:
	xorl	%eax, %eax
	callq	_dev_err
LBB0_7:
	movl	$-1, %r14d
LBB0_8:
	movl	%r14d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"sending \"%s\" to bootloader\n"

	.comm	_BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN,4,2 ## @BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN
L_.str.1:                               ## @.str.1
	.asciz	"Command string too long, max length is: %d\n"

L_.str.2:                               ## @.str.2
	.asciz	"Bootloader not ready for command.\n"

	.comm	_BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR,4,2 ## @BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR
	.comm	_BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR,4,2 ## @BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR
	.comm	_BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR,4,2 ## @BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR
	.comm	_OCTEON_PCI_IO_BUF_OWNER_OCTEON,4,2 ## @OCTEON_PCI_IO_BUF_OWNER_OCTEON
L_.str.3:                               ## @.str.3
	.asciz	"Bootloader did not accept command.\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_octeon_console_send_cmd        ; -- Begin function octeon_console_send_cmd
	.p2align	2
_octeon_console_send_cmd:               ; @octeon_console_send_cmd
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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	x22, x2
	mov	x21, x1
	mov	x19, x0
	mov	x0, x1
	bl	_strlen
	mov	x20, x0
	ldr	x0, [x19]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x21
	bl	_dev_dbg
Lloh2:
	adrp	x8, _BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN@GOTPAGE
Lloh3:
	ldr	x8, [x8, _BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	cmp	w20, w8
	b.ge	LBB0_3
; %bb.1:
	mov	x0, x19
	mov	x1, x22
	bl	_octeon_wait_for_bootloader
	cbz	x0, LBB0_6
; %bb.2:
	ldr	x0, [x19]
Lloh5:
	adrp	x1, l_.str.2@PAGE
Lloh6:
	add	x1, x1, l_.str.2@PAGEOFF
	b	LBB0_4
LBB0_3:
	sub	w8, w8, #1
	ldr	x0, [x19]
	str	x8, [sp]
Lloh7:
	adrp	x1, l_.str.1@PAGE
Lloh8:
	add	x1, x1, l_.str.1@PAGEOFF
LBB0_4:
	bl	_dev_err
	mov	w0, #-1
LBB0_5:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #64
	ret
LBB0_6:
	bl	_octeon_remote_lock
Lloh9:
	adrp	x8, _BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR@GOTPAGE
Lloh10:
	ldr	x8, [x8, _BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR@GOTPAGEOFF]
Lloh11:
	ldr	w1, [x8]
	mov	x0, x19
	mov	x2, x21
	mov	x3, x20
	bl	_octeon_pci_write_core_mem
Lloh12:
	adrp	x8, _BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR@GOTPAGE
Lloh13:
	ldr	x8, [x8, _BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	mov	x0, x19
	mov	x2, x20
	bl	_octeon_write_device_mem32
Lloh15:
	adrp	x8, _BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR@GOTPAGE
Lloh16:
	ldr	x8, [x8, _BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR@GOTPAGEOFF]
Lloh17:
	ldr	w1, [x8]
Lloh18:
	adrp	x8, _OCTEON_PCI_IO_BUF_OWNER_OCTEON@GOTPAGE
Lloh19:
	ldr	x8, [x8, _OCTEON_PCI_IO_BUF_OWNER_OCTEON@GOTPAGEOFF]
Lloh20:
	ldr	w2, [x8]
	mov	x0, x19
	bl	_octeon_write_device_mem32
	mov	x0, x19
	mov	w1, #200
	bl	_octeon_wait_for_bootloader
	mov	x20, x0
	bl	_octeon_remote_unlock
	cbz	x20, LBB0_8
; %bb.7:
	ldr	x0, [x19]
Lloh21:
	adrp	x1, l_.str.3@PAGE
Lloh22:
	add	x1, x1, l_.str.3@PAGEOFF
	b	LBB0_4
LBB0_8:
	mov	w0, #0
	b	LBB0_5
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh21, Lloh22
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"sending \"%s\" to bootloader\n"

	.comm	_BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN,4,2 ; @BOOTLOADER_PCI_WRITE_BUFFER_STR_LEN
l_.str.1:                               ; @.str.1
	.asciz	"Command string too long, max length is: %d\n"

l_.str.2:                               ; @.str.2
	.asciz	"Bootloader not ready for command.\n"

	.comm	_BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR,4,2 ; @BOOTLOADER_PCI_READ_BUFFER_DATA_ADDR
	.comm	_BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR,4,2 ; @BOOTLOADER_PCI_READ_BUFFER_LEN_ADDR
	.comm	_BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR,4,2 ; @BOOTLOADER_PCI_READ_BUFFER_OWNER_ADDR
	.comm	_OCTEON_PCI_IO_BUF_OWNER_OCTEON,4,2 ; @OCTEON_PCI_IO_BUF_OWNER_OCTEON
l_.str.3:                               ; @.str.3
	.asciz	"Bootloader did not accept command.\n"

.subsections_via_symbols
