Code: Select all
__asm__(" movw $0x10, %ax \n \
movw %ax, %ds \n \
movw %ax, %es \n \
movw %ax, %ss \n \
movw %ax, %fs \n \
movw %ax, %gs \n \
ljmp $0x08, $retour \n \
retour: \n");
Code: Select all
__asm__(" movw $0x10, %ax \n \
movw %ax, %ds \n \
movw %ax, %es \n \
movw %ax, %ss \n \
movw %ax, %fs \n \
movw %ax, %gs \n \
ljmp $0x08, $retour \n \
retour: \n");
hi!wilson wrote:me, I have a problem with GDT. my bootloader correctly switches in protected mode, when I reload the GDT by my kenel (written in C) I have a bugg. the bugg is this part of codeIt nevers come back from this code, I don't know why ?? can You help me please ?Code: Select all
__asm__(" movw $0x10, %ax \n \ movw %ax, %ds \n \ movw %ax, %es \n \ movw %ax, %ss \n \ movw %ax, %fs \n \ movw %ax, %gs \n \ ljmp $0x08, $retour \n \ retour: \n");
Troll! Troll in the dungeons!lup0 wrote:develop .NET applications with Visual Basic
Code: Select all
ENTRY(start)
SECTIONS
{
.text 0x100000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data :
{
data = .; _data = .; __data = .;
*(.data)
*(.rodata)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
Code: Select all
struct struct_entry_gdt
{
u16_int limite_low;
u16_int base_low;
u8_int base_middle;
u8_int base_hight;
u8_int access;
u8_int granularity;
} __attribute__((packed));
typedef struct struct_entry_gdt gdt_entry_t;
struct gdt_ptr_struct
{
u16_int limite;
u32_int base;
} __attribute__((packed));
typedef struct gdt_ptr_struct gdt_ptr_t;
Code: Select all
void init_gdt()
{
gdt_ptr.limite = (sizeof(gdt_entry_t) * 5) - 1;
gdt_ptr.base = (u32_int)&gdt_entries;
gdt_set_gate(0, 0x0, 0x0, 0x0, 0x0); /* Null descriptor */
gdt_set_gate(1, 0x0, 0xFFFFFFFF, 0x9A, 0xCF); /* code segment */
gdt_set_gate(2, 0x0, 0xFFFFFFFF, 0x92, 0xCF); /* data segment */
gdt_set_gate(3, 0x0, 0xFFFFFFFF, 0xFA, 0xCF); /* code segment (user mode) */
gdt_set_gate(4, 0x0, 0xFFFFFFFF, 0xF2, 0xCF); /* data segment (user mode) */
memcpy((char *)0x0, (char *)gdt_entries, gdt_ptr.limite);
asm("lgdtl (gdt_ptr)");
asm(" movw $0x10, %ax \n \
movw %ax, %ds \n \
movw %ax, %es \n \
movw %ax, %fs \n \
movw %ax, %gs \n \
ljmp $0x08, $next \n \
next: \n");*/
}
void gdt_set_gate(int num, u32_int base, u32_int limite, u8_int access, u8_int gran)
{
gdt_entries[num].base_low = (base & 0xFFFF);
gdt_entries[num].base_middle = (base >> 16) & 0xFF;
gdt_entries[num].base_hight = (base >> 24) & 0xFF;
gdt_entries[num].limite_low = (limite & 0xFFFF);
gdt_entries[num].granularity = (limite >> 16) & 0x0F;
gdt_entries[num].granularity |= gran & 0xF0;
gdt_entries[num].access = access;
}
Code: Select all
memcpy((char *)0x0, (char *)gdt_entries, gdt_ptr.limite);
this line permit to copy the GDT table at the adresse 0x0 here is its prototypethepowersgang wrote:I'm almost scared to ask, but what is the purpose of this line?Code: Select all
memcpy((char *)0x0, (char *)gdt_entries, gdt_ptr.limite);
Code: Select all
memcpy( char *dest, char *src, int ln)