Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: mpsort.H | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | // ========== Copyright Header Begin ========================================== | |
24 | // | |
25 | // OpenSPARC T2 Processor File: mpsort.H | |
26 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
27 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
28 | // | |
29 | // The above named program is free software; you can redistribute it and/or | |
30 | // modify it under the terms of the GNU General Public | |
31 | // License version 2 as published by the Free Software Foundation. | |
32 | // | |
33 | // The above named program is distributed in the hope that it will be | |
34 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
35 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
36 | // General Public License for more details. | |
37 | // | |
38 | // You should have received a copy of the GNU General Public | |
39 | // License along with this work; if not, write to the Free Software | |
40 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
41 | // | |
42 | // ========== Copyright Header End ============================================ | |
43 | #ifndef _MPSORT_H | |
44 | #define _MPSORT_H | |
45 | ||
46 | #include <stdlib.h> | |
47 | #include <limits.h> | |
48 | ||
49 | #include "rstf/rstf.h" | |
50 | ||
51 | enum { | |
52 | RSTZIP_MAXCPUS = 32 // max cpus supported in trace | |
53 | }; | |
54 | ||
55 | typedef struct { | |
56 | unsigned cpu : 1; // max number of cpus = 2 | |
57 | unsigned count : 7; // max rec count = 127; 0 means extended | |
58 | } CpuCountZ2p; | |
59 | ||
60 | typedef struct { | |
61 | unsigned cpu : 2; // max number of cpus = 4 | |
62 | unsigned count : 6; // max rec count = 63; 0 means extended | |
63 | } CpuCountZ4p; | |
64 | ||
65 | typedef struct { | |
66 | unsigned cpu : 3; // max number of cpus = 32 | |
67 | unsigned count : 5; // max rec count = 31; 0 means extended | |
68 | } CpuCountZ8p; | |
69 | ||
70 | typedef struct { | |
71 | unsigned cpu : 4; // max number of cpus = 16 | |
72 | unsigned count : 4; // max rec count = 15; 0 means extended | |
73 | } CpuCountZ16p; | |
74 | ||
75 | typedef struct { | |
76 | unsigned cpu : 5; // max number of cpus = 32 | |
77 | unsigned count : 3; // max rec count = 7; 0 means extended | |
78 | } CpuCountZ32p; | |
79 | ||
80 | typedef struct { | |
81 | int cpu; | |
82 | int count; | |
83 | } CpuCount; | |
84 | ||
85 | typedef struct { | |
86 | rstf_unionT* rst; | |
87 | unsigned nrecs; | |
88 | } RstSplit; | |
89 | ||
90 | // multirst is a buffer containing nrstrecs records | |
91 | // unirst[n] is a buffer with space for nrstrecs records | |
92 | // cpucount is a buffer with space for nrstrecs CpuCount records | |
93 | // *curcpu is the cpu for the previous RST record | |
94 | // The total number of CpuCount records is returned. | |
95 | int sortRstTrace(rstf_unionT* multirst, int nrecs, | |
96 | RstSplit* unirst, CpuCount* cpucount, int* curcpu) { | |
97 | int total_recs = 0; | |
98 | int cpu = 0; | |
99 | int numcpus = 0; // Number of cpu's in this trace. | |
100 | int count = 0; | |
101 | int i, j; | |
102 | ||
103 | for (i = 0, j = 0; i < nrecs; i++) { | |
104 | if (multirst[i].proto.rtype == CPU_T) { | |
105 | cpucount[j].cpu = *curcpu; | |
106 | cpucount[j].count = count; | |
107 | j++; | |
108 | ||
109 | *curcpu = multirst[i].cpu.cpu; | |
110 | count = 0; | |
111 | } else { | |
112 | count++; | |
113 | ||
114 | unirst[*curcpu].rst[unirst[*curcpu].nrecs] = multirst[i]; | |
115 | unirst[*curcpu].nrecs++; | |
116 | } | |
117 | } | |
118 | ||
119 | cpucount[j].cpu = *curcpu; | |
120 | cpucount[j].count = count; | |
121 | ||
122 | return (j + 1); | |
123 | } | |
124 | ||
125 | #endif // _MPSORT_H | |
126 |