Mail Archives: djgpp/1999/06/17/06:10:35
Eli Zaretskii wrote in message ...
>
>On Wed, 16 Jun 1999, Michael Stewart wrote:
>
>> It creates a selector, given the location and size. So if you wanted a
>> descriptor which spanned the VGA memory (0xa0000, 64000 bytes) you would
>> call it like so.
>>
>> if (make_ds (video_ds, 0xa0000, 64000))
>> return -1; /* Error making descriptor */
>
>I think it might be useful.
>
>> int make_ds (int &ds, int base, int limit) {
>> static char ds_data[8];
>
>Why did you make the ds_data[] array static?
Thats what was in the original code, I never gave it much thought.
>Also, I think it's better to declare it "unsigned char".
Will do.
>> limit--;
>> ds_data[0] = limit & 0xff;
>> ds_data[1] = limit >> 8 & 0xff;
>
>It might be better to make sure that if the size of the segment is
>more than 1MB, the lower 12 bits in the limit you pass to
>__dpmi_set_descriptor are set. This is because the DPMI spec requires
>such large segments to be page-aligned, and some servers will fail the
>call otherwise. Too many people posted here code that didn't work
>because they failed to comply to that requirement, and it would be a
>good idea to make this function take care of that for the user.
Ok
>> ds_data[6] = limit >> 16 & 0x0f + 0x40;
>
>The 0x40 part is only correct for limits less than 64KB (and even then
>I think it needs to be 0x41). For larger segments, you need to make
>it page-granular, so 0xc1 is the value in those cases.
Ok
>> ds_data[7] = 0x00;
>
>This is only right for addresses in the first 16MB range. Why the
>limitation?
As before it was in the original code. I'll look into changing it.
Michael Stewart
- Raw text -