fw-calling.txt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. This page describes how to make calls to the firmware api.
  2. How to call
  3. ===========
  4. The preferred calling convention is known as the firmware mailbox. The
  5. mailboxes are basically a fixed length array that serves as the call-stack.
  6. Firmware mailboxes can be located by searching the encoder and decoder memory
  7. for a 16 byte signature. That signature will be located on a 256-byte boundary.
  8. Signature:
  9. 0x78, 0x56, 0x34, 0x12, 0x12, 0x78, 0x56, 0x34,
  10. 0x34, 0x12, 0x78, 0x56, 0x56, 0x34, 0x12, 0x78
  11. The firmware implements 20 mailboxes of 20 32-bit words. The first 10 are
  12. reserved for API calls. The second 10 are used by the firmware for event
  13. notification.
  14. Index Name
  15. ----- ----
  16. 0 Flags
  17. 1 Command
  18. 2 Return value
  19. 3 Timeout
  20. 4-19 Parameter/Result
  21. The flags are defined in the following table. The direction is from the
  22. perspective of the firmware.
  23. Bit Direction Purpose
  24. --- --------- -------
  25. 2 O Firmware has processed the command.
  26. 1 I Driver has finished setting the parameters.
  27. 0 I Driver is using this mailbox.
  28. The command is a 32-bit enumerator. The API specifics may be found in the
  29. fw-*-api.txt documents.
  30. The return value is a 32-bit enumerator. Only two values are currently defined:
  31. 0=success and -1=command undefined.
  32. There are 16 parameters/results 32-bit fields. The driver populates these fields
  33. with values for all the parameters required by the call. The driver overwrites
  34. these fields with result values returned by the call. The API specifics may be
  35. found in the fw-*-api.txt documents.
  36. The timeout value protects the card from a hung driver thread. If the driver
  37. doesn't handle the completed call within the timeout specified, the firmware
  38. will reset that mailbox.
  39. To make an API call, the driver iterates over each mailbox looking for the
  40. first one available (bit 0 has been cleared). The driver sets that bit, fills
  41. in the command enumerator, the timeout value and any required parameters. The
  42. driver then sets the parameter ready bit (bit 1). The firmware scans the
  43. mailboxes for pending commands, processes them, sets the result code, populates
  44. the result value array with that call's return values and sets the call
  45. complete bit (bit 2). Once bit 2 is set, the driver should retrieve the results
  46. and clear all the flags. If the driver does not perform this task within the
  47. time set in the timeout register, the firmware will reset that mailbox.
  48. Event notifications are sent from the firmware to the host. The host tells the
  49. firmware which events it is interested in via an API call. That call tells the
  50. firmware which notification mailbox to use. The firmware signals the host via
  51. an interrupt. Only the 16 Results fields are used, the Flags, Command, Return
  52. value and Timeout words are not used.