Check for CMOV support on boot
This commit is contained in:
		
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
objects = entry.o kernel.o task.o handler.o interrupt.o v86.o print.o tss.o dosfs/dosfs.o gdt.o usermode.o paging.o fault.o tests.o kbd.o helper.o progs.o
 | 
			
		||||
CFLAGS = -target "i486-elf" -m32 -mgeneral-regs-only -ffreestanding -march=pentium-m -fno-stack-protector -Wno-int-conversion -nostdlib -c
 | 
			
		||||
CFLAGS = -target "i686-elf" -m32 -mgeneral-regs-only -ffreestanding -march=i686 -fno-stack-protector -Wno-int-conversion -nostdlib -c
 | 
			
		||||
 | 
			
		||||
%.o: %.nasm
 | 
			
		||||
	nasm -f elf32 -o $@ $<
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										13
									
								
								kernel.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								kernel.c
									
									
									
									
									
								
							@@ -23,6 +23,11 @@ char check_sse() {
 | 
			
		||||
    asm("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(1));
 | 
			
		||||
    return (edx & (1 << 25)) != 0;
 | 
			
		||||
}
 | 
			
		||||
char check_cmov() {
 | 
			
		||||
    uint32_t eax, ebx, ecx, edx;
 | 
			
		||||
    asm("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(1));
 | 
			
		||||
    return (edx & (1 << 15)) != 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void enable_sse() {
 | 
			
		||||
    asm volatile(
 | 
			
		||||
@@ -308,6 +313,14 @@ void start() {
 | 
			
		||||
    // DL *should* be preserved
 | 
			
		||||
    uint8_t dl;
 | 
			
		||||
    asm volatile("nop":"=d"(dl));
 | 
			
		||||
 | 
			
		||||
    if (!check_cmov()) {
 | 
			
		||||
        char cmov_err[] = "NO CMOV";
 | 
			
		||||
        for (int i = 0; i < sizeof(cmov_err); i++)
 | 
			
		||||
            *(char *)&vga_text[i] = cmov_err[i];
 | 
			
		||||
        for (;;) asm volatile("hlt");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    vga_text += printByte(dl, vga_text);
 | 
			
		||||
    vga_text++;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user