1 #ifndef _GPXE_POSIX_IO_H
2 #define _GPXE_POSIX_IO_H
11 #include <gpxe/uaccess.h>
13 /** Minimum file descriptor that will ever be allocated */
14 #define POSIX_FD_MIN ( 1 )
16 /** Maximum file descriptor that will ever be allocated */
17 #define POSIX_FD_MAX ( 31 )
19 /** File descriptor set as used for select() */
20 typedef uint32_t fd_set
;
22 extern int open ( const char *uri_string
);
23 extern ssize_t
read_user ( int fd
, userptr_t buffer
,
24 off_t offset
, size_t len
);
25 extern int select ( fd_set
*readfds
, int wait
);
26 extern ssize_t
fsize ( int fd
);
27 extern int close ( int fd
);
30 * Zero a file descriptor set
32 * @v set File descriptor set
34 static inline __attribute__ (( always_inline
)) void
35 FD_ZERO ( fd_set
*set
) {
40 * Set a bit within a file descriptor set
42 * @v fd File descriptor
43 * @v set File descriptor set
45 static inline __attribute__ (( always_inline
)) void
46 FD_SET ( int fd
, fd_set
*set
) {
51 * Clear a bit within a file descriptor set
53 * @v fd File descriptor
54 * @v set File descriptor set
56 static inline __attribute__ (( always_inline
)) void
57 FD_CLR ( int fd
, fd_set
*set
) {
62 * Test a bit within a file descriptor set
64 * @v fd File descriptor
65 * @v set File descriptor set
66 * @ret is_set Corresponding bit is set
68 static inline __attribute__ (( always_inline
)) int
69 FD_ISSET ( int fd
, fd_set
*set
) {
70 return ( *set
& ( 1 << fd
) );
76 * @v fd File descriptor
78 * @v len Maximum length to read
79 * @ret len Actual length read, or negative error number
81 static inline ssize_t
read ( int fd
, void *buf
, size_t len
) {
82 return read_user ( fd
, virt_to_user ( buf
), 0, len
);
85 #endif /* _GPXE_POSIX_IO_H */