delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/06/28/04:24:44

From: "Tom Demmer" <DEMMER AT brain1 DOT lstm DOT ruhr-uni-bochum DOT de>
Organization: Lehrstuhl Stroemungsmechanik, RUB
To: djgpp-workers AT delorie DOT com
Date: Fri, 28 Jun 1996 10:22:46 GMT-1
Subject: ioctl proposal
Reply-to: Demmer AT LStM DOT Ruhr-Uni-Bochum DOT De
Message-ID: <F0B59D4F60@brain1.lstm.ruhr-uni-bochum.de>

Hi all, 
what do you think of this starting point? If I have overlooked (hmm, 
is that the right word?) something essential, let me know. 
#include <stdargs.h>
#include <stdlib.h>
/*
**  For the real implementation, this should be moved
**  to a headerfile of course.
**
*/
int ioctl( int fd, int cmd, ...);

/*
**  Values from TC 2.0. Names by me. 
**  This is the DOSish stuff. 
*/
#define IOCTL_GET_INFO      0
#define IOCTL_SET_INFO      1
#define IOCTL_READ          2
#define IOCTL_WRITE         3
#define IOCTL_READ_DRV      4
#define IOCTL_WRITE_DRV     5
#define IOCTL_GET_I_STATUS  6
#define IOCTL_GET_O_STATUS  7
#define IOCTL_REMOVABLE     8
#define IOCTL_SHARE_COL     11

/*
** UNIX stuff
*/
/*
*  From /usr/include/sys/ioctl.h (AIX3.2.5)
*  For djgpp, IO.H needs this, too.
*/
#ifndef _IO
/*
* Ioctl's have the command encoded in the lower word,
* and the size of any in or out parameters in the upper
* word.  The high 2 bits of the upper word are used
* to encode the in/out status of the parameter; for now
* we restrict parameters to at most 128 bytes.
*/
#define IOCPARM_MASK    0x7f            /* parameters must be < 128 bytes */
#define IOC_VOID        0x20000000      /* no parameters */
#define IOC_OUT         0x40000000      /* copy out parameters */
#define IOC_IN          0x80000000      /* copy in parameters */
#define IOC_INOUT       (IOC_IN|IOC_OUT)
/* the 0x20000000 is so we can distinguish new ioctl's from old */
#define _IO(x,y)        (IOC_VOID|(x<<8)|y)
#define _IOR(x,y,t)     (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
#define _IOW(x,y,t)     (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
/* this should be _IORW, but stdio got there first */
#define _IOWR(x,y,t)    (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
#endif /* _IO */
      
      




static int _dos_ioctl(int fd, int cmd, va_list args){
/*
** Do an int0x21,0x44 and such
*/
}
  
static int _unix_ioctl(int fd,int cmd, int arg){
/*
** What to do _HERE_ ?
*/
}

int ioctl(int fd, int cmd, ...){
  va_list args;

  va_start(args,cmd);
  
  if(cmd & 0xffff0000){
    int arg = va_arg(args, int);
    return _unix_ioctl(fd,cmd,arg);
  }
  return _dos_ioctl(fd,cmd,args);
}      

Ciao
Tom

  ******************************************************************
  *  Thomas Demmer                     * Phone : +49 234 700 6434  *
  *  Universitaetsstr. 150             * or you try                *
  *  Lehrstuhl fuer Stroemungsmechanik *         +49 234 700 2896  *
  *  D-44780 Bochum                    * and MIGHT get someone who *
  *                                    * knows where I am          *
  *  Demmer AT LStM DOT Ruhr-Uni-Bochum DOT De    * Fax    : +49 234 709-4162 *
  *          http://www.lstm.ruhr-uni-bochum.de/~demmer            *
  ******************************************************************

    Dreams are there to make them real.      -- Richard Gere
    To make dreams real you have to wake up. -- Josephine Baker

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019