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
37FILE_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
52struct sockaddr;
53struct slirp_config;
54struct slirp_callbacks;
55struct Slirp;
56
57extern int linux_errno;
58extern int linux_argc;
59extern char **linux_argv;
60
61extern int __asmcall linux_open ( const char *pathname, int flags, ... );
62extern int __asmcall linux_close ( int fd );
63extern off_t __asmcall linux_lseek ( int fd, off_t offset, int whence );
64extern ssize_t __asmcall linux_read ( int fd, void *buf, size_t count );
65extern ssize_t __asmcall linux_write ( int fd, const void *buf, size_t count );
66extern int __asmcall linux_fcntl ( int fd, int cmd, ... );
67extern int __asmcall linux_ioctl ( int fd, unsigned long request, ... );
68extern int __asmcall linux_fstat_size ( int fd, size_t *size );
69extern int __asmcall linux_poll ( struct pollfd *fds, unsigned int nfds,
70 int timeout );
71extern int __asmcall linux_nanosleep ( const struct timespec *req,
72 struct timespec *rem );
73extern int __asmcall linux_usleep ( unsigned int usec );
74extern int __asmcall linux_gettimeofday ( struct timeval *tv,
75 struct timezone *tz );
76extern void * __asmcall linux_mmap ( void *addr, size_t length, int prot,
77 int flags, int fd, off_t offset );
78extern void * __asmcall linux_mremap ( void *old_address, size_t old_size,
79 size_t new_size, int flags, ... );
80extern int __asmcall linux_munmap ( void *addr, size_t length );
81extern int __asmcall linux_socket ( int domain, int type, int protocol );
82extern int __asmcall linux_bind ( int sockfd, const struct sockaddr *addr,
83 size_t addrlen );
84extern 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 );
88extern const char * __asmcall linux_strerror ( int linux_errno );
89extern struct Slirp * __asmcall
90linux_slirp_new ( const struct slirp_config *config,
91 const struct slirp_callbacks *callbacks, void *opaque );
92extern void __asmcall linux_slirp_cleanup ( struct Slirp *slirp );
93extern void __asmcall linux_slirp_input ( struct Slirp *slirp,
94 const uint8_t *pkt, int pkt_len );
95extern void __asmcall
97 int ( __asmcall * add_poll ) ( int fd, int events,
98 void *opaque ),
99 void *opaque );
100extern void __asmcall
101linux_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 */
struct golan_eqe_cmd cmd
Definition CIB_PRM.h:1
uint16_t pkt_len
Definition aqc1xx.h:2
#define __asmcall
Declare a function with standard calling conventions.
Definition compiler.h:15
unsigned int uint32_t
Definition stdint.h:12
signed long off_t
Definition stdint.h:8
unsigned char uint8_t
Definition stdint.h:10
signed long ssize_t
Definition stdint.h:7
uint16_t offset
Offset to command line.
Definition bzimage.h:3
void timeout(int)
ring len
Length.
Definition dwmac.h:226
uint32_t addr
Buffer address.
Definition dwmac.h:9
uint32_t type
Operating system type.
Definition ena.h:1
uint8_t flags
Flags.
Definition ena.h:7
static struct sockaddr_in dest_addr
Definition gdbudp.c:55
uint16_t size
Buffer size.
Definition dwmac.h:3
static unsigned int count
Number of entries.
Definition dwmac.h:220
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
u8 request[0]
List of IEs requested.
Definition ieee80211.h:2
void *__asmcall linux_mremap(void *old_address, size_t old_size, size_t new_size, int flags,...)
ssize_t __asmcall linux_write(int fd, const void *buf, size_t count)
int __asmcall linux_usleep(unsigned int usec)
int __asmcall linux_open(const char *pathname, int flags,...)
int __asmcall linux_munmap(void *addr, size_t length)
int linux_errno
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)
void __asmcall linux_slirp_input(struct Slirp *slirp, const uint8_t *pkt, int pkt_len)
int __asmcall linux_gettimeofday(struct timeval *tv, struct timezone *tz)
int __asmcall linux_ioctl(int fd, unsigned long request,...)
int __asmcall linux_close(int fd)
int __asmcall linux_fcntl(int fd, int cmd,...)
ssize_t __asmcall linux_sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, size_t addrlen)
ssize_t __asmcall linux_read(int fd, void *buf, size_t count)
int __asmcall linux_socket(int domain, int type, int protocol)
int __asmcall linux_nanosleep(const struct timespec *req, struct timespec *rem)
void __asmcall linux_slirp_pollfds_poll(struct Slirp *slirp, int select_error, int(__asmcall *get_revents)(int idx, void *opaque), void *opaque)
struct Slirp *__asmcall linux_slirp_new(const struct slirp_config *config, const struct slirp_callbacks *callbacks, void *opaque)
void __asmcall linux_slirp_cleanup(struct Slirp *slirp)
int __asmcall linux_poll(struct pollfd *fds, unsigned int nfds, int timeout)
void *__asmcall linux_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
off_t __asmcall linux_lseek(int fd, off_t offset, int whence)
const char *__asmcall linux_strerror(int linux_errno)
int __asmcall linux_fstat_size(int fd, size_t *size)
int linux_argc
Definition linux_args.c:29
char ** linux_argv
Definition linux_args.c:30
u16 length
Definition sky2.h:1
uint16_t protocol
Protocol ID.
Definition stp.h:7
Slirp device callbacks.
Definition slirp.h:81
Slirp device configuration.
Definition slirp.h:31
Generalized socket address structure.
Definition socket.h:97