When I run my kernel in VMWare with the ?for?-loop excluded the system stalls. It doesn't reset or triple-faults, it just hangs. It writes "Hello" and hangs.
If I include the "for"-loop it write "Hello", my cpu name and "Done!".
I?ve also included my startup file, lnker script and the implementation of ?get_cpu_id?.
My main:
Code: Select all
int main()
{
int max_cpuid_call,i;
unsigned char cpu_sign[13];
init_video();
printf("Hello\n");
//for(i = 0; i < strlen(cpu_sign); i++)
//cpu_sign[i]= 0;
max_cpuid_call = get_cpu_id(cpu_sign);
cpu_sign[13] = 0;
printf("%s\n",cpu_sign);
printf("Done!");
for (;;);
return 0;
}
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(COMMON)
*(.bss)
. = ALIGN(4096);
bss_end = .;
}
end = .;
}
Code: Select all
; Switches gdt's
lgdt [gdt_ptr]
mov ax,LINEAR_DATA_SEL
mov ds,ax
mov es,ax
mov ss,ax
mov fs,ax
mov gs,ax
jmp LINEAR_CODE_SEL:sbat
sbat:
EXTERN bss, bss_end
mov edi,bss
mov ecx,bss_end
sub ecx,edi
xor eax,eax
rep stosb
mov esp,_sys_stack
call _main
jmp $
Code: Select all
push ebp
mov ebp, esp
xor eax,eax
cpuid
push eax
mov eax, [ebp + 8]
mov DWORD [eax], ebx
mov DWORD [eax + 4], edx
mov DWORD [eax + 8], ecx
pop eax
pop ebp
ret