FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/gpf/osl/os_mem_ir.c @ 439:c2da9dd01f85
OSL: os_mem_ir.c done
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 22 Jun 2014 22:10:03 +0000 |
parents | 0eb7c6389717 |
children |
comparison
equal
deleted
inserted
replaced
438:0eb7c6389717 | 439:c2da9dd01f85 |
---|---|
57 return(OS_ERROR); | 57 return(OS_ERROR); |
58 if (NU_Deallocate_Partition(Buffer) != NU_SUCCESS) | 58 if (NU_Deallocate_Partition(Buffer) != NU_SUCCESS) |
59 return(OS_ERROR); | 59 return(OS_ERROR); |
60 return(OS_OK); | 60 return(OS_OK); |
61 } | 61 } |
62 | |
63 GLOBAL LONG | |
64 os_AllocatePartition(OS_HANDLE TaskHandle, T_VOID_STRUCT **Buffer, ULONG Size, | |
65 ULONG Suspend, OS_HANDLE GroupHandle) | |
66 { | |
67 T_OS_PART_POOL *pool, *requested_pool; | |
68 ULONG nu_suspend; | |
69 STATUS sts; | |
70 int ret; | |
71 | |
72 for (pool = PartGrpTable[GroupHandle].grp_head; pool; | |
73 pool = pool->next) | |
74 if (Size <= pool->size) | |
75 break; | |
76 if (!pool) | |
77 return(OS_ERROR); | |
78 requested_pool = pool; | |
79 ret = OS_OK; | |
80 nu_suspend = NU_NO_SUSPEND; | |
81 try_alloc: | |
82 sts = NU_Allocate_Partition(&pool->pcb, (VOID **) Buffer, nu_suspend); | |
83 switch (sts) { | |
84 case NU_SUCCESS: | |
85 return(ret); | |
86 case NU_TIMEOUT: | |
87 case NU_INVALID_SUSPEND: | |
88 *Buffer = 0; | |
89 return(OS_TIMEOUT); | |
90 case NU_NO_PARTITION: | |
91 pool = pool->next; | |
92 if (pool) { | |
93 ret = OS_ALLOCATED_BIGGER; | |
94 goto try_alloc; | |
95 } | |
96 pool = requested_pool; | |
97 if (Suspend) { | |
98 nu_suspend = Suspend; | |
99 ret = OS_WAITED; | |
100 goto try_alloc; | |
101 } | |
102 return(OS_TIMEOUT); | |
103 default: | |
104 *Buffer = 0; | |
105 return(OS_ERROR); | |
106 } | |
107 } |