Thank oyu two for your replies . I changed the placement of the limit1916 field, to where it was supposed to be, and now I still get #GP fault and not "virtual machine error must close" from Virtual PC, so it's good.
Here's my refreshed structure:
Code: Select all
typedef struct segmentdescriptor {
unsigned short limit1500;
unsigned short base1500;
unsigned char base2316;
unsigned type : 4;
unsigned desctype: 1;
unsigned dpl : 2;
unsigned present : 1;
unsigned limit1916: 4;
unsigned avl : 1;
unsigned l : 1;
unsigned db : 1;
unsigned g : 1;
unsigned char base3124;
} __attribute__ ((packed)) segmentdescriptor;
I don't use bitfield generally, but if the feature exist, why not using it? And it makes the code, cleaner? Bitfields makes C a higher level language than requested, imho.
Now...
Code: Select all
movw $0x10, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
movw %ax, %ss
Is this code right? Because I think Ive found the problem. It's about segment selectors. They have the segment, the TI bit, and the RPL, but I don't use that when adressing my segment registers. Do I need to? Because my code works correctly without.