-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > > I added a short version of your description to the flashrom README.
Ok > I made some more changes to the Makefile. "make dos" is something I'd > rather avoid because it hardcodes too many assumptions. I would prefer to have there something like: make djgpp-dos because I will tend to forgot how to invoke the make from command line. > >> 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__ >> [...] >> +#elif __DARWIN__ >> > > Can you change this to > #elif defined(__DARWIN) > to keep the logic as it was? I don't have a Mac OS X machine, so I can't > test... yes sorry fixed. > > >> + >> #include <DirectIO/darwinio.h> >> >> #define MEM_DEV "DirectIO" >> > > If you drop the board_enable.c hunk (and if my latest Makefile+README > patch is OK for you), this is > Acked-by: Carl-Daniel Hailfinger <[email protected]> > > I can update the README once your pciutils patch has been merged. > I dont know who can commit this, I'm attaching the fixed patch. Signed-off-by: Rudolf Marek <[email protected]> Please check that in, so at least something is there ;) The libpci fixes etc can wait until Martin shows up. Thanks, Rudolf -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkugCPEACgkQ3J9wPJqZRNUqWQCdErhzjgjP8JpAJoyJk1uNPNiD /AgAoNf9oyKTxSFfsBlyvwFo+kwtx3el =SS6P -----END PGP SIGNATURE-----
Index: hwaccess.c
===================================================================
--- hwaccess.c (revision 943)
+++ 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 943)
+++ 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 943)
+++ 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 defined(__DARWIN__)
+
#include <DirectIO/darwinio.h>
#define MEM_DEV "DirectIO"
Index: Makefile
===================================================================
--- Makefile (revision 943)
+++ 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
+djgpp-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
dos3.patch.sig
Description: Binary data
_______________________________________________ flashrom mailing list [email protected] http://www.flashrom.org/mailman/listinfo/flashrom
