// File: /workspace/github_c_makefile_star2_O3/intel[P]pf-bb-config/bb_acc_common.c
// Function: acc_mem_read
int acc_mem_read(void *dev, int rwFlag, int regAddr, int wPayload)
{
	hw_device *device = (hw_device *)dev;
	uint32_t payload = 0x0;
	LOG(DEBUG, "rwFlag = %d, regAddr = 0x%x, wPayload = 0x%x\n",
			rwFlag, regAddr, wPayload);
	clear_log_resp_file(dev);
	/* Protection specific to VRB registers. */
	if (device->device_id == VRB1_DEVICE_ID) {
		if ((regAddr >= VRB1_QMGR_BA_START) && (regAddr < VRB1_QMGR_BA_END)) {
			LOG_RESP(ERR, "Invalid Address for VRB1 0x%x", regAddr);
			LOG_RESP_END();
			return 0;
		}
		if ((regAddr >= VRB1_ARAM_START) && (regAddr < VRB1_ARAM_END)) {
			LOG_RESP(ERR, "Invalid ARAM Address for VRB1 0x%x", regAddr);
			LOG_RESP_END();
			return 0;
		}
		if ((regAddr >= VRB1_QOS_A_START) && (regAddr < VRB1_QOS_A_END)) {
			LOG_RESP(ERR, "Invalid QoS A Address for VRB1 0x%x", regAddr);
			LOG_RESP_END();
			return 0;
		}
		if ((regAddr >= VRB1_QOS_B_START) && (regAddr < VRB1_QOS_B_END)) {
			LOG_RESP(ERR, "Invalid QoS B Address for VRB1 0x%x", regAddr);
			LOG_RESP_END();
			return 0;
		}
		if ((regAddr >= VRB1_QOS_C_START) && (regAddr < VRB1_QOS_C_END)) {
			LOG_RESP(ERR, "Invalid QoS C Address for VRB1 0x%x", regAddr);
			LOG_RESP_END();
			return 0;
		}
	}
	if (device->device_id == VRB2_DEVICE_ID) {
		if ((regAddr >= VRB2_QMGR_BA_START) && (regAddr < VRB2_QMGR_BA_END)) {
			LOG_RESP(ERR, "Invalid Address for VRB2 0x%x", regAddr);
			LOG_RESP_END();
			return 0;
		}
		if ((regAddr >= VRB2_ARAM_START) && (regAddr < VRB2_ARAM_END)) {
			LOG_RESP(ERR, "Invalid ARAM Address for VRB2 0x%x", regAddr);
			LOG_RESP_END();
			return 0;
		}
		if ((regAddr >= VRB2_MLD_START) && (regAddr < VRB2_MLD_END)) {
			LOG_RESP(ERR, "Invalid MLD Address for VRB2 0x%x", regAddr);
			LOG_RESP_END();
			return 0;
		}
	}

	/* Prevent 4B read outside of PF BAR. */
	if ((regAddr + 4) > device->bar_size) {
		LOG_RESP(ERR, "Invalid address range for PF BAR 0x%x", regAddr);
		LOG_RESP_END();
		return 0;
	}

	switch (rwFlag) {
	default:
	case MM_READ_REG_READ:
		payload = reg_read(device->bar0Addr, regAddr);
		LOG_RESP(INFO, "Read 0x%08X 0x%08X\n", regAddr, payload);
		break;
	case MM_READ_REG_WRITE:
		LOG_RESP(INFO, "Write 0x%08X 0x%08X\n", regAddr, wPayload);
		reg_write(device->bar0Addr, regAddr, wPayload);
		break;
	}
	LOG_RESP_END();
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl %ecx, %ebp
movl %edx, %ebx
movl %esi, %r15d
movq %rdi, %r14
callq 0x1a858
leaq 0x199c9(%rip), %r12     # 0x33ed0
movq 0x18(%r12), %r8
movl %ebp, 0x10(%rsp)
movl %ebx, 0x8(%rsp)
movl %r15d, (%rsp)
leaq 0x140ac(%rip), %rdx     # 0x2e5cb
leaq 0x140e0(%rip), %r9      # 0x2e606
movl $0x3, %edi
xorl %esi, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x199b4
movq %r14, %rdi
callq 0x1a20c
movl 0x1c(%r14), %eax
cmpl $0x57c2, %eax           # imm = 0x57C2
je 0x1a578
cmpl $0x57c0, %eax           # imm = 0x57C0
jne 0x1a62d
movl %ebx, %eax
andl $0xfffff000, %eax       # imm = 0xFFFFF000
cmpl $0xa01000, %eax         # imm = 0xA01000
jne 0x1a59b
callq 0x1a858
movq (%r12), %r8
leaq 0x140a0(%rip), %rdx     # 0x2e613
jmp 0x1a649
movl %ebx, %eax
andl $0xffffe000, %eax       # imm = 0xFFFFE000
cmpl $0xa08000, %eax         # imm = 0xA08000
jne 0x1a5be
callq 0x1a858
movq (%r12), %r8
leaq 0x1414d(%rip), %rdx     # 0x2e6e3
jmp 0x1a649
movl %ebx, %eax
andl $0xffff8000, %eax       # imm = 0xFFFF8000
cmpl $0x818000, %eax         # imm = 0x818000
jne 0x1a5e0
callq 0x1a858
movq (%r12), %r8
leaq 0x1407f(%rip), %rdx     # 0x2e638
jmp 0x1a649
movl %ebx, %ecx
andl $0xffff8000, %ecx       # imm = 0xFFFF8000
cmpl $0x818000, %ecx         # imm = 0x818000
jne 0x1a614
callq 0x1a858
movq (%r12), %r8
leaq 0x1412a(%rip), %rdx     # 0x2e708
jmp 0x1a649
movl %ebx, %eax
andl $-0x20, %eax
cmpl $0xbb00c0, %eax         # imm = 0xBB00C0
je 0x1a70f
cmpl $0xba00c0, %eax         # imm = 0xBA00C0
je 0x1a6fa
cmpl $0xb900c0, %eax         # imm = 0xB900C0
jne 0x1a62d
callq 0x1a858
movq (%r12), %r8
leaq 0x14050(%rip), %rdx     # 0x2e662
jmp 0x1a649
cmpl $0xb5e000, %eax         # imm = 0xB5E000
jne 0x1a62d
callq 0x1a858
movq (%r12), %r8
leaq 0x14107(%rip), %rdx     # 0x2e732
jmp 0x1a649
leal 0x4(%rbx), %eax
cmpl 0xb8(%r14), %eax
jbe 0x1a691
callq 0x1a858
movq (%r12), %r8
leaq 0x14112(%rip), %rdx     # 0x2e75b
xorl %edi, %edi
movl $0x1, %esi
movq %rax, %rcx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x199b4
callq 0x1a858
movq 0x10(%r12), %r8
leaq 0x13f40(%rip), %rdx     # 0x2e5ae
movl $0x2, %edi
movl $0x1, %esi
movq %rax, %rcx
xorl %eax, %eax
callq 0x199b4
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %r15d
jne 0x1a6d0
callq 0x1a858
movq 0x10(%r12), %r8
movl %ebp, (%rsp)
leaq 0x140f8(%rip), %rdx     # 0x2e7a3
movl $0x2, %edi
movl $0x1, %esi
movq %rax, %rcx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x199b4
movq 0xb0(%r14), %rax
movl %ebx, %ecx
movl %ebp, (%rax,%rcx)
jmp 0x1a65d
movq 0xb0(%r14), %rax
movl %ebx, %ecx
movl (%rax,%rcx), %ebp
callq 0x1a858
movq 0x10(%r12), %r8
movl %ebp, (%rsp)
leaq 0x14098(%rip), %rdx     # 0x2e788
movl $0x2, %edi
jmp 0x1a64b
callq 0x1a858
movq (%r12), %r8
leaq 0x13f83(%rip), %rdx     # 0x2e68d
jmp 0x1a649
callq 0x1a858
movq (%r12), %r8
leaq 0x13f99(%rip), %rdx     # 0x2e6b8
jmp 0x1a649