]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[linux] Add linux api headers
authorPiotr Jaroszyński <p.jaroszynski@gmail.com>
Thu, 27 May 2010 17:13:56 +0000 (19:13 +0200)
committerMichael Brown <mcb30@ipxe.org>
Thu, 19 Aug 2010 11:29:37 +0000 (12:29 +0100)
Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/i386/include/bits/linux_api.h [new file with mode: 0644]
src/arch/x86/include/bits/linux_api_platform.h [new file with mode: 0644]
src/arch/x86_64/include/bits/linux_api.h [new file with mode: 0644]
src/include/linux_api.h [new file with mode: 0644]

diff --git a/src/arch/i386/include/bits/linux_api.h b/src/arch/i386/include/bits/linux_api.h
new file mode 100644 (file)
index 0000000..dc6e741
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _I386_LINUX_API_H
+#define _I386_LINUX_API_H
+
+#define __SYSCALL_mmap __NR_mmap2
+
+#endif /* _I386_LINUX_API_H */
diff --git a/src/arch/x86/include/bits/linux_api_platform.h b/src/arch/x86/include/bits/linux_api_platform.h
new file mode 100644 (file)
index 0000000..4a9ced5
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _LINUX_API_PLATFORM_H
+#define _LINUX_API_PLATFORM_H
+
+extern int linux_errno;
+
+#endif /* _LINUX_API_PLATFORM_H */
diff --git a/src/arch/x86_64/include/bits/linux_api.h b/src/arch/x86_64/include/bits/linux_api.h
new file mode 100644 (file)
index 0000000..589fb58
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _X86_64_LINUX_API_H
+#define _X86_64_LINUX_API_H
+
+#define __SYSCALL_mmap __NR_mmap
+
+#endif /* _X86_64_LINUX_API_H */
diff --git a/src/include/linux_api.h b/src/include/linux_api.h
new file mode 100644 (file)
index 0000000..6f591d8
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Piotr Jaroszyński <p.jaroszynski@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _LINUX_API_H
+#define _LINUX_API_H
+
+/** * @file
+ *
+ * Linux API prototypes.
+ * Most of the functions map directly to linux syscalls and are the equivalent
+ * of POSIX functions with the linux_ prefix removed.
+ */
+
+FILE_LICENCE(GPL2_OR_LATER);
+
+#include <bits/linux_api.h>
+#include <bits/linux_api_platform.h>
+
+#include <stdint.h>
+
+typedef int pid_t;
+
+#include <linux/types.h>
+#include <linux/posix_types.h>
+#include <linux/time.h>
+#include <linux/mman.h>
+#include <linux/fcntl.h>
+#include <linux/ioctl.h>
+#include <linux/poll.h>
+
+typedef uint32_t useconds_t;
+
+extern long linux_syscall(int number, ...);
+
+extern int linux_open(const char *pathname, int flags);
+extern int linux_close(int fd);
+extern ssize_t linux_read(int fd, void *buf, size_t count);
+extern ssize_t linux_write(int fd, const void *buf, size_t count);
+extern int linux_fcntl(int fd, int cmd, ...);
+extern int linux_ioctl(int fd, int request, ...);
+
+typedef unsigned long nfds_t;
+extern int linux_poll(struct pollfd *fds, nfds_t nfds, int timeout);
+
+extern int linux_nanosleep(const struct timespec *req, struct timespec *rem);
+extern int linux_usleep(useconds_t usec);
+extern int linux_gettimeofday(struct timeval *tv, struct timezone *tz);
+
+#define MAP_FAILED ((void *)-1)
+
+extern void *linux_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
+extern void *linux_mremap(void *old_address, size_t old_size, size_t new_size, int flags);
+extern int linux_munmap(void *addr, size_t length);
+
+extern const char *linux_strerror(int errnum);
+
+#endif /* _LINUX_API_H */