torb@idt.unit.no (01/18/90)
I am currently developing an operating system kernel for an 80386 based, 16 node hypercube, and I am having some trouble with the documentation. Both "80386 Programmer's Reference Manual" and "80386 System Software Writer's Guide" are ambiguous in their interpretation of the limit field in segment descriptors, so I am seeking the wisdom of the net to help me in this matter. What I want to know is the maximum segment size for a *small* segment. Both references mentioned above says both 64KB and 1MB for expand-up segments. What's right ?? I would guess 1MB since the limit field is 20 bits long. For expand down segments the references agree on 64KB as maximum for a small segment. Is this right ?? 1MB seems more logical with a 20 bit limit field. Thanks in advance Tor Brekke Email: torb@idt.unit.no
wbeebe@rtmvax.UUCP (Bill Beebe) (01/20/90)
In article <1990Jan17.164046.10641@idt.unit.no> torb@idt.unit.no () writes: > >What I want to know is the maximum segment size for a *small* segment. >Both references mentioned above says both 64KB and 1MB for expand-up >segments. What's right ?? I would guess 1MB since the limit field is >20 bits long. > >For expand down segments the references agree on 64KB as maximum for a >small segment. Is this right ?? 1MB seems more logical with a 20 >bit limit field. > In the original 286 documentation the user was advised to leave the upper word of the segment discripter as zero for 286 protected mode code. If you did that and you want to run that 286 PM code on your 386, then it will run with the the same 64K segment limit as it did on the 80286. The high descriptor word on the 386 contains additional bits for the segment base and limit size, a granularity bit, and a few other bits I can't recall because I don't have the book in front of me. I do remember that the upper word contains bits 24 to 31 of the base, and bits 16-19 of the limit. Now, if the granularity bit is clear, the limit is interpreted in units of one byte. Thus the maximum segment limit is 1 Mbyte on 1 *byte* boudaries. If the granularity bit is set, the limit is interpreted in units of 4096, or 4 Kbytes. That means a segment can have a limit of up to the full addressing range of the base address. This mechanism allows the 386 to be set up in flat mode where the base is set to zero, the limit is set to all binary ones (the highest address), and the granularity bit is set for the 4K intrepretation. So you have your choices: run the 386 like a 286 with the highest 16 bits set to zero, take advantage of the additional limit bits and the granularity bit to pick how large you want your segments to be, or run the 386 in Mot mode.