Ignore:
Timestamp:
Dec 18, 2011, 10:28:22 PM (14 years ago)
Author:
dmik
Message:

Merge branch gcc-kmk to trunk.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1 bin
        2 Makefile.inc
         1env.cmd
         2LocalConfig.kmk
    • Property svn:mergeinfo set to
      /branches/gcc-kmkmergedeligible
  • trunk/src/kernel32/hmparport.cpp

    r8404 r21916  
    6060
    6161#define MAX_PARALLEL_PORTS_CONFIGURATION 3
    62 static PARALLELPORTCONFIGURATION arrParallelPorts[MAX_PARALLEL_PORTS_CONFIGURATION] = 
     62static PARALLELPORTCONFIGURATION arrParallelPorts[MAX_PARALLEL_PORTS_CONFIGURATION] =
    6363{
    6464  {1, 0x378, 8, 0x778, 3},
     
    7171{
    7272  ULONG ulMagic;
    73  
     73
    7474  // Win32 Device Control Block
    7575  COMMCONFIG   CommCfg;
    76  
     76
    7777  // hardware configuration block
    7878  PPARALLELPORTCONFIGURATION pHardwareConfiguration;
     
    8383static VOID *CreateDevData()
    8484{
    85    HFILE  hfFileHandle = 0L;   
    86    UCHAR   uchParms[2] = {0, RM_COMMAND_PHYS}; 
    87    ULONG   ulParmLen = 0; 
     85   HFILE  hfFileHandle = 0L;
     86   UCHAR   uchParms[2] = {0, RM_COMMAND_PHYS};
     87   ULONG   ulParmLen = 0;
    8888   UCHAR   uchDataArea[MAX_ENUM_SIZE] = {0};
    89    UCHAR   uchDataArea2[MAX_RM_NODE_SIZE] = {0}; 
    90    ULONG   ulDataLen = 0;           
     89   UCHAR   uchDataArea2[MAX_RM_NODE_SIZE] = {0};
     90   ULONG   ulDataLen = 0;
    9191   int rc,portCount = 0;
    92  
     92
    9393   PRM_ENUMNODES_DATA enumData;
    9494   PNODEENTRY pNode;
     
    105105  }
    106106  else
    107   { 
     107  {
    108108            dprintf(("HMDeviceParPortClass: Succesfully opened Resource Manager"));
    109109
     
    114114                    CAT_RM,FUNC_RM_ENUM_NODES, uchParms, sizeof(uchParms),
    115115                    &ulParmLen,
    116                     uchDataArea,         
    117                     sizeof(uchDataArea), 
    118                     &ulDataLen);         
    119                                        
     116                    uchDataArea,
     117                    sizeof(uchDataArea),
     118                    &ulDataLen);
     119
    120120            if (rc)
    121121            {
    122                   dprintf(("HMDeviceParPortClass: Failed to get resource list (IOCTL)"));     
     122                  dprintf(("HMDeviceParPortClass: Failed to get resource list (IOCTL)"));
    123123            goto resourceLoopEnd;
    124124            }
    125125
    126126            enumData = (PRM_ENUMNODES_DATA)uchDataArea;
    127  
     127
    128128            inputData.RMHandle = enumData->NodeEntry[0].RMHandle;
    129129            inputData.Linaddr = (ULONG)&uchDataArea2[0];
    130          
     130
    131131        for (int i=0;i<enumData->NumEntries;i++)
    132132        {
    133133            ulParmLen = sizeof(inputData);                        /* Length of input parameters */
    134134            ulDataLen = sizeof(uchDataArea2);                      /* Length of data  */
    135        
     135
    136136            rc = OSLibDosDevIOCtl(hfFileHandle,           /* Handle to device */
    137137                   CAT_RM,FUNC_RM_GET_NODEINFO,
     
    146146            if (rc)
    147147            {
    148                 dprintf(("HMDeviceParPortClass: Failed to get resource node (IOCTL)"));     
    149                 break; 
     148                dprintf(("HMDeviceParPortClass: Failed to get resource node (IOCTL)"));
     149                break;
    150150            }
    151151            inputData.RMHandle = enumData->NodeEntry[i].RMHandle;
     
    163163                // @@PF Hack, but what to do no ECP info from Resource Manager!
    164164                    if (arrParallelPorts[portCount].ulPortBase == 0x378)
    165                 {       
     165                {
    166166                    arrParallelPorts[portCount].ulEcpPortBase = 0x778;
    167167                    arrParallelPorts[portCount].ulEcpPortSpan = 3;
    168168                }
    169                     else       
     169                    else
    170170                    if (arrParallelPorts[portCount].ulPortBase == 0x278)
    171                 {       
     171                {
    172172                    arrParallelPorts[portCount].ulEcpPortBase = 0x678;
    173173                    arrParallelPorts[portCount].ulEcpPortSpan = 3;
     
    178178                arrParallelPorts[portCount].ulEcpPortSpan = 0;
    179179                dprintf(("HMDeviceParPortClass: Found and registered LPT%d with Base I/O: 0x%x",portCount,arrParallelPorts[portCount].ulPortBase));
    180                 portCount ++ ;   
     180                portCount ++ ;
    181181            }
    182182        }
    183183    }
    184184resourceLoopEnd:
    185     OSLibDosClose(hfFileHandle); 
     185    OSLibDosClose(hfFileHandle);
    186186
    187187    pData = new HMDEVPARPORTDATA();
     
    194194        pData->CommCfg.dwProviderSubType = PST_PARALLELPORT;
    195195    }
    196    
     196
    197197    return pData;
    198198}
    199199//******************************************************************************
    200200//******************************************************************************
    201 HMDeviceParPortClass::HMDeviceParPortClass(LPCSTR lpDeviceName) : 
     201HMDeviceParPortClass::HMDeviceParPortClass(LPCSTR lpDeviceName) :
    202202  HMDeviceHandler(lpDeviceName)
    203203{
    204204  dprintf(("HMDeviceParPortClass::HMDevParPortClass(%s)\n",
    205205           lpDeviceName));
    206  
     206
    207207#ifndef DEVINFO_PRINTER
    208208#define DEVINFO_PRINTER         0
    209209#endif
    210  
     210
    211211  // first, we determine the number of parallel port devices available
    212  
     212
    213213  // PH 2001-12-04 Note:
    214214  // This call will not return any information about redirected LPT ports.
     
    223223  if (0 == bNumberOfParallelPorts)
    224224    return;
    225  
     225
    226226  VOID *pData;
    227227  dprintf(("HMDeviceParPortClass: Registering LPTs with Handle Manager\n"));
    228  
     228
    229229  pData = CreateDevData();
    230230  if(pData!= NULL)
    231231    HMDeviceRegisterEx("LPT1", this, pData);
    232  
     232
    233233  // add symbolic links to the "real name" of the device
    234234  if (bNumberOfParallelPorts > 0)
     
    246246    free(pszLPT);
    247247    free(pszLPT2);
    248    
     248
    249249    // add "PRN" device
    250250    HandleNamesAddSymbolicLink("PRN",        "LPT1");
     
    272272  if (bNumberOfParallelPorts == 0)
    273273    return FALSE;
    274  
     274
    275275  // can be both, "LPT1" and "LPT1:"
    276276  if(namelength > 5)
     
    283283  if(namelength == 5 && lpDeviceName[4] != ':')
    284284    return FALSE;
    285  
     285
    286286  // can support up tp LPT9
    287287  if ( (lpDeviceName[3] >= '1') &&
     
    305305           lpSecurityAttributes,
    306306           pHMHandleDataTemplate));
    307  
     307
    308308  char lptname[6];
    309309
    310310  dprintf(("HMDeviceParPortClass: Parallel port %s open request\n", lpFileName));
    311  
     311
    312312  // Don't accept any name if no parallel ports have been detected
    313313  if (bNumberOfParallelPorts == 0)
     
    315315    return ERROR_DEV_NOT_EXIST;
    316316  }
    317  
     317
    318318  strcpy(lptname, lpFileName);
    319319  lptname[4] = 0;   //get rid of : (if present) (eg LPT1:)
     
    326326                                          OSLIB_ACCESS_SHAREDENYWRITE);
    327327  SetErrorMode(oldmode);
    328  
     328
    329329  // check if handle could be opened properly
    330330  if (0 == pHMHandleData->hHMHandle)
     
    337337    APIRET rc;
    338338    pHMHandleData->lpHandlerData = new HMDEVPARPORTDATA();
    339    
     339
    340340    // Init The handle instance with the default default device config
    341341    memcpy( pHMHandleData->lpHandlerData,
    342342            pHMHandleData->lpDeviceData,
    343343            sizeof(HMDEVPARPORTDATA));
    344    
     344
    345345    // determine which port was opened
    346346    ULONG ulPortNo = lptname[3] - '1';
    347    
     347
    348348    // safety check (device no 0..8 -> LPT1..9)
    349349    if (ulPortNo > MAX_PARALLEL_PORTS_CONFIGURATION)
     
    352352      return ERROR_DEV_NOT_EXIST;
    353353    }
    354    
     354
    355355    // and save the hardware information
    356356    PHMDEVPARPORTDATA pPPD = (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData;
    357357    pPPD->pHardwareConfiguration = &arrParallelPorts[ulPortNo];
    358  
     358
    359359    return NO_ERROR;
    360360  }
     
    387387  dprintf(("HMDeviceParPortClass: Parallel port close request(%08xh)\n",
    388388           pHMHandleData));
    389  
    390   delete pHMHandleData->lpHandlerData;
     389
     390  delete (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData;
    391391  return OSLibDosClose(pHMHandleData->hHMHandle);
    392392}
     
    511511//******************************************************************************
    512512//******************************************************************************
    513 BOOL HMDeviceParPortClass::DeviceIoControl(PHMHANDLEDATA pHMHandleData, 
     513BOOL HMDeviceParPortClass::DeviceIoControl(PHMHANDLEDATA pHMHandleData,
    514514                                           DWORD dwIoControlCode,
    515                                            LPVOID lpInBuffer, 
     515                                           LPVOID lpInBuffer,
    516516                                           DWORD nInBufferSize,
    517                                            LPVOID lpOutBuffer, 
     517                                           LPVOID lpOutBuffer,
    518518                                           DWORD nOutBufferSize,
    519                                            LPDWORD lpBytesReturned, 
     519                                           LPDWORD lpBytesReturned,
    520520                                           LPOVERLAPPED lpOverlapped)
    521521{
    522522#ifdef DEBUG
    523     char *msg = NULL;
     523    const char *msg = NULL;
    524524
    525525    switch(dwIoControlCode)
     
    528528        msg = "IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO";
    529529        break;
    530      
     530
    531531      case IOCTL_INTERNAL_GET_PARALLEL_PNP_INFO:
    532532        msg = "IOCTL_INTERNAL_GET_PARALLEL_PNP_INFO";
    533533        break;
    534534    }
    535  
     535
    536536    if(msg) {
    537537        dprintf(("HMDeviceParPortClass::DeviceIoControl %s %x %d %x %d %x %x", msg, lpInBuffer, nInBufferSize,
     
    545545      {
    546546        PPARALLEL_PORT_INFORMATION pPPI = (PPARALLEL_PORT_INFORMATION)lpOutBuffer;
    547        
    548         if(nOutBufferSize < sizeof(PARALLEL_PORT_INFORMATION) || !pPPI) 
     547
     548        if(nOutBufferSize < sizeof(PARALLEL_PORT_INFORMATION) || !pPPI)
    549549        {
    550550          SetLastError(ERROR_INSUFFICIENT_BUFFER);
    551551          return FALSE;
    552552        }
    553        
     553
    554554        if(lpBytesReturned)
    555555          *lpBytesReturned = sizeof(PARALLEL_PORT_INFORMATION);
    556        
     556
    557557        // fill in the data values
    558558        PHMDEVPARPORTDATA pPPD = (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData;
    559        
     559
    560560        // @@@PH
    561561        // Specifies the bus relative base I/O address of the parallel port registers.
    562562        pPPI->OriginalController.LowPart  = pPPD->pHardwareConfiguration->ulPortBase;
    563563        pPPI->OriginalController.HighPart = 0;
    564        
     564
    565565        // Pointer to the system-mapped base I/O location of the parallel port registers.
    566566        pPPI->Controller = NULL;
    567        
     567
    568568        // Specifies the size, in bytes, of the I/O space, allocated to the parallel port.
    569569        pPPI->SpanOfController = pPPD->pHardwareConfiguration->ulPortSpan;
    570        
     570
    571571        // Pointer to a callback routine that a kernel-mode driver can use to try to allocate the parallel port.
    572572        pPPI->TryAllocatePort = NULL;
    573        
     573
    574574        // Pointer to a callback routine that a kernel-mode driver can use to free the parallel port.
    575575        pPPI->FreePort = NULL;
    576        
     576
    577577        // Pointer to a callback routine that a kernel-mode driver can use to determine the number of requests on the work queue of the parallel port.
    578578        pPPI->QueryNumWaiters = NULL;
    579        
     579
    580580        // Pointer to the device extension of parallel port.
    581581        pPPI->Context = NULL;
     
    583583        return TRUE;
    584584      }
    585      
    586      
     585
     586
    587587      case IOCTL_INTERNAL_GET_PARALLEL_PNP_INFO:
    588588      {
    589589        PPARALLEL_PNP_INFORMATION pPPI = (PPARALLEL_PNP_INFORMATION)lpOutBuffer;
    590        
     590
    591591        if(nOutBufferSize < sizeof(PARALLEL_PNP_INFORMATION) || !pPPI)
    592592        {
     
    594594          return FALSE;
    595595        }
    596        
     596
    597597        if(lpBytesReturned)
    598598          *lpBytesReturned = sizeof(PARALLEL_PNP_INFORMATION);
    599        
     599
    600600        // fill in the data values
    601601        PHMDEVPARPORTDATA pPPD = (PHMDEVPARPORTDATA)pHMHandleData->lpHandlerData;
    602        
     602
    603603        // @@@PH
    604         // Specifies the base physical address that the system-supplied 
    605         // function driver for parallel ports uses to control the ECP 
     604        // Specifies the base physical address that the system-supplied
     605        // function driver for parallel ports uses to control the ECP
    606606        // operation of the parallel port.
    607607        pPPI->OriginalEcpController.LowPart  = pPPD->pHardwareConfiguration->ulEcpPortBase;
    608608        pPPI->OriginalEcpController.HighPart = 0;
    609        
    610         // Pointer to the I/O port resource that is used to control the 
     609
     610        // Pointer to the I/O port resource that is used to control the
    611611        // port in ECP mode.
    612612        pPPI->EcpController = NULL;
    613        
     613
    614614        // Specifies the size, in bytes, of the I/O port resource.
    615615        pPPI->SpanOfEcpController = pPPD->pHardwareConfiguration->ulEcpPortSpan;
    616        
     616
    617617        // Not used.
    618618        pPPI->PortNumber = 0;
    619        
     619
    620620        // Specifies the hardware capabilities of the parallel port. The following capabilities can be set using a bitwise OR of the following constants:
    621621        pPPI->HardwareCapabilities = 0;
     
    626626        //  PPT_EPP_PRESENT
    627627        //  PT_NO_HARDWARE_PRESENT
    628        
     628
    629629        // Pointer to a callback routine that a kernel-mode driver can use to change the operating mode of the parallel port.
    630630        pPPI->TrySetChipMode = 0;
    631        
     631
    632632        // Pointer to a callback routine that a kernel-mode driver can use to clear the operating mode of the parallel port.
    633633        pPPI->ClearChipMode = 0;
    634        
     634
    635635        // Specifies the size, in words, of the hardware first in/first out (FIFO) buffer. The FIFO word size, in bits, is the value of FifoWidth.
    636636        pPPI->FifoDepth = 0;
    637        
     637
    638638        // Specifies the FIFO word size, in bits, which is the number of bits handled in parallel.
    639639        pPPI->FifoWidth = 0;
    640        
     640
    641641        // Not used.
    642642        pPPI->EppControllerPhysicalAddress.LowPart = 0;
    643643        pPPI->EppControllerPhysicalAddress.HighPart = 0;
    644        
     644
    645645        // Not used.
    646646        pPPI->SpanOfEppController = 0;
    647        
     647
    648648        // Specifies the number of daisy-chain devices currently attached to a parallel port. In Microsoftÿ Windowsÿ XP, from zero to two devices can be simultaneously connected to a
    649649        // parallel port. In Windows 2000, from zero to four devices can be simultaneously connected to a parallel port.
    650650        pPPI->Ieee1284_3DeviceCount = 0;
    651        
     651
    652652        // Pointer to a callback routine that a kernel-mode driver can use to try to select an IEEE 1284.3 device.
    653653        pPPI->TrySelectDevice = 0;
    654        
     654
    655655        // Pointer to a callback routine that a kernel-mode driver can use to deselect an IEEE 1284.3 device.
    656656        pPPI->DeselectDevice = 0;
    657        
     657
    658658        // Pointer to the device extension of a parallel port's function device object (FDO).
    659659        pPPI->Context = 0;
    660        
     660
    661661        // The current operating mode of the parallel port.
    662662        pPPI->CurrentMode = 0;
    663        
     663
    664664        // The symbolic link name of the parallel port.
    665665        pPPI->PortName = 0;
    666        
     666
    667667        return TRUE;
    668668      }
Note: See TracChangeset for help on using the changeset viewer.