mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
Remove unneeded #include statements completely
Unistd.h was only used to get a definition of NULL in all files. Add our own NULL #define and remove unistd.h from flash.h stdio.h has no place in flash.h, it should be included only in files which really need it. Add #include statements in individual .c files where needed. Replace a few printf with msg_* to eliminate the need for stdio.h. Corresponding to flashrom svn r1021. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
This commit is contained in:
parent
4178760241
commit
831e8f4abb
@ -26,8 +26,6 @@
|
||||
* - Order number: 290658-004
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "flash.h"
|
||||
#include "chipdrivers.h"
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include "flash.h"
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
@ -107,8 +106,8 @@ static int fdc37b787_gpio50_raise(uint16_t port, const char * name)
|
||||
OUTB(0x55, port); /* enter conf mode */
|
||||
id = sio_read(port, 0x20);
|
||||
if (id != 0x44) {
|
||||
fprintf(stderr, "\nERROR: %s: FDC37B787: Wrong ID 0x%02X.\n",
|
||||
name, id);
|
||||
msg_perr("\nERROR: %s: FDC37B787: Wrong ID 0x%02X.\n",
|
||||
name, id);
|
||||
OUTB(0xAA, port); /* leave conf mode */
|
||||
return -1;
|
||||
}
|
||||
@ -118,8 +117,8 @@ static int fdc37b787_gpio50_raise(uint16_t port, const char * name)
|
||||
val = sio_read(port, 0xC8); /* GP50 */
|
||||
if ((val & 0x1B) != 0x10) /* output, no invert, GPIO */
|
||||
{
|
||||
fprintf(stderr, "\nERROR: %s: GPIO50 mode 0x%02X unexpected.\n",
|
||||
name, val);
|
||||
msg_perr("\nERROR: %s: GPIO50 mode 0x%02X unexpected.\n",
|
||||
name, val);
|
||||
OUTB(0xAA, port);
|
||||
return -1;
|
||||
}
|
||||
|
@ -22,6 +22,8 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#define _LARGEFILE64_SOURCE
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -21,6 +21,7 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -18,9 +18,6 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <usb.h>
|
||||
#include "flash.h"
|
||||
#include "chipdrivers.h"
|
||||
|
@ -19,8 +19,6 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include "flash.h"
|
||||
|
||||
#define PCI_VENDOR_ID_DRKAISER 0x1803
|
||||
|
7
flash.h
7
flash.h
@ -24,9 +24,7 @@
|
||||
#ifndef __FLASH_H__
|
||||
#define __FLASH_H__ 1
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "hwaccess.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@ -34,6 +32,10 @@
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *) 0)
|
||||
#endif
|
||||
|
||||
typedef unsigned long chipaddr;
|
||||
|
||||
enum programmer {
|
||||
@ -556,7 +558,6 @@ extern unsigned long flashbase;
|
||||
extern int verbose;
|
||||
extern const char *flashrom_version;
|
||||
extern char *chip_to_probe;
|
||||
#define printf_debug(x...) { if (verbose) printf(x); }
|
||||
void map_flash_registers(struct flashchip *flash);
|
||||
int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len);
|
||||
int erase_flash(struct flashchip *flash);
|
||||
|
@ -21,6 +21,7 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
31
layout.c
31
layout.c
@ -18,6 +18,7 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
@ -73,7 +74,7 @@ int show_id(uint8_t *bios, int size, int force)
|
||||
mb_vendor_offset = *(walk - 2);
|
||||
if ((*walk) == 0 || ((*walk) & 0x3ff) != 0 || (*walk) > size ||
|
||||
mb_part_offset > size || mb_vendor_offset > size) {
|
||||
printf("Flash image seems to be a legacy BIOS. Disabling checks.\n");
|
||||
msg_pinfo("Flash image seems to be a legacy BIOS. Disabling checks.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -81,25 +82,25 @@ int show_id(uint8_t *bios, int size, int force)
|
||||
mb_vendor = (char *)(bios + size - mb_vendor_offset);
|
||||
if (!isprint((unsigned char)*mb_part) ||
|
||||
!isprint((unsigned char)*mb_vendor)) {
|
||||
printf("Flash image seems to have garbage in the ID location."
|
||||
msg_pinfo("Flash image seems to have garbage in the ID location."
|
||||
" Disabling checks.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf_debug("coreboot last image size "
|
||||
msg_pdbg("coreboot last image size "
|
||||
"(not ROM size) is %d bytes.\n", *walk);
|
||||
|
||||
mainboard_part = strdup(mb_part);
|
||||
mainboard_vendor = strdup(mb_vendor);
|
||||
printf_debug("Manufacturer: %s\n", mainboard_vendor);
|
||||
printf_debug("Mainboard ID: %s\n", mainboard_part);
|
||||
msg_pdbg("Manufacturer: %s\n", mainboard_vendor);
|
||||
msg_pdbg("Mainboard ID: %s\n", mainboard_part);
|
||||
|
||||
/*
|
||||
* If lb_vendor is not set, the coreboot table was
|
||||
* not found. Nor was -m VENDOR:PART specified.
|
||||
*/
|
||||
if (!lb_vendor || !lb_part) {
|
||||
printf("Note: If the following flash access fails, "
|
||||
msg_pinfo("Note: If the following flash access fails, "
|
||||
"try -m <vendor>:<mainboard>.\n");
|
||||
return 0;
|
||||
}
|
||||
@ -109,13 +110,13 @@ int show_id(uint8_t *bios, int size, int force)
|
||||
*/
|
||||
if (!strcasecmp(mainboard_vendor, lb_vendor) &&
|
||||
!strcasecmp(mainboard_part, lb_part)) {
|
||||
printf_debug("This firmware image matches this mainboard.\n");
|
||||
msg_pdbg("This firmware image matches this mainboard.\n");
|
||||
} else {
|
||||
if (force_boardmismatch) {
|
||||
printf("WARNING: This firmware image does not "
|
||||
msg_pinfo("WARNING: This firmware image does not "
|
||||
"seem to fit to this machine - forcing it.\n");
|
||||
} else {
|
||||
printf("ERROR: Your firmware image (%s:%s) does not "
|
||||
msg_pinfo("ERROR: Your firmware image (%s:%s) does not "
|
||||
"appear to\n be correct for the detected "
|
||||
"mainboard (%s:%s)\n\nOverride with -p internal:"
|
||||
"boardmismatch=force if you are absolutely sure "
|
||||
@ -141,7 +142,7 @@ int read_romlayout(char *name)
|
||||
romlayout = fopen(name, "r");
|
||||
|
||||
if (!romlayout) {
|
||||
fprintf(stderr, "ERROR: Could not open ROM layout (%s).\n",
|
||||
msg_gerr("ERROR: Could not open ROM layout (%s).\n",
|
||||
name);
|
||||
return -1;
|
||||
}
|
||||
@ -159,7 +160,7 @@ int read_romlayout(char *name)
|
||||
tstr1 = strtok(tempstr, ":");
|
||||
tstr2 = strtok(NULL, ":");
|
||||
if (!tstr1 || !tstr2) {
|
||||
fprintf(stderr, "Error parsing layout file.\n");
|
||||
msg_gerr("Error parsing layout file.\n");
|
||||
fclose(romlayout);
|
||||
return 1;
|
||||
}
|
||||
@ -170,7 +171,7 @@ int read_romlayout(char *name)
|
||||
}
|
||||
|
||||
for (i = 0; i < romimages; i++) {
|
||||
printf_debug("romlayout %08x - %08x named %s\n",
|
||||
msg_gdbg("romlayout %08x - %08x named %s\n",
|
||||
rom_entries[i].start,
|
||||
rom_entries[i].end, rom_entries[i].name);
|
||||
}
|
||||
@ -187,16 +188,16 @@ int find_romentry(char *name)
|
||||
if (!romimages)
|
||||
return -1;
|
||||
|
||||
printf("Looking for \"%s\"... ", name);
|
||||
msg_ginfo("Looking for \"%s\"... ", name);
|
||||
|
||||
for (i = 0; i < romimages; i++) {
|
||||
if (!strcmp(rom_entries[i].name, name)) {
|
||||
rom_entries[i].included = 1;
|
||||
printf("found.\n");
|
||||
msg_ginfo("found.\n");
|
||||
return i;
|
||||
}
|
||||
}
|
||||
printf("not found.\n"); // Not found. Error.
|
||||
msg_ginfo("not found.\n"); // Not found. Error.
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -21,8 +21,6 @@
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include "flash.h"
|
||||
|
||||
#define BIOS_ROM_ADDR 0x04
|
||||
|
@ -21,8 +21,6 @@
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include "flash.h"
|
||||
|
||||
#define PCI_VENDOR_ID_REALTEK 0x10ec
|
||||
|
10
physmap.c
10
physmap.c
@ -20,6 +20,8 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@ -310,8 +312,8 @@ int wrmsr(int addr, msr_t msr)
|
||||
int setup_cpu_msr(int cpu)
|
||||
{
|
||||
char msrfilename[64];
|
||||
memset(msrfilename, 0, 64);
|
||||
sprintf(msrfilename, "/dev/cpu/%d/msr", cpu);
|
||||
memset(msrfilename, 0, sizeof(msrfilename));
|
||||
snprintf(msrfilename, sizeof(msrfilename), "/dev/cpu/%d/msr", cpu);
|
||||
|
||||
if (fd_msr != -1) {
|
||||
msg_pinfo("MSR was already initialized\n");
|
||||
@ -393,8 +395,8 @@ int wrmsr(int addr, msr_t msr)
|
||||
int setup_cpu_msr(int cpu)
|
||||
{
|
||||
char msrfilename[64];
|
||||
memset(msrfilename, 0, 64);
|
||||
sprintf(msrfilename, "/dev/cpu%d", cpu);
|
||||
memset(msrfilename, 0, sizeof(msrfilename));
|
||||
snprintf(msrfilename, sizeof(msrfilename), "/dev/cpu%d", cpu);
|
||||
|
||||
if (fd_msr != -1) {
|
||||
msg_pinfo("MSR was already initialized\n");
|
||||
|
1
print.c
1
print.c
@ -19,6 +19,7 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "flash.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flash.h"
|
||||
|
||||
/* No-op shutdown() for programmers which don't need special handling */
|
||||
|
@ -21,7 +21,6 @@
|
||||
/* Datasheets can be found on http://www.siliconimage.com. Great thanks! */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "flash.h"
|
||||
|
||||
#define PCI_VENDOR_ID_SII 0x1095
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
#include <string.h>
|
||||
#include "flash.h"
|
||||
#include "chipdrivers.h"
|
||||
#include "spi.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flash.h"
|
||||
#include "chipdrivers.h"
|
||||
|
||||
|
1
spi.c
1
spi.c
@ -22,7 +22,6 @@
|
||||
* Contains the generic SPI framework
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "flash.h"
|
||||
#include "flashchips.h"
|
||||
#include "chipdrivers.h"
|
||||
|
@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "flash.h"
|
||||
#include "chipdrivers.h"
|
||||
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
/* Adapted from the Intel FW hub stuff for 82802ax parts. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "flash.h"
|
||||
#include "chipdrivers.h"
|
||||
|
||||
|
@ -27,8 +27,6 @@
|
||||
* ST M50FLW080B (not yet tested)
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "flash.h"
|
||||
#include "flashchips.h"
|
||||
#include "chipdrivers.h"
|
||||
|
5
udelay.c
5
udelay.c
@ -19,6 +19,7 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
@ -63,7 +64,7 @@ void myusec_calibrate_delay(void)
|
||||
unsigned long timeusec;
|
||||
int i, tries = 0;
|
||||
|
||||
printf("Calibrating delay loop... ");
|
||||
msg_pinfo("Calibrating delay loop... ");
|
||||
|
||||
recalibrate:
|
||||
count = 1000;
|
||||
@ -113,7 +114,7 @@ recalibrate:
|
||||
timeusec = measure_delay(10000);
|
||||
msg_pdbg("10000 myus = %ld us, ", timeusec);
|
||||
|
||||
printf("OK.\n");
|
||||
msg_pinfo("OK.\n");
|
||||
}
|
||||
|
||||
void internal_delay(int usecs)
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
#include <string.h>
|
||||
#include "flash.h"
|
||||
#include "chipdrivers.h"
|
||||
#include "spi.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user