// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]MQSim/src/host/SATA_HBA.cpp
// Function: Host_Components::SATA_HBA::SATA_HBA(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned short, unsigned long, Host_Components::PCIe_Root_Complex*, std::vector<Host_Components::IO_Flow_Base*, std::allocator<Host_Components::IO_Flow_Base*>>*)
SATA_HBA::SATA_HBA(sim_object_id_type id, uint16_t ncq_size, sim_time_type hba_processing_delay, PCIe_Root_Complex* pcie_root_complex, std::vector<Host_Components::IO_Flow_Base*>* IO_flows) :
		MQSimEngine::Sim_Object(id), ncq_size(ncq_size), hba_processing_delay(hba_processing_delay), pcie_root_complex(pcie_root_complex), IO_flows(IO_flows)
	{
		for (uint16_t cmdid = 0; cmdid < (uint16_t)(0xffffffff); cmdid++) {
			available_command_ids.insert(cmdid);
		}
		Host_IO_Request* t = NULL;
		for (uint16_t cmdid = 0; cmdid < ncq_size; cmdid++) {
			request_queue_in_memory.push_back(t);
		}
		sata_ncq.Submission_queue_size = ncq_size;
		sata_ncq.Submission_queue_head = 0;
		sata_ncq.Submission_queue_tail = 0;
		sata_ncq.Completion_queue_size = ncq_size;
		sata_ncq.Completion_queue_head = 0;
		sata_ncq.Completion_queue_tail = 0;
		sata_ncq.Submission_queue_memory_base_address = SUBMISSION_QUEUE_MEMORY_1;
		sata_ncq.Submission_tail_register_address_on_device = NCQ_SUBMISSION_REGISTER;
		sata_ncq.Completion_queue_memory_base_address = COMPLETION_QUEUE_MEMORY_1;
		sata_ncq.Completion_head_register_address_on_device = NCQ_COMPLETION_REGISTER;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r14
movq %r8, %r15
movq %rcx, %r12
movl %edx, %ebp
movq %rdi, %rbx
callq 0x165ce
leaq 0x48c74(%rip), %rax     # 0x6ddd0
movq %rax, (%rbx)
movw %bp, 0x2a(%rbx)
movq %r12, 0x30(%rbx)
movq %r15, 0x38(%rbx)
movq %r14, 0x40(%rbx)
leaq 0xa8(%rbx), %rax
movq %rax, 0x78(%rbx)
movq $0x1, 0x80(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x88(%rbx)
movl $0x3f800000, 0x98(%rbx) # imm = 0x3F800000
movups %xmm0, 0xa0(%rbx)
leaq 0xb0(%rbx), %r14
leaq 0xb8(%rbx), %rax
movl $0x0, 0xb8(%rbx)
xorl %ecx, %ecx
movq %rcx, 0xc0(%rbx)
movq %rax, 0xc8(%rbx)
movq %rax, 0xd0(%rbx)
leaq 0xe0(%rbx), %r15
leaq 0xf8(%rbx), %r13
movups %xmm0, 0xd8(%rbx)
movups %xmm0, 0xe8(%rbx)
movq %r13, 0x100(%rbx)
movq %r13, 0xf8(%rbx)
leaq 0x110(%rbx), %r12
movups %xmm0, 0x108(%rbx)
movups %xmm0, 0x118(%rbx)
movups %xmm0, 0x128(%rbx)
movups %xmm0, 0x138(%rbx)
movups %xmm0, 0x148(%rbx)
movq %rcx, 0x158(%rbx)
movq %r12, %rdi
xorl %esi, %esi
callq 0x25c18
movq %r12, 0x20(%rsp)
leaq 0x160(%rbx), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x1a0(%rbx)
movups %xmm0, 0x190(%rbx)
movups %xmm0, 0x180(%rbx)
movups %xmm0, 0x170(%rbx)
movups %xmm0, 0x160(%rbx)
movq %rdi, 0x18(%rsp)
xorl %esi, %esi
callq 0x25d80
leaq 0xa(%rsp), %r12
movw $0x0, (%r12)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2178a
movzwl 0xa(%rsp), %eax
incl %eax
movw %ax, 0xa(%rsp)
cmpw $-0x1, %ax
jne 0x2527e
movq $0x0, 0x10(%rsp)
movl %ebp, 0xc(%rsp)
testw %bp, %bp
je 0x252ea
leaq 0x10(%rsp), %r12
movl 0xc(%rsp), %eax
movl %eax, %ebp
movq 0xe8(%rbx), %rsi
cmpq 0xf0(%rbx), %rsi
je 0x252da
movq 0x10(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xe8(%rbx)
jmp 0x252e5
movq %r15, %rdi
movq %r12, %rdx
callq 0x218a2
decw %bp
jne 0x252b8
movl 0xc(%rsp), %ecx
movw %cx, 0x4c(%rbx)
xorl %eax, %eax
movl %eax, 0x48(%rbx)
movw %cx, 0x64(%rbx)
movl %eax, 0x60(%rbx)
movabsq $0x10000000000, %rax    # imm = 0x10000000000
movq %rax, 0x58(%rbx)
movq $0x1000, 0x50(%rbx)     # imm = 0x1000
movabsq $0x1f000000000, %rax    # imm = 0x1F000000000
movq %rax, 0x70(%rbx)
movq $0x1003, 0x68(%rbx)     # imm = 0x1003
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbp
jmp 0x25352
movq %rax, %rbp
jmp 0x2535c
jmp 0x25345
movq %rax, %rbp
movq 0x18(%rsp), %rdi
callq 0x25b90
movq 0x20(%rsp), %rdi
callq 0x25bd4
movq (%r13), %rdi
cmpq %r13, %rdi
je 0x25375
movq (%rdi), %r12
callq 0x7370
movq %r12, %rdi
cmpq %r13, %r12
jne 0x25365
leaq 0x78(%rbx), %r12
movq (%r15), %rdi
testq %rdi, %rdi
je 0x25386
callq 0x7370
movq %r14, %rdi
callq 0x21740
movq %r12, %rdi
callq 0x216de
leaq 0x486bb(%rip), %rax     # 0x6da58
movq %rax, (%rbx)
movq 0x8(%rbx), %rdi
addq $0x18, %rbx
cmpq %rbx, %rdi
je 0x253b2
callq 0x7370
movq %rbp, %rdi
callq 0x7620