Date: Mon, 7 Jul 1997 08:19:26 -0700 (PDT) Message-Id: <199707071519.IAA23803@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Johan Karlsson From: Nate Eldredge Subject: Re: Protected mode Cc: djgpp AT delorie DOT com Precedence: bulk At 09:21 7/7/1997 +0200, you wrote: >I tried to use the dpmi interrupt 2fH ax = 1686H >see: http://www.delorie.com/djgpp/doc/dpmi/ch5.g.html >to get the CPU mode, but it return that the program runs in Real Mode. >Is there some problem with this code part: >__dpmi_regs r; >r.x.ax = 0x1686; >__dpmi_int(0x2f, &r) > >Now if (r.x.ax == 0) then Protected mode else Real Mode. >And r.x.ax is not 0 when __dpmi_int returns. That's correct. __dpmi_int creates a *real mode* interrupt. I'm not sure offhand how to get a protected mode interrupt, but I think it can be done with int86. >I have a memory board on the ISA Bus which I want to access. >The memory is in the address range 0x00400000 to 0x0047fffe Here's some code which ought to do that. Note that I don't have any memory-mapped devices to test it with so I don't know if it will work. Also: it calls abort in each place where something has gone wrong. --cut-- #define MEM_BD_PHYSICAL_BASE 0x00400000 #define MEM_BD_SIZE 0x00080000 /* or so */ __dpmi_meminfo meminfo_block; short mem_bd_selector; int mem_bd_linear; /* First, get a selector that we can use */ if ((mem_bd_selector = __dpmi_allocate_ldt_descriptors(1)) == -1) abort(); /* Now, the physical address has to be mapped to a linear address */ meminfo_block.address = MEM_BD_PHYSICAL_BASE; meminfo_block.size = MEM_BD_SIZE; if ((mem_bd_linear = __dpmi_physical_address_mapping(&meminfo_block)) == -1) abort(); /* Now we lock it so nobody gets any funny ideas about swapping it */ meminfo_block.address = mem_bd_linear; meminfo_block.size = MEM_BD_SIZE; if (__dpmi_lock_linear_region(&meminfo_block) == -1) abort(); /* Ok, now make the selector work on the mem board area */ /* First, set the base address of the segment */ if (__dpmi_set_segment_base_address(mem_bd_selector,mem_bd_linear) == -1) abort(); /* Now the limit, to catch any pointer overruns, etc */ if (__dpmi_set_segment_limit(mem_bd_selector,MEM_BD_SIZE) == -1) abort(); /* That's it! Now you can use mem_bd_selector to access your board with farptr functions or movedata */ HTH Nate Eldredge eldredge AT ap DOT net