diff options
Diffstat (limited to 'payloads/libpayload')
22 files changed, 103 insertions, 73 deletions
diff --git a/payloads/libpayload/arch/arm/gdb.c b/payloads/libpayload/arch/arm/gdb.c index 7a3d9642fd..830382e8fa 100644 --- a/payloads/libpayload/arch/arm/gdb.c +++ b/payloads/libpayload/arch/arm/gdb.c @@ -22,10 +22,10 @@ struct gdb_regs struct fp_reg { u8 byte[12]; - } __attribute__((packed)) f[8]; + } __packed f[8]; u32 fps; u32 cpsr; -} __attribute__((packed)); +} __packed; static const u8 type_to_signal[] = { [EXC_UNDEF] = GDB_SIGILL, diff --git a/payloads/libpayload/arch/arm64/gdb.c b/payloads/libpayload/arch/arm64/gdb.c index e51a2e7942..166c9ffb13 100644 --- a/payloads/libpayload/arch/arm64/gdb.c +++ b/payloads/libpayload/arch/arm64/gdb.c @@ -22,11 +22,11 @@ struct gdb_regs struct fp_reg { u64 quad[2]; - } __attribute__((packed)) f[32]; + } __packed f[32]; u32 fpcr; u32 fpsr; u32 spsr; -} __attribute__((packed)); +} __packed; static const u8 type_to_signal[] = { [EXC_SYNC_SP0] = GDB_SIGTRAP, diff --git a/payloads/libpayload/drivers/cbmem_console.c b/payloads/libpayload/drivers/cbmem_console.c index 76c2abb74d..9435e1ca9f 100644 --- a/payloads/libpayload/drivers/cbmem_console.c +++ b/payloads/libpayload/drivers/cbmem_console.c @@ -34,7 +34,7 @@ struct cbmem_console { uint32_t size; uint32_t cursor; uint8_t body[0]; -} __attribute__ ((__packed__)); +} __packed; #define CURSOR_MASK ((1 << 28) - 1) #define OVERFLOW (1 << 31) diff --git a/payloads/libpayload/drivers/usb/ehci_private.h b/payloads/libpayload/drivers/usb/ehci_private.h index 46ad551289..ac845e6153 100644 --- a/payloads/libpayload/drivers/usb/ehci_private.h +++ b/payloads/libpayload/drivers/usb/ehci_private.h @@ -55,7 +55,7 @@ typedef volatile struct { u32 hcsparams; u32 hccparams; u64 hcsp_portroute; -} __attribute__ ((packed)) hc_cap_t; +} __packed hc_cap_t; typedef volatile struct { u32 usbcmd; @@ -83,7 +83,7 @@ typedef volatile struct { u8 res2[0x40]; u32 hostpc; /* hostpc register is used for CONFIG_LP_USB_EHCI_HOSTPC_ROOT_HUB_TT */ -} __attribute__ ((packed)) hc_op_t; +} __packed hc_op_t; typedef volatile struct { #define QTD_TERMINATE 1 @@ -108,7 +108,7 @@ typedef volatile struct { #define QTD_TOGGLE_DATA1 (1 << QTD_TOGGLE_SHIFT) u32 bufptrs[5]; u32 bufptrs64[5]; -} __attribute__ ((packed)) qtd_t; +} __packed qtd_t; typedef volatile struct { u32 horiz_link_ptr; @@ -132,7 +132,7 @@ typedef volatile struct { #define QH_PIPE_MULTIPLIER_SHIFT 30 volatile u32 current_td_ptr; volatile qtd_t td; -} __attribute__ ((packed)) ehci_qh_t; +} __packed ehci_qh_t; typedef struct ehci { hc_cap_t *capabilities; diff --git a/payloads/libpayload/drivers/usb/ohci_private.h b/payloads/libpayload/drivers/usb/ohci_private.h index 58be5fa5bb..116a2b4ec6 100644 --- a/payloads/libpayload/drivers/usb/ohci_private.h +++ b/payloads/libpayload/drivers/usb/ohci_private.h @@ -186,7 +186,7 @@ _DO NOT_ use |= to set the bits, this clears the entire state */ volatile u32 HcRhPortStatus[]; - } __attribute__ ((packed)) opreg_t; + } __packed opreg_t; typedef struct { /* should be 256 bytes according to spec */ u32 HccaInterruptTable[32]; @@ -195,14 +195,14 @@ volatile u32 HccaDoneHead; u8 reserved[116]; /* pad according to spec */ u8 what[4]; /* really pad to 256 as spec only covers 252 */ - } __attribute__ ((packed)) hcca_t; + } __packed hcca_t; typedef volatile struct { u32 config; u32 tail_pointer; u32 head_pointer; u32 next_ed; - } __attribute__ ((packed)) ed_t; + } __packed ed_t; #define ED_HALTED 1 #define ED_TOGGLE 2 @@ -220,7 +220,7 @@ u32 current_buffer_pointer; u32 next_td; u32 buffer_end; - } __attribute__ ((packed)) td_t; + } __packed td_t; /* * Bits 0 through 17 of .config won't be interpreted by the host controller * (HC) and, after processing the TD, the HC has to ensure those bits have diff --git a/payloads/libpayload/drivers/usb/uhci_private.h b/payloads/libpayload/drivers/usb/uhci_private.h index 3d796cfe19..e5114ae046 100644 --- a/payloads/libpayload/drivers/usb/uhci_private.h +++ b/payloads/libpayload/drivers/usb/uhci_private.h @@ -67,13 +67,13 @@ typedef struct { u32 bufptr; -} __attribute__ ((packed)) +} __packed td_t; typedef struct { flistp_t headlinkptr; volatile flistp_t elementlinkptr; - } __attribute__ ((packed)) + } __packed qh_t; typedef enum { USBCMD = 0, USBSTS = 2, USBINTR = 4, FRNUM = diff --git a/payloads/libpayload/drivers/usb/usbmsc.c b/payloads/libpayload/drivers/usb/usbmsc.c index 17313cf88e..2c7cbe5ef2 100644 --- a/payloads/libpayload/drivers/usb/usbmsc.c +++ b/payloads/libpayload/drivers/usb/usbmsc.c @@ -112,14 +112,14 @@ typedef struct { unsigned long bCBWCBLength:5; unsigned long:3; unsigned char CBWCB[31 - 15]; -} __attribute__ ((packed)) cbw_t; +} __packed cbw_t; typedef struct { unsigned int dCSWSignature; unsigned int dCSWTag; unsigned int dCSWDataResidue; unsigned char bCSWStatus; -} __attribute__ ((packed)) csw_t; +} __packed csw_t; enum { /* @@ -297,7 +297,7 @@ typedef struct { unsigned char res2; //6 unsigned short numblocks; //7-8 unsigned char control; //9 - the block is 10 bytes long -} __attribute__ ((packed)) cmdblock_t; +} __packed cmdblock_t; typedef struct { unsigned char command; //0 @@ -312,7 +312,7 @@ typedef struct { unsigned char length; // for REQUEST SENSE }; unsigned char control; //5 -} __attribute__ ((packed)) cmdblock6_t; +} __packed cmdblock6_t; /** * Like readwrite_blocks, but for soft-sectors of 512b size. Converts the diff --git a/payloads/libpayload/drivers/usb/xhci_private.h b/payloads/libpayload/drivers/usb/xhci_private.h index a6dcc847b0..14d0e89c2e 100644 --- a/payloads/libpayload/drivers/usb/xhci_private.h +++ b/payloads/libpayload/drivers/usb/xhci_private.h @@ -165,7 +165,7 @@ typedef struct { trb_t *ring; trb_t *cur; u8 pcs; -} __attribute__ ((packed)) transfer_ring_t; +} __packed transfer_ring_t; #define COMMAND_RING_SIZE 4 typedef transfer_ring_t command_ring_t; @@ -332,8 +332,8 @@ typedef struct xhci { struct { u8 hciver_lo; u8 hciver_hi; - } __attribute__ ((packed)); - } __attribute__ ((packed)); + } __packed; + } __packed; union { u32 hcsparams1; struct { @@ -341,8 +341,8 @@ typedef struct xhci { unsigned long MaxIntrs:11; unsigned long:6; unsigned long MaxPorts:8; - } __attribute__ ((packed)); - } __attribute__ ((packed)); + } __packed; + } __packed; union { u32 hcsparams2; struct { @@ -352,16 +352,16 @@ typedef struct xhci { unsigned long Max_Scratchpad_Bufs_Hi:5; unsigned long SPR:1; unsigned long Max_Scratchpad_Bufs_Lo:5; - } __attribute__ ((packed)); - } __attribute__ ((packed)); + } __packed; + } __packed; union { u32 hcsparams3; struct { unsigned long u1latency:8; unsigned long:8; unsigned long u2latency:16; - } __attribute__ ((packed)); - } __attribute__ ((packed)); + } __packed; + } __packed; union { u32 hccparams; struct { @@ -376,11 +376,11 @@ typedef struct xhci { unsigned long:4; unsigned long MaxPSASize:4; unsigned long xECP:16; - } __attribute__ ((packed)); - } __attribute__ ((packed)); + } __packed; + } __packed; u32 dboff; u32 rtsoff; - } __attribute__ ((packed)) *capreg; + } __packed *capreg; /* opreg is R/W is most places, so volatile access is necessary. volatile means that the compiler seeks byte writes if possible, @@ -446,8 +446,8 @@ typedef struct xhci { u32 portpmsc; u32 portli; u32 res; - } __attribute__ ((packed)) prs[]; - } __attribute__ ((packed)) *opreg; + } __packed prs[]; + } __packed *opreg; /* R/W, volatile, MMIO -> no bitfields */ volatile struct hcrreg { @@ -462,8 +462,8 @@ typedef struct xhci { u32 erstba_hi; u32 erdp_lo; u32 erdp_hi; - } __attribute__ ((packed)) intrrs[]; // up to 1024, but maximum host specific, given in capreg->MaxIntrs - } __attribute__ ((packed)) *hcrreg; + } __packed intrrs[]; // up to 1024, but maximum host specific, given in capreg->MaxIntrs + } __packed *hcrreg; /* R/W, volatile, MMIO -> no bitfields */ volatile u32 *dbreg; diff --git a/payloads/libpayload/drivers/video/bitmap.h b/payloads/libpayload/drivers/video/bitmap.h index 7670097411..a41a2c8233 100644 --- a/payloads/libpayload/drivers/video/bitmap.h +++ b/payloads/libpayload/drivers/video/bitmap.h @@ -37,7 +37,7 @@ struct bitmap_file_header { uint32_t file_size; uint16_t reserved[2]; uint32_t bitmap_offset; -} __attribute__ ((__packed__)); +} __packed; /* Bitmap version 3 */ @@ -53,13 +53,13 @@ struct bitmap_header_v3 { int32_t v_res; uint32_t colors_used; uint32_t colors_important; -} __attribute__ ((__packed__)); +} __packed; struct bitmap_palette_element_v3 { uint8_t blue; uint8_t green; uint8_t red; uint8_t reserved; -} __attribute__ ((__packed__)); +} __packed; #endif /* __BITMAP_H__ */ diff --git a/payloads/libpayload/include/arm/arch/exception.h b/payloads/libpayload/include/arm/arch/exception.h index fbbce5ed3d..9a631e4614 100644 --- a/payloads/libpayload/include/arm/arch/exception.h +++ b/payloads/libpayload/include/arm/arch/exception.h @@ -39,7 +39,7 @@ struct exception_state { u32 regs[16]; u32 cpsr; -} __attribute__((packed)); +} __packed; extern struct exception_state exception_state; extern u32 exception_stack[]; diff --git a/payloads/libpayload/include/arm64/arch/exception.h b/payloads/libpayload/include/arm64/arch/exception.h index f5026f8402..8afe39103b 100644 --- a/payloads/libpayload/include/arm64/arch/exception.h +++ b/payloads/libpayload/include/arm64/arch/exception.h @@ -39,7 +39,7 @@ struct exception_state uint64_t elr; uint64_t esr; uint64_t regs[31]; -} __attribute__((packed)); +} __packed; extern struct exception_state *exception_state; diff --git a/payloads/libpayload/include/cbfs_core.h b/payloads/libpayload/include/cbfs_core.h index f45139e9aa..1f155df0ca 100644 --- a/payloads/libpayload/include/cbfs_core.h +++ b/payloads/libpayload/include/cbfs_core.h @@ -50,6 +50,7 @@ #include <stddef.h> #include <stdint.h> #include <stdlib.h> +#include <compiler.h> /** These are standard values for the known compression alogrithms that coreboot knows about for stages and @@ -97,7 +98,7 @@ struct cbfs_header { uint32_t offset; uint32_t architecture; uint32_t pad[1]; -} __attribute__((packed)); +} __packed; /* this used to be flexible, but wasn't ever set to something different. */ #define CBFS_ALIGNMENT 64 @@ -134,7 +135,7 @@ struct cbfs_file { uint32_t attributes_offset; uint32_t offset; char filename[]; -} __attribute__((packed)); +} __packed; /* Depending on how the header was initialized, it may be backed with 0x00 or * 0xff. Support both. */ @@ -151,7 +152,7 @@ struct cbfs_file_attribute { /* len covers the whole structure, incl. tag and len */ uint32_t len; uint8_t data[0]; -} __attribute__((packed)); +} __packed; struct cbfs_file_attr_compression { uint32_t tag; @@ -159,7 +160,7 @@ struct cbfs_file_attr_compression { /* whole file compression format. 0 if no compression. */ uint32_t compression; uint32_t decompressed_size; -} __attribute__((packed)); +} __packed; struct cbfs_file_attr_hash { uint32_t tag; @@ -167,7 +168,7 @@ struct cbfs_file_attr_hash { uint32_t hash_type; /* hash_data is len - sizeof(struct) bytes */ uint8_t hash_data[]; -} __PACKED; +} __packed; /*** Component sub-headers ***/ @@ -183,7 +184,7 @@ struct cbfs_stage { uint64_t load; /** Where to load in memory */ uint32_t len; /** length of data to load */ uint32_t memlen; /** total length of object in memory */ -} __attribute__((packed)); +} __packed; /** this is the sub-header for payload components. Payloads are loaded by coreboot at the end of the boot process */ @@ -195,7 +196,7 @@ struct cbfs_payload_segment { uint64_t load_addr; uint32_t len; uint32_t mem_len; -} __attribute__((packed)); +} __packed; struct cbfs_payload { struct cbfs_payload_segment segments; @@ -210,7 +211,7 @@ struct cbfs_payload { struct cbfs_optionrom { uint32_t compression; uint32_t len; -} __attribute__((packed)); +} __packed; #define CBFS_MEDIA_INVALID_MAP_ADDRESS ((void*)(0xffffffff)) #define CBFS_DEFAULT_MEDIA ((void*)(0x0)) diff --git a/payloads/libpayload/include/compiler.h b/payloads/libpayload/include/compiler.h new file mode 100644 index 0000000000..f218725086 --- /dev/null +++ b/payloads/libpayload/include/compiler.h @@ -0,0 +1,28 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2017 Google Inc. + * + * 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; version 2 of the License. + * + * 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. + */ + +#ifndef __COMPILER_H__ +#define __COMPILER_H__ + +#if defined(__WIN32) || defined(__WIN64) +#define __packed __attribute__((gcc_struct, packed)) +#else +#define __packed __attribute__((packed)) +#endif + +#define __aligned(x) __attribute__((aligned(x))) +#define __always_unused __attribute__((unused)) + +#endif diff --git a/payloads/libpayload/include/fmap_serialized.h b/payloads/libpayload/include/fmap_serialized.h index 3585f0bc84..1e83760442 100644 --- a/payloads/libpayload/include/fmap_serialized.h +++ b/payloads/libpayload/include/fmap_serialized.h @@ -56,7 +56,7 @@ struct fmap_area { uint32_t size; /* size in bytes */ uint8_t name[FMAP_STRLEN]; /* descriptive name */ uint16_t flags; /* flags for this area */ -} __attribute__((packed)); +} __packed; struct fmap { uint8_t signature[8]; /* "__FMAP__" (0x5F5F464D41505F5F) */ @@ -68,6 +68,6 @@ struct fmap { uint16_t nareas; /* number of areas described by fmap_areas[] below */ struct fmap_area areas[]; -} __attribute__((packed)); +} __packed; #endif /* FLASHMAP_SERIALIZED_H__ */ diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h index 54e01623a1..83658d15b4 100644 --- a/payloads/libpayload/include/libpayload.h +++ b/payloads/libpayload/include/libpayload.h @@ -44,6 +44,7 @@ #define _LIBPAYLOAD_H #include <libpayload-config.h> +#include <compiler.h> #include <cbgfx.h> #include <ctype.h> #include <die.h> @@ -361,7 +362,7 @@ long long int llabs(long long int j); u8 bin2hex(u8 b); u8 hex2bin(u8 h); void hexdump(const void *memory, size_t length); -void fatal(const char *msg) __attribute__ ((noreturn)); +void fatal(const char *msg) __attribute__((noreturn)); /* Count Leading Zeroes: clz(0) == 32, clz(0xf) == 28, clz(1 << 31) == 0 */ static inline int clz(u32 x) { return x ? __builtin_clz(x) : sizeof(x) * 8; } diff --git a/payloads/libpayload/include/mips/arch/exception.h b/payloads/libpayload/include/mips/arch/exception.h index 6af5f8e793..27f0b6417b 100644 --- a/payloads/libpayload/include/mips/arch/exception.h +++ b/payloads/libpayload/include/mips/arch/exception.h @@ -70,7 +70,7 @@ struct exception_state_t { u32 ra; } regs; u32 vector; -} __attribute__((packed)); +} __packed; extern struct exception_state_t *exception_state_ptr; extern u32 *exception_stack_end; diff --git a/payloads/libpayload/include/stdio.h b/payloads/libpayload/include/stdio.h index d2db640118..431042c1ee 100644 --- a/payloads/libpayload/include/stdio.h +++ b/payloads/libpayload/include/stdio.h @@ -43,13 +43,13 @@ extern FILE *stdout, *stdin, *stderr; * @{ */ int snprintf(char *str, size_t size, const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); + __attribute__((format (printf, 3, 4))); int sprintf(char *str, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); + __attribute__((format (printf, 2, 3))); int printf(const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); + __attribute__((format (printf, 1, 2))); int fprintf(FILE *file, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); + __attribute__((format (printf, 2, 3))); /** @} */ void perror(const char *s); diff --git a/payloads/libpayload/include/stdlib.h b/payloads/libpayload/include/stdlib.h index 689bf01b68..658fe610d0 100644 --- a/payloads/libpayload/include/stdlib.h +++ b/payloads/libpayload/include/stdlib.h @@ -214,8 +214,8 @@ void srand(unsigned int seed); /** * Stop execution and halt the processor (this function does not return). */ -void halt(void) __attribute__ ((noreturn)); -void exit(int status) __attribute__ ((noreturn)); +void halt(void) __attribute__((noreturn)); +void exit(int status) __attribute__((noreturn)); #define abort() halt() /**< Alias for the halt() function */ #if IS_ENABLED(CONFIG_LP_REMOTEGDB) /* Override abort()/halt() to trap into GDB if it is enabled. */ diff --git a/payloads/libpayload/include/usb/usb.h b/payloads/libpayload/include/usb/usb.h index e93a11e616..ef1892661c 100644 --- a/payloads/libpayload/include/usb/usb.h +++ b/payloads/libpayload/include/usb/usb.h @@ -83,13 +83,13 @@ typedef struct { unsigned long ttThinkTime:2; unsigned long arePortIndicatorsSupported:1; unsigned long:8; - } __attribute__ ((packed)); + } __packed; unsigned short wHubCharacteristics; - } __attribute__ ((packed)); + } __packed; unsigned char bPowerOn2PwrGood; unsigned char bHubContrCurrent; char DeviceRemovable[]; -} __attribute__ ((packed)) hub_descriptor_t; +} __packed hub_descriptor_t; typedef struct { unsigned char bLength; @@ -106,7 +106,7 @@ typedef struct { unsigned char iProduct; unsigned char iSerialNumber; unsigned char bNumConfigurations; -} __attribute__ ((packed)) device_descriptor_t; +} __packed device_descriptor_t; typedef struct { unsigned char bLength; @@ -117,7 +117,7 @@ typedef struct { unsigned char iConfiguration; unsigned char bmAttributes; unsigned char bMaxPower; -} __attribute__ ((packed)) configuration_descriptor_t; +} __packed configuration_descriptor_t; typedef struct { unsigned char bLength; @@ -129,7 +129,7 @@ typedef struct { unsigned char bInterfaceSubClass; unsigned char bInterfaceProtocol; unsigned char iInterface; -} __attribute__ ((packed)) interface_descriptor_t; +} __packed interface_descriptor_t; typedef struct { unsigned char bLength; @@ -138,7 +138,7 @@ typedef struct { unsigned char bmAttributes; unsigned short wMaxPacketSize; unsigned char bInterval; -} __attribute__ ((packed)) endpoint_descriptor_t; +} __packed endpoint_descriptor_t; typedef struct { unsigned char bLength; @@ -148,7 +148,7 @@ typedef struct { unsigned char bNumDescriptors; unsigned char bReportDescriptorType; unsigned short wReportDescriptorLength; -} __attribute__ ((packed)) hid_descriptor_t; +} __packed hid_descriptor_t; typedef struct { union { @@ -156,14 +156,14 @@ typedef struct { dev_req_recp req_recp:5; dev_req_type req_type:2; dev_req_dir data_dir:1; - } __attribute__ ((packed)); + } __packed; unsigned char bmRequestType; - } __attribute__ ((packed)); + } __packed; unsigned char bRequest; unsigned short wValue; unsigned short wIndex; unsigned short wLength; -} __attribute__ ((packed)) dev_req_t; +} __packed dev_req_t; struct usbdev_hc; typedef struct usbdev_hc hci_t; diff --git a/payloads/libpayload/include/x86/arch/exception.h b/payloads/libpayload/include/x86/arch/exception.h index fe222aa4f2..8acdb09552 100644 --- a/payloads/libpayload/include/x86/arch/exception.h +++ b/payloads/libpayload/include/x86/arch/exception.h @@ -58,7 +58,7 @@ struct exception_state } regs; u32 error_code; u32 vector; -} __attribute__((packed)); +} __packed; extern struct exception_state *exception_state; extern u32 exception_stack[]; diff --git a/payloads/libpayload/liblz4/lz4_wrapper.c b/payloads/libpayload/liblz4/lz4_wrapper.c index 6de140e403..d125ce336f 100644 --- a/payloads/libpayload/liblz4/lz4_wrapper.c +++ b/payloads/libpayload/liblz4/lz4_wrapper.c @@ -98,7 +98,7 @@ struct lz4_frame_header { }; /* + uint64_t content_size iff has_content_size is set */ /* + uint8_t header_checksum */ -} __attribute__((packed)); +} __packed; struct lz4_block_header { union { @@ -110,7 +110,7 @@ struct lz4_block_header { }; /* + size bytes of data */ /* + uint32_t block_checksum iff has_block_checksum is set */ -} __attribute__((packed)); +} __packed; size_t ulz4fn(const void *src, size_t srcn, void *dst, size_t dstn) { diff --git a/payloads/libpayload/libpci/libpci.c b/payloads/libpayload/libpci/libpci.c index 7b40e828d1..f715666a78 100644 --- a/payloads/libpayload/libpci/libpci.c +++ b/payloads/libpayload/libpci/libpci.c @@ -82,7 +82,7 @@ void pci_init(struct pci_access *pacc) memset(pacc, 0, sizeof(*pacc)); } -void pci_cleanup(__attribute__ ((unused)) struct pci_access *pacc) +void pci_cleanup(__attribute__((unused)) struct pci_access *pacc) { } |