Clean up Mac OS X support of inteltool
Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Peter Stuge <peter@stuge.se> Some minor modifications to allow 64bit/32bit compilation on Darwin git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4621 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
b2aedb1a3f
commit
f7f2f258d8
@ -31,9 +31,7 @@ OBJS = inteltool.o cpu.o gpio.o rootcmplx.o powermgt.o memory.o pcie.o
|
|||||||
|
|
||||||
OS_ARCH = $(shell uname)
|
OS_ARCH = $(shell uname)
|
||||||
ifeq ($(OS_ARCH), Darwin)
|
ifeq ($(OS_ARCH), Darwin)
|
||||||
CFLAGS += -DDARWIN -I/usr/local/include
|
LDFLAGS = -framework DirectIO -lpci -lz
|
||||||
LDFLAGS = -framework IOKit -framework DirectIO -L/usr/local/lib -lpci -lz
|
|
||||||
# OBJS += darwinio.o
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: pciutils dep $(PROGRAM)
|
all: pciutils dep $(PROGRAM)
|
||||||
@ -56,7 +54,7 @@ pciutils:
|
|||||||
printf "struct pci_access *pacc;\n"; \
|
printf "struct pci_access *pacc;\n"; \
|
||||||
printf "int main(int argc, char **argv)\n"; \
|
printf "int main(int argc, char **argv)\n"; \
|
||||||
printf "{ pacc = pci_alloc(); return 0; }\n"; ) > .test.c )
|
printf "{ pacc = pci_alloc(); return 0; }\n"; ) > .test.c )
|
||||||
@$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) &>/dev/null && \
|
@$(CC) $(CFLAGS) $(LDFLAGS) .test.c -o .test &>/dev/null && \
|
||||||
printf "found.\n" || ( printf "not found.\n\n"; \
|
printf "found.\n" || ( printf "not found.\n\n"; \
|
||||||
printf "Please install pciutils-devel and zlib-devel.\n"; \
|
printf "Please install pciutils-devel and zlib-devel.\n"; \
|
||||||
printf "See README for more information.\n\n"; \
|
printf "See README for more information.\n\n"; \
|
||||||
@ -64,6 +62,7 @@ pciutils:
|
|||||||
@rm -rf .test.c .test .test.dSYM
|
@rm -rf .test.c .test .test.dSYM
|
||||||
|
|
||||||
install: $(PROGRAM)
|
install: $(PROGRAM)
|
||||||
|
mkdir -p $(DESTDIR)$(PREFIX)/sbin
|
||||||
$(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
|
$(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
|
||||||
mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
|
mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
|
||||||
$(INSTALL) $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
|
$(INSTALL) $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
|
||||||
|
@ -30,30 +30,23 @@ int fd_msr;
|
|||||||
|
|
||||||
unsigned int cpuid(unsigned int op)
|
unsigned int cpuid(unsigned int op)
|
||||||
{
|
{
|
||||||
unsigned int ret;
|
uint32_t ret;
|
||||||
unsigned int dummy2, dummy3, dummy4;
|
|
||||||
#if DARWIN
|
#if defined(__DARWIN__) && !defined(__LP64__)
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"pushl %%ebx \n"
|
"pushl %%ebx \n"
|
||||||
"cpuid \n"
|
"cpuid \n"
|
||||||
"movl %%ebx, %1 \n"
|
"popl %%ebx \n"
|
||||||
"popl %%ebx \n"
|
: "=a" (ret) : "a" (op) : "%ecx", "%edx"
|
||||||
: "=a" (ret), "=r" (dummy2), "=c" (dummy3), "=d" (dummy4)
|
);
|
||||||
: "a" (op)
|
|
||||||
: "cc"
|
|
||||||
);
|
|
||||||
#else
|
#else
|
||||||
asm volatile (
|
asm ("cpuid" : "=a" (ret) : "a" (op) : "%ebx", "%ecx", "%edx");
|
||||||
"cpuid"
|
|
||||||
: "=a" (ret), "=b" (dummy2), "=c" (dummy3), "=d" (dummy4)
|
|
||||||
: "a" (op)
|
|
||||||
: "cc"
|
|
||||||
);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DARWIN
|
#ifndef __DARWIN__
|
||||||
int msr_readerror = 0;
|
int msr_readerror = 0;
|
||||||
|
|
||||||
msr_t rdmsr(int addr)
|
msr_t rdmsr(int addr)
|
||||||
@ -288,7 +281,7 @@ int print_intel_core_msrs(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DARWIN
|
#ifndef __DARWIN__
|
||||||
fd_msr = open("/dev/cpu/0/msr", O_RDWR);
|
fd_msr = open("/dev/cpu/0/msr", O_RDWR);
|
||||||
if (fd_msr < 0) {
|
if (fd_msr < 0) {
|
||||||
perror("Error while opening /dev/cpu/0/msr");
|
perror("Error while opening /dev/cpu/0/msr");
|
||||||
@ -309,7 +302,7 @@ int print_intel_core_msrs(void)
|
|||||||
close(fd_msr);
|
close(fd_msr);
|
||||||
|
|
||||||
for (core = 0; core < 8; core++) {
|
for (core = 0; core < 8; core++) {
|
||||||
#ifndef DARWIN
|
#ifndef __DARWIN__
|
||||||
char msrfilename[64];
|
char msrfilename[64];
|
||||||
memset(msrfilename, 0, 64);
|
memset(msrfilename, 0, 64);
|
||||||
sprintf(msrfilename, "/dev/cpu/%d/msr", core);
|
sprintf(msrfilename, "/dev/cpu/%d/msr", core);
|
||||||
@ -330,12 +323,12 @@ int print_intel_core_msrs(void)
|
|||||||
cpu->per_core_msrs[i].number, msr.hi, msr.lo,
|
cpu->per_core_msrs[i].number, msr.hi, msr.lo,
|
||||||
cpu->per_core_msrs[i].name);
|
cpu->per_core_msrs[i].name);
|
||||||
}
|
}
|
||||||
#ifndef DARWIN
|
#ifndef __DARWIN__
|
||||||
close(fd_msr);
|
close(fd_msr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DARWIN
|
#ifndef __DARWIN__
|
||||||
if (msr_readerror)
|
if (msr_readerror)
|
||||||
printf("\n(*) Some MSRs could not be read. The marked values are unreliable.\n");
|
printf("\n(*) Some MSRs could not be read. The marked values are unreliable.\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,10 +50,10 @@ static const struct {
|
|||||||
{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH, "ICH" }
|
{ PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH, "ICH" }
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef DARWIN
|
#ifndef __DARWIN__
|
||||||
static int fd_mem;
|
static int fd_mem;
|
||||||
|
|
||||||
void *map_physical(unsigned long phys_addr, int len)
|
void *map_physical(unsigned long phys_addr, size_t len)
|
||||||
{
|
{
|
||||||
void *virt_addr;
|
void *virt_addr;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ void *map_physical(unsigned long phys_addr, int len)
|
|||||||
return virt_addr;
|
return virt_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unmap_physical(void *virt_addr, int len)
|
void unmap_physical(void *virt_addr, size_t len)
|
||||||
{
|
{
|
||||||
munmap(virt_addr, len);
|
munmap(virt_addr, len);
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ int main(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DARWIN
|
#ifndef __DARWIN__
|
||||||
if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
|
if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
|
||||||
perror("Can not open /dev/mem");
|
perror("Can not open /dev/mem");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -18,12 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#ifndef DARWIN
|
|
||||||
|
#if defined(__GLIBC__)
|
||||||
#include <sys/io.h>
|
#include <sys/io.h>
|
||||||
#else
|
#endif
|
||||||
/* DirectIO is available here:
|
#if (defined(__MACH__) && defined(__APPLE__))
|
||||||
* http://www.coresystems.de/en/directio
|
/* DirectIO is available here: http://www.coresystems.de/en/directio */
|
||||||
*/
|
#define __DARWIN__
|
||||||
#include <DirectIO/darwinio.h>
|
#include <DirectIO/darwinio.h>
|
||||||
#endif
|
#endif
|
||||||
#include <pci/pci.h>
|
#include <pci/pci.h>
|
||||||
@ -55,13 +56,13 @@
|
|||||||
|
|
||||||
#define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
|
#define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
|
||||||
|
|
||||||
#ifndef DARWIN
|
#ifndef __DARWIN__
|
||||||
typedef struct { uint32_t hi, lo; } msr_t;
|
typedef struct { uint32_t hi, lo; } msr_t;
|
||||||
#endif
|
#endif
|
||||||
typedef struct { uint16_t addr; int size; char *name; } io_register_t;
|
typedef struct { uint16_t addr; int size; char *name; } io_register_t;
|
||||||
|
|
||||||
void *map_physical(unsigned long phys_addr, int len);
|
void *map_physical(unsigned long phys_addr, size_t len);
|
||||||
void unmap_physical(void *virt_addr, int len);
|
void unmap_physical(void *virt_addr, size_t len);
|
||||||
|
|
||||||
unsigned int cpuid(unsigned int op);
|
unsigned int cpuid(unsigned int op);
|
||||||
int print_intel_core_msrs(void);
|
int print_intel_core_msrs(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user