Linux Audio

Check our new training course

Loading...
v4.6
 
   1
   2/*    low-level asm for "intrigue" (PA8500-8700 CPU perf counters)
   3 * 
   4 *    Copyright (C) 2001 Randolph Chung <tausq at parisc-linux.org>
   5 *    Copyright (C) 2001 Hewlett-Packard (Grant Grundler)
   6 * 
   7 *    This program is free software; you can redistribute it and/or modify
   8 *    it under the terms of the GNU General Public License as published by
   9 *    the Free Software Foundation; either version 2 of the License, or
  10 *    (at your option) any later version.
  11 * 
  12 *    This program is distributed in the hope that it will be useful,
  13 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15 *    GNU General Public License for more details.
  16 * 
  17 *    You should have received a copy of the GNU General Public License
  18 *    along with this program; if not, write to the Free Software
  19 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20 */
  21
  22#include <asm/assembly.h>
  23
  24#include <linux/init.h>
  25#include <linux/linkage.h>
  26
  27#ifdef CONFIG_64BIT
  28	.level		2.0w
  29#endif /* CONFIG_64BIT */
  30
  31#define MTDIAG_1(gr)    .word 0x14201840 + gr*0x10000
  32#define MTDIAG_2(gr)    .word 0x14401840 + gr*0x10000
  33#define MFDIAG_1(gr)    .word 0x142008A0 + gr
  34#define MFDIAG_2(gr)    .word 0x144008A0 + gr
  35#define STDIAG(dr)      .word 0x14000AA0 + dr*0x200000
  36#define SFDIAG(dr)      .word 0x14000BA0 + dr*0x200000
  37#define DR2_SLOW_RET    53
  38
  39
  40;
  41; Enable the performance counters
  42;
  43; The coprocessor only needs to be enabled when
  44; starting/stopping the coprocessor with the pmenb/pmdis.
  45;
  46	.text
  47
  48ENTRY(perf_intrigue_enable_perf_counters)
  49	.proc
  50	.callinfo  frame=0,NO_CALLS
  51	.entry
  52
  53	ldi     0x20,%r25                ; load up perfmon bit
  54	mfctl   ccr,%r26                 ; get coprocessor register
  55	or      %r25,%r26,%r26             ; set bit
  56	mtctl   %r26,ccr                 ; turn on performance coprocessor
  57	pmenb                           ; enable performance monitor
  58	ssm     0,0                     ; dummy op to ensure completion
  59	sync                            ; follow ERS
  60	andcm   %r26,%r25,%r26             ; clear bit now 
  61	mtctl   %r26,ccr                 ; turn off performance coprocessor
  62	nop                             ; NOPs as specified in ERS
  63	nop
  64	nop
  65	nop
  66	nop
  67	nop
  68	nop
  69	bve    (%r2)
  70	nop
  71	.exit
  72	.procend
  73ENDPROC(perf_intrigue_enable_perf_counters)
  74
  75ENTRY(perf_intrigue_disable_perf_counters)
  76	.proc
  77	.callinfo  frame=0,NO_CALLS
  78	.entry
  79	ldi     0x20,%r25                ; load up perfmon bit
  80	mfctl   ccr,%r26                 ; get coprocessor register
  81	or      %r25,%r26,%r26             ; set bit
  82	mtctl   %r26,ccr                 ; turn on performance coprocessor
  83	pmdis                           ; disable performance monitor
  84	ssm     0,0                     ; dummy op to ensure completion
  85	andcm   %r26,%r25,%r26             ; clear bit now 
  86	bve    (%r2)
  87	mtctl   %r26,ccr                 ; turn off performance coprocessor
  88	.exit
  89	.procend
  90ENDPROC(perf_intrigue_disable_perf_counters)
  91
  92;***********************************************************************
  93;*
  94;* Name: perf_rdr_shift_in_W
  95;*
  96;* Description:
  97;*	This routine shifts data in from the RDR in arg0 and returns
  98;*	the result in ret0.  If the RDR is <= 64 bits in length, it
  99;*	is shifted shifted backup immediately.  This is to compensate
 100;*	for RDR10 which has bits that preclude PDC stack operations
 101;*	when they are in the wrong state.
 102;*
 103;* Arguments:
 104;*	arg0 : rdr to be read
 105;*	arg1 : bit length of rdr
 106;*
 107;* Returns:
 108;*	ret0 = next 64 bits of rdr data from staging register
 109;*
 110;* Register usage:
 111;*	arg0 : rdr to be read
 112;*	arg1 : bit length of rdr
 113;*	%r24  - original DR2 value
 114;*	%r1   - scratch
 115;*  %r29  - scratch
 116;*
 117;* Returns:
 118;*	ret0 = RDR data (right justified)
 119;*
 120;***********************************************************************
 121
 122ENTRY(perf_rdr_shift_in_W)
 123	.proc
 124	.callinfo frame=0,NO_CALLS
 125	.entry
 126;
 127; read(shift in) the RDR.
 128;
 129
 130; NOTE: The PCX-W ERS states that DR2_SLOW_RET must be set before any
 131; shifting is done, from or to, remote diagnose registers.
 132;
 133
 134	depdi,z		1,DR2_SLOW_RET,1,%r29
 135	MFDIAG_2	(24)
 136	or		    %r24,%r29,%r29
 137	MTDIAG_2	(29)			; set DR2_SLOW_RET
 138
 139	nop
 140	nop
 141	nop
 142	nop
 143
 144;
 145; Cacheline start (32-byte cacheline)
 146;
 147	nop
 148	nop
 149	nop
 150	extrd,u		arg1,63,6,%r1	; setup shift amount by bits to move 
 151
 152	mtsar		%r1
 153	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
 154	blr  		%r1,%r0		; branch to 8-instruction sequence
 155	nop
 156
 157;
 158; Cacheline start (32-byte cacheline)
 159;
 160
 161	;
 162	; RDR 0 sequence
 163	;
 164	SFDIAG		(0)
 165	ssm		    0,0
 166	MFDIAG_1	(28)
 167	shrpd		ret0,%r0,%sar,%r1
 168	MTDIAG_1	(1)			; mtdiag %dr1, %r1 
 169	STDIAG		(0)
 170	ssm		    0,0
 171	b,n         perf_rdr_shift_in_W_leave
 172
 173	;
 174	; RDR 1 sequence
 175	;
 176	sync
 177	ssm		    0,0
 178	SFDIAG		(1)
 179	ssm		    0,0
 180	MFDIAG_1	(28)
 181	ssm		    0,0
 182	b,n         perf_rdr_shift_in_W_leave
 183	nop
 184
 185	;
 186	; RDR 2 read sequence
 187	;
 188	SFDIAG		(2)
 189	ssm		    0,0
 190	MFDIAG_1	(28)
 191	shrpd		ret0,%r0,%sar,%r1
 192	MTDIAG_1	(1)
 193	STDIAG		(2)
 194	ssm		    0,0
 195	b,n         perf_rdr_shift_in_W_leave
 196
 197	;
 198	; RDR 3 read sequence
 199	;
 200	b,n         perf_rdr_shift_in_W_leave
 201	nop
 202	nop
 203	nop
 204	nop
 205	nop
 206	nop
 207	nop
 208
 209	;
 210	; RDR 4 read sequence
 211	;
 212	sync
 213	ssm		0,0
 214	SFDIAG		(4)
 215	ssm		0,0
 216	MFDIAG_1	(28)
 217	b,n         perf_rdr_shift_in_W_leave
 218	ssm		0,0
 219	nop
 220
 221	; 
 222	; RDR 5 read sequence
 223	;
 224	sync
 225	ssm		0,0
 226	SFDIAG		(5)
 227	ssm		0,0
 228	MFDIAG_1	(28)
 229	b,n         perf_rdr_shift_in_W_leave
 230	ssm		0,0
 231	nop
 232
 233	;
 234	; RDR 6 read sequence
 235	;
 236	sync
 237	ssm		0,0
 238	SFDIAG		(6)
 239	ssm		0,0
 240	MFDIAG_1	(28)
 241	b,n         perf_rdr_shift_in_W_leave
 242	ssm		0,0
 243	nop
 244
 245	;
 246	; RDR 7 read sequence
 247	;
 248	b,n         perf_rdr_shift_in_W_leave
 249	nop
 250	nop
 251	nop
 252	nop
 253	nop
 254	nop
 255	nop
 256
 257	;
 258	; RDR 8 read sequence
 259	;
 260	b,n         perf_rdr_shift_in_W_leave
 261	nop
 262	nop
 263	nop
 264	nop
 265	nop
 266	nop
 267	nop
 268
 269	;
 270	; RDR 9 read sequence
 271	;
 272	b,n         perf_rdr_shift_in_W_leave
 273	nop
 274	nop
 275	nop
 276	nop
 277	nop
 278	nop
 279	nop
 280
 281	;
 282	; RDR 10 read sequence
 283	;
 284	SFDIAG		(10)
 285	ssm		0,0
 286	MFDIAG_1	(28)
 287	shrpd		ret0,%r0,%sar,%r1
 288	MTDIAG_1	(1)
 289	STDIAG		(10)
 290	ssm		0,0
 291	b,n         perf_rdr_shift_in_W_leave
 292
 293	;
 294	; RDR 11 read sequence
 295	;
 296	SFDIAG		(11)
 297	ssm		0,0
 298	MFDIAG_1	(28)
 299	shrpd		ret0,%r0,%sar,%r1
 300	MTDIAG_1	(1)
 301	STDIAG		(11)
 302	ssm		0,0
 303	b,n         perf_rdr_shift_in_W_leave
 304
 305	;
 306	; RDR 12 read sequence
 307	;
 308	b,n         perf_rdr_shift_in_W_leave
 309	nop
 310	nop
 311	nop
 312	nop
 313	nop
 314	nop
 315	nop
 316
 317	;
 318	; RDR 13 read sequence
 319	;
 320	sync
 321	ssm		0,0
 322	SFDIAG		(13)
 323	ssm		0,0
 324	MFDIAG_1	(28)
 325	b,n         perf_rdr_shift_in_W_leave
 326	ssm		0,0
 327	nop
 328
 329	;
 330	; RDR 14 read sequence
 331	;
 332	SFDIAG		(14)
 333	ssm		0,0
 334	MFDIAG_1	(28)
 335	shrpd		ret0,%r0,%sar,%r1
 336	MTDIAG_1	(1)
 337	STDIAG		(14)
 338	ssm		0,0
 339	b,n         perf_rdr_shift_in_W_leave
 340
 341	;
 342	; RDR 15 read sequence
 343	;
 344	sync
 345	ssm		0,0
 346	SFDIAG		(15)
 347	ssm		0,0
 348	MFDIAG_1	(28)
 349	ssm		0,0
 350	b,n         perf_rdr_shift_in_W_leave
 351	nop
 352
 353	;
 354	; RDR 16 read sequence
 355	;
 356	sync
 357	ssm		0,0
 358	SFDIAG		(16)
 359	ssm		0,0
 360	MFDIAG_1	(28)
 361	b,n         perf_rdr_shift_in_W_leave
 362	ssm		0,0
 363	nop
 364
 365	;
 366	; RDR 17 read sequence
 367	;
 368	SFDIAG		(17)
 369	ssm		0,0
 370	MFDIAG_1	(28)
 371	shrpd		ret0,%r0,%sar,%r1
 372	MTDIAG_1	(1)
 373	STDIAG		(17)
 374	ssm		0,0
 375	b,n         perf_rdr_shift_in_W_leave
 376
 377	;
 378	; RDR 18 read sequence
 379	;
 380	SFDIAG		(18)
 381	ssm		0,0
 382	MFDIAG_1	(28)
 383	shrpd		ret0,%r0,%sar,%r1
 384	MTDIAG_1	(1)
 385	STDIAG		(18)
 386	ssm		0,0
 387	b,n         perf_rdr_shift_in_W_leave
 388
 389	;
 390	; RDR 19 read sequence
 391	;
 392	b,n         perf_rdr_shift_in_W_leave
 393	nop
 394	nop
 395	nop
 396	nop
 397	nop
 398	nop
 399	nop
 400
 401	;
 402	; RDR 20 read sequence
 403	;
 404	sync
 405	ssm		0,0
 406	SFDIAG		(20)
 407	ssm		0,0
 408	MFDIAG_1	(28)
 409	b,n         perf_rdr_shift_in_W_leave
 410	ssm		0,0
 411	nop
 412
 413	;
 414	; RDR 21 read sequence
 415	;
 416	sync
 417	ssm		0,0
 418	SFDIAG		(21)
 419	ssm		0,0
 420	MFDIAG_1	(28)
 421	b,n         perf_rdr_shift_in_W_leave
 422	ssm		0,0
 423	nop
 424
 425	;
 426	; RDR 22 read sequence
 427	;
 428	sync
 429	ssm		0,0
 430	SFDIAG		(22)
 431	ssm		0,0
 432	MFDIAG_1	(28)
 433	b,n         perf_rdr_shift_in_W_leave
 434	ssm		0,0
 435	nop
 436
 437	;
 438	; RDR 23 read sequence
 439	;
 440	sync
 441	ssm		0,0
 442	SFDIAG		(23)
 443	ssm		0,0
 444	MFDIAG_1	(28)
 445	b,n         perf_rdr_shift_in_W_leave
 446	ssm		0,0
 447	nop
 448
 449	;
 450	; RDR 24 read sequence
 451	;
 452	sync
 453	ssm		0,0
 454	SFDIAG		(24)
 455	ssm		0,0
 456	MFDIAG_1	(28)
 457	b,n         perf_rdr_shift_in_W_leave
 458	ssm		0,0
 459	nop
 460
 461	;
 462	; RDR 25 read sequence
 463	;
 464	sync
 465	ssm		0,0
 466	SFDIAG		(25)
 467	ssm		0,0
 468	MFDIAG_1	(28)
 469	b,n         perf_rdr_shift_in_W_leave
 470	ssm		0,0
 471	nop
 472
 473	;
 474	; RDR 26 read sequence
 475	;
 476	SFDIAG		(26)
 477	ssm		0,0
 478	MFDIAG_1	(28)
 479	shrpd		ret0,%r0,%sar,%r1
 480	MTDIAG_1	(1)
 481	STDIAG		(26)
 482	ssm		0,0
 483	b,n         perf_rdr_shift_in_W_leave
 484
 485	;
 486	; RDR 27 read sequence
 487	;
 488	SFDIAG		(27)
 489	ssm		0,0
 490	MFDIAG_1	(28)
 491	shrpd		ret0,%r0,%sar,%r1
 492	MTDIAG_1	(1)
 493	STDIAG		(27)
 494	ssm		0,0
 495	b,n         perf_rdr_shift_in_W_leave
 496
 497	;
 498	; RDR 28 read sequence
 499	;
 500	sync
 501	ssm		0,0
 502	SFDIAG		(28)
 503	ssm		0,0
 504	MFDIAG_1	(28)
 505	b,n         perf_rdr_shift_in_W_leave
 506	ssm		0,0
 507	nop
 508
 509	;
 510	; RDR 29 read sequence
 511	;
 512	sync
 513	ssm		0,0
 514	SFDIAG		(29)
 515	ssm		0,0
 516	MFDIAG_1	(28)
 517	b,n         perf_rdr_shift_in_W_leave
 518	ssm		0,0
 519	nop
 520
 521	;
 522	; RDR 30 read sequence
 523	;
 524	SFDIAG		(30)
 525	ssm		0,0
 526	MFDIAG_1	(28)
 527	shrpd		ret0,%r0,%sar,%r1
 528	MTDIAG_1	(1)
 529	STDIAG		(30)
 530	ssm		0,0
 531	b,n         perf_rdr_shift_in_W_leave
 532
 533	;
 534	; RDR 31 read sequence
 535	;
 536	sync
 537	ssm		0,0
 538	SFDIAG		(31)
 539	ssm		0,0
 540	MFDIAG_1	(28)
 541	nop
 542	ssm		0,0
 543	nop
 544
 545	;
 546	; Fallthrough
 547	;
 548
 549perf_rdr_shift_in_W_leave:
 550	bve		    (%r2)
 551	.exit
 552	MTDIAG_2	(24)			; restore DR2
 553	.procend
 554ENDPROC(perf_rdr_shift_in_W)
 555
 556
 557;***********************************************************************
 558;*
 559;* Name: perf_rdr_shift_out_W
 560;*
 561;* Description:
 562;*	This routine moves data to the RDR's.  The double-word that
 563;*	arg1 points to is loaded and moved into the staging register.
 564;*	Then the STDIAG instruction for the RDR # in arg0 is called
 565;*	to move the data to the RDR.
 566;*
 567;* Arguments:
 568;*	arg0 = rdr number
 569;*	arg1 = 64-bit value to write
 570;*	%r24 - DR2 | DR2_SLOW_RET
 571;*	%r23 - original DR2 value
 572;*
 573;* Returns:
 574;*	None
 575;*
 576;* Register usage:
 577;*
 578;***********************************************************************
 579
 580ENTRY(perf_rdr_shift_out_W)
 581	.proc
 582	.callinfo frame=0,NO_CALLS
 583	.entry
 584;
 585; NOTE: The PCX-W ERS states that DR2_SLOW_RET must be set before any
 586; shifting is done, from or to, the remote diagnose registers.
 587;
 588
 589	depdi,z		1,DR2_SLOW_RET,1,%r24
 590	MFDIAG_2	(23)
 591	or		%r24,%r23,%r24
 592	MTDIAG_2	(24)		; set DR2_SLOW_RET
 593	MTDIAG_1	(25)		; data to the staging register
 594	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
 595	blr		    %r1,%r0	; branch to 8-instruction sequence
 596	nop
 597
 598	;
 599	; RDR 0 write sequence
 600	;
 601	sync				; RDR 0 write sequence
 602	ssm		0,0
 603	STDIAG		(0)
 604	ssm		0,0
 605	b,n         perf_rdr_shift_out_W_leave
 606	nop
 607	ssm		0,0
 608	nop
 609
 610	;
 611	; RDR 1 write sequence
 612	;
 613	sync
 614	ssm		0,0
 615	STDIAG		(1)
 616	ssm		0,0
 617	b,n         perf_rdr_shift_out_W_leave
 618	nop
 619	ssm		0,0
 620	nop
 621
 622	;
 623	; RDR 2 write sequence
 624	;
 625	sync
 626	ssm		0,0
 627	STDIAG		(2)
 628	ssm		0,0
 629	b,n         perf_rdr_shift_out_W_leave
 630	nop
 631	ssm		0,0
 632	nop
 633
 634	;
 635	; RDR 3 write sequence
 636	;
 637	sync
 638	ssm		0,0
 639	STDIAG		(3)
 640	ssm		0,0
 641	b,n         perf_rdr_shift_out_W_leave
 642	nop
 643	ssm		0,0
 644	nop
 645
 646	;
 647	; RDR 4 write sequence
 648	;
 649	sync
 650	ssm		0,0
 651	STDIAG		(4)
 652	ssm		0,0
 653	b,n         perf_rdr_shift_out_W_leave
 654	nop
 655	ssm		0,0
 656	nop
 657
 658	;
 659	; RDR 5 write sequence
 660	;
 661	sync
 662	ssm		0,0
 663	STDIAG		(5)
 664	ssm		0,0
 665	b,n         perf_rdr_shift_out_W_leave
 666	nop
 667	ssm		0,0
 668	nop
 669
 670	;
 671	; RDR 6 write sequence
 672	;
 673	sync
 674	ssm		0,0
 675	STDIAG		(6)
 676	ssm		0,0
 677	b,n         perf_rdr_shift_out_W_leave
 678	nop
 679	ssm		0,0
 680	nop
 681
 682	;
 683	; RDR 7 write sequence
 684	;
 685	sync
 686	ssm		0,0
 687	STDIAG		(7)
 688	ssm		0,0
 689	b,n         perf_rdr_shift_out_W_leave
 690	nop
 691	ssm		0,0
 692	nop
 693
 694	;
 695	; RDR 8 write sequence
 696	;
 697	sync
 698	ssm		0,0
 699	STDIAG		(8)
 700	ssm		0,0
 701	b,n         perf_rdr_shift_out_W_leave
 702	nop
 703	ssm		0,0
 704	nop
 705
 706	;
 707	; RDR 9 write sequence
 708	;
 709	sync
 710	ssm		0,0
 711	STDIAG		(9)
 712	ssm		0,0
 713	b,n         perf_rdr_shift_out_W_leave
 714	nop
 715	ssm		0,0
 716	nop
 717
 718	;
 719	; RDR 10 write sequence
 720	;
 721	sync
 722	ssm		0,0
 723	STDIAG		(10)
 724	STDIAG		(26)
 725	ssm		0,0
 726	b,n         perf_rdr_shift_out_W_leave
 727	ssm		0,0
 728	nop
 729
 730	;
 731	; RDR 11 write sequence
 732	;
 733	sync
 734	ssm		0,0
 735	STDIAG		(11)
 736	STDIAG		(27)
 737	ssm		0,0
 738	b,n         perf_rdr_shift_out_W_leave
 739	ssm		0,0
 740	nop
 741
 742	;
 743	; RDR 12 write sequence
 744	;
 745	sync
 746	ssm		0,0
 747	STDIAG		(12)
 748	ssm		0,0
 749	b,n         perf_rdr_shift_out_W_leave
 750	nop
 751	ssm		0,0
 752	nop
 753
 754	;
 755	; RDR 13 write sequence
 756	;
 757	sync
 758	ssm		0,0
 759	STDIAG		(13)
 760	ssm		0,0
 761	b,n         perf_rdr_shift_out_W_leave
 762	nop
 763	ssm		0,0
 764	nop
 765
 766	;
 767	; RDR 14 write sequence
 768	;
 769	sync
 770	ssm		0,0
 771	STDIAG		(14)
 772	ssm		0,0
 773	b,n         perf_rdr_shift_out_W_leave
 774	nop
 775	ssm		0,0
 776	nop
 777
 778	;
 779	; RDR 15 write sequence
 780	;
 781	sync
 782	ssm		0,0
 783	STDIAG		(15)
 784	ssm		0,0
 785	b,n         perf_rdr_shift_out_W_leave
 786	nop
 787	ssm		0,0
 788	nop
 789
 790	;
 791	; RDR 16 write sequence
 792	;
 793	sync
 794	ssm		0,0
 795	STDIAG		(16)
 796	ssm		0,0
 797	b,n         perf_rdr_shift_out_W_leave
 798	nop
 799	ssm		0,0
 800	nop
 801
 802	;
 803	; RDR 17 write sequence
 804	;
 805	sync
 806	ssm		0,0
 807	STDIAG		(17)
 808	ssm		0,0
 809	b,n         perf_rdr_shift_out_W_leave
 810	nop
 811	ssm		0,0
 812	nop
 813
 814	;
 815	; RDR 18 write sequence
 816	;
 817	sync
 818	ssm		0,0
 819	STDIAG		(18)
 820	ssm		0,0
 821	b,n         perf_rdr_shift_out_W_leave
 822	nop
 823	ssm		0,0
 824	nop
 825
 826	;
 827	; RDR 19 write sequence
 828	;
 829	sync
 830	ssm		0,0
 831	STDIAG		(19)
 832	ssm		0,0
 833	b,n         perf_rdr_shift_out_W_leave
 834	nop
 835	ssm		0,0
 836	nop
 837
 838	;
 839	; RDR 20 write sequence
 840	;
 841	sync
 842	ssm		0,0
 843	STDIAG		(20)
 844	ssm		0,0
 845	b,n         perf_rdr_shift_out_W_leave
 846	nop
 847	ssm		0,0
 848	nop
 849
 850	;
 851	; RDR 21 write sequence
 852	;
 853	sync
 854	ssm		0,0
 855	STDIAG		(21)
 856	ssm		0,0
 857	b,n         perf_rdr_shift_out_W_leave
 858	nop
 859	ssm		0,0
 860	nop
 861
 862	;
 863	; RDR 22 write sequence
 864	;
 865	sync
 866	ssm		0,0
 867	STDIAG		(22)
 868	ssm		0,0
 869	b,n         perf_rdr_shift_out_W_leave
 870	nop
 871	ssm		0,0
 872	nop
 873
 874	;
 875	; RDR 23 write sequence
 876	;
 877	sync
 878	ssm		0,0
 879	STDIAG		(23)
 880	ssm		0,0
 881	b,n         perf_rdr_shift_out_W_leave
 882	nop
 883	ssm		0,0
 884	nop
 885
 886	;
 887	; RDR 24 write sequence
 888	;
 889	sync
 890	ssm		0,0
 891	STDIAG		(24)
 892	ssm		0,0
 893	b,n         perf_rdr_shift_out_W_leave
 894	nop
 895	ssm		0,0
 896	nop
 897
 898	;
 899	; RDR 25 write sequence
 900	;
 901	sync
 902	ssm		0,0
 903	STDIAG		(25)
 904	ssm		0,0
 905	b,n         perf_rdr_shift_out_W_leave
 906	nop
 907	ssm		0,0
 908	nop
 909
 910	;
 911	; RDR 26 write sequence
 912	;
 913	sync
 914	ssm		0,0
 915	STDIAG		(10)
 916	STDIAG		(26)
 917	ssm		0,0
 918	b,n         perf_rdr_shift_out_W_leave
 919	ssm		0,0
 920	nop
 921
 922	;
 923	; RDR 27 write sequence
 924	;
 925	sync
 926	ssm		0,0
 927	STDIAG		(11)
 928	STDIAG		(27)
 929	ssm		0,0
 930	b,n         perf_rdr_shift_out_W_leave
 931	ssm		0,0
 932	nop
 933
 934	;
 935	; RDR 28 write sequence
 936	;
 937	sync
 938	ssm		0,0
 939	STDIAG		(28)
 940	ssm		0,0
 941	b,n         perf_rdr_shift_out_W_leave
 942	nop
 943	ssm		0,0
 944	nop
 945
 946	;
 947	; RDR 29 write sequence
 948	;
 949	sync
 950	ssm		0,0
 951	STDIAG		(29)
 952	ssm		0,0
 953	b,n         perf_rdr_shift_out_W_leave
 954	nop
 955	ssm		0,0
 956	nop
 957
 958	;
 959	; RDR 30 write sequence
 960	;
 961	sync
 962	ssm		0,0
 963	STDIAG		(30)
 964	ssm		0,0
 965	b,n         perf_rdr_shift_out_W_leave
 966	nop
 967	ssm		0,0
 968	nop
 969
 970	;
 971	; RDR 31 write sequence
 972	;
 973	sync
 974	ssm		0,0
 975	STDIAG		(31)
 976	ssm		0,0
 977	b,n         perf_rdr_shift_out_W_leave
 978	nop
 979	ssm		0,0
 980	nop
 981
 982perf_rdr_shift_out_W_leave:
 983	bve		(%r2)
 984	.exit
 985	MTDIAG_2	(23)			; restore DR2
 986	.procend
 987ENDPROC(perf_rdr_shift_out_W)
 988
 989
 990;***********************************************************************
 991;*
 992;* Name: rdr_shift_in_U
 993;*
 994;* Description:
 995;*	This routine shifts data in from the RDR in arg0 and returns
 996;*	the result in ret0.  If the RDR is <= 64 bits in length, it
 997;*	is shifted shifted backup immediately.  This is to compensate
 998;*	for RDR10 which has bits that preclude PDC stack operations
 999;*	when they are in the wrong state.
1000;*
1001;* Arguments:
1002;*	arg0 : rdr to be read
1003;*	arg1 : bit length of rdr
1004;*
1005;* Returns:
1006;*	ret0 = next 64 bits of rdr data from staging register
1007;*
1008;* Register usage:
1009;*	arg0 : rdr to be read						                        
1010;*	arg1 : bit length of rdr					                        
1011;*	%r24 - original DR2 value
1012;*	%r23 - DR2 | DR2_SLOW_RET
1013;*	%r1  - scratch
1014;*
1015;***********************************************************************
1016
1017ENTRY(perf_rdr_shift_in_U)
1018	.proc
1019	.callinfo frame=0,NO_CALLS
1020	.entry
1021
1022; read(shift in) the RDR.
1023;
1024; NOTE: The PCX-U ERS states that DR2_SLOW_RET must be set before any
1025; shifting is done, from or to, remote diagnose registers.
1026
1027	depdi,z		1,DR2_SLOW_RET,1,%r29
1028	MFDIAG_2	(24)
1029	or			%r24,%r29,%r29
1030	MTDIAG_2	(29)			; set DR2_SLOW_RET
1031
1032	nop
1033	nop
1034	nop
1035	nop
1036
1037;
1038; Start of next 32-byte cacheline
1039;
1040	nop
1041	nop
1042	nop
1043	extrd,u		arg1,63,6,%r1
1044
1045	mtsar		%r1
1046	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
1047	blr 		%r1,%r0		; branch to 8-instruction sequence
1048	nop
1049
1050;
1051; Start of next 32-byte cacheline
1052;
1053	SFDIAG		(0)		; RDR 0 read sequence
1054	ssm		0,0
1055	MFDIAG_1	(28)
1056	shrpd		ret0,%r0,%sar,%r1
1057	MTDIAG_1	(1)
1058	STDIAG		(0)
1059	ssm		0,0
1060	b,n         perf_rdr_shift_in_U_leave
1061
1062	SFDIAG		(1)		; RDR 1 read sequence
1063	ssm		0,0
1064	MFDIAG_1	(28)
1065	shrpd		ret0,%r0,%sar,%r1
1066	MTDIAG_1	(1)
1067	STDIAG		(1)
1068	ssm		0,0
1069	b,n         perf_rdr_shift_in_U_leave
1070
1071	sync				; RDR 2 read sequence
1072	ssm		0,0
1073	SFDIAG		(4)
1074	ssm		0,0
1075	MFDIAG_1	(28)
1076	b,n         perf_rdr_shift_in_U_leave
1077	ssm		0,0
1078	nop
1079
1080	sync				; RDR 3 read sequence
1081	ssm		0,0
1082	SFDIAG		(3)
1083	ssm		0,0
1084	MFDIAG_1	(28)
1085	b,n         perf_rdr_shift_in_U_leave
1086	ssm		0,0
1087	nop
1088
1089	sync				; RDR 4 read sequence
1090	ssm		0,0
1091	SFDIAG		(4)
1092	ssm		0,0
1093	MFDIAG_1	(28)
1094	b,n         perf_rdr_shift_in_U_leave
1095	ssm		0,0
1096	nop
1097
1098	sync				; RDR 5 read sequence
1099	ssm		0,0
1100	SFDIAG		(5)
1101	ssm		0,0
1102	MFDIAG_1	(28)
1103	b,n         perf_rdr_shift_in_U_leave
1104	ssm		0,0
1105	nop
1106
1107	sync				; RDR 6 read sequence
1108	ssm		0,0
1109	SFDIAG		(6)
1110	ssm		0,0
1111	MFDIAG_1	(28)
1112	b,n         perf_rdr_shift_in_U_leave
1113	ssm		0,0
1114	nop
1115
1116	sync				; RDR 7 read sequence
1117	ssm		0,0
1118	SFDIAG		(7)
1119	ssm		0,0
1120	MFDIAG_1	(28)
1121	b,n         perf_rdr_shift_in_U_leave
1122	ssm		0,0
1123	nop
1124
1125	b,n         perf_rdr_shift_in_U_leave
1126	nop
1127	nop
1128	nop
1129	nop
1130	nop
1131	nop
1132	nop
1133
1134	SFDIAG		(9)		; RDR 9 read sequence
1135	ssm		0,0
1136	MFDIAG_1	(28)
1137	shrpd		ret0,%r0,%sar,%r1
1138	MTDIAG_1	(1)
1139	STDIAG		(9)
1140	ssm		0,0
1141	b,n         perf_rdr_shift_in_U_leave
1142
1143	SFDIAG		(10)		; RDR 10 read sequence
1144	ssm		0,0
1145	MFDIAG_1	(28)
1146	shrpd		ret0,%r0,%sar,%r1
1147	MTDIAG_1	(1)
1148	STDIAG		(10)
1149	ssm		0,0
1150	b,n         perf_rdr_shift_in_U_leave
1151
1152	SFDIAG		(11)		; RDR 11 read sequence
1153	ssm		0,0
1154	MFDIAG_1	(28)
1155	shrpd		ret0,%r0,%sar,%r1
1156	MTDIAG_1	(1)
1157	STDIAG		(11)
1158	ssm		0,0
1159	b,n         perf_rdr_shift_in_U_leave
1160
1161	SFDIAG		(12)		; RDR 12 read sequence
1162	ssm		0,0
1163	MFDIAG_1	(28)
1164	shrpd		ret0,%r0,%sar,%r1
1165	MTDIAG_1	(1)
1166	STDIAG		(12)
1167	ssm		0,0
1168	b,n         perf_rdr_shift_in_U_leave
1169
1170	SFDIAG		(13)		; RDR 13 read sequence
1171	ssm		0,0
1172	MFDIAG_1	(28)
1173	shrpd		ret0,%r0,%sar,%r1
1174	MTDIAG_1	(1)
1175	STDIAG		(13)
1176	ssm		0,0
1177	b,n         perf_rdr_shift_in_U_leave
1178
1179	SFDIAG		(14)		; RDR 14 read sequence
1180	ssm		0,0
1181	MFDIAG_1	(28)
1182	shrpd		ret0,%r0,%sar,%r1
1183	MTDIAG_1	(1)
1184	STDIAG		(14)
1185	ssm		0,0
1186	b,n         perf_rdr_shift_in_U_leave
1187
1188	SFDIAG		(15)		; RDR 15 read sequence
1189	ssm		0,0
1190	MFDIAG_1	(28)
1191	shrpd		ret0,%r0,%sar,%r1
1192	MTDIAG_1	(1)
1193	STDIAG		(15)
1194	ssm		0,0
1195	b,n         perf_rdr_shift_in_U_leave
1196
1197	sync				; RDR 16 read sequence
1198	ssm		0,0
1199	SFDIAG		(16)
1200	ssm		0,0
1201	MFDIAG_1	(28)
1202	b,n         perf_rdr_shift_in_U_leave
1203	ssm		0,0
1204	nop
1205
1206	SFDIAG		(17)		; RDR 17 read sequence
1207	ssm		0,0
1208	MFDIAG_1	(28)
1209	shrpd		ret0,%r0,%sar,%r1
1210	MTDIAG_1	(1)
1211	STDIAG		(17)
1212	ssm		0,0
1213	b,n         perf_rdr_shift_in_U_leave
1214
1215	SFDIAG		(18)		; RDR 18 read sequence
1216	ssm		0,0
1217	MFDIAG_1	(28)
1218	shrpd		ret0,%r0,%sar,%r1
1219	MTDIAG_1	(1)
1220	STDIAG		(18)
1221	ssm		0,0
1222	b,n         perf_rdr_shift_in_U_leave
1223
1224	b,n         perf_rdr_shift_in_U_leave
1225	nop
1226	nop
1227	nop
1228	nop
1229	nop
1230	nop
1231	nop
1232
1233	sync				; RDR 20 read sequence
1234	ssm		0,0
1235	SFDIAG		(20)
1236	ssm		0,0
1237	MFDIAG_1	(28)
1238	b,n         perf_rdr_shift_in_U_leave
1239	ssm		0,0
1240	nop
1241
1242	sync				; RDR 21 read sequence
1243	ssm		0,0
1244	SFDIAG		(21)
1245	ssm		0,0
1246	MFDIAG_1	(28)
1247	b,n         perf_rdr_shift_in_U_leave
1248	ssm		0,0
1249	nop
1250
1251	sync				; RDR 22 read sequence
1252	ssm		0,0
1253	SFDIAG		(22)
1254	ssm		0,0
1255	MFDIAG_1	(28)
1256	b,n         perf_rdr_shift_in_U_leave
1257	ssm		0,0
1258	nop
1259
1260	sync				; RDR 23 read sequence
1261	ssm		0,0
1262	SFDIAG		(23)
1263	ssm		0,0
1264	MFDIAG_1	(28)
1265	b,n         perf_rdr_shift_in_U_leave
1266	ssm		0,0
1267	nop
1268
1269	sync				; RDR 24 read sequence
1270	ssm		0,0
1271	SFDIAG		(24)
1272	ssm		0,0
1273	MFDIAG_1	(28)
1274	b,n         perf_rdr_shift_in_U_leave
1275	ssm		0,0
1276	nop
1277
1278	sync				; RDR 25 read sequence
1279	ssm		0,0
1280	SFDIAG		(25)
1281	ssm		0,0
1282	MFDIAG_1	(28)
1283	b,n         perf_rdr_shift_in_U_leave
1284	ssm		0,0
1285	nop
1286
1287	SFDIAG		(26)		; RDR 26 read sequence
1288	ssm		0,0
1289	MFDIAG_1	(28)
1290	shrpd		ret0,%r0,%sar,%r1
1291	MTDIAG_1	(1)
1292	STDIAG		(26)
1293	ssm		0,0
1294	b,n         perf_rdr_shift_in_U_leave
1295
1296	SFDIAG		(27)		; RDR 27 read sequence
1297	ssm		0,0
1298	MFDIAG_1	(28)
1299	shrpd		ret0,%r0,%sar,%r1
1300	MTDIAG_1	(1)
1301	STDIAG		(27)
1302	ssm		0,0
1303	b,n         perf_rdr_shift_in_U_leave
1304
1305	sync				; RDR 28 read sequence
1306	ssm		0,0
1307	SFDIAG		(28)
1308	ssm		0,0
1309	MFDIAG_1	(28)
1310	b,n         perf_rdr_shift_in_U_leave
1311	ssm		0,0
1312	nop
1313
1314	b,n         perf_rdr_shift_in_U_leave
1315	nop
1316	nop
1317	nop
1318	nop
1319	nop
1320	nop
1321	nop
1322
1323	SFDIAG		(30)		; RDR 30 read sequence
1324	ssm		0,0
1325	MFDIAG_1	(28)
1326	shrpd		ret0,%r0,%sar,%r1
1327	MTDIAG_1	(1)
1328	STDIAG		(30)
1329	ssm		0,0
1330	b,n         perf_rdr_shift_in_U_leave
1331
1332	SFDIAG		(31)		; RDR 31 read sequence
1333	ssm		0,0
1334	MFDIAG_1	(28)
1335	shrpd		ret0,%r0,%sar,%r1
1336	MTDIAG_1	(1)
1337	STDIAG		(31)
1338	ssm		0,0
1339	b,n         perf_rdr_shift_in_U_leave
1340	nop
1341
1342perf_rdr_shift_in_U_leave:
1343	bve		    (%r2)
1344	.exit
1345	MTDIAG_2	(24)			; restore DR2
1346	.procend
1347ENDPROC(perf_rdr_shift_in_U)
1348
1349;***********************************************************************
1350;*
1351;* Name: rdr_shift_out_U
1352;*
1353;* Description:
1354;*	This routine moves data to the RDR's.  The double-word that
1355;*	arg1 points to is loaded and moved into the staging register.
1356;*	Then the STDIAG instruction for the RDR # in arg0 is called
1357;*	to move the data to the RDR.
1358;*
1359;* Arguments:
1360;*	arg0 = rdr target
1361;*	arg1 = buffer pointer
1362;*
1363;* Returns:
1364;*	None
1365;*
1366;* Register usage:
1367;*	arg0 = rdr target
1368;*	arg1 = buffer pointer
1369;*	%r24 - DR2 | DR2_SLOW_RET
1370;*	%r23 - original DR2 value
1371;*
1372;***********************************************************************
1373
1374ENTRY(perf_rdr_shift_out_U)
1375	.proc
1376	.callinfo frame=0,NO_CALLS
1377	.entry
1378
1379;
1380; NOTE: The PCX-U ERS states that DR2_SLOW_RET must be set before any
1381; shifting is done, from or to, the remote diagnose registers.
1382;
1383
1384	depdi,z		1,DR2_SLOW_RET,1,%r24
1385	MFDIAG_2	(23)
1386	or		%r24,%r23,%r24
1387	MTDIAG_2	(24)		; set DR2_SLOW_RET
1388
1389	MTDIAG_1	(25)		; data to the staging register
1390	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
1391	blr		%r1,%r0		; branch to 8-instruction sequence
1392	nop
1393
1394;
1395; 32-byte cachline aligned
1396;
1397
1398	sync				; RDR 0 write sequence
1399	ssm		0,0
1400	STDIAG		(0)
1401	ssm		0,0
1402	b,n         perf_rdr_shift_out_U_leave
1403	nop
1404	ssm		0,0
1405	nop
1406
1407	sync				; RDR 1 write sequence
1408	ssm		0,0
1409	STDIAG		(1)
1410	ssm		0,0
1411	b,n         perf_rdr_shift_out_U_leave
1412	nop
1413	ssm		0,0
1414	nop
1415
1416	sync				; RDR 2 write sequence
1417	ssm		0,0
1418	STDIAG		(2)
1419	ssm		0,0
1420	b,n         perf_rdr_shift_out_U_leave
1421	nop
1422	ssm		0,0
1423	nop
1424
1425	sync				; RDR 3 write sequence
1426	ssm		0,0
1427	STDIAG		(3)
1428	ssm		0,0
1429	b,n         perf_rdr_shift_out_U_leave
1430	nop
1431	ssm		0,0
1432	nop
1433
1434	sync				; RDR 4 write sequence
1435	ssm		0,0
1436	STDIAG		(4)
1437	ssm		0,0
1438	b,n         perf_rdr_shift_out_U_leave
1439	nop
1440	ssm		0,0
1441	nop
1442
1443	sync				; RDR 5 write sequence
1444	ssm		0,0
1445	STDIAG		(5)
1446	ssm		0,0
1447	b,n         perf_rdr_shift_out_U_leave
1448	nop
1449	ssm		0,0
1450	nop
1451
1452	sync				; RDR 6 write sequence
1453	ssm		0,0
1454	STDIAG		(6)
1455	ssm		0,0
1456	b,n         perf_rdr_shift_out_U_leave
1457	nop
1458	ssm		0,0
1459	nop
1460
1461	sync				; RDR 7 write sequence
1462	ssm		0,0
1463	STDIAG		(7)
1464	ssm		0,0
1465	b,n         perf_rdr_shift_out_U_leave
1466	nop
1467	ssm		0,0
1468	nop
1469
1470	sync				; RDR 8 write sequence
1471	ssm		0,0
1472	STDIAG		(8)
1473	ssm		0,0
1474	b,n         perf_rdr_shift_out_U_leave
1475	nop
1476	ssm		0,0
1477	nop
1478
1479	sync				; RDR 9 write sequence
1480	ssm		0,0
1481	STDIAG		(9)
1482	ssm		0,0
1483	b,n         perf_rdr_shift_out_U_leave
1484	nop
1485	ssm		0,0
1486	nop
1487
1488	sync				; RDR 10 write sequence
1489	ssm		0,0
1490	STDIAG		(10)
1491	ssm		0,0
1492	b,n         perf_rdr_shift_out_U_leave
1493	nop
1494	ssm		0,0
1495	nop
1496
1497	sync				; RDR 11 write sequence
1498	ssm		0,0
1499	STDIAG		(11)
1500	ssm		0,0
1501	b,n         perf_rdr_shift_out_U_leave
1502	nop
1503	ssm		0,0
1504	nop
1505
1506	sync				; RDR 12 write sequence
1507	ssm		0,0
1508	STDIAG		(12)
1509	ssm		0,0
1510	b,n         perf_rdr_shift_out_U_leave
1511	nop
1512	ssm		0,0
1513	nop
1514
1515	sync				; RDR 13 write sequence
1516	ssm		0,0
1517	STDIAG		(13)
1518	ssm		0,0
1519	b,n         perf_rdr_shift_out_U_leave
1520	nop
1521	ssm		0,0
1522	nop
1523
1524	sync				; RDR 14 write sequence
1525	ssm		0,0
1526	STDIAG		(14)
1527	ssm		0,0
1528	b,n         perf_rdr_shift_out_U_leave
1529	nop
1530	ssm		0,0
1531	nop
1532
1533	sync				; RDR 15 write sequence
1534	ssm		0,0
1535	STDIAG		(15)
1536	ssm		0,0
1537	b,n         perf_rdr_shift_out_U_leave
1538	nop
1539	ssm		0,0
1540	nop
1541
1542	sync				; RDR 16 write sequence
1543	ssm		0,0
1544	STDIAG		(16)
1545	ssm		0,0
1546	b,n         perf_rdr_shift_out_U_leave
1547	nop
1548	ssm		0,0
1549	nop
1550
1551	sync				; RDR 17 write sequence
1552	ssm		0,0
1553	STDIAG		(17)
1554	ssm		0,0
1555	b,n         perf_rdr_shift_out_U_leave
1556	nop
1557	ssm		0,0
1558	nop
1559
1560	sync				; RDR 18 write sequence
1561	ssm		0,0
1562	STDIAG		(18)
1563	ssm		0,0
1564	b,n         perf_rdr_shift_out_U_leave
1565	nop
1566	ssm		0,0
1567	nop
1568
1569	sync				; RDR 19 write sequence
1570	ssm		0,0
1571	STDIAG		(19)
1572	ssm		0,0
1573	b,n         perf_rdr_shift_out_U_leave
1574	nop
1575	ssm		0,0
1576	nop
1577
1578	sync				; RDR 20 write sequence
1579	ssm		0,0
1580	STDIAG		(20)
1581	ssm		0,0
1582	b,n         perf_rdr_shift_out_U_leave
1583	nop
1584	ssm		0,0
1585	nop
1586
1587	sync				; RDR 21 write sequence
1588	ssm		0,0
1589	STDIAG		(21)
1590	ssm		0,0
1591	b,n         perf_rdr_shift_out_U_leave
1592	nop
1593	ssm		0,0
1594	nop
1595
1596	sync				; RDR 22 write sequence
1597	ssm		0,0
1598	STDIAG		(22)
1599	ssm		0,0
1600	b,n         perf_rdr_shift_out_U_leave
1601	nop
1602	ssm		0,0
1603	nop
1604
1605	sync				; RDR 23 write sequence
1606	ssm		0,0
1607	STDIAG		(23)
1608	ssm		0,0
1609	b,n         perf_rdr_shift_out_U_leave
1610	nop
1611	ssm		0,0
1612	nop
1613
1614	sync				; RDR 24 write sequence
1615	ssm		0,0
1616	STDIAG		(24)
1617	ssm		0,0
1618	b,n         perf_rdr_shift_out_U_leave
1619	nop
1620	ssm		0,0
1621	nop
1622
1623	sync				; RDR 25 write sequence
1624	ssm		0,0
1625	STDIAG		(25)
1626	ssm		0,0
1627	b,n         perf_rdr_shift_out_U_leave
1628	nop
1629	ssm		0,0
1630	nop
1631
1632	sync				; RDR 26 write sequence
1633	ssm		0,0
1634	STDIAG		(26)
1635	ssm		0,0
1636	b,n         perf_rdr_shift_out_U_leave
1637	nop
1638	ssm		0,0
1639	nop
1640
1641	sync				; RDR 27 write sequence
1642	ssm		0,0
1643	STDIAG		(27)
1644	ssm		0,0
1645	b,n         perf_rdr_shift_out_U_leave
1646	nop
1647	ssm		0,0
1648	nop
1649
1650	sync				; RDR 28 write sequence
1651	ssm		0,0
1652	STDIAG		(28)
1653	ssm		0,0
1654	b,n         perf_rdr_shift_out_U_leave
1655	nop
1656	ssm		0,0
1657	nop
1658
1659	sync				; RDR 29 write sequence
1660	ssm		0,0
1661	STDIAG		(29)
1662	ssm		0,0
1663	b,n         perf_rdr_shift_out_U_leave
1664	nop
1665	ssm		0,0
1666	nop
1667
1668	sync				; RDR 30 write sequence
1669	ssm		0,0
1670	STDIAG		(30)
1671	ssm		0,0
1672	b,n         perf_rdr_shift_out_U_leave
1673	nop
1674	ssm		0,0
1675	nop
1676
1677	sync				; RDR 31 write sequence
1678	ssm		0,0
1679	STDIAG		(31)
1680	ssm		0,0
1681	b,n         perf_rdr_shift_out_U_leave
1682	nop
1683	ssm		0,0
1684	nop
1685
1686perf_rdr_shift_out_U_leave:
1687	bve		(%r2)
1688	.exit
1689	MTDIAG_2	(23)			; restore DR2
1690	.procend
1691ENDPROC(perf_rdr_shift_out_U)
1692
v6.2
   1/* SPDX-License-Identifier: GPL-2.0-or-later */
   2
   3/*    low-level asm for "intrigue" (PA8500-8700 CPU perf counters)
   4 * 
   5 *    Copyright (C) 2001 Randolph Chung <tausq at parisc-linux.org>
   6 *    Copyright (C) 2001 Hewlett-Packard (Grant Grundler)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
   7 */
   8
   9#include <asm/assembly.h>
  10
  11#include <linux/init.h>
  12#include <linux/linkage.h>
  13
  14#ifdef CONFIG_64BIT
  15	.level		2.0w
  16#endif /* CONFIG_64BIT */
  17
  18#define MTDIAG_1(gr)    .word 0x14201840 + gr*0x10000
  19#define MTDIAG_2(gr)    .word 0x14401840 + gr*0x10000
  20#define MFDIAG_1(gr)    .word 0x142008A0 + gr
  21#define MFDIAG_2(gr)    .word 0x144008A0 + gr
  22#define STDIAG(dr)      .word 0x14000AA0 + dr*0x200000
  23#define SFDIAG(dr)      .word 0x14000BA0 + dr*0x200000
  24#define DR2_SLOW_RET    53
  25
  26
  27;
  28; Enable the performance counters
  29;
  30; The coprocessor only needs to be enabled when
  31; starting/stopping the coprocessor with the pmenb/pmdis.
  32;
  33	.text
  34
  35ENTRY(perf_intrigue_enable_perf_counters)
  36	.proc
  37	.callinfo  frame=0,NO_CALLS
  38	.entry
  39
  40	ldi     0x20,%r25                ; load up perfmon bit
  41	mfctl   ccr,%r26                 ; get coprocessor register
  42	or      %r25,%r26,%r26             ; set bit
  43	mtctl   %r26,ccr                 ; turn on performance coprocessor
  44	pmenb                           ; enable performance monitor
  45	ssm     0,0                     ; dummy op to ensure completion
  46	sync                            ; follow ERS
  47	andcm   %r26,%r25,%r26             ; clear bit now 
  48	mtctl   %r26,ccr                 ; turn off performance coprocessor
  49	nop                             ; NOPs as specified in ERS
  50	nop
  51	nop
  52	nop
  53	nop
  54	nop
  55	nop
  56	bve    (%r2)
  57	nop
  58	.exit
  59	.procend
  60ENDPROC(perf_intrigue_enable_perf_counters)
  61
  62ENTRY(perf_intrigue_disable_perf_counters)
  63	.proc
  64	.callinfo  frame=0,NO_CALLS
  65	.entry
  66	ldi     0x20,%r25                ; load up perfmon bit
  67	mfctl   ccr,%r26                 ; get coprocessor register
  68	or      %r25,%r26,%r26             ; set bit
  69	mtctl   %r26,ccr                 ; turn on performance coprocessor
  70	pmdis                           ; disable performance monitor
  71	ssm     0,0                     ; dummy op to ensure completion
  72	andcm   %r26,%r25,%r26             ; clear bit now 
  73	bve    (%r2)
  74	mtctl   %r26,ccr                 ; turn off performance coprocessor
  75	.exit
  76	.procend
  77ENDPROC(perf_intrigue_disable_perf_counters)
  78
  79;***********************************************************************
  80;*
  81;* Name: perf_rdr_shift_in_W
  82;*
  83;* Description:
  84;*	This routine shifts data in from the RDR in arg0 and returns
  85;*	the result in ret0.  If the RDR is <= 64 bits in length, it
  86;*	is shifted shifted backup immediately.  This is to compensate
  87;*	for RDR10 which has bits that preclude PDC stack operations
  88;*	when they are in the wrong state.
  89;*
  90;* Arguments:
  91;*	arg0 : rdr to be read
  92;*	arg1 : bit length of rdr
  93;*
  94;* Returns:
  95;*	ret0 = next 64 bits of rdr data from staging register
  96;*
  97;* Register usage:
  98;*	arg0 : rdr to be read
  99;*	arg1 : bit length of rdr
 100;*	%r24  - original DR2 value
 101;*	%r1   - scratch
 102;*  %r29  - scratch
 103;*
 104;* Returns:
 105;*	ret0 = RDR data (right justified)
 106;*
 107;***********************************************************************
 108
 109ENTRY(perf_rdr_shift_in_W)
 110	.proc
 111	.callinfo frame=0,NO_CALLS
 112	.entry
 113;
 114; read(shift in) the RDR.
 115;
 116
 117; NOTE: The PCX-W ERS states that DR2_SLOW_RET must be set before any
 118; shifting is done, from or to, remote diagnose registers.
 119;
 120
 121	depdi,z		1,DR2_SLOW_RET,1,%r29
 122	MFDIAG_2	(24)
 123	or		    %r24,%r29,%r29
 124	MTDIAG_2	(29)			; set DR2_SLOW_RET
 125
 126	nop
 127	nop
 128	nop
 129	nop
 130
 131;
 132; Cacheline start (32-byte cacheline)
 133;
 134	nop
 135	nop
 136	nop
 137	extrd,u		arg1,63,6,%r1	; setup shift amount by bits to move 
 138
 139	mtsar		%r1
 140	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
 141	blr  		%r1,%r0		; branch to 8-instruction sequence
 142	nop
 143
 144;
 145; Cacheline start (32-byte cacheline)
 146;
 147
 148	;
 149	; RDR 0 sequence
 150	;
 151	SFDIAG		(0)
 152	ssm		    0,0
 153	MFDIAG_1	(28)
 154	shrpd		ret0,%r0,%sar,%r1
 155	MTDIAG_1	(1)			; mtdiag %dr1, %r1 
 156	STDIAG		(0)
 157	ssm		    0,0
 158	b,n         perf_rdr_shift_in_W_leave
 159
 160	;
 161	; RDR 1 sequence
 162	;
 163	sync
 164	ssm		    0,0
 165	SFDIAG		(1)
 166	ssm		    0,0
 167	MFDIAG_1	(28)
 168	ssm		    0,0
 169	b,n         perf_rdr_shift_in_W_leave
 170	nop
 171
 172	;
 173	; RDR 2 read sequence
 174	;
 175	SFDIAG		(2)
 176	ssm		    0,0
 177	MFDIAG_1	(28)
 178	shrpd		ret0,%r0,%sar,%r1
 179	MTDIAG_1	(1)
 180	STDIAG		(2)
 181	ssm		    0,0
 182	b,n         perf_rdr_shift_in_W_leave
 183
 184	;
 185	; RDR 3 read sequence
 186	;
 187	b,n         perf_rdr_shift_in_W_leave
 188	nop
 189	nop
 190	nop
 191	nop
 192	nop
 193	nop
 194	nop
 195
 196	;
 197	; RDR 4 read sequence
 198	;
 199	sync
 200	ssm		0,0
 201	SFDIAG		(4)
 202	ssm		0,0
 203	MFDIAG_1	(28)
 204	b,n         perf_rdr_shift_in_W_leave
 205	ssm		0,0
 206	nop
 207
 208	; 
 209	; RDR 5 read sequence
 210	;
 211	sync
 212	ssm		0,0
 213	SFDIAG		(5)
 214	ssm		0,0
 215	MFDIAG_1	(28)
 216	b,n         perf_rdr_shift_in_W_leave
 217	ssm		0,0
 218	nop
 219
 220	;
 221	; RDR 6 read sequence
 222	;
 223	sync
 224	ssm		0,0
 225	SFDIAG		(6)
 226	ssm		0,0
 227	MFDIAG_1	(28)
 228	b,n         perf_rdr_shift_in_W_leave
 229	ssm		0,0
 230	nop
 231
 232	;
 233	; RDR 7 read sequence
 234	;
 235	b,n         perf_rdr_shift_in_W_leave
 236	nop
 237	nop
 238	nop
 239	nop
 240	nop
 241	nop
 242	nop
 243
 244	;
 245	; RDR 8 read sequence
 246	;
 247	b,n         perf_rdr_shift_in_W_leave
 248	nop
 249	nop
 250	nop
 251	nop
 252	nop
 253	nop
 254	nop
 255
 256	;
 257	; RDR 9 read sequence
 258	;
 259	b,n         perf_rdr_shift_in_W_leave
 260	nop
 261	nop
 262	nop
 263	nop
 264	nop
 265	nop
 266	nop
 267
 268	;
 269	; RDR 10 read sequence
 270	;
 271	SFDIAG		(10)
 272	ssm		0,0
 273	MFDIAG_1	(28)
 274	shrpd		ret0,%r0,%sar,%r1
 275	MTDIAG_1	(1)
 276	STDIAG		(10)
 277	ssm		0,0
 278	b,n         perf_rdr_shift_in_W_leave
 279
 280	;
 281	; RDR 11 read sequence
 282	;
 283	SFDIAG		(11)
 284	ssm		0,0
 285	MFDIAG_1	(28)
 286	shrpd		ret0,%r0,%sar,%r1
 287	MTDIAG_1	(1)
 288	STDIAG		(11)
 289	ssm		0,0
 290	b,n         perf_rdr_shift_in_W_leave
 291
 292	;
 293	; RDR 12 read sequence
 294	;
 295	b,n         perf_rdr_shift_in_W_leave
 296	nop
 297	nop
 298	nop
 299	nop
 300	nop
 301	nop
 302	nop
 303
 304	;
 305	; RDR 13 read sequence
 306	;
 307	sync
 308	ssm		0,0
 309	SFDIAG		(13)
 310	ssm		0,0
 311	MFDIAG_1	(28)
 312	b,n         perf_rdr_shift_in_W_leave
 313	ssm		0,0
 314	nop
 315
 316	;
 317	; RDR 14 read sequence
 318	;
 319	SFDIAG		(14)
 320	ssm		0,0
 321	MFDIAG_1	(28)
 322	shrpd		ret0,%r0,%sar,%r1
 323	MTDIAG_1	(1)
 324	STDIAG		(14)
 325	ssm		0,0
 326	b,n         perf_rdr_shift_in_W_leave
 327
 328	;
 329	; RDR 15 read sequence
 330	;
 331	sync
 332	ssm		0,0
 333	SFDIAG		(15)
 334	ssm		0,0
 335	MFDIAG_1	(28)
 336	ssm		0,0
 337	b,n         perf_rdr_shift_in_W_leave
 338	nop
 339
 340	;
 341	; RDR 16 read sequence
 342	;
 343	sync
 344	ssm		0,0
 345	SFDIAG		(16)
 346	ssm		0,0
 347	MFDIAG_1	(28)
 348	b,n         perf_rdr_shift_in_W_leave
 349	ssm		0,0
 350	nop
 351
 352	;
 353	; RDR 17 read sequence
 354	;
 355	SFDIAG		(17)
 356	ssm		0,0
 357	MFDIAG_1	(28)
 358	shrpd		ret0,%r0,%sar,%r1
 359	MTDIAG_1	(1)
 360	STDIAG		(17)
 361	ssm		0,0
 362	b,n         perf_rdr_shift_in_W_leave
 363
 364	;
 365	; RDR 18 read sequence
 366	;
 367	SFDIAG		(18)
 368	ssm		0,0
 369	MFDIAG_1	(28)
 370	shrpd		ret0,%r0,%sar,%r1
 371	MTDIAG_1	(1)
 372	STDIAG		(18)
 373	ssm		0,0
 374	b,n         perf_rdr_shift_in_W_leave
 375
 376	;
 377	; RDR 19 read sequence
 378	;
 379	b,n         perf_rdr_shift_in_W_leave
 380	nop
 381	nop
 382	nop
 383	nop
 384	nop
 385	nop
 386	nop
 387
 388	;
 389	; RDR 20 read sequence
 390	;
 391	sync
 392	ssm		0,0
 393	SFDIAG		(20)
 394	ssm		0,0
 395	MFDIAG_1	(28)
 396	b,n         perf_rdr_shift_in_W_leave
 397	ssm		0,0
 398	nop
 399
 400	;
 401	; RDR 21 read sequence
 402	;
 403	sync
 404	ssm		0,0
 405	SFDIAG		(21)
 406	ssm		0,0
 407	MFDIAG_1	(28)
 408	b,n         perf_rdr_shift_in_W_leave
 409	ssm		0,0
 410	nop
 411
 412	;
 413	; RDR 22 read sequence
 414	;
 415	sync
 416	ssm		0,0
 417	SFDIAG		(22)
 418	ssm		0,0
 419	MFDIAG_1	(28)
 420	b,n         perf_rdr_shift_in_W_leave
 421	ssm		0,0
 422	nop
 423
 424	;
 425	; RDR 23 read sequence
 426	;
 427	sync
 428	ssm		0,0
 429	SFDIAG		(23)
 430	ssm		0,0
 431	MFDIAG_1	(28)
 432	b,n         perf_rdr_shift_in_W_leave
 433	ssm		0,0
 434	nop
 435
 436	;
 437	; RDR 24 read sequence
 438	;
 439	sync
 440	ssm		0,0
 441	SFDIAG		(24)
 442	ssm		0,0
 443	MFDIAG_1	(28)
 444	b,n         perf_rdr_shift_in_W_leave
 445	ssm		0,0
 446	nop
 447
 448	;
 449	; RDR 25 read sequence
 450	;
 451	sync
 452	ssm		0,0
 453	SFDIAG		(25)
 454	ssm		0,0
 455	MFDIAG_1	(28)
 456	b,n         perf_rdr_shift_in_W_leave
 457	ssm		0,0
 458	nop
 459
 460	;
 461	; RDR 26 read sequence
 462	;
 463	SFDIAG		(26)
 464	ssm		0,0
 465	MFDIAG_1	(28)
 466	shrpd		ret0,%r0,%sar,%r1
 467	MTDIAG_1	(1)
 468	STDIAG		(26)
 469	ssm		0,0
 470	b,n         perf_rdr_shift_in_W_leave
 471
 472	;
 473	; RDR 27 read sequence
 474	;
 475	SFDIAG		(27)
 476	ssm		0,0
 477	MFDIAG_1	(28)
 478	shrpd		ret0,%r0,%sar,%r1
 479	MTDIAG_1	(1)
 480	STDIAG		(27)
 481	ssm		0,0
 482	b,n         perf_rdr_shift_in_W_leave
 483
 484	;
 485	; RDR 28 read sequence
 486	;
 487	sync
 488	ssm		0,0
 489	SFDIAG		(28)
 490	ssm		0,0
 491	MFDIAG_1	(28)
 492	b,n         perf_rdr_shift_in_W_leave
 493	ssm		0,0
 494	nop
 495
 496	;
 497	; RDR 29 read sequence
 498	;
 499	sync
 500	ssm		0,0
 501	SFDIAG		(29)
 502	ssm		0,0
 503	MFDIAG_1	(28)
 504	b,n         perf_rdr_shift_in_W_leave
 505	ssm		0,0
 506	nop
 507
 508	;
 509	; RDR 30 read sequence
 510	;
 511	SFDIAG		(30)
 512	ssm		0,0
 513	MFDIAG_1	(28)
 514	shrpd		ret0,%r0,%sar,%r1
 515	MTDIAG_1	(1)
 516	STDIAG		(30)
 517	ssm		0,0
 518	b,n         perf_rdr_shift_in_W_leave
 519
 520	;
 521	; RDR 31 read sequence
 522	;
 523	sync
 524	ssm		0,0
 525	SFDIAG		(31)
 526	ssm		0,0
 527	MFDIAG_1	(28)
 528	nop
 529	ssm		0,0
 530	nop
 531
 532	;
 533	; Fallthrough
 534	;
 535
 536perf_rdr_shift_in_W_leave:
 537	bve		    (%r2)
 538	.exit
 539	MTDIAG_2	(24)			; restore DR2
 540	.procend
 541ENDPROC(perf_rdr_shift_in_W)
 542
 543
 544;***********************************************************************
 545;*
 546;* Name: perf_rdr_shift_out_W
 547;*
 548;* Description:
 549;*	This routine moves data to the RDR's.  The double-word that
 550;*	arg1 points to is loaded and moved into the staging register.
 551;*	Then the STDIAG instruction for the RDR # in arg0 is called
 552;*	to move the data to the RDR.
 553;*
 554;* Arguments:
 555;*	arg0 = rdr number
 556;*	arg1 = 64-bit value to write
 557;*	%r24 - DR2 | DR2_SLOW_RET
 558;*	%r23 - original DR2 value
 559;*
 560;* Returns:
 561;*	None
 562;*
 563;* Register usage:
 564;*
 565;***********************************************************************
 566
 567ENTRY(perf_rdr_shift_out_W)
 568	.proc
 569	.callinfo frame=0,NO_CALLS
 570	.entry
 571;
 572; NOTE: The PCX-W ERS states that DR2_SLOW_RET must be set before any
 573; shifting is done, from or to, the remote diagnose registers.
 574;
 575
 576	depdi,z		1,DR2_SLOW_RET,1,%r24
 577	MFDIAG_2	(23)
 578	or		%r24,%r23,%r24
 579	MTDIAG_2	(24)		; set DR2_SLOW_RET
 580	MTDIAG_1	(25)		; data to the staging register
 581	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
 582	blr		    %r1,%r0	; branch to 8-instruction sequence
 583	nop
 584
 585	;
 586	; RDR 0 write sequence
 587	;
 588	sync				; RDR 0 write sequence
 589	ssm		0,0
 590	STDIAG		(0)
 591	ssm		0,0
 592	b,n         perf_rdr_shift_out_W_leave
 593	nop
 594	ssm		0,0
 595	nop
 596
 597	;
 598	; RDR 1 write sequence
 599	;
 600	sync
 601	ssm		0,0
 602	STDIAG		(1)
 603	ssm		0,0
 604	b,n         perf_rdr_shift_out_W_leave
 605	nop
 606	ssm		0,0
 607	nop
 608
 609	;
 610	; RDR 2 write sequence
 611	;
 612	sync
 613	ssm		0,0
 614	STDIAG		(2)
 615	ssm		0,0
 616	b,n         perf_rdr_shift_out_W_leave
 617	nop
 618	ssm		0,0
 619	nop
 620
 621	;
 622	; RDR 3 write sequence
 623	;
 624	sync
 625	ssm		0,0
 626	STDIAG		(3)
 627	ssm		0,0
 628	b,n         perf_rdr_shift_out_W_leave
 629	nop
 630	ssm		0,0
 631	nop
 632
 633	;
 634	; RDR 4 write sequence
 635	;
 636	sync
 637	ssm		0,0
 638	STDIAG		(4)
 639	ssm		0,0
 640	b,n         perf_rdr_shift_out_W_leave
 641	nop
 642	ssm		0,0
 643	nop
 644
 645	;
 646	; RDR 5 write sequence
 647	;
 648	sync
 649	ssm		0,0
 650	STDIAG		(5)
 651	ssm		0,0
 652	b,n         perf_rdr_shift_out_W_leave
 653	nop
 654	ssm		0,0
 655	nop
 656
 657	;
 658	; RDR 6 write sequence
 659	;
 660	sync
 661	ssm		0,0
 662	STDIAG		(6)
 663	ssm		0,0
 664	b,n         perf_rdr_shift_out_W_leave
 665	nop
 666	ssm		0,0
 667	nop
 668
 669	;
 670	; RDR 7 write sequence
 671	;
 672	sync
 673	ssm		0,0
 674	STDIAG		(7)
 675	ssm		0,0
 676	b,n         perf_rdr_shift_out_W_leave
 677	nop
 678	ssm		0,0
 679	nop
 680
 681	;
 682	; RDR 8 write sequence
 683	;
 684	sync
 685	ssm		0,0
 686	STDIAG		(8)
 687	ssm		0,0
 688	b,n         perf_rdr_shift_out_W_leave
 689	nop
 690	ssm		0,0
 691	nop
 692
 693	;
 694	; RDR 9 write sequence
 695	;
 696	sync
 697	ssm		0,0
 698	STDIAG		(9)
 699	ssm		0,0
 700	b,n         perf_rdr_shift_out_W_leave
 701	nop
 702	ssm		0,0
 703	nop
 704
 705	;
 706	; RDR 10 write sequence
 707	;
 708	sync
 709	ssm		0,0
 710	STDIAG		(10)
 711	STDIAG		(26)
 712	ssm		0,0
 713	b,n         perf_rdr_shift_out_W_leave
 714	ssm		0,0
 715	nop
 716
 717	;
 718	; RDR 11 write sequence
 719	;
 720	sync
 721	ssm		0,0
 722	STDIAG		(11)
 723	STDIAG		(27)
 724	ssm		0,0
 725	b,n         perf_rdr_shift_out_W_leave
 726	ssm		0,0
 727	nop
 728
 729	;
 730	; RDR 12 write sequence
 731	;
 732	sync
 733	ssm		0,0
 734	STDIAG		(12)
 735	ssm		0,0
 736	b,n         perf_rdr_shift_out_W_leave
 737	nop
 738	ssm		0,0
 739	nop
 740
 741	;
 742	; RDR 13 write sequence
 743	;
 744	sync
 745	ssm		0,0
 746	STDIAG		(13)
 747	ssm		0,0
 748	b,n         perf_rdr_shift_out_W_leave
 749	nop
 750	ssm		0,0
 751	nop
 752
 753	;
 754	; RDR 14 write sequence
 755	;
 756	sync
 757	ssm		0,0
 758	STDIAG		(14)
 759	ssm		0,0
 760	b,n         perf_rdr_shift_out_W_leave
 761	nop
 762	ssm		0,0
 763	nop
 764
 765	;
 766	; RDR 15 write sequence
 767	;
 768	sync
 769	ssm		0,0
 770	STDIAG		(15)
 771	ssm		0,0
 772	b,n         perf_rdr_shift_out_W_leave
 773	nop
 774	ssm		0,0
 775	nop
 776
 777	;
 778	; RDR 16 write sequence
 779	;
 780	sync
 781	ssm		0,0
 782	STDIAG		(16)
 783	ssm		0,0
 784	b,n         perf_rdr_shift_out_W_leave
 785	nop
 786	ssm		0,0
 787	nop
 788
 789	;
 790	; RDR 17 write sequence
 791	;
 792	sync
 793	ssm		0,0
 794	STDIAG		(17)
 795	ssm		0,0
 796	b,n         perf_rdr_shift_out_W_leave
 797	nop
 798	ssm		0,0
 799	nop
 800
 801	;
 802	; RDR 18 write sequence
 803	;
 804	sync
 805	ssm		0,0
 806	STDIAG		(18)
 807	ssm		0,0
 808	b,n         perf_rdr_shift_out_W_leave
 809	nop
 810	ssm		0,0
 811	nop
 812
 813	;
 814	; RDR 19 write sequence
 815	;
 816	sync
 817	ssm		0,0
 818	STDIAG		(19)
 819	ssm		0,0
 820	b,n         perf_rdr_shift_out_W_leave
 821	nop
 822	ssm		0,0
 823	nop
 824
 825	;
 826	; RDR 20 write sequence
 827	;
 828	sync
 829	ssm		0,0
 830	STDIAG		(20)
 831	ssm		0,0
 832	b,n         perf_rdr_shift_out_W_leave
 833	nop
 834	ssm		0,0
 835	nop
 836
 837	;
 838	; RDR 21 write sequence
 839	;
 840	sync
 841	ssm		0,0
 842	STDIAG		(21)
 843	ssm		0,0
 844	b,n         perf_rdr_shift_out_W_leave
 845	nop
 846	ssm		0,0
 847	nop
 848
 849	;
 850	; RDR 22 write sequence
 851	;
 852	sync
 853	ssm		0,0
 854	STDIAG		(22)
 855	ssm		0,0
 856	b,n         perf_rdr_shift_out_W_leave
 857	nop
 858	ssm		0,0
 859	nop
 860
 861	;
 862	; RDR 23 write sequence
 863	;
 864	sync
 865	ssm		0,0
 866	STDIAG		(23)
 867	ssm		0,0
 868	b,n         perf_rdr_shift_out_W_leave
 869	nop
 870	ssm		0,0
 871	nop
 872
 873	;
 874	; RDR 24 write sequence
 875	;
 876	sync
 877	ssm		0,0
 878	STDIAG		(24)
 879	ssm		0,0
 880	b,n         perf_rdr_shift_out_W_leave
 881	nop
 882	ssm		0,0
 883	nop
 884
 885	;
 886	; RDR 25 write sequence
 887	;
 888	sync
 889	ssm		0,0
 890	STDIAG		(25)
 891	ssm		0,0
 892	b,n         perf_rdr_shift_out_W_leave
 893	nop
 894	ssm		0,0
 895	nop
 896
 897	;
 898	; RDR 26 write sequence
 899	;
 900	sync
 901	ssm		0,0
 902	STDIAG		(10)
 903	STDIAG		(26)
 904	ssm		0,0
 905	b,n         perf_rdr_shift_out_W_leave
 906	ssm		0,0
 907	nop
 908
 909	;
 910	; RDR 27 write sequence
 911	;
 912	sync
 913	ssm		0,0
 914	STDIAG		(11)
 915	STDIAG		(27)
 916	ssm		0,0
 917	b,n         perf_rdr_shift_out_W_leave
 918	ssm		0,0
 919	nop
 920
 921	;
 922	; RDR 28 write sequence
 923	;
 924	sync
 925	ssm		0,0
 926	STDIAG		(28)
 927	ssm		0,0
 928	b,n         perf_rdr_shift_out_W_leave
 929	nop
 930	ssm		0,0
 931	nop
 932
 933	;
 934	; RDR 29 write sequence
 935	;
 936	sync
 937	ssm		0,0
 938	STDIAG		(29)
 939	ssm		0,0
 940	b,n         perf_rdr_shift_out_W_leave
 941	nop
 942	ssm		0,0
 943	nop
 944
 945	;
 946	; RDR 30 write sequence
 947	;
 948	sync
 949	ssm		0,0
 950	STDIAG		(30)
 951	ssm		0,0
 952	b,n         perf_rdr_shift_out_W_leave
 953	nop
 954	ssm		0,0
 955	nop
 956
 957	;
 958	; RDR 31 write sequence
 959	;
 960	sync
 961	ssm		0,0
 962	STDIAG		(31)
 963	ssm		0,0
 964	b,n         perf_rdr_shift_out_W_leave
 965	nop
 966	ssm		0,0
 967	nop
 968
 969perf_rdr_shift_out_W_leave:
 970	bve		(%r2)
 971	.exit
 972	MTDIAG_2	(23)			; restore DR2
 973	.procend
 974ENDPROC(perf_rdr_shift_out_W)
 975
 976
 977;***********************************************************************
 978;*
 979;* Name: rdr_shift_in_U
 980;*
 981;* Description:
 982;*	This routine shifts data in from the RDR in arg0 and returns
 983;*	the result in ret0.  If the RDR is <= 64 bits in length, it
 984;*	is shifted shifted backup immediately.  This is to compensate
 985;*	for RDR10 which has bits that preclude PDC stack operations
 986;*	when they are in the wrong state.
 987;*
 988;* Arguments:
 989;*	arg0 : rdr to be read
 990;*	arg1 : bit length of rdr
 991;*
 992;* Returns:
 993;*	ret0 = next 64 bits of rdr data from staging register
 994;*
 995;* Register usage:
 996;*	arg0 : rdr to be read						                        
 997;*	arg1 : bit length of rdr					                        
 998;*	%r24 - original DR2 value
 999;*	%r23 - DR2 | DR2_SLOW_RET
1000;*	%r1  - scratch
1001;*
1002;***********************************************************************
1003
1004ENTRY(perf_rdr_shift_in_U)
1005	.proc
1006	.callinfo frame=0,NO_CALLS
1007	.entry
1008
1009; read(shift in) the RDR.
1010;
1011; NOTE: The PCX-U ERS states that DR2_SLOW_RET must be set before any
1012; shifting is done, from or to, remote diagnose registers.
1013
1014	depdi,z		1,DR2_SLOW_RET,1,%r29
1015	MFDIAG_2	(24)
1016	or			%r24,%r29,%r29
1017	MTDIAG_2	(29)			; set DR2_SLOW_RET
1018
1019	nop
1020	nop
1021	nop
1022	nop
1023
1024;
1025; Start of next 32-byte cacheline
1026;
1027	nop
1028	nop
1029	nop
1030	extrd,u		arg1,63,6,%r1
1031
1032	mtsar		%r1
1033	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
1034	blr 		%r1,%r0		; branch to 8-instruction sequence
1035	nop
1036
1037;
1038; Start of next 32-byte cacheline
1039;
1040	SFDIAG		(0)		; RDR 0 read sequence
1041	ssm		0,0
1042	MFDIAG_1	(28)
1043	shrpd		ret0,%r0,%sar,%r1
1044	MTDIAG_1	(1)
1045	STDIAG		(0)
1046	ssm		0,0
1047	b,n         perf_rdr_shift_in_U_leave
1048
1049	SFDIAG		(1)		; RDR 1 read sequence
1050	ssm		0,0
1051	MFDIAG_1	(28)
1052	shrpd		ret0,%r0,%sar,%r1
1053	MTDIAG_1	(1)
1054	STDIAG		(1)
1055	ssm		0,0
1056	b,n         perf_rdr_shift_in_U_leave
1057
1058	sync				; RDR 2 read sequence
1059	ssm		0,0
1060	SFDIAG		(4)
1061	ssm		0,0
1062	MFDIAG_1	(28)
1063	b,n         perf_rdr_shift_in_U_leave
1064	ssm		0,0
1065	nop
1066
1067	sync				; RDR 3 read sequence
1068	ssm		0,0
1069	SFDIAG		(3)
1070	ssm		0,0
1071	MFDIAG_1	(28)
1072	b,n         perf_rdr_shift_in_U_leave
1073	ssm		0,0
1074	nop
1075
1076	sync				; RDR 4 read sequence
1077	ssm		0,0
1078	SFDIAG		(4)
1079	ssm		0,0
1080	MFDIAG_1	(28)
1081	b,n         perf_rdr_shift_in_U_leave
1082	ssm		0,0
1083	nop
1084
1085	sync				; RDR 5 read sequence
1086	ssm		0,0
1087	SFDIAG		(5)
1088	ssm		0,0
1089	MFDIAG_1	(28)
1090	b,n         perf_rdr_shift_in_U_leave
1091	ssm		0,0
1092	nop
1093
1094	sync				; RDR 6 read sequence
1095	ssm		0,0
1096	SFDIAG		(6)
1097	ssm		0,0
1098	MFDIAG_1	(28)
1099	b,n         perf_rdr_shift_in_U_leave
1100	ssm		0,0
1101	nop
1102
1103	sync				; RDR 7 read sequence
1104	ssm		0,0
1105	SFDIAG		(7)
1106	ssm		0,0
1107	MFDIAG_1	(28)
1108	b,n         perf_rdr_shift_in_U_leave
1109	ssm		0,0
1110	nop
1111
1112	b,n         perf_rdr_shift_in_U_leave
1113	nop
1114	nop
1115	nop
1116	nop
1117	nop
1118	nop
1119	nop
1120
1121	SFDIAG		(9)		; RDR 9 read sequence
1122	ssm		0,0
1123	MFDIAG_1	(28)
1124	shrpd		ret0,%r0,%sar,%r1
1125	MTDIAG_1	(1)
1126	STDIAG		(9)
1127	ssm		0,0
1128	b,n         perf_rdr_shift_in_U_leave
1129
1130	SFDIAG		(10)		; RDR 10 read sequence
1131	ssm		0,0
1132	MFDIAG_1	(28)
1133	shrpd		ret0,%r0,%sar,%r1
1134	MTDIAG_1	(1)
1135	STDIAG		(10)
1136	ssm		0,0
1137	b,n         perf_rdr_shift_in_U_leave
1138
1139	SFDIAG		(11)		; RDR 11 read sequence
1140	ssm		0,0
1141	MFDIAG_1	(28)
1142	shrpd		ret0,%r0,%sar,%r1
1143	MTDIAG_1	(1)
1144	STDIAG		(11)
1145	ssm		0,0
1146	b,n         perf_rdr_shift_in_U_leave
1147
1148	SFDIAG		(12)		; RDR 12 read sequence
1149	ssm		0,0
1150	MFDIAG_1	(28)
1151	shrpd		ret0,%r0,%sar,%r1
1152	MTDIAG_1	(1)
1153	STDIAG		(12)
1154	ssm		0,0
1155	b,n         perf_rdr_shift_in_U_leave
1156
1157	SFDIAG		(13)		; RDR 13 read sequence
1158	ssm		0,0
1159	MFDIAG_1	(28)
1160	shrpd		ret0,%r0,%sar,%r1
1161	MTDIAG_1	(1)
1162	STDIAG		(13)
1163	ssm		0,0
1164	b,n         perf_rdr_shift_in_U_leave
1165
1166	SFDIAG		(14)		; RDR 14 read sequence
1167	ssm		0,0
1168	MFDIAG_1	(28)
1169	shrpd		ret0,%r0,%sar,%r1
1170	MTDIAG_1	(1)
1171	STDIAG		(14)
1172	ssm		0,0
1173	b,n         perf_rdr_shift_in_U_leave
1174
1175	SFDIAG		(15)		; RDR 15 read sequence
1176	ssm		0,0
1177	MFDIAG_1	(28)
1178	shrpd		ret0,%r0,%sar,%r1
1179	MTDIAG_1	(1)
1180	STDIAG		(15)
1181	ssm		0,0
1182	b,n         perf_rdr_shift_in_U_leave
1183
1184	sync				; RDR 16 read sequence
1185	ssm		0,0
1186	SFDIAG		(16)
1187	ssm		0,0
1188	MFDIAG_1	(28)
1189	b,n         perf_rdr_shift_in_U_leave
1190	ssm		0,0
1191	nop
1192
1193	SFDIAG		(17)		; RDR 17 read sequence
1194	ssm		0,0
1195	MFDIAG_1	(28)
1196	shrpd		ret0,%r0,%sar,%r1
1197	MTDIAG_1	(1)
1198	STDIAG		(17)
1199	ssm		0,0
1200	b,n         perf_rdr_shift_in_U_leave
1201
1202	SFDIAG		(18)		; RDR 18 read sequence
1203	ssm		0,0
1204	MFDIAG_1	(28)
1205	shrpd		ret0,%r0,%sar,%r1
1206	MTDIAG_1	(1)
1207	STDIAG		(18)
1208	ssm		0,0
1209	b,n         perf_rdr_shift_in_U_leave
1210
1211	b,n         perf_rdr_shift_in_U_leave
1212	nop
1213	nop
1214	nop
1215	nop
1216	nop
1217	nop
1218	nop
1219
1220	sync				; RDR 20 read sequence
1221	ssm		0,0
1222	SFDIAG		(20)
1223	ssm		0,0
1224	MFDIAG_1	(28)
1225	b,n         perf_rdr_shift_in_U_leave
1226	ssm		0,0
1227	nop
1228
1229	sync				; RDR 21 read sequence
1230	ssm		0,0
1231	SFDIAG		(21)
1232	ssm		0,0
1233	MFDIAG_1	(28)
1234	b,n         perf_rdr_shift_in_U_leave
1235	ssm		0,0
1236	nop
1237
1238	sync				; RDR 22 read sequence
1239	ssm		0,0
1240	SFDIAG		(22)
1241	ssm		0,0
1242	MFDIAG_1	(28)
1243	b,n         perf_rdr_shift_in_U_leave
1244	ssm		0,0
1245	nop
1246
1247	sync				; RDR 23 read sequence
1248	ssm		0,0
1249	SFDIAG		(23)
1250	ssm		0,0
1251	MFDIAG_1	(28)
1252	b,n         perf_rdr_shift_in_U_leave
1253	ssm		0,0
1254	nop
1255
1256	sync				; RDR 24 read sequence
1257	ssm		0,0
1258	SFDIAG		(24)
1259	ssm		0,0
1260	MFDIAG_1	(28)
1261	b,n         perf_rdr_shift_in_U_leave
1262	ssm		0,0
1263	nop
1264
1265	sync				; RDR 25 read sequence
1266	ssm		0,0
1267	SFDIAG		(25)
1268	ssm		0,0
1269	MFDIAG_1	(28)
1270	b,n         perf_rdr_shift_in_U_leave
1271	ssm		0,0
1272	nop
1273
1274	SFDIAG		(26)		; RDR 26 read sequence
1275	ssm		0,0
1276	MFDIAG_1	(28)
1277	shrpd		ret0,%r0,%sar,%r1
1278	MTDIAG_1	(1)
1279	STDIAG		(26)
1280	ssm		0,0
1281	b,n         perf_rdr_shift_in_U_leave
1282
1283	SFDIAG		(27)		; RDR 27 read sequence
1284	ssm		0,0
1285	MFDIAG_1	(28)
1286	shrpd		ret0,%r0,%sar,%r1
1287	MTDIAG_1	(1)
1288	STDIAG		(27)
1289	ssm		0,0
1290	b,n         perf_rdr_shift_in_U_leave
1291
1292	sync				; RDR 28 read sequence
1293	ssm		0,0
1294	SFDIAG		(28)
1295	ssm		0,0
1296	MFDIAG_1	(28)
1297	b,n         perf_rdr_shift_in_U_leave
1298	ssm		0,0
1299	nop
1300
1301	b,n         perf_rdr_shift_in_U_leave
1302	nop
1303	nop
1304	nop
1305	nop
1306	nop
1307	nop
1308	nop
1309
1310	SFDIAG		(30)		; RDR 30 read sequence
1311	ssm		0,0
1312	MFDIAG_1	(28)
1313	shrpd		ret0,%r0,%sar,%r1
1314	MTDIAG_1	(1)
1315	STDIAG		(30)
1316	ssm		0,0
1317	b,n         perf_rdr_shift_in_U_leave
1318
1319	SFDIAG		(31)		; RDR 31 read sequence
1320	ssm		0,0
1321	MFDIAG_1	(28)
1322	shrpd		ret0,%r0,%sar,%r1
1323	MTDIAG_1	(1)
1324	STDIAG		(31)
1325	ssm		0,0
1326	b,n         perf_rdr_shift_in_U_leave
1327	nop
1328
1329perf_rdr_shift_in_U_leave:
1330	bve		    (%r2)
1331	.exit
1332	MTDIAG_2	(24)			; restore DR2
1333	.procend
1334ENDPROC(perf_rdr_shift_in_U)
1335
1336;***********************************************************************
1337;*
1338;* Name: rdr_shift_out_U
1339;*
1340;* Description:
1341;*	This routine moves data to the RDR's.  The double-word that
1342;*	arg1 points to is loaded and moved into the staging register.
1343;*	Then the STDIAG instruction for the RDR # in arg0 is called
1344;*	to move the data to the RDR.
1345;*
1346;* Arguments:
1347;*	arg0 = rdr target
1348;*	arg1 = buffer pointer
1349;*
1350;* Returns:
1351;*	None
1352;*
1353;* Register usage:
1354;*	arg0 = rdr target
1355;*	arg1 = buffer pointer
1356;*	%r24 - DR2 | DR2_SLOW_RET
1357;*	%r23 - original DR2 value
1358;*
1359;***********************************************************************
1360
1361ENTRY(perf_rdr_shift_out_U)
1362	.proc
1363	.callinfo frame=0,NO_CALLS
1364	.entry
1365
1366;
1367; NOTE: The PCX-U ERS states that DR2_SLOW_RET must be set before any
1368; shifting is done, from or to, the remote diagnose registers.
1369;
1370
1371	depdi,z		1,DR2_SLOW_RET,1,%r24
1372	MFDIAG_2	(23)
1373	or		%r24,%r23,%r24
1374	MTDIAG_2	(24)		; set DR2_SLOW_RET
1375
1376	MTDIAG_1	(25)		; data to the staging register
1377	shladd		arg0,2,%r0,%r1	; %r1 = 4 * RDR number
1378	blr		%r1,%r0		; branch to 8-instruction sequence
1379	nop
1380
1381;
1382; 32-byte cachline aligned
1383;
1384
1385	sync				; RDR 0 write sequence
1386	ssm		0,0
1387	STDIAG		(0)
1388	ssm		0,0
1389	b,n         perf_rdr_shift_out_U_leave
1390	nop
1391	ssm		0,0
1392	nop
1393
1394	sync				; RDR 1 write sequence
1395	ssm		0,0
1396	STDIAG		(1)
1397	ssm		0,0
1398	b,n         perf_rdr_shift_out_U_leave
1399	nop
1400	ssm		0,0
1401	nop
1402
1403	sync				; RDR 2 write sequence
1404	ssm		0,0
1405	STDIAG		(2)
1406	ssm		0,0
1407	b,n         perf_rdr_shift_out_U_leave
1408	nop
1409	ssm		0,0
1410	nop
1411
1412	sync				; RDR 3 write sequence
1413	ssm		0,0
1414	STDIAG		(3)
1415	ssm		0,0
1416	b,n         perf_rdr_shift_out_U_leave
1417	nop
1418	ssm		0,0
1419	nop
1420
1421	sync				; RDR 4 write sequence
1422	ssm		0,0
1423	STDIAG		(4)
1424	ssm		0,0
1425	b,n         perf_rdr_shift_out_U_leave
1426	nop
1427	ssm		0,0
1428	nop
1429
1430	sync				; RDR 5 write sequence
1431	ssm		0,0
1432	STDIAG		(5)
1433	ssm		0,0
1434	b,n         perf_rdr_shift_out_U_leave
1435	nop
1436	ssm		0,0
1437	nop
1438
1439	sync				; RDR 6 write sequence
1440	ssm		0,0
1441	STDIAG		(6)
1442	ssm		0,0
1443	b,n         perf_rdr_shift_out_U_leave
1444	nop
1445	ssm		0,0
1446	nop
1447
1448	sync				; RDR 7 write sequence
1449	ssm		0,0
1450	STDIAG		(7)
1451	ssm		0,0
1452	b,n         perf_rdr_shift_out_U_leave
1453	nop
1454	ssm		0,0
1455	nop
1456
1457	sync				; RDR 8 write sequence
1458	ssm		0,0
1459	STDIAG		(8)
1460	ssm		0,0
1461	b,n         perf_rdr_shift_out_U_leave
1462	nop
1463	ssm		0,0
1464	nop
1465
1466	sync				; RDR 9 write sequence
1467	ssm		0,0
1468	STDIAG		(9)
1469	ssm		0,0
1470	b,n         perf_rdr_shift_out_U_leave
1471	nop
1472	ssm		0,0
1473	nop
1474
1475	sync				; RDR 10 write sequence
1476	ssm		0,0
1477	STDIAG		(10)
1478	ssm		0,0
1479	b,n         perf_rdr_shift_out_U_leave
1480	nop
1481	ssm		0,0
1482	nop
1483
1484	sync				; RDR 11 write sequence
1485	ssm		0,0
1486	STDIAG		(11)
1487	ssm		0,0
1488	b,n         perf_rdr_shift_out_U_leave
1489	nop
1490	ssm		0,0
1491	nop
1492
1493	sync				; RDR 12 write sequence
1494	ssm		0,0
1495	STDIAG		(12)
1496	ssm		0,0
1497	b,n         perf_rdr_shift_out_U_leave
1498	nop
1499	ssm		0,0
1500	nop
1501
1502	sync				; RDR 13 write sequence
1503	ssm		0,0
1504	STDIAG		(13)
1505	ssm		0,0
1506	b,n         perf_rdr_shift_out_U_leave
1507	nop
1508	ssm		0,0
1509	nop
1510
1511	sync				; RDR 14 write sequence
1512	ssm		0,0
1513	STDIAG		(14)
1514	ssm		0,0
1515	b,n         perf_rdr_shift_out_U_leave
1516	nop
1517	ssm		0,0
1518	nop
1519
1520	sync				; RDR 15 write sequence
1521	ssm		0,0
1522	STDIAG		(15)
1523	ssm		0,0
1524	b,n         perf_rdr_shift_out_U_leave
1525	nop
1526	ssm		0,0
1527	nop
1528
1529	sync				; RDR 16 write sequence
1530	ssm		0,0
1531	STDIAG		(16)
1532	ssm		0,0
1533	b,n         perf_rdr_shift_out_U_leave
1534	nop
1535	ssm		0,0
1536	nop
1537
1538	sync				; RDR 17 write sequence
1539	ssm		0,0
1540	STDIAG		(17)
1541	ssm		0,0
1542	b,n         perf_rdr_shift_out_U_leave
1543	nop
1544	ssm		0,0
1545	nop
1546
1547	sync				; RDR 18 write sequence
1548	ssm		0,0
1549	STDIAG		(18)
1550	ssm		0,0
1551	b,n         perf_rdr_shift_out_U_leave
1552	nop
1553	ssm		0,0
1554	nop
1555
1556	sync				; RDR 19 write sequence
1557	ssm		0,0
1558	STDIAG		(19)
1559	ssm		0,0
1560	b,n         perf_rdr_shift_out_U_leave
1561	nop
1562	ssm		0,0
1563	nop
1564
1565	sync				; RDR 20 write sequence
1566	ssm		0,0
1567	STDIAG		(20)
1568	ssm		0,0
1569	b,n         perf_rdr_shift_out_U_leave
1570	nop
1571	ssm		0,0
1572	nop
1573
1574	sync				; RDR 21 write sequence
1575	ssm		0,0
1576	STDIAG		(21)
1577	ssm		0,0
1578	b,n         perf_rdr_shift_out_U_leave
1579	nop
1580	ssm		0,0
1581	nop
1582
1583	sync				; RDR 22 write sequence
1584	ssm		0,0
1585	STDIAG		(22)
1586	ssm		0,0
1587	b,n         perf_rdr_shift_out_U_leave
1588	nop
1589	ssm		0,0
1590	nop
1591
1592	sync				; RDR 23 write sequence
1593	ssm		0,0
1594	STDIAG		(23)
1595	ssm		0,0
1596	b,n         perf_rdr_shift_out_U_leave
1597	nop
1598	ssm		0,0
1599	nop
1600
1601	sync				; RDR 24 write sequence
1602	ssm		0,0
1603	STDIAG		(24)
1604	ssm		0,0
1605	b,n         perf_rdr_shift_out_U_leave
1606	nop
1607	ssm		0,0
1608	nop
1609
1610	sync				; RDR 25 write sequence
1611	ssm		0,0
1612	STDIAG		(25)
1613	ssm		0,0
1614	b,n         perf_rdr_shift_out_U_leave
1615	nop
1616	ssm		0,0
1617	nop
1618
1619	sync				; RDR 26 write sequence
1620	ssm		0,0
1621	STDIAG		(26)
1622	ssm		0,0
1623	b,n         perf_rdr_shift_out_U_leave
1624	nop
1625	ssm		0,0
1626	nop
1627
1628	sync				; RDR 27 write sequence
1629	ssm		0,0
1630	STDIAG		(27)
1631	ssm		0,0
1632	b,n         perf_rdr_shift_out_U_leave
1633	nop
1634	ssm		0,0
1635	nop
1636
1637	sync				; RDR 28 write sequence
1638	ssm		0,0
1639	STDIAG		(28)
1640	ssm		0,0
1641	b,n         perf_rdr_shift_out_U_leave
1642	nop
1643	ssm		0,0
1644	nop
1645
1646	sync				; RDR 29 write sequence
1647	ssm		0,0
1648	STDIAG		(29)
1649	ssm		0,0
1650	b,n         perf_rdr_shift_out_U_leave
1651	nop
1652	ssm		0,0
1653	nop
1654
1655	sync				; RDR 30 write sequence
1656	ssm		0,0
1657	STDIAG		(30)
1658	ssm		0,0
1659	b,n         perf_rdr_shift_out_U_leave
1660	nop
1661	ssm		0,0
1662	nop
1663
1664	sync				; RDR 31 write sequence
1665	ssm		0,0
1666	STDIAG		(31)
1667	ssm		0,0
1668	b,n         perf_rdr_shift_out_U_leave
1669	nop
1670	ssm		0,0
1671	nop
1672
1673perf_rdr_shift_out_U_leave:
1674	bve		(%r2)
1675	.exit
1676	MTDIAG_2	(23)			; restore DR2
1677	.procend
1678ENDPROC(perf_rdr_shift_out_U)
1679