Subject: Properly Identify HP4xx
To: None <port-hp300@NetBSD.ORG>
From: mike smith <miff@spam.frisbee.net.au>
List: port-hp300
Date: 04/17/1997 01:30:16
This is a multi-part message in MIME format.

--------------7DE145182F1CF0FB237C228A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Please find attached diffs to nearly-current that should make
it possble to correctly discern the difference between an
HP9000/380 and a 425.  In addition, it appears to be able
to correctly determine whether the unit is running at
25 or 33MHz (though I am not sure if this is correct).

If you have any of a 345, 375, 380, 400, 425, 433, it would 
be greatly appreciated if you could try this patch and let me 
know the MMU ID printed at startup (just after the delay 
constant).

--
Mike Smith  *BSD hack  Unix hardware collector
The question "why are the fundamental laws of nature mathematical"
invites the trivial response "because we define as fundamental those
laws which are mathematical".  Paul Davies, _The_Mind_of_God_

--------------7DE145182F1CF0FB237C228A
Content-Type: text/plain; charset=us-ascii; name="425_id.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="425_id.diff"

*** /work/sys/arch/hp300/include/cpu.h	Fri Mar 21 20:53:51 1997
--- include/cpu.h	Thu Apr 17 00:59:37 1997
***************
*** 199,208 ****
  #define	HP_340		5	/* 16Mhz 68030 */
  #define	HP_375		6	/* 50Mhz 68030+32K external cache */
  #define	HP_380		7	/* 25Mhz 68040 */
! #define HP_433		8	/* 33Mhz 68040 */
  
  #ifdef _KERNEL
  extern	int machineid;		/* CPU model */
  extern	int cpuspeed;		/* CPU speed, in MHz */
  
  extern	char *intiobase, *intiolimit;
--- 199,210 ----
  #define	HP_340		5	/* 16Mhz 68030 */
  #define	HP_375		6	/* 50Mhz 68030+32K external cache */
  #define	HP_380		7	/* 25Mhz 68040 */
! #define HP_425		9	/* 25/33Mhz 68040 */
! #define HP_433		8	/* 33Mhz 68040 (maybe also 25MHz?) */
  
  #ifdef _KERNEL
  extern	int machineid;		/* CPU model */
+ extern	int mmuid;		/* MMU model */
  extern	int cpuspeed;		/* CPU speed, in MHz */
  
  extern	char *intiobase, *intiolimit;
*** /work/sys/arch/hp300/hp300/hpux_machdep.c	Fri Mar 21 20:55:03 1997
--- hp300/hpux_machdep.c	Wed Apr 16 23:43:34 1997
***************
*** 113,119 ****
  	{ HP_360,	"360" },
  	{ HP_370,	"370" },
  	{ HP_375,	"375" },	/* includes 345 and 400 */
! 	{ HP_380,	"380" },	/* includes 425 */
  	{ HP_433,	"433" },
  	{     -1,	"3?0" },	/* unknown system (???) */
  };
--- 113,120 ----
  	{ HP_360,	"360" },
  	{ HP_370,	"370" },
  	{ HP_375,	"375" },	/* includes 345 and 400 */
! 	{ HP_380,	"380" },
! 	{ HP_425,	"425" },
  	{ HP_433,	"433" },
  	{     -1,	"3?0" },	/* unknown system (???) */
  };
***************
*** 258,263 ****
--- 259,265 ----
  		return (HPUX_SYSCONF_CPUM030);
  
  	case HP_380:
+ 	case HP_425:
  	case HP_433:
  		return (HPUX_SYSCONF_CPUM040);
  
*** /work/sys/arch/hp300/hp300/machdep.c	Fri Mar 21 20:55:03 1997
--- hp300/machdep.c	Thu Apr 17 01:08:09 1997
***************
*** 467,476 ****
  		t = "345/375 (50MHz";
  		break;
  	case HP_380:
! 		t = "380/425 (25MHz";
  		break;
  	case HP_433:
! 		t = "433 (33MHz";
  		break;
  	default:
  		printf("\nunknown machine type %d\n", machineid);
--- 467,487 ----
  		t = "345/375 (50MHz";
  		break;
  	case HP_380:
! 		t = "380 (25MHz";
! 		break;
! 	case HP_425:
! 	        if (mmuid == 5) {
! 		    t = "425 (25MHz";
! 		} else {	/* == 4 */
! 		    t = "425 (33MHz";
! 		}
  		break;
  	case HP_433:
! 	        if (mmuid == 6) {
! 		    t = "433 (33MHz";
! 		} else {	/* == 7 ??? what is this? */
! 		    t = "433 (25MHz";
! 		}
  		break;
  	default:
  		printf("\nunknown machine type %d\n", machineid);
***************
*** 518,524 ****
  	}
  	strcat(cpu_model, ")");
  	printf("%s\n", cpu_model);
! 	printf("delay constant for this cpu: %d\n", delay_divisor);
  	/*
  	 * Now that we have told the user what they have,
  	 * let them know if that machine type isn't configured.
--- 529,536 ----
  	}
  	strcat(cpu_model, ")");
  	printf("%s\n", cpu_model);
! 	printf("delay constant for this cpu: %d  MMU ID: %d\n", 
! 	       delay_divisor, mmuid & 0xff);
  	/*
  	 * Now that we have told the user what they have,
  	 * let them know if that machine type isn't configured.
***************
*** 539,544 ****
--- 551,557 ----
  #endif
  #if !defined(HP380)
  	case HP_380:
+ 	case HP_425:
  	case HP_433:
  #endif
  		panic("CPU type not configured");
*** /work/sys/arch/hp300/hp300/locore.s	Fri Mar 21 20:55:03 1997
--- hp300/locore.s	Thu Apr 17 01:24:21 1997
***************
*** 161,166 ****
--- 161,169 ----
  	btst	#16,d0			| still on?
  	jeq	Lstart1			| no, must be a 360
  	movl	#HP_375,a0@		| yes, must be a 345/375
+ 	RELOC(_mmuid, a0)
+ 	lsrl	#8,d0			| get apparent ID
+ 	movl	d0,a0@			| save MMU ID
  	jra	Lhaspac
  Lisa370:
  	movl	#HP_370,a0@		| set to 370
***************
*** 184,197 ****
  	movl	#FPU_68040,a0@		| ...and FPU
  	RELOC(_ectype, a0)
  	movl	#EC_NONE,a0@		| and no cache (for now XXX)
! 	RELOC(_machineid, a0)
  	movl	a1@(MMUCMD),d0		| read MMU register
  	lsrl	#8,d0			| get apparent ID
  	cmpb	#6,d0			| id == 6?
! 	jeq	Lis33mhz		| yes, we have a 433s
! 	movl	#HP_380,a0@		| no, we have a 380/425t
  	jra	Lstart1
! Lis33mhz:
  	movl	#HP_433,a0@		| 433s (XXX 425s returns same ID, ugh!)
  	jra	Lstart1
  Lis68020:
--- 187,211 ----
  	movl	#FPU_68040,a0@		| ...and FPU
  	RELOC(_ectype, a0)
  	movl	#EC_NONE,a0@		| and no cache (for now XXX)
! 	RELOC(_mmuid, a0)
  	movl	a1@(MMUCMD),d0		| read MMU register
  	lsrl	#8,d0			| get apparent ID
+ 	movl	d0,a0@			| save MMU ID
+ 	RELOC(_machineid, a0)
+ 	cmpb	#7,d0			| id == 7?
+ 	jeq	Lis433			| XXX 433 underclocked?
  	cmpb	#6,d0			| id == 6?
! 	jeq	Lis433			| yes, we have a 433s
! 	cmpb	#5,d0			| id == 5?
! 	jeq	Lis425			| yes, we have a 425t
! 	cmpb	#4,d0			| id == 4?
! 	jeq	Lis425			| Heh, 425t overclocked
! 	movl	#HP_380,a0@		| no, we have a 380
! 	jra	Lstart1
! Lis425:
! 	movl	#HP_425,a0@		| 425t
  	jra	Lstart1
! Lis433:
  	movl	#HP_433,a0@		| 433s (XXX 425s returns same ID, ugh!)
  	jra	Lstart1
  Lis68020:
***************
*** 2013,2022 ****
  #undef DOREBOOT
  
  	.data
! 	.globl	_machineid,_mmutype,_cputype,_ectype,_fputype
  	.globl	_protorp,_prototc
  _machineid:
  	.long	HP_320		| default to 320
  _mmutype:
  	.long	MMU_HP		| default to HP MMU
  _cputype:
--- 2027,2038 ----
  #undef DOREBOOT
  
  	.data
! 	.globl	_machineid,_mmuid,_mmutype,_cputype,_ectype,_fputype
  	.globl	_protorp,_prototc
  _machineid:
  	.long	HP_320		| default to 320
+ _mmuid:
+ 	.long	0		| default to nothing
  _mmutype:
  	.long	MMU_HP		| default to HP MMU
  _cputype:

--------------7DE145182F1CF0FB237C228A--