FreeCalypso > hg > fc-magnetite
annotate src/gpf2/osl/os_mem_ir.c @ 615:2bd7c1dcac4b
doc/Compiling: fc-host-tools-latest symlink
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 29 Jun 2019 02:06:50 +0000 |
parents | e9bdc8184d50 |
children |
rev | line source |
---|---|
487
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This C module is a reconstruction based on the disassembly of |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * os_mem.obj in frame_na7_db_ir.lib from the Leonardo package. |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 /* set of included headers from COFF symtab: */ |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
494
e9bdc8184d50
OSL: os_mem_ir.c compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
487
diff
changeset
|
9 #include "nucleus.h" |
487
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "typedefs.h" |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "os.h" |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "gdi.h" |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "os_types.h" |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "os_glob.h" |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern T_OS_PART_GRP_TABLE_ENTRY PartGrpTable[]; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern T_OS_POOL_BORDER PoolBorder[]; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 GLOBAL LONG |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 os_is_valid_partition(T_VOID_STRUCT *Buffer) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 int i; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 for (i = 0; i <= MaxPoolGroups; i++) { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 if (PoolBorder[i].End == 0) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 return(OS_ERROR); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if ((char *)Buffer < PoolBorder[i].Start) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 continue; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if ((char *)Buffer >= PoolBorder[i].End) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 continue; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 return(OS_OK); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 return(OS_ERROR); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 GLOBAL LONG |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 os_PartitionCheck(ULONG *ptr) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 PM_HEADER *phdr; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 PM_PCB *pool; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 phdr = (PM_HEADER *)(ptr - 2); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 if (phdr->pm_next_available) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 return(OS_PARTITION_FREE); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 pool = phdr->pm_partition_pool; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 if (ptr[(pool->pm_partition_size - 4) >> 2] == GUARD_PATTERN) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 return(OS_OK); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 else |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 return(OS_PARTITION_GUARD_PATTERN_DESTROYED); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 GLOBAL LONG |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 os_DeallocatePartition(OS_HANDLE TaskHandle, T_VOID_STRUCT *Buffer) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 if (os_is_valid_partition(Buffer) != OS_OK) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 return(OS_ERROR); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 if (NU_Deallocate_Partition(Buffer) != NU_SUCCESS) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 return(OS_ERROR); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 return(OS_OK); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 GLOBAL LONG |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 os_AllocatePartition(OS_HANDLE TaskHandle, T_VOID_STRUCT **Buffer, ULONG Size, |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 ULONG Suspend, OS_HANDLE GroupHandle) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 T_OS_PART_POOL *pool, *requested_pool; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 ULONG nu_suspend; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 STATUS sts; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 int ret; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 for (pool = PartGrpTable[GroupHandle].grp_head; pool; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 pool = pool->next) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 if (Size <= pool->size) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 break; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 if (!pool) |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 return(OS_ERROR); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 requested_pool = pool; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 ret = OS_OK; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 nu_suspend = NU_NO_SUSPEND; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 try_alloc: |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 sts = NU_Allocate_Partition(&pool->pcb, (VOID **) Buffer, nu_suspend); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 switch (sts) { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 case NU_SUCCESS: |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 return(ret); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 case NU_TIMEOUT: |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 case NU_INVALID_SUSPEND: |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 *Buffer = 0; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 return(OS_TIMEOUT); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 case NU_NO_PARTITION: |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 pool = pool->next; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 if (pool) { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 ret = OS_ALLOCATED_BIGGER; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 goto try_alloc; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 pool = requested_pool; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 if (Suspend) { |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 nu_suspend = Suspend; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 ret = OS_WAITED; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 goto try_alloc; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 return(OS_TIMEOUT); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 default: |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 *Buffer = 0; |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 return(OS_ERROR); |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } |
91e8dac34ada
src/gpf2/osl: initial import from old freecalypso-sw tree
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 } |