summaryrefslogtreecommitdiffstats
path: root/physmap.c
diff options
context:
space:
mode:
authorRudolf Marek <r.marek@assembler.cz>2010-04-25 22:47:50 +0000
committerRudolf Marek <r.marek@assembler.cz>2010-04-25 22:47:50 +0000
commit837d81079689927b78baa5c606c6d8484ea21a95 (patch)
tree3984257535f8147f22220157a0952834f6760e35 /physmap.c
parentce1c798c1ce12873c101d0e3345548db83d2e374 (diff)
downloadast2050-flashrom-837d81079689927b78baa5c606c6d8484ea21a95.zip
ast2050-flashrom-837d81079689927b78baa5c606c6d8484ea21a95.tar.gz
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. Corresponding to flashrom svn r995. Signed-off-by: Rudolf Marek <r.marek@assembler.cz> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'physmap.c')
-rw-r--r--physmap.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/physmap.c b/physmap.c
index 38a395c..0e3ce60 100644
--- a/physmap.c
+++ b/physmap.c
@@ -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;
}
OpenPOWER on IntegriCloud