home *** CD-ROM | disk | FTP | other *** search
- // SYSTEM.H
- // (C) Anubis Software Noviembre 1994
- // Con la especial colaboración de todo el ShareWare del mundo
- // De todo corazón (Gracias)
- // NOTA:(!!! MUY IMPORTANTE !!!) esta librería debe compilarse con
- // el procesador 386 como mínimo. Sino dará un bonito error
- #ifndef SYSTEM.H
- #define SYSTEM.H
-
- #include <conio.h>
- #include <stdio.h>
- #include <string.h>
-
- #pragma inline
-
- unsigned int test_cpu(void)
- {
- unsigned char i,ii,iii,iiii;
- unsigned int total;
- asm cli
-
- asm mov al,34h
- asm out 43h,al
-
- asm xor al,al
- asm out 40h,al
- asm out 40h,al
-
- asm sti
-
- asm mov cx,1000h
- here:
- asm dec cx
- asm jnz here
-
- asm cli
-
- asm mov al,4h
- asm out 43h,al
-
- asm in al,40h
- asm mov dl,al
- asm in al,40h
- asm mov dh,al
-
- asm sti
-
- asm neg dx
-
- asm mov cl,dh
- asm and cl,11110000b
- asm shr cl,4
- asm mov iiii,cl
-
- asm mov cl,dh
- asm and cl,00001111b
- asm mov iii,cl
-
- asm mov cl,dl
- asm and cl,11110000b
- asm shr cl,4
- asm mov ii,cl
-
- asm mov cl,dl
- asm and cl,00001111b
- asm mov i,cl
-
- total=i |(ii<<4)|(iii<<8)|(iiii<<12);
- return(total);
- }// end test cpu
-
- // Esta rutina (adaptada por mí, devuelve un valor entre 0 y 8
- // correspondiendo los siguientes tipos:
- // 0 -> 8088
- // 1 -> 8086
- // 2 -> NEC V20
- // 3 -> NEC V30
- // 4 -> 80188
- // 5 -> 80186
- // 6 -> 80286
- // 7 -> 80386
- // 8 -> 80486
- unsigned int procesador(void)
- {
- unsigned int cpu;
-
- asm pushf
- asm push ds
- asm push es
- asm push cx
- asm push dx
- asm push di
- asm push si
- asm mov ax,cs
- asm mov ds,ax
- asm mov es,ax
- asm mov dl,6
- asm pushf
- asm pop ax
- asm and ax,0FFFh
- asm push ax
- asm popf
- asm pushf
- asm pop ax
- asm and ax,0F000h
- asm cmp ax,0f000h
- asm je ni286ni_super
- asm pushf
- asm pop ax
- asm or ax,7000h
- asm push ax
- asm popf
- asm pushf
- asm pop ax
- asm and ax,7000h
- asm jz cpu_hallada
- asm inc dl
- asm push dx
- asm cli
- asm mov edx,esp
- asm and esp,0FFFFh
- asm and esp,0FFFCh
- asm pushfd
- asm pop eax
- asm mov ecx,eax
- asm xor eax,40000h
- asm push eax
- asm popfd
- asm pushfd
- asm pop eax
- asm xor eax,ecx
- asm shr eax,12h
- asm and eax,1
- asm push ecx
- asm popfd
- asm mov esp,edx
- asm sti
- asm pop dx
- asm cmp ax,0
- asm je cpu_hallada
- asm inc dl
- asm jmp cpu_hallada
- ni286ni_super:
- asm mov dl,4
- asm mov ax,0FFFFh
- asm mov cl,33
- asm shl ax,cl
- asm jnz tipo_bus_proc
- asm mov dl,2
- asm mov cx,0FFFFh
- asm sti
- asm repz lodsb
- asm jcxz tipo_bus_proc
- asm xor dl,dl
- tipo_bus_proc:
- cpu_hallada:
- asm mov al,dl
- asm xor ah,ah
- asm pop si
- asm pop di
- asm pop dx
- asm pop cx
- asm pop es
- asm pop ds
- asm popf
- asm mov cpu,ax
- return(cpu);
- }// end procesador
-
-
-
- // Esta función debe devolver si la tarjeta instalad es una TRIDENT
- // Se basa en el archivo TRIDENT.TXT de las PCGPE.
- // Pero desgraciadamente no funciona asi como esperaba
- // y se cuelga.
- unsigned char trident(void)
- {
- unsigned char valor,valor1,valor2;
-
- asm mov dx,3C4h // Cogemos el valor del 3C4h
- asm in al,dx
- asm mov valor,al
-
- // asm mov dx,3C5h // Cogemos el valor del 3C5h
- // asm in ax,dx
- // asm mov valor1,ax
-
- asm mov al,0Eh // Ponemos 0Eh en 3C4h
- asm mov dx,3C4h
- asm out dx,al
-
- // asm mov ax,00h // Ponemos 00h en 3C5h
- // asm mov dx,3C5h
- // asm out dx,ax
-
- asm mov dx,3C5h //Cogemos el valor de 3C5h
- asm in al,dx
- asm mov valor2,al
-
- // asm mov ax,valor1 // Restablecemos el valor de 3C5h
- // asm mov dx,3C5h
- // asm out dx,ax
-
- asm mov al,valor // Restablecemos el valor de 3C4h
- asm mov dx,3C4h
- asm out dx,al
-
- return(valor2>=1);
- }// end trident
-
- // Esta función, determina que chip de la trident está instalado
- // si el valor devuelto es >=3 es el chip 8900
- // si no es el chip 8800
- unsigned int trident_chip(void)
- {
- unsigned char valor,valor1,valor2;
-
- asm mov dx,3C4h // Cogemos el valor del 3C4h
- asm in al,dx
- asm mov valor,al
-
- asm mov dx,3C5h // Cogemos el valor del 3C5h
- asm in al,dx
- asm mov valor1,al
-
- asm mov dx,3C4h // Ponemos 0B$ en 3C4h
- asm mov al,0Bh
- asm out dx,al
-
- asm mov dx,3C5h // Ponemos 00h en 3C5h
- asm mov al,00h
- asm out dx,al
-
- asm mov dx,3C5h // Cogemos el valor que nos interesa
- asm in al,dx
- asm mov valor2,al
-
- asm mov al,valor1 // Restablecemos el valor de 3C5h
- asm mov dx,3C5h
- asm out dx,al
-
- asm mov al,valor // Restablecemos el valor de 3C4h
- asm mov dx,3C4h
- asm out dx,al
- if(valor2>=3) return(8900);
- else return(8800);
- }// end trident_chip
-
-
-
- int main(void)
- {
- int a;
- char cadena[10];
- a=procesador();
- switch (a) {
- case 0:{strcpy(cadena,"8088");break;}
- case 1:{strcpy(cadena,"8086");break;}
- case 2:{strcpy(cadena,"NEC V20");break;}
- case 3:{strcpy(cadena,"NEC V30");break;}
- case 4:{strcpy(cadena,"80188");break;}
- case 5:{strcpy(cadena,"80186");break;}
- case 6:{strcpy(cadena,"80286");break;}
- case 7:{strcpy(cadena,"80386");break;}
- case 8:{strcpy(cadena,"80486");}
- }// end switch
- printf("\nProcesador: %s",cadena);
- a=test_cpu();
- printf("\nSpeed Test: %X %d",a,a);
- a=trident();
- printf("\nTarjeta TRIDENT : %d",a);
- a=trident_chip();
- printf("\nChip de la tarjeta TRIDENT : %d",a);
- return(0);
- }// end main
-
- #endif