summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorSimon Rettberg2022-05-11 10:41:01 +0200
committerSimon Rettberg2022-05-11 10:41:01 +0200
commita12e3c379cf2e5946c7316259ef46736cdd5f222 (patch)
tree49638dad528a4490e293ea4a0f87e39ce862a75b /src/include/ipxe
parentLocal UEFI disk boot support (diff)
parent[cloud] Allow aws-import script to run on Python 3.6 (diff)
downloadipxe-a12e3c379cf2e5946c7316259ef46736cdd5f222.tar.gz
ipxe-a12e3c379cf2e5946c7316259ef46736cdd5f222.tar.xz
ipxe-a12e3c379cf2e5946c7316259ef46736cdd5f222.zip
Merge branch 'master' into openslx
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/acpi.h3
-rw-r--r--src/include/ipxe/efi/efi.h1
-rw-r--r--src/include/ipxe/efi/efi_wrap.h2
-rw-r--r--src/include/ipxe/errfile.h1
-rw-r--r--src/include/ipxe/fbcon.h7
-rw-r--r--src/include/ipxe/keymap.h57
-rw-r--r--src/include/ipxe/linux/linux_uaccess.h15
-rw-r--r--src/include/ipxe/sbat.h68
-rw-r--r--src/include/ipxe/settings.h1
-rw-r--r--src/include/ipxe/srp.h2
-rw-r--r--src/include/ipxe/tables.h27
-rw-r--r--src/include/ipxe/uri.h31
-rw-r--r--src/include/ipxe/utf8.h69
-rw-r--r--src/include/ipxe/virtio-pci.h8
-rw-r--r--src/include/ipxe/virtio-ring.h7
15 files changed, 280 insertions, 19 deletions
diff --git a/src/include/ipxe/acpi.h b/src/include/ipxe/acpi.h
index 7df3ec21c..c34681238 100644
--- a/src/include/ipxe/acpi.h
+++ b/src/include/ipxe/acpi.h
@@ -386,7 +386,10 @@ acpi_describe ( struct interface *interface );
#define acpi_describe_TYPE( object_type ) \
typeof ( struct acpi_descriptor * ( object_type ) )
+extern userptr_t ( * acpi_finder ) ( uint32_t signature, unsigned int index );
+
extern void acpi_fix_checksum ( struct acpi_header *acpi );
+extern userptr_t acpi_table ( uint32_t signature, unsigned int index );
extern int acpi_extract ( uint32_t signature, void *data,
int ( * extract ) ( userptr_t zsdt, size_t len,
size_t offset, void *data ) );
diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h
index a83fa0f27..1dd0d4453 100644
--- a/src/include/ipxe/efi/efi.h
+++ b/src/include/ipxe/efi/efi.h
@@ -223,6 +223,7 @@ extern EFI_HANDLE efi_image_handle;
extern EFI_LOADED_IMAGE_PROTOCOL *efi_loaded_image;
extern EFI_DEVICE_PATH_PROTOCOL *efi_loaded_image_path;
extern EFI_SYSTEM_TABLE *efi_systab;
+extern EFI_TPL efi_internal_tpl;
extern EFI_TPL efi_external_tpl;
extern int efi_shutdown_in_progress;
diff --git a/src/include/ipxe/efi/efi_wrap.h b/src/include/ipxe/efi/efi_wrap.h
index 6c7ccf2e4..2747a9e33 100644
--- a/src/include/ipxe/efi/efi_wrap.h
+++ b/src/include/ipxe/efi/efi_wrap.h
@@ -10,7 +10,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/efi/efi.h>
-extern EFI_SYSTEM_TABLE * efi_wrap_systab ( void );
+extern EFI_BOOT_SERVICES * efi_wrap_bs ( void );
extern void efi_wrap ( EFI_HANDLE handle );
#endif /* _IPXE_EFI_WRAP_H */
diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h
index 23e406b62..81f555725 100644
--- a/src/include/ipxe/errfile.h
+++ b/src/include/ipxe/errfile.h
@@ -395,6 +395,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define ERRFILE_efi_cachedhcp ( ERRFILE_OTHER | 0x00550000 )
#define ERRFILE_linux_sysfs ( ERRFILE_OTHER | 0x00560000 )
#define ERRFILE_linux_acpi ( ERRFILE_OTHER | 0x00570000 )
+#define ERRFILE_dynkeymap ( ERRFILE_OTHER | 0x00580000 )
/** @} */
diff --git a/src/include/ipxe/fbcon.h b/src/include/ipxe/fbcon.h
index 42ffca3d7..a4c7a9ab3 100644
--- a/src/include/ipxe/fbcon.h
+++ b/src/include/ipxe/fbcon.h
@@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <ipxe/ansiesc.h>
+#include <ipxe/utf8.h>
#include <ipxe/uaccess.h>
#include <ipxe/console.h>
@@ -36,7 +37,7 @@ struct fbcon_font {
/**
* Get character glyph
*
- * @v character Character
+ * @v character Unicode character
* @v glyph Character glyph to fill in
*/
void ( * glyph ) ( unsigned int character, uint8_t *glyph );
@@ -92,7 +93,7 @@ struct fbcon_text_cell {
uint32_t foreground;
/** Background colour */
uint32_t background;
- /** Character */
+ /** Unicode character */
unsigned int character;
};
@@ -138,6 +139,8 @@ struct fbcon {
unsigned int ypos;
/** ANSI escape sequence context */
struct ansiesc_context ctx;
+ /** UTF-8 accumulator */
+ struct utf8_accumulator utf8;
/** Text array */
struct fbcon_text text;
/** Background picture */
diff --git a/src/include/ipxe/keymap.h b/src/include/ipxe/keymap.h
index 0f1b0c656..8bfbe07a5 100644
--- a/src/include/ipxe/keymap.h
+++ b/src/include/ipxe/keymap.h
@@ -13,18 +13,67 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <ipxe/tables.h>
-/** A keyboard mapping */
-struct key_mapping {
+/** A remapped key
+ *
+ * Represents a mapping from an ASCII character (as interpreted from a
+ * keyboard scancode by the US-only keyboard driver provided by the
+ * BIOS) to the appropriate ASCII value for the keyboard layout.
+ */
+struct keymap_key {
/** Character read from keyboard */
uint8_t from;
/** Character to be used instead */
uint8_t to;
} __attribute__ (( packed ));
+/** A keyboard mapping */
+struct keymap {
+ /** Name */
+ const char *name;
+ /** Basic remapping table (zero-terminated) */
+ struct keymap_key *basic;
+ /** AltGr remapping table (zero-terminated) */
+ struct keymap_key *altgr;
+};
+
/** Keyboard mapping table */
-#define KEYMAP __table ( struct key_mapping, "keymap" )
+#define KEYMAP __table ( struct keymap, "keymap" )
+
+/** Define a default keyboard mapping */
+#define __keymap_default __table_entry ( KEYMAP, 01 )
/** Define a keyboard mapping */
-#define __keymap __table_entry ( KEYMAP, 01 )
+#define __keymap __table_entry ( KEYMAP, 02 )
+
+/** Mappable character mask */
+#define KEYMAP_MASK 0xff
+
+/** Pseudo key flag */
+#define KEYMAP_PSEUDO 0x80
+
+/** Ctrl key flag */
+#define KEYMAP_CTRL 0x0100
+
+/** CapsLock key flag */
+#define KEYMAP_CAPSLOCK 0x0200
+
+/** Undo CapsLock key flag
+ *
+ * Used when the keyboard driver has already interpreted the CapsLock
+ * key, in which case the effect needs to be undone before remapping
+ * in order to correctly handle keyboard mappings that swap alphabetic
+ * and non-alphabetic keys.
+ */
+#define KEYMAP_CAPSLOCK_UNDO 0x0400
+
+/** Undo and redo CapsLock key flags */
+#define KEYMAP_CAPSLOCK_REDO ( KEYMAP_CAPSLOCK | KEYMAP_CAPSLOCK_UNDO )
+
+/** AltGr key flag */
+#define KEYMAP_ALTGR 0x0800
+
+extern unsigned int key_remap ( unsigned int character );
+extern struct keymap * keymap_find ( const char *name );
+extern void keymap_set ( struct keymap *keymap );
#endif /* _IPXE_KEYMAP_H */
diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h
index acd919a85..a642b6163 100644
--- a/src/include/ipxe/linux/linux_uaccess.h
+++ b/src/include/ipxe/linux/linux_uaccess.h
@@ -25,7 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#endif
/**
- * Convert user buffer to physical address
+ * Convert user pointer to physical address
*
* @v userptr User pointer
* @v offset Offset from user pointer
@@ -46,6 +46,19 @@ UACCESS_INLINE ( linux, user_to_phys ) ( userptr_t userptr, off_t offset ) {
return ( userptr + offset );
}
+/**
+ * Convert physical address to user pointer
+ *
+ * @v phys_addr Physical address
+ * @ret userptr User pointer
+ */
+static inline __always_inline userptr_t
+UACCESS_INLINE ( linux, phys_to_user ) ( physaddr_t phys_addr ) {
+
+ /* For symmetry with the stub user_to_phys() */
+ return phys_addr;
+}
+
static inline __always_inline userptr_t
UACCESS_INLINE ( linux, virt_to_user ) ( volatile const void *addr ) {
return trivial_virt_to_user ( addr );
diff --git a/src/include/ipxe/sbat.h b/src/include/ipxe/sbat.h
new file mode 100644
index 000000000..4b74670ed
--- /dev/null
+++ b/src/include/ipxe/sbat.h
@@ -0,0 +1,68 @@
+#ifndef _IPXE_SBAT_H
+#define _IPXE_SBAT_H
+
+/** @file
+ *
+ * Secure Boot Advanced Targeting (SBAT)
+ *
+ * SBAT defines an encoding for security generation numbers stored as
+ * a CSV file within a special ".sbat" section in the signed binary.
+ * If a Secure Boot exploit is discovered then the generation number
+ * will be incremented alongside the corresponding fix.
+ *
+ * Platforms may then record the minimum generation number required
+ * for any given product. This allows for an efficient revocation
+ * mechanism that consumes minimal flash storage space (in contrast to
+ * the DBX mechanism, which allows for only a single-digit number of
+ * revocation events to ever take place across all possible signed
+ * binaries).
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+/**
+ * A single line within an SBAT CSV file
+ *
+ * @v name Machine-readable component name
+ * @v generation Security generation number
+ * @v vendor Human-readable vendor name
+ * @v package Human-readable package name
+ * @v version Human-readable package version
+ * @v uri Contact URI
+ * @ret line CSV line
+ */
+#define SBAT_LINE( name, generation, vendor, package, version, uri ) \
+ name "," _S2 ( generation ) "," vendor "," package "," \
+ version "," uri "\n"
+
+/** SBAT format generation */
+#define SBAT_GENERATION 1
+
+/** Upstream security generation
+ *
+ * This represents the security generation of the upstream codebase.
+ * It will be incremented whenever a Secure Boot exploit is fixed in
+ * the upstream codebase.
+ *
+ * If you do not have commit access to the upstream iPXE repository,
+ * then you may not modify this value under any circumstances.
+ */
+#define IPXE_SBAT_GENERATION 1
+
+/* Seriously, do not modify this value */
+#if IPXE_SBAT_GENERATION != 1
+#error "You may not modify IPXE_SBAT_GENERATION"
+#endif
+
+/** SBAT header line */
+#define SBAT_HEADER \
+ SBAT_LINE ( "sbat", SBAT_GENERATION, "SBAT Version", "sbat", \
+ _S2 ( SBAT_GENERATION ), \
+ "https://github.com/rhboot/shim/blob/main/SBAT.md" )
+
+/** Mark variable as being in the ".sbat" section */
+#define __sbat __attribute__ (( section ( ".sbat" ), aligned ( 512 ) ))
+
+extern const char sbat[] __sbat;
+
+#endif /* _IPXE_SBAT_H */
diff --git a/src/include/ipxe/settings.h b/src/include/ipxe/settings.h
index 2bffe2fba..9759a600f 100644
--- a/src/include/ipxe/settings.h
+++ b/src/include/ipxe/settings.h
@@ -427,6 +427,7 @@ extern const struct setting_type setting_type_hexraw __setting_type;
extern const struct setting_type setting_type_md5 __setting_type;
extern const struct setting_type setting_type_base64 __setting_type;
extern const struct setting_type setting_type_uuid __setting_type;
+extern const struct setting_type setting_type_guid __setting_type;
extern const struct setting_type setting_type_busdevfn __setting_type;
extern const struct setting_type setting_type_dnssl __setting_type;
diff --git a/src/include/ipxe/srp.h b/src/include/ipxe/srp.h
index 3abb0995f..1f66a22b2 100644
--- a/src/include/ipxe/srp.h
+++ b/src/include/ipxe/srp.h
@@ -774,7 +774,7 @@ struct srp_aer_rsp {
* The working draft specification for the SRP boot firmware table can
* be found at
*
- * http://ipxe.org/wiki/srp/sbft
+ * https://ipxe.org/wiki/srp/sbft
*
*****************************************************************************
*/
diff --git a/src/include/ipxe/tables.h b/src/include/ipxe/tables.h
index 28a87da96..de5b1f297 100644
--- a/src/include/ipxe/tables.h
+++ b/src/include/ipxe/tables.h
@@ -253,6 +253,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
__table_entries; } )
/**
+ * Declare start of linker table entries
+ *
+ * @v entries Start of entries
+ * @v table Linker table
+ * @v idx Sub-table index
+ */
+#define __TABLE_ENTRIES( entries, table, idx ) \
+ __table_type ( table ) entries[0] \
+ __table_entry ( table, idx )
+
+/**
* Get start of linker table
*
* @v table Linker table
@@ -271,6 +282,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define table_start( table ) __table_entries ( table, 00 )
/**
+ * Declare start of linker table
+ *
+ * @v start Start of linker table
+ * @v table Linker table
+ */
+#define TABLE_START( start, table ) __TABLE_ENTRIES ( start, table, 00 )
+
+/**
* Get end of linker table
*
* @v table Linker table
@@ -289,6 +308,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define table_end( table ) __table_entries ( table, 99 )
/**
+ * Declare end of linker table
+ *
+ * @v end End of linker table
+ * @v table Linker table
+ */
+#define TABLE_END( end, table ) __TABLE_ENTRIES ( end, table, 99 )
+
+/**
* Get number of entries in linker table
*
* @v table Linker table
diff --git a/src/include/ipxe/uri.h b/src/include/ipxe/uri.h
index 3879a0e73..e5b7c8616 100644
--- a/src/include/ipxe/uri.h
+++ b/src/include/ipxe/uri.h
@@ -46,6 +46,20 @@ struct parameters;
* scheme = "ftp", user = "joe", password = "secret",
* host = "insecure.org", port = "8081", path = "/hidden/path/to",
* query = "what=is", fragment = "this"
+ *
+ * The URI syntax includes a percent-encoding mechanism that can be
+ * used to represent characters that would otherwise not be possible,
+ * such as a '/' character within the password field. These encodings
+ * are decoded during the URI parsing stage, thereby allowing protocol
+ * implementations to consume the raw field values directly without
+ * further decoding.
+ *
+ * Some protocols (such as HTTP) communicate using URI-encoded values.
+ * For these protocols, the original encoded substring must be
+ * retained verbatim since the choice of whether or not to encode a
+ * particular character may have significance to the receiving
+ * application. We therefore retain the originally-encoded substrings
+ * for the path, query, and fragment fields.
*/
struct uri {
/** Reference count */
@@ -62,12 +76,14 @@ struct uri {
const char *host;
/** Port number */
const char *port;
- /** Path */
+ /** Path (after URI decoding) */
const char *path;
- /** Query */
- const char *query;
- /** Fragment */
- const char *fragment;
+ /** Path (with original URI encoding) */
+ const char *epath;
+ /** Query (with original URI encoding) */
+ const char *equery;
+ /** Fragment (with original URI encoding) */
+ const char *efragment;
/** Form parameters */
struct parameters *params;
} __attribute__ (( packed ));
@@ -100,8 +116,9 @@ enum uri_fields {
URI_HOST = URI_FIELD ( host ),
URI_PORT = URI_FIELD ( port ),
URI_PATH = URI_FIELD ( path ),
- URI_QUERY = URI_FIELD ( query ),
- URI_FRAGMENT = URI_FIELD ( fragment ),
+ URI_EPATH = URI_FIELD ( epath ),
+ URI_EQUERY = URI_FIELD ( equery ),
+ URI_EFRAGMENT = URI_FIELD ( efragment ),
URI_FIELDS
};
diff --git a/src/include/ipxe/utf8.h b/src/include/ipxe/utf8.h
new file mode 100644
index 000000000..299c25511
--- /dev/null
+++ b/src/include/ipxe/utf8.h
@@ -0,0 +1,69 @@
+#ifndef _IPXE_UTF8_H
+#define _IPXE_UTF8_H
+
+/** @file
+ *
+ * UTF-8 Unicode encoding
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <stdint.h>
+
+/** Maximum length of UTF-8 sequence */
+#define UTF8_MAX_LEN 4
+
+/** Minimum legal value for two-byte UTF-8 sequence */
+#define UTF8_MIN_TWO 0x80
+
+/** Minimum legal value for three-byte UTF-8 sequence */
+#define UTF8_MIN_THREE 0x800
+
+/** Minimum legal value for four-byte UTF-8 sequence */
+#define UTF8_MIN_FOUR 0x10000
+
+/** High bit of UTF-8 bytes */
+#define UTF8_HIGH_BIT 0x80
+
+/** Number of data bits in each continuation byte */
+#define UTF8_CONTINUATION_BITS 6
+
+/** Bit mask for data bits in a continuation byte */
+#define UTF8_CONTINUATION_MASK ( ( 1 << UTF8_CONTINUATION_BITS ) - 1 )
+
+/** Non-data bits in a continuation byte */
+#define UTF8_CONTINUATION 0x80
+
+/** Check for a continuation byte
+ *
+ * @v byte UTF-8 byte
+ * @ret is_continuation Byte is a continuation byte
+ */
+#define UTF8_IS_CONTINUATION( byte ) \
+ ( ( (byte) & ~UTF8_CONTINUATION_MASK ) == UTF8_CONTINUATION )
+
+/** Check for an ASCII byte
+ *
+ * @v byte UTF-8 byte
+ * @ret is_ascii Byte is an ASCII byte
+ */
+#define UTF8_IS_ASCII( byte ) ( ! ( (byte) & UTF8_HIGH_BIT ) )
+
+/** Invalid character returned when decoding fails */
+#define UTF8_INVALID 0xfffd
+
+/** A UTF-8 character accumulator */
+struct utf8_accumulator {
+ /** Character in progress */
+ unsigned int character;
+ /** Number of remaining continuation bytes */
+ unsigned int remaining;
+ /** Minimum legal character */
+ unsigned int min;
+};
+
+extern unsigned int utf8_accumulate ( struct utf8_accumulator *utf8,
+ uint8_t byte );
+
+#endif /* _IPXE_UTF8_H */
diff --git a/src/include/ipxe/virtio-pci.h b/src/include/ipxe/virtio-pci.h
index f3074f14d..7abae26ff 100644
--- a/src/include/ipxe/virtio-pci.h
+++ b/src/include/ipxe/virtio-pci.h
@@ -1,6 +1,8 @@
#ifndef _VIRTIO_PCI_H_
# define _VIRTIO_PCI_H_
+#include <ipxe/dma.h>
+
/* A 32-bit r/o bitmask of the features supported by the host */
#define VIRTIO_PCI_HOST_FEATURES 0
@@ -198,7 +200,8 @@ struct vring_virtqueue;
void vp_free_vq(struct vring_virtqueue *vq);
int vp_find_vq(unsigned int ioaddr, int queue_index,
- struct vring_virtqueue *vq);
+ struct vring_virtqueue *vq, struct dma_device *dma_dev,
+ size_t header_size);
/* Virtio 1.0 I/O routines abstract away the three possible HW access
@@ -298,7 +301,8 @@ void vpm_notify(struct virtio_pci_modern_device *vdev,
struct vring_virtqueue *vq);
int vpm_find_vqs(struct virtio_pci_modern_device *vdev,
- unsigned nvqs, struct vring_virtqueue *vqs);
+ unsigned nvqs, struct vring_virtqueue *vqs,
+ struct dma_device *dma_dev, size_t header_size);
int virtio_pci_find_capability(struct pci_device *pci, uint8_t cfg_type);
diff --git a/src/include/ipxe/virtio-ring.h b/src/include/ipxe/virtio-ring.h
index 852769f29..d082139e9 100644
--- a/src/include/ipxe/virtio-ring.h
+++ b/src/include/ipxe/virtio-ring.h
@@ -2,6 +2,7 @@
# define _VIRTIO_RING_H_
#include <ipxe/virtio-pci.h>
+#include <ipxe/dma.h>
/* Status byte for guest to report progress, and synchronize features. */
/* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
@@ -74,17 +75,21 @@ struct vring {
struct vring_virtqueue {
unsigned char *queue;
+ size_t queue_size;
+ struct dma_mapping map;
+ struct dma_device *dma;
struct vring vring;
u16 free_head;
u16 last_used_idx;
void **vdata;
+ struct virtio_net_hdr_modern *empty_header;
/* PCI */
int queue_index;
struct virtio_pci_region notification;
};
struct vring_list {
- char *addr;
+ physaddr_t addr;
unsigned int length;
};