ppc64-diag
Macros | Functions | Variables
epow.c File Reference

Routines to handle EPOW RTAS events. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <librtas.h>
#include <librtasevent.h>
#include "rtas_errd.h"

Macros

#define SENSOR_TOKEN_KEY_SWITCH   1
 
#define SENSOR_TOKEN_ENCLOSURE_SWITCH   2
 
#define SENSOR_TOKEN_THERMAL_SENSOR   3
 
#define SENSOR_TOKEN_POWER_SOURCE   5
 
#define SENSOR_TOKEN_EPOW_SENSOR   9
 
#define EPOW_PROGRAM   "/etc/rc.powerfail"
 
#define EPOW_PROGRAM_NOPATH   "rc.powerfail"
 

Functions

void epow_timer_handler (int sig, siginfo_t siginfo, void *context)
 Routine to handle SIGALRM timer interrupts. More...
 
static void log_epow (struct event *event, char *fmt,...)
 
static int parse_epow (struct event *event)
 Retrieve the epow status from an RTAS event. More...
 
int check_epow (struct event *event)
 Check an RTAS event for EPOW data. More...
 

Variables

static int time_remaining = 0
 Time remaining until a system shutdown. More...
 

Detailed Description

Copyright (C) 2004 IBM Corporation

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Macro Definition Documentation

◆ EPOW_PROGRAM

#define EPOW_PROGRAM   "/etc/rc.powerfail"

Referenced by check_epow().

◆ EPOW_PROGRAM_NOPATH

#define EPOW_PROGRAM_NOPATH   "rc.powerfail"

Referenced by check_epow().

◆ SENSOR_TOKEN_ENCLOSURE_SWITCH

#define SENSOR_TOKEN_ENCLOSURE_SWITCH   2

◆ SENSOR_TOKEN_EPOW_SENSOR

#define SENSOR_TOKEN_EPOW_SENSOR   9

Referenced by epow_timer_handler(), and parse_epow().

◆ SENSOR_TOKEN_KEY_SWITCH

#define SENSOR_TOKEN_KEY_SWITCH   1

◆ SENSOR_TOKEN_POWER_SOURCE

#define SENSOR_TOKEN_POWER_SOURCE   5

◆ SENSOR_TOKEN_THERMAL_SENSOR

#define SENSOR_TOKEN_THERMAL_SENSOR   3

Function Documentation

◆ check_epow()

int check_epow ( struct event event)

check_epow Parses error information to determine if it represents an EPOW event. If it is, the epow_status_file is updated with the appropriate condition, and EPOW_PROGRAM is invoked to take the appropriate system action (shutdown, etc).

Parameters
eventpointer to the RTAS event

References EPOW_PROGRAM, EPOW_PROGRAM_NOPATH, log_msg(), parse_epow(), and update_epow_status_file().

Referenced by handle_rtas_event().

◆ epow_timer_handler()

void epow_timer_handler ( int  sig,
siginfo_t  siginfo,
void *  context 
)

epow_timer_handler

Parameters
sigunused
siginfounused
contextunused

References SENSOR_TOKEN_EPOW_SENSOR, time_remaining, and update_epow_status_file().

Referenced by main().

◆ log_epow()

static void log_epow ( struct event event,
char *  fmt,
  ... 
)
static

References event::addl_text, ADDL_TEXT_MAX, and log_msg().

Referenced by parse_epow().

◆ parse_epow()

static int parse_epow ( struct event event)
static

parse_epow This routine returns the value that will be written to the epow_status file. The value will be used by the EPOW_PROGRAM script (which can be modified by a system administrator) to establish actions to be taken for certain EPOW conditions. The return value must be 7 digits or less.

Parameters
eventpointer to the RTAS event
Returns
 Return Value                                   Action
 ==========================                     =====================
 0   normal state                               none
 1   loss of primary power                      4 ms to shutdown
 2   power supply failure                       4 ms to shutdown
 3   manual power-off switch    activated       4 ms to shutdown
 4   thermal high                               20 seconds to shutdown
 5   primary fan failure                        20 seconds to shutdown
 6   secondary fan failure                      10 minutes to shutdown
 7   battery backup                             10 minutes to shutdown
 8   non-critical cooling problem               none
 9   non-critical power problem         none
 10  (v6) normal shutdown requested             initiate shutdown immediately
 11  (v6) loss of critical system functions     initiate shutdown immediately

References log_epow(), log_msg(), event::rtas_event, SENSOR_TOKEN_EPOW_SENSOR, and time_remaining.

Referenced by check_epow().

Variable Documentation

◆ time_remaining

time_remaining = 0
static

The time_remaining variable is used by the epow timer to track the time remaining until a system shutdown

Referenced by epow_timer_handler(), and parse_epow().