mirror of https://github.com/ipxe/ipxe.git
[linux] Rewrite headers included in all builds
Rewrite (and relicense) the header files which are included in all builds of iPXE (including non-Linux builds). Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/34/head
parent
81166302a0
commit
bfbb2b8f1c
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* iPXE entropy API for linux
|
* /dev/random-based entropy source
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -23,10 +23,12 @@ FILE_LICENCE(GPL2_OR_LATER_OR_UBDL);
|
||||||
static inline __always_inline double
|
static inline __always_inline double
|
||||||
ENTROPY_INLINE ( linux, min_entropy_per_sample ) ( void ) {
|
ENTROPY_INLINE ( linux, min_entropy_per_sample ) ( void ) {
|
||||||
|
|
||||||
/* We read single bytes from /dev/random and assume that each
|
/* linux_get_noise() reads a single byte from /dev/random,
|
||||||
* contains full entropy.
|
* which is supposed to block until a sufficient amount of
|
||||||
|
* entropy is available. We therefore assume that each sample
|
||||||
|
* contains exactly 8 bits of entropy.
|
||||||
*/
|
*/
|
||||||
return 8;
|
return 8.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _IPXE_LINUX_ENTROPY_H */
|
#endif /* _IPXE_LINUX_ENTROPY_H */
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FILE_LICENCE(GPL2_OR_LATER);
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
#ifdef NAP_LINUX
|
#ifdef NAP_LINUX
|
||||||
#define NAP_PREFIX_linux
|
#define NAP_PREFIX_linux
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* iPXE SMBIOS API for linux
|
* iPXE SMBIOS API for Linux
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FILE_LICENCE(GPL2_OR_LATER);
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
#ifdef SMBIOS_LINUX
|
#ifdef SMBIOS_LINUX
|
||||||
#define SMBIOS_PREFIX_linux
|
#define SMBIOS_PREFIX_linux
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER );
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
#ifdef TIMER_LINUX
|
#ifdef TIMER_LINUX
|
||||||
#define TIMER_PREFIX_linux
|
#define TIMER_PREFIX_linux
|
||||||
|
|
|
@ -1,115 +1,107 @@
|
||||||
/*
|
|
||||||
* 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 _IPXE_LINUX_UACCESS_H
|
#ifndef _IPXE_LINUX_UACCESS_H
|
||||||
#define _IPXE_LINUX_UACCESS_H
|
#define _IPXE_LINUX_UACCESS_H
|
||||||
|
|
||||||
FILE_LICENCE(GPL2_OR_LATER);
|
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* iPXE user access API for linux
|
* iPXE user access API for Linux
|
||||||
*
|
*
|
||||||
* In linux userspace virtual == user == phys addresses.
|
* We run with no distinction between internal and external addresses,
|
||||||
* Physical addresses also being the same is wrong, but there is no general way
|
* so can use trivial_virt_to_user() et al.
|
||||||
* of converting userspace addresses to physical as what appears to be
|
*
|
||||||
* contiguous in userspace is physically fragmented.
|
* We have no concept of the underlying physical addresses, since
|
||||||
* Currently only the DMA memory is special-cased, but its conversion to bus
|
* these are not exposed to userspace. We provide a stub
|
||||||
* addresses is done in phys_to_bus.
|
* implementation of user_to_phys() since this is required by
|
||||||
* This is known to break virtio as it is passing phys addresses to the virtual
|
* alloc_memblock(). We provide no implementation of phys_to_user();
|
||||||
* device.
|
* any code attempting to access physical addresses will therefore
|
||||||
|
* (correctly) fail to link.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
#ifdef UACCESS_LINUX
|
#ifdef UACCESS_LINUX
|
||||||
#define UACCESS_PREFIX_linux
|
#define UACCESS_PREFIX_linux
|
||||||
#else
|
#else
|
||||||
#define UACCESS_PREFIX_linux __linux_
|
#define UACCESS_PREFIX_linux __linux_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline __always_inline userptr_t
|
/**
|
||||||
UACCESS_INLINE(linux, phys_to_user)(unsigned long phys_addr)
|
* Convert user buffer to physical address
|
||||||
{
|
*
|
||||||
return phys_addr;
|
* @v userptr User pointer
|
||||||
}
|
* @v offset Offset from user pointer
|
||||||
|
* @ret phys_addr Physical address
|
||||||
|
*/
|
||||||
static inline __always_inline unsigned long
|
static inline __always_inline unsigned long
|
||||||
UACCESS_INLINE(linux, user_to_phys)(userptr_t userptr, off_t offset)
|
UACCESS_INLINE ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) {
|
||||||
{
|
|
||||||
return userptr + offset;
|
/* We do not know the real underlying physical address. We
|
||||||
|
* provide this stub implementation only because it is
|
||||||
|
* required by alloc_memblock() (which allocates memory with
|
||||||
|
* specified physical address alignment). We assume that the
|
||||||
|
* low-order bits of virtual addresses match the low-order
|
||||||
|
* bits of physical addresses, and so simply returning the
|
||||||
|
* virtual address will suffice for the purpose of determining
|
||||||
|
* alignment.
|
||||||
|
*/
|
||||||
|
return ( userptr + offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline userptr_t
|
static inline __always_inline userptr_t
|
||||||
UACCESS_INLINE(linux, virt_to_user)(volatile const void *addr)
|
UACCESS_INLINE ( linux, virt_to_user ) ( volatile const void *addr ) {
|
||||||
{
|
|
||||||
return trivial_virt_to_user ( addr );
|
return trivial_virt_to_user ( addr );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline void *
|
static inline __always_inline void *
|
||||||
UACCESS_INLINE(linux, user_to_virt)(userptr_t userptr, off_t offset)
|
UACCESS_INLINE ( linux, user_to_virt ) ( userptr_t userptr, off_t offset ) {
|
||||||
{
|
|
||||||
return trivial_user_to_virt ( userptr, offset );
|
return trivial_user_to_virt ( userptr, offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline userptr_t
|
static inline __always_inline userptr_t
|
||||||
UACCESS_INLINE(linux, userptr_add)(userptr_t userptr, off_t offset)
|
UACCESS_INLINE ( linux, userptr_add ) ( userptr_t userptr, off_t offset ) {
|
||||||
{
|
|
||||||
return trivial_userptr_add ( userptr, offset );
|
return trivial_userptr_add ( userptr, offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline off_t
|
static inline __always_inline off_t
|
||||||
UACCESS_INLINE(linux, userptr_sub)(userptr_t userptr, userptr_t subtrahend)
|
UACCESS_INLINE ( linux, userptr_sub ) ( userptr_t userptr,
|
||||||
{
|
userptr_t subtrahend ) {
|
||||||
return trivial_userptr_sub ( userptr, subtrahend );
|
return trivial_userptr_sub ( userptr, subtrahend );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline void
|
static inline __always_inline void
|
||||||
UACCESS_INLINE(linux, memcpy_user)(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
|
UACCESS_INLINE ( linux, memcpy_user ) ( userptr_t dest, off_t dest_off,
|
||||||
{
|
userptr_t src, off_t src_off,
|
||||||
|
size_t len ) {
|
||||||
trivial_memcpy_user ( dest, dest_off, src, src_off, len );
|
trivial_memcpy_user ( dest, dest_off, src, src_off, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline void
|
static inline __always_inline void
|
||||||
UACCESS_INLINE(linux, memmove_user)(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
|
UACCESS_INLINE ( linux, memmove_user ) ( userptr_t dest, off_t dest_off,
|
||||||
{
|
userptr_t src, off_t src_off,
|
||||||
|
size_t len ) {
|
||||||
trivial_memmove_user ( dest, dest_off, src, src_off, len );
|
trivial_memmove_user ( dest, dest_off, src, src_off, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline int
|
static inline __always_inline int
|
||||||
UACCESS_INLINE(linux, memcmp_user)(userptr_t first, off_t first_off, userptr_t second, off_t second_off, size_t len)
|
UACCESS_INLINE ( linux, memcmp_user ) ( userptr_t first, off_t first_off,
|
||||||
{
|
userptr_t second, off_t second_off,
|
||||||
|
size_t len ) {
|
||||||
return trivial_memcmp_user ( first, first_off, second, second_off, len);
|
return trivial_memcmp_user ( first, first_off, second, second_off, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline void
|
static inline __always_inline void
|
||||||
UACCESS_INLINE(linux, memset_user)(userptr_t buffer, off_t offset, int c, size_t len)
|
UACCESS_INLINE ( linux, memset_user ) ( userptr_t buffer, off_t offset,
|
||||||
{
|
int c, size_t len ) {
|
||||||
trivial_memset_user ( buffer, offset, c, len );
|
trivial_memset_user ( buffer, offset, c, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline size_t
|
static inline __always_inline size_t
|
||||||
UACCESS_INLINE(linux, strlen_user)(userptr_t buffer, off_t offset)
|
UACCESS_INLINE ( linux, strlen_user ) ( userptr_t buffer, off_t offset ) {
|
||||||
{
|
|
||||||
return trivial_strlen_user ( buffer, offset );
|
return trivial_strlen_user ( buffer, offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline off_t
|
static inline __always_inline off_t
|
||||||
UACCESS_INLINE(linux, memchr_user)(userptr_t buffer, off_t offset, int c, size_t len)
|
UACCESS_INLINE ( linux, memchr_user ) ( userptr_t buffer, off_t offset,
|
||||||
{
|
int c, size_t len ) {
|
||||||
return trivial_memchr_user ( buffer, offset, c, len );
|
return trivial_memchr_user ( buffer, offset, c, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#ifndef _IPXE_LINUX_UMALLOC_H
|
#ifndef _IPXE_LINUX_UMALLOC_H
|
||||||
#define _IPXE_LINUX_UMALLOC_H
|
#define _IPXE_LINUX_UMALLOC_H
|
||||||
|
|
||||||
FILE_LICENCE(GPL2_OR_LATER);
|
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* iPXE user memory allocation API for linux
|
* iPXE user memory allocation API for Linux
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
#ifdef UMALLOC_LINUX
|
#ifdef UMALLOC_LINUX
|
||||||
#define UMALLOC_PREFIX_linux
|
#define UMALLOC_PREFIX_linux
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -27,7 +27,6 @@ FILE_LICENCE(GPL2_OR_LATER);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PROVIDE_UACCESS_INLINE(linux, phys_to_user);
|
|
||||||
PROVIDE_UACCESS_INLINE(linux, user_to_phys);
|
PROVIDE_UACCESS_INLINE(linux, user_to_phys);
|
||||||
PROVIDE_UACCESS_INLINE(linux, virt_to_user);
|
PROVIDE_UACCESS_INLINE(linux, virt_to_user);
|
||||||
PROVIDE_UACCESS_INLINE(linux, user_to_virt);
|
PROVIDE_UACCESS_INLINE(linux, user_to_virt);
|
||||||
|
|
Loading…
Reference in New Issue