diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/endian.h | 4 | ||||
| -rw-r--r-- | src/include/ipxe/cpio.h | 21 | ||||
| -rw-r--r-- | src/include/ipxe/errfile.h | 4 | ||||
| -rw-r--r-- | src/include/ipxe/gzip.h | 71 | ||||
| -rw-r--r-- | src/include/ipxe/image.h | 12 | ||||
| -rw-r--r-- | src/include/ipxe/rndis.h | 4 | ||||
| -rw-r--r-- | src/include/ipxe/zlib.h | 43 | ||||
| -rw-r--r-- | src/include/mii.h | 2 | ||||
| -rw-r--r-- | src/include/readline/readline.h | 3 | ||||
| -rw-r--r-- | src/include/stdio.h | 2 | ||||
| -rw-r--r-- | src/include/strings.h | 2 | ||||
| -rw-r--r-- | src/include/usr/imgarchive.h | 16 |
12 files changed, 180 insertions, 4 deletions
diff --git a/src/include/endian.h b/src/include/endian.h index 79c3163ee..bdae9de45 100644 --- a/src/include/endian.h +++ b/src/include/endian.h @@ -8,14 +8,18 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * Little-endian systems should define BYTE_ORDER as LITTLE_ENDIAN. * This constant is intended to be used only at compile time. */ +#ifndef __LITTLE_ENDIAN #define __LITTLE_ENDIAN 0x44332211UL +#endif /** Constant representing big-endian byte order * * Big-endian systems should define BYTE_ORDER as BIG_ENDIAN. * This constant is intended to be used only at compile time. */ +#ifndef __BIG_ENDIAN #define __BIG_ENDIAN 0x11223344UL +#endif #include "bits/endian.h" diff --git a/src/include/ipxe/cpio.h b/src/include/ipxe/cpio.h index 0637c531d..9c5e22d5a 100644 --- a/src/include/ipxe/cpio.h +++ b/src/include/ipxe/cpio.h @@ -9,6 +9,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include <ipxe/image.h> + /** A CPIO archive header * * All field are hexadecimal ASCII numbers padded with '0' on the @@ -48,6 +50,25 @@ struct cpio_header { /** CPIO magic */ #define CPIO_MAGIC "070701" +/** CPIO header length alignment */ +#define CPIO_ALIGN 4 + +/** Alignment for CPIO archives within an initrd */ +#define INITRD_ALIGN 4096 + +/** + * Get CPIO image name + * + * @v image Image + * @ret name Image name (not NUL terminated) + */ +static inline __attribute__ (( always_inline )) const char * +cpio_name ( struct image *image ) { + return image->cmdline; +} + extern void cpio_set_field ( char *field, unsigned long value ); +extern size_t cpio_name_len ( struct image *image ); +extern size_t cpio_header ( struct image *image, struct cpio_header *cpio ); #endif /* _IPXE_CPIO_H */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index e3bf9f565..cf5757874 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -213,6 +213,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_usbblk ( ERRFILE_DRIVER | 0x00ce0000 ) #define ERRFILE_iphone ( ERRFILE_DRIVER | 0x00cf0000 ) #define ERRFILE_slirp ( ERRFILE_DRIVER | 0x00d00000 ) +#define ERRFILE_rdc ( ERRFILE_DRIVER | 0x00d10000 ) #define ERRFILE_aoe ( ERRFILE_NET | 0x00000000 ) #define ERRFILE_arp ( ERRFILE_NET | 0x00010000 ) @@ -301,6 +302,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_png ( ERRFILE_IMAGE | 0x00070000 ) #define ERRFILE_der ( ERRFILE_IMAGE | 0x00080000 ) #define ERRFILE_pem ( ERRFILE_IMAGE | 0x00090000 ) +#define ERRFILE_archive ( ERRFILE_IMAGE | 0x000a0000 ) +#define ERRFILE_zlib ( ERRFILE_IMAGE | 0x000b0000 ) +#define ERRFILE_gzip ( ERRFILE_IMAGE | 0x000c0000 ) #define ERRFILE_asn1 ( ERRFILE_OTHER | 0x00000000 ) #define ERRFILE_chap ( ERRFILE_OTHER | 0x00010000 ) diff --git a/src/include/ipxe/gzip.h b/src/include/ipxe/gzip.h new file mode 100644 index 000000000..c8cf64147 --- /dev/null +++ b/src/include/ipxe/gzip.h @@ -0,0 +1,71 @@ +#ifndef _IPXE_GZIP_H +#define _IPXE_GZIP_H + +/** @file + * + * gzip compressed images + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include <stdint.h> +#include <ipxe/image.h> + +/** gzip header */ +struct gzip_header { + /** Magic ID */ + uint16_t magic; + /** Compression method */ + uint8_t method; + /** Flags */ + uint8_t flags; + /** Modification time */ + uint32_t mtime; + /** Extra flags */ + uint8_t extra; + /** Operating system */ + uint8_t os; +} __attribute__ (( packed )); + +/** Magic ID */ +#define GZIP_MAGIC 0x1f8b + +/** Compression method */ +#define GZIP_METHOD_DEFLATE 0x08 + +/** CRC header is present */ +#define GZIP_FL_HCRC 0x02 + +/** Extra header is present */ +#define GZIP_FL_EXTRA 0x04 + +/** File name is present */ +#define GZIP_FL_NAME 0x08 + +/** File comment is present */ +#define GZIP_FL_COMMENT 0x10 + +/** gzip extra header */ +struct gzip_extra_header { + /** Extra header length (excluding this field) */ + uint16_t len; +} __attribute__ (( packed )); + +/** gzip CRC header */ +struct gzip_crc_header { + /** CRC-16 */ + uint16_t crc; +} __attribute__ (( packed )); + +/** gzip footer */ +struct gzip_footer { + /** CRC-32 */ + uint32_t crc; + /** Uncompressed size (modulo 2^32) */ + uint32_t len; +} __attribute__ (( packed )); + +extern struct image_type gzip_image_type __image_type ( PROBE_NORMAL ); + +#endif /* _IPXE_GZIP_H */ diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h index 4fd270081..0a5a26034 100644 --- a/src/include/ipxe/image.h +++ b/src/include/ipxe/image.h @@ -113,6 +113,14 @@ struct image_type { */ int ( * asn1 ) ( struct image *image, size_t offset, struct asn1_cursor **cursor ); + /** + * Extract archive image + * + * @v image Image + * @v extracted Extracted image + * @ret rc Return status code + */ + int ( * extract ) ( struct image *image, struct image *extracted ); }; /** @@ -175,6 +183,7 @@ extern struct image * alloc_image ( struct uri *uri ); extern int image_set_uri ( struct image *image, struct uri *uri ); extern int image_set_name ( struct image *image, const char *name ); extern int image_set_cmdline ( struct image *image, const char *cmdline ); +extern int image_set_len ( struct image *image, size_t len ); extern int image_set_data ( struct image *image, userptr_t data, size_t len ); extern int register_image ( struct image *image ); extern void unregister_image ( struct image *image ); @@ -189,6 +198,9 @@ extern struct image * image_memory ( const char *name, userptr_t data, extern int image_pixbuf ( struct image *image, struct pixel_buffer **pixbuf ); extern int image_asn1 ( struct image *image, size_t offset, struct asn1_cursor **cursor ); +extern int image_extract ( struct image *image, const char *name, + struct image **extracted ); +extern int image_extract_exec ( struct image *image ); /** * Increment reference count on an image diff --git a/src/include/ipxe/rndis.h b/src/include/ipxe/rndis.h index bcb6d8e6a..e8ece1e85 100644 --- a/src/include/ipxe/rndis.h +++ b/src/include/ipxe/rndis.h @@ -84,7 +84,7 @@ struct rndis_initialise_completion { /** Packet alignment factor */ uint32_t align; /** Reserved */ - uint32_t reserved; + uint32_t reserved[2]; } __attribute__ (( packed )); /** RNDIS halt message */ @@ -237,7 +237,7 @@ struct rndis_packet_message { /** Per-packet information record */ struct rndis_packet_field ppi; /** Reserved */ - uint32_t reserved; + uint32_t reserved[2]; } __attribute__ (( packed )); /** RNDIS packet record */ diff --git a/src/include/ipxe/zlib.h b/src/include/ipxe/zlib.h new file mode 100644 index 000000000..29016c38e --- /dev/null +++ b/src/include/ipxe/zlib.h @@ -0,0 +1,43 @@ +#ifndef _IPXE_ZLIB_H +#define _IPXE_ZLIB_H + +/** @file + * + * zlib compressed images + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include <stdint.h> +#include <byteswap.h> +#include <ipxe/image.h> +#include <ipxe/deflate.h> + +/** zlib magic header */ +union zlib_magic { + /** Compression method and flags */ + uint8_t cmf; + /** Check value */ + uint16_t check; +} __attribute__ (( packed )); + +/** + * Check that zlib magic header is valid + * + * @v magic Magic header + * @ret is_valid Magic header is valid + */ +static inline int zlib_magic_is_valid ( union zlib_magic *magic ) { + + /* Check magic value as per RFC 6713 */ + return ( ( ( magic->cmf & 0x8f ) == 0x08 ) && + ( ( be16_to_cpu ( magic->check ) % 31 ) == 0 ) ); +} + +extern int zlib_deflate ( enum deflate_format format, struct deflate_chunk *in, + struct image *extracted ); + +extern struct image_type zlib_image_type __image_type ( PROBE_NORMAL ); + +#endif /* _IPXE_ZLIB_H */ diff --git a/src/include/mii.h b/src/include/mii.h index e2afef854..515ba224d 100644 --- a/src/include/mii.h +++ b/src/include/mii.h @@ -23,6 +23,8 @@ FILE_LICENCE ( GPL2_ONLY ); #define MII_EXPANSION 0x06 /* Expansion register */ #define MII_CTRL1000 0x09 /* 1000BASE-T control */ #define MII_STAT1000 0x0a /* 1000BASE-T status */ +#define MII_MMD_CTRL 0x0d /* MMD Access Control Register */ +#define MII_MMD_DATA 0x0e /* MMD Access Data Register */ #define MII_ESTATUS 0x0f /* Extended Status */ #define MII_DCOUNTER 0x12 /* Disconnect counter */ #define MII_FCSCOUNTER 0x13 /* False carrier counter */ diff --git a/src/include/readline/readline.h b/src/include/readline/readline.h index afafbbdf5..3caf28b47 100644 --- a/src/include/readline/readline.h +++ b/src/include/readline/readline.h @@ -51,7 +51,8 @@ struct readline_history { extern void history_free ( struct readline_history *history ); extern int readline_history ( const char *prompt, const char *prefill, - struct readline_history *history, char **line ); + struct readline_history *history, + unsigned long timeout, char **line ); extern char * __malloc readline ( const char *prompt ); #endif /* _READLINE_H */ diff --git a/src/include/stdio.h b/src/include/stdio.h index a618482ce..ac17da83d 100644 --- a/src/include/stdio.h +++ b/src/include/stdio.h @@ -6,7 +6,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <stdint.h> #include <stdarg.h> -extern void putchar ( int character ); +extern int putchar ( int character ); extern int getchar ( void ); diff --git a/src/include/strings.h b/src/include/strings.h index fab26dc28..d7e9d6971 100644 --- a/src/include/strings.h +++ b/src/include/strings.h @@ -189,5 +189,7 @@ bzero ( void *dest, size_t len ) { } int __pure strcasecmp ( const char *first, const char *second ) __nonnull; +int __pure strncasecmp ( const char *first, const char *second, + size_t max ) __nonnull; #endif /* _STRINGS_H */ diff --git a/src/include/usr/imgarchive.h b/src/include/usr/imgarchive.h new file mode 100644 index 000000000..bf0c18f55 --- /dev/null +++ b/src/include/usr/imgarchive.h @@ -0,0 +1,16 @@ +#ifndef _USR_IMGARCHIVE_H +#define _USR_IMGARCHIVE_H + +/** @file + * + * Archive image management + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include <ipxe/image.h> + +extern int imgextract ( struct image *image, const char *name ); + +#endif /* _USR_IMGARCHIVE_H */ |
