iPXE
linux_api.h
Go to the documentation of this file.
1 #ifndef _IPXE_LINUX_API_H
2 #define _IPXE_LINUX_API_H
3 
4 /*
5  * Copyright (C) 2010 Piotr JaroszyƄski <p.jaroszynski@gmail.com>.
6  * Copyright (C) 2021 Michael Brown <mbrown@fensystems.co.uk>.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 /** @file
24  *
25  * Linux host API
26  *
27  * This file is included from both the iPXE build environment and the
28  * host build environment.
29  *
30  */
31 
32 #if __STDC_HOSTED__
33 #define __asmcall
34 #define FILE_LICENCE(x)
35 #endif
36 
37 FILE_LICENCE ( GPL2_OR_LATER );
38 
39 #include <stdint.h>
40 
41 #if ! __STDC_HOSTED__
42 #define __KERNEL_STRICT_NAMES
43 #include <linux/time.h>
44 #include <linux/mman.h>
45 #include <linux/fcntl.h>
46 #include <linux/ioctl.h>
47 #include <linux/poll.h>
48 #include <linux/fs.h>
49 #define MAP_FAILED ( ( void * ) -1 )
50 #endif
51 
52 struct sockaddr;
53 struct slirp_config;
54 struct slirp_callbacks;
55 struct Slirp;
56 
57 extern int linux_errno;
58 extern int linux_argc;
59 extern char **linux_argv;
60 
61 extern int __asmcall linux_open ( const char *pathname, int flags, ... );
62 extern int __asmcall linux_close ( int fd );
63 extern off_t __asmcall linux_lseek ( int fd, off_t offset, int whence );
64 extern ssize_t __asmcall linux_read ( int fd, void *buf, size_t count );
65 extern ssize_t __asmcall linux_write ( int fd, const void *buf, size_t count );
66 extern int __asmcall linux_fcntl ( int fd, int cmd, ... );
67 extern int __asmcall linux_ioctl ( int fd, unsigned long request, ... );
68 extern int __asmcall linux_fstat_size ( int fd, size_t *size );
69 extern int __asmcall linux_poll ( struct pollfd *fds, unsigned int nfds,
70  int timeout );
71 extern int __asmcall linux_nanosleep ( const struct timespec *req,
72  struct timespec *rem );
73 extern int __asmcall linux_usleep ( unsigned int usec );
74 extern int __asmcall linux_gettimeofday ( struct timeval *tv,
75  struct timezone *tz );
76 extern void * __asmcall linux_mmap ( void *addr, size_t length, int prot,
77  int flags, int fd, off_t offset );
78 extern void * __asmcall linux_mremap ( void *old_address, size_t old_size,
79  size_t new_size, int flags, ... );
80 extern int __asmcall linux_munmap ( void *addr, size_t length );
81 extern int __asmcall linux_socket ( int domain, int type, int protocol );
82 extern int __asmcall linux_bind ( int sockfd, const struct sockaddr *addr,
83  size_t addrlen );
84 extern ssize_t __asmcall linux_sendto ( int sockfd, const void *buf,
85  size_t len, int flags,
86  const struct sockaddr *dest_addr,
87  size_t addrlen );
88 extern const char * __asmcall linux_strerror ( int linux_errno );
89 extern struct Slirp * __asmcall
90 linux_slirp_new ( const struct slirp_config *config,
91  const struct slirp_callbacks *callbacks, void *opaque );
92 extern void __asmcall linux_slirp_cleanup ( struct Slirp *slirp );
93 extern void __asmcall linux_slirp_input ( struct Slirp *slirp,
94  const uint8_t *pkt, int pkt_len );
95 extern void __asmcall
96 linux_slirp_pollfds_fill ( struct Slirp *slirp, uint32_t *timeout,
97  int ( __asmcall * add_poll ) ( int fd, int events,
98  void *opaque ),
99  void *opaque );
100 extern void __asmcall
101 linux_slirp_pollfds_poll ( struct Slirp *slirp, int select_error,
102  int ( __asmcall * get_revents ) ( int idx,
103  void *opaque ),
104  void *opaque );
105 
106 #endif /* _IPXE_LINUX_API_H */
Slirp device configuration.
Definition: slirp.h:31
u16 length
Definition: sky2.h:9
void *__asmcall linux_mremap(void *old_address, size_t old_size, size_t new_size, int flags,...)
int __asmcall linux_fcntl(int fd, int cmd,...)
char ** linux_argv
Definition: linux_args.c:30
int linux_argc
Definition: linux_args.c:29
struct Slirp *__asmcall linux_slirp_new(const struct slirp_config *config, const struct slirp_callbacks *callbacks, void *opaque)
int __asmcall linux_gettimeofday(struct timeval *tv, struct timezone *tz)
int __asmcall linux_close(int fd)
int __asmcall linux_open(const char *pathname, int flags,...)
off_t __asmcall linux_lseek(int fd, off_t offset, int whence)
void __asmcall linux_slirp_pollfds_fill(struct Slirp *slirp, uint32_t *timeout, int(__asmcall *add_poll)(int fd, int events, void *opaque), void *opaque)
int __asmcall linux_bind(int sockfd, const struct sockaddr *addr, size_t addrlen)
int __asmcall linux_socket(int domain, int type, int protocol)
int __asmcall linux_fstat_size(int fd, size_t *size)
int __asmcall linux_ioctl(int fd, unsigned long request,...)
void __asmcall linux_slirp_cleanup(struct Slirp *slirp)
int linux_errno
int __asmcall linux_poll(struct pollfd *fds, unsigned int nfds, int timeout)
#define __asmcall
Declare a function with standard calling conventions.
Definition: compiler.h:15
ssize_t __asmcall linux_read(int fd, void *buf, size_t count)
ssize_t __asmcall linux_sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, size_t addrlen)
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
const char *__asmcall linux_strerror(int linux_errno)
Generalized socket address structure.
Definition: socket.h:96
void *__asmcall linux_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
int __asmcall linux_munmap(void *addr, size_t length)
FILE_LICENCE(GPL2_OR_LATER)
u32 addr
Definition: sky2.h:8
unsigned char uint8_t
Definition: stdint.h:10
int __asmcall linux_usleep(unsigned int usec)
ssize_t __asmcall linux_write(int fd, const void *buf, size_t count)
unsigned int uint32_t
Definition: stdint.h:12
void __asmcall linux_slirp_pollfds_poll(struct Slirp *slirp, int select_error, int(__asmcall *get_revents)(int idx, void *opaque), void *opaque)
Slirp device callbacks.
Definition: slirp.h:81
signed long off_t
Definition: stdint.h:8
uint32_t len
Length.
Definition: ena.h:14
uint32_t type
Operating system type.
Definition: ena.h:12
uint16_t count
Number of entries.
Definition: ena.h:22
u8 request[0]
List of IEs requested.
Definition: ieee80211.h:16
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
int __asmcall linux_nanosleep(const struct timespec *req, struct timespec *rem)
void timeout(int)
uint16_t protocol
Protocol ID.
Definition: stp.h:18
signed long ssize_t
Definition: stdint.h:7
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
struct ntlm_data domain
Domain name.
Definition: ntlm.h:16
void __asmcall linux_slirp_input(struct Slirp *slirp, const uint8_t *pkt, int pkt_len)
uint8_t flags
Flags.
Definition: ena.h:18
static struct sockaddr_in dest_addr
Definition: gdbudp.c:54