doscmd under 8-stable, anyone?

nickolasbug at gmail.com nickolasbug at gmail.com
Wed Jun 15 14:46:44 UTC 2011


2011/6/15 Jeremy Chadwick <freebsd at jdc.parodius.com>:
> On Wed, Jun 15, 2011 at 03:57:05PM +0200, Joerg Wunsch wrote:
>> When trying to use doscmd on 8-stable, all I get is:
>>
>> Error mapping HMA, HMA disabled: : Invalid argument
>> Segmentation fault (core dumped)
>>
>> The segfault happens at the end of mem_init(), when the allocated DOS
>> memory (which is located at virtual address 0) is attempted to be
>> written to.  Apparently, the mmap() failure that causes the "HMA
>> disabled" message is actually a fatal error rather than a benign one
>> the could be ignored, as it results in no valid DOS memory allocation
>> at all.
>>
>> Right now, the only older system I could test it against uses FreeBSD
>> 5.x, where the mmap() works as expected.  So does anyone have an idea
>> why this mmap() call:
>>
>>     if (mmap((caddr_t)0x000000, 0x100000,
>>                    PROT_EXEC | PROT_READ | PROT_WRITE,
>>                    MAP_ANON | MAP_FIXED | MAP_SHARED,
>>                    -1, 0) == MAP_FAILED) {
>>         perror("Error mapping HMA, HMA disabled: ");
>>         HMA_a20 = -1;
>>         close(HMA_fd_off);
>>         close(HMA_fd_on);
>>         return;
>>     }
>>
>> yields an EINVAL now under 8-stable?

As I remember, mapping of "zero" page forbidden by default.

> I imagine that the page size ordeal is probably what's biting you.  Now,
> I'm not sure if page size in that above context refers to "kernel page
> size" (e.g. hw.pagesizes or hw.pagesize) or if it refers to "a page of
> memory" as in what libc/malloc uses.

It refers. mmap(2) is system call.
On i386/amd64 "big" page size is 2MB, and code above is trying to
allocate 1MB, so memory will be allocated with 4KB-sized pages.

>
> I'm not sure why a person would need or want MAP_FIXED in this
> situation; why can't they just take the result of mmap() (a void *) and
> use that as a base address offset instead of assuming zero in their
> software?

AFAIK, doscmd is trying to emulate real mode on real hardware while
being in protected mode, thus it want first pages of memory.

Another way to do the same thing - open /dev/mem and call mmap() at zero offset.


More information about the freebsd-stable mailing list