FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/gpf/osl/os_isr.c @ 348:e63ab4a97e24
OSL: os_isr.c done
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Thu, 08 May 2014 02:58:05 +0000 |
parents | c9dfa0e20640 |
children | 6e6d4c1ec733 |
comparison
equal
deleted
inserted
replaced
347:c9dfa0e20640 | 348:e63ab4a97e24 |
---|---|
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 | 15 |
16 typedef unsigned char u_char; | |
17 | |
16 extern T_OS_OSISR_TABLE_ENTRY OSISRTable[]; | 18 extern T_OS_OSISR_TABLE_ENTRY OSISRTable[]; |
19 extern OS_HANDLE os_int_pool_handle; | |
17 | 20 |
18 GLOBAL LONG | 21 GLOBAL LONG |
19 os_isr_init(void) | 22 os_isr_init(void) |
20 { | 23 { |
21 USHORT i; | 24 USHORT i; |
65 *old_state = 0; | 68 *old_state = 0; |
66 else | 69 else |
67 *old_state = 1; | 70 *old_state = 1; |
68 return(OS_OK); | 71 return(OS_OK); |
69 } | 72 } |
73 | |
74 GLOBAL LONG | |
75 os_DeleteOSISR(OS_HANDLE hisr_handle) | |
76 { | |
77 OS_INT_STATE old_state, state; | |
78 | |
79 if (hisr_handle <= 0 || hisr_handle > MaxOSISRs) | |
80 return(OS_ERROR); | |
81 if (OSISRTable[hisr_handle].hisr_cb.tc_activation_count) | |
82 return(OS_ERROR); | |
83 os_DisableInterrupts(&old_state); | |
84 if (os_DeallocateMemory(os_MyHandle(), OSISRTable[hisr_handle].stack) | |
85 == OS_ERROR) { | |
86 error: os_SetInterruptState(old_state, &state); | |
87 return(OS_ERROR); | |
88 } | |
89 if (NU_Delete_HISR(&OSISRTable[hisr_handle].hisr_cb) != NU_SUCCESS) | |
90 goto error; | |
91 OSISRTable[hisr_handle].name[0] = 0; | |
92 os_SetInterruptState(old_state, &state); | |
93 return(OS_OK); | |
94 } | |
95 | |
96 GLOBAL LONG | |
97 os_CreateOSISR(char *name, void (*OSISR_entry)(void), | |
98 int stacksize, int priority, | |
99 int flags, OS_HANDLE *hisr_handle) | |
100 { | |
101 OS_HANDLE handle; | |
102 T_VOID_STRUCT *hisr_stack; | |
103 OS_INT_STATE old_state, state; | |
104 | |
105 if (priority < 0 || priority > 2) | |
106 return(OS_ERROR); | |
107 priority = 2 - priority; | |
108 os_DisableInterrupts(&old_state); | |
109 for (handle = 1; handle <= MaxOSISRs; handle++) | |
110 if (!strncmp(OSISRTable[handle].name, name, | |
111 RESOURCE_NAMELEN - 1)) { | |
112 error: os_SetInterruptState(old_state, &state); | |
113 return(OS_ERROR); | |
114 } | |
115 for (handle = 1; handle <= MaxOSISRs; handle++) | |
116 if (!OSISRTable[handle].name[0]) | |
117 break; | |
118 if (handle > MaxOSISRs) | |
119 goto error; | |
120 if (os_AllocateMemory(os_MyHandle(), &hisr_stack, stacksize, | |
121 0xFFFFFFFF, os_int_pool_handle) == OS_ERROR) | |
122 goto error; | |
123 memset((u_char *)hisr_stack, INITIAL_STACK_VALUE, stacksize); | |
124 *hisr_stack = GUARD_PATTERN; | |
125 if (NU_Create_HISR(&OSISRTable[handle].hisr_cb, name, OSISR_entry, | |
126 priority, (VOID *)hisr_stack, stacksize) | |
127 != NU_SUCCESS) | |
128 goto error; | |
129 strncpy(OSISRTable[handle].name, name, RESOURCE_NAMELEN); | |
130 OSISRTable[handle].name[RESOURCE_NAMELEN-1] = 0; | |
131 *hisr_handle = handle; | |
132 os_SetInterruptState(old_state, &state); | |
133 return(OS_OK); | |
134 } | |
135 | |
136 GLOBAL LONG | |
137 os_ActivateOSISR(OS_HANDLE hisr_handle) | |
138 { | |
139 if (hisr_handle <= 0 || hisr_handle > MaxOSISRs) | |
140 return(OS_ERROR); | |
141 if (NU_Activate_HISR(&OSISRTable[hisr_handle].hisr_cb) == NU_SUCCESS) | |
142 return(OS_OK); | |
143 else | |
144 return(OS_ERROR); | |
145 } |