annotate src/gpf/osl/os_mem_ir.c @ 68:be5b218f0765

src/g23m-gprs/llc: fixed many invalid uses of ##
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 20 Jul 2018 00:51:15 +0000
parents 8b2a9a374324
children 82ae724ca0d7
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
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 phdr = (PM_HEADER *)(ptr - 2);
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;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (ptr[(pool->pm_partition_size - 4) >> 2] == GUARD_PATTERN)
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 return(OS_OK);
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 else
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 return(OS_PARTITION_GUARD_PATTERN_DESTROYED);
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }
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 GLOBAL LONG
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 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
54 {
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 if (os_is_valid_partition(Buffer) != OS_OK)
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 return(OS_ERROR);
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 if (NU_Deallocate_Partition(Buffer) != NU_SUCCESS)
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 return(OS_ERROR);
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 return(OS_OK);
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }
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 GLOBAL LONG
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 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
64 ULONG Suspend, OS_HANDLE GroupHandle)
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 {
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 T_OS_PART_POOL *pool, *requested_pool;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 ULONG nu_suspend;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 STATUS sts;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 int ret;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 for (pool = PartGrpTable[GroupHandle].grp_head; pool;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 pool = pool->next)
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 if (Size <= pool->size)
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 break;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 if (!pool)
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 return(OS_ERROR);
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 requested_pool = pool;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 ret = OS_OK;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 nu_suspend = NU_NO_SUSPEND;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 try_alloc:
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 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
82 switch (sts) {
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 case NU_SUCCESS:
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 return(ret);
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 case NU_TIMEOUT:
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 case NU_INVALID_SUSPEND:
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 *Buffer = 0;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 return(OS_TIMEOUT);
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 case NU_NO_PARTITION:
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 pool = pool->next;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 if (pool) {
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 ret = OS_ALLOCATED_BIGGER;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 goto try_alloc;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 }
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 pool = requested_pool;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 if (Suspend) {
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 nu_suspend = Suspend;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 ret = OS_WAITED;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 goto try_alloc;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 }
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 return(OS_TIMEOUT);
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 default:
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 *Buffer = 0;
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 return(OS_ERROR);
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 }
8b2a9a374324 src/gpf: addition of Magnetite src/gpf2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 }