UniSet  1.4.0
IOAccessOld.h
См. документацию.
00001 /* This file is part of the UniSet project
00002  * Copyright (c) 2002 Free Software Foundation, Inc.
00003  * Copyright (c) 2002 Vitaly Lipatov
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018  */
00019 // --------------------------------------------------------------------------
00024 // --------------------------------------------------------------------------
00025 #include <unistd.h>
00026 #ifdef __GLIBC__
00027     #include <sys/io.h> // для glibc
00028 #else
00029     #include <asm/io.h>
00030 #endif
00031  
00032 #ifndef _IOACCESS_H_
00033 #define _IOACCESS_H_
00034 
00035 #include <fcntl.h>
00036 #include <iostream>
00037 #include <iomanip>
00038 
00039 #include "Exceptions.h"
00040 
00047 class IOAccess
00048 {
00049 public:
00050 
00052     IOAccess()
00053     {
00054         std::cout << "IOAccess!!" << std::endl;
00055         if (ioperm( 0x100, 0x50, 0666 ) == -1 )
00056             throw UniSetTypes::IOBadParam();
00057     }
00058     
00059     ~IOAccess()
00060     {
00061     }
00062     
00066     /*
00067     void get(int port, void* buf, int size) const
00068     {
00069         if ( lseek(fd_port, port, SEEK_SET) == -1 )
00070             throw IOBadParam();
00071         ssize_t s = read(fd_port, buf, size);
00072         if ( s != size )
00073             throw IOBadParam();
00074     }
00075     */
00076     
00078     int in(int port) const
00079     {
00080         char input;
00081         //get(port, &input, 1);
00082         input = inb( port );
00083 
00084         return input;
00085     }
00086     
00090     /*
00091     void put(int port, const void* buf, int size) const
00092     {
00093         if ( lseek(fd_port, port, SEEK_SET) == -1 )
00094             throw IOBadParam();
00095         ssize_t s = write(fd_port, buf, size);
00096         if ( s != size )
00097             throw IOBadParam();
00098     }
00099     */
00101     void out(int port, int value) const
00102     {
00103 //      char output = value;
00104         //put(port,&output,1);
00105         outb( value, port );
00106 
00107     }
00108 
00109 private:
00110 
00112     int fd_port;
00113     
00114 };
00115 
00116 #endif
00117 
00118