📄 car6koid.cpp
字号:
static MPOidInfo g_Car6kSupportedQueryOids[] =
{
{ OID_CAR6K_GET_PNP_POWER, sizeof(ULONG) },
{ OID_CAR6K_RESUME_WLAN_STATE, sizeof(ULONG) },
{ OID_CAR6K_FIRMWARE_VERSION, sizeof(ULONG) },
{ 0, 0 }
};
NDIS_STATUS
CAR6KMini::QueryInformation(
IN NDIS_OID Oid,
OUT PVOID Buffer,
IN ULONG cbBuffer,
OUT PULONG pcbWritten,
OUT PULONG pcbNeeded)
//
// QueryInformation is a required function that returns information
// about the capabilities and staus of the driver and/or its NIC.
//
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
// Check that OID is supported and buffer size is reasonable.
Status = CheckOidRequest(&g_Car6kSupportedQueryOids[0], Oid, cbBuffer, pcbNeeded);
if (NDIS_STATUS_INVALID_OID == Status)
{
// OID is not a supported CAR6K OID. Check to see if it is an 802_11 OID.
Status = C802_11Miniport::QueryInformation(Oid, Buffer, cbBuffer, pcbWritten, pcbNeeded);
goto done;
}
if (NDIS_STATUS_SUCCESS != Status)
goto done;
switch (Oid)
{
case OID_CAR6K_GET_PNP_POWER:
Status = GetPnpPower((ULONG *)Buffer);
break;
case OID_CAR6K_RESUME_WLAN_STATE:
Status = GetResumeWlanState((ULONG *)Buffer);
break;
case OID_CAR6K_FIRMWARE_VERSION:
Status = GetFirmwareVersion((ULONG *)Buffer);
break;
default:
Status = NDIS_STATUS_INVALID_OID;
break;
}
if (NDIS_STATUS_SUCCESS == Status)
{
if (*pcbNeeded > cbBuffer)
Status = NDIS_STATUS_INVALID_LENGTH;
else
*pcbWritten = *pcbNeeded;
}
done:
return Status;
}
static MPOidInfo g_Car6kSupportedSetOids[] =
{
{ OID_CAR6K_802_11_AUTH_ALG, sizeof(ULONG) },
{ OID_CAR6K_RESUME_WLAN_STATE, sizeof(ULONG) },
{ OID_CAR6K_BMI_DONE, 0 },
{ OID_CAR6K_BMI_WRITE_MEMORY, sizeof(BMI_WRITE_MEMORY_PARAM) },
{ OID_CAR6K_BMI_EXECUTE, sizeof(BMI_EXECUTE_PARAM) },
{ OID_CAR6K_BMI_SET_APP_START, sizeof(BMI_SET_APP_START_PARAM) },
{ OID_CAR6K_BMI_WRITE_SOC_REGISTER, sizeof(BMI_WRITE_SOC_REG_PARAM) },
{ OID_CAR6K_BMI_READ_MEMORY, sizeof(BMI_READ_MEMORY_PARAM) },
{ OID_CAR6K_BMI_READ_SOC_REGISTER, sizeof(BMI_READ_SOC_REG_PARAM) },
#ifdef HTC_RAW_INTERFACE
{ OID_CAR6K_HTC_RAW_OPEN, 0 },
{ OID_CAR6K_HTC_RAW_CLOSE, 0 },
{ OID_CAR6K_HTC_RAW_READ, sizeof(HTC_RAW_READ_PARAM) },
{ OID_CAR6K_HTC_RAW_WRITE, sizeof(HTC_RAW_WRITE_PARAM) },
#endif //HTC_RAW_INTERFACE
{ 0, 0 }
};
NDIS_STATUS
CAR6KMini::SetInformation(
IN NDIS_OID Oid,
IN PVOID Buffer,
IN ULONG cbBuffer,
OUT PULONG pcbRead,
OUT PULONG pcbNeeded)
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
// Check that OID is supported and buffer size is reasonable.
Status = CheckOidRequest(&g_Car6kSupportedSetOids[0], Oid, cbBuffer, pcbNeeded);
if (NDIS_STATUS_INVALID_OID == Status)
{
// OID is not a supported CAR6K OID. Check to see if it is an 802_11 OID.
Status = C802_11Miniport::SetInformation(Oid, Buffer, cbBuffer, pcbRead, pcbNeeded);
goto done;
}
if (NDIS_STATUS_SUCCESS != Status)
goto done;
switch (Oid)
{
case OID_CAR6K_802_11_AUTH_ALG:
Status = SetCAr6k802_11AuthAlg(*(ULONG *)Buffer);
break;
case OID_CAR6K_RESUME_WLAN_STATE:
Status = SetResumeWlanState(*(ULONG *)Buffer);
break;
case OID_CAR6K_BMI_DONE:
Status = SetCAr6kBmiDone(Buffer);
break;
case OID_CAR6K_BMI_READ_MEMORY:
Status = SetCAr6kBmiReadMemory((BMI_READ_MEMORY_PARAM *)Buffer);
break;
case OID_CAR6K_BMI_WRITE_MEMORY:
Status = SetCAr6kBmiWriteMemory((BMI_WRITE_MEMORY_PARAM *)Buffer);
break;
case OID_CAR6K_BMI_EXECUTE:
Status = SetCAr6kBmiExecute((BMI_EXECUTE_PARAM *)Buffer);
break;
case OID_CAR6K_BMI_SET_APP_START:
Status = SetCAr6kBmiSetAppStart((BMI_SET_APP_START_PARAM *)Buffer);
break;
case OID_CAR6K_BMI_READ_SOC_REGISTER:
Status = SetCAr6kBmiReadSocRegister((BMI_READ_SOC_REG_PARAM *)Buffer);
break;
case OID_CAR6K_BMI_WRITE_SOC_REGISTER:
Status = SetCAr6kBmiWriteSocRegister((BMI_WRITE_SOC_REG_PARAM *)Buffer);
break;
#ifdef HTC_RAW_INTERFACE
case OID_CAR6K_HTC_RAW_OPEN:
Status = SetCAr6kHtcRawOpen();
break;
case OID_CAR6K_HTC_RAW_CLOSE:
Status = SetCAr6kHtcRawClose();
break;
case OID_CAR6K_HTC_RAW_READ:
Status = SetCAr6kHtcRawRead((HTC_RAW_READ_PARAM *)Buffer);
break;
case OID_CAR6K_HTC_RAW_WRITE:
Status = SetCAr6kHtcRawWrite((HTC_RAW_WRITE_PARAM *)Buffer);
break;
#endif //HTC_RAW_INTERFACE
default:
ASSERT(FALSE);
Status = NDIS_STATUS_INVALID_OID;
break;
}
done:
return Status;
}
///////////// OID_GEN Query Handlers ////////////////////
PNDIS_OID
CAR6KMini::GetSupportedOidList(
OUT PNDIS_OID pOidBuffer,
IN OUT PULONG pMaxOidsToAddToBuffer,
IN OUT PULONG pTotalNumberOfSupportedOids)
//
// Add the OIDs supported by the driver to pOidBuffer, but
// do not add more than MaxOidsToAddToBuffer.
//
// TotalNumberOfSupportedOids is set to the number of Oids
// that the driver supports.
//
// Returns a pointer to the next unused slot in pOidBuffer
// after the oids have been added.
//
{
PNDIS_OID p_Car6kOidListStart;
ULONG OidListCount = 0;
// First fill in base class supported OIDs
p_Car6kOidListStart = C802_11Miniport::GetSupportedOidList(pOidBuffer, pMaxOidsToAddToBuffer, pTotalNumberOfSupportedOids);
// Now append CAR6K OIDs
AddOidsToList(&g_Car6kSupportedQueryOids[0], p_Car6kOidListStart, &OidListCount, pMaxOidsToAddToBuffer, pTotalNumberOfSupportedOids);
AddOidsToList(&g_Car6kSupportedSetOids[0], p_Car6kOidListStart, &OidListCount, pMaxOidsToAddToBuffer, pTotalNumberOfSupportedOids);
return p_Car6kOidListStart + OidListCount;
}
ULONG
CAR6KMini::GetGenVendorDriverVersion()
{
return ATH_SW_VER_MAJOR << 16 | ATH_SW_VER_MINOR;
}
ULONG
CAR6KMini::GetGenMacOptions()
// A bitmask that defines optional properties of the underlying driver or its NIC.
{
return NDIS_MAC_OPTION_NO_LOOPBACK;
}
NDIS_HARDWARE_STATUS
CAR6KMini::GetGenHardwareStatus()
// The current hardware status of the underlying NIC
{
NDIS_HARDWARE_STATUS HardwareStatus;
if (!m_WMIReady)
HardwareStatus = NdisHardwareStatusInitializing;
else
HardwareStatus = NdisHardwareStatusReady;
return HardwareStatus;
}
NDIS_MEDIA_STATE
CAR6KMini::GetGenMediaConnectStatus()
// Whether the media is currently connected and able to Tx/Rx packets.
{
NDIS_MEDIA_STATE MediaState;
if (m_Connected)
MediaState = NdisMediaStateConnected;
else
MediaState = NdisMediaStateDisconnected;
return MediaState;
}
ULONG
CAR6KMini::GetGenLinkSpeed()
// Link speed in units of 100 bps.
{
return m_BitrateKpbs * 10;
}
ULONG
CAR6KMini::GetGenTransmitBufferSpace()
// The amount of memory, in bytes, on the NIC that is available for buffering Tx data.
{
return 1512 * 16;
}
ULONG
CAR6KMini::GetGenReceiveBufferSpace()
// The amount of memory, in bytes, on the NIC that is available for buffering Rx data.
{
return 1512 * 16;
}
ULONG
CAR6KMini::GetGenTransmitBlockSize()
// Minimum amount of storage, in bytes, that a single packet
// occupies in the Tx buffer space of the NIC.
{
return 1500;
}
ULONG
CAR6KMini::GetGenReceiveBlockSize()
// Minimum amount of storage, in bytes, that a single packet
// occupies in the Rx buffer space of the NIC.
{
return 1500;
}
#define ATHEROS_IEEE_VENDOR_CODE 0x00037F
#define ATHEROS_AR6001_NIC_CODE 0x00 // Placeholder
ULONG
CAR6KMini::GetGenVendorId()
// The OID_GEN_VENDOR_ID OID specifies a three-byte IEEE-registered vendor code,
// followed by a single byte that the vendor assigns to identify a particular NIC.
// Vendors without an IEEE registered code should use 0xFFFFFF for the vendor code.
{
return (ATHEROS_IEEE_VENDOR_CODE << 8) | ATHEROS_AR6001_NIC_CODE;
}
const char *
CAR6KMini::GetGenVendorDescription()
// The OID_GEN_VENDOR_DESCRIPTION OID points to a zero-terminated string describing the NIC.
{
return "Atheros AR6001 802.11 Network Adapter";
}
USHORT
CAR6KMini::GetGenDriverVersion()
// The NDIS version in use by the NIC driver.
// The high byte is the major version number; the low byte is the minor version number.
{
return (m_NdisDriverMajorVersion << 8) | m_NdisDriverMinorVersion;
}
ULONG
CAR6KMini::GetSupportedPacketTypes()
// Return the types of packets supported by the miniport,
// used in conjuction with OID_GEN_CURRENT_PACKET_FILTER requests.
{
return NDIS_PACKET_TYPE_ALL_MULTICAST
| NDIS_PACKET_TYPE_ALL_LOCAL
| NDIS_PACKET_TYPE_BROADCAST
| NDIS_PACKET_TYPE_DIRECTED
| NDIS_PACKET_TYPE_MULTICAST
;
}
ULONG
CAR6KMini::GetGenXmitOk()
// Number of packets transmitted ok.
{
return 0;
}
ULONG
CAR6KMini::GetGenRcvOk()
// Number of packets received ok.
{
return 0;
}
ULONG
CAR6KMini::GetGenXmitError()
// Number of transmitted packets that had errors.
{
return 0;
}
ULONG
CAR6KMini::GetGenRcvError()
// Number of received packets that had FCS/framing errors.
{
return 0;
}
ULONG
CAR6KMini::GetGenRcvNoBuffer()
// Number of packets that could not be received because no buffer space was available.
{
return 0;
}
void
CAR6KMini::GetPnpCapabilities(
OUT NDIS_PNP_CAPABILITIES *pCaps
)
{
// Wake on event not supported but power mgmt is supported
PNDIS_PM_WAKE_UP_CAPABILITIES pWakeCaps = &pCaps->WakeUpCapabilities;
pWakeCaps->MinMagicPacketWakeUp = NdisDeviceStateUnspecified;
pWakeCaps->MinPatternWakeUp = NdisDeviceStateUnspecified;
pWakeCaps->MinLinkChangeWakeUp = NdisDeviceStateUnspecified;
return;
}
NDIS_STATUS
CAR6KMini::QueryPnpPower(
IN NDIS_DEVICE_POWER_STATE *pDevPowerState
)
{
NDIS_STATUS Status;
if (*pDevPowerState == NdisDeviceStateD3) {
Status = NDIS_STATUS_SUCCESS;
} else {
Status = NDIS_STATUS_NOT_SUPPORTED;
}
return Status;
}
BYTE *
CAR6KMini::Get802_3PermanentAddress()
// The address of the NIC encoded in the hardware.
{
return &m_PermanentAddress[0];
}
BYTE *
CAR6KMini::Get802_3CurrentAddress()
// The address the NIC is currently using.
{
return &m_CurrentAddress[0];
}
ULONG
CAR6KMini::Get802_3MacOptions()
{
return 0;
}
ULONG
CAR6KMini::Get802_3RcvErrorAlignment()
// Number of received packets that had alignment errors
{
return 0;
}
ULONG
CAR6KMini::Get802_3XmitOneCollision()
// Number of transmitted packets that were transmitted after one collision
{
// Since AR6K is a wireless NIC and not using the Ethernet physical layer
// there are no collisions.
return 0;
}
ULONG
CAR6KMini::Get802_3XmitMoreCollision()
// Number of transmitted packets that were transmitted after more than one collision
{
// Since AR6K is a wireless NIC and not using the Ethernet physical layer
// there are no collisions.
return 0;
}
NDIS_STATUS
CAR6KMini::SetPnpPower(
IN NDIS_DEVICE_POWER_STATE *pDevPowerState
)
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
WCHAR sysPwrStateName[32];
DWORD sysPwrState;
DWORD result;
// Already in the requested power state
if (m_PowerState == *pDevPowerState) {
return NDIS_STATUS_SUCCESS;
}
#ifdef UNDER_CE
// Don't call the Power Manager APIs directly.
// Doing so assumes the PM is sysgen'ed into every image.
typedef DWORD GetSystemPowerStateProto(LPWSTR, DWORD, PDWORD);
GetSystemPowerStateProto *pfnGetSystemPowerState = NULL;
HMODULE hCoreDll = (HMODULE) LoadLibrary(TEXT("coredll.dll"));
if (NULL != hCoreDll) {
pfnGetSystemPowerState = (GetSystemPowerStateProto *)
GetProcAddress(hCoreDll, TEXT("GetSystemPowerState"));
}
if (NULL == pfnGetSystemPowerState) {
result = ERROR_SUCCESS;
} else {
result = pfnGetSystemPowerState(sysPwrStateName, sizeof(sysPwrStateName) / sizeof(WCHAR), &sysPwrState);
}
if (NULL != hCoreDll) {
FreeLibrary(hCoreDll);
}
#else /*!UNDER_CE*/
result = GetSystemPowerState(sysPwrStateName, sizeof(sysPwrStateName) / sizeof(WCHAR), &sysPwrState);
#endif /*UNDER_CE*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -