home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / kernex32.zip / mwdd_src.zip / 32bits / ext2-os2 / mwdd32 / mwdd32_idc.c < prev    next >
C/C++ Source or Header  |  1997-03-16  |  4KB  |  136 lines

  1. //
  2. // $Header: d:\\32bits\\ext2-os2\\mwdd32\\rcs\\mwdd32_idc.c,v 1.6 1997/03/16 12:44:29 Willm Exp $
  3. //
  4.  
  5. // 32 bits OS/2 device driver and IFS support. Provides 32 bits kernel 
  6. // services (DevHelp) and utility functions to 32 bits OS/2 ring 0 code 
  7. // (device drivers and installable file system drivers).
  8. // Copyright (C) 1995, 1996, 1997  Matthieu WILLM (willm@ibm.net)
  9. //
  10. // This program is free software; you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation; either version 2 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program; if not, write to the Free Software
  22. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24. #define INCL_DOSERRORS
  25. #define INCL_NOPMAPI
  26. #include <os2.h>
  27.  
  28. #include <string.h>
  29.  
  30. #include <os2/types.h>
  31. #include <os2/StackToFlat.h>
  32. #include <os2/DevHlp32.h>
  33.  
  34. #include "mwdd32.h"
  35.  
  36. short mwdd32_export_devhelp32(void **pTKSSBase, struct DevHelp32 *pDevHelp32) {
  37.     short rc;
  38.  
  39.     rc = ERROR_INVALID_PARAMETER;
  40.     if (pTKSSBase) {
  41.         /*
  42.          * Updates TKSSBase
  43.          */
  44.         *pTKSSBase = TKSSBase;
  45.    
  46.         if ((pDevHelp32) && (pDevHelp32->magic == DEVHELP32_MAGIC)) {
  47.             switch (pDevHelp32->version) {
  48.             case 1:
  49.             memcpy(&(pDevHelp32->version_1), &(DevHlp32.version_1), sizeof(DevHlp32.version_1));
  50.             rc = NO_ERROR;
  51.             break;
  52.         case 2:
  53.             memcpy(&(pDevHelp32->version_2), &(DevHlp32.version_2), sizeof(DevHlp32.version_2));
  54.             rc = NO_ERROR;
  55.             break;
  56.         case 3:
  57.             memcpy(&(pDevHelp32->version_3), &(DevHlp32.version_3), sizeof(DevHlp32.version_3));
  58.             rc = NO_ERROR;
  59.             break;
  60.         case 4:
  61.             memcpy(&(pDevHelp32->version_4), &(DevHlp32.version_4), sizeof(DevHlp32.version_4));
  62.             rc = NO_ERROR;
  63.             break;
  64.         case 5:
  65.             memcpy(&(pDevHelp32->version_5), &(DevHlp32.version_5), sizeof(DevHlp32.version_5));
  66.             rc = NO_ERROR;
  67.             break;
  68.         case 6:
  69.             memcpy(&(pDevHelp32->version_6), &(DevHlp32.version_6), sizeof(DevHlp32.version_6));
  70.             rc = NO_ERROR;
  71.             break;
  72.         case 7:
  73.             memcpy(&(pDevHelp32->version_7), &(DevHlp32.version_7), sizeof(DevHlp32.version_7));
  74.             rc = NO_ERROR;
  75.             break;
  76.                 default:
  77.             break;
  78.         }
  79.         }
  80.     }
  81.     return rc;
  82. }
  83.  
  84. struct mwdd32_idc_parms {
  85.     union {
  86.         struct {
  87.         int zero;
  88.         int magic;
  89.             int func;
  90.             union {
  91.                 struct {
  92.                     struct DevHelp32  *pDevHelp32;
  93.                     void             **pTKSSBase;
  94.                 } func_1;
  95.             };
  96.         } new_interface;
  97.         struct {
  98.             void             **pTKSSBase;
  99.             struct DevHelp32  *pDevHelp32;
  100.         } old_interface;
  101.     };   
  102. };
  103.  
  104.  
  105. /*
  106.  * 32 bits IDC entry point
  107.  */
  108. unsigned long mwdd32_idc(struct mwdd32_idc_parms *parms) {
  109.     unsigned long rc;
  110.  
  111.     parms = __StackToFlat(parms);
  112.  
  113.     rc = ERROR_INVALID_PARAMETER;
  114.     if ((parms->new_interface.zero == 0) && (parms->new_interface.magic == 0x61153275)) {
  115.         /*
  116.          * this is a new post V1.00 interface
  117.          */
  118.         switch(parms->new_interface.func) {
  119.            case 1:
  120.                 rc = (unsigned long)mwdd32_export_devhelp32(parms->new_interface.func_1.pTKSSBase, parms->new_interface.func_1.pDevHelp32);
  121.                 break;
  122.             default :
  123.                 break;
  124.         }
  125.         rc &= 0xFFFF;
  126.     } else {
  127.         /*
  128.          * this is the old V1.00 interface
  129.          */
  130.         rc  = (unsigned long)mwdd32_export_devhelp32(parms->old_interface.pTKSSBase, parms->old_interface.pDevHelp32);
  131.         rc |= 0xFFFF0000;
  132.     }
  133.     return rc;
  134. }
  135.  
  136.