print CPU serial number at boot time. After all, we have a million other flags printed, what's one more interesting one.

This commit is contained in:
explorer 2000-09-29 09:03:18 +00:00
parent 3c5d2c7fac
commit be5f26e138
1 changed files with 34 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.401 2000/09/28 18:31:36 thorpej Exp $ */
/* $NetBSD: machdep.c,v 1.402 2000/09/29 09:03:18 explorer Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@ -171,6 +171,8 @@ extern struct proc *npxproc;
char machine[] = "i386"; /* cpu "architecture" */
char machine_arch[] = "i386"; /* machine == machine_arch */
u_int cpu_serial[3];
char bootinfo[BOOTINFO_MAXSIZE];
/* Our exported CPU info; we have only one right now. */
@ -350,6 +352,14 @@ cpu_startup()
printf("cpu0: features %s\n", buf);
}
if (cpuid_level < 3)
printf("cpu0: serial number not supported\n");
else if ((cpu_feature & CPUID_PN) == 0)
printf("cpu0: serial number disabled\n");
else
printf("cpu0: serial number %08X%08X%08X\n",
cpu_serial[0], cpu_serial[1], cpu_serial[2]);
format_bytes(pbuf, sizeof(pbuf), ptoa(physmem));
printf("total memory = %s\n", pbuf);
@ -784,6 +794,22 @@ do_cpuid(u_int which, u_int *rv)
: "ebx", "ecx", "edx");
}
static void
do_cpuid_serial(u_int *serial)
{
__asm __volatile(
" movl $1,%%eax ;"
" cpuid ;"
" movl %%eax,0(%0) ;"
" movl $3,%%eax ;"
" cpuid ;"
" movl %%edx,4(%0) ;"
" movl %%ecx,8(%0) "
: /* no imputs */
: "S" (serial)
: "eax", "ebx", "ecx", "edx");
}
void
identifycpu()
{
@ -893,6 +919,13 @@ identifycpu()
}
}
/*
* If the processor serial number misfeature is present and supported,
* extract it here.
*/
if (cpuid_level >= 3 && (cpu_feature & CPUID_PN) != 0)
do_cpuid_serial(cpu_serial);
/*
* Now that we have told the user what they have,
* let them know if that machine type isn't configured.