vpowerd.h

来自「用于查询PC机上的USB端口是否有设备挂接上」· C头文件 代码 · 共 725 行 · 第 1/2 页

H
725
字号
/*******************************************************************************
*
*  (C) COPYRIGHT MICROSOFT CORP., 1993-1994
*
*  TITLE:       VPOWERD.H
*
*  VERSION:     1.0
*
*  DATE:        01 Oct 1993
*
*  AUTHOR:      TCS
*
*  Definitions for the Virtual Power Management Device.
*
********************************************************************************
*
*  CHANGE LOG:
*
*  DATE        REV DESCRIPTION
*  ----------- --- -------------------------------------------------------------
*  01 Oct 1993 TCS Original implementation.
*
*******************************************************************************/

#ifndef _INC_VPOWERD
#define _INC_VPOWERD

#ifndef Not_VxD

//
//  Virtual Power Management Device service table.
//

/*XLATOFF*/
#define VPOWERD_Service                 Declare_Service
/*XLATON*/

/*MACROS*/
Begin_Service_Table(VPOWERD, VxD)

    VPOWERD_Service     (_VPOWERD_Get_Version, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Get_APM_BIOS_Version, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Get_Power_Management_Level, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Set_Power_Management_Level, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Set_Device_Power_State, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Set_System_Power_State, VxD_LOCKED_CODE)
    VPOWERD_Service     (_VPOWERD_Restore_Power_On_Defaults, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Get_Power_Status, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Get_Power_State, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_OEM_APM_Function, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Register_Power_Handler, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Deregister_Power_Handler, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_W32_Get_System_Power_Status, VxD_PAGEABLE_CODE)	
	VPOWERD_Service     (_VPOWERD_W32_Set_System_Power_State, VxD_PAGEABLE_CODE)
	// APM 1.2 services
	VPOWERD_Service     (_VPOWERD_Get_Capabilities, VxD_PAGEABLE_CODE)
	VPOWERD_Service     (_VPOWERD_Enable_Resume_On_Ring, VxD_PAGEABLE_CODE)
	VPOWERD_Service     (_VPOWERD_Disable_Resume_On_Ring, VxD_PAGEABLE_CODE)
	VPOWERD_Service     (_VPOWERD_Set_Resume_Timer, VxD_PAGEABLE_CODE)
	VPOWERD_Service     (_VPOWERD_Get_Resume_Timer, VxD_PAGEABLE_CODE)
	VPOWERD_Service     (_VPOWERD_Disable_Resume_Timer, VxD_PAGEABLE_CODE)
	VPOWERD_Service     (_VPOWERD_Enable_Timer_Based_Requests, VxD_PAGEABLE_CODE)
	VPOWERD_Service     (_VPOWERD_Disable_Timer_Based_Requests, VxD_PAGEABLE_CODE)
	VPOWERD_Service     (_VPOWERD_W32_Get_Power_Status, VxD_PAGEABLE_CODE)
	VPOWERD_Service		(_VPOWERD_Get_Timer_Based_Requests_Status, VxD_PAGEABLE_CODE)
	VPOWERD_Service		(_VPOWERD_Get_Ring_Resume_Status, VxD_PAGEABLE_CODE)
    // ACPI related Services
    VPOWERD_Service     (_VPOWERD_Transfer_Control, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_OS_Shutdown, VxD_SYSEXIT_CODE)
    VPOWERD_Service		(_VPOWERD_Indicate_User_Arrival, VxD_PAGEABLE_CODE)
    VPOWERD_Service		(_VPOWERD_Get_Battery_Unit_Status, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Get_Battery_Unit_Presence, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Disable_APM_Idle, VxD_PAGEABLE_CODE)    
    VPOWERD_Service     (_VPOWERD_Enable_APM_Idle, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Get_Mode, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Critical_Shutdown, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Disable_Hibernate, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Reboot, VxD_SYSEXIT_CODE)
    VPOWERD_Service     (_VPOWERD_Log_Suspend_Failure, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_RtInfo, VxD_PAGEABLE_CODE)
    VPOWERD_Service     (_VPOWERD_Get_Global_Flags, VxD_PAGEABLE_CODE)

End_Service_Table(VPOWERD, VxD)
/*ENDMACROS*/


#endif

#ifndef PCHAR
    typedef char* PCHAR;
#endif


/*XLATOFF*/

#ifndef _NTDDK_

#ifdef IS_32
#define POWERFAR
#else
#define POWERFAR                        _far
#endif

#else

#define POWERFAR

#endif

/*XLATON*/

//
//  Standard return type from VPOWERD services and handlers.
//
//  Error codes 0x00000001 through 0x000000FF are reserved for APM firmware
//  errors.
//
//  Error codes above 0x80000000 are reserved for definition by VPOWERD
//

typedef DWORD                           POWERRET;

#define PR_SUCCESS                      0x00000000

#define PR_PM_DISABLED                  0x00000001
#define PR_RM_CONNECT_EXISTS            0x00000002
#define PR_INTERFACE_NOT_CONNECTED      0x00000003
#define PR_16BIT_PM_CONNECT_EXISTS      0x00000005
#define PR_16BIT_PM_UNSUPPORTED         0x00000006
#define PR_32BIT_PM_CONNECT_EXISTS      0x00000007
#define PR_32BIT_PM_UNSUPPORTED         0x00000008
#define PR_UNRECOGNIZED_DEVICE_ID       0x00000009
#define PR_PARAMETER_OUT_OF_RANGE       0x0000000A
#define PR_INTERFACE_NOT_ENGAGED        0x0000000B
// 	APM 1.2 error codes
#define PR_FUNC_NOT_SUPPORTED			0x0000000C
#define PR_RESUME_TIMER_DISABLED		0x0000000D
//	end
#define PR_CANNOT_ENTER_STATE           0x00000060
#define PR_NO_PM_EVENTS_PENDING         0x00000080
#define PR_APM_NOT_PRESENT              0x00000086
#define PR_UNDEFINED_FUNCTION           0x000000FF

#define PR_DEFAULT                      0x80000000
#define PR_FAILURE                      0x80000001
#define PR_REQUEST_VETOED               0x80000002
#define PR_INVALID_POINTER              0x80000003
#define PR_INVALID_FLAG                 0x80000004
#define PR_INVALID_PMLEVEL              0x80000005
#define PR_INVALID_DEVICE_ID            0x80000006
#define PR_INVALID_POWER_STATE          0x80000007
#define PR_INVALID_REQUEST_TYPE         0x80000008
#define PR_OUT_OF_MEMORY                0x80000009
#define PR_DUPLICATE_POWER_HANDLER      0x8000000A
#define PR_POWER_HANDLER_NOT_FOUND      0x8000000B
#define PR_INVALID_FUNCTION             0x8000000C

//
//  Power device ID type and standard IDs as defined by the APM 1.1
//  specification.
//

typedef DWORD                           POWER_DEVICE_ID;

#define PDI_APM_BIOS                    0x0000
#define PDI_MANAGED_BY_APM_BIOS         0x0001
#define PDI_MANAGED_BY_APM_BIOS_OLD     0xFFFF
// 	APM 1.2
#define PDI_SPECIFIC_BATTERY			0x8000	// OR in the 1 based battery unit number
//	end

//
//  Power state type and standard power states as defined by the APM 1.1
//  specification.
//

#ifdef _NTDDK_

typedef DWORD                           VXD_POWER_STATE;
typedef VXD_POWER_STATE POWERFAR*       LPVXD_POWER_STATE;

#else

typedef DWORD                           POWER_STATE;
typedef POWER_STATE POWERFAR*           LPPOWER_STATE;

#endif  // _NTDDK_

#define PSTATE_APM_ENABLED              0x0000
#define PSTATE_STANDBY                  0x0001
#define PSTATE_SUSPEND                  0x0002
#define PSTATE_OFF                      0x0003
//	APM 1.2
#define PSTATE_HIBERNATE				0x0006
//  end

//
//  Valid power management levels.
//

#define PMLEVEL_ADVANCED                0
#define PMLEVEL_STANDARD                1
#define PMLEVEL_OFF                     2
#define PMLEVEL_ACPI					3
#define PMLEVEL_MAXIMUM                 PMLEVEL_ACPI

//
//  Valid request types.
//

#define REQTYPE_USER_INITIATED          0x00000000
#define REQTYPE_TIMER_INITIATED         0x00000001
#define REQTYPE_FORCED_REQUEST          0x00000002
#define REQTYPE_BIOS_CRITICAL_SUSPEND   0x00000003
#define REQTYPE_HIBERNATE_FLAG          0x40000000
#define REQTYPE_FROM_BIOS_FLAG          0x80000000                  // ;Internal
#define REQTYPE_FLAGS                   0xFFFFF000

// valid values for Status returned by Get_Timer_Based_Requests_Status and Get_Ring_Resume_Status
#define CAPABILITY_ENABLED	0x00000001
#define CAPABILITY_DISABLED	0x00000000

//
//  Power status structures returned by _VPOWERD_Get_Power_Status and
//  _VPOWERD_W32_Get_Power_Status.
//

#ifndef NOPOWERSTATUSDEFINES

#define AC_LINE_OFFLINE                 0x00
#define AC_LINE_ONLINE                  0x01
#define AC_LINE_BACKUP_POWER            0x02
#define AC_LINE_UNKNOWN                 0xFF

#define BATTERY_STATUS_HIGH             0x00
#define BATTERY_STATUS_LOW              0x01
#define BATTERY_STATUS_CRITICAL         0x02
#define BATTERY_STATUS_CHARGING         0x03
#define BATTERY_STATUS_UNKNOWN          0xFF

#define BATTERY_FLAG_HIGH               0x01
#define BATTERY_FLAG_LOW                0x02
#define BATTERY_FLAG_CRITICAL           0x04
#define BATTERY_FLAG_CHARGING           0x08
//	APM 1.2 
#define BATTERY_NOT_PRESENT				0x10
//	end
#define BATTERY_FLAG_NO_BATTERY         0x80
#define BATTERY_FLAG_UNKNOWN            0xFF

#define BATTERY_PERCENTAGE_UNKNOWN      0xFF

#define BATTERY_LIFE_MINUTES_MASK       0x8000
#define BATTERY_LIFE_UNKNOWN            0xFFFF

#define BATTERY_LIFE_W32_UNKNOWN        0xFFFFFFFF

#endif  // NOPOWERSTATUSDEFINES

#define	VPOWERD_GLOBAL_FLAG_S4BIOS	0x01

typedef struct _POWER_STATUS {
    BYTE PS_AC_Line_Status;
    BYTE PS_Battery_Status;
    BYTE PS_Battery_Flag;
    BYTE PS_Battery_Life_Percentage;
    WORD PS_Battery_Life_Time;	
}   POWER_STATUS;

typedef POWER_STATUS POWERFAR* LPPOWER_STATUS;

typedef struct _POWERTIME {  // st  
    WORD Year;
    WORD Month;
    WORD DayOfWeek;
    WORD Day;
    WORD Hour;
    WORD Minute;
    WORD Second;
    WORD Milliseconds;
} POWERTIME;

typedef POWERTIME POWERFAR* LPPOWERTIME;

typedef struct APM_CAPABILITIES_S	{
		WORD Capabilities;
		BYTE BatteryCount;
		BYTE Reserved;
}APM_CAPABILITIES, *PAPM_CAPABILITIES;

/*
Capability flags
Bit 0 = 1  System can enter global standby state. Indicates BIOS will post standby and standby-resume events.
Bit 1 = 1  System can enter global suspend state. Indicates BIOS will post suspend and suspend-resume events.
Bit 2 = 1  Resume timer will wake up from standby.
Bit 3 = 1  Resume timer will wake up from suspend.
Bit 4 = 1  Resume on ring indicator (internal COM or modem) will wake up from standby.
Bit 5 = 1  Resume on ring indicator (internal COM or modem) will wake up from suspend.
Bit 6 = 1  PCMCIA Ring indicator will wake up from standby.
Bit 7 = 1  PCMCIA Ring indicator will wake up from suspend.
Other bits  Reserved (must be set to 0)
*/

#define GLOBAL_STANDBY_SUPPORTED_BIT		0
#define GLOBAL_STANDBY_SUPPORTED			(1 << GLOBAL_STANDBY_SUPPORTED_BIT)

#define GLOBAL_SUSPEND_SUPPORTED_BIT  		1
#define GLOBAL_SUSPEND_SUPPORTED			(1 << GLOBAL_SUSPEND_SUPPORTED_BIT)

#define WAKE_ON_TIMER_STANDBY_BIT			2
#define WAKE_ON_TIMER_STANDBY				(1 << WAKE_ON_TIMER_STANDBY_BIT)
		
#define WAKE_ON_TIMER_SUSPEND_BIT			3
#define WAKE_ON_TIMER_SUSPEND				(1 << WAKE_ON_TIMER_SUSPEND_BIT)

#define RING_RESUME_INTERNAL_STANDBY_BIT	4
#define RING_RESUME_INTERNAL_STANDBY		(1 << RING_RESUME_INTERNAL_STANDBY_BIT)

#define RING_RESUME_INTERNAL_SUSPEND_BIT	5
#define RING_RESUME_INTERNAL_SUSPEND		(1 << RING_RESUME_INTERNAL_SUSPEND_BIT)

#define RING_RESUME_PCMCIA_STANDBY_BIT		6
#define RING_RESUME_PCMCIA_STANDBY			(1 << RING_RESUME_PCMCIA_STANDBY_BIT)

#define RING_RESUME_PCMCIA_SUSPEND_BIT		7
#define RING_RESUME_PCMCIA_SUSPEND			(1 << RING_RESUME_PCMCIA_SUSPEND_BIT)


typedef struct _WIN32_SYSTEM_POWER_STATUS {
    BYTE W32PS_AC_Line_Status;
    BYTE W32PS_Battery_Flag;
    BYTE W32PS_Battery_Life_Percent;
    BYTE W32PS_Reserved1;
    DWORD W32PS_Battery_Life_Time;
    DWORD W32PS_Battery_Full_Life_Time;
}   WIN32_SYSTEM_POWER_STATUS;

typedef WIN32_SYSTEM_POWER_STATUS POWERFAR* LPWIN32_SYSTEM_POWER_STATUS;

//
//  OEM APM Register Structure used by _VPOWERD_OEM_APM_Function.
//

struct _OEM_APM_BYTE_REGS {
    WORD OEMAPM_Reserved1[6];
    BYTE OEMAPM_BL;
    BYTE OEMAPM_BH;
    WORD OEMAPM_Reserved2;
    BYTE OEMAPM_DL;
    BYTE OEMAPM_DH;
    WORD OEMAPM_Reserved3;
    BYTE OEMAPM_CL;
    BYTE OEMAPM_CH;
    WORD OEMAPM_Reserved4;
    BYTE OEMAPM_AL;
    BYTE OEMAPM_AH;
    WORD OEMAPM_Reserved5;
    BYTE OEMAPM_Flags;
    BYTE OEMAPM_Reserved6[3];
};

struct _OEM_APM_WORD_REGS {
    WORD OEMAPM_DI;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?