Protected mode segmentation
Posted: Mon Sep 01, 2008 4:49 am
Okay, I just have learned (suthers...) :that if I want to access the physical address e.g. 0x100000 in pmode using GDT settings from DexOS, I have to use the "linear sel" selector (8h). In Bochs, I have confirmed it:
u 0x8:0x100000 - returns okay.
There are some cases that I must not use the "linear sel", a direct example: video driver, which would behave abnormally if DS and ES would be set to "linear sel" - 0x8 (since the chars/strings would point at completely different location).
If I don't use the "linear sel" selector and try to point to 0x100000, it will point to completely another location, because the active selector is 0x18, "sys_data", and that'll point to address 0x100000 + 0x83340 = 0x183340 .
So if I want to display contents of the first megabyte to screen using the SYS_DATA selector and using WriteS in ESI the specified pointer, I must use:
I have also learned that 0x8:0x100000 (linear) is not the same as 0x18:0x100000 (sys_data). lol. I hope the equation "LinearSelDifferential" will not change when the kernel will grow...
Ah well, just another hair-tearing course of segmentation...
u 0x8:0x100000 - returns okay.
There are some cases that I must not use the "linear sel", a direct example: video driver, which would behave abnormally if DS and ES would be set to "linear sel" - 0x8 (since the chars/strings would point at completely different location).
If I don't use the "linear sel" selector and try to point to 0x100000, it will point to completely another location, because the active selector is 0x18, "sys_data", and that'll point to address 0x100000 + 0x83340 = 0x183340 .
So if I want to display contents of the first megabyte to screen using the SYS_DATA selector and using WriteS in ESI the specified pointer, I must use:
Code: Select all
LinearSelDifferential equ 0x83340
...
mov esi,0x100000 - LinearSelDifferential
call WriteS
Ah well, just another hair-tearing course of segmentation...