mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
Convince compilers to put constant data into the .rodata section
This patch reduces the stack usage by declaring 'const' stack variables as 'static const' so they end up in the .rodata section instead of being copied from there to the stack for every invocation of the corresponding function. As a plus we end up in having a smaller binary as the "copy from .rodata to stack" code isn't emitted by the compiler any more (roughly -100 bytes). Corresponding to flashrom svn r1252. Signed-off-by: Mathias Krause <mathias.krause@secunet.com> Acked-by: Stefan Reinauer <stepan@coreboot.org>
This commit is contained in:
parent
2c3afa34fc
commit
a60faab83e
@ -114,8 +114,8 @@ int cli_classic(int argc, char *argv[])
|
|||||||
int operation_specified = 0;
|
int operation_specified = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
const char *optstring = "r:Rw:v:nVEfc:m:l:i:p:Lzh";
|
static const char optstring[] = "r:Rw:v:nVEfc:m:l:i:p:Lzh";
|
||||||
static struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
{"read", 1, 0, 'r'},
|
{"read", 1, 0, 'r'},
|
||||||
{"write", 1, 0, 'w'},
|
{"write", 1, 0, 'w'},
|
||||||
{"erase", 0, 0, 'E'},
|
{"erase", 0, 0, 'E'},
|
||||||
|
2
flash.h
2
flash.h
@ -188,7 +188,7 @@ enum write_granularity {
|
|||||||
};
|
};
|
||||||
extern enum chipbustype buses_supported;
|
extern enum chipbustype buses_supported;
|
||||||
extern int verbose;
|
extern int verbose;
|
||||||
extern const char * const flashrom_version;
|
extern const char flashrom_version[];
|
||||||
extern char *chip_to_probe;
|
extern char *chip_to_probe;
|
||||||
void map_flash_registers(struct flashchip *flash);
|
void map_flash_registers(struct flashchip *flash);
|
||||||
int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len);
|
int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len);
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include "flashchips.h"
|
#include "flashchips.h"
|
||||||
#include "programmer.h"
|
#include "programmer.h"
|
||||||
|
|
||||||
const char * const flashrom_version = FLASHROM_VERSION;
|
const char flashrom_version[] = FLASHROM_VERSION;
|
||||||
char *chip_to_probe = NULL;
|
char *chip_to_probe = NULL;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
|
|
||||||
|
4
ichspi.c
4
ichspi.c
@ -948,10 +948,10 @@ int ich_spi_send_multicommand(struct spi_command *cmds)
|
|||||||
|
|
||||||
static void do_ich9_spi_frap(uint32_t frap, int i)
|
static void do_ich9_spi_frap(uint32_t frap, int i)
|
||||||
{
|
{
|
||||||
const char *access_names[4] = {
|
static const char *const access_names[4] = {
|
||||||
"locked", "read-only", "write-only", "read-write"
|
"locked", "read-only", "write-only", "read-write"
|
||||||
};
|
};
|
||||||
const char *region_names[5] = {
|
static const char *const region_names[5] = {
|
||||||
"Flash Descriptor", "BIOS", "Management Engine",
|
"Flash Descriptor", "BIOS", "Management Engine",
|
||||||
"Gigabit Ethernet", "Platform Data"
|
"Gigabit Ethernet", "Platform Data"
|
||||||
};
|
};
|
||||||
|
18
print_wiki.c
18
print_wiki.c
@ -27,7 +27,7 @@
|
|||||||
#include "flashchips.h"
|
#include "flashchips.h"
|
||||||
#include "programmer.h"
|
#include "programmer.h"
|
||||||
|
|
||||||
static const char * const wiki_header = "= Supported devices =\n\n\
|
static const char wiki_header[] = "= Supported devices =\n\n\
|
||||||
<div style=\"margin-top:0.5em; padding:0.5em 0.5em 0.5em 0.5em; \
|
<div style=\"margin-top:0.5em; padding:0.5em 0.5em 0.5em 0.5em; \
|
||||||
background-color:#eeeeee; align:right; border:1px solid #aabbcc;\"><small>\n\
|
background-color:#eeeeee; align:right; border:1px solid #aabbcc;\"><small>\n\
|
||||||
Please do '''not''' edit these tables in the wiki directly, they are \
|
Please do '''not''' edit these tables in the wiki directly, they are \
|
||||||
@ -35,16 +35,16 @@ generated by pasting '''flashrom -z''' output.<br />\
|
|||||||
'''Last update:''' %s(generated by flashrom %s)\n</small></div>\n";
|
'''Last update:''' %s(generated by flashrom %s)\n</small></div>\n";
|
||||||
|
|
||||||
#if CONFIG_INTERNAL == 1
|
#if CONFIG_INTERNAL == 1
|
||||||
static const char * const chipset_th = "{| border=\"0\" style=\"font-size: smaller\"\n\
|
static const char chipset_th[] = "{| border=\"0\" style=\"font-size: smaller\"\n\
|
||||||
|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
|
|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
|
||||||
! align=\"left\" | Southbridge\n! align=\"left\" | PCI IDs\n\
|
! align=\"left\" | Southbridge\n! align=\"left\" | PCI IDs\n\
|
||||||
! align=\"left\" | Status\n\n";
|
! align=\"left\" | Status\n\n";
|
||||||
|
|
||||||
static const char * const board_th = "{| border=\"0\" style=\"font-size: smaller\" \
|
static const char board_th[] = "{| border=\"0\" style=\"font-size: smaller\" \
|
||||||
valign=\"top\"\n|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
|
valign=\"top\"\n|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
|
||||||
! align=\"left\" | Mainboard\n! align=\"left\" | Required option\n! align=\"left\" | Status\n\n";
|
! align=\"left\" | Mainboard\n! align=\"left\" | Required option\n! align=\"left\" | Status\n\n";
|
||||||
|
|
||||||
static const char * const board_intro = "\
|
static const char board_intro[] = "\
|
||||||
\n== Supported mainboards ==\n\n\
|
\n== Supported mainboards ==\n\n\
|
||||||
In general, it is very likely that flashrom works out of the box even if your \
|
In general, it is very likely that flashrom works out of the box even if your \
|
||||||
mainboard is not listed below.\n\nThis is a list of mainboards where we have \
|
mainboard is not listed below.\n\nThis is a list of mainboards where we have \
|
||||||
@ -57,14 +57,14 @@ know, someone has to give it a try). Please report any further verified \
|
|||||||
mainboards on the [[Mailinglist|mailing list]].\n";
|
mainboards on the [[Mailinglist|mailing list]].\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char * const chip_th = "{| border=\"0\" style=\"font-size: smaller\" \
|
static const char chip_th[] = "{| border=\"0\" style=\"font-size: smaller\" \
|
||||||
valign=\"top\"\n|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
|
valign=\"top\"\n|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
|
||||||
! align=\"left\" | Device\n! align=\"left\" | Size / KB\n\
|
! align=\"left\" | Device\n! align=\"left\" | Size / KB\n\
|
||||||
! align=\"left\" | Type\n! align=\"left\" colspan=\"4\" | Status\n\n\
|
! align=\"left\" | Type\n! align=\"left\" colspan=\"4\" | Status\n\n\
|
||||||
|- bgcolor=\"#6699ff\"\n| colspan=\"4\" | \n\
|
|- bgcolor=\"#6699ff\"\n| colspan=\"4\" | \n\
|
||||||
| Probe\n| Read\n| Erase\n| Write\n\n";
|
| Probe\n| Read\n| Erase\n| Write\n\n";
|
||||||
|
|
||||||
static const char * const programmer_section = "\
|
static const char programmer_section[] = "\
|
||||||
\n== Supported programmers ==\n\nThis is a list \
|
\n== Supported programmers ==\n\nThis is a list \
|
||||||
of supported PCI devices flashrom can use as programmer:\n\n{| border=\"0\" \
|
of supported PCI devices flashrom can use as programmer:\n\n{| border=\"0\" \
|
||||||
valign=\"top\"\n| valign=\"top\"|\n\n{| border=\"0\" style=\"font-size: \
|
valign=\"top\"\n| valign=\"top\"|\n\n{| border=\"0\" style=\"font-size: \
|
||||||
@ -73,7 +73,7 @@ smaller\" valign=\"top\"\n|- bgcolor=\"#6699dd\"\n! align=\"left\" | Vendor\n\
|
|||||||
! align=\"left\" | Status\n\n";
|
! align=\"left\" | Status\n\n";
|
||||||
|
|
||||||
#if CONFIG_INTERNAL == 1
|
#if CONFIG_INTERNAL == 1
|
||||||
static const char * const laptop_intro = "\n== Supported laptops/notebooks ==\n\n\
|
static const char laptop_intro[] = "\n== Supported laptops/notebooks ==\n\n\
|
||||||
In general, flashing laptops is more difficult because laptops\n\n\
|
In general, flashing laptops is more difficult because laptops\n\n\
|
||||||
* often use the flash chip for stuff besides the BIOS,\n\
|
* often use the flash chip for stuff besides the BIOS,\n\
|
||||||
* often have special protection stuff which has to be handled by flashrom,\n\
|
* often have special protection stuff which has to be handled by flashrom,\n\
|
||||||
@ -167,9 +167,9 @@ static void wiki_helper(const char *devicetype, int cols,
|
|||||||
|
|
||||||
if (boards[i].note) {
|
if (boards[i].note) {
|
||||||
printf("<sup>%d</sup>\n", num_notes + 1);
|
printf("<sup>%d</sup>\n", num_notes + 1);
|
||||||
snprintf((char *)&tmp, 900, "<sup>%d</sup> %s<br />\n",
|
snprintf(tmp, sizeof(tmp), "<sup>%d</sup> %s<br />\n",
|
||||||
1 + num_notes++, boards[i].note);
|
1 + num_notes++, boards[i].note);
|
||||||
notes = strcat_realloc(notes, (char *)&tmp);
|
notes = strcat_realloc(notes, tmp);
|
||||||
} else {
|
} else {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ int sb600_probe_spi(struct pci_dev *dev)
|
|||||||
struct pci_dev *smbus_dev;
|
struct pci_dev *smbus_dev;
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
uint8_t reg;
|
uint8_t reg;
|
||||||
const char *speed_names[4] = {
|
static const char *const speed_names[4] = {
|
||||||
"Reserved", "33", "22", "16.5"
|
"Reserved", "33", "22", "16.5"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
18
spi25.c
18
spi25.c
@ -33,7 +33,7 @@ void spi_prettyprint_status_register(struct flashchip *flash);
|
|||||||
|
|
||||||
static int spi_rdid(unsigned char *readarr, int bytes)
|
static int spi_rdid(unsigned char *readarr, int bytes)
|
||||||
{
|
{
|
||||||
const unsigned char cmd[JEDEC_RDID_OUTSIZE] = { JEDEC_RDID };
|
static const unsigned char cmd[JEDEC_RDID_OUTSIZE] = { JEDEC_RDID };
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ static int spi_res(unsigned char *readarr, int bytes)
|
|||||||
|
|
||||||
int spi_write_enable(void)
|
int spi_write_enable(void)
|
||||||
{
|
{
|
||||||
const unsigned char cmd[JEDEC_WREN_OUTSIZE] = { JEDEC_WREN };
|
static const unsigned char cmd[JEDEC_WREN_OUTSIZE] = { JEDEC_WREN };
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
/* Send WREN (Write Enable) */
|
/* Send WREN (Write Enable) */
|
||||||
@ -109,7 +109,7 @@ int spi_write_enable(void)
|
|||||||
|
|
||||||
int spi_write_disable(void)
|
int spi_write_disable(void)
|
||||||
{
|
{
|
||||||
const unsigned char cmd[JEDEC_WRDI_OUTSIZE] = { JEDEC_WRDI };
|
static const unsigned char cmd[JEDEC_WRDI_OUTSIZE] = { JEDEC_WRDI };
|
||||||
|
|
||||||
/* Send WRDI (Write Disable) */
|
/* Send WRDI (Write Disable) */
|
||||||
return spi_send_command(sizeof(cmd), 0, cmd, NULL);
|
return spi_send_command(sizeof(cmd), 0, cmd, NULL);
|
||||||
@ -232,10 +232,10 @@ int probe_spi_rems(struct flashchip *flash)
|
|||||||
|
|
||||||
int probe_spi_res1(struct flashchip *flash)
|
int probe_spi_res1(struct flashchip *flash)
|
||||||
{
|
{
|
||||||
|
static const unsigned char allff[] = {0xff, 0xff, 0xff};
|
||||||
|
static const unsigned char all00[] = {0x00, 0x00, 0x00};
|
||||||
unsigned char readarr[3];
|
unsigned char readarr[3];
|
||||||
uint32_t id2;
|
uint32_t id2;
|
||||||
const unsigned char allff[] = {0xff, 0xff, 0xff};
|
|
||||||
const unsigned char all00[] = {0x00, 0x00, 0x00};
|
|
||||||
|
|
||||||
/* We only want one-byte RES if RDID and REMS are unusable. */
|
/* We only want one-byte RES if RDID and REMS are unusable. */
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ int probe_spi_res2(struct flashchip *flash)
|
|||||||
|
|
||||||
uint8_t spi_read_status_register(void)
|
uint8_t spi_read_status_register(void)
|
||||||
{
|
{
|
||||||
const unsigned char cmd[JEDEC_RDSR_OUTSIZE] = { JEDEC_RDSR };
|
static const unsigned char cmd[JEDEC_RDSR_OUTSIZE] = { JEDEC_RDSR };
|
||||||
/* FIXME: No workarounds for driver/hardware bugs in generic code. */
|
/* FIXME: No workarounds for driver/hardware bugs in generic code. */
|
||||||
unsigned char readarr[2]; /* JEDEC_RDSR_INSIZE=1 but wbsio needs 2 */
|
unsigned char readarr[2]; /* JEDEC_RDSR_INSIZE=1 but wbsio needs 2 */
|
||||||
int ret;
|
int ret;
|
||||||
@ -486,7 +486,7 @@ void spi_prettyprint_status_register_sst25(uint8_t status)
|
|||||||
*/
|
*/
|
||||||
void spi_prettyprint_status_register_sst25vf016(uint8_t status)
|
void spi_prettyprint_status_register_sst25vf016(uint8_t status)
|
||||||
{
|
{
|
||||||
const char *bpt[] = {
|
static const char *const bpt[] = {
|
||||||
"none",
|
"none",
|
||||||
"1F0000H-1FFFFFH",
|
"1F0000H-1FFFFFH",
|
||||||
"1E0000H-1FFFFFH",
|
"1E0000H-1FFFFFH",
|
||||||
@ -502,7 +502,7 @@ void spi_prettyprint_status_register_sst25vf016(uint8_t status)
|
|||||||
|
|
||||||
void spi_prettyprint_status_register_sst25vf040b(uint8_t status)
|
void spi_prettyprint_status_register_sst25vf040b(uint8_t status)
|
||||||
{
|
{
|
||||||
const char *bpt[] = {
|
static const char *const bpt[] = {
|
||||||
"none",
|
"none",
|
||||||
"0x70000-0x7ffff",
|
"0x70000-0x7ffff",
|
||||||
"0x60000-0x7ffff",
|
"0x60000-0x7ffff",
|
||||||
@ -837,7 +837,7 @@ int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int
|
|||||||
|
|
||||||
int spi_write_status_enable(void)
|
int spi_write_status_enable(void)
|
||||||
{
|
{
|
||||||
const unsigned char cmd[JEDEC_EWSR_OUTSIZE] = { JEDEC_EWSR };
|
static const unsigned char cmd[JEDEC_EWSR_OUTSIZE] = { JEDEC_EWSR };
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
/* Send EWSR (Enable Write Status Register). */
|
/* Send EWSR (Enable Write Status Register). */
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
static int unlock_block_stm50flw0x0x(struct flashchip *flash, int offset)
|
static int unlock_block_stm50flw0x0x(struct flashchip *flash, int offset)
|
||||||
{
|
{
|
||||||
chipaddr wrprotect = flash->virtual_registers + 2;
|
chipaddr wrprotect = flash->virtual_registers + 2;
|
||||||
const uint8_t unlock_sector = 0x00;
|
static const uint8_t unlock_sector = 0x00;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user