Fix bug with clobbers of cpuid function

This commit is contained in:
mintsuki 2020-08-29 18:51:23 +02:00
parent 155362570e
commit 2150daaf9a
2 changed files with 3 additions and 2 deletions

View File

@ -1,4 +1,5 @@
CC = ../toolchain/bin/i386-elf-gcc
LD = ../toolchain/bin/i386-elf-gcc
CFLAGS = -Os -pipe -Wall -Wextra
@ -31,7 +32,7 @@ OBJ := $(C_FILES:.c=.o)
all: qloader2.bin
qloader2.bin: $(OBJ)
$(CC) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o stage2.bin
$(LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o stage2.bin
cd bootsect && nasm bootsect.asm -fbin -o ../qloader2.bin
%.o: %.c

View File

@ -20,7 +20,7 @@ int cpuid(uint32_t leaf, uint32_t subleaf,
uint32_t cpuid_max;
ASM("cpuid\n\t", "=a" (cpuid_max)
: "a" (leaf & 0x80000000)
: "rbx", "rcx", "rdx");
: "ebx", "ecx", "edx");
if (leaf > cpuid_max)
return 1;
ASM("cpuid\n\t", "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)