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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [syn/] [components/] [sd_card/] [firmware/] [bsp/] [HAL/] [inc/] [priv/] [alt_file.h] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 alfik
#ifndef __ALT_FILE_H__
2
#define __ALT_FILE_H__
3
 
4
/******************************************************************************
5
*                                                                             *
6
* License Agreement                                                           *
7
*                                                                             *
8
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA.           *
9
* All rights reserved.                                                        *
10
*                                                                             *
11
* Permission is hereby granted, free of charge, to any person obtaining a     *
12
* copy of this software and associated documentation files (the "Software"),  *
13
* to deal in the Software without restriction, including without limitation   *
14
* the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
15
* and/or sell copies of the Software, and to permit persons to whom the       *
16
* Software is furnished to do so, subject to the following conditions:        *
17
*                                                                             *
18
* The above copyright notice and this permission notice shall be included in  *
19
* all copies or substantial portions of the Software.                         *
20
*                                                                             *
21
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
22
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
23
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
24
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
25
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
26
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
27
* DEALINGS IN THE SOFTWARE.                                                   *
28
*                                                                             *
29
* This agreement shall be governed in all respects by the laws of the State   *
30
* of California and by the laws of the United States of America.              *
31
*                                                                             *
32
* Altera does not recommend, suggest or require that this reference design    *
33
* file be used in conjunction or combination with any other product.          *
34
******************************************************************************/
35
 
36
/******************************************************************************
37
*                                                                             *
38
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT.                       *
39
*                                                                             *
40
******************************************************************************/
41
 
42
#include "sys/alt_dev.h"
43
#include "sys/alt_llist.h"
44
#include "os/alt_sem.h"
45
 
46
#include "alt_types.h"
47
 
48
/*
49
 * This header provides the internal defenitions required to control file
50
 * access. These variables and functions are not guaranteed to exist in
51
 * future implementations of the HAL.
52
 */
53
 
54
#ifdef __cplusplus
55
extern "C"
56
{
57
#endif /* __cplusplus */
58
 
59
/*
60
 * The function alt_find_dev() is used to search the device list "list" to
61
 * locate a device named "name". If a match is found, then a pointer to the
62
 * device is returned, otherwise NULL is returned.
63
 */
64
 
65
extern alt_dev* alt_find_dev (const char* name, alt_llist* list);
66
 
67
/*
68
 * alt_find_file() is used to search the list of registered file systems to
69
 * find the filesystem that the file named "name" belongs to. If a match is
70
 * found, then a pointer to the filesystems alt_dev structure is returned,
71
 * otherwise NULL is returned.
72
 *
73
 * Note that a match does not indicate that the file exists, only that a
74
 * filesystem exists that is registered for a partition that could contain
75
 * the file. The filesystems open() function would need to be called in order
76
 * to determine if the file exists.
77
 */
78
 
79
extern alt_dev* alt_find_file (const char* name);
80
 
81
/*
82
 * alt_get_fd() is used to allocate a file descriptor for the device or
83
 * filesystem "dev". A negative return value indicates an error, otherwise the
84
 * return value is the index of the file descriptor within the file descriptor
85
 * pool.
86
 */
87
 
88
extern int alt_get_fd (alt_dev* dev);
89
 
90
/*
91
 * alt_release_fd() is called to free the file descriptor with index "fd".
92
 */
93
 
94
extern void alt_release_fd (int fd);
95
 
96
/*
97
 * alt_fd_lock() is called by ioctl() to mark the file descriptor "fd" as
98
 * being open for exclusive access. Subsequent calls to open() for the device
99
 * associated with "fd" will fail. A device is unlocked by either calling
100
 * close() for "fd", or by an alternate call to ioctl() (see ioctl.c for
101
 * details).
102
 */
103
 
104
extern int alt_fd_lock (alt_fd* fd);
105
 
106
/*
107
 * alt_fd_unlock() is called by ioctl() to unlock a descriptor previously
108
 * locked by a call to alt_fd_lock().
109
 */
110
 
111
extern int alt_fd_unlock (alt_fd* fd);
112
 
113
/*
114
 * "alt_fd_list" is the pool of file descriptors.
115
 */
116
 
117
extern alt_fd alt_fd_list[];
118
 
119
/*
120
 * flags used by alt_fd.
121
 *
122
 * ALT_FD_EXCL is used to mark a file descriptor as locked for exclusive
123
 * access, i.e. further calls to open() for the associated device should
124
 * fail.
125
 *
126
 * ALT_FD_DEV marks a dile descriptor as belonging to a device as oposed to a
127
 * filesystem.
128
 */
129
 
130
#define ALT_FD_EXCL 0x80000000
131
#define ALT_FD_DEV  0x40000000
132
 
133
#define ALT_FD_FLAGS_MASK (ALT_FD_EXCL | ALT_FD_DEV)
134
 
135
/*
136
 * "alt_dev_list" is the head of the linked list of registered devices.
137
 */
138
 
139
extern alt_llist alt_dev_list;
140
 
141
/*
142
 * "alt_fs_list" is the head of the linked list of registered filesystems.
143
 */
144
 
145
extern alt_llist alt_fs_list;
146
 
147
/*
148
 * "alt_fd_list_lock" is a semaphore used to ensure that access to the pool
149
 * of file descriptors is thread safe.
150
 */
151
 
152
ALT_EXTERN_SEM(alt_fd_list_lock)
153
 
154
/*
155
 * "alt_max_fd" is a 'high water mark'. It indicates the highest file
156
 * descriptor allocated. Use of this can save searching the entire pool
157
 * for active file descriptors, which helps avoid contention on access
158
 * to the file descriptor pool.
159
 */
160
 
161
extern alt_32 alt_max_fd;
162
 
163
/*
164
 * alt_io_redirect() is called at startup to redirect stdout, stdin, and
165
 * stderr to the devices named in the input arguments. By default these streams
166
 * are directed at /dev/null, and are then redirected using this function once
167
 * all of the devices have been registered within the system.
168
 */
169
 
170
extern void alt_io_redirect(const char* stdout_dev,
171
                            const char* stdin_dev,
172
                            const char* stderr_dev);
173
 
174
 
175
#ifdef __cplusplus
176
}
177
#endif
178
 
179
#endif /* __ALT_FILE_H__ */

powered by: WebSVN 2.1.0

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