[WinCE]ioctrl.c与ioctrl_tab.h的关联

/***************************************************
 *作     者:温子祺
 *联系方式:[email protected]
 *说    明 :ioctrl.c与ioctrl_tab.h的关联
 ***************************************************/

ioctrl.c文件路径:       C:\WINCE600\PLATFORM\2440\SRC\OAL\INC

ioctrl_tab.h文件路径:C:\WINCE600\PLATFORM\2440\SRC\OAL\OALLIB


1、首先阅读一下ioctrl.c与ioctrl_tab.h的代码

     (1)ioctrl.c代码如下:


代码

     (2)ioctrl_tab.h代码如下:

 

 

 

代码
   
     
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
// ------------------------------------------------------------------------------
//
// File: ioctl_tab.h
//
// Configuration file for the OAL IOCTL component.
//
// This file is included by the platform's ioctl.c file and defines the
// global IOCTL table, g_oalIoCtlTable[]. Therefore, this file may ONLY
// define OAL_IOCTL_HANDLER entries.
//
// IOCTL CODE, Flags Handler Function
// ------------------------------------------------------------------------------

{ IOCTL_HAL_TRANSLATE_IRQ,
0 , OALIoCtlHalRequestSysIntr },
{ IOCTL_HAL_REQUEST_SYSINTR,
0 , OALIoCtlHalRequestSysIntr },
{ IOCTL_HAL_RELEASE_SYSINTR,
0 , OALIoCtlHalReleaseSysIntr },
{ IOCTL_HAL_REQUEST_IRQ,
0 , OALIoCtlHalRequestIrq },

{ IOCTL_HAL_DDK_CALL,
0 , OALIoCtlHalDdkCall },

{ IOCTL_HAL_DISABLE_WAKE,
0 , OALIoCtlHalDisableWake },
{ IOCTL_HAL_ENABLE_WAKE,
0 , OALIoCtlHalEnableWake },
{ IOCTL_HAL_GET_WAKE_SOURCE,
0 , OALIoCtlHalGetWakeSource },

{ IOCTL_HAL_GET_CACHE_INFO,
0 , OALIoCtlHalGetCacheInfo },
{ IOCTL_HAL_GET_DEVICEID,
0 , OALIoCtlHalGetDeviceId },
{ IOCTL_HAL_GET_UUID,
0 , OALIoCtlHalGetUUID },
{ IOCTL_HAL_GET_DEVICE_INFO,
0 , OALIoCtlHalGetDeviceInfo },
{ IOCTL_PROCESSOR_INFORMATION,
0 , OALIoCtlProcessorInfo },

{ IOCTL_HAL_INITREGISTRY,
0 , OALIoCtlHalInitRegistry },
{ IOCTL_HAL_INIT_RTC,
0 , OALIoCtlHalInitRTC },
{ IOCTL_HAL_REBOOT,
0 , OALIoCtlHalReboot },
#if 0
{ IOCTL_VBRIDGE_802_3_MULTICAST_LIST,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_ADD_MAC,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_CURRENT_PACKET_FILTER,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_GET_ETHERNET_MAC,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_GET_RX_PACKET,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_GET_RX_PACKET_COMPLETE,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_GET_TX_PACKET,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_GET_TX_PACKET_COMPLETE,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_SHARED_ETHERNET,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_WILD_CARD,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_WILD_CARD_RESET_BUFFER,
0 , OALIoCtlVBridge },
{ IOCTL_VBRIDGE_WILD_CARD_VB_INITIALIZED,
0 , OALIoCtlVBridge },
#endif
// Required Termination
{ 0 , 0 , NULL }

// ------------------------------------------------------------------------------

 

2、认真分析基于ioctrl.c中的全局变量g_oalIoCtlTable 

 

  
    
const OAL_IOCTL_HANDLER g_oalIoCtlTable[] = {
#include
" ioctl_tab.h "
};

 

    精析:

    g_oalIoCtlTable数组是一个没有限定下标的数组,这样就可以减少了程序修改的麻烦,为什么这样说呢?一般编程人员都会在定义数组变量时都会初始化下标值,例如

 

  
    
#define MAX_COUNTS 10
UINT8 g_ucValTbl[MAX_COUNTS]
= { 1 , 3 , 4 , 6 , 11 , 23 , 55 , 88 , 99 , 55 };

 

      一旦添加或删除数组中的内容时既要修改宏MAX_COUNTS  ,又要修改g_ucValTbl中的内容,假若数组中内容庞大,更容易出错。为了在定义数组变量给自己带来更少的麻烦,最后就将数组的下标值给编译器检测处理,例如:

 

  
    
UINT8 g_ucValTbl[] = { 1 , 3 , 4 , 6 , 11 , 23 , 55 , 88 , 99 , 55 };

 

      有时为了更加方便的使用,数组中最后一个内容为特定的值,一般都是0或者NULL。这样做的原因就是因为数组已经没有确定的下标值,必需要通过在数组查表中查找到特定值以表示当前查表结束或进入下一次查表。

这种方法类似本人发表过的前后台程序框架1/2中,具体地址:

http://www.cnblogs.com/wenziqi/archive/2010/07/01/1769117.html

    当然微软也采用同样的手法,g_oalIoCtlTable中的内容都存放在ioctl_tab.h中,最后并以{ 0,          0,    NULL   }结束,与本人的前后台程序框架有异曲同工之妙。

 

 


你可能感兴趣的:(WinCE)