lowlevel.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #include "ibmasm.h"
  24. #include "lowlevel.h"
  25. #include "i2o.h"
  26. #include "dot_command.h"
  27. #include "remote.h"
  28. static struct i2o_header header = I2O_HEADER_TEMPLATE;
  29. int ibmasm_send_i2o_message(struct service_processor *sp)
  30. {
  31. u32 mfa;
  32. unsigned int command_size;
  33. struct i2o_message *message;
  34. struct command *command = sp->current_command;
  35. mfa = get_mfa_inbound(sp->base_address);
  36. if (!mfa)
  37. return 1;
  38. command_size = get_dot_command_size(command->buffer);
  39. header.message_size = outgoing_message_size(command_size);
  40. message = get_i2o_message(sp->base_address, mfa);
  41. memcpy_toio(&message->header, &header, sizeof(struct i2o_header));
  42. memcpy_toio(&message->data, command->buffer, command_size);
  43. set_mfa_inbound(sp->base_address, mfa);
  44. return 0;
  45. }
  46. irqreturn_t ibmasm_interrupt_handler(int irq, void * dev_id)
  47. {
  48. u32 mfa;
  49. struct service_processor *sp = (struct service_processor *)dev_id;
  50. void __iomem *base_address = sp->base_address;
  51. char tsbuf[32];
  52. if (!sp_interrupt_pending(base_address))
  53. return IRQ_NONE;
  54. dbg("respond to interrupt at %s\n", get_timestamp(tsbuf));
  55. if (mouse_interrupt_pending(sp)) {
  56. ibmasm_handle_mouse_interrupt(sp);
  57. clear_mouse_interrupt(sp);
  58. }
  59. mfa = get_mfa_outbound(base_address);
  60. if (valid_mfa(mfa)) {
  61. struct i2o_message *msg = get_i2o_message(base_address, mfa);
  62. ibmasm_receive_message(sp, &msg->data, incoming_data_size(msg));
  63. } else
  64. dbg("didn't get a valid MFA\n");
  65. set_mfa_outbound(base_address, mfa);
  66. dbg("finished interrupt at %s\n", get_timestamp(tsbuf));
  67. return IRQ_HANDLED;
  68. }