void send_post_code_to_BMC()

in common/util/hal_snoop.c [125:198]


void send_post_code_to_BMC()
{
	int send_postcode_end_position;
	ipmi_msg *send_postcode_msg;
	ipmb_error status;

	while (1) {
		k_msleep(100); // send post code to BMC once 100 ms
		send_postcode_end_position = snoop_read_num;
		if (get_DC_status() == 0) {
			return;
		}
		if (send_postcode_start_position != send_postcode_end_position) {
			send_postcode_msg = (ipmi_msg *)malloc(sizeof(ipmi_msg));
			static uint8_t alloc_sendmsg_retry = 0;
			if (send_postcode_msg == NULL) {
				if (get_post_status()) {
					alloc_sendmsg_retry += 1;
					if (alloc_sendmsg_retry > 3) {
						printk("post complete and send post code thread alloc fail three times continuously\n");
						return;
					} else {
						continue;
					}
				} else {
					printk("send post code thread alloc fail\n");
					continue;
				}
			}

			alloc_sendmsg_retry = 0;

			if (send_postcode_end_position - send_postcode_start_position >
			    SNOOP_MAX_LEN) {
				send_postcode_end_position =
					send_postcode_start_position + SNOOP_MAX_LEN;
			}
			memset(send_postcode_msg, 0, sizeof(ipmi_msg));
			send_postcode_msg->InF_source = Self_IFs;
			send_postcode_msg->InF_target = BMC_IPMB_IFs;
			send_postcode_msg->netfn = NETFN_OEM_1S_REQ;
			send_postcode_msg->cmd = CMD_OEM_1S_SEND_POST_CODE_TO_BMC;
			send_postcode_msg->data_len =
				send_postcode_end_position - send_postcode_start_position + 4;
			send_postcode_msg->data[0] = WW_IANA_ID & 0xFF;
			send_postcode_msg->data[1] = (WW_IANA_ID >> 8) & 0xFF;
			send_postcode_msg->data[2] = (WW_IANA_ID >> 16) & 0xFF;
			send_postcode_msg->data[3] =
				send_postcode_end_position - send_postcode_start_position;
			copy_snoop_read_buffer(send_postcode_start_position % SNOOP_MAX_LEN,
					       send_postcode_msg->data[3],
					       &send_postcode_msg->data[4], copy_specific_postcode);

			status = ipmb_read(send_postcode_msg,
					   IPMB_inf_index_map[send_postcode_msg->InF_target]);
			if (send_postcode_msg != NULL) {
				free(send_postcode_msg);
			}
			if (status == ipmb_error_failure) {
				printf("Fail to post msg to txqueue for send post code from %d to %d\n",
				       send_postcode_start_position, send_postcode_end_position);
				continue;
			} else if (status == ipmb_error_get_messageQueue) {
				printf("No response from bmc for send post code\n");
				continue;
			}
			send_postcode_start_position = send_postcode_end_position;
		} else {
			if (CPU_power_good() == false) {
				return;
			}
		}
	}
}