Author: ruik Date: Mon Apr 26 00:47:50 2010 New Revision: 995 URL: http://flashrom.org/trac/coreboot/changeset/995
Log: Fix the DOS port. Now the DS selector limit is set to 4GB and all mmio accesses goes through DS, the 1:1 mapping is fixed so the _DS base is taken onto account. Plus is that the hwaccess.c needs no change and memcpy etc can be used on mmaped space.
Signed-off-by: Rudolf Marek r.marek@assembler.cz Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Modified: trunk/Makefile trunk/hwaccess.c trunk/physmap.c
Modified: trunk/Makefile ============================================================================== --- trunk/Makefile Tue Apr 20 21:34:31 2010 (r994) +++ trunk/Makefile Mon Apr 26 00:47:50 2010 (r995) @@ -202,12 +202,8 @@ endif
ifeq ($(NEED_PCI), yes) -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'
Modified: trunk/hwaccess.c ============================================================================== --- trunk/hwaccess.c Tue Apr 20 21:34:31 2010 (r994) +++ trunk/hwaccess.c Mon Apr 26 00:47:50 2010 (r995) @@ -54,44 +54,6 @@ #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; @@ -121,4 +83,3 @@ { return *(volatile uint32_t *) addr; } -#endif
Modified: trunk/physmap.c ============================================================================== --- trunk/physmap.c Tue Apr 20 21:34:31 2010 (r994) +++ trunk/physmap.c Mon Apr 26 00:47:50 2010 (r995) @@ -30,66 +30,67 @@
#ifdef __DJGPP__ #include <dpmi.h> +#include <sys/nearptr.h>
#define MEM_DEV "dpmi"
-unsigned short segFS = 0; +static void *realmem_map;
-void *sys_physmap(unsigned long phys_addr, size_t len) +static void *map_first_meg(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); + if (realmem_map) { + return realmem_map + phys_addr; }
- mi.address = phys_addr; - mi.size = len; - ret = __dpmi_physical_address_mapping (&mi); + realmem_map = valloc(1024 * 1024);
- if (ret != 0) { + if (!realmem_map) { return NULL; }
- return (void *) mi.address; -} - -#define sys_physmap_rw_uncached sys_physmap - -#include <sys/movedata.h> -#include <sys/segments.h> -#include <go32.h> + if (__djgpp_map_physical_memory(realmem_map, (1024 * 1024), 0)) { + return NULL; + }
-static void *realmem_cpy; + return realmem_map + phys_addr; +}
-void *sys_physmap_ro_cached(unsigned long phys_addr, size_t len) +void *sys_physmap(unsigned long phys_addr, size_t len) { - /* no support for not a 1MB of mem */ - if ((phys_addr + len) > 1024*1024) + int ret; + __dpmi_meminfo mi; + + /* enable 4GB limit on DS descriptor */ + if (!__djgpp_nearptr_enable()) { return NULL; + }
- if (realmem_cpy) - return realmem_cpy + phys_addr; + if ((phys_addr + len - 1) < (1024 * 1024)) { + /* we need to use another method to map first 1MB */ + return map_first_meg(phys_addr, len); + }
- realmem_cpy = valloc(1024*1024); + mi.address = phys_addr; + mi.size = len; + ret = __dpmi_physical_address_mapping (&mi);
- if (!realmem_cpy) + if (ret != 0) { return NULL; + }
- movedata(_dos_ds, 0, _my_ds(), (unsigned long) realmem_cpy, 1024*1024); - return realmem_cpy + phys_addr; + return (void *) mi.address + __djgpp_conventional_base; }
+#define sys_physmap_rw_uncached sys_physmap +#define sys_physmap_ro_cached sys_physmap
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))) { + /* we ignore unmaps for our first 1MB */ + if ((virt_addr >= realmem_map) && ((virt_addr + len) <= (realmem_map + (1024 * 1024)))) { return; }