make the linux-ppc packags be in synch with other platforms
[tangerine.git] / arch / m68k-mac / exec / detect_memory.c
blob917829694bc0bdaa3f0bfee3be1d7e4f22610a76
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 "pp_exec_internal.h"
16 #define MEM_START 0x400
20 * Detect memory in step sizes of 1kb. Keep it that way...
22 #define STEPSIZE 1024
24 UBYTE * check_memory(UBYTE * address)
26 int found = FALSE;
27 *(ULONG *)ADDRESS_ERROR_MARKER_ADDRESS = 0;
28 while (1) {
29 *(UBYTE *)address = 0xcc;
30 if (0xcc != *(UBYTE *)address) {
31 break;
33 if (0 == *(ULONG *)ADDRESS_ERROR_MARKER_ADDRESS) {
34 found = TRUE;
35 } else {
36 break;
38 address += STEPSIZE;
40 address -= STEPSIZE;
42 if (FALSE == found)
43 return NULL;
44 return address;
48 * Detect some initial memory. This should be enough
49 * to get the OS up and running. More detection follows
50 * later...
52 struct MemHeader * detect_memory(void)
54 struct MemHeader * mh;
56 * There is no SysBase available here!!
57 * It has not been initialized, yet.
61 * Must initialize the BusError handler
63 UBYTE * address = (UBYTE *)1024;
65 *(ULONG *)(2*4) = (ULONG)dm_bus_error_handler;
66 *(ULONG *)(3*4) = (ULONG)dm_addr_error_handler;
68 address = check_memory(address);
70 mh=(struct MemHeader*)MEM_START;
71 mh->mh_Node.ln_Succ = NULL;
72 mh->mh_Node.ln_Pred = NULL;
73 mh->mh_Node.ln_Type = NT_MEMORY;
74 mh->mh_Node.ln_Name = "chip memory";
75 mh->mh_Node.ln_Pri = -5;
76 mh->mh_Attributes = MEMF_CHIP | MEMF_PUBLIC | MEMF_LOCAL | MEMF_24BITDMA |
77 MEMF_KICK;
78 mh->mh_First = (struct MemChunk *)((UBYTE*)mh+MEMHEADER_TOTAL);
79 mh->mh_First->mc_Next = NULL;
80 mh->mh_First->mc_Bytes = ((ULONG)address - MEM_START) - MEMHEADER_TOTAL;
82 mh->mh_Lower = mh->mh_First;
83 mh->mh_Upper = (APTR)(address);
84 mh->mh_Free = mh->mh_First->mc_Bytes;
86 return mh;
90 * The locations where memory can be.
91 * Beware: Whatever is at 0x0 is also at 0x10000000 for 1MB.
92 * So I am trying to avoid detecting this part again
93 * and start later in memory.
95 struct memories
97 UBYTE * start;
98 UBYTE pri;
101 static struct memories memory[] = {{(UBYTE *)0x10100000,-10},
102 {(UBYTE *)0xf0000000,-10},
103 {(UBYTE *)NULL,0}};
106 * Detect the rest of the memory available on this device.
108 void detect_memory_rest(struct ExecBase * SysBase)
110 int c = 0;
111 *(ULONG *)(2*4) = (ULONG)dm_bus_error_handler;
112 *(ULONG *)(3*4) = (ULONG)dm_addr_error_handler;
114 while (0 != memory[c].start) {
115 UBYTE * end;
117 * Now try to detect sram size
119 end = check_memory(memory[c].start);
120 if (end != memory->start[c] && NULL != end) {
121 AddMemList((ULONG)end-(ULONG)memory[c].start,
122 MEMF_CHIP | MEMF_PUBLIC | MEMF_LOCAL | MEMF_24BITDMA | MEMF_KICK,
123 memory[c].pri,
124 memory[c].start,
125 "fast memory");
127 c++;