00001 /************************************************************************* 00002 ** C version of CIO 00003 ** Copyright (c) 1991 Jim Patchell 00004 ** 00005 ** This is the Central Input Output device handler. This is probably 00006 ** a lame attempt to make access to various I/O devices a little more 00007 ** orthagonal. Maybe, maybe not. 00008 ** 00009 ** The interface function, cio only requires one parameter, but accepts 00010 ** a variable number of parameters depending on the type of function 00011 ** it is that is being executed. 00012 ** 00013 ** The functions that can be executed are: 00014 ** 00015 ** add handler 00016 ** open 00017 ** close 00018 ** get 00019 ** get record (read) 00020 ** put 00021 ** put record (write) 00022 ** status 00023 ** special command (xio) 00024 ** 00025 ** 00026 **************************************************************************/ 00027 00028 #include <stdio.h> 00029 #include <stdlib.h> 00030 #include <string.h> 00031 #include "fcntl.h" 00032 #include "cio.h" 00033 #include "task.h" 00034 00035 00036 int CioGetC(IOCB *I) 00037 { 00038 /* 00039 ** Get character from handler 00040 ** called as: cio(GETC,handle) 00041 */ 00042 if((I->mode & FCNTL_RDONLY) == 0) 00043 return(CIO_WRONLY); 00044 // 00045 // look up function 00046 // 00047 return ( (*htabs[I->ichid].HtabsEntry->getv)(I) ); 00048 } 00049 00050 int CioRead(IOCB *I,char *b,int n) 00051 { 00052 /* 00053 ** Get a character buffer from handler 00054 ** called as: cio(READ,handle,buffer,count) 00055 ** driver function returns either an error or 00056 ** actual number of bytes read 00057 */ 00058 if((I->mode & FCNTL_RDONLY) == 0) 00059 return(CIO_WRONLY); 00060 // 00061 //look up function 00062 // 00063 return (*htabs[I->ichid].HtabsEntry->readv)(I,b,n); 00064 }