1 1.1.10.2 yamt /* $NetBSD: gemini_ipmvar.h,v 1.1.10.2 2009/05/04 08:10:41 yamt Exp $ */ 2 1.1.10.2 yamt 3 1.1.10.2 yamt #ifndef _GEMINI_IPMVAR_H_ 4 1.1.10.2 yamt #define _GEMINI_IPMVAR_H_ 5 1.1.10.2 yamt 6 1.1.10.2 yamt /* 7 1.1.10.2 yamt * message queue 8 1.1.10.2 yamt * 9 1.1.10.2 yamt * - the queue gets located in memory shared between cores 10 1.1.10.2 yamt * - is mapped non-cached so SW coherency is not required. 11 1.1.10.2 yamt * - be sure ipm_queue_t starts on 32 bit (min) boundary to align descriptors 12 1.1.10.2 yamt * - note that indicies are 8 bit and NIPMDESC < (1<<8) 13 1.1.10.2 yamt * be sure to adjust typedef if size is increased 14 1.1.10.2 yamt * - current sizes, typedef, and padding make sizeof(ipm_queue_t) == 4096 15 1.1.10.2 yamt */ 16 1.1.10.2 yamt typedef uint32_t ipmqindex_t; 17 1.1.10.2 yamt #define NIPMDESC 255 18 1.1.10.2 yamt #define IPMQPADSZ (4096 - ((sizeof(ipm_desc_t) * NIPMDESC) + (2 * sizeof(ipmqindex_t)))) 19 1.1.10.2 yamt typedef struct ipm_queue { 20 1.1.10.2 yamt ipm_desc_t ipm_desc[NIPMDESC]; 21 1.1.10.2 yamt volatile ipmqindex_t ix_write; /* writer increments and inserts here */ 22 1.1.10.2 yamt volatile ipmqindex_t ix_read; /* reader extracts here and increments */ 23 1.1.10.2 yamt uint8_t pad[IPMQPADSZ]; 24 1.1.10.2 yamt } ipm_queue_t; 25 1.1.10.2 yamt 26 1.1.10.2 yamt static inline ipmqindex_t 27 1.1.10.2 yamt ipmqnext(ipmqindex_t ix) 28 1.1.10.2 yamt { 29 1.1.10.2 yamt if (++ix >= NIPMDESC) 30 1.1.10.2 yamt ix = 0; 31 1.1.10.2 yamt return ix; 32 1.1.10.2 yamt } 33 1.1.10.2 yamt 34 1.1.10.2 yamt static inline bool 35 1.1.10.2 yamt ipmqisempty(ipmqindex_t ixr, ipmqindex_t ixw) 36 1.1.10.2 yamt { 37 1.1.10.2 yamt if (ixr == ixw) 38 1.1.10.2 yamt return TRUE; 39 1.1.10.2 yamt return FALSE; 40 1.1.10.2 yamt } 41 1.1.10.2 yamt 42 1.1.10.2 yamt static inline bool 43 1.1.10.2 yamt ipmqisfull(ipmqindex_t ixr, ipmqindex_t ixw) 44 1.1.10.2 yamt { 45 1.1.10.2 yamt if (ipmqnext(ixw) == ixr) 46 1.1.10.2 yamt return TRUE; 47 1.1.10.2 yamt return FALSE; 48 1.1.10.2 yamt } 49 1.1.10.2 yamt 50 1.1.10.2 yamt #endif /* _GEMINI_IPMVAR_H_ */ 51