From patchwork Mon Aug 31 18:25:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: misc coreboot utility patches Date: Mon, 31 Aug 2009 18:25:48 -0000 From: Stefan Reinauer X-Patchwork-Id: 233 Message-Id: <4A9C15AC.7060009@coresystems.de> To: Coreboot See attachments Acked-by: Peter Stuge Index: inteltool-r4620/inteltool.h =================================================================== --- inteltool-r4620/inteltool.h +++ inteltool-r4620/inteltool.h @@ -18,12 +18,13 @@ */ #include -#ifndef DARWIN + +#if defined(__GLIBC__) #include -#else -/* DirectIO is available here: - * http://www.coresystems.de/en/directio - */ +#endif +#if (defined(__MACH__) && defined(__APPLE__)) +/* DirectIO is available here: http://www.coresystems.de/en/directio */ +#define __DARWIN__ #include #endif #include @@ -55,7 +56,7 @@ #define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0]))) -#ifndef DARWIN +#ifndef __DARWIN__ typedef struct { uint32_t hi, lo; } msr_t; #endif typedef struct { uint16_t addr; int size; char *name; } io_register_t; Index: inteltool-r4620/cpu.c =================================================================== --- inteltool-r4620/cpu.c +++ inteltool-r4620/cpu.c @@ -32,7 +32,7 @@ { unsigned int ret; unsigned int dummy2, dummy3, dummy4; -#if DARWIN +#ifdef __DARWIN__ asm volatile ( "pushl %%ebx \n" "cpuid \n" @@ -53,7 +53,7 @@ return ret; } -#ifndef DARWIN +#ifndef __DARWIN__ int msr_readerror = 0; msr_t rdmsr(int addr) @@ -288,7 +288,7 @@ return -1; } -#ifndef DARWIN +#ifndef __DARWIN__ fd_msr = open("/dev/cpu/0/msr", O_RDWR); if (fd_msr < 0) { perror("Error while opening /dev/cpu/0/msr"); @@ -309,7 +309,7 @@ close(fd_msr); for (core = 0; core < 8; core++) { -#ifndef DARWIN +#ifndef __DARWIN__ char msrfilename[64]; memset(msrfilename, 0, 64); sprintf(msrfilename, "/dev/cpu/%d/msr", core); @@ -330,12 +330,12 @@ cpu->per_core_msrs[i].number, msr.hi, msr.lo, cpu->per_core_msrs[i].name); } -#ifndef DARWIN +#ifndef __DARWIN__ close(fd_msr); #endif } -#ifndef DARWIN +#ifndef __DARWIN__ if (msr_readerror) printf("\n(*) Some MSRs could not be read. The marked values are unreliable.\n"); #endif Index: inteltool-r4620/inteltool.c =================================================================== --- inteltool-r4620/inteltool.c +++ inteltool-r4620/inteltool.c @@ -50,7 +50,7 @@ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH, "ICH" } }; -#ifndef DARWIN +#ifndef __DARWIN__ static int fd_mem; void *map_physical(unsigned long phys_addr, int len) @@ -192,7 +192,7 @@ exit(1); } -#ifndef DARWIN +#ifndef __DARWIN__ if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) { perror("Can not open /dev/mem"); exit(1); Index: inteltool-r4620/Makefile =================================================================== --- inteltool-r4620/Makefile +++ inteltool-r4620/Makefile @@ -31,9 +31,7 @@ OS_ARCH = $(shell uname) ifeq ($(OS_ARCH), Darwin) -CFLAGS += -DDARWIN -I/usr/local/include -LDFLAGS = -framework IOKit -framework DirectIO -L/usr/local/lib -lpci -lz -# OBJS += darwinio.o +LDFLAGS = -framework IOKit -framework DirectIO -lpci -lz endif all: pciutils dep $(PROGRAM)