diff --git a/Makefile b/Makefile index aaed139..98d2b92 100644 --- a/Makefile +++ b/Makefile @@ -172,7 +172,7 @@ $(KOBJDIR)/%.o: %.c $(INCLUDEDIR)/*/*.h $(KALEIDDIR)/*/*/*.h | $(KOBJDIR) @echo ${CL2}[$@] ${CL}Compiled.${CL3} test: all - @qemu-system-x86_64 -soundhw pcspk -rtc base=localtime -m 4G -hda $(BUILDDIR)/bin/disk.img \ + @qemu-system-x86_64 -cpu core2duo -soundhw pcspk -rtc base=localtime -m 4G -hda $(BUILDDIR)/bin/disk.img \ -d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log & test32: all diff --git a/include/kernel/cpuid.h b/include/kernel/cpuid.h index ea63172..16eb9e0 100644 --- a/include/kernel/cpuid.h +++ b/include/kernel/cpuid.h @@ -31,9 +31,6 @@ // -------------------------------------------------------------------------- // -typedef struct Registers_t Registers_t; - -// -------------------------------------------------------------------------- // // CPU features masks enum { @@ -98,13 +95,21 @@ enum { // -------------------------------------------------------------------------- // -struct Registers_t +// Issue a single request to CPUID. Fits 'intel features', for instance +// note that even if only "eax" and "edx" are of interest, other registers +// will be modified by the operation, so we need to tell the compiler about it. +static inline void CpuCpuid(int code, uint *a, uint *d) { - ulong ds; - ulong rdi, rsi, rbp, rsp, rbx, rdx, rcx, rax; - ulong intNo, errCode; - ulong rip, cs, eflags, useresp, ss; -} __attribute__((packed)); + asm volatile("cpuid":"=a"(*a),"=d"(*d):"a"(code):"ecx","ebx"); +} + +// Issue a complete request, storing general registers output as a string +static inline int CpuCpuidString(int code, uint where[4]) +{ + asm volatile("cpuid":"=a"(*where),"=b"(*(where+1)), + "=c"(*(where+3)),"=d"(*(where+2)):"a"(code)); + return (int)where[0]; +} // -------------------------------------------------------------------------- // diff --git a/kaleid/kernel/cpu/cpuf.asm b/kaleid/kernel/cpu/cpuf.asm index 232f145..98abe26 100644 --- a/kaleid/kernel/cpu/cpuf.asm +++ b/kaleid/kernel/cpu/cpuf.asm @@ -24,8 +24,3 @@ %include "kaleid/kernel/cpu/cpuf.inc" -CpuCpuid: - pushAll - mov rax, rsi - cpuid - popAll diff --git a/kaleid/kernel/cpu/cpuid.c b/kaleid/kernel/cpu/cpuid.c index c6909d2..43630b0 100644 --- a/kaleid/kernel/cpu/cpuid.c +++ b/kaleid/kernel/cpu/cpuid.c @@ -24,8 +24,9 @@ #include -char *KeGetVendorString(void) { - return "Null"; +char* CpuGetVendorString(void) { + uint where[5] = { 0 }; + return (char *)&where[1]; } diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 5a8be24..70cc1ff 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -62,7 +62,8 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg) IoGetRtcTimeChar(); IoPrintRtcTime(); - KernLog("%d\n",realKernelEnd); + extern void PrintVendorString(void); + PrintVendorString(); KeStartShell(); diff --git a/kaleid/kernel/mm/map.c b/kaleid/kernel/mm/map.c index 45334c7..93b3d6a 100644 --- a/kaleid/kernel/mm/map.c +++ b/kaleid/kernel/mm/map.c @@ -139,7 +139,7 @@ void *MmGetFirstAvailZone(void *start) { // Because the kernel is the kernel if ((ulong)start < (ulong)BtLoaderInfo.kernelEndAddr) { - return MmGetFirstAvailZone(BtLoaderInfo.kernelEndAddr); + return MmGetFirstAvailZone(BtLoaderInfo.kernelEndAddr+1); } // Search the zone where the start address is