iPXE
linux_api.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010 Piotr JaroszyƄski <p.jaroszynski@gmail.com>
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef _LINUX_API_H
00020 #define _LINUX_API_H
00021 
00022 /** * @file
00023  *
00024  * Linux API prototypes.
00025  * Most of the functions map directly to linux syscalls and are the equivalent
00026  * of POSIX functions with the linux_ prefix removed.
00027  */
00028 
00029 FILE_LICENCE(GPL2_OR_LATER);
00030 
00031 #include <bits/linux_api.h>
00032 #include <bits/linux_api_platform.h>
00033 
00034 #include <stdint.h>
00035 
00036 #define __KERNEL_STRICT_NAMES
00037 #include <linux/types.h>
00038 #include <linux/posix_types.h>
00039 typedef __kernel_pid_t pid_t;
00040 typedef __kernel_suseconds_t suseconds_t;
00041 typedef __kernel_loff_t loff_t;
00042 #include <linux/time.h>
00043 #include <linux/mman.h>
00044 #include <linux/fcntl.h>
00045 #include <linux/ioctl.h>
00046 #include <linux/poll.h>
00047 typedef unsigned long nfds_t;
00048 typedef uint32_t useconds_t;
00049 typedef uint32_t socklen_t;
00050 struct sockaddr;
00051 #define MAP_FAILED ( ( void * ) -1 )
00052 #define SEEK_SET 0
00053 
00054 extern long linux_syscall ( int number, ... );
00055 
00056 extern int linux_open ( const char *pathname, int flags );
00057 extern int linux_close ( int fd );
00058 extern off_t linux_lseek ( int fd, off_t offset, int whence );
00059 extern __kernel_ssize_t linux_read ( int fd, void *buf, __kernel_size_t count );
00060 extern __kernel_ssize_t linux_write ( int fd, const void *buf,
00061                                       __kernel_size_t count );
00062 extern int linux_fcntl ( int fd, int cmd, ... );
00063 extern int linux_ioctl ( int fd, int request, ... );
00064 extern int linux_poll ( struct pollfd *fds, nfds_t nfds, int timeout );
00065 extern int linux_nanosleep ( const struct timespec *req, struct timespec *rem );
00066 extern int linux_usleep ( useconds_t usec );
00067 extern int linux_gettimeofday ( struct timeval *tv, struct timezone *tz );
00068 extern void * linux_mmap ( void *addr, __kernel_size_t length, int prot,
00069                            int flags, int fd, off_t offset );
00070 extern void * linux_mremap ( void *old_address, __kernel_size_t old_size,
00071                              __kernel_size_t new_size, int flags );
00072 extern int linux_munmap ( void *addr, __kernel_size_t length );
00073 extern int linux_socket ( int domain, int type_, int protocol );
00074 extern int linux_bind ( int fd, const struct sockaddr *addr,
00075                         socklen_t addrlen );
00076 extern ssize_t linux_sendto ( int fd, const void *buf, size_t len, int flags,
00077                               const struct sockaddr *daddr, socklen_t addrlen );
00078 
00079 extern const char * linux_strerror ( int errnum );
00080 
00081 #endif /* _LINUX_API_H */