Skip to content

Commit

Permalink
Better MAC address handling (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
wheremyfoodat authored Oct 17, 2023
1 parent 5043f98 commit 6626c2a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion include/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ class Memory {
Regions region = Regions::USA;
const EmulatorConfig& config;

public:
static constexpr std::array<u8, 6> MACAddress = {0x40, 0xF4, 0x07, 0xFF, 0xFF, 0xEE};

public:
u16 kernelVersion = 0;
u32 usedUserMemory = u32(0_MB); // How much of the APPLICATION FCRAM range is used (allocated to the appcore)
u32 usedSystemMemory = u32(0_MB); // Similar for the SYSTEM range (reserved for the syscore)
Expand Down
2 changes: 1 addition & 1 deletion include/panda_qt/main_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <QtWidgets>
#include <atomic>
#include <filesystem>
#include <thread>
#include <mutex>
#include <thread>

#include "emulator.hpp"
#include "panda_qt/screen.hpp"
Expand Down
14 changes: 12 additions & 2 deletions src/core/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ u8 Memory::read8(u32 vaddr) {
case ConfigMem::FirmVersionMajor: return firm.major;
case ConfigMem::WifiLevel: return 0; // No wifi :(

case ConfigMem::WifiMac:
case ConfigMem::WifiMac + 1:
case ConfigMem::WifiMac + 2:
case ConfigMem::WifiMac + 3:
case ConfigMem::WifiMac + 4:
case ConfigMem::WifiMac + 5: return MACAddress[vaddr - ConfigMem::WifiMac];

default: Helpers::panic("Unimplemented 8-bit read, addr: %08X", vaddr);
}
}
Expand All @@ -136,7 +143,7 @@ u16 Memory::read16(u32 vaddr) {
return *(u16*)(pointer + offset);
} else {
switch (vaddr) {
case ConfigMem::WifiMac + 4: return 0xEEFF; // Wifi MAC: Last 2 bytes of MAC Address
case ConfigMem::WifiMac + 4: return (MACAddress[5] << 8) | MACAddress[4]; // Wifi MAC: Last 2 bytes of MAC Address
default: Helpers::panic("Unimplemented 16-bit read, addr: %08X", vaddr);
}
}
Expand Down Expand Up @@ -166,7 +173,10 @@ u32 Memory::read32(u32 vaddr) {
case ConfigMem::AppMemAlloc: return appResourceLimits.maxCommit;
case ConfigMem::SyscoreVer: return 2;
case 0x1FF81000: return 0; // TODO: Figure out what this config mem address does
case ConfigMem::WifiMac: return 0xFF07F440; // Wifi MAC: First 4 bytes of MAC Address
// Wifi MAC: First 4 bytes of MAC Address
case ConfigMem::WifiMac:
return (u32(MACAddress[3]) << 24) | (u32(MACAddress[2]) << 16) | (u32(MACAddress[1]) << 8) |
MACAddress[0];

// 3D slider. Float in range 0.0 = off, 1.0 = max.
case ConfigMem::SliderState3D: return Helpers::bit_cast<u32, float>(0.0f);
Expand Down

0 comments on commit 6626c2a

Please sign in to comment.