[flashrom] [commit] r944 - trunk

repository service svn at flashrom.org
Wed Mar 17 00:59:19 CET 2010


Author: hailfinger
Date: Wed Mar 17 00:59:19 2010
New Revision: 944
URL: http://flashrom.org/trac/coreboot/changeset/944

Log:
Add MS-DOS crosscompilation support to flashrom. Tested, works fine.
Part 1: Code changes.

Signed-off-by: Rudolf Marek <r.marek at assembler.cz>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Modified:
   trunk/hwaccess.c
   trunk/hwaccess.h
   trunk/physmap.c

Modified: trunk/hwaccess.c
==============================================================================
--- trunk/hwaccess.c	Tue Mar 16 04:09:10 2010	(r943)
+++ trunk/hwaccess.c	Wed Mar 17 00:59:19 2010	(r944)
@@ -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,6 +54,44 @@
 #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

Modified: trunk/hwaccess.h
==============================================================================
--- trunk/hwaccess.h	Tue Mar 16 04:09:10 2010	(r943)
+++ trunk/hwaccess.h	Wed Mar 17 00:59:19 2010	(r944)
@@ -68,12 +68,30 @@
   #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
 

Modified: trunk/physmap.c
==============================================================================
--- trunk/physmap.c	Tue Mar 16 04:09:10 2010	(r943)
+++ trunk/physmap.c	Wed Mar 17 00:59:19 2010	(r944)
@@ -4,6 +4,7 @@
  * Copyright (C) 2009 Peter Stuge <peter at stuge.se>
  * Copyright (C) 2009 coresystems GmbH
  * Copyright (C) 2010 Carl-Daniel Hailfinger
+ * Copyright (C) 2010 Rudolf Marek <r.marek at assembler.cz>
  *
  * 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"




More information about the flashrom mailing list