link to full code隱式指針轉換似乎並不指向數組
我正在編寫操作系統和一部分,我需要告訴有關內存段的CPU。基本思想是我用LGDT彙編調用加載GDT寄存器。該參數是包含實際GDT大小和位置的結構的內存地址。我遇到的問題是,在GlobalDescriptorTable.h的第75行中,我將結構中的數組地址設置爲傳遞給LGDT,但是當我在結構給出的地址檢查內存時,沒有任何內容。
class GlobalDescriptorTable {
private:
GdtEntry _gdt[256];
size_t size;
GdtDescriptor gdtd;
public:
GlobalDescriptorTable() ;
GdtEntry encodeGlobalDescriptorTableEntry(uint32_t limit,
uint32_t baseAddress, Access access, Flags flags);
void load() {
//get size, -1 because Int-hell hates you
size_t sizeOfGdt = (3 * sizeof(GdtEntry)) - 1;
//get the info to tell cpu about the GDT
gdtd.size = (uint16_t)sizeOfGdt;
gdtd.location = _gdt;
asm ("LGDT %[gdtd]" : : [gdtd] "m" (gdtd));
}
};
分配作爲測試:
uint64_t temp = 0xF00FB00BEE00F0AA;
_gdt[0] = *((GdtEntry*) &temp);
任何幫助,將理解
請[**]用[mcve]或[SSCCE(Short,Self Contained,Correct Example)](http://sscce.org) – NathanOliver