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