FreeCalypso > hg > fc-magnetite
comparison src/gpf2/osl/os_com_ir.c @ 490:a996d0429c59
OSL os_com_ir.c: system protect/unprotect are macros, not functions
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 22 Jun 2018 16:43:25 +0000 |
parents | f89439ce0d45 |
children |
comparison
equal
deleted
inserted
replaced
489:f89439ce0d45 | 490:a996d0429c59 |
---|---|
10 #include "typedefs.h" | 10 #include "typedefs.h" |
11 #include "os.h" | 11 #include "os.h" |
12 #include "gdi.h" | 12 #include "gdi.h" |
13 #include "os_types.h" | 13 #include "os_types.h" |
14 #include "os_glob.h" | 14 #include "os_glob.h" |
15 | |
16 extern TC_PROTECT TCD_System_Protect; | |
17 extern VOID TCT_Protect(TC_PROTECT *protect); | |
18 extern VOID TCT_Unprotect(VOID); | |
19 extern VOID TCT_Unprotect_Specific(TC_PROTECT *protect); | |
20 | |
21 #define My_System_Protect() TCT_Protect(&TCD_System_Protect) | |
22 #define My_System_Unprotect() TCT_Unprotect_Specific(&TCD_System_Protect) | |
15 | 23 |
16 extern T_OS_COM_TABLE_ENTRY ComTable[]; | 24 extern T_OS_COM_TABLE_ENTRY ComTable[]; |
17 extern unsigned os_tick_to_time_multiplier; | 25 extern unsigned os_tick_to_time_multiplier; |
18 | 26 |
19 extern int ObtainSemaphoreCB(NU_SEMAPHORE *SemCB, ULONG Timeout, | 27 extern int ObtainSemaphoreCB(NU_SEMAPHORE *SemCB, ULONG Timeout, |
38 return(OS_INVALID_QUEUE); | 46 return(OS_INVALID_QUEUE); |
39 CBPtr = &pTable->FreeSemCB; | 47 CBPtr = &pTable->FreeSemCB; |
40 ret = ObtainSemaphoreCB(CBPtr, Suspend, 1); | 48 ret = ObtainSemaphoreCB(CBPtr, Suspend, 1); |
41 if (ret == OS_ERROR || ret == OS_TIMEOUT) | 49 if (ret == OS_ERROR || ret == OS_TIMEOUT) |
42 return(ret); | 50 return(ret); |
43 TCT_System_Protect(); | 51 My_System_Protect(); |
44 elem = pTable->pFreeElement; | 52 elem = pTable->pFreeElement; |
45 pTable->pFreeElement = elem->pNext; | 53 pTable->pFreeElement = elem->pNext; |
46 memcpy(&elem->Data, Msg, sizeof(OS_QDATA)); | 54 memcpy(&elem->Data, Msg, sizeof(OS_QDATA)); |
47 queue = &pTable->Queue[Priority - OS_MIN_PRIORITY]; | 55 queue = &pTable->Queue[Priority - OS_MIN_PRIORITY]; |
48 *queue->pWrite++ = &elem->Data; | 56 *queue->pWrite++ = &elem->Data; |
49 if (queue->pWrite - queue->pStart >= pTable->Entries + 1) | 57 if (queue->pWrite - queue->pStart >= pTable->Entries + 1) |
50 queue->pWrite = queue->pStart; | 58 queue->pWrite = queue->pStart; |
51 watmark = pTable->Entries - CBPtr->sm_semaphore_count; | 59 watmark = pTable->Entries - CBPtr->sm_semaphore_count; |
52 if (pTable->MaxUsed < watmark) | 60 if (pTable->MaxUsed < watmark) |
53 pTable->MaxUsed = watmark; | 61 pTable->MaxUsed = watmark; |
54 TCT_System_Unprotect(); | 62 My_System_Unprotect(); |
55 ReleaseSemaphoreCB(&pTable->UsedSemCB); | 63 ReleaseSemaphoreCB(&pTable->UsedSemCB); |
56 return(ret); | 64 return(ret); |
57 } | 65 } |
58 | 66 |
59 GLOBAL LONG | 67 GLOBAL LONG |
72 return(OS_ERROR); | 80 return(OS_ERROR); |
73 pTable->current_msg.type = 0; | 81 pTable->current_msg.type = 0; |
74 ret = ObtainSemaphoreCB(&pTable->UsedSemCB, Timeout, 0); | 82 ret = ObtainSemaphoreCB(&pTable->UsedSemCB, Timeout, 0); |
75 if (ret == OS_ERROR || ret == OS_TIMEOUT) | 83 if (ret == OS_ERROR || ret == OS_TIMEOUT) |
76 return(ret); | 84 return(ret); |
77 TCT_System_Protect(); | 85 My_System_Protect(); |
78 for (i = OS_MAX_PRIORITY; i >= OS_MIN_PRIORITY; i--) { | 86 for (i = OS_MAX_PRIORITY; i >= OS_MIN_PRIORITY; i--) { |
79 pQueue = &pTable->Queue[i - OS_MIN_PRIORITY]; | 87 pQueue = &pTable->Queue[i - OS_MIN_PRIORITY]; |
80 if (pQueue->pWrite != pQueue->pRead) | 88 if (pQueue->pWrite != pQueue->pRead) |
81 break; | 89 break; |
82 } | 90 } |
83 if (i < OS_MIN_PRIORITY) { | 91 if (i < OS_MIN_PRIORITY) { |
84 TCT_System_Unprotect(); | 92 My_System_Unprotect(); |
85 ReleaseSemaphoreCB(&pTable->FreeSemCB); | 93 ReleaseSemaphoreCB(&pTable->FreeSemCB); |
86 return(OS_ERROR); | 94 return(OS_ERROR); |
87 } | 95 } |
88 memcpy(Msg, *pQueue->pRead, sizeof(OS_QDATA)); | 96 memcpy(Msg, *pQueue->pRead, sizeof(OS_QDATA)); |
89 pElem = (T_QDATA_ELEMENT *)*pQueue->pRead++; | 97 pElem = (T_QDATA_ELEMENT *)*pQueue->pRead++; |
95 pTable->current_msg.type = Msg->data16; | 103 pTable->current_msg.type = Msg->data16; |
96 pTable->current_msg.opc = Msg->data32; | 104 pTable->current_msg.opc = Msg->data32; |
97 c_time = NU_Retrieve_Clock(); | 105 c_time = NU_Retrieve_Clock(); |
98 pTable->current_msg.time = SYSTEM_TICKS_TO_TIME(c_time); | 106 pTable->current_msg.time = SYSTEM_TICKS_TO_TIME(c_time); |
99 pTable->current_msg.ptr = Msg->ptr; | 107 pTable->current_msg.ptr = Msg->ptr; |
100 TCT_System_Unprotect(); | 108 My_System_Unprotect(); |
101 ReleaseSemaphoreCB(&pTable->FreeSemCB); | 109 ReleaseSemaphoreCB(&pTable->FreeSemCB); |
102 return(OS_OK); | 110 return(OS_OK); |
103 } | 111 } |