Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * IBM ASM Service Processor Device Driver
0004  *
0005  * Copyright (C) IBM Corporation, 2004
0006  *
0007  * Author: Max Asböck <amax@us.ibm.com>
0008  */
0009 
0010 #include "ibmasm.h"
0011 #include "lowlevel.h"
0012 #include "i2o.h"
0013 #include "dot_command.h"
0014 #include "remote.h"
0015 
0016 static struct i2o_header header = I2O_HEADER_TEMPLATE;
0017 
0018 
0019 int ibmasm_send_i2o_message(struct service_processor *sp)
0020 {
0021     u32 mfa;
0022     unsigned int command_size;
0023     struct i2o_message *message;
0024     struct command *command = sp->current_command;
0025 
0026     mfa = get_mfa_inbound(sp->base_address);
0027     if (!mfa)
0028         return 1;
0029 
0030     command_size = get_dot_command_size(command->buffer);
0031     header.message_size = outgoing_message_size(command_size);
0032 
0033     message = get_i2o_message(sp->base_address, mfa);
0034 
0035     memcpy_toio(&message->header, &header, sizeof(struct i2o_header));
0036     memcpy_toio(&message->data, command->buffer, command_size);
0037 
0038     set_mfa_inbound(sp->base_address, mfa);
0039 
0040     return 0;
0041 }
0042 
0043 irqreturn_t ibmasm_interrupt_handler(int irq, void * dev_id)
0044 {
0045     u32 mfa;
0046     struct service_processor *sp = (struct service_processor *)dev_id;
0047     void __iomem *base_address = sp->base_address;
0048     char tsbuf[32];
0049 
0050     if (!sp_interrupt_pending(base_address))
0051         return IRQ_NONE;
0052 
0053     dbg("respond to interrupt at %s\n", get_timestamp(tsbuf));
0054 
0055     if (mouse_interrupt_pending(sp)) {
0056         ibmasm_handle_mouse_interrupt(sp);
0057         clear_mouse_interrupt(sp);
0058     }
0059 
0060     mfa = get_mfa_outbound(base_address);
0061     if (valid_mfa(mfa)) {
0062         struct i2o_message *msg = get_i2o_message(base_address, mfa);
0063         ibmasm_receive_message(sp, &msg->data, incoming_data_size(msg));
0064     } else
0065         dbg("didn't get a valid MFA\n");
0066 
0067     set_mfa_outbound(base_address, mfa);
0068     dbg("finished interrupt at   %s\n", get_timestamp(tsbuf));
0069 
0070     return IRQ_HANDLED;
0071 }