Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Emulator/Main/Core/Machine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,10 +1027,11 @@ public void PostCreationActions()
}
}

// Register io_executable flags for all ArrayMemory peripherals
// Register io_executable flags for all non-IMapped peripherals so that
// instruction fetches from them go through I/O callbacks instead of aborting.
foreach(var context in SystemBus.GetAllContextKeys())
{
foreach(var registration in SystemBus.GetRegistrationsForPeripheralType<Peripherals.Memory.ArrayMemory>(context))
foreach(var registration in SystemBus.GetRegistrationsForPeripheralType<IBusPeripheral>(context).Where(r => !(r.Peripheral is IMapped)))
{
var range = registration.RegistrationPoint.Range;
var perCore = registration.RegistrationPoint.Initiator;
Expand Down
12 changes: 11 additions & 1 deletion src/Emulator/Main/Peripherals/Bus/SystemBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ public void MoveRegistrationWithinContext(IBusPeripheral peripheral, BusRangeReg
AddMappingsForPeripheral(peripheral, newRegistration, context);
}

if(peripheral is ArrayMemory)
if(!(peripheral is IMapped))
{
foreach(var cpu in GetCPUsForContext<ICPUWithMappedMemory>(context))
{
Expand Down Expand Up @@ -2054,6 +2054,16 @@ private void RegisterInner(IBusPeripheral peripheral, PeripheralAccessMethods me
});
// let's add new mappings
AddMappingsForPeripheral(peripheral, registrationPoint, context);
// For non-IMapped peripherals, mark the range as executable I/O so that
// instruction fetches go through I/O callbacks instead of causing cpu_abort.
if(!(peripheral is IMapped))
{
foreach(var cpu in GetCPUsForContext<ICPUWithMappedMemory>(context))
{
var range = registrationPoint.Range;
cpu.RegisterAccessFlags(range.StartAddress, range.Size, isIoMemory: true);
}
}
// After adding new mappings, if the address range is locked, the mappings possibly have to be modified/unmapped on the CPU's side
// RelockRange to make this happen
if(IsAddressRangeLocked(registrationPoint.Range, context))
Expand Down