]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm/xscale/ixp425/ixp425_npereg.h
Fix EXT2FS_DEBUG definition usage.
[FreeBSD/FreeBSD.git] / sys / arm / xscale / ixp425 / ixp425_npereg.h
1 /*-
2  * SPDX-License-Identifier: (BSD-2-Clause-FreeBSD AND BSD-3-Clause)
3  *
4  * Copyright (c) 2006 Sam Leffler, Errno Consulting
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer,
12  *    without modification.
13  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
15  *    redistribution must be conditioned upon including a substantially
16  *    similar Disclaimer requirement for further binary redistribution.
17  *
18  * NO WARRANTY
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
22  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
24  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
27  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29  * THE POSSIBILITY OF SUCH DAMAGES.
30  *
31  * $FreeBSD$
32  */
33
34 /*-
35  * Copyright (c) 2001-2005, Intel Corporation.
36  * All rights reserved.
37  *
38  * Redistribution and use in source and binary forms, with or without
39  * modification, are permitted provided that the following conditions
40  * are met:
41  * 1. Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  * 2. Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in the
45  *    documentation and/or other materials provided with the distribution.
46  * 3. Neither the name of the Intel Corporation nor the names of its contributors
47  *    may be used to endorse or promote products derived from this software
48  *    without specific prior written permission.
49  *
50  *
51  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
52  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
55  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61  * SUCH DAMAGE.
62 */
63
64 #ifndef _IXP425_NPEREG_H_
65 #define _IXP425_NPEREG_H_
66
67 /* signature found as 1st word in a microcode image library */
68 #define IX_NPEDL_IMAGEMGR_SIGNATURE      0xDEADBEEF
69 /* marks end of header in a microcode image library */
70 #define IX_NPEDL_IMAGEMGR_END_OF_HEADER  0xFFFFFFFF
71
72 /*
73  * Intel (R) IXP400 Software NPE Image ID Definition
74  *
75  * Definition of NPE Image ID to be passed to ixNpeDlNpeInitAndStart()
76  * as input of type uint32_t which has the following fields format:
77  *
78  * Field                [Bit Location]
79  * -----------------------------------
80  * Device ID            [31 - 28]
81  * NPE ID               [27 - 24]
82  * NPE Functionality ID [23 - 16]
83  * Major Release Number [15 -  8]
84  * Minor Release Number [7 - 0]
85  */
86 #define IX_NPEDL_NPEID_FROM_IMAGEID_GET(imageId) \
87     (((imageId) >> 24) & 0xf)
88 #define IX_NPEDL_DEVICEID_FROM_IMAGEID_GET(imageId) \
89     (((imageId) >> 28) & 0xf)
90 #define IX_NPEDL_FUNCTIONID_FROM_IMAGEID_GET(imageId) \
91     (((imageId) >> 16) & 0xff)
92 #define IX_NPEDL_MAJOR_FROM_IMAGEID_GET(imageId) \
93     (((imageId) >> 8) & 0xff)
94 #define IX_NPEDL_MINOR_FROM_IMAGEID_GET(imageId) \
95     (((imageId) >> 0) & 0xff)
96
97 /*
98  * Instruction and Data Memory Size (in words) for each NPE
99  */
100 #define IX_NPEDL_INS_MEMSIZE_WORDS_NPEA     4096
101 #define IX_NPEDL_INS_MEMSIZE_WORDS_NPEB     2048
102 #define IX_NPEDL_INS_MEMSIZE_WORDS_NPEC     2048
103
104 #define IX_NPEDL_DATA_MEMSIZE_WORDS_NPEA    2048
105 #define IX_NPEDL_DATA_MEMSIZE_WORDS_NPEB    2048
106 #define IX_NPEDL_DATA_MEMSIZE_WORDS_NPEC    2048
107
108 #define IXP46X_NPEDL_INS_MEMSIZE_WORDS      4096
109 #define IXP46X_NPEDL_DATA_MEMSIZE_WORDS     4096
110
111 /* BAR offsets */
112 #define IX_NPEDL_REG_OFFSET_EXAD             0x00000000 /* Execution Address */
113 #define IX_NPEDL_REG_OFFSET_EXDATA           0x00000004 /* Execution Data */
114 #define IX_NPEDL_REG_OFFSET_EXCTL            0x00000008 /* Execution Control */
115 #define IX_NPEDL_REG_OFFSET_EXCT             0x0000000C /* Execution Count */
116 #define IX_NPEDL_REG_OFFSET_AP0              0x00000010 /* Action Point 0 */
117 #define IX_NPEDL_REG_OFFSET_AP1              0x00000014 /* Action Point 1 */
118 #define IX_NPEDL_REG_OFFSET_AP2              0x00000018 /* Action Point 2 */
119 #define IX_NPEDL_REG_OFFSET_AP3              0x0000001C /* Action Point 3 */
120 #define IX_NPEDL_REG_OFFSET_WFIFO            0x00000020 /* Watchpoint FIFO */
121 #define IX_NPEDL_REG_OFFSET_WC               0x00000024 /* Watch Count */
122 #define IX_NPEDL_REG_OFFSET_PROFCT           0x00000028 /* Profile Count */
123 #define IX_NPEDL_REG_OFFSET_STAT             0x0000002C /* Messaging Status */
124 #define IX_NPEDL_REG_OFFSET_CTL              0x00000030 /* Messaging Control */
125 #define IX_NPEDL_REG_OFFSET_MBST             0x00000034 /* Mailbox Status */
126 #define IX_NPEDL_REG_OFFSET_FIFO             0x00000038 /* Message FIFO */
127
128 /*
129  * Reset value for Mailbox (MBST) register
130  * NOTE that if used, it should be complemented with an NPE instruction
131  * to clear the Mailbox at the NPE side as well
132  */
133 #define IX_NPEDL_REG_RESET_MBST              0x0000F0F0
134
135 #define IX_NPEDL_MASK_WFIFO_VALID            0x80000000 /* VALID bit */
136 #define IX_NPEDL_MASK_STAT_OFNE              0x00010000 /* OFNE bit */
137 #define IX_NPEDL_MASK_STAT_IFNE              0x00080000 /* IFNE bit */
138
139 /*
140  * EXCTL (Execution Control) Register commands
141 */
142 #define IX_NPEDL_EXCTL_CMD_NPE_STEP          0x01       /* Step 1 instruction */
143 #define IX_NPEDL_EXCTL_CMD_NPE_START         0x02       /* Start execution */
144 #define IX_NPEDL_EXCTL_CMD_NPE_STOP          0x03       /* Stop execution */
145 #define IX_NPEDL_EXCTL_CMD_NPE_CLR_PIPE      0x04       /* Clear ins pipeline */
146
147 /*
148  * Read/write operations use address in EXAD and data in EXDATA.
149  */
150 #define IX_NPEDL_EXCTL_CMD_RD_INS_MEM        0x10       /* Read ins memory */
151 #define IX_NPEDL_EXCTL_CMD_WR_INS_MEM        0x11       /* Write ins memory */
152 #define IX_NPEDL_EXCTL_CMD_RD_DATA_MEM       0x12       /* Read data memory */
153 #define IX_NPEDL_EXCTL_CMD_WR_DATA_MEM       0x13       /* Write data memory */
154 #define IX_NPEDL_EXCTL_CMD_RD_ECS_REG        0x14       /* Read ECS register */
155 #define IX_NPEDL_EXCTL_CMD_WR_ECS_REG        0x15       /* Write ECS register */
156
157 #define IX_NPEDL_EXCTL_CMD_CLR_PROFILE_CNT   0x0C       /* Clear Profile Count register */
158
159
160 /*
161  * EXCTL (Execution Control) Register status bit masks
162  */
163 #define IX_NPEDL_EXCTL_STATUS_RUN            0x80000000
164 #define IX_NPEDL_EXCTL_STATUS_STOP           0x40000000
165 #define IX_NPEDL_EXCTL_STATUS_CLEAR          0x20000000
166 #define IX_NPEDL_EXCTL_STATUS_ECS_K          0x00800000 /* pipeline Klean */
167
168 /*
169  * Executing Context Stack (ECS) level registers
170  */
171 #define IX_NPEDL_ECS_BG_CTXT_REG_0           0x00       /* reg 0 @ bg ctx */
172 #define IX_NPEDL_ECS_BG_CTXT_REG_1           0x01       /* reg 1 @ bg ctx */
173 #define IX_NPEDL_ECS_BG_CTXT_REG_2           0x02       /* reg 2 @ bg ctx */
174
175 #define IX_NPEDL_ECS_PRI_1_CTXT_REG_0        0x04       /* reg 0 @ pri 1 ctx */
176 #define IX_NPEDL_ECS_PRI_1_CTXT_REG_1        0x05       /* reg 1 @ pri 1 ctx */
177 #define IX_NPEDL_ECS_PRI_1_CTXT_REG_2        0x06       /* reg 2 @ pri 1 ctx */
178
179 #define IX_NPEDL_ECS_PRI_2_CTXT_REG_0        0x08       /* reg 0 @ pri 2 ctx */
180 #define IX_NPEDL_ECS_PRI_2_CTXT_REG_1        0x09       /* reg 1 @ pri 2 ctx */
181 #define IX_NPEDL_ECS_PRI_2_CTXT_REG_2        0x0A       /* reg 2 @ pri 2 ctx */
182
183 #define IX_NPEDL_ECS_DBG_CTXT_REG_0          0x0C       /* reg 0 @ debug ctx */
184 #define IX_NPEDL_ECS_DBG_CTXT_REG_1          0x0D       /* reg 1 @ debug ctx */
185 #define IX_NPEDL_ECS_DBG_CTXT_REG_2          0x0E       /* reg 2 @ debug ctx */
186
187 #define IX_NPEDL_ECS_INSTRUCT_REG            0x11       /* Instruction reg */
188
189 /*
190  * Execution Access register reset values
191  */
192 #define IX_NPEDL_ECS_BG_CTXT_REG_0_RESET     0xA0000000
193 #define IX_NPEDL_ECS_BG_CTXT_REG_1_RESET     0x01000000
194 #define IX_NPEDL_ECS_BG_CTXT_REG_2_RESET     0x00008000
195 #define IX_NPEDL_ECS_PRI_1_CTXT_REG_0_RESET  0x20000080
196 #define IX_NPEDL_ECS_PRI_1_CTXT_REG_1_RESET  0x01000000
197 #define IX_NPEDL_ECS_PRI_1_CTXT_REG_2_RESET  0x00008000
198 #define IX_NPEDL_ECS_PRI_2_CTXT_REG_0_RESET  0x20000080
199 #define IX_NPEDL_ECS_PRI_2_CTXT_REG_1_RESET  0x01000000
200 #define IX_NPEDL_ECS_PRI_2_CTXT_REG_2_RESET  0x00008000
201 #define IX_NPEDL_ECS_DBG_CTXT_REG_0_RESET    0x20000000
202 #define IX_NPEDL_ECS_DBG_CTXT_REG_1_RESET    0x00000000
203 #define IX_NPEDL_ECS_DBG_CTXT_REG_2_RESET    0x001E0000
204 #define IX_NPEDL_ECS_INSTRUCT_REG_RESET      0x1003C00F
205
206 /*
207  * Masks used to read/write particular bits in Execution Access registers
208  */
209
210 #define IX_NPEDL_MASK_ECS_REG_0_ACTIVE       0x80000000 /* Active bit */
211 #define IX_NPEDL_MASK_ECS_REG_0_NEXTPC       0x1FFF0000 /* NextPC bits */
212 #define IX_NPEDL_MASK_ECS_REG_0_LDUR         0x00000700 /* LDUR bits */
213
214 #define IX_NPEDL_MASK_ECS_REG_1_CCTXT        0x000F0000 /* NextPC bits */
215 #define IX_NPEDL_MASK_ECS_REG_1_SELCTXT      0x0000000F
216
217 #define IX_NPEDL_MASK_ECS_DBG_REG_2_IF       0x00100000 /* IF bit */
218 #define IX_NPEDL_MASK_ECS_DBG_REG_2_IE       0x00080000 /* IE bit */
219
220
221 /*
222  * Bit-Offsets from LSB of particular bit-fields in Execution Access registers.
223  */
224
225 #define IX_NPEDL_OFFSET_ECS_REG_0_NEXTPC     16
226 #define IX_NPEDL_OFFSET_ECS_REG_0_LDUR        8
227
228 #define IX_NPEDL_OFFSET_ECS_REG_1_CCTXT      16
229 #define IX_NPEDL_OFFSET_ECS_REG_1_SELCTXT     0
230
231 /*
232  * NPE core & co-processor instruction templates to load into NPE Instruction
233  * Register, for read/write of NPE register file registers.
234  */
235
236 /*
237  * Read an 8-bit NPE internal logical register
238  * and return the value in the EXDATA register (aligned to MSB).
239  * NPE Assembler instruction:  "mov8 d0, d0  &&& DBG_WrExec"
240  */
241 #define IX_NPEDL_INSTR_RD_REG_BYTE    0x0FC00000
242
243 /*
244  * Read a 16-bit NPE internal logical register
245  * and return the value in the EXDATA register (aligned to MSB).
246  * NPE Assembler instruction:  "mov16 d0, d0  &&& DBG_WrExec"
247  */
248 #define IX_NPEDL_INSTR_RD_REG_SHORT   0x0FC08010
249
250 /*
251  * Read a 16-bit NPE internal logical register
252  * and return the value in the EXDATA register.
253  * NPE Assembler instruction:  "mov32 d0, d0  &&& DBG_WrExec"
254  */
255 #define IX_NPEDL_INSTR_RD_REG_WORD    0x0FC08210
256
257 /*
258  * Write an 8-bit NPE internal logical register.
259  * NPE Assembler instruction:  "mov8 d0, #0"
260  */
261 #define IX_NPEDL_INSTR_WR_REG_BYTE    0x00004000
262
263 /*
264  * Write a 16-bit NPE internal logical register.
265  * NPE Assembler instruction:  "mov16 d0, #0"
266  */
267 #define IX_NPEDL_INSTR_WR_REG_SHORT   0x0000C000
268
269 /*
270  * Write a 16-bit NPE internal logical register.
271  * NPE Assembler instruction:  "cprd32 d0    &&& DBG_RdInFIFO"
272  */
273 #define IX_NPEDL_INSTR_RD_FIFO        0x0F888220
274
275 /*
276  * Reset Mailbox (MBST) register
277  * NPE Assembler instruction:  "mov32 d0, d0  &&& DBG_ClearM"
278  */
279 #define IX_NPEDL_INSTR_RESET_MBOX     0x0FAC8210
280
281
282 /*
283  * Bit-offsets from LSB, of particular bit-fields in an NPE instruction
284  */
285 #define IX_NPEDL_OFFSET_INSTR_SRC              4        /* src operand */
286 #define IX_NPEDL_OFFSET_INSTR_DEST             9        /* dest operand */
287 #define IX_NPEDL_OFFSET_INSTR_COPROC          18        /* coprocessor ins */
288
289 /*
290  * Masks used to read/write particular bits of an NPE Instruction
291  */
292
293 /**
294  * Mask the bits of 16-bit data value (least-sig 5 bits) to be used in
295  * SRC field of immediate-mode NPE instruction
296  */
297 #define IX_NPEDL_MASK_IMMED_INSTR_SRC_DATA         0x1F
298
299 /**
300  * Mask the bits of 16-bit data value (most-sig 11 bits) to be used in
301  * COPROC field of immediate-mode NPE instruction
302  */
303 #define IX_NPEDL_MASK_IMMED_INSTR_COPROC_DATA      0xFFE0
304
305 /**
306  * LSB offset of the bit-field of 16-bit data value (most-sig 11 bits)
307  * to be used in COPROC field of immediate-mode NPE instruction
308  */
309 #define IX_NPEDL_OFFSET_IMMED_INSTR_COPROC_DATA    5
310
311 /**
312  * Number of left-shifts required to align most-sig 11 bits of 16-bit
313  * data value into COPROC field of immediate-mode NPE instruction
314  */
315 #define IX_NPEDL_DISPLACE_IMMED_INSTR_COPROC_DATA \
316      (IX_NPEDL_OFFSET_INSTR_COPROC - IX_NPEDL_OFFSET_IMMED_INSTR_COPROC_DATA)
317
318 /**
319  * LDUR value used with immediate-mode NPE Instructions by the NpeDl
320  * for writing to NPE internal logical registers
321  */
322 #define IX_NPEDL_WR_INSTR_LDUR                     1
323
324 /**
325  * LDUR value used with NON-immediate-mode NPE Instructions by the NpeDl
326  * for reading from NPE internal logical registers
327  */
328 #define IX_NPEDL_RD_INSTR_LDUR                     0
329
330
331 /**
332  * NPE internal Context Store registers.
333  */
334 typedef enum
335 {
336     IX_NPEDL_CTXT_REG_STEVT = 0,  /**< identifies STEVT   */
337     IX_NPEDL_CTXT_REG_STARTPC,    /**< identifies STARTPC */
338     IX_NPEDL_CTXT_REG_REGMAP,     /**< identifies REGMAP  */
339     IX_NPEDL_CTXT_REG_CINDEX,     /**< identifies CINDEX  */
340     IX_NPEDL_CTXT_REG_MAX         /**< Total number of Context Store registers */
341 } IxNpeDlCtxtRegNum;
342
343
344 /*
345  * NPE Context Store register logical addresses
346  */
347 #define IX_NPEDL_CTXT_REG_ADDR_STEVT      0x0000001B
348 #define IX_NPEDL_CTXT_REG_ADDR_STARTPC    0x0000001C
349 #define IX_NPEDL_CTXT_REG_ADDR_REGMAP     0x0000001E
350 #define IX_NPEDL_CTXT_REG_ADDR_CINDEX     0x0000001F
351
352 /*
353  * NPE Context Store register reset values
354  */
355
356 /**
357  * Reset value of STEVT NPE internal Context Store register
358  *        (STEVT = off, 0x80)
359  */
360 #define IX_NPEDL_CTXT_REG_RESET_STEVT     0x80
361
362 /**
363  * Reset value of STARTPC NPE internal Context Store register
364  *        (STARTPC = 0x0000)
365  */
366 #define IX_NPEDL_CTXT_REG_RESET_STARTPC   0x0000
367
368 /**
369  * Reset value of REGMAP NPE internal Context Store register
370  *        (REGMAP = d0->p0, d8->p2, d16->p4)
371  */
372 #define IX_NPEDL_CTXT_REG_RESET_REGMAP    0x0820
373
374 /**
375  * Reset value of CINDEX NPE internal Context Store register
376  *        (CINDEX = 0)
377  */
378 #define IX_NPEDL_CTXT_REG_RESET_CINDEX    0x00
379
380
381 /*
382  * Numeric range of context levels available on an NPE
383  */
384 #define IX_NPEDL_CTXT_NUM_MIN             0
385 #define IX_NPEDL_CTXT_NUM_MAX             15
386
387
388 /**
389  * Number of Physical registers currently supported
390  *        Initial NPE implementations will have a 32-word register file.
391  *        Later implementations may have a 64-word register file.
392  */
393 #define IX_NPEDL_TOTAL_NUM_PHYS_REG               32
394
395 /**
396  * LSB-offset of Regmap number in Physical NPE register address, used
397  *        for Physical To Logical register address mapping in the NPE
398  */
399 #define IX_NPEDL_OFFSET_PHYS_REG_ADDR_REGMAP      1
400
401 /**
402  * Mask to extract a logical NPE register address from a physical
403  *        register address, used for Physical To Logical address mapping
404  */
405 #define IX_NPEDL_MASK_PHYS_REG_ADDR_LOGICAL_ADDR   0x1
406
407 /*
408  * NPE Message/Mailbox interface.
409  */
410 #define IX_NPESTAT      IX_NPEDL_REG_OFFSET_STAT        /* status register */
411 #define IX_NPECTL       IX_NPEDL_REG_OFFSET_CTL         /* control register */
412 #define IX_NPEFIFO      IX_NPEDL_REG_OFFSET_FIFO        /* FIFO register */
413
414 /* control register */
415 #define IX_NPECTL_OFE           0x00010000      /* output fifo enable */
416 #define IX_NPECTL_IFE           0x00020000      /* input fifo enable */
417 #define IX_NPECTL_OFWE          0x01000000      /* output fifo write enable */
418 #define IX_NPECTL_IFWE          0x02000000      /* input fifo write enable */
419
420 /* status register */
421 #define IX_NPESTAT_OFNE         0x00010000      /* output fifo not empty */
422 #define IX_NPESTAT_IFNF         0x00020000      /* input fifo not full */
423 #define IX_NPESTAT_OFNF         0x00040000      /* output fifo not full */
424 #define IX_NPESTAT_IFNE         0x00080000      /* input fifo not empty */
425 #define IX_NPESTAT_MBINT        0x00100000      /* Mailbox interrupt */
426 #define IX_NPESTAT_IFINT        0x00200000      /* input fifo interrupt */
427 #define IX_NPESTAT_OFINT        0x00400000      /* output fifo interrupt */
428 #define IX_NPESTAT_WFINT        0x00800000      /* watch fifo interrupt */
429 #endif /* _IXP425_NPEREG_H_ */