program to determine ROM revisions, SPARC FPU version

From: Alexander Dupuy (dupuy@hudson.cs.columbia.edu)
Date: Thu May 10 1990 - 04:41:50 CDT


Someone posted a program to either sun-spots or sun-managers which went and got
the PROM revision from kernel memory. The motivation was that since 4.1
required certain PROM revision levels, it was easier to run a program than to
run around halting workstations and typing "kb<CR>" to get the banner. Not to
mention that "kb<CR>" doesn't work with SPARCstation-1 PROMS; I don't know what
the Forth command is. Anyhow, the posted program didn't do much better on
sun4c machines than "kb<CR>", so I fixed it to work with the OPENPROMS
architecture.

But the reason I got sidetracked into this was that I was looking for a recent
posting to one of these two newsgroups about SPARC FPU versions, and how to
determine what kind of FPU (if any) you have on a Sun-4. (I know about
/usr/etc/fpuversion4, but I want detailed info on the FPU, like Weitek 123XYZ,
or TI ABC456).

Anyhow, here's the new getromrev.c.

@alex

/*
 * compile with cc -O -s -o getromrev getromrev.c -lkvm
 */

#include <sys/types.h>
#include <sys/param.h>
#ifdef OPENPROMS
#include <mon/openprom.h>
#include <nlist.h>
#else
#include <mon/sunromvec.h>
#endif
#include <fcntl.h>
#include <stdio.h>
#include <kvm.h>

#define MAXREVLEN 16
static char rev[MAXREVLEN];

main (argc, argv)
char **argv;
{
    kvm_t *kd;
    static struct sunromvec rom;
#ifdef OPENPROMS
    static struct nlist rompsym[2] = { "_romp" };
    unsigned romp;
#endif

    if ((kd = kvm_open (NULL, NULL, NULL, O_RDONLY, argv[0])) == NULL)
        exit (1);

#ifdef OPENPROMS

    if (kvm_nlist (kd, rompsym) != 0)
    {
        fprintf (stderr, "%s: \"romp\" not in kernel name list\n", argv[0]);
        exit (1);
    }

    romp = rompsym[0].n_value;

    if (kvm_read (kd, romp, &romp, sizeof (romp)) != sizeof (romp))
    {
        fprintf (stderr, "%s: ", argv[0]);
        perror ("Error reading kernel memory");
        exit (1);
    }

#endif

    if (kvm_read (kd, romp, &rom, sizeof (rom)) != sizeof (rom))
    {
        fprintf (stderr, "%s: ", argv[0]);
        perror ("Error reading kernel memory");
        exit (1);
    }

#ifdef OPENPROMS

    if (rom.v_magic != ROMVEC_MAGIC)
    {
        fprintf (stderr, "%s: couldn't find romvec\n", argv[0]);
        exit (1);
    }
    
    printf ("%d/%d.%d\n", rom.v_romvec_version,
            rom.v_mon_id >> 16, rom.v_mon_id & 0xffff);

#else

    printf ("%d/", rom.v_romvec_version - 1);

    if (kvm_read (kd, rom.v_mon_id, rev, sizeof (rev)) != sizeof (rev))
    {
        fprintf (stderr, "%s: ", argv[0]);
        perror ("Error reading kernel memory");
        exit (1);
    }

    printf ("%s\n", rev);

#endif

    exit (0);
}



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:05:57 CDT