change console=tty0 to enable linux framebuffer console
[jz_uboot.git] / cpu / ixp / npe / include / IxQMgrAqmIf_p.h
blob7f5733c5d24e734fde05c7896421f2f6265265cd
1 /**
2 * @file IxQMgrAqmIf_p.h
4 * @author Intel Corporation
5 * @date 30-Oct-2001
7 * @brief The IxQMgrAqmIf sub-component provides a number of inline
8 * functions for performing I/O on the AQM.
10 * Because some functions contained in this module are inline and are
11 * used in other modules (within the QMgr component) the definitions are
12 * contained in this header file. The "normal" use of inline functions
13 * is to use the inline functions in the module in which they are
14 * defined. In this case these inline functions are used in external
15 * modules and therefore the use of "inline extern". What this means
16 * is as follows: if a function foo is declared as "inline extern"this
17 * definition is only used for inlining, in no case is the function
18 * compiled on its own. If the compiler cannot inline the function it
19 * becomes an external reference. Therefore in IxQMgrAqmIf.c all
20 * inline functions are defined without the "inline extern" specifier
21 * and so define the external references. In all other modules these
22 * funtions are defined as "inline extern".
25 * @par
26 * IXP400 SW Release version 2.0
28 * -- Copyright Notice --
30 * @par
31 * Copyright 2001-2005, Intel Corporation.
32 * All rights reserved.
34 * @par
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
37 * are met:
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. Neither the name of the Intel Corporation nor the names of its contributors
44 * may be used to endorse or promote products derived from this software
45 * without specific prior written permission.
47 * @par
48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
49 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
60 * @par
61 * -- End of Copyright Notice --
64 #ifndef IXQMGRAQMIF_P_H
65 #define IXQMGRAQMIF_P_H
67 #include "IxOsalTypes.h"
70 * inline definition
73 #ifdef IX_OSAL_INLINE_ALL
74 /* If IX_OSAL_INLINE_ALL is set then each inlineable API functions will be defined as
75 inline functions */
76 #define IX_QMGR_AQMIF_INLINE IX_OSAL_INLINE_EXTERN
77 #else
78 #ifdef IXQMGRAQMIF_C
79 #ifndef IX_QMGR_AQMIF_INLINE
80 #define IX_QMGR_AQMIF_INLINE
81 #endif
82 #else
83 #ifndef IX_QMGR_AQMIF_INLINE
84 #define IX_QMGR_AQMIF_INLINE IX_OSAL_INLINE_EXTERN
85 #endif
86 #endif /* IXQMGRAQMIF_C */
87 #endif /* IX_OSAL_INLINE */
91 * User defined include files.
93 #include "IxQMgr.h"
94 #include "IxQMgrLog_p.h"
95 #include "IxQMgrQCfg_p.h"
97 /* Because this file contains inline functions which will be compiled into
98 * other components, we need to ensure that the IX_COMPONENT_NAME define
99 * is set to ix_qmgr while this code is being compiled. This will ensure
100 * that the correct implementation is provided for the memory access macros
101 * IX_OSAL_READ_LONG and IX_OSAL_WRITE_LONG which are used in this file.
102 * This must be done before including "IxOsalMemAccess.h"
104 #define IX_QMGR_AQMIF_SAVED_COMPONENT_NAME IX_COMPONENT_NAME
105 #undef IX_COMPONENT_NAME
106 #define IX_COMPONENT_NAME ix_qmgr
107 #include "IxOsal.h"
110 * #defines and macros used in this file.
113 /* Number of bytes per word */
114 #define IX_QMGR_NUM_BYTES_PER_WORD 4
116 /* Underflow bit mask */
117 #define IX_QMGR_UNDERFLOW_BIT_OFFSET 0x0
119 /* Overflow bit mask */
120 #define IX_QMGR_OVERFLOW_BIT_OFFSET 0x1
122 /* Queue access register, queue 0 */
123 #define IX_QMGR_QUEACC0_OFFSET 0x0000
125 /* Size of queue access register in words */
126 #define IX_QMGR_QUEACC_SIZE 0x4/*words*/
128 /* Queue status register, queues 0-7 */
129 #define IX_QMGR_QUELOWSTAT0_OFFSET (IX_QMGR_QUEACC0_OFFSET +\
130 (IX_QMGR_MAX_NUM_QUEUES * IX_QMGR_QUEACC_SIZE * IX_QMGR_NUM_BYTES_PER_WORD))
132 /* Queue status register, queues 8-15 */
133 #define IX_QMGR_QUELOWSTAT1_OFFSET (IX_QMGR_QUELOWSTAT0_OFFSET +\
134 IX_QMGR_NUM_BYTES_PER_WORD)
136 /* Queue status register, queues 16-23 */
137 #define IX_QMGR_QUELOWSTAT2_OFFSET (IX_QMGR_QUELOWSTAT1_OFFSET +\
138 IX_QMGR_NUM_BYTES_PER_WORD)
140 /* Queue status register, queues 24-31 */
141 #define IX_QMGR_QUELOWSTAT3_OFFSET (IX_QMGR_QUELOWSTAT2_OFFSET +\
142 IX_QMGR_NUM_BYTES_PER_WORD)
144 /* Queue status register Q status bits mask */
145 #define IX_QMGR_QUELOWSTAT_QUE_STS_BITS_MASK 0xF
147 /* Size of queue 0-31 status register */
148 #define IX_QMGR_QUELOWSTAT_SIZE 0x4 /*words*/
150 /* The number of queues' status specified per word */
151 #define IX_QMGR_QUELOWSTAT_NUM_QUE_PER_WORD 0x8
153 /* Queue UF/OF status register queues 0-15 */
154 #define IX_QMGR_QUEUOSTAT0_OFFSET (IX_QMGR_QUELOWSTAT3_OFFSET +\
155 IX_QMGR_NUM_BYTES_PER_WORD)
156 /* Queue UF/OF status register queues 16-31 */
157 #define IX_QMGR_QUEUOSTAT1_OFFSET (IX_QMGR_QUEUOSTAT0_OFFSET +\
158 IX_QMGR_NUM_BYTES_PER_WORD)
160 /* The number of queues' underflow/overflow status specified per word */
161 #define IX_QMGR_QUEUOSTAT_NUM_QUE_PER_WORD 0x10
163 /* Queue NE status register, queues 32-63 */
164 #define IX_QMGR_QUEUPPSTAT0_OFFSET (IX_QMGR_QUEUOSTAT1_OFFSET +\
165 IX_QMGR_NUM_BYTES_PER_WORD)
167 /* Queue F status register, queues 32-63 */
168 #define IX_QMGR_QUEUPPSTAT1_OFFSET (IX_QMGR_QUEUPPSTAT0_OFFSET +\
169 IX_QMGR_NUM_BYTES_PER_WORD)
171 /* Size of queue 32-63 status register */
172 #define IX_QMGR_QUEUPPSTAT_SIZE 0x2 /*words*/
174 /* The number of queues' status specified per word */
175 #define IX_QMGR_QUEUPPSTAT_NUM_QUE_PER_WORD 0x20
177 /* Queue INT source select register, queues 0-7 */
178 #define IX_QMGR_INT0SRCSELREG0_OFFSET (IX_QMGR_QUEUPPSTAT1_OFFSET +\
179 IX_QMGR_NUM_BYTES_PER_WORD)
181 /* Queue INT source select register, queues 8-15 */
182 #define IX_QMGR_INT0SRCSELREG1_OFFSET (IX_QMGR_INT0SRCSELREG0_OFFSET+\
183 IX_QMGR_NUM_BYTES_PER_WORD)
185 /* Queue INT source select register, queues 16-23 */
186 #define IX_QMGR_INT0SRCSELREG2_OFFSET (IX_QMGR_INT0SRCSELREG1_OFFSET+\
187 IX_QMGR_NUM_BYTES_PER_WORD)
189 /* Queue INT source select register, queues 24-31 */
190 #define IX_QMGR_INT0SRCSELREG3_OFFSET (IX_QMGR_INT0SRCSELREG2_OFFSET+\
191 IX_QMGR_NUM_BYTES_PER_WORD)
193 /* Size of interrupt source select reegister */
194 #define IX_QMGR_INT0SRCSELREG_SIZE 0x4 /*words*/
196 /* The number of queues' interrupt source select specified per word*/
197 #define IX_QMGR_INTSRC_NUM_QUE_PER_WORD 0x8
199 /* Queue INT enable register, queues 0-31 */
200 #define IX_QMGR_QUEIEREG0_OFFSET (IX_QMGR_INT0SRCSELREG3_OFFSET +\
201 IX_QMGR_NUM_BYTES_PER_WORD)
203 /* Queue INT enable register, queues 32-63 */
204 #define IX_QMGR_QUEIEREG1_OFFSET (IX_QMGR_QUEIEREG0_OFFSET +\
205 IX_QMGR_NUM_BYTES_PER_WORD)
207 /* Queue INT register, queues 0-31 */
208 #define IX_QMGR_QINTREG0_OFFSET (IX_QMGR_QUEIEREG1_OFFSET +\
209 IX_QMGR_NUM_BYTES_PER_WORD)
211 /* Queue INT register, queues 32-63 */
212 #define IX_QMGR_QINTREG1_OFFSET (IX_QMGR_QINTREG0_OFFSET +\
213 IX_QMGR_NUM_BYTES_PER_WORD)
215 /* Size of interrupt register */
216 #define IX_QMGR_QINTREG_SIZE 0x2 /*words*/
218 /* Number of queues' status specified per word */
219 #define IX_QMGR_QINTREG_NUM_QUE_PER_WORD 0x20
221 /* Number of bits per queue interrupt status */
222 #define IX_QMGR_QINTREG_BITS_PER_QUEUE 0x1
223 #define IX_QMGR_QINTREG_BIT_OFFSET 0x1
225 /* Size of address space not used by AQM */
226 #define IX_QMGR_AQM_UNUSED_ADDRESS_SPACE_SIZE_IN_BYTES 0x1bC0
228 /* Queue config register, queue 0 */
229 #define IX_QMGR_QUECONFIG_BASE_OFFSET (IX_QMGR_QINTREG1_OFFSET +\
230 IX_QMGR_NUM_BYTES_PER_WORD +\
231 IX_QMGR_AQM_UNUSED_ADDRESS_SPACE_SIZE_IN_BYTES)
233 /* Total size of configuration words */
234 #define IX_QMGR_QUECONFIG_SIZE 0x100
236 /* Start of SRAM queue buffer space */
237 #define IX_QMGR_QUEBUFFER_SPACE_OFFSET (IX_QMGR_QUECONFIG_BASE_OFFSET +\
238 IX_QMGR_MAX_NUM_QUEUES * IX_QMGR_NUM_BYTES_PER_WORD)
240 /* Total bits in a word */
241 #define BITS_PER_WORD 32
243 /* Size of queue buffer space */
244 #define IX_QMGR_QUE_BUFFER_SPACE_SIZE 0x1F00
247 * This macro will return the address of the access register for the
248 * queue specified by qId
250 #define IX_QMGR_Q_ACCESS_ADDR_GET(qId)\
251 (((qId) * (IX_QMGR_QUEACC_SIZE * IX_QMGR_NUM_BYTES_PER_WORD))\
252 + IX_QMGR_QUEACC0_OFFSET)
255 * Bit location of bit-3 of INT0SRCSELREG0 register to enabled
256 * sticky interrupt register.
258 #define IX_QMGR_INT0SRCSELREG0_BIT3 3
261 * Variable declerations global to this file. Externs are followed by
262 * statics.
264 extern UINT32 aqmBaseAddress;
267 * Function declarations.
269 void
270 ixQMgrAqmIfInit (void);
272 void
273 ixQMgrAqmIfUninit (void);
275 unsigned
276 ixQMgrAqmIfLog2 (unsigned number);
278 void
279 ixQMgrAqmIfQRegisterBitsWrite (IxQMgrQId qId,
280 UINT32 registerBaseAddrOffset,
281 unsigned queuesPerRegWord,
282 UINT32 value);
284 void
285 ixQMgrAqmIfQStatusCheckValsCalc (IxQMgrQId qId,
286 IxQMgrSourceId srcSel,
287 unsigned int *statusWordOffset,
288 UINT32 *checkValue,
289 UINT32 *mask);
291 * The Xscale software allways deals with logical addresses and so the
292 * base address of the AQM memory space is not a hardcoded value. This
293 * function must be called before any other function in this component.
294 * NO CHECKING is performed to ensure that the base address has been
295 * set.
297 void
298 ixQMgrAqmIfBaseAddressSet (UINT32 address);
301 * Get the base address of the AQM memory space.
303 void
304 ixQMgrAqmIfBaseAddressGet (UINT32 *address);
307 * Get the sram base address
309 void
310 ixQMgrAqmIfSramBaseAddressGet (UINT32 *address);
313 * Read a queue status
315 void
316 ixQMgrAqmIfQueStatRead (IxQMgrQId qId,
317 IxQMgrQStatus* status);
321 * Set INT0SRCSELREG0 Bit3
323 void ixQMgrAqmIfIntSrcSelReg0Bit3Set (void);
327 * Set the interrupt source
329 void
330 ixQMgrAqmIfIntSrcSelWrite (IxQMgrQId qId,
331 IxQMgrSourceId sourceId);
334 * Enable interruptson a queue
336 void
337 ixQMgrAqmIfQInterruptEnable (IxQMgrQId qId);
340 * Disable interrupt on a quee
342 void
343 ixQMgrAqmIfQInterruptDisable (IxQMgrQId qId);
346 * Write the config register of the specified queue
348 void
349 ixQMgrAqmIfQueCfgWrite (IxQMgrQId qId,
350 IxQMgrQSizeInWords qSizeInWords,
351 IxQMgrQEntrySizeInWords entrySizeInWords,
352 UINT32 freeSRAMAddress);
355 * read fields from the config of the specified queue.
357 void
358 ixQMgrAqmIfQueCfgRead (IxQMgrQId qId,
359 unsigned int numEntries,
360 UINT32 *baseAddress,
361 unsigned int *ne,
362 unsigned int *nf,
363 UINT32 *readPtr,
364 UINT32 *writePtr);
367 * Set the ne and nf watermark level on a queue.
369 void
370 ixQMgrAqmIfWatermarkSet (IxQMgrQId qId,
371 unsigned ne,
372 unsigned nf);
374 /* Inspect an entry without moving the read pointer */
375 IX_STATUS
376 ixQMgrAqmIfQPeek (IxQMgrQId qId,
377 unsigned int entryIndex,
378 unsigned int *entry);
380 /* Modify an entry without moving the write pointer */
381 IX_STATUS
382 ixQMgrAqmIfQPoke (IxQMgrQId qId,
383 unsigned int entryIndex,
384 unsigned int *entry);
387 * Function prototype for inline functions. For description refers to
388 * the functions defintion below.
390 IX_QMGR_AQMIF_INLINE void
391 ixQMgrAqmIfWordWrite (VUINT32 *address,
392 UINT32 word);
394 IX_QMGR_AQMIF_INLINE void
395 ixQMgrAqmIfWordRead (VUINT32 *address,
396 UINT32 *word);
398 IX_QMGR_AQMIF_INLINE void
399 ixQMgrAqmIfQPop (IxQMgrQId qId,
400 IxQMgrQEntrySizeInWords numWords,
401 UINT32 *entry);
403 IX_QMGR_AQMIF_INLINE void
404 ixQMgrAqmIfQPush (IxQMgrQId qId,
405 IxQMgrQEntrySizeInWords numWords,
406 UINT32 *entry);
408 IX_QMGR_AQMIF_INLINE void
409 ixQMgrAqmIfQStatusRegsRead (IxQMgrDispatchGroup group,
410 UINT32 *qStatusWords);
412 IX_QMGR_AQMIF_INLINE BOOL
413 ixQMgrAqmIfQStatusCheck (UINT32 *oldQStatusWords,
414 UINT32 *newQStatusWords,
415 unsigned int statusWordOffset,
416 UINT32 checkValue,
417 UINT32 mask);
419 IX_QMGR_AQMIF_INLINE BOOL
420 ixQMgrAqmIfRegisterBitCheck (IxQMgrQId qId,
421 UINT32 registerBaseAddrOffset,
422 unsigned queuesPerRegWord,
423 unsigned relativeBitOffset,
424 BOOL reset);
426 IX_QMGR_AQMIF_INLINE BOOL
427 ixQMgrAqmIfUnderflowCheck (IxQMgrQId qId);
429 IX_QMGR_AQMIF_INLINE BOOL
430 ixQMgrAqmIfOverflowCheck (IxQMgrQId qId);
432 IX_QMGR_AQMIF_INLINE UINT32
433 ixQMgrAqmIfQRegisterBitsRead (IxQMgrQId qId,
434 UINT32 registerBaseAddrOffset,
435 unsigned queuesPerRegWord);
436 IX_QMGR_AQMIF_INLINE void
437 ixQMgrAqmIfQInterruptRegWrite (IxQMgrDispatchGroup group,
438 UINT32 reg);
439 IX_QMGR_AQMIF_INLINE void
440 ixQMgrAqmIfQInterruptRegRead (IxQMgrDispatchGroup group,
441 UINT32 *regVal);
443 IX_QMGR_AQMIF_INLINE void
444 ixQMgrAqmIfQueLowStatRead (IxQMgrQId qId,
445 IxQMgrQStatus *status);
447 IX_QMGR_AQMIF_INLINE void
448 ixQMgrAqmIfQueUppStatRead (IxQMgrQId qId,
449 IxQMgrQStatus *status);
451 IX_QMGR_AQMIF_INLINE void
452 ixQMgrAqmIfQueStatRead (IxQMgrQId qId,
453 IxQMgrQStatus *qStatus);
455 IX_QMGR_AQMIF_INLINE unsigned
456 ixQMgrAqmIfPow2NumDivide (unsigned numerator,
457 unsigned denominator);
459 IX_QMGR_AQMIF_INLINE void
460 ixQMgrAqmIfQInterruptEnableRegRead (IxQMgrDispatchGroup group,
461 UINT32 *regVal);
463 * Inline functions
467 * This inline function is used by other QMgr components to write one
468 * word to the specified address.
470 IX_QMGR_AQMIF_INLINE void
471 ixQMgrAqmIfWordWrite (VUINT32 *address,
472 UINT32 word)
474 IX_OSAL_WRITE_LONG(address, word);
478 * This inline function is used by other QMgr components to read a
479 * word from the specified address.
481 IX_QMGR_AQMIF_INLINE void
482 ixQMgrAqmIfWordRead (VUINT32 *address,
483 UINT32 *word)
485 *word = IX_OSAL_READ_LONG(address);
490 * This inline function is used by other QMgr components to pop an
491 * entry off the specified queue.
493 IX_QMGR_AQMIF_INLINE void
494 ixQMgrAqmIfQPop (IxQMgrQId qId,
495 IxQMgrQEntrySizeInWords numWords,
496 UINT32 *entry)
498 volatile UINT32 *accRegAddr;
500 accRegAddr = (UINT32*)(aqmBaseAddress +
501 IX_QMGR_Q_ACCESS_ADDR_GET(qId));
503 switch (numWords)
505 case IX_QMGR_Q_ENTRY_SIZE1:
506 ixQMgrAqmIfWordRead (accRegAddr, entry);
507 break;
508 case IX_QMGR_Q_ENTRY_SIZE2:
509 ixQMgrAqmIfWordRead (accRegAddr++, entry++);
510 ixQMgrAqmIfWordRead (accRegAddr, entry);
511 break;
512 case IX_QMGR_Q_ENTRY_SIZE4:
513 ixQMgrAqmIfWordRead (accRegAddr++, entry++);
514 ixQMgrAqmIfWordRead (accRegAddr++, entry++);
515 ixQMgrAqmIfWordRead (accRegAddr++, entry++);
516 ixQMgrAqmIfWordRead (accRegAddr, entry);
517 break;
518 default:
519 IX_QMGR_LOG_ERROR0("Invalid Q Entry size passed to ixQMgrAqmIfQPop");
520 break;
525 * This inline function is used by other QMgr components to push an
526 * entry to the specified queue.
528 IX_QMGR_AQMIF_INLINE void
529 ixQMgrAqmIfQPush (IxQMgrQId qId,
530 IxQMgrQEntrySizeInWords numWords,
531 UINT32 *entry)
533 volatile UINT32 *accRegAddr;
535 accRegAddr = (UINT32*)(aqmBaseAddress +
536 IX_QMGR_Q_ACCESS_ADDR_GET(qId));
538 switch (numWords)
540 case IX_QMGR_Q_ENTRY_SIZE1:
541 ixQMgrAqmIfWordWrite (accRegAddr, *entry);
542 break;
543 case IX_QMGR_Q_ENTRY_SIZE2:
544 ixQMgrAqmIfWordWrite (accRegAddr++, *entry++);
545 ixQMgrAqmIfWordWrite (accRegAddr, *entry);
546 break;
547 case IX_QMGR_Q_ENTRY_SIZE4:
548 ixQMgrAqmIfWordWrite (accRegAddr++, *entry++);
549 ixQMgrAqmIfWordWrite (accRegAddr++, *entry++);
550 ixQMgrAqmIfWordWrite (accRegAddr++, *entry++);
551 ixQMgrAqmIfWordWrite (accRegAddr, *entry);
552 break;
553 default:
554 IX_QMGR_LOG_ERROR0("Invalid Q Entry size passed to ixQMgrAqmIfQPush");
555 break;
560 * The AQM interrupt registers contains a bit for each AQM queue
561 * specifying the queue (s) that cause an interrupt to fire. This
562 * function is called by IxQMGrDispatcher component.
564 IX_QMGR_AQMIF_INLINE void
565 ixQMgrAqmIfQStatusRegsRead (IxQMgrDispatchGroup group,
566 UINT32 *qStatusWords)
568 volatile UINT32 *regAddress = NULL;
570 if (group == IX_QMGR_QUELOW_GROUP)
572 regAddress = (UINT32*)(aqmBaseAddress +
573 IX_QMGR_QUELOWSTAT0_OFFSET);
575 ixQMgrAqmIfWordRead (regAddress++, qStatusWords++);
576 ixQMgrAqmIfWordRead (regAddress++, qStatusWords++);
577 ixQMgrAqmIfWordRead (regAddress++, qStatusWords++);
578 ixQMgrAqmIfWordRead (regAddress, qStatusWords);
580 else /* We have the upper queues */
582 /* Only need to read the Nearly Empty status register for
583 * queues 32-63 as for therse queues the interrtupt source
584 * condition is fixed to Nearly Empty
586 regAddress = (UINT32*)(aqmBaseAddress +
587 IX_QMGR_QUEUPPSTAT0_OFFSET);
588 ixQMgrAqmIfWordRead (regAddress, qStatusWords);
594 * This function check if the status for a queue has changed between
595 * 2 snapshots and if it has, that the status matches a particular
596 * value after masking.
598 IX_QMGR_AQMIF_INLINE BOOL
599 ixQMgrAqmIfQStatusCheck (UINT32 *oldQStatusWords,
600 UINT32 *newQStatusWords,
601 unsigned int statusWordOffset,
602 UINT32 checkValue,
603 UINT32 mask)
605 if (((oldQStatusWords[statusWordOffset] & mask) !=
606 (newQStatusWords[statusWordOffset] & mask)) &&
607 ((newQStatusWords[statusWordOffset] & mask) == checkValue))
609 return TRUE;
612 return FALSE;
616 * The AQM interrupt register contains a bit for each AQM queue
617 * specifying the queue (s) that cause an interrupt to fire. This
618 * function is called by IxQMgrDispatcher component.
620 IX_QMGR_AQMIF_INLINE void
621 ixQMgrAqmIfQInterruptRegRead (IxQMgrDispatchGroup group,
622 UINT32 *regVal)
624 volatile UINT32 *regAddress;
626 if (group == IX_QMGR_QUELOW_GROUP)
628 regAddress = (UINT32*)(aqmBaseAddress +
629 IX_QMGR_QINTREG0_OFFSET);
631 else
633 regAddress = (UINT32*)(aqmBaseAddress +
634 IX_QMGR_QINTREG1_OFFSET);
637 ixQMgrAqmIfWordRead (regAddress, regVal);
641 * The AQM interrupt enable register contains a bit for each AQM queue.
642 * This function reads the interrupt enable register. This
643 * function is called by IxQMgrDispatcher component.
645 IX_QMGR_AQMIF_INLINE void
646 ixQMgrAqmIfQInterruptEnableRegRead (IxQMgrDispatchGroup group,
647 UINT32 *regVal)
649 volatile UINT32 *regAddress;
651 if (group == IX_QMGR_QUELOW_GROUP)
653 regAddress = (UINT32*)(aqmBaseAddress +
654 IX_QMGR_QUEIEREG0_OFFSET);
656 else
658 regAddress = (UINT32*)(aqmBaseAddress +
659 IX_QMGR_QUEIEREG1_OFFSET);
662 ixQMgrAqmIfWordRead (regAddress, regVal);
667 * This inline function will read the status bit of a queue
668 * specified by qId. If reset is TRUE the bit is cleared.
670 IX_QMGR_AQMIF_INLINE BOOL
671 ixQMgrAqmIfRegisterBitCheck (IxQMgrQId qId,
672 UINT32 registerBaseAddrOffset,
673 unsigned queuesPerRegWord,
674 unsigned relativeBitOffset,
675 BOOL reset)
677 UINT32 actualBitOffset;
678 volatile UINT32 *registerAddress;
679 UINT32 registerWord;
682 * Calculate the registerAddress
683 * multiple queues split accross registers
685 registerAddress = (UINT32*)(aqmBaseAddress +
686 registerBaseAddrOffset +
687 ((qId / queuesPerRegWord) *
688 IX_QMGR_NUM_BYTES_PER_WORD));
691 * Get the status word
693 ixQMgrAqmIfWordRead (registerAddress, &registerWord);
696 * Calculate the actualBitOffset
697 * status for multiple queues stored in one register
699 actualBitOffset = (relativeBitOffset + 1) <<
700 ((qId & (queuesPerRegWord - 1)) * (BITS_PER_WORD / queuesPerRegWord));
702 /* Check if the status bit is set */
703 if (registerWord & actualBitOffset)
705 /* Clear the bit if reset */
706 if (reset)
708 ixQMgrAqmIfWordWrite (registerAddress, registerWord & (~actualBitOffset));
710 return TRUE;
713 /* Bit not set */
714 return FALSE;
719 * @ingroup IxQmgrAqmIfAPI
721 * @brief Read the underflow status of a queue
723 * This inline function will read the underflow status of a queue
724 * specified by qId.
727 IX_QMGR_AQMIF_INLINE BOOL
728 ixQMgrAqmIfUnderflowCheck (IxQMgrQId qId)
730 if (qId < IX_QMGR_MIN_QUEUPP_QID)
732 return (ixQMgrAqmIfRegisterBitCheck (qId,
733 IX_QMGR_QUEUOSTAT0_OFFSET,
734 IX_QMGR_QUEUOSTAT_NUM_QUE_PER_WORD,
735 IX_QMGR_UNDERFLOW_BIT_OFFSET,
736 TRUE/*reset*/));
738 else
740 /* Qs 32-63 have no underflow status */
741 return FALSE;
746 * This inline function will read the overflow status of a queue
747 * specified by qId.
749 IX_QMGR_AQMIF_INLINE BOOL
750 ixQMgrAqmIfOverflowCheck (IxQMgrQId qId)
752 if (qId < IX_QMGR_MIN_QUEUPP_QID)
754 return (ixQMgrAqmIfRegisterBitCheck (qId,
755 IX_QMGR_QUEUOSTAT0_OFFSET,
756 IX_QMGR_QUEUOSTAT_NUM_QUE_PER_WORD,
757 IX_QMGR_OVERFLOW_BIT_OFFSET,
758 TRUE/*reset*/));
760 else
762 /* Qs 32-63 have no overflow status */
763 return FALSE;
768 * This inline function will read the status bits of a queue
769 * specified by qId.
771 IX_QMGR_AQMIF_INLINE UINT32
772 ixQMgrAqmIfQRegisterBitsRead (IxQMgrQId qId,
773 UINT32 registerBaseAddrOffset,
774 unsigned queuesPerRegWord)
776 volatile UINT32 *registerAddress;
777 UINT32 registerWord;
778 UINT32 statusBitsMask;
779 UINT32 bitsPerQueue;
781 bitsPerQueue = BITS_PER_WORD / queuesPerRegWord;
784 * Calculate the registerAddress
785 * multiple queues split accross registers
787 registerAddress = (UINT32*)(aqmBaseAddress +
788 registerBaseAddrOffset +
789 ((qId / queuesPerRegWord) *
790 IX_QMGR_NUM_BYTES_PER_WORD));
792 * Read the status word
794 ixQMgrAqmIfWordRead (registerAddress, &registerWord);
798 * Calculate the mask for the status bits for this queue.
800 statusBitsMask = ((1 << bitsPerQueue) - 1);
803 * Shift the status word so it is right justified
805 registerWord >>= ((qId & (queuesPerRegWord - 1)) * bitsPerQueue);
808 * Mask out all bar the status bits for this queue
810 return (registerWord &= statusBitsMask);
814 * This function is called by IxQMgrDispatcher to set the contents of
815 * the AQM interrupt register.
817 IX_QMGR_AQMIF_INLINE void
818 ixQMgrAqmIfQInterruptRegWrite (IxQMgrDispatchGroup group,
819 UINT32 reg)
821 volatile UINT32 *address;
823 if (group == IX_QMGR_QUELOW_GROUP)
825 address = (UINT32*)(aqmBaseAddress +
826 IX_QMGR_QINTREG0_OFFSET);
828 else
830 address = (UINT32*)(aqmBaseAddress +
831 IX_QMGR_QINTREG1_OFFSET);
834 ixQMgrAqmIfWordWrite (address, reg);
838 * Read the status of a queue in the range 0-31.
840 * This function is used by other QMgr components to read the
841 * status of the queue specified by qId.
843 IX_QMGR_AQMIF_INLINE void
844 ixQMgrAqmIfQueLowStatRead (IxQMgrQId qId,
845 IxQMgrQStatus *status)
847 /* Read the general status bits */
848 *status = ixQMgrAqmIfQRegisterBitsRead (qId,
849 IX_QMGR_QUELOWSTAT0_OFFSET,
850 IX_QMGR_QUELOWSTAT_NUM_QUE_PER_WORD);
854 * This function will read the status of the queue specified
855 * by qId.
857 IX_QMGR_AQMIF_INLINE void
858 ixQMgrAqmIfQueUppStatRead (IxQMgrQId qId,
859 IxQMgrQStatus *status)
861 /* Reset the status bits */
862 *status = 0;
865 * Check if the queue is nearly empty,
866 * N.b. QUPP stat register contains status for regs 32-63 at each
867 * bit position so subtract 32 to get bit offset
869 if (ixQMgrAqmIfRegisterBitCheck ((qId - IX_QMGR_MIN_QUEUPP_QID),
870 IX_QMGR_QUEUPPSTAT0_OFFSET,
871 IX_QMGR_QUEUPPSTAT_NUM_QUE_PER_WORD,
872 0/*relativeBitOffset*/,
873 FALSE/*!reset*/))
875 *status |= IX_QMGR_Q_STATUS_NE_BIT_MASK;
879 * Check if the queue is full,
880 * N.b. QUPP stat register contains status for regs 32-63 at each
881 * bit position so subtract 32 to get bit offset
883 if (ixQMgrAqmIfRegisterBitCheck ((qId - IX_QMGR_MIN_QUEUPP_QID),
884 IX_QMGR_QUEUPPSTAT1_OFFSET,
885 IX_QMGR_QUEUPPSTAT_NUM_QUE_PER_WORD,
886 0/*relativeBitOffset*/,
887 FALSE/*!reset*/))
889 *status |= IX_QMGR_Q_STATUS_F_BIT_MASK;
894 * This function is used by other QMgr components to read the
895 * status of the queue specified by qId.
897 IX_QMGR_AQMIF_INLINE void
898 ixQMgrAqmIfQueStatRead (IxQMgrQId qId,
899 IxQMgrQStatus *qStatus)
901 if (qId < IX_QMGR_MIN_QUEUPP_QID)
903 ixQMgrAqmIfQueLowStatRead (qId, qStatus);
905 else
907 ixQMgrAqmIfQueUppStatRead (qId, qStatus);
913 * This function performs a mod division
915 IX_QMGR_AQMIF_INLINE unsigned
916 ixQMgrAqmIfPow2NumDivide (unsigned numerator,
917 unsigned denominator)
919 /* Number is evenly divisable by 2 */
920 return (numerator >> ixQMgrAqmIfLog2 (denominator));
923 /* Restore IX_COMPONENT_NAME */
924 #undef IX_COMPONENT_NAME
925 #define IX_COMPONENT_NAME IX_QMGR_AQMIF_SAVED_COMPONENT_NAME
927 #endif/*IXQMGRAQMIF_P_H*/