annotate gsm-fw/gpf/osl/os_mem_fl.c @ 376:754e72d134a0

os_mem_fl.c: os_GetPartitionPoolStatus() done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 09 Jun 2014 04:53:32 +0000
parents 1319bd1d5ac3
children d148403013c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
370
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This C module is a reconstruction based on the disassembly of
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * os_mem.obj in frame_na7_db_fl.lib from the Leonardo package.
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 /* set of included headers from COFF symtab: */
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "gpfconf.h" /* FreeCalypso addition */
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "../../nucleus/nucleus.h"
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "typedefs.h"
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "os.h"
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "gdi.h"
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "os_types.h"
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "os_glob.h"
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 extern T_OS_PART_GRP_TABLE_ENTRY PartGrpTable[];
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 extern T_OS_MEM_POOL_TABLE_ENTRY MemPoolTable[];
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 extern T_OS_POOL_BORDER PoolBorder[];
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 OS_HANDLE os_ext_pool_handle;
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 OS_HANDLE os_int_pool_handle;
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 static USHORT NumOfMemoryPools;
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 static NU_SEMAPHORE MemSemCB;
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 static NU_MEMORY_POOL mem_pool_head;
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 GLOBAL LONG
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 os_SetPoolHandles(OS_HANDLE ext_pool_handle, OS_HANDLE int_pool_handle)
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 {
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 os_ext_pool_handle = ext_pool_handle;
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 os_int_pool_handle = int_pool_handle;
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 return(OS_OK);
37e19cbbbc8d OSL: os_mem_fl.c started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 }
371
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
35
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
36 static int
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
37 os_GetPartitionPoolEntry(USHORT Index, T_OS_PART_POOL **pool)
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
38 {
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
39 static T_OS_PART_POOL *part_pool;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
40 static int grp_hndl;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
41
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
42 switch (Index) {
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
43 case FIRST_ENTRY:
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
44 grp_hndl = 0;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
45 *pool = part_pool = PartGrpTable[0].grp_head;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
46 return(OS_OK);
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
47 case NEXT_ENTRY:
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
48 if (part_pool->next) {
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
49 *pool = part_pool = part_pool->next;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
50 return(OS_OK);
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
51 }
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
52 grp_hndl++;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
53 if (PartGrpTable[grp_hndl].grp_head) {
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
54 *pool = part_pool = PartGrpTable[grp_hndl].grp_head;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
55 return(OS_OK);
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
56 } else
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
57 return(OS_ERROR);
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
58 default:
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
59 return(OS_ERROR);
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
60 }
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
61 }
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
62
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
63 GLOBAL LONG
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
64 os_PartitionInformation(USHORT Handle, char *Buffer)
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
65 {
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
66 T_OS_PART_POOL *pool;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
67 OPTION SuspendType;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
68 UNSIGNED PoolSize;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
69 UNSIGNED PartitionSize;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
70 UNSIGNED Available;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
71 UNSIGNED Waiting;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
72 UNSIGNED Allocated;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
73 VOID *pStartAddress;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
74 NU_TASK *First;
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
75 CHAR Name[8];
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
76
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
77 if (os_GetPartitionPoolEntry(Handle, &pool) == OS_ERROR)
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
78 return(OS_ERROR);
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
79 if (NU_Partition_Pool_Information(&pool->pcb, Name, &pStartAddress,
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
80 &PoolSize, &PartitionSize, &Available,
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
81 &Allocated, &SuspendType, &Waiting,
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
82 &First)
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
83 != NU_SUCCESS)
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
84 return(OS_ERROR);
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
85 sprintf(Buffer,
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
86 "Name:%s Addr:%lx PoolSize:%ld PartSize:%ld Free:%ld Used:%ld",
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
87 Name, (UNSIGNED) pStartAddress, PoolSize, PartitionSize,
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
88 Available, Allocated);
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
89 return(OS_OK);
8df6f38d2f3a os_mem_fl.c: os_PartitionInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 370
diff changeset
90 }
372
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
91
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
92 static int
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
93 os_GetMemoryPoolEntry(USHORT Index, OS_HANDLE *Handle)
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
94 {
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
95 static USHORT Idx;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
96
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
97 switch (Index) {
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
98 case FIRST_ENTRY:
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
99 Idx = 0;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
100 break;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
101 case NEXT_ENTRY:
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
102 Idx++;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
103 break;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
104 default:
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
105 Idx = Index;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
106 }
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
107 if (Idx == NumOfMemoryPools)
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
108 return(OS_ERROR);
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
109 *Handle = Idx;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
110 return(OS_OK);
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
111 }
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
112
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
113 GLOBAL LONG
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
114 os_MemoryInformation(USHORT Index, char *Buffer)
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
115 {
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
116 OS_HANDLE Handle;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
117 OPTION SuspendType;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
118 UNSIGNED Size, Min, Available, Waiting;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
119 VOID *pStartAddress;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
120 NU_TASK *First;
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
121 CHAR Name[8];
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
122
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
123 if (os_GetMemoryPoolEntry(Index, &Handle) == OS_ERROR)
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
124 return(OS_ERROR);
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
125 if (NU_Memory_Pool_Information(MemPoolTable[Handle].pcb, Name,
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
126 &pStartAddress, &Size, &Min,
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
127 &Available, &SuspendType, &Waiting,
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
128 &First)
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
129 != NU_SUCCESS)
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
130 return(OS_ERROR);
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
131 sprintf(Buffer,
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
132 "Heapname:%s Addr:%lx Size:%ld Min:%ld Free:%ld Suspend:%d",
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
133 Name, (UNSIGNED) pStartAddress, Size, Min, Available,
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
134 SuspendType);
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
135 return(OS_OK);
47391b5c15ff os_mem_fl.c: os_MemoryInformation() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 371
diff changeset
136 }
373
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
137
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
138 GLOBAL LONG
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
139 os_MemInit(void)
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
140 {
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
141 USHORT i;
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
142
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
143 if (NU_Create_Semaphore(&MemSemCB, "MEMSEM", 1, NU_PRIORITY)
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
144 != NU_SUCCESS)
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
145 return(OS_ERROR);
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
146 for (i = 0; i <= MaxPoolGroups; i++) {
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
147 PoolBorder[i].Start = (char *)0xFFFFFFFF;
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
148 PoolBorder[i].End = (char *)0;
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
149 PartGrpTable[i].grp_head = 0;
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
150 PartGrpTable[i].name[0] = 0;
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
151 }
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
152 MemPoolTable[0].pcb = &mem_pool_head;
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
153 return(OS_OK);
5f7d723b9343 os_mem_fl.c: os_MemInit() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 372
diff changeset
154 }
374
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
155
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
156 void
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
157 os_InitPartitionCheck(T_OS_PART_POOL *pool)
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
158 {
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
159 unsigned **Buffer, offset;
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
160 USHORT i, k;
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
161
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
162 NU_Allocate_Memory(MemPoolTable[0].pcb, (VOID **) &Buffer,
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
163 pool->pcb.pm_available * sizeof(unsigned *),
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
164 NU_NO_SUSPEND);
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
165 offset = pool->pcb.pm_partition_size / sizeof(unsigned) - 1;
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
166 for (i = 0; ; i++) {
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
167 if (NU_Allocate_Partition(&pool->pcb, (VOID **)(Buffer + i),
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
168 NU_NO_SUSPEND)
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
169 != NU_SUCCESS)
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
170 break;
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
171 Buffer[i][offset] = GUARD_PATTERN;
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
172 }
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
173 for (k = 0; k < i; k++)
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
174 if (NU_Deallocate_Partition(Buffer[k]) != NU_SUCCESS)
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
175 break;
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
176 NU_Deallocate_Memory(Buffer);
3efb28578dad os_mem_fl.c: os_InitPartitionCheck() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 373
diff changeset
177 }
375
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
178
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
179 GLOBAL const ULONG *
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
180 os_GetPrimpoolCB(int grp, int id)
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
181 {
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
182 T_OS_PART_POOL *pool;
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
183 int i;
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
184
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
185 pool = PartGrpTable[grp].grp_head;
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
186 if (!pool)
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
187 return(0);
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
188 if (id < 0)
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
189 return(0);
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
190 for (i = 0; i < id; i++) {
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
191 pool = pool->next;
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
192 if (!pool)
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
193 return(0);
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
194 }
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
195 return (const ULONG *) &pool->pcb;
1319bd1d5ac3 os_mem_fl.c: os_GetPrimpoolCB() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 374
diff changeset
196 }
376
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
197
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
198 GLOBAL LONG
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
199 os_GetPartitionPoolStatus(ULONG size, OS_HANDLE gr_hndl,
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
200 USHORT *m_free, USHORT *m_alloc)
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
201 {
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
202 T_OS_PART_POOL *pool;
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
203 UNSIGNED dummy, allocated, available;
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
204 CHAR Name[8];
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
205
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
206 for (pool = PartGrpTable[gr_hndl].grp_head; pool; pool = pool->next) {
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
207 if (!size)
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
208 break;
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
209 if (size > pool->size)
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
210 continue;
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
211 if (NU_Partition_Pool_Information(&pool->pcb, Name,
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
212 (VOID **)&dummy, &dummy,
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
213 &dummy, &available,
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
214 &allocated, (OPTION *)&dummy,
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
215 &dummy, (NU_TASK **)&dummy)
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
216 != NU_SUCCESS)
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
217 break;
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
218 *m_alloc = allocated;
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
219 *m_free = available;
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
220 return(OS_OK);
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
221 }
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
222 *m_alloc = 0;
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
223 *m_free = 0;
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
224 return(OS_ERROR);
754e72d134a0 os_mem_fl.c: os_GetPartitionPoolStatus() done
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 375
diff changeset
225 }