1
Lowlevel-Coding / Re: Endlosschleife nach Initialisieren der GDT
« am: 10. September 2009, 23:35 »
kann man den lgdt befehl mit dem inline assembler aufrufen?
23. November 2024, 03:01
Diese Sektion erlaubt es dir alle Beiträge dieses Mitglieds zu sehen. Beachte, dass du nur solche Beiträge sehen kannst, zu denen du auch Zugriffsrechte hast.
mov esp, [_sys_stack + 2]
[BITS 32]
global start
start:
mov esp, _sys_stack
...
SECTION .bss
resb 4096
_sys_stack:
unsigned long kernelpagedir[1024] __attribute__ ((aligned (4096)));
unsigned long lowpagetable[1024] __attribute__ ((aligned (4096)));
extern void paging();
void *kernelpagedirPtr = 0;
void init_paging()
{
void *kernelpagedirPtr = 0;
void *lowpagetablePtr = 0;
int k = 0;
kernelpagedirPtr = (char *)kernelpagedir + 0x40000000;
lowpagetablePtr = (char *)lowpagetable + 0x40000000;
for (k = 0; k < 1024; k++)
{
lowpagetable[k] = (k * 4096) | 0x3;
kernelpagedir[k] = 0;
}
kernelpagedir[0] = (unsigned long)lowpagetablePtr | 0x3;
kernelpagedir[768] = (unsigned long)lowpagetablePtr | 0x3;
paging();
}
global paging
extern kernelpagedirPtr
paging:
push eax
mov eax, [kernelpagedirPtr]
mov cr3, eax
mov eax, cr0
or eax, 0x80000000
mov cr0, eax
pop eax
ret
IN:
0x00100381: mov %cr0,%eax
0x00100384: or $0x80000000,%eax
0x00100389: mov %eax,%cr0
IN:
0x0010038c: pop %eax
0x0010038d: ret
IN:
0x0010038c: pop %eax
0x0010038d: ret
check_exception old: 0xffffffff new 0xe
0: v=0e e=0000 i=0 cpl=0 IP=0008:c010038c pc=0010038c SP=0010:ffffffc8 CR2=3fffffc8
EAX=e0000011 EBX=c0106000 ECX=c0105000 EDX=003ff003
ESI=0002c736 EDI=0002c737 EBP=ffffffe8 ESP=ffffffc8
EIPc010038c EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 40000000 ffffffff 40cf9300
CS =0010 40000000 ffffffff 40cf9300
SS =0010 40000000 ffffffff 40cf9300
DS =0010 40000000 ffffffff 40cf9300
FS =0010 40000000 ffffffff 40cf9300
GS =0010 40000000 ffffffff 40cf9300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00100006 00000017
IDT= 00000000 000003ff
CR0=e0000011 CR2=3fffffc8 CR3=00105000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000400 CCD=e0000011 CCO=LOGICL
check_exception old: 0xe new 0xd
1: v=08 e=0000 i=0 cpl=0 IP=0008:c010038c pc=0010038c SP=0010:ffffffc8 EAX=e0000011
EAX=e0000011 EBX=c0106000 ECX=c0105000 EDX=003ff003
ESI=0002c736 EDI=0002c737 EBP=ffffffe8 ESP=ffffffc8
EIP=c010038c EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 40000000 ffffffff 40cf9300
CS =0010 40000000 ffffffff 40cf9300
SS =0010 40000000 ffffffff 40cf9300
DS =0010 40000000 ffffffff 40cf9300
FS =0010 40000000 ffffffff 40cf9300
GS =0010 40000000 ffffffff 40cf9300
LDT=0000 00000000 0000ffff 00008200
TR =0000 00000000 0000ffff 00008b00
GDT= 00100006 00000017
IDT= 00000000 000003ff
CR0=e0000011 CR2=3fffffc8 CR3=00105000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000400 CCD=e0000011 CCO=LOGICL
check_exception old: 0x8 new 0xd
Triple Fault