heartbeat.c (1da177e4c3f41524e886b7f1b8a0c1fc7321cac2) heartbeat.c (8818760512424f60ad9fafb7a087b007a9274eb3)
1
2/*
3 * IBM ASM Service Processor Device Driver
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 11 unchanged lines hidden (view full) ---

20 *
21 * Author: Max Asb�ck <amax@us.ibm.com>
22 *
23 */
24
25#include <linux/notifier.h>
26#include "ibmasm.h"
27#include "dot_command.h"
1
2/*
3 * IBM ASM Service Processor Device Driver
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 11 unchanged lines hidden (view full) ---

20 *
21 * Author: Max Asb�ck <amax@us.ibm.com>
22 *
23 */
24
25#include <linux/notifier.h>
26#include "ibmasm.h"
27#include "dot_command.h"
28#include "lowlevel.h"
28
29static int suspend_heartbeats = 0;
30
31/*
32 * Once the driver indicates to the service processor that it is running
33 * - see send_os_state() - the service processor sends periodic heartbeats
34 * to the driver. The driver must respond to the heartbeats or else the OS
35 * will be rebooted.

--- 21 unchanged lines hidden (view full) ---

57void ibmasm_unregister_panic_notifier(void)
58{
59 notifier_chain_unregister(&panic_notifier_list, &panic_notifier);
60}
61
62
63int ibmasm_heartbeat_init(struct service_processor *sp)
64{
29
30static int suspend_heartbeats = 0;
31
32/*
33 * Once the driver indicates to the service processor that it is running
34 * - see send_os_state() - the service processor sends periodic heartbeats
35 * to the driver. The driver must respond to the heartbeats or else the OS
36 * will be rebooted.

--- 21 unchanged lines hidden (view full) ---

58void ibmasm_unregister_panic_notifier(void)
59{
60 notifier_chain_unregister(&panic_notifier_list, &panic_notifier);
61}
62
63
64int ibmasm_heartbeat_init(struct service_processor *sp)
65{
65 sp->heartbeat = ibmasm_new_command(HEARTBEAT_BUFFER_SIZE);
66 sp->heartbeat = ibmasm_new_command(sp, HEARTBEAT_BUFFER_SIZE);
66 if (sp->heartbeat == NULL)
67 return -ENOMEM;
68
69 return 0;
70}
71
72void ibmasm_heartbeat_exit(struct service_processor *sp)
73{
67 if (sp->heartbeat == NULL)
68 return -ENOMEM;
69
70 return 0;
71}
72
73void ibmasm_heartbeat_exit(struct service_processor *sp)
74{
75 char tsbuf[32];
76
77 dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf));
78 ibmasm_wait_for_response(sp->heartbeat, IBMASM_CMD_TIMEOUT_NORMAL);
79 dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf));
80 suspend_heartbeats = 1;
74 command_put(sp->heartbeat);
75}
76
77void ibmasm_receive_heartbeat(struct service_processor *sp, void *message, size_t size)
78{
79 struct command *cmd = sp->heartbeat;
80 struct dot_command_header *header = (struct dot_command_header *)cmd->buffer;
81 command_put(sp->heartbeat);
82}
83
84void ibmasm_receive_heartbeat(struct service_processor *sp, void *message, size_t size)
85{
86 struct command *cmd = sp->heartbeat;
87 struct dot_command_header *header = (struct dot_command_header *)cmd->buffer;
88 char tsbuf[32];
81
89
90 dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf));
82 if (suspend_heartbeats)
83 return;
84
85 /* return the received dot command to sender */
86 cmd->status = IBMASM_CMD_PENDING;
87 size = min(size, cmd->buffer_size);
91 if (suspend_heartbeats)
92 return;
93
94 /* return the received dot command to sender */
95 cmd->status = IBMASM_CMD_PENDING;
96 size = min(size, cmd->buffer_size);
88 memcpy(cmd->buffer, message, size);
97 memcpy_fromio(cmd->buffer, message, size);
89 header->type = sp_write;
90 ibmasm_exec_command(sp, cmd);
91}
98 header->type = sp_write;
99 ibmasm_exec_command(sp, cmd);
100}