annotate gsm-fw/gpf/osl/os_mem_ir.c @ 939:62ca61292b77

gsm-fw: Intel single bank flash driver (Compal) compiles and links
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sat, 31 Oct 2015 23:21:40 +0000
parents c2da9dd01f85
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
436
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This C module is a reconstruction based on the disassembly of
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * os_mem.obj in frame_na7_db_ir.lib from the Leonardo package.
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 /* set of included headers from COFF symtab: */
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "gpfconf.h" /* FreeCalypso addition */
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "../../nucleus/nucleus.h"
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "typedefs.h"
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "os.h"
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "gdi.h"
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "os_types.h"
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "os_glob.h"
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 extern T_OS_PART_GRP_TABLE_ENTRY PartGrpTable[];
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 extern T_OS_POOL_BORDER PoolBorder[];
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 GLOBAL LONG
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 os_is_valid_partition(T_VOID_STRUCT *Buffer)
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 {
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 int i;
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 for (i = 0; i <= MaxPoolGroups; i++) {
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 if (PoolBorder[i].End == 0)
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 return(OS_ERROR);
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 if ((char *)Buffer < PoolBorder[i].Start)
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 continue;
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 if ((char *)Buffer >= PoolBorder[i].End)
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 continue;
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 return(OS_OK);
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 }
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 return(OS_ERROR);
adfc04008d75 OSL: os_mem_ir.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 }
437
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
36
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
37 GLOBAL LONG
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
38 os_PartitionCheck(ULONG *ptr)
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
39 {
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
40 PM_HEADER *phdr;
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
41 PM_PCB *pool;
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
42
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
43 phdr = (PM_HEADER *)(ptr - 2);
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
44 if (phdr->pm_next_available)
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
45 return(OS_PARTITION_FREE);
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
46 pool = phdr->pm_partition_pool;
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
47 if (ptr[(pool->pm_partition_size - 4) >> 2] == GUARD_PATTERN)
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
48 return(OS_OK);
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
49 else
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
50 return(OS_PARTITION_GUARD_PATTERN_DESTROYED);
1d78af921a5a os_mem_ir.c: os_PartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 436
diff changeset
51 }
438
0eb7c6389717 os_mem_ir.c: os_DeallocatePartition() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 437
diff changeset
52
0eb7c6389717 os_mem_ir.c: os_DeallocatePartition() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 437
diff changeset
53 GLOBAL LONG
0eb7c6389717 os_mem_ir.c: os_DeallocatePartition() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 437
diff changeset
54 os_DeallocatePartition(OS_HANDLE TaskHandle, T_VOID_STRUCT *Buffer)
0eb7c6389717 os_mem_ir.c: os_DeallocatePartition() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 437
diff changeset
55 {
0eb7c6389717 os_mem_ir.c: os_DeallocatePartition() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 437
diff changeset
56 if (os_is_valid_partition(Buffer) != OS_OK)
0eb7c6389717 os_mem_ir.c: os_DeallocatePartition() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 437
diff changeset
57 return(OS_ERROR);
0eb7c6389717 os_mem_ir.c: os_DeallocatePartition() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 437
diff changeset
58 if (NU_Deallocate_Partition(Buffer) != NU_SUCCESS)
0eb7c6389717 os_mem_ir.c: os_DeallocatePartition() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 437
diff changeset
59 return(OS_ERROR);
0eb7c6389717 os_mem_ir.c: os_DeallocatePartition() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 437
diff changeset
60 return(OS_OK);
0eb7c6389717 os_mem_ir.c: os_DeallocatePartition() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 437
diff changeset
61 }
439
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
62
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
63 GLOBAL LONG
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
64 os_AllocatePartition(OS_HANDLE TaskHandle, T_VOID_STRUCT **Buffer, ULONG Size,
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
65 ULONG Suspend, OS_HANDLE GroupHandle)
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
66 {
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
67 T_OS_PART_POOL *pool, *requested_pool;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
68 ULONG nu_suspend;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
69 STATUS sts;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
70 int ret;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
71
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
72 for (pool = PartGrpTable[GroupHandle].grp_head; pool;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
73 pool = pool->next)
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
74 if (Size <= pool->size)
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
75 break;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
76 if (!pool)
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
77 return(OS_ERROR);
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
78 requested_pool = pool;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
79 ret = OS_OK;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
80 nu_suspend = NU_NO_SUSPEND;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
81 try_alloc:
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
82 sts = NU_Allocate_Partition(&pool->pcb, (VOID **) Buffer, nu_suspend);
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
83 switch (sts) {
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
84 case NU_SUCCESS:
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
85 return(ret);
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
86 case NU_TIMEOUT:
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
87 case NU_INVALID_SUSPEND:
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
88 *Buffer = 0;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
89 return(OS_TIMEOUT);
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
90 case NU_NO_PARTITION:
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
91 pool = pool->next;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
92 if (pool) {
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
93 ret = OS_ALLOCATED_BIGGER;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
94 goto try_alloc;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
95 }
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
96 pool = requested_pool;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
97 if (Suspend) {
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
98 nu_suspend = Suspend;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
99 ret = OS_WAITED;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
100 goto try_alloc;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
101 }
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
102 return(OS_TIMEOUT);
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
103 default:
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
104 *Buffer = 0;
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
105 return(OS_ERROR);
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
106 }
c2da9dd01f85 OSL: os_mem_ir.c done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 438
diff changeset
107 }