i2o.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #pragma pack(1)
  24. struct i2o_header {
  25. u8 version;
  26. u8 message_flags;
  27. u16 message_size;
  28. u8 target;
  29. u8 initiator_and_target;
  30. u8 initiator;
  31. u8 function;
  32. u32 initiator_context;
  33. };
  34. #pragma pack()
  35. #define I2O_HEADER_TEMPLATE \
  36. { .version = 0x01, \
  37. .message_flags = 0x00, \
  38. .function = 0xFF, \
  39. .initiator = 0x00, \
  40. .initiator_and_target = 0x40, \
  41. .target = 0x00, \
  42. .initiator_context = 0x0 }
  43. #define I2O_MESSAGE_SIZE 0x1000
  44. #define I2O_COMMAND_SIZE (I2O_MESSAGE_SIZE - sizeof(struct i2o_header))
  45. #pragma pack(1)
  46. struct i2o_message {
  47. struct i2o_header header;
  48. void *data;
  49. };
  50. #pragma pack()
  51. static inline unsigned short outgoing_message_size(unsigned int data_size)
  52. {
  53. unsigned int size;
  54. unsigned short i2o_size;
  55. if (data_size > I2O_COMMAND_SIZE)
  56. data_size = I2O_COMMAND_SIZE;
  57. size = sizeof(struct i2o_header) + data_size;
  58. i2o_size = size / sizeof(u32);
  59. if (size % sizeof(u32))
  60. i2o_size++;
  61. return i2o_size;
  62. }
  63. static inline u32 incoming_data_size(struct i2o_message *i2o_message)
  64. {
  65. return (sizeof(u32) * i2o_message->header.message_size);
  66. }