dot_command.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * IBM ASM Service Processor Device Driver
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * Copyright (C) IBM Corporation, 2004
  19. *
  20. * Author: Max Asböck <amax@us.ibm.com>
  21. *
  22. */
  23. #ifndef __DOT_COMMAND_H__
  24. #define __DOT_COMMAND_H__
  25. /*
  26. * dot commands are the protocol used to communicate with the service
  27. * processor.
  28. * They consist of header, a command of variable length and data of
  29. * variable length.
  30. */
  31. /* dot command types */
  32. #define sp_write 0
  33. #define sp_write_next 1
  34. #define sp_read 2
  35. #define sp_read_next 3
  36. #define sp_command_response 4
  37. #define sp_event 5
  38. #define sp_heartbeat 6
  39. #pragma pack(1)
  40. struct dot_command_header {
  41. u8 type;
  42. u8 command_size;
  43. u16 data_size;
  44. u8 status;
  45. u8 reserved;
  46. };
  47. #pragma pack()
  48. static inline size_t get_dot_command_size(void *buffer)
  49. {
  50. struct dot_command_header *cmd = (struct dot_command_header *)buffer;
  51. return sizeof(struct dot_command_header) + cmd->command_size + cmd->data_size;
  52. }
  53. static inline unsigned int get_dot_command_timeout(void *buffer)
  54. {
  55. struct dot_command_header *header = (struct dot_command_header *)buffer;
  56. unsigned char *cmd = buffer + sizeof(struct dot_command_header);
  57. /* dot commands 6.3.1, 7.1 and 8.x need a longer timeout */
  58. if (header->command_size == 3) {
  59. if ((cmd[0] == 6) && (cmd[1] == 3) && (cmd[2] == 1))
  60. return IBMASM_CMD_TIMEOUT_EXTRA;
  61. } else if (header->command_size == 2) {
  62. if ((cmd[0] == 7) && (cmd[1] == 1))
  63. return IBMASM_CMD_TIMEOUT_EXTRA;
  64. if (cmd[0] == 8)
  65. return IBMASM_CMD_TIMEOUT_EXTRA;
  66. }
  67. return IBMASM_CMD_TIMEOUT_NORMAL;
  68. }
  69. #endif /* __DOT_COMMAND_H__ */