annotate src/gpf/osl/os_mem_ir.c @ 174:097e25b925a2

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