OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [io/] [common/] [current/] [include/] [file.h] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      io/common/include/file.h
4
//
5
//      Defines for high level file I/O
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    gthomas
43
// Contributors: gthomas
44
// Date:         2000-01-10
45
// Purpose:      
46
// Description:  
47
//              
48
//
49
//####DESCRIPTIONEND####
50
//
51
//==========================================================================
52
 
53
 
54
#ifndef _CYG_IO_FILE_H_
55
#define _CYG_IO_FILE_H_
56
 
57
#include <pkgconf/system.h>
58
 
59
//==========================================================================
60
// If the fileio package is loaded, we need to go through that to do all
61
// basic IO operations. This code redefines the tags on the structures so
62
// that they have the names expected by BSD based code.
63
 
64
#ifdef CYGPKG_IO_FILEIO
65
 
66
#include <pkgconf/io_fileio.h>
67
 
68
#define CYG_IOVEC_TAG iovec
69
#define CYG_UIO_TAG uio
70
#define CYG_FILEOPS_TAG fileops
71
#define CYG_FILE_TAG file
72
#define CYG_SELINFO_TAG selinfo
73
 
74
#include <cyg/fileio/fileio.h>
75
 
76
// File states
77
#define FREAD      CYG_FREAD
78
#define FWRITE     CYG_FWRITE
79
#define FNONBLOCK  CYG_FNONBLOCK
80
#define FASYNC     CYG_FASYNC
81
 
82
// Type of "file"
83
#define DTYPE_VNODE     CYG_FILE_TYPE_FILE      /* file */
84
#define DTYPE_SOCKET    CYG_FILE_TYPE_SOCKET    /* communications endpoint */
85
 
86
//==========================================================================
87
// Otherwise define all the structs here...
88
 
89
#else // CYGPKG_IO_FILEIO
90
 
91
// High-level file I/O interfaces
92
// Derived [in part] from OpenBSD <sys/file.h>, <sys/uio.h>, <sys/fcntl.h>
93
 
94
#include <pkgconf/io.h>
95
#include <cyg/infra/cyg_type.h>
96
 
97
#define NFILE CYGPKG_IO_NFILE
98
 
99
struct iovec {
100
    void           *iov_base;   /* Base address. */
101
    CYG_ADDRWORD   iov_len;     /* Length. */
102
};
103
 
104
enum    uio_rw { UIO_READ, UIO_WRITE };
105
 
106
/* Segment flag values. */
107
enum uio_seg {
108
    UIO_USERSPACE,              /* from user data space */
109
    UIO_SYSSPACE                /* from system space */
110
};
111
 
112
struct uio {
113
    struct      iovec *uio_iov; /* pointer to array of iovecs */
114
    int uio_iovcnt;     /* number of iovecs in array */
115
    CYG_ADDRWORD        uio_offset;     /* offset into file this uio corresponds to */
116
    CYG_ADDRWORD        uio_resid;      /* residual i/o count */
117
    enum        uio_seg uio_segflg; /* see above */
118
    enum        uio_rw uio_rw;  /* see above */
119
};
120
 
121
/*
122
 * Limits
123
 */
124
#define UIO_SMALLIOV    8               /* 8 on stack, else malloc */
125
 
126
// Description of open file
127
struct file {
128
    short       f_flag;         /* file state */
129
    short       f_type;         /* descriptor type */
130
    struct      fileops {
131
        int     (*fo_read)(struct file *fp, struct uio *uio);
132
        int     (*fo_write)(struct file *fp, struct uio *uio);
133
        int     (*fo_ioctl)(struct file *fp, CYG_ADDRWORD com,
134
                            CYG_ADDRWORD data);
135
        int     (*fo_select)(struct file *fp, int which);
136
        int     (*fo_close)(struct file *fp);
137
    } *f_ops;
138
    CYG_ADDRWORD        f_offset;
139
    CYG_ADDRWORD        f_data;         /* vnode or socket */
140
};
141
 
142
// File states
143
#define FREAD      0x01
144
#define FWRITE     0x02
145
#define FNONBLOCK  0x10
146
#define FASYNC     0x20
147
#define FALLOC     0x80         // File is "busy", i.e. allocated
148
 
149
// Type of "file"
150
#define DTYPE_VNODE     1       /* file */
151
#define DTYPE_SOCKET    2       /* communications endpoint */
152
#define DTYPE_PIPE      3       /* pipe */
153
 
154
externC cyg_bool getfp(int fdes, struct file **fp);
155
externC int falloc(struct file **fp, int *fd);
156
externC void ffree(struct file *fp);
157
 
158
//==========================================================================
159
 
160
#endif // CYGPKG_IO_FILEIO
161
 
162
//==========================================================================
163
#endif // _CYG_IO_FILE_H_

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.