Test initialisation of MUIA_List_AdjustWidth and MUIA_List_AdjustHeight, and
[AROS.git] / arch / .unmaintained / arm-all / exec / detect_memory.c
blob8a6de63ef2185f76fa4e7ddcb4ceb809a37dfbd8
1 #include <exec/io.h>
2 #include <exec/types.h>
3 #include <exec/nodes.h>
4 #include <exec/memory.h>
5 #include <exec/resident.h>
6 #include <exec/libraries.h>
7 #include <exec/execbase.h>
8 #include <proto/exec.h>
9 #include "memory.h"
11 #define DBEUG 1
12 #include <aros/debug.h>
14 #include <asm/registers.h>
15 #include <asm/cpu.h>
16 #include "arm_exec_internal.h"
18 #define MEM_START 0x400
22 * Detect memory in step sizes of 1kb. Keep it that way...
24 #define STEPSIZE 1024
26 UBYTE * check_memory(UBYTE * address, UBYTE * end)
28 int found = FALSE;
29 *(ULONG *)DATA_ABORT_MARKER_ADDRESS = 0;
30 #warning Will not find all memory!
31 while ((ULONG)address < (ULONG)end) {
32 *(UBYTE *)address = 0xcc;
33 if (0xcc != *(UBYTE *)address) {
34 break;
36 if (0 == *(ULONG *)DATA_ABORT_MARKER_ADDRESS) {
37 found = TRUE;
38 } else {
39 break;
41 address += STEPSIZE;
43 address -= STEPSIZE;
45 if (FALSE == found)
46 return NULL;
47 return address;
51 * Detect some initial memory. This should be enough
52 * to get the OS up and running. More detection follows
53 * later...
55 struct MemHeader * detect_memory(void)
57 struct MemHeader * mh;
59 * There is no SysBase available here!!
60 * It has not been initialized, yet.
64 * Must initialize the BusError handler
66 UBYTE * address = (UBYTE *)1024;
68 INSTALL_IRQ_HANDLER(VECTOR_DATA_ABORT, dm_data_abort_handler);
70 address = check_memory(address, 0x80000);
72 mh=(struct MemHeader*)MEM_START;
73 mh->mh_Node.ln_Succ = NULL;
74 mh->mh_Node.ln_Pred = NULL;
75 mh->mh_Node.ln_Type = NT_MEMORY;
76 mh->mh_Node.ln_Name = "chip memory";
77 mh->mh_Node.ln_Pri = -5;
78 mh->mh_Attributes = MEMF_CHIP | MEMF_PUBLIC | MEMF_LOCAL | MEMF_24BITDMA |
79 MEMF_KICK;
80 mh->mh_First = (struct MemChunk *)((UBYTE*)mh+MEMHEADER_TOTAL);
81 mh->mh_First->mc_Next = NULL;
82 mh->mh_First->mc_Bytes = ((ULONG)address - MEM_START) - MEMHEADER_TOTAL;
84 mh->mh_Lower = mh->mh_First;
85 mh->mh_Upper = (APTR)(address);
86 mh->mh_Free = mh->mh_First->mc_Bytes;
88 return mh;
92 * The locations where memory can be.
93 * Beware: Whatever is at 0x0 is also at 0x10000000 for 1MB.
94 * So I am trying to avoid detecting this part again
95 * and start later in memory.
97 struct memories
99 UBYTE * start;
100 UBYTE * end;
101 UBYTE pri;
104 static struct memories memory[] = {{(UBYTE *)0xc0000000,(UBYTE *)0xc0100000,-10},
105 {(UBYTE *)NULL,0}};
108 * Detect the rest of the memory available on this device.
110 void detect_memory_rest(struct ExecBase * SysBase)
112 int c = 0;
114 INSTALL_IRQ_HANDLER(VECTOR_DATA_ABORT, dm_data_abort_handler);
116 while (0 != memory[c].start) {
117 UBYTE * end;
119 * Now try to detect sram size
121 end = check_memory(memory[c].start,
122 memory[c].end);
123 if (end != memory->start[c] && NULL != end) {
124 AddMemList((ULONG)end-(ULONG)memory[c].start,
125 MEMF_CHIP | MEMF_PUBLIC | MEMF_LOCAL | MEMF_24BITDMA | MEMF_KICK,
126 memory[c].pri,
127 memory[c].start,
128 "fast memory");
130 c++;