iPXE
linux_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Piotr JaroszyƄski <p.jaroszynski@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef _LINUX_API_H
20 #define _LINUX_API_H
21 
22 /** * @file
23  *
24  * Linux API prototypes.
25  * Most of the functions map directly to linux syscalls and are the equivalent
26  * of POSIX functions with the linux_ prefix removed.
27  */
28 
29 FILE_LICENCE(GPL2_OR_LATER);
30 
31 #include <bits/linux_api.h>
33 
34 #include <stdint.h>
35 
36 #define __KERNEL_STRICT_NAMES
37 #include <linux/types.h>
38 #include <linux/posix_types.h>
39 typedef __kernel_pid_t pid_t;
40 typedef __kernel_suseconds_t suseconds_t;
41 typedef __kernel_loff_t loff_t;
42 #include <linux/time.h>
43 #include <linux/mman.h>
44 #include <linux/fcntl.h>
45 #include <linux/ioctl.h>
46 #include <linux/poll.h>
47 typedef unsigned long nfds_t;
50 struct sockaddr;
51 #define MAP_FAILED ( ( void * ) -1 )
52 #define SEEK_SET 0
53 
54 extern long linux_syscall ( int number, ... );
55 
56 extern int linux_open ( const char *pathname, int flags );
57 extern int linux_close ( int fd );
58 extern off_t linux_lseek ( int fd, off_t offset, int whence );
59 extern __kernel_ssize_t linux_read ( int fd, void *buf, __kernel_size_t count );
60 extern __kernel_ssize_t linux_write ( int fd, const void *buf,
61  __kernel_size_t count );
62 extern int linux_fcntl ( int fd, int cmd, ... );
63 extern int linux_ioctl ( int fd, int request, ... );
64 extern int linux_poll ( struct pollfd *fds, nfds_t nfds, int timeout );
65 extern int linux_nanosleep ( const struct timespec *req, struct timespec *rem );
66 extern int linux_usleep ( useconds_t usec );
67 extern int linux_gettimeofday ( struct timeval *tv, struct timezone *tz );
68 extern void * linux_mmap ( void *addr, __kernel_size_t length, int prot,
69  int flags, int fd, off_t offset );
70 extern void * linux_mremap ( void *old_address, __kernel_size_t old_size,
71  __kernel_size_t new_size, int flags );
72 extern int linux_munmap ( void *addr, __kernel_size_t length );
73 extern int linux_socket ( int domain, int type_, int protocol );
74 extern int linux_bind ( int fd, const struct sockaddr *addr,
75  socklen_t addrlen );
76 extern ssize_t linux_sendto ( int fd, const void *buf, size_t len, int flags,
77  const struct sockaddr *daddr, socklen_t addrlen );
78 
79 extern const char * linux_strerror ( int errnum );
80 
81 #endif /* _LINUX_API_H */
uint16_t length
Length.
Definition: intel.h:14
off_t linux_lseek(int fd, off_t offset, int whence)
Definition: linux_api.c:40
int linux_gettimeofday(struct timeval *tv, struct timezone *tz)
Definition: linux_api.c:92
__kernel_ssize_t linux_read(int fd, void *buf, __kernel_size_t count)
Definition: linux_api.c:44
void * linux_mremap(void *old_address, __kernel_size_t old_size, __kernel_size_t new_size, int flags)
Definition: linux_api.c:102
FILE_LICENCE(GPL2_OR_LATER)
int linux_close(int fd)
Definition: linux_api.c:36
uint32_t useconds_t
Definition: linux_api.h:48
int linux_ioctl(int fd, int request,...)
Definition: linux_api.c:64
uint32_t socklen_t
Definition: linux_api.h:49
long linux_syscall(int number,...)
int linux_bind(int fd, const struct sockaddr *addr, socklen_t addrlen)
Definition: linux_api.c:124
__kernel_ssize_t linux_write(int fd, const void *buf, __kernel_size_t count)
Definition: linux_api.c:48
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
int linux_poll(struct pollfd *fds, nfds_t nfds, int timeout)
Definition: linux_api.c:75
__kernel_pid_t pid_t
Definition: linux_api.h:39
int linux_socket(int domain, int type_, int protocol)
Definition: linux_api.c:112
int linux_fcntl(int fd, int cmd,...)
Definition: linux_api.c:53
Generalized socket address structure.
Definition: socket.h:96
int linux_open(const char *pathname, int flags)
Definition: linux_api.c:32
int linux_usleep(useconds_t usec)
Definition: linux_api.c:83
void * linux_mmap(void *addr, __kernel_size_t length, int prot, int flags, int fd, off_t offset)
u32 addr
Definition: sky2.h:8
int linux_nanosleep(const struct timespec *req, struct timespec *rem)
Definition: linux_api.c:79
unsigned int uint32_t
Definition: stdint.h:12
signed long off_t
Definition: stdint.h:8
__kernel_suseconds_t suseconds_t
Definition: linux_api.h:40
uint32_t len
Length.
Definition: ena.h:14
const char * linux_strerror(int errnum)
uint16_t count
Number of entries.
Definition: ena.h:22
u8 request[0]
List of IEs requested.
Definition: ieee80211.h:16
unsigned long nfds_t
Definition: linux_api.h:47
__kernel_loff_t loff_t
Definition: linux_api.h:41
void timeout(int)
ssize_t linux_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *daddr, socklen_t addrlen)
Definition: linux_api.c:136
uint16_t protocol
Protocol ID.
Definition: stp.h:18
signed long ssize_t
Definition: stdint.h:7
int linux_munmap(void *addr, __kernel_size_t length)
Definition: linux_api.c:108
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
struct ntlm_data domain
Domain name.
Definition: ntlm.h:16
uint8_t flags
Flags.
Definition: ena.h:18