-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all,
I reworked the physmem mapping and also did a hack to allow RO mapping of first 1MB which is not allowed under DPMI ;) I simply copy the memory and return a pointer to a copied data. This is used for the coreboot tables and there is no need for RW. The dmidecode could be also DOS recompiled but executing that if quite complicated. Therefore maybe own parser for DMI would be nice. Attached patches are for the flashrom and pciutils. To make it work try following: 1) get RPMs of the cross compiler from DJGPP site djcross-binutils-2.19.1-10ap.i386.rpm djcross-gcc-tools-4.4.1-1ap.i686.rpm djcross-gcc-4.3.2-8ap.i686.rpm Somehow install them on your system. I used alien on 32bit machine to make debs and I forced them to install on amd64 ;) 2) Download all stuff from: http://assembler.cz/flashrom 3) patch flashrom source and pciutils source 4) compile the libgetopt in its dir 5) compile the pciutils, use the README.DJGPP 6) flashrom patch expects that the ../libpci contains the stuff what is installed from pciutils and ../libgetopt contains compiled getopt.a compile it too ;) I put there also the binary image and cwsdpmi zip which exe files are needed to run the flashrom.exe (I think only cwdpmi.exe) Have fun and please test ;) The dos.patch contains some flashrom NULL ptr fix and also Carl-Daniels changes for Makefile. Rudolf -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkudHrIACgkQ3J9wPJqZRNXgtQCgk+mYKzbmeYnuVoaMgfKoOLG2 nj8AoIXJv0tIo51Wktq/GYPDj8RhIzWs =v0AX -----END PGP SIGNATURE-----
Index: hwaccess.c
===================================================================
--- hwaccess.c (revision 927)
+++ hwaccess.c (working copy)
@@ -36,7 +36,9 @@
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) != 0) {
#elif defined(__FreeBSD__) || defined (__DragonFly__)
if ((io_fd = open("/dev/io", O_RDWR)) < 0) {
-#else
+#elif __DJGPP__
+ if (0) {
+#else
if (iopl(3) != 0) {
#endif
fprintf(stderr, "ERROR: Could not get I/O privileges (%s).\n"
@@ -52,8 +54,46 @@
#endif
}
+#ifdef __DJGPP__
+
+extern unsigned short segFS;
+
+#include <sys/farptr.h>
+
void mmio_writeb(uint8_t val, void *addr)
{
+ _farpokeb(segFS, (unsigned long) addr, val);
+}
+
+void mmio_writew(uint16_t val, void *addr)
+{
+ _farpokew(segFS, (unsigned long) addr, val);
+}
+
+void mmio_writel(uint32_t val, void *addr)
+{
+ _farpokel(segFS, (unsigned long) addr, val);
+}
+
+uint8_t mmio_readb(void *addr)
+{
+ return _farpeekb(segFS, (unsigned long) addr);
+}
+
+uint16_t mmio_readw(void *addr)
+{
+ return _farpeekw(segFS, (unsigned long) addr);
+}
+
+uint32_t mmio_readl(void *addr)
+{
+ return _farpeekl(segFS, (unsigned long) addr);
+}
+
+#else
+
+void mmio_writeb(uint8_t val, void *addr)
+{
*(volatile uint8_t *) addr = val;
}
@@ -81,3 +121,4 @@
{
return *(volatile uint32_t *) addr;
}
+#endif
Index: hwaccess.h
===================================================================
--- hwaccess.h (revision 935)
+++ hwaccess.h (working copy)
@@ -68,14 +68,32 @@
#define INW inw
#define INL inl
#else
+
+#ifdef __DJGPP__
+
+#include <pc.h>
+
+ #define OUTB(x,y) outportb(y, x)
+ #define OUTW(x,y) outportw(y, x)
+ #define OUTL(x,y) outportl(y, x)
+
+ #define INB inportb
+ #define INW inportw
+ #define INL inportl
+
+#else
+
#define OUTB outb
#define OUTW outw
#define OUTL outl
#define INB inb
#define INW inw
#define INL inl
+
#endif
+
#endif
+#endif
#if defined(__NetBSD__)
#define off64_t off_t
Index: physmap.c
===================================================================
--- physmap.c (revision 935)
+++ physmap.c (working copy)
@@ -4,6 +4,7 @@
* Copyright (C) 2009 Peter Stuge <[email protected]>
* Copyright (C) 2009 coresystems GmbH
* Copyright (C) 2010 Carl-Daniel Hailfinger
+ * Copyright (C) 2010 Rudolf Marek <[email protected]>
*
* 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
@@ -27,7 +28,77 @@
#include <errno.h>
#include "flash.h"
-#ifdef __DARWIN__
+#ifdef __DJGPP__
+#include <dpmi.h>
+
+#define MEM_DEV "dpmi"
+
+unsigned short segFS = 0;
+
+void *sys_physmap(unsigned long phys_addr, size_t len)
+{
+ int ret;
+ __dpmi_meminfo mi;
+
+ if (segFS == 0) {
+ segFS = __dpmi_allocate_ldt_descriptors (1);
+ __dpmi_set_segment_base_address (segFS, 0x0);
+ __dpmi_set_segment_limit (segFS, 0xffffffff);
+ }
+
+ mi.address = phys_addr;
+ mi.size = len;
+ ret = __dpmi_physical_address_mapping (&mi);
+
+ if (ret != 0) {
+ return NULL;
+ }
+
+ return (void *) mi.address;
+}
+
+#define sys_physmap_rw_uncached sys_physmap
+
+#include <sys/movedata.h>
+#include <sys/segments.h>
+#include <go32.h>
+
+static void *realmem_cpy;
+
+void *sys_physmap_ro_cached(unsigned long phys_addr, size_t len)
+{
+ /* no support for not a 1MB of mem */
+ if ((phys_addr + len) > 1024*1024)
+ return NULL;
+
+ if (realmem_cpy)
+ return realmem_cpy + phys_addr;
+
+ realmem_cpy = valloc(1024*1024);
+
+ if (!realmem_cpy)
+ return NULL;
+
+ movedata(_dos_ds, 0, _my_ds(), (unsigned long) realmem_cpy, 1024*1024);
+ return realmem_cpy + phys_addr;
+}
+
+
+void physunmap(void *virt_addr, size_t len)
+{
+ __dpmi_meminfo mi;
+
+ /* we ignore unmaps for our cheat 1MB copy */
+ if ((virt_addr >= realmem_cpy) && ((virt_addr + len) <= (realmem_cpy + 1024*1024))) {
+ return;
+ }
+
+ mi.address = (unsigned long) virt_addr;
+ __dpmi_free_physical_address_mapping(&mi);
+}
+
+#elif __DARWIN__
+
#include <DirectIO/darwinio.h>
#define MEM_DEV "DirectIO"
Index: Makefile
===================================================================
--- Makefile (revision 935)
+++ Makefile (working copy)
@@ -2,6 +2,7 @@
# This file is part of the flashrom project.
#
# Copyright (C) 2005 coresystems GmbH <[email protected]>
+# Copyright (C) 2009,2010 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
@@ -20,15 +21,22 @@
PROGRAM = flashrom
CC ?= gcc
-STRIP = strip
+STRIP ?= strip
INSTALL = install
DIFF = diff
PREFIX ?= /usr/local
MANDIR ?= $(PREFIX)/share/man
-CFLAGS ?= -Os -Wall -Werror -Wshadow
+CFLAGS ?= -Os -Wall -Wshadow
EXPORTDIR ?= .
-OS_ARCH = $(shell uname)
+WARNERROR ?= yes
+
+ifeq ($(WARNERROR), yes)
+CFLAGS += -Werror
+endif
+
+# FIXME We have to differentiate between host and target arch.
+OS_ARCH ?= $(shell uname)
ifneq ($(OS_ARCH), SunOS)
STRIP_ARGS = -s
endif
@@ -40,6 +48,12 @@
CPPFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib
endif
+ifeq ($(OS_ARCH), DOS)
+CPPFLAGS += -I../libgetopt -I../libpci/include
+# Bus Pirate and Serprog are not supported under DOS.
+CONFIG_BUSPIRATESPI = no
+CONFIG_SERPROG = no
+endif
CHIP_OBJS = jedec.o stm50flw0x0x.o w39v040c.o w39v080fa.o sharplhf00l04.o w29ee011.o \
sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \
@@ -188,14 +202,28 @@
endif
ifeq ($(NEED_PCI), yes)
-LIBS += -lpci
+ifneq ($(OS_ARCH), DOS)
+# FIXME This workaround is needed until libpci detection can handle
+# cross-compiling for DOS.
+CHECK_LIBPCI = yes
+endif
+endif
+
+ifeq ($(NEED_PCI), yes)
FEATURE_CFLAGS += -D'NEED_PCI=1'
PROGRAMMER_OBJS += pcidev.o physmap.o hwaccess.o
ifeq ($(OS_ARCH), NetBSD)
LIBS += -lpciutils # The libpci we want.
LIBS += -l$(shell uname -p) # For (i386|x86_64)_iopl(2).
+else
+ifeq ($(OS_ARCH), DOS)
+# FIXME There needs to be a better way to do this
+LIBS += ../libpci/lib/libpci.a ../libgetopt/libgetopt.a
+else
+LIBS += -lpci
endif
endif
+endif
ifeq ($(CONFIG_PRINT_WIKI), yes)
FEATURE_CFLAGS += -D'PRINT_WIKI_SUPPORT=1'
@@ -205,7 +233,7 @@
# We could use PULLED_IN_LIBS, but that would be ugly.
FEATURE_LIBS += $(shell LC_ALL=C grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")
-OBJS = $(CHIP_OBJS) $(CLI_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
+OBJS = $(CHIP_OBJS) $(CLI_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS) $(OS_OBJS)
$(PROGRAM): $(OBJS)
$(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(FEATURE_LIBS) $(LIBS)
@@ -239,7 +267,7 @@
rm -f .test.c .test; exit 1)
@rm -f .test.c .test
-ifeq ($(NEED_PCI), yes)
+ifeq ($(CHECK_LIBPCI), yes)
pciutils: compiler
@printf "Checking for libpci headers... "
@$(shell ( echo "#include <pci/pci.h>"; \
@@ -315,6 +343,9 @@
@rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
@echo Created $(EXPORTDIR)/flashrom-$(RELEASENAME).tar.bz2
-.PHONY: all clean distclean dep compiler pciutils features export tarball
+dos: clean
+ make CC=i586-pc-msdosdjgpp-gcc STRIP=i586-pc-msdosdjgpp-strip WARNERROR=no OS_ARCH=DOS
+.PHONY: all clean distclean dep compiler pciutils features export tarball dos
+
-include .dependencies
Index: board_enable.c
===================================================================
--- board_enable.c (revision 927)
+++ board_enable.c (working copy)
@@ -1442,7 +1442,7 @@
if (!board)
board = board_match_pci_card_ids();
- if (board->status == NT) {
+ if (board && board->status == NT) {
if (!force_boardenable)
{
printf("WARNING: Your mainboard is %s %s, but the mainboard-specific\n"
Binární soubory pciutils-3.1.5-orig/example.exe a pciutils/example.exe jsou rùzné diff -uprN pciutils-3.1.5-orig/lib/configure pciutils/lib/configure --- pciutils-3.1.5-orig/lib/configure 2009-07-04 18:11:04.000000000 +0200 +++ pciutils/lib/configure 2010-03-14 17:31:26.870334510 +0100 @@ -115,7 +115,11 @@ case $sys in echo >>$m 'WITH_LIBS+=-lpci' LIBRESOLV= ;; - gnu) + gnu) + echo_n " i386-ports" + echo >>$c '#define PCI_HAVE_PM_INTEL_CONF' + ;; + djgpp) echo_n " i386-ports" echo >>$c '#define PCI_HAVE_PM_INTEL_CONF' ;; diff -uprN pciutils-3.1.5-orig/lib/i386-io-djgpp.h pciutils/lib/i386-io-djgpp.h --- pciutils-3.1.5-orig/lib/i386-io-djgpp.h 1970-01-01 01:00:00.000000000 +0100 +++ pciutils/lib/i386-io-djgpp.h 2010-03-14 17:51:35.140113292 +0100 @@ -0,0 +1,29 @@ +/* + * The PCI Library -- Access to i386 I/O ports on DJGPP + * + * Copyright (c) 2010 Rudolf Marek <[email protected]> + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#include <pc.h> + +#define outb(x,y) outportb(y, x) +#define outw(x,y) outportw(y, x) +#define outl(x,y) outportl(y, x) + +#define inb inportb +#define inw inportw +#define inl inportl + +static int +intel_setup_io(struct pci_access *a UNUSED) +{ + return 1; +} + +static inline int +intel_cleanup_io(struct pci_access *a UNUSED) +{ + return 1; +} diff -uprN pciutils-3.1.5-orig/lib/i386-ports.c pciutils/lib/i386-ports.c --- pciutils-3.1.5-orig/lib/i386-ports.c 2009-07-04 18:11:04.000000000 +0200 +++ pciutils/lib/i386-ports.c 2010-03-14 17:48:57.737333497 +0100 @@ -22,6 +22,8 @@ #include "i386-io-windows.h" #elif defined(PCI_OS_CYGWIN) #include "i386-io-cygwin.h" +#elif defined(PCI_OS_DJGPP) +#include "i386-io-djgpp.h" #else #error Do not know how to access I/O ports on this OS. #endif diff -uprN pciutils-3.1.5-orig/lib/types.h pciutils/lib/types.h --- pciutils-3.1.5-orig/lib/types.h 2008-11-11 00:11:51.000000000 +0100 +++ pciutils/lib/types.h 2010-03-14 17:45:17.442094774 +0100 @@ -21,10 +21,17 @@ typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; #else +#ifdef __DJGPP__ +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +#else typedef u_int8_t u8; typedef u_int16_t u16; typedef u_int32_t u32; #endif +#endif + #ifdef PCI_HAVE_64BIT_ADDRESS #include <limits.h> Binární soubory pciutils-3.1.5-orig/lspci.exe a pciutils/lspci.exe jsou rùzné diff -uprN pciutils-3.1.5-orig/lspci.h pciutils/lspci.h --- pciutils-3.1.5-orig/lspci.h 2009-07-04 18:11:04.000000000 +0200 +++ pciutils/lspci.h 2010-03-14 17:55:51.349334077 +0100 @@ -14,7 +14,7 @@ * This increases our memory footprint, but only slightly since we don't * use alloca() much. */ -#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__DragonFly__) +#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__DragonFly__) || defined (__DJGPP__) /* alloca() is defined in stdlib.h */ #elif defined(__GNUC__) && !defined(PCI_OS_WINDOWS) #include <alloca.h> diff -uprN pciutils-3.1.5-orig/Makefile pciutils/Makefile --- pciutils-3.1.5-orig/Makefile 2010-01-19 10:36:35.000000000 +0100 +++ pciutils/Makefile 2010-03-14 18:05:19.621333523 +0100 @@ -8,15 +8,15 @@ VERSION=3.1.5 DATE=2010-01-19 # Host OS and release (override if you are cross-compiling) -HOST= +HOST=i386-djgpp-djgpp RELEASE= -CROSS_COMPILE= +CROSS_COMPILE=i586-pc-msdosdjgpp- # Support for compressed pci.ids (yes/no, default: detect) -ZLIB= +ZLIB=no # Support for resolving ID's by DNS (yes/no, default: detect) -DNS= +DNS=no # Build libpci as a shared library (yes/no; or local for testing; requires GCC) SHARED=no @@ -37,7 +37,9 @@ PKGCFDIR=$(LIBDIR)/pkgconfig # Commands INSTALL=install DIRINSTALL=install -d -STRIP=-s + +SSTRIP=-s --strip-program=$(CROSS_COMPILE)strip + CC=$(CROSS_COMPILE)gcc AR=$(CROSS_COMPILE)ar RANLIB=$(CROSS_COMPILE)ranlib @@ -101,7 +103,7 @@ distclean: clean install: all # -c is ignored on Linux, but required on FreeBSD $(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7 - $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(DESTDIR)$(SBINDIR) + $(INSTALL) -c -m 755 $(SSTRIP) lspci setpci $(DESTDIR)$(SBINDIR) $(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR) $(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR) $(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8 diff -uprN pciutils-3.1.5-orig/README.DJGPP pciutils/README.DJGPP --- pciutils-3.1.5-orig/README.DJGPP 1970-01-01 01:00:00.000000000 +0100 +++ pciutils/README.DJGPP 2010-03-14 18:11:27.177412750 +0100 @@ -0,0 +1,17 @@ +To cross compile use following setting in the Makefile + +HOST=i386-djgpp-djgpp +RELEASE= +CROSS_COMPILE=i586-pc-msdosdjgpp- + +# Support for compressed pci.ids (yes/no, default: detect) +ZLIB=no + +# Support for resolving ID's by DNS (yes/no, default: detect) +DNS=no + +Then invoke crosscompile to some other dir + +mkdir -p ../libpci +make PREFIX=/ DESTDIR=$PWD/../libpci install install-lib + Binární soubory pciutils-3.1.5-orig/setpci.exe a pciutils/setpci.exe jsou rùzné
dos.patch.sig
Description: Binary data
pciutils.patch.sig
Description: Binary data
_______________________________________________ flashrom mailing list [email protected] http://www.flashrom.org/mailman/listinfo/flashrom
