2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
10 #include <aros/debug.h>
11 #include <proto/expansion.h>
12 #include <exec/memory.h>
13 #include <proto/exec.h>
15 #include <expansion_intern.h>
17 /* See rom/expansion/readexpansionrom.c for documentation */
19 static void readexprom(APTR board
, struct ExpansionRom
*rom
, struct ExpansionBase
*ExpansionBase
)
23 for (cnt
= 0; cnt
< sizeof(struct ExpansionRom
); cnt
++)
24 ((UBYTE
*)rom
)[cnt
] = ~ReadExpansionByte(board
, cnt
);
25 /* AOS expansion.library appears to have off-by-one bug.. */
26 ReadExpansionByte(board
, cnt
);
27 rom
->er_Type
= ~rom
->er_Type
;
30 #include <clib/expansion_protos.h>
32 AROS_LH2(BOOL
, ReadExpansionRom
,
33 AROS_LHA(APTR
, board
, A0
),
34 AROS_LHA(struct ConfigDev
*, configDev
, A1
),
35 struct ExpansionBase
*, ExpansionBase
, 17, Expansion
)
39 struct ExpansionRom
*rom
= &configDev
->cd_Rom
;
40 struct ExpansionRom tmprom
;
44 readexprom(board
, rom
, ExpansionBase
);
46 if (rom
->er_Reserved03
!= 0)
49 if (rom
->er_Manufacturer
== 0 || rom
->er_Manufacturer
== 0xffff)
52 if ((rom
->er_Type
& ERT_TYPEMASK
) != ERT_ZORROII
&& (rom
->er_Type
& ERT_TYPEMASK
) != ERT_ZORROIII
)
55 /* AOS expansion.library wants to be really really sure... */
56 for (cnt
= 0; cnt
< 11; cnt
++) {
57 readexprom(board
, &tmprom
, ExpansionBase
);
58 if (memcmp(&tmprom
, rom
, sizeof(struct ExpansionRom
)))
62 if ((rom
->er_Type
& ERT_TYPEMASK
) == ERT_ZORROIII
&& (rom
->er_Flags
& ERFF_EXTENDED
)) {
63 size
= (16 * 1024 * 1024) << (rom
->er_Type
& ERT_MEMMASK
);
65 UBYTE mem
= rom
->er_Type
& ERT_MEMMASK
;
67 size
= 8 * 1024 * 1024; // 8M
69 size
= (32 * 1024) << mem
; // 64k,128k,256k,512k,1m,2m,4m
71 if ((rom
->er_Type
& ERT_TYPEMASK
) == ERT_ZORROIII
) {
72 UBYTE subsize
= rom
->er_Flags
& ERT_Z3_SSMASK
;
74 if (subsize
>= 2 && subsize
<= 7) { // 64k,128k,256k,512k,1m,2m
75 ss
= (64 * 1024) << (subsize
- 2);
76 } else if (subsize
>= 8) { // 4m,6m,8m,10m,12m,14m
77 ss
= (4 + (subsize
- 8) * 2) * 1024 * 1024;
83 configDev
->cd_BoardSize
= size
;
84 configDev
->cd_BoardAddr
= board
;
86 D(bug("Found board %p: mfg=%d prod=%d size=%08x serial=%08x diag=%p\n",
87 board
, rom
->er_Manufacturer
, rom
->er_Product
, size
, rom
->er_SerialNumber
, rom
->er_InitDiagVec
));
92 } /* ReadExpansionRom */