129 lines
4.8 KiB
Diff
129 lines
4.8 KiB
Diff
From 14f7e3a845c339fc98c14d0d57908d4c76f4596a Mon Sep 17 00:00:00 2001
|
|
From: Laurent Vivier <lvivier@redhat.com>
|
|
Date: Wed, 8 Aug 2018 15:11:00 +0100
|
|
Subject: [PATCH 4/6] romfs/tools: Remove superfluous union around the rom
|
|
header struct
|
|
|
|
RH-Author: Laurent Vivier <lvivier@redhat.com>
|
|
Message-id: <20180808151102.11232-5-lvivier@redhat.com>
|
|
Patchwork-id: 81683
|
|
O-Subject: [RHEL-8.0 SLOF PATCH 4/6] romfs/tools: Remove superfluous union around the rom header struct
|
|
Bugzilla: 1613619
|
|
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
RH-Acked-by: David Gibson <dgibson@redhat.com>
|
|
|
|
From: Thomas Huth <thuth@redhat.com>
|
|
|
|
Accessing the struct with memset and memcpy can also be done without the
|
|
union wrapper. While we're at it, also remove the FLASHFS_HEADER_DATA_SIZE
|
|
macre and use sizeof(stHeader) instead.
|
|
|
|
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
(cherry picked from commit d4443f17c956e77df7bb23b2d19462faae9f4b23)
|
|
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
|
|
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
---
|
|
include/calculatecrc.h | 1 -
|
|
romfs/tools/create_crc.c | 29 +++++++++++++----------------
|
|
2 files changed, 13 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/include/calculatecrc.h b/include/calculatecrc.h
|
|
index a19a229..667ea81 100644
|
|
--- a/include/calculatecrc.h
|
|
+++ b/include/calculatecrc.h
|
|
@@ -17,7 +17,6 @@
|
|
#define FLASHFS_HEADER_SIZE_ADDR 0x08 // uint64_t position of total flash header size value
|
|
|
|
#define FLASHFS_ROMADDR 0x00 // uint64_t position of pointer to next file
|
|
-#define FLASHFS_HEADER_DATA_SIZE 0x68 // 104 bytes of total header data size
|
|
#define CRC_METHODE Ethernet_32 // define the CRC genarator (CRC 16 bit to 64 is supported)
|
|
|
|
//--- header format ---------------------------------
|
|
diff --git a/romfs/tools/create_crc.c b/romfs/tools/create_crc.c
|
|
index 5a76b9c..e354339 100644
|
|
--- a/romfs/tools/create_crc.c
|
|
+++ b/romfs/tools/create_crc.c
|
|
@@ -10,6 +10,7 @@
|
|
* IBM Corporation - initial implementation
|
|
*****************************************************************************/
|
|
|
|
+#include <assert.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
@@ -71,21 +72,18 @@ createHeaderImage(int notime)
|
|
char dastr[16] = { 0, };
|
|
unsigned long long da = 0;
|
|
|
|
- union {
|
|
- unsigned char pcArray[FLASHFS_HEADER_DATA_SIZE];
|
|
- struct stH stHeader;
|
|
- } uHeader;
|
|
+ struct stH stHeader;
|
|
|
|
/* initialize Header */
|
|
- memset(uHeader.pcArray, 0x00, FLASHFS_HEADER_DATA_SIZE);
|
|
+ memset(&stHeader, 0x00, sizeof(stHeader));
|
|
|
|
/* read driver info */
|
|
if (NULL != (pcVersion = getenv("DRIVER_NAME"))) {
|
|
- strncpy(uHeader.stHeader.version, pcVersion, 16);
|
|
+ strncpy(stHeader.version, pcVersion, 16);
|
|
} else if (NULL != (pcVersion = getenv("USER"))) {
|
|
- strncpy(uHeader.stHeader.version, pcVersion, 16);
|
|
+ strncpy(stHeader.version, pcVersion, 16);
|
|
} else if (pcVersion == NULL) {
|
|
- strncpy(uHeader.stHeader.version, "No known user!", 16);
|
|
+ strncpy(stHeader.version, "No known user!", 16);
|
|
}
|
|
|
|
if (!notime) {
|
|
@@ -104,18 +102,18 @@ createHeaderImage(int notime)
|
|
}
|
|
da = cpu_to_be64(strtoll(dastr, NULL, 16));
|
|
}
|
|
- memcpy(uHeader.stHeader.date, &da, 8);
|
|
+ memcpy(stHeader.date, &da, 8);
|
|
|
|
/* write Magic value into data stream */
|
|
- strncpy(uHeader.stHeader.magic, FLASHFS_MAGIC, 8);
|
|
+ strncpy(stHeader.magic, FLASHFS_MAGIC, 8);
|
|
/* write platform name into data stream */
|
|
- strcpy(uHeader.stHeader.platform_name, FLASHFS_PLATFORM_MAGIC);
|
|
+ strcpy(stHeader.platform_name, FLASHFS_PLATFORM_MAGIC);
|
|
/* write platform revision into data stream */
|
|
- strcpy(uHeader.stHeader.platform_revision, FLASHFS_PLATFORM_REVISION);
|
|
+ strcpy(stHeader.platform_revision, FLASHFS_PLATFORM_REVISION);
|
|
|
|
|
|
/* fill end of file info (8 bytes of FF) into data stream */
|
|
- uHeader.stHeader.ui64FileEnd = -1;
|
|
+ stHeader.ui64FileEnd = -1;
|
|
|
|
/* read address of next file and address of header date, both are 64 bit values */
|
|
ui64RomAddr = 0;
|
|
@@ -129,7 +127,7 @@ createHeaderImage(int notime)
|
|
|
|
/* calculate final flash-header-size and flash-file-size */
|
|
/* calculate end addr of header */
|
|
- ui64globalHeaderSize = (uint32_t) ui64DataAddr + (uint32_t) FLASHFS_HEADER_DATA_SIZE;
|
|
+ ui64globalHeaderSize = (uint32_t) ui64DataAddr + sizeof(stHeader);
|
|
/* cut 64 bit to place CRC for File-End */
|
|
ui64globalHeaderSize -= 8;
|
|
/* add 64 bit to place CRC behind File-End */
|
|
@@ -143,8 +141,7 @@ createHeaderImage(int notime)
|
|
/* fill free space in Header with zeros */
|
|
memset(&pucFileStream[ui64DataAddr], 0, (ui64RomAddr - ui64DataAddr));
|
|
/* place data to header */
|
|
- memcpy(&pucFileStream[ui64DataAddr], uHeader.pcArray,
|
|
- FLASHFS_HEADER_DATA_SIZE);
|
|
+ memcpy(&pucFileStream[ui64DataAddr], &stHeader, sizeof(stHeader));
|
|
|
|
/* insert header length into data stream */
|
|
*(uint64_t *) (pucFileStream + FLASHFS_HEADER_SIZE_ADDR) =
|
|
--
|
|
1.8.3.1
|
|
|