Skip to content

Commit 637c20e

Browse files
joevtdingusdev
authored andcommitted
grandcentral: Handle bit-flipping of MAC address.
If the ENET ROM begins with 0x10, then the bits of each byte are flipped 7..0 -> 0..7 which means the MAC address will begin with 0x08. A MAC address beginning with 0x08 can be bit-flipped or not bit-flipped. A MAC address cannot begin with 0x10. I have a `dump-device-tree` output for a Power Mac 9500 with MAC address beginning with 08-00-07 (OUI for "Apple, Inc."). I don't know if it's using the bit-flipped ROM (starting with 10) or not bit-flipped ROM (starting with 08). Most of the other `dump-device-tree` outputs I've seen have a MAC address beginning with an OUI for "Apple, Inc." that begins with 00.
1 parent ba9bbb3 commit 637c20e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

devices/ioctrl/grandcentral.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,11 @@ void GrandCentral::notify_bar_change(int bar_num)
172172
}
173173
}
174174

175-
176-
static uint8_t ENET_ROM[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 };
175+
// The first 3 bytes of a MAC address is an OUI for "Apple, Inc."
176+
// A MAC address cannot begin with 0x10 because that will get bit-flipped to 0x08.
177+
// A MAC address that begins with 0x08 can be stored as bit-flipped or not bit-flipped.
178+
static uint8_t mac_address[] = { 0x08, 0x00, 0x07, 0x44, 0x55, 0x66, 0x00, 0x00 };
179+
static bool bit_flip_0x08 = false;
177180

178181
uint32_t GrandCentral::read(uint32_t rgn_start, uint32_t offset, int size)
179182
{
@@ -206,7 +209,17 @@ uint32_t GrandCentral::read(uint32_t rgn_start, uint32_t offset, int size)
206209
case 8: // MESH SCSI
207210
return this->mesh->read((offset >> 4) & 0xF);
208211
case 9: // ENET-ROM
209-
return ENET_ROM[(offset >> 4) & 0x7];
212+
{
213+
uint8_t val = mac_address[(offset >> 4) & 0x7];
214+
if (((offset >> 4) & 0x7) < 6) {
215+
if (mac_address[0] == 0x08 && bit_flip_0x08)
216+
val = (val * 0x0202020202ULL & 0x010884422010ULL) % 1023;
217+
} else {
218+
LOG_F(WARNING, "%s: reading byte %d of ENET_ROM using offset %x",
219+
this->name.c_str(), (offset >> 4) & 0x7, offset);
220+
}
221+
return val;
222+
}
210223
case 0xA: // IOBus device #1 ; Board register 1 and bandit1 PRSNT bits
211224
case 0xB: // IOBus device #2 ; RaDACal/DACula
212225
case 0xC: // IOBus device #3 ; chaos or bandit2 PRSNT bits ; sixty6

0 commit comments

Comments
 (0)