2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
10 #include <aros/debug.h>
12 #include <proto/expansion.h>
14 #include "expansion_intern.h"
16 #include <clib/expansion_protos.h>
17 #include <proto/exec.h>
18 #include <exec/resident.h>
20 AROS_UFP3(ULONG
, MemoryTest
,
21 AROS_UFPA(APTR
, startaddr
, A0
),
22 AROS_UFPA(APTR
, endaddr
, A1
),
23 AROS_UFPA(ULONG
, block
, D0
));
25 static ULONG
autosize(struct ExpansionBase
*ExpansionBase
, struct ConfigDev
*configDev
)
27 UBYTE sizebits
= configDev
->cd_Rom
.er_Flags
& ERT_Z3_SSMASK
;
28 ULONG maxsize
= configDev
->cd_BoardSize
;
30 UBYTE
*addr
= (UBYTE
*)configDev
->cd_BoardAddr
;
32 D(bug("sizebits=%x\n", sizebits
));
33 if (sizebits
>= 14) /* 14 and 15 = reserved */
35 if (sizebits
>= 2 && sizebits
<= 8)
36 return 0x00010000 << (sizebits
- 2);
38 return 0x00600000 + (0x200000 * (sizebits
- 9));
39 size
= AROS_UFC3(ULONG
, MemoryTest
,
40 AROS_UFCA(APTR
, addr
, A0
),
41 AROS_UFCA(APTR
, addr
+ maxsize
, A1
),
42 AROS_UFCA(ULONG
, 0x80000, D0
));
43 D(bug("addr=%lx size=%lx maxsize=%lx\n", addr
, size
, maxsize
));
47 static void findmbram(struct ExpansionBase
*ExpansionBase
)
50 ULONG step
, start
, end
;
52 if (!(SysBase
->AttnFlags
& AFF_68020
))
54 if ((SysBase
->AttnFlags
& AFF_68020
) && !(SysBase
->AttnFlags
& AFF_ADDR32
))
61 ret
= AROS_UFC3(LONG
, MemoryTest
,
62 AROS_UFCA(APTR
, start
, A0
),
63 AROS_UFCA(APTR
, end
, A1
),
64 AROS_UFCA(ULONG
, step
, D0
));
68 AddMemList(ret
, MEMF_KICK
| MEMF_LOCAL
| MEMF_FAST
| MEMF_PUBLIC
, 40, (APTR
)start
, "expansion.memory");
69 D(bug("MBRAM @%08x, size %08x\n", start
, ret
));
72 /* Low MBRAM, reversed detection needed */
77 ret
= AROS_UFC3(LONG
, MemoryTest
,
78 AROS_UFCA(APTR
, start
- step
, A0
),
79 AROS_UFCA(APTR
, start
, A1
),
80 AROS_UFCA(ULONG
, step
, D0
));
83 if (end
>= start
- step
)
87 if (start
!= 0x08000000) {
88 ULONG size
= 0x08000000 - start
;
89 AddMemList(size
, MEMF_KICK
| MEMF_LOCAL
| MEMF_FAST
| MEMF_PUBLIC
, 30, (APTR
)start
, "expansion.memory");
90 D(bug("MBRAM @%08x, size %08x\n", start
, size
));
94 static void allocram(struct ExpansionBase
*ExpansionBase
)
98 findmbram(ExpansionBase
);
99 // we should merge address spaces, later..
100 D(bug("adding ram boards\n"));
101 ForeachNode(&ExpansionBase
->BoardList
, node
) {
102 struct ConfigDev
*configDev
= (struct ConfigDev
*)node
;
103 if ((configDev
->cd_Rom
.er_Type
& ERTF_MEMLIST
) && !(configDev
->cd_Flags
& CDF_SHUTUP
) && !(configDev
->cd_Flags
& CDF_PROCESSED
)) {
104 ULONG attr
= MEMF_PUBLIC
| MEMF_FAST
| MEMF_KICK
;
105 ULONG size
= configDev
->cd_BoardSize
;
106 APTR addr
= configDev
->cd_BoardAddr
;
108 if (configDev
->cd_BoardAddr
<= (APTR
)0x00FFFFFF) {
109 attr
|= MEMF_24BITDMA
;
111 } else if ((configDev
->cd_Rom
.er_Flags
& ERT_Z3_SSMASK
) != 0) {
112 size
= autosize(ExpansionBase
, configDev
);
114 if (size
&& size
<= configDev
->cd_BoardSize
) {
115 D(bug("ram board at %08x, size %08x attr %08x\n", addr
, size
, attr
));
116 AddMemList(size
, attr
, pri
, addr
, "Fast Memory");
118 configDev
->cd_Flags
|= CDF_PROCESSED
;
121 D(bug("ram boards done\n"));
125 AROS_LH1(void, ConfigChain
,
126 AROS_LHA(APTR
, baseAddr
, A0
),
127 struct ExpansionBase
*, ExpansionBase
, 11, Expansion
)
131 struct ConfigDev
*configDev
= NULL
;
133 /* Try to guess if we have Z3 based machine.
134 * Not all Z3 boards appear in Z2 region.
136 * Ignores original baseAddr by design.
138 BOOL maybeZ3
= (SysBase
->AttnFlags
& AFF_ADDR32
);
139 D(bug("configchain\n"));
143 configDev
= AllocConfigDev();
147 baseAddr
= (APTR
)EZ3_EXPANSIONBASE
;
148 gotrom
= ReadExpansionRom(baseAddr
, configDev
);
151 baseAddr
= (APTR
)E_EXPANSIONBASE
;
152 gotrom
= ReadExpansionRom(baseAddr
, configDev
);
155 FreeConfigDev(configDev
);
158 if (ConfigBoard(baseAddr
, configDev
)) {
159 AddConfigDev(configDev
);
163 D(bug("configchain done\n"));
165 allocram(ExpansionBase
);