X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fwcpu%2Fwcpu.c;h=39dcad7d02107b23ce0031bb8e9a0302a5bea03c;hb=6021fc3f27b895d382fbd30488ead35657e39196;hp=92b919198fb0721835678c42dcbc3bcb79247697;hpb=fb900d77df687bfa549995e15a762017c381e552;p=16.git diff --git a/src/lib/wcpu/wcpu.c b/src/lib/wcpu/wcpu.c index 92b91919..39dcad7d 100755 --- a/src/lib/wcpu/wcpu.c +++ b/src/lib/wcpu/wcpu.c @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * Copyright (C) 2012-2018 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover * * This file is part of Project 16. * @@ -21,57 +21,15 @@ */ /* tab size = 8 */ -#include "src/lib/wcpu/wcpu.h" +#include "src/lib/wcpu/16_wcpu.h" -byte detectcpu() +void main(int argc, char **argv) { - byte cputype=0; - __asm - { - PUSHF ; we gonna modify flags, so back them up - ; first check if its 8086/8088 or 80186/80188 - PUSHF ; FLAGS -> STACK - POP AX ; STACK -> AX - AND AX, 00FFFh ; clear 12-15 bits (they are always 1 on 8086/8088 and 80186/80188) - PUSH AX ; AX -> STACK - POPF ; STACK -> FLAGS - ; this is where magic happen - PUSHF ; FLAGS -> STACK - POP AX ; STACK -> AX - AND AX, 0F000h ; 0-11 bits aren't important to us - CMP AX, 0F000h ; check if all 12-15 bits are set (simple comparision) - JNE _286p ; if no, 286+ CPU - MOV cputype, 0 ; if yes, we are done, set cputype to 0 and end this - JMP _done - _286p: - ; now check if its 286 or newer - PUSHF ; FLAGS -> STACK - POP AX ; STACK -> AX - OR AX, 07000h ; set 12-14 bits (they are always cleared by 286 if its real mode) - PUSH AX ; AX -> STACK - POPF ; STACK -> FLAGS - ; this is where magic happen - PUSHF ; FLAGS -> STACK - POP AX ; STACK -> AX - TEST AX, 07000h ; check if at least 1 bit in 12-14 bits range is set (15th won't be set anyway) - JNZ _386p ; not all bits clear, its 386+ - MOV cputype, 1 ; all bits clear, its 286, we are done - JMP _done - _386p: - MOV cputype, 2 ; its 386 or newer, but we don't care if its newer at this point - _done: - POPF ; restore flags we backed up earlier - } - return cputype; -} - -#ifdef TEST -int main(int argc, char **argv) -{ - const char *cpus; - unsigned char cput; + /*const char *cpus, *fpus; + unsigned char cput, fput; - cput = detectcpu(); + cput = WCPU_detectcpu(); + fput = WCPU_detectfpu(); switch(cput) { case 0: cpus = "8086/8088 or 186/88"; break; @@ -79,8 +37,15 @@ int main(int argc, char **argv) case 2: cpus = "386 or newer"; break; default: cpus = "internal error"; break; } + + switch(fput) + { + case 0: fpus = "none"; break; + case 1: fpus = "8087"; break; + default: fpus = "internal error"; break; + } printf("detected CPU type: %s\n", cpus); - return 0; + printf("detected FPU type: %s\n", fpus);*/ + WCPU_cpufpumesg(); + //if (cpu_flags & CPU_FLAG_FPU) printf(" - With FPU\n"); } -#endif -