Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 1991 - 2001 Microsoft Corporation
  3. Module Name:
  4. ## # ## ## ##### ### ## ## ## ##
  5. ### # ## ## ## ## ### ### ### ## ##
  6. #### # ## ## ## ## ## ## ######## ## ##
  7. # #### #### ##### ## ## # ### ## #######
  8. # ### #### #### ####### # # ## ## ##
  9. # ## ## ## ## ## ## # ## ## ## ##
  10. # # ## ## ## ## ## # ## ## ## ##
  11. Abstract:
  12. This header file contains all the global
  13. definitions for the NVRAM device.
  14. Author:
  15. Wesley Witt (wesw) 1-Oct-2001
  16. Environment:
  17. Kernel mode only.
  18. Notes:
  19. --*/
  20. /////////////////////////////////////////////////////////////////////
  21. // By default we assume a power cycle has occurred if the driver
  22. // has been down for more than DURATION_OF_POWERCYCLE milliseconds.
  23. // In other words, the "initializing boot" is expected. This is
  24. // determined if the driver shutdown timestamp is the latest
  25. // timestamp. If the driver was never shut down (i.e., the last up
  26. // timestamp is greater than the shutdown timestamp, then the duration
  27. // is required to be more than two minutes to conclude that there
  28. // was a power cycle. This is necessary to prevent falsly assuming
  29. // a power cycle on repeated crashes, and hence potentially entering
  30. // a cycle whereby an alternative OS is never switched over to.
  31. //
  32. // AAN: If we did get a shutdown IRP and we took a timestamp during shutdown
  33. // (indicated by the fact that the shutdown timestamp is later than the last
  34. // periodic timestamp) then we use DURATION_OF_POWERCYCLE interval to determine
  35. // if power has cycled. If the shutdown timestamp wa snot taken (because we did
  36. // not get a shutdown IRP) then we the DURATION_PWRCYCLE_NOSHUTDOWN interval.
  37. // The periodic timestamps are taken at half the duration of DURATION_PWRCYCLE_NOSHUTDOWN
  38. // interval.
  39. #define DURATION_OF_POWERCYCLE (90*1000) // 90 seconds in milliseconds
  40. #define DURATION_OF_POWERCYCLE_STRING (L"Duration Powercycle")
  41. // four minutes in milliseconds
  42. #define DURATION_PWRCYCLE_NOSHUTDOWN (4*60*1000)
  43. #define DURATION_PWRCYCLE_NOSHUTDOWN_STRING (L"Duration PwrCycle NoShutDn")
  44. //#define DURATION_PWRCYCLE_NOSHUTDOWN (10*1000) // test code, for fast testing
  45. #define NVRAM_MAXIMUM_PARTITIONS 4
  46. #define NVRAM_RESERVED_BOOTCOUNTER_SLOTS 4
  47. #define NVRAM_RESERVED_DRIVER_SLOTS 8
  48. #define NVRAM_MAX_RESERVED_SLOTS (NVRAM_RESERVED_BOOTCOUNTER_SLOTS + NVRAM_RESERVED_DRIVER_SLOTS)
  49. //
  50. // Device Extension
  51. //
  52. typedef struct _NVRAM_DEVICE_EXTENSION : _DEVICE_EXTENSION {
  53. SA_NVRAM_CAPS DeviceCaps;
  54. ULONG PrimaryOS;
  55. LONGLONG LastStartupTime;
  56. LONGLONG StartupInterval;
  57. LONGLONG StartIntNoShutdown;
  58. LONGLONG ShutdownTime;
  59. LONGLONG LastUpTime;
  60. BOOLEAN PowerCycleBoot;
  61. ULONG SlotPowerCycle; // 1 slot
  62. ULONG SlotShutDownTime; // 2 slots
  63. ULONG SlotBootCounter; // 1 slot
  64. PULONG NvramData;
  65. } NVRAM_DEVICE_EXTENSION, *PNVRAM_DEVICE_EXTENSION;
  66. NTSTATUS
  67. SaNvramDetermineIfPowerCycled(
  68. IN PNVRAM_DEVICE_EXTENSION DeviceExtension
  69. );
  70. NTSTATUS
  71. SaNvramStartDevice(
  72. IN PNVRAM_DEVICE_EXTENSION DeviceExtension
  73. );
  74. NTSTATUS
  75. SaNvramDeviceInitialization(
  76. IN PSAPORT_DRIVER_EXTENSION DriverExtension
  77. );
  78. NTSTATUS
  79. SaNvramIoValidation(
  80. IN PNVRAM_DEVICE_EXTENSION DeviceExtension,
  81. IN PIRP Irp,
  82. PIO_STACK_LOCATION IrpSp
  83. );
  84. NTSTATUS
  85. SaNvramShutdownNotification(
  86. IN PNVRAM_DEVICE_EXTENSION DeviceExtension,
  87. IN PIRP Irp,
  88. PIO_STACK_LOCATION IrpSp
  89. );