Answer the question
In order to leave comments, you need to log in
How can I correctly read the descriptor table?
I write my kernel in C and assembler.
To build the "project: "I used the scripts from this article https://xakep.ru/2018/06/18/lets-write-a-kernel/
The problem was that when I ran the kernel in qemu via the -kernel key, everything worked fine, but when run through easyBCD on real hardware, all the text disappeared and it broke a bit.
I accidentally found out that the matter was in the descriptor table, when I changed the selector to the code segment for the interrupt gate, the code started working on real hardware, but at the same moment it stopped working on the virtual machine.
I decided that I would just set my descriptor table (at least I would try), and first of all I decided to read it, using the code below I got the address of the table, passed a pointer to the structure as an argument (the structures below.
_getGDTR:
mov eax,[esp+4]
sgdt [eax]
ret
struct GDTR{
unsigned short limit;
unsigned long addr;
};
struct SegmentDescription {
unsigned char limit_low_low;
unsigned char limit_low_hi;
unsigned char address_low_low;
unsigned char address_low_hi;
unsigned char address_middle;
unsigned char access_rights;
unsigned char limit_hi_and_flags;
unsigned char address_hi;
};
Answer the question
In order to leave comments, you need to log in
Most likely the problem is related to how the C compiler packs structures.
As long as the actions take place inside the C code, this is not so important. But if the structure is used to store data in some strict byte order format, or is not explicitly used from the outside, this already causes problems.
More:
https://m.habr.com/ru/post/142662/
PS: I asked the question myself, I answered it myself. I will not mark the answer, somehow it does not turn out beautifully, and I'm not sure that I'm right. But it seemed to help me, using the knowledge from the link above, I was able to make a working crutch (good luck?).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question