Code: Select all
// The MMIO area base address.
switch (raspi) {
case 2:
case 3: MMIO_BASE = 0x3F000000; break; // for raspi2 & 3
case 4: MMIO_BASE = 0xFE000000; break; // for raspi4
default: MMIO_BASE = 0x20000000; break; // for raspi1, raspi zero etc.
}
I simply replaced it with the appropriate sub-entry (the case 3 entry), but the code as given caught my interest.
However, I am curious as to why this was in the code sample. Is there an actual way to do this using a switch() statement (as opposed to, say, #define and #ifdef directives)?
Is this in the code primarily as a 'copy trap' (by which I mean, it is there to force the programmers following the tutorial to actually read the code), or is there a real idiom which this is meant to apply?
As an aside, AFAICT the triplet for AArch64 has changed to 'aarch64-none-elf-' rather than just 'aarch64-elf-', presumably to improve the consistency with other triplets. I don't want to change this in the wiki page until I have confirmed this, however.