[comp.os.minix] Intel CPU detection

nfs@notecnirp.Princeton.EDU (Norbert Schlenker) (03/13/90)

I need a large variety of testers for the enclosed routines, so I'm 
posting them here.  The routines identify the type of Intel CPU and
math coprocessor in use by a program.  My intention is to modify
/usr/lib/crtso.s to execute equivalent code at program startup, so
that programs can take advantage of the expanded instruction set in
80186+ processors.  This would be particularly useful in the library.

Andy Tanenbaum has expressed interest in this, but he insists that
the code work on every 80x86.  I have tested this on quite a number
of machines, and Bruce Evans has helped me out with some machines to
which he has access.  There are still gaps in the test coverage.

To run these routines, you must:
  - Pull the posting apart (uud, compress -d, unshar).  There will be
    three files:  test.c, cpuid.s, and fpuid.s.
  - Edit the constants at the top of test.c to reflect (approximately)
    your machine and your patience.  They are currently set up for
    30 second tests for (each of) the CPU and FPU on my Toshiba 5100,
    which is about the limit of my patience. :-)
  - Compile with:  cc -o test test.c cpuid.s fpuid.s
  - Run test.

Send me the results, please, by email.  I am particularly interested
in reports of failures, but would also like confirmation that the
successful tests that Bruce and I have run are not flukes.  When
sending a result, please describe your system (CPU/FPU) and whether
the result was seen in real mode or protected mode.  If the test
fails, either because it misdetected the type of chip(s) you run or
because the test program detected an inconsistency, please describe
the failure.

Thanks for your help.

Norbert

---------------------------------------------------------------------------
table
 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
begin 644 id.shar.Z
M'YV-9<:@>0,"#X@6(.B4F4/'Q1@%<\J0 7'BA1<L+^:\V'@"A(^$"QN. <&#z
M!\47)Q1@5 &""IHR(,R\8</FS9TT;LZ &//&#<,P;NC, 3%G8!TV$\7 #$-&y
M31V&$HD2I(,F#!T084#(*1-F3L\P8MB440F"I9LZ;93* ?'&#$B&0\-LU5K'x
M#0L08NI<]9JPZE6J,.'(>3-FX= T<]R<N%I7J5RP;/*095DSIPL0()*X8>L&w
M9AN<>LO<S1K#!H@F2/2 P %C!@[3-VG2W0SVC=[5(#[33-,3Q! H52:_%;H#v
M*XC2IU.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^&9X4g
M^';8F0#Q^9SS69^N)@/X&81(P9\#HE3!IJ44R:7.F6K1.9UA%Q,<"GZ?HJ;-f
M>6IN"J9X<)_YN9_]B:8+N('TMBBKF0!VZIU5YY_8QGDS-9J:-HZ#@9+@5B@$e
MAJ3XN*ABA(\E^GY10Q14-71(=E"S9 9SBIN#=X$5NJB887W_$A<8NIH7FD_.d
MX7X;"F(Y(6(@^GZ/&!$K-129Q5%L #-NH%GI,DL9IU-#07&#H08\F0;-=1<0c
MAQ6AV1FU,P5\Z5#D!C4L-HM9-10BL@(X0:QT,$L)4F-R,ZS7.:Y(\R]N409Qb
M0&4-R'[3IVFGZ2W%(480!W!]AI5MIIJ/68]%,)D_FEY!JI1#BA>@R96T^1("a
M Y8S)98_YA/%\1)N4!@ !W? M&,/.Y8]498PT1DV*1>SU!-G-Y6=:I05BP:#z
MX09IH <&!U/3]5SM4:1=ZJ;2Z6K4F9_I>J?R29_3B0/YB13 ")]M"IUZ6@1,y
M&A-(H0<\ZZ5$4 2Q9@0YD)\TDF@)P -Q X/3<F+@BJXL.ZY-FZ>Q-@0:0J83x
MP1!A:[336;8Q(1!SD!]8&S>>=F+G*J[OR:9X"IU0:[3Y.79.<[59BZU/DWY"w
M1@?0EK;S203V.:8Q 1=_"FR%<J@B&&=TME2*FFQG\*EI&"ULR#=6E))Y%P9Hv
MX(^+6F1S08TT$K%U=QB; 39A< 8!.()0AV=V^"D66'@%MHYN$:[I.II#X:[Pu
M>A>L>I>(5[N3JX&SZT\WH+L]1 ?""RB'X:I#^H'3%*B@=28GR :%PA3$9FP=t
0:9T&X5,LUI)5F@#XMH(* +L]s
 r
end

nfs@notecnirp.Princeton.EDU (Norbert Schlenker) (03/19/90)

In article <24855@princeton.Princeton.EDU> nfs@notecnirp.UUCP (me) writes:
>I need a large variety of testers for the enclosed routines, so I'm 
>posting them here.  The routines identify the type of Intel CPU and
>math coprocessor in use by a program...

What an uncommunicative bunch!  Are you all too busy upgrading to 1.5.x,
or doesn't anyone run Minix on Intel CPU's any more?  My plea for testers
garnered exactly 4 (!) replies.  Let's try this once more.

The current list of CPU/FPU combinations for which the detection routines
work looks like this, but I sure would like more Y's and fewer ?'s.

    CPU	    FPU	    Real    Protected
   -----   -----    ----    ---------
    8088    None      Y	       N/A
    8088    8087      Y        N/A
    8086    None      Y	       N/A
    8086    8087      ?	       N/A
    V20	    None      ?	       N/A
    V20     8087      ?        N/A
    V30	    None      Y	       N/A
    V30     8087      ?        N/A
    80188   None      ?	       N/A
    80186   None      ?	       N/A
    80286   None      Y	        Y
    80286   80287     Y	        ?
    80386   None      Y	        Y
    80386   80287     ?	        ?
    80386   80387     Y	        Y

I would particularly like to fill in the holes for 8086/8087, V20/none,
and 80286/80287 (protected mode).  Somebody on the net has to be running
these combinations, surely (nudge nudge).

Thanks for any help you can give me.

Norbert