HvLpEvent.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Copyright 2001 Mike Corrigan IBM Corp
  3.  *
  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.
  8.  */
  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>
  15. /* Array of LpEvent handler functions */
  16. LpEventHandler lpEventHandler[HvLpEvent_Type_NumTypes];
  17. unsigned lpEventHandlerPaths[HvLpEvent_Type_NumTypes];
  18. /* Register a handler for an LpEvent type */
  19. int HvLpEvent_registerHandler( HvLpEvent_Type eventType, LpEventHandler handler )
  20. {
  21. int rc = 1;
  22. if ( eventType < HvLpEvent_Type_NumTypes ) {
  23. lpEventHandler[eventType] = handler;
  24. rc = 0;
  25. }
  26. return rc;
  27. }
  28. int HvLpEvent_unregisterHandler( HvLpEvent_Type eventType )
  29. {
  30. int rc = 1;
  31. if ( eventType < HvLpEvent_Type_NumTypes ) {
  32. if ( !lpEventHandlerPaths[eventType] ) {
  33. lpEventHandler[eventType] = NULL;
  34. rc = 0;
  35. }
  36. }
  37. return rc;
  38. }
  39. /* (lpIndex is the partition index of the target partition.  
  40.  * needed only for VirtualIo, VirtualLan and SessionMgr.  Zero
  41.  * indicates to use our partition index - for the other types)
  42.  */
  43. int HvLpEvent_openPath( HvLpEvent_Type eventType, HvLpIndex lpIndex )
  44. {
  45. int rc = 1;
  46. if ( eventType < HvLpEvent_Type_NumTypes &&
  47.      lpEventHandler[eventType] ) {
  48. if ( lpIndex == 0 )
  49. lpIndex = itLpNaca.xLpIndex;
  50. HvCallEvent_openLpEventPath( lpIndex, eventType );
  51. ++lpEventHandlerPaths[eventType];
  52. rc = 0;
  53. }
  54. return rc;
  55. }
  56. int HvLpEvent_closePath( HvLpEvent_Type eventType, HvLpIndex lpIndex )
  57. {
  58. int rc = 1;
  59. if ( eventType < HvLpEvent_Type_NumTypes &&
  60.      lpEventHandler[eventType] &&
  61.      lpEventHandlerPaths[eventType] ) {
  62. if ( lpIndex == 0 )
  63. lpIndex = itLpNaca.xLpIndex;
  64. HvCallEvent_closeLpEventPath( lpIndex, eventType );
  65. --lpEventHandlerPaths[eventType];
  66. rc = 0;
  67. }
  68. return rc;
  69. }