Merge pull request #3 in PROCESSOR-SDK/ibl from PRSDK-5675 to master
[keystone-rtos/ibl.git] / src / hw / qm / qm_api.h
1 #ifndef _QM_API_H
2 #define _QM_API_H
3 /*******************************************************************************************
4  * FILE PURPOSE: Boot loader queue manager API definition
5  *******************************************************************************************
6  * FILE NAME: qm_api.h
7  *
8  * DESCRIPTION: Defines the stripped down QM driver API to the boot loader.
9  *
10  ********************************************************************************************/
11  
12 /* return values */
13 #define QM_OK                                0
14 #define QM_INVALID_LINKRAM_ALIGNMENT        -1
15 #define QM_INVALID_MEMREGION_ALIGNMENT      -2
16 #define QM_INVALID_LINKRAM_SIZE             -3
17 #define QM_INVALID_LINKRAM_RAM_SIZE         -4      /* Not enough link ram for the number of descriptors */
20 /* Memory alignment requirements (bytes) */
21 #define QM_LINKRAM_ALIGN        4 
22 #define QM_MEMR_ALIGN           16      /* Not specified in the doc */
24 /* The driver supports only a single descriptor size */
25 #define QM_DESC_SIZE_BYTES      64
27 /* QM setup configuration */
28 typedef struct qmConfig_s  {
30     UINT32 linkRamBase;
31     UINT32 linkRamSize;
32     
33     UINT32 memRegionBase;
34     UINT32 memRegNumDescriptors; 
35     
36     UINT32 destQ;       /* Where the initialized descriptors are placed */
37     
38 } qmConfig_t;
40 typedef struct qmHostDesc_s {
41     /** Descriptor type, packet type, protocol specific region location, packet length */
42     UINT32          descInfo;  
43     /** Source tag, Destination tag */
44     UINT32          tagInfo;
45     /** EPIB present, PS valid word count, error flags, PS flags, return policy, return push policy, 
46      * packet return QM number, packet return queue number */
47     UINT32          packetInfo;
48     /** Number of valid data bytes in the buffer */
49     UINT32          buffLen;
50     /** Byte aligned memory address of the buffer associated with this descriptor */
51     UINT32          buffPtr;
52     /** 32-bit word aligned memory address of the next buffer descriptor */
53     UINT32          nextBDPtr;       
54     /** Completion tag, original buffer size */
55     UINT32          origBufferLen;
56     /** Original buffer pointer */
57     UINT32          origBuffPtr;
58     /** Optional EPIB word0 */
59     UINT32          timeStamp;
60     /** Optional EPIB word1 */
61     UINT32          softwareInfo0;
62     /** Optional EPIB word2 */
63     UINT32          softwareInfo1;
64     /** Optional EPIB word3 */
65     UINT32          softwareInfo2;
66     /** Optional protocol specific data */
67     UINT32          psData; 
68 } qmHostDesc_t;
71 /* Descriptor values */
72 /* Descriptor Info: Descriptor type is host with any protocol specific info in the descriptor */
73 #define QM_DESC_TYPE_HOST           0
74 #define QM_DESC_PSINFO_IN_DESCR     0
75 #define QM_DESC_DEFAULT_DESCINFO       (QM_DESC_TYPE_HOST << 30)    |  \
76                                        (QM_DESC_PSINFO_IN_DESCR << 22)
77 #define QM_DESC_INFO_GET_PSINFO_LOC(x)  BOOT_READ_BITFIELD((x), 22, 22)
78                                                                         
79 #define QM_DESC_DESCINFO_SET_PKT_LEN(x,v)  (x) = BOOT_SET_BITFIELD((x), (v), 21, 0)
80 #define QM_DESC_DESCINFO_GET_PKT_LEN(x)    BOOT_READ_BITFIELD((x), 21, 0)
81                                         
82                                         
83 /* Packet Info */
84 #define QM_DESC_PINFO_EPIB              1
85 #define QM_DESC_PINFO_RETURN_OWN        1
86 #define QM_DESC_DEFAULT_PINFO           (QM_DESC_PINFO_EPIB << 31)          |   \
87                                         (QM_DESC_PINFO_RETURN_OWN << 15) 
88 #define QM_PKT_INFO_GET_EPIB(x)         BOOT_READ_BITFIELD((x), 31, 31)
89 #define QM_PKT_INFO_SET_PSINFO_SIZE(x,v)    (x) = BOOT_SET_BITFIELD((x), (v), 29, 24)                                      
90                                         
91                                                                              
92                                         
93 #define QM_DESC_PINFO_SET_QM(x,v)       (x) = BOOT_SET_BITFIELD((x), (v), 13, 12)
94 #define QM_DESC_PINFO_SET_QUEUE(x,v)    (x) = BOOT_SET_BITFIELD((x), (v), 11,  0)
95                                         
96                                         
97 /*  prototypes */
98 qmHostDesc_t *hwQmQueuePop (UINT32 qnum);
99 void hwQmQueuePush (qmHostDesc_t *hd, UINT32 qnum, UINT32 descSize);
100 SINT16 hwQmSetup (qmConfig_t *cfg);
101 UINT32  hwQmQueueCount (UINT32 qnum);
102 void hwQmTeardown (void);
103 SINT16 hwQmInitThreshold (UINT32 qnum);
108 #endif /* _QM_API_H */