comparison gsm-fw/gpf/osl/os_com_fl.c @ 350:5bc6a8f8b4a8

OSL: os_com_fl.c: reconstructed up to os_GetQueueData()
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 08 May 2014 07:55:06 +0000
parents a163da322bc5
children fd015570cacc
comparison
equal deleted inserted replaced
349:a163da322bc5 350:5bc6a8f8b4a8
17 typedef unsigned char u_char; 17 typedef unsigned char u_char;
18 18
19 extern T_OS_COM_TABLE_ENTRY ComTable[]; 19 extern T_OS_COM_TABLE_ENTRY ComTable[];
20 20
21 static NU_SEMAPHORE ComSemCB; 21 static NU_SEMAPHORE ComSemCB;
22 static USHORT entry = 0;
23 22
24 static int 23 static int
25 os_GetQueueEntry(USHORT Index, OS_HANDLE *Handle) 24 os_GetQueueEntry(USHORT Index, OS_HANDLE *Handle)
26 { 25 {
27 static USHORT Idx; 26 static USHORT Idx;
60 sprintf(Buffer, "Name:%s Startadr:%lx Entries:%d Used:%ld MaxUsed:%d", 59 sprintf(Buffer, "Name:%s Startadr:%lx Entries:%d Used:%ld MaxUsed:%d",
61 ent->Name, (ULONG)ent->pQueueMemory, ent->Entries, (LONG)Used, 60 ent->Name, (ULONG)ent->pQueueMemory, ent->Entries, (LONG)Used,
62 ent->MaxUsed); 61 ent->MaxUsed);
63 return(OS_OK); 62 return(OS_OK);
64 } 63 }
64
65 GLOBAL LONG
66 os_OpenQueue(OS_HANDLE TaskHandle, char *Name, OS_HANDLE *ComHandle)
67 {
68 USHORT i;
69
70 if (!Name)
71 return(OS_ERROR);
72 for (i = 1; i <= MaxCommunications; i++)
73 if (ComTable[i].Name[0] &&
74 !strncmp(ComTable[i].Name, Name, RESOURCE_NAMELEN - 1)) {
75 *ComHandle = i;
76 return(OS_OK);
77 }
78 return(OS_ERROR);
79 }
80
81 GLOBAL LONG
82 os_GetQueueState(OS_HANDLE Caller, OS_HANDLE Handle, ULONG *Used, ULONG *Free)
83 {
84 if (ComTable[Handle].Name[0]) {
85 *Used = ComTable[Handle].UsedSemCB.sm_semaphore_count;
86 *Free = ComTable[Handle].FreeSemCB.sm_semaphore_count;
87 return(OS_OK);
88 } else
89 return(OS_ERROR);
90 }
91
92 GLOBAL LONG
93 os_GetQueueName(OS_HANDLE Caller, OS_HANDLE ComHandle, char *Name)
94 {
95 if (ComHandle > MaxCommunications)
96 return(OS_ERROR);
97 if (!ComTable[ComHandle].Name[0])
98 return(OS_ERROR);
99 strcpy(Name, ComTable[ComHandle].Name);
100 return(OS_OK);
101 }
102
103 GLOBAL LONG
104 os_GetQueueHandle(OS_HANDLE Caller, char *Name, OS_HANDLE *ComHandle)
105 {
106 USHORT i;
107
108 for (i = 1; i <= MaxCommunications; i++)
109 if (ComTable[i].Name[0] &&
110 !strncmp(Name, ComTable[i].Name, RESOURCE_NAMELEN - 1)) {
111 *ComHandle = i;
112 return(OS_OK);
113 }
114 return(OS_ERROR);
115 }
116
117 GLOBAL LONG
118 os_GetQueueData(OS_HANDLE Caller, OS_HANDLE Handle, USHORT Index, USHORT *Type,
119 ULONG *opc, ULONG *ptr, ULONG *time)
120 {
121 static USHORT entry;
122 static T_QDATA_ELEMENT *p;
123
124 if (!ComTable[Handle].Name[0])
125 return(OS_ERROR);
126 if (Index == FIRST_ENTRY) {
127 *Type = ComTable[Handle].current_msg.type;
128 *opc = ComTable[Handle].current_msg.opc;
129 *time = ComTable[Handle].current_msg.time;
130 *ptr = (ULONG) ComTable[Handle].current_msg.ptr;
131 p = ComTable[Handle].pQueueMemory;
132 entry = 0;
133 return(OS_OK);
134 }
135 if (entry >= ComTable[Handle].Entries)
136 return(OS_ERROR);
137 entry++;
138 *Type = p->Data.data16;
139 *ptr = (ULONG) p->Data.ptr;
140 *opc = p->Data.data32;
141 *time = p->Data.time;
142 p++;
143 return(OS_OK);
144 }