Changeset 1858 for trunk/src


Ignore:
Timestamp:
Nov 27, 1999, 1:48:26 PM (26 years ago)
Author:
achimha
Message:

start of COM port implementation

Location:
trunk/src/kernel32
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/HandleManager.cpp

    r1850 r1858  
    1 /* $Id: HandleManager.cpp,v 1.27 1999-11-26 21:10:51 phaller Exp $ */
     1/* $Id: HandleManager.cpp,v 1.28 1999-11-27 12:48:25 achimha Exp $ */
    22
    33/*
     
    25912591  return (fResult);                                   /* deliver return code */
    25922592}
     2593
     2594
     2595/*****************************************************************************
     2596 * Name      : HMSetupComm
     2597 * Purpose   : router function for SetupComm
     2598 * Parameters:
     2599 * Variables :
     2600 * Result    :
     2601 * Remark    :
     2602 * Status    :
     2603 *
     2604 * Author    : Achim Hasenmueller [Sat, 1999/11/27 13:13]
     2605 *****************************************************************************/
     2606
     2607BOOL HMSetupComm(HANDLE hFile, DWORD dwInQueue, DWORD dwOutQueue)
     2608{
     2609  int       iIndex;                           /* index into the handle table */
     2610  BOOL      bResult;                /* result from the device handler's API */
     2611  PHMHANDLE pHMHandle;       /* pointer to the handle structure in the table */
     2612
     2613                                                          /* validate handle */
     2614  iIndex = _HMHandleQuery(hFile);              /* get the index */
     2615  if (-1 == iIndex)                                               /* error ? */
     2616  {
     2617    SetLastError(ERROR_INVALID_HANDLE);       /* set win32 error information */
     2618    return (NULL);                                         /* signal failure */
     2619  }
     2620
     2621  pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
     2622  bResult = pHMHandle->pDeviceHandler->SetupComm(&pHMHandle->hmHandleData,
     2623                                                 dwInQueue, dwOutQueue);
     2624
     2625  return (bResult);                                  /* deliver return code */
     2626}
     2627
     2628
     2629/*****************************************************************************
     2630 * Name      : HMGetCommState
     2631 * Purpose   : router function for GetCommState
     2632 * Parameters:
     2633 * Variables :
     2634 * Result    :
     2635 * Remark    :
     2636 * Status    :
     2637 *
     2638 * Author    : Achim Hasenmueller [Sat, 1999/11/27 13:40]
     2639 *****************************************************************************/
     2640
     2641BOOL HMGetCommState(INT hCommDev, LPDCB lpdcb)
     2642{
     2643  int       iIndex;                           /* index into the handle table */
     2644  BOOL      bResult;                /* result from the device handler's API */
     2645  PHMHANDLE pHMHandle;       /* pointer to the handle structure in the table */
     2646
     2647                                                          /* validate handle */
     2648  iIndex = _HMHandleQuery(hCommDev);              /* get the index */
     2649  if (-1 == iIndex)                                               /* error ? */
     2650  {
     2651    SetLastError(ERROR_INVALID_HANDLE);       /* set win32 error information */
     2652    return (NULL);                                         /* signal failure */
     2653  }
     2654
     2655  pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
     2656  bResult = pHMHandle->pDeviceHandler->GetCommState(&pHMHandle->hmHandleData,
     2657                                                    lpdcb);
     2658
     2659  return (bResult);                                  /* deliver return code */
     2660}
  • trunk/src/kernel32/comm.cpp

    r100 r1858  
    1 /* $Id: comm.cpp,v 1.2 1999-06-10 20:47:54 phaller Exp $ */
     1/* $Id: comm.cpp,v 1.3 1999-11-27 12:48:25 achimha Exp $ */
    22
    33/*
     
    1515#include <os2win.h>
    1616#include "unicode.h"
     17#include "handlemanager.h"
    1718
    1819
     
    109110BOOL WIN32API SetupComm( HANDLE hFile, DWORD dwInQueue, DWORD dwOutQueue )
    110111{
    111   dprintf(("SetupComm Not implemented (TRUE)\n"));
    112   return(TRUE);
     112  return HMSetupComm(hFile, dwInQueue, dwOutQueue);
    113113}
    114114
     
    181181BOOL WIN32API GetCommState(INT hCommDev, LPDCB lpdcb)
    182182{
    183   dprintf(("OS2GetCommState Not implemented\n"));
    184   return(FALSE);
     183  return HMGetCommState(hCommDev, lpdcb);
    185184}
    186185
  • trunk/src/kernel32/hmcomm.cpp

    r1847 r1858  
    1 /* $Id: hmcomm.cpp,v 1.2 1999-11-26 08:18:16 achimha Exp $ */
     1/* $Id: hmcomm.cpp,v 1.3 1999-11-27 12:48:26 achimha Exp $ */
    22
    33/*
     
    1010 */
    1111
     12#include <odin.h>
     13#include <win32type.h>
     14#include <misc.h>
     15#include "handlemanager.h"
     16#include "hmdevice.h"
     17#include "hmcomm.h"
     18#include "oslibdos.h"
     19
     20
     21HMDeviceCommClass::HMDeviceCommClass(LPCSTR lpDeviceName) : HMDeviceHandler(lpDeviceName)
     22{
     23  dprintf(("HMDeviceCommClass: Register COM1 to COM4 with Handle Manager\n"));
     24  HMDeviceRegister("COM1", this);
     25  HMDeviceRegister("COM2", this);
     26  HMDeviceRegister("COM3", this);
     27  HMDeviceRegister("COM4", this);
     28
     29}
     30
     31
     32
     33DWORD HMDeviceCommClass::CreateFile(LPCSTR lpFileName,
     34                                    PHMHANDLEDATA pHMHandleData,
     35                                    PVOID lpSecurityAttributes,
     36                                    PHMHANDLEDATA pHMHandleDataTemplate)
     37{
     38  dprintf(("HMComm: Serial communication port %s open request\n", lpFileName));
     39
     40  pHMHandleData->hHMHandle = 0;
     41
     42  //AH: TODO parse Win32 security handles   
     43  pHMHandleData->hHMHandle = OSLibDosOpen((char*)lpFileName,
     44                                          OSLIB_ACCESS_READWRITE |
     45                                          OSLIB_ACCESS_SHAREDENYREAD |
     46                                          OSLIB_ACCESS_SHAREDENYWRITE);
     47  if (pHMHandleData->hHMHandle != 0)
     48    return 0;
     49  else
     50    return  -1;
     51}
     52
     53
     54                      /* this is a handler method for calls to CloseHandle() */
     55DWORD HMDeviceCommClass::CloseHandle(PHMHANDLEDATA pHMHandleData)
     56{
     57  dprintf(("HMComm: Serial communication port close request\n"));
     58  return OSLibDosClose(pHMHandleData->hHMHandle);
     59}
     60
     61/*****************************************************************************
     62 * Name      : DWORD HMDeviceHandler::SetupComm     
     63 * Purpose   : set com port parameters (queue)
     64 * Variables :
     65 * Result    :
     66 * Remark    :
     67 * Status    :
     68 *
     69 * Author    : Achim Hasenmueller
     70 *****************************************************************************/
     71
     72BOOL HMDeviceCommClass::SetupComm(PHMHANDLEDATA pHMHandleData, DWORD dwInQueue, DWORD dwOutQueue)
     73{
     74  dprintf(("HMDeviceCommClass::SetupComm unimplemented stub!"));
     75
     76
     77  return(TRUE);
     78}
  • trunk/src/kernel32/hmcomm.h

    r1850 r1858  
    1 /* $Id: hmcomm.h,v 1.3 1999-11-26 21:10:52 phaller Exp $ */
     1/* $Id: hmcomm.h,v 1.4 1999-11-27 12:48:26 achimha Exp $ */
    22
    33/*
     
    1616{
    1717  public:
    18     HMDeviceCommClass(LPCSTR lpDeviceName) : HMDeviceHandler(lpDeviceName) {}
    19  
    20   /* @@@PH here go the API methods
    21   virtual DWORD CreateEvent (PHMHANDLEDATA         pHMHandleData,
    22                              LPSECURITY_ATTRIBUTES lpsa,
    23                              BOOL                  fManualReset,
    24                              BOOL                  fInitialState,
    25                              LPCTSTR               lpszEventName);
    26                              
    27   - strings are ASCII
    28   - HANDLEs are translated to a PHMHANDLEDATA pointer
    29                              
    30   */
     18
     19  HMDeviceCommClass(LPCSTR lpDeviceName);
     20
     21  /* this is the handler method for calls to CreateFile() */
     22  virtual DWORD  CreateFile (LPCSTR        lpFileName,
     23                             PHMHANDLEDATA pHMHandleData,
     24                             PVOID         lpSecurityAttributes,
     25                             PHMHANDLEDATA pHMHandleDataTemplate);
     26
     27  /* this is the handler method for calls to CloseHandle() */
     28  virtual DWORD  CloseHandle(PHMHANDLEDATA pHMHandleData);
     29
     30  /* this is the handler method for SetComm() */
     31  virtual BOOL SetupComm(PHMHANDLEDATA pHMHandleData, DWORD dwInQueue, DWORD dwOutQueue);
    3132
    3233};
    3334
    3435
    35 
    3636#endif // _HM_COMM_H_
  • trunk/src/kernel32/hmdevice.cpp

    r1713 r1858  
    1 /* $Id: hmdevice.cpp,v 1.9 1999-11-12 14:57:13 sandervl Exp $ */
     1/* $Id: hmdevice.cpp,v 1.10 1999-11-27 12:48:26 achimha Exp $ */
    22
    33/*
     
    10821082  return(FALSE);
    10831083}
     1084
     1085
     1086/*****************************************************************************
     1087 * Name      : DWORD HMDeviceHandler::SetupComm     
     1088 * Purpose   : set com port parameters (queue)
     1089 * Variables :
     1090 * Result    :
     1091 * Remark    :
     1092 * Status    :
     1093 *
     1094 * Author    : Achim Hasenmueller
     1095 *****************************************************************************/
     1096
     1097BOOL HMDeviceHandler::SetupComm(PHMHANDLEDATA pHMHandleData, DWORD dwInQueue, DWORD dwOutQueue)
     1098{
     1099  dprintf(("KERNEL32: HandleManager::DeviceHandler::SetupComm(%08xh,%08xh,%08xh)\n",
     1100           pHMHandleData->hHMHandle,
     1101           dwInQueue, dwOutQueue));
     1102
     1103  return(FALSE);
     1104}
     1105
     1106
     1107/*****************************************************************************
     1108 * Name      : DWORD HMDeviceHandler::GetCommState   
     1109 * Purpose   : query com port control block   
     1110 * Variables :
     1111 * Result    :
     1112 * Remark    :
     1113 * Status    :
     1114 *
     1115 * Author    : Achim Hasenmueller
     1116 *****************************************************************************/
     1117BOOL HMDeviceHandler::GetCommState(PHMHANDLEDATA pHMHandleData, LPDCB lpdcb)
     1118{
     1119  dprintf(("KERNEL32: HandleManager::DeviceHandler::GetCommState(%08xh,%08xh)\n",
     1120           pHMHandleData->hHMHandle,
     1121           lpdcb));
     1122
     1123  return(FALSE);
     1124}
     1125
  • trunk/src/kernel32/hmdevice.h

    r1713 r1858  
    1 /* $Id: hmdevice.h,v 1.10 1999-11-12 14:57:14 sandervl Exp $ */
     1/* $Id: hmdevice.h,v 1.11 1999-11-27 12:48:26 achimha Exp $ */
    22
    33/*
     
    287287                                     LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped);
    288288
     289 /* COM ports */
     290 virtual BOOL SetupComm(PHMHANDLEDATA pHMHandleData, DWORD dwInQueue, DWORD dwOutQueue);
     291
     292 virtual BOOL GetCommState(PHMHANDLEDATA pHMHandleData, LPDCB lpdcb);
     293
    289294};
    290295
  • trunk/src/kernel32/kernel32exp.def

    r1605 r1858  
    591591    _lstrncmpA@12                             @785
    592592    _lstrncmpW@12                             @786
     593    _IsProcessorFeaturePresent@4              @880
    593594    _GetFileAttributesExA@12                  @874
    594595    _GetFileAttributesExW@12                  @875
     
    654655    _smalloc__FUi                             @1271
    655656    _wsnprintfA                               @2000
     657    IsExeStarted__Fv                          @2001
Note: See TracChangeset for help on using the changeset viewer.