mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-26 22:52:34 +02:00
Remove exit call and mayfail parameter from physmap_common()
The only call path where exit was reached was from physmap functions. Callers of physmap() et al. which were not prepared to handle ERROR_PTR return values have been adjusted. physmap_try_ro() has been renamed to physmap_ro() and physmap_common() slightly refactored due to the now removed *FAIL parameters. Corresponding to flashrom svn r1745. Signed-off-by: Niklas Söderlund <niso@kth.se> Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
This commit is contained in:
parent
2d8b7ef4a8
commit
5d3072030a
@ -261,7 +261,7 @@ int cb_parse_table(const char **vendor, const char **model)
|
|||||||
#else
|
#else
|
||||||
start = 0x0;
|
start = 0x0;
|
||||||
#endif
|
#endif
|
||||||
table_area = physmap_try_ro("low megabyte", start, BYTES_TO_MAP - start);
|
table_area = physmap_ro("low megabyte", start, BYTES_TO_MAP - start);
|
||||||
if (ERROR_PTR == table_area) {
|
if (ERROR_PTR == table_area) {
|
||||||
msg_perr("Failed getting access to coreboot low tables.\n");
|
msg_perr("Failed getting access to coreboot low tables.\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -277,7 +277,7 @@ int cb_parse_table(const char **vendor, const char **model)
|
|||||||
start = forward->forward;
|
start = forward->forward;
|
||||||
start &= ~(getpagesize() - 1);
|
start &= ~(getpagesize() - 1);
|
||||||
physunmap(table_area, BYTES_TO_MAP);
|
physunmap(table_area, BYTES_TO_MAP);
|
||||||
table_area = physmap_try_ro("high tables", start, BYTES_TO_MAP);
|
table_area = physmap_ro("high tables", start, BYTES_TO_MAP);
|
||||||
if (ERROR_PTR == table_area) {
|
if (ERROR_PTR == table_area) {
|
||||||
msg_perr("Failed getting access to coreboot high tables.\n");
|
msg_perr("Failed getting access to coreboot high tables.\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -482,7 +482,7 @@ static int enable_flash_tunnelcreek(struct pci_dev *dev, const char *name)
|
|||||||
/* Map RCBA to virtual memory */
|
/* Map RCBA to virtual memory */
|
||||||
rcrb = rphysmap("ICH RCRB", tmp, 0x4000);
|
rcrb = rphysmap("ICH RCRB", tmp, 0x4000);
|
||||||
if (rcrb == ERROR_PTR)
|
if (rcrb == ERROR_PTR)
|
||||||
return 1;
|
return ERROR_FATAL;
|
||||||
|
|
||||||
/* Test Boot BIOS Strap Status */
|
/* Test Boot BIOS Strap Status */
|
||||||
bnt = mmio_readl(rcrb + 0x3410);
|
bnt = mmio_readl(rcrb + 0x3410);
|
||||||
@ -566,7 +566,7 @@ static int enable_flash_ich_dc_spi(struct pci_dev *dev, const char *name,
|
|||||||
/* Map RCBA to virtual memory */
|
/* Map RCBA to virtual memory */
|
||||||
rcrb = rphysmap("ICH RCRB", tmp, 0x4000);
|
rcrb = rphysmap("ICH RCRB", tmp, 0x4000);
|
||||||
if (rcrb == ERROR_PTR)
|
if (rcrb == ERROR_PTR)
|
||||||
return 1;
|
return ERROR_FATAL;
|
||||||
|
|
||||||
gcs = mmio_readl(rcrb + 0x3410);
|
gcs = mmio_readl(rcrb + 0x3410);
|
||||||
msg_pdbg("GCS = 0x%x: ", gcs);
|
msg_pdbg("GCS = 0x%x: ", gcs);
|
||||||
@ -1289,6 +1289,8 @@ static int get_flashbase_sc520(struct pci_dev *dev, const char *name)
|
|||||||
|
|
||||||
/* 1. Map MMCR */
|
/* 1. Map MMCR */
|
||||||
mmcr = physmap("Elan SC520 MMCR", 0xfffef000, getpagesize());
|
mmcr = physmap("Elan SC520 MMCR", 0xfffef000, getpagesize());
|
||||||
|
if (mmcr == ERROR_PTR)
|
||||||
|
return ERROR_FATAL;
|
||||||
|
|
||||||
/* 2. Scan PAR0 (0x88) - PAR15 (0xc4) for
|
/* 2. Scan PAR0 (0x88) - PAR15 (0xc4) for
|
||||||
* BOOTCS region (PARx[31:29] = 100b)e
|
* BOOTCS region (PARx[31:29] = 100b)e
|
||||||
|
4
dmi.c
4
dmi.c
@ -250,8 +250,8 @@ int dmi_fill(void)
|
|||||||
* - EFI's configuration table contains a pointer to the SMBIOS table. On linux it can be obtained from
|
* - EFI's configuration table contains a pointer to the SMBIOS table. On linux it can be obtained from
|
||||||
* sysfs. EFI's SMBIOS GUID is: {0xeb9d2d31,0x2d88,0x11d3,0x9a,0x16,0x0,0x90,0x27,0x3f,0xc1,0x4d}
|
* sysfs. EFI's SMBIOS GUID is: {0xeb9d2d31,0x2d88,0x11d3,0x9a,0x16,0x0,0x90,0x27,0x3f,0xc1,0x4d}
|
||||||
* - Scanning physical memory address range 0x000F0000h to 0x000FFFFF for the anchor-string(s). */
|
* - Scanning physical memory address range 0x000F0000h to 0x000FFFFF for the anchor-string(s). */
|
||||||
dmi_mem = physmap_try_ro("DMI", 0xF0000, 0x10000);
|
dmi_mem = physmap_ro("DMI", 0xF0000, 0x10000);
|
||||||
if (dmi_mem == NULL)
|
if (dmi_mem == ERROR_PTR)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (fp = 0; fp <= 0xFFF0; fp += 16) {
|
for (fp = 0; fp <= 0xFFF0; fp += 16) {
|
||||||
|
@ -177,6 +177,9 @@ int nicintel_spi_init(void)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
nicintel_spibar = rphysmap("Intel Gigabit NIC w/ SPI flash", io_base_addr, MEMMAP_SIZE);
|
nicintel_spibar = rphysmap("Intel Gigabit NIC w/ SPI flash", io_base_addr, MEMMAP_SIZE);
|
||||||
|
if (nicintel_spibar == ERROR_PTR)
|
||||||
|
return 1;
|
||||||
|
|
||||||
/* Automatic restore of EECD on shutdown is not possible because EECD
|
/* Automatic restore of EECD on shutdown is not possible because EECD
|
||||||
* does not only contain FLASH_WRITES_DISABLED|FLASH_WRITES_ENABLED,
|
* does not only contain FLASH_WRITES_DISABLED|FLASH_WRITES_ENABLED,
|
||||||
* but other bits with side effects as well. Those other bits must be
|
* but other bits with side effects as well. Those other bits must be
|
||||||
|
32
physmap.c
32
physmap.c
@ -203,8 +203,6 @@ void physunmap(void *virt_addr, size_t len)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PHYSM_NOFAIL 0
|
|
||||||
#define PHYSM_MAYFAIL 1
|
|
||||||
#define PHYSM_RW 0
|
#define PHYSM_RW 0
|
||||||
#define PHYSM_RO 1
|
#define PHYSM_RO 1
|
||||||
#define PHYSM_NOCLEANUP 0
|
#define PHYSM_NOCLEANUP 0
|
||||||
@ -249,8 +247,8 @@ static int undo_physmap(void *data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *physmap_common(const char *descr, uintptr_t phys_addr, size_t len, bool mayfail,
|
static void *physmap_common(const char *descr, uintptr_t phys_addr, size_t len, bool readonly, bool autocleanup,
|
||||||
bool readonly, bool autocleanup, bool round)
|
bool round)
|
||||||
{
|
{
|
||||||
void *virt_addr;
|
void *virt_addr;
|
||||||
uintptr_t offset = 0;
|
uintptr_t offset = 0;
|
||||||
@ -287,53 +285,47 @@ static void *physmap_common(const char *descr, uintptr_t phys_addr, size_t len,
|
|||||||
"and reboot, or reboot into\n"
|
"and reboot, or reboot into\n"
|
||||||
"single user mode.\n");
|
"single user mode.\n");
|
||||||
#endif
|
#endif
|
||||||
if (mayfail)
|
return ERROR_PTR;
|
||||||
return ERROR_PTR;
|
|
||||||
else
|
|
||||||
exit(3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autocleanup) {
|
if (autocleanup) {
|
||||||
struct undo_physmap_data *d = malloc(sizeof(struct undo_physmap_data));
|
struct undo_physmap_data *d = malloc(sizeof(struct undo_physmap_data));
|
||||||
if (d == NULL) {
|
if (d == NULL) {
|
||||||
msg_perr("%s: Out of memory!\n", __func__);
|
msg_perr("%s: Out of memory!\n", __func__);
|
||||||
goto unmap_out;
|
physunmap(virt_addr, len);
|
||||||
|
return ERROR_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->virt_addr = virt_addr;
|
d->virt_addr = virt_addr;
|
||||||
d->len = len;
|
d->len = len;
|
||||||
if (register_shutdown(undo_physmap, d) != 0) {
|
if (register_shutdown(undo_physmap, d) != 0) {
|
||||||
msg_perr("%s: Could not register shutdown function!\n", __func__);
|
msg_perr("%s: Could not register shutdown function!\n", __func__);
|
||||||
goto unmap_out;
|
physunmap(virt_addr, len);
|
||||||
|
return ERROR_PTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return virt_addr + offset;
|
return virt_addr + offset;
|
||||||
unmap_out:
|
|
||||||
physunmap(virt_addr, len);
|
|
||||||
if (!mayfail)
|
|
||||||
exit(3);
|
|
||||||
return ERROR_PTR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *physmap(const char *descr, uintptr_t phys_addr, size_t len)
|
void *physmap(const char *descr, uintptr_t phys_addr, size_t len)
|
||||||
{
|
{
|
||||||
return physmap_common(descr, phys_addr, len, PHYSM_NOFAIL, PHYSM_RW, PHYSM_NOCLEANUP, PHYSM_EXACT);
|
return physmap_common(descr, phys_addr, len, PHYSM_RW, PHYSM_NOCLEANUP, PHYSM_EXACT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *rphysmap(const char *descr, uintptr_t phys_addr, size_t len)
|
void *rphysmap(const char *descr, uintptr_t phys_addr, size_t len)
|
||||||
{
|
{
|
||||||
return physmap_common(descr, phys_addr, len, PHYSM_NOFAIL, PHYSM_RW, PHYSM_CLEANUP, PHYSM_ROUND);
|
return physmap_common(descr, phys_addr, len, PHYSM_RW, PHYSM_CLEANUP, PHYSM_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *physmap_round(const char *descr, uintptr_t phys_addr, size_t len)
|
void *physmap_round(const char *descr, uintptr_t phys_addr, size_t len)
|
||||||
{
|
{
|
||||||
return physmap_common(descr, phys_addr, len, PHYSM_NOFAIL, PHYSM_RW, PHYSM_NOCLEANUP, PHYSM_ROUND);
|
return physmap_common(descr, phys_addr, len, PHYSM_RW, PHYSM_NOCLEANUP, PHYSM_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *physmap_try_ro(const char *descr, uintptr_t phys_addr, size_t len)
|
void *physmap_ro(const char *descr, uintptr_t phys_addr, size_t len)
|
||||||
{
|
{
|
||||||
return physmap_common(descr, phys_addr, len, PHYSM_MAYFAIL, PHYSM_RO, PHYSM_NOCLEANUP, PHYSM_EXACT);
|
return physmap_common(descr, phys_addr, len, PHYSM_RO, PHYSM_NOCLEANUP, PHYSM_EXACT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MSR abstraction implementations for Linux, OpenBSD, FreeBSD/Dragonfly, OSX, libpayload
|
/* MSR abstraction implementations for Linux, OpenBSD, FreeBSD/Dragonfly, OSX, libpayload
|
||||||
|
@ -278,7 +278,7 @@ int processor_flash_enable(void);
|
|||||||
void *physmap(const char *descr, uintptr_t phys_addr, size_t len);
|
void *physmap(const char *descr, uintptr_t phys_addr, size_t len);
|
||||||
void *rphysmap(const char *descr, uintptr_t phys_addr, size_t len);
|
void *rphysmap(const char *descr, uintptr_t phys_addr, size_t len);
|
||||||
void *physmap_round(const char *descr, uintptr_t phys_addr, size_t len);
|
void *physmap_round(const char *descr, uintptr_t phys_addr, size_t len);
|
||||||
void *physmap_try_ro(const char *descr, uintptr_t phys_addr, size_t len);
|
void *physmap_ro(const char *descr, uintptr_t phys_addr, size_t len);
|
||||||
void physunmap(void *virt_addr, size_t len);
|
void physunmap(void *virt_addr, size_t len);
|
||||||
#if CONFIG_INTERNAL == 1
|
#if CONFIG_INTERNAL == 1
|
||||||
int setup_cpu_msr(int cpu);
|
int setup_cpu_msr(int cpu);
|
||||||
|
@ -353,7 +353,7 @@ int sb600_probe_spi(struct pci_dev *dev)
|
|||||||
/* Physical memory has to be mapped at page (4k) boundaries. */
|
/* Physical memory has to be mapped at page (4k) boundaries. */
|
||||||
sb600_spibar = rphysmap("SB600 SPI registers", tmp & 0xfffff000, 0x1000);
|
sb600_spibar = rphysmap("SB600 SPI registers", tmp & 0xfffff000, 0x1000);
|
||||||
if (sb600_spibar == ERROR_PTR)
|
if (sb600_spibar == ERROR_PTR)
|
||||||
return 1;
|
return ERROR_FATAL;
|
||||||
|
|
||||||
/* The low bits of the SPI base address are used as offset into
|
/* The low bits of the SPI base address are used as offset into
|
||||||
* the mapped page.
|
* the mapped page.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user