⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dalcwdde.c

📁 此代码为WCE5.0下显示器的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:

          // force these values to zero in case the caller is trying to read
          // so information out of these in a future version and we do not
          // support that future version.

          lpAdapterInfo->ulReserved1 = 0;
          lpAdapterInfo->ulReserved2 = 0;
        }
      }
      *lpInfoSize = sizeof(ADAPTERINFO);
      break;

    case CWDDEDI_AdapterGetCRTCOwned:
      {
        CRTCOWNED FAR *lpCrtcOwned;
        ULONG ulControllersUsed = 0;

        // used to return the controllers per driver
        if (lpCmd->ulDriverReserved >= MAX_NUMBER_CONTROLLERS)
        {
          ulReturn = CWDDE_ERR_BADINPUT;
        } else if (ulOutputSize < sizeof(CRTCOWNED))
        {
          // cannot return the version because there is insufficient room in
          // the output buffer for a OUTPUTULONG.

          ulReturn = CWDDE_ERR_BADOUTPUTSIZE;
        } else
        {
          // Return the mapped controllers for this driver.

          lpCrtcOwned                   = (CRTCOWNED FAR *) lpOutput;
          lpCrtcOwned->ulSize           = sizeof(CRTCOWNED);
          lpCrtcOwned->ulOwnedCRTCs     = lpHDE->aControllerMap[lpCmd->ulDriverReserved];
          lpCrtcOwned->ulAvailableCRTCs = 0;

          for (i = 0; i < MAX_NUMBER_CONTROLLERS; i++)
          {
            // Check which of the controllers are taken by the drivers
            // We don't check here if driver "i" is enabled, because
            // if not, lpHDE->aControllerMap[i] will be 0
            ulControllersUsed |= lpHDE->aControllerMap[i];
          }

          for( j = 0; j < lpHDE->ulControllersCount; j++)
          {      
            if(!(VECTORFROMINDEX(j) & ulControllersUsed))
            {
              lpCrtcOwned->ulAvailableCRTCs |= VECTORFROMINDEX(j);
            }
          }
        }
      }
      *lpInfoSize = sizeof(CRTCOWNED);
      break;

    case CWDDEDI_AdapterGetSavePath:
      {
        SAVEDATA FAR *lpSaveData;
        UCHAR aucRegPathName[256];
        ULONG ulRegPathNameSize;

        if (ulOutputSize < sizeof(SAVEDATA))
        {
          // cannot return the version because there is insufficient room in
          // the output buffer for a SAVEDATA structure

          ulReturn = CWDDE_ERR_BADOUTPUTSIZE;
        } else if (lpCmd->ulDriverReserved >= MAX_NUMBER_CONTROLLERS)
        {
          // driver index specified in the command block is invalid

          ulReturn = CWDDE_ERR_BADINPUT;
        } else
        {
          lpSaveData = (SAVEDATA FAR *)lpOutput;

          lpSaveData->ulSize = sizeof(SAVEDATA);

          ulRegPathNameSize = DDLGetRegistryPathName(lpHDE->hDDL, (LPUCHAR)aucRegPathName);

          MOVEMEMORY((LPVOID)lpSaveData->cStrName,
                     (LPVOID) aucRegPathName,
                     ulRegPathNameSize);

          ulReturn = CWDDE_OK;
        }
      }
      *lpInfoSize = sizeof(SAVEDATA);
      break;

    case CWDDEDI_AdapterFlushSaveData:
      {
        if (ulOutputSize < sizeof(SAVEDATA))
        {
          // cannot return the version because there is insufficient room in
          // the output buffer for a SAVEDATA structure

          ulReturn = CWDDE_ERR_BADOUTPUTSIZE;
        } else if (lpCmd->ulDriverReserved >= MAX_NUMBER_CONTROLLERS)
        {
          // driver index specified in the command block is invalid

          ulReturn = CWDDE_ERR_BADINPUT;
        } else
        {
          ulReturn = DALCWDDE_AdapterFlushData(lpHDE,
                                               lpCmd->ulDriverReserved,
                                               (SAVEDATA FAR *)lpOutput);
        }
      }
      *lpInfoSize = sizeof(SAVEDATA);
      break;

    case CWDDEDI_AdapterGetDisplayMapping:
      {
        DEVICESELECTION FAR       *lpDeviceSelection;
        OUTPUTULONG FAR           *lpOutputUlong;
        LPDEVGDO                  lpDisplay;
        ULONG                     ulObjectTypesSelected = 0;
        ULONG                     ulIndex;
        LPDAL_OBJECT_MAP          lpObjectMap;

        if (ulInputSize < (sizeof(CWDDECMD) + sizeof(DEVICESELECTION)))
        {
          // input size of the buffer is less than the command buffer and
          // enum refresh structure so fail the call.

          ulReturn = CWDDE_ERR_BADINPUTSIZE;
        } else if (ulOutputSize < sizeof(OUTPUTULONG))
        {
          // cannot return the version because there is insufficient room in
          // the output buffer for an OUTPUTULONG structure

          ulReturn = CWDDE_ERR_BADOUTPUTSIZE;
        } else if (lpCmd->ulIndex >= lpHDE->ulControllersCount)
        {
          ulReturn = CWDDE_ERR_BADINPUT;

          // we don't want to fail the call if the calling driver does not own the controller        
          // since it might acquire it later.
          
        } else
        {
          lpDeviceSelection      = (DEVICESELECTION FAR *)(lpCmd + 1);
          lpOutputUlong          = (OUTPUTULONG FAR *) lpOutput;
          lpOutputUlong->ulSize  = sizeof(OUTPUTULONG);
          lpOutputUlong->ulValue = 0;
          
          // use the lpDeviceSlection to index into the  DAL_OBJECT_MAP
          // lpDeviceSelection is a bit vector of index of devices                    
          for(i=0; (lpDeviceSelection->ulDeviceSelection >> i) && (i < lpHDE->ulDisplaysCount); i++)
          {          
            lpDisplay = (LPDEVGDO) &lpHDE->aDisplays[i];

            // loop through the list of connected displays, and generate the type 
            // mask.  The type mask can then be used to index into the DAL_OBJECT_MAP
            // structure.
            if (VECTORFROMINDEX(i) & lpDeviceSelection->ulDeviceSelection)
            {              
              // DFP bootup support, display types replaced with a mask - VG
              ulObjectTypesSelected |= (lpDisplay->lpHWED->ulDisplayType &
                                HW_DISPLAY_TYPES_MASK);
            }
          }
          
          // Since the second driver is disabled index is equal to ulObjectTypes
          ulIndex = ulObjectTypesSelected;

          // lookup the selected object map structure for above slot of active devices.
          lpObjectMap = (LPDAL_OBJECT_MAP) &lpHDE->asDriverSelectedObjectMap[ulIndex];
                    
          lpOutputUlong->ulValue = (ULONG)lpObjectMap->aDriverMap[lpCmd->ulDriverReserved].aucDisplayMap[lpCmd->ulIndex];

          ulReturn = CWDDE_OK;
        }
      }

      *lpInfoSize = sizeof(OUTPUTULONG);
      break;

    case CWDDEDI_AdapterGetDriverInfo:
      {
         DRIVERINFO FAR *lpDriverInfo;
         LPCHAR lpcDriverName;
         LPCHAR lpcDriver;

        if (ulOutputSize < sizeof(DRIVERINFO))
        {
          // cannot return the version because there is insufficient room in
          // the output buffer for an ADAPTERCAPS structure

          ulReturn = CWDDE_ERR_BADOUTPUTSIZE;
        } 
        else if ((lpCmd->ulDriverReserved >= MAX_NUMBER_CONTROLLERS) ||
                 (!(lpHDE->aDriverData[lpCmd->ulDriverReserved].ulFlags & DRIVERDATA_ENABLED)))
        {
          // driver index specified in the command block is invalid

          ulReturn = CWDDE_ERR_BADINPUT;
        } 
        else
        {
          ULONG cchDriverName = MAX_REGISTRY_PATH - 2;

          lpDriverInfo = (DRIVERINFO FAR *)lpOutput;
          ZEROMEMORY((LPVOID)lpDriverInfo, sizeof(DRIVERINFO));

          lpDriverInfo->ulSize = sizeof(DRIVERINFO);

          lpcDriverName = (LPCHAR) lpDriverInfo->cDriverID;

          lpcDriver = (LPCHAR)DALREGKEY_DRIVER;

          strncpy(lpcDriverName, lpcDriver, cchDriverName - 1);
          lpcDriverName[cchDriverName - 1] = 0;

          if (cchDriverName >= strlen(lpcDriver) + 2)
          {
            lpcDriverName += strlen(lpcDriver);

            *lpcDriverName++ = ((CHAR)lpCmd->ulDriverReserved + '0');

            *lpcDriverName++ = '\0';
          }

          DDLGetAdapterID(lpHDE->hDDL, (LPCHAR)lpDriverInfo->cAdapterID);

          ulReturn = CWDDE_OK;
        }
      }

      *lpInfoSize = sizeof(DRIVERINFO);
      break;

    case CWDDEDI_AdapterGetDefaultSetting:
    {
      if (ulInputSize < sizeof(CWDDECMD))
      {
        // input size of the buffer is less than the command buffer
        ulReturn = CWDDE_ERR_BADINPUTSIZE;
      } 
      else if (ulOutputSize < sizeof(ADAPTERSETTING))
      {
        // cannot return the version because there is insufficient room in
        // the output buffer

        ulReturn = CWDDE_ERR_BADOUTPUTSIZE;
      }
      else if ((lpCmd->ulDriverReserved >= MAX_NUMBER_CONTROLLERS) ||
               (!(lpHDE->aDriverData[lpCmd->ulDriverReserved].ulFlags & DRIVERDATA_ENABLED)))
      {

        ulReturn = CWDDE_ERR_BADINPUT;
      }
      else
      {
        ulReturn = ulGetAdapterDefaultSetting(lpHDE,
                                              lpCmd->ulDriverReserved,
                                              ulOutputSize,
                                              (ADAPTERSETTING FAR*)lpOutput);
      }

      *lpInfoSize = ulOutputSize;
      break;
    }

    case CWDDEDI_AdapterGetConfig:
    {
      if (ulInputSize < (sizeof(CWDDECMD)+sizeof(ADAPTERCONFIG)))
      {
        // input size of the buffer is less than the command buffer
        ulReturn = CWDDE_ERR_BADINPUTSIZE;
      } 
      else if (ulOutputSize < sizeof(ADAPTERCONFIG))
      {
        // cannot return the version because there is insufficient room in
        // the output buffer

        ulReturn = CWDDE_ERR_BADOUTPUTSIZE;
      }
      else
      {
        ADAPTERCONFIG FAR * lpOAdapterConfig = (ADAPTERCONFIG FAR *)lpOutput;
        ADAPTERCONFIG FAR * lpIAdapterConfig = (ADAPTERCONFIG FAR *)(lpCmd + 1);

        ZEROMEMORY(lpOAdapterConfig, sizeof(ADAPTERCONFIG));
        lpOAdapterConfig->ulSize   = sizeof(ADAPTERCONFIG);
        lpOAdapterConfig->ulConfig = lpIAdapterConfig->ulConfig;

        ulReturn = ulGetAdapterConfig(lpHDE,
                                      lpIAdapterConfig->ulConfig,
                                      (LPULONG)&lpOAdapterConfig->ulValue);
      }

      *lpInfoSize = sizeof(ADAPTERCONFIG);
      break;
    }

    case CWDDEDI_AdapterSetConfig:
    {
      if (ulInputSize < (sizeof(CWDDECMD) + sizeof(ADAPTERCONFIG)))
      {
        // input size of the buffer is less than the command buffer
        ulReturn = CWDDE_ERR_BADINPUTSIZE;
      } 
      else
      {
        ADAPTERCONFIG FAR * lpAdapterConfig = (ADAPTERCONFIG FAR *)(lpCmd + 1);

        ulReturn = ulSetAdapterConfig(lpHDE,
                                      lpAdapterConfig->ulConfig,
                                      lpAdapterConfig->ulValue);
      }

      *lpInfoSize = 0;
      break;
    }

    case CWDDEDI_AdapterGetPowerCaps:
    {

      if (ulOutputSize < sizeof(DI_ADAPTERPOWERCAPS))
      {
        // cannot return the version because there is insufficient room in
        // the output buffer
        ulReturn = CWDDE_ERR_BADOUTPUTSIZE;
      }
      else
      {
        if (lpHDE->bPowerPlaySupported)
        {

          DI_ADAPTERPOWERCAPS FAR * lpAdapterPowerCaps = (DI_ADAPTERPOWERCAPS FAR *)lpOutput;
          ZEROMEMORY(lpAdapterPowerCaps, sizeof(DI_ADAPTERPOWERCAPS));
          lpAdapterPowerCaps->ulSize   = sizeof(DI_ADAPTERPOWERCAPS);
          
          lpAdapterPowerCaps->ulAPIVersion = CWDDEDI_POWERPLAY_VERSION;
          lpAdapterPowerCaps->ulNumberofPowerStates = lpHDE->ulNumberOfPowerStates;

          for( i = 0; (i < lpHDE->ulNumberOfPowerStates) && (i < MAX_POWER_STATE) && (i < DAL_GCO_MAX_POWERSTATE); i++)
          {
            lpAdapterPowerCaps->sPowerState[i].ulFlags = 0;

            if (lpHDE->sAdapterPowerStates.sGCOPowerState[i].ulFlags & DAL_GCOPOWERSTATE_FLAGS_MEMORYSHARESCORECLK)
            {

⌨️ 快捷键说明

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