2 * Copyright 2001 Mike Corrigan IBM Corp
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 #include <linux/stddef.h>
10 #include <linux/kernel.h>
11 #include <asm/system.h>
12 #include <asm/iSeries/HvLpEvent.h>
13 #include <asm/iSeries/HvCallEvent.h>
14 #include <asm/iSeries/LparData.h>
16 /* Array of LpEvent handler functions */
17 LpEventHandler lpEventHandler[HvLpEvent_Type_NumTypes];
18 unsigned lpEventHandlerPaths[HvLpEvent_Type_NumTypes];
20 /* Register a handler for an LpEvent type */
22 int HvLpEvent_registerHandler( HvLpEvent_Type eventType, LpEventHandler handler )
25 if ( eventType < HvLpEvent_Type_NumTypes ) {
26 lpEventHandler[eventType] = handler;
33 int HvLpEvent_unregisterHandler( HvLpEvent_Type eventType )
36 if ( eventType < HvLpEvent_Type_NumTypes ) {
37 if ( !lpEventHandlerPaths[eventType] ) {
38 lpEventHandler[eventType] = NULL;
45 /* (lpIndex is the partition index of the target partition.
46 * needed only for VirtualIo, VirtualLan and SessionMgr. Zero
47 * indicates to use our partition index - for the other types)
49 int HvLpEvent_openPath( HvLpEvent_Type eventType, HvLpIndex lpIndex )
52 if ( eventType < HvLpEvent_Type_NumTypes &&
53 lpEventHandler[eventType] ) {
55 lpIndex = itLpNaca.xLpIndex;
56 HvCallEvent_openLpEventPath( lpIndex, eventType );
57 ++lpEventHandlerPaths[eventType];
63 int HvLpEvent_closePath( HvLpEvent_Type eventType, HvLpIndex lpIndex )
66 if ( eventType < HvLpEvent_Type_NumTypes &&
67 lpEventHandler[eventType] &&
68 lpEventHandlerPaths[eventType] ) {
70 lpIndex = itLpNaca.xLpIndex;
71 HvCallEvent_closeLpEventPath( lpIndex, eventType );
72 --lpEventHandlerPaths[eventType];