summaryrefslogtreecommitdiffstats
path: root/hwaccess.h
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-12-14 03:32:24 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-12-14 03:32:24 +0000
commit5d5c072422ba6200180ae1707329c4f69d9e908e (patch)
tree0879142b94920fe708537db087da38e4ee312916 /hwaccess.h
parent516f93219f0ea955d7f98d856c4e3161e0416348 (diff)
downloadast2050-flashrom-5d5c072422ba6200180ae1707329c4f69d9e908e.zip
ast2050-flashrom-5d5c072422ba6200180ae1707329c4f69d9e908e.tar.gz
Split hardware access, OS abstraction and chip drivers out of flash.h
This patch is only the first step, but it hopefully will make working with the code and especially porting to new platforms easier. Subsequent patches should move #includes for the newly created files hwaccess.h and chipdrivers.h from flash.h to the files which need them. Programmers should live in a separate header file as well. Tested-by: Idwer Vollering <vidwer@gmail.com> Corresponding to flashrom svn r799. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Sean Nelson <audiohacked@gmail.com>
Diffstat (limited to 'hwaccess.h')
-rw-r--r--hwaccess.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/hwaccess.h b/hwaccess.h
new file mode 100644
index 0000000..edf1738
--- /dev/null
+++ b/hwaccess.h
@@ -0,0 +1,99 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * Copyright (C) 2009 Carl-Daniel Hailfinger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Header file for hardware access and OS abstraction. Included from flash.h.
+ */
+
+#ifndef __HWACCESS_H__
+#define __HWACCESS_H__ 1
+
+#if defined(__GLIBC__)
+#include <sys/io.h>
+#endif
+#if NEED_PCI == 1
+#include <pci/pci.h>
+#endif
+
+/* for iopl and outb under Solaris */
+#if defined (__sun) && (defined(__i386) || defined(__amd64))
+#include <strings.h>
+#include <sys/sysi86.h>
+#include <sys/psw.h>
+#include <asm/sunddi.h>
+#endif
+
+#if (defined(__MACH__) && defined(__APPLE__))
+#define __DARWIN__
+#endif
+
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+ #include <machine/cpufunc.h>
+ #define off64_t off_t
+ #define lseek64 lseek
+ #define OUTB(x, y) do { u_int tmp = (y); outb(tmp, (x)); } while (0)
+ #define OUTW(x, y) do { u_int tmp = (y); outw(tmp, (x)); } while (0)
+ #define OUTL(x, y) do { u_int tmp = (y); outl(tmp, (x)); } while (0)
+ #define INB(x) __extension__ ({ u_int tmp = (x); inb(tmp); })
+ #define INW(x) __extension__ ({ u_int tmp = (x); inw(tmp); })
+ #define INL(x) __extension__ ({ u_int tmp = (x); inl(tmp); })
+#else
+#if defined(__DARWIN__)
+ #include <DirectIO/darwinio.h>
+ #define off64_t off_t
+ #define lseek64 lseek
+#endif
+#if defined (__sun) && (defined(__i386) || defined(__amd64))
+ /* Note different order for outb */
+ #define OUTB(x,y) outb(y, x)
+ #define OUTW(x,y) outw(y, x)
+ #define OUTL(x,y) outl(y, x)
+ #define INB inb
+ #define INW inw
+ #define INL inl
+#else
+ #define OUTB outb
+ #define OUTW outw
+ #define OUTL outl
+ #define INB inb
+ #define INW inw
+ #define INL inl
+#endif
+#endif
+
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+extern int io_fd;
+#endif
+
+#if !defined(__DARWIN__) && !defined(__FreeBSD__) && !defined(__DragonFly__)
+typedef struct { uint32_t hi, lo; } msr_t;
+msr_t rdmsr(int addr);
+int wrmsr(int addr, msr_t msr);
+#endif
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+/* FreeBSD already has conflicting definitions for wrmsr/rdmsr. */
+#undef rdmsr
+#undef wrmsr
+#define rdmsr freebsd_rdmsr
+#define wrmsr freebsd_wrmsr
+typedef struct { uint32_t hi, lo; } msr_t;
+msr_t freebsd_rdmsr(int addr);
+int freebsd_wrmsr(int addr, msr_t msr);
+#endif
+
+#endif /* !__HWACCESS_H__ */
OpenPOWER on IntegriCloud