Mailbox Client Intel® FPGA IP User Guide

ID 683290
Date 4/04/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

1.10.1. Driver API

Table 14.  mailbox_client_open
Prototype: mailbox_client_open(const char *name)
Include: <altera_s10_mailbox_client.h>
Parameter:
  • name – character pointer to name of Mailbox Client Intel FPGA peripheral as registered with the HAL
Return: Return non-NULL if successful and otherwise return:
  • -NULL for Invalid argument. Found no device or wrong input name
Description: Retrieve a pointer to the Mailbox Client block instance. Search for the list of registered mailbox client instances for the one with the supplied name.
Table 15.  mailbox_client_send_cmd
Prototype: mailbox_client_send_cmd (intel_mailbox_client* fd, alt_u8 id, alt_u32 cmd, alt_u32* arg, int arg_length, int cmd_length, alt_u32* input_data, alt_u32* resp_buf, alt_u32 resp_buf_len) 11
Include: <altera_s10_mailbox_client.h>
Parameter:
  • fd – pointer to the flash device structure
  • id - command ID
  • cmd - mailbox client command
  • arg - mailbox Client argument 12
  • arg_length - number of arguments
  • cmd_length - command length (arg_length + input_data length)
  • input_data - input data
  • resp_buf - response buffer
  • res_buf_len - response buffer length
Return: Return 0 if successful and otherwise return:
  • error codes for mailbox client in Table 12
  • -EINVAL for Invalid argument
  • -ETIME for polling timeout and skipping the loop after 5 seconds
  • -EBACK_TOUT for back pressure timer interrupt 13
  • -EEOP_TOUT for end of packet timer interrupt 14
  • -ECMD_INVLD for invalid command interrupt
  • -ENOBUFS for the response buffer length is insufficient 15
  • -ENOSYS for unmatched returned command ID from SDM
Description: Send commands and data to the Mailbox Client. Reads back the response when data valid interrupt occurs. For more information, refer to Example 1 in Driver API Application.
Table 16.  mailbox_client_flash_open
Prototype: mailbox_client_flash_open(intel_mailbox_client* fd)
Include: <altera_s10_mailbox_client_flash.h>
Parameter:
  • fd – pointer to the flash device structure
Return: Return 0 if successful and otherwise return:
  • -EINVAL for Invalid argument
  • -ENODEV for unrecognized flash device
Description: Send command to the mailbox client for QSPI open and QSPI chip select. Provides exclusive access to the quad SPI interface. Determines the QSPI flash size.
Table 17.  mailbox_client_flash_close
Prototype: mailbox_client_flash_close(intel_mailbox_client* fd)
Include: <altera_s10_mailbox_client_flash.h>
Parameter:
  • fd – pointer to the flash device structure
Return: Return 0 if successful and otherwise return:
  • -EINVAL for Invalid argument
Description: Send command to the mailbox client for QSPI close. Stops the exclusive access to the quad SPI interface.
Table 18.  mailbox_client_flash_get_info
Prototype: mailbox_client_flash_get_info(intel_mailbox_client* fd, flash_region** info, int* number_of_regions)
Include: <altera_s10_mailbox_client_flash.h>
Parameter:
  • fd – pointer to the flash device structure
  • info - pointer to the flash region
  • number_of_regions - pointer to the number of regions
Return: Return 0 if successful and otherwise return:
  • -EINVAL for Invalid argument
  • -EIO for possible hardware issue
Description: Provide information corresponding to nCSO[0].

Returns the flash memory offset, flash memory size, number of flash device, number of sector, and sector size values.

Table 19.  mailbox_client_flash_read
Prototype: mailbox_client_flash_read (intel_mailbox_client* fd, int offset, void* dest_addr, int length)
Include: <altera_s10_mailbox_client_flash.h>
Parameter:
  • fd – pointer to the flash device structure
  • offset - read flash address (unaligned access)
  • dest_addr - destination buffer (in byte size)
  • length - size of read data (in byte size)
Return: Return 0 if successful and otherwise return:
  • -EINVAL for Invalid argument
Description: Read data from selected address specified by the length in byte size. Length is a non-zero value.
Table 20.  mailbox_client_flash_erase_block
Prototype: mailbox_client_flash_erase_block (intel_mailbox_client* fd, int block_offset)
Include: <altera_s10_mailbox_client_flash.h>
Parameter:
  • fd – pointer to the flash device structure
  • block_offset - address offset from the start of flash sector specified to be erased
Return: Return 0 if successful and otherwise return:
  • -EINVAL for Invalid argument
  • -EIO for erase failed and sector might be protected
Description: Erase a single flash sector.
Table 21.  mailbox_client_flash_write_block
Prototype: mailbox_client_flash_write_block (intel_mailbox_client* fd, int block_offset, int data_offset, const void* data, int length)
Include: <altera_s10_mailbox_client_flash.h>
Parameter:
  • fd – pointer to the flash device structure
  • block_offset - sector address. Starts at the flash sector specified to be written to
  • data_offset - byte offset (unaligned access) of write into memory
  • data - data buffer to be written (in byte size)
  • length - size of write data (in byte size)
Return: Return 0 if successful and otherwise return:
  • -EINVAL for Invalid argument
Description: Write one block or sector of data into the flash. The write data length cannot split between adjacent sectors.

The function assumes the address is empty. You must erase it prior its programming.

Table 22.  mailbox_client_flash_write
Prototype: mailbox_client_flash_write (intel_mailbox_client* fd, int offset, const void* src_addr, int length)
Include: <altera_s10_mailbox_client_flash.h>
Parameter:
  • fd – pointer to the flash device structure
  • offset - flash address (unaligned access) of write to the flash memory
  • src_addr - source buffer (in byte size)
  • length - size of write data (in byte size)
Return:
Return 0 if successful and otherwise return:
  • -EINVAL for Invalid argument
Description: Program the data into the flash at the selected address. Automatically erase the block as needed before programming.
11 Prior to Intel® Quartus® Prime Pro Edition software version 21.3, the response buffer length (resp_buf_len) was declared as a pointer rather than an integer.
12 Argument represents the parameters needed for mailbox client operation, not including input data.
13 The recommended error code recovery is the full system reconfiguration.
14 The recommended error code recovery is to reset the Mailbox Client Intel® FPGA IP.
15 If the response buffer length is insufficient, the HAL API discards the collected data from Mailbox Client Intel® FPGA IP and return ENOBUFS.