Improved stability during reboot
This commit is contained in:
parent
1ddb7d3a42
commit
1d8dd979ab
|
@ -1268,13 +1268,15 @@ static void one_tick(...)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_PTHREADS_SERVICES
|
#ifdef USE_PTHREADS_SERVICES
|
||||||
|
bool tick_inhibit;
|
||||||
static void *tick_func(void *arg)
|
static void *tick_func(void *arg)
|
||||||
{
|
{
|
||||||
uint64 start = GetTicks_usec();
|
uint64 start = GetTicks_usec();
|
||||||
int64 ticks = 0;
|
int64 ticks = 0;
|
||||||
uint64 next = start;
|
uint64 next = start;
|
||||||
while (!tick_thread_cancel) {
|
while (!tick_thread_cancel) {
|
||||||
one_tick();
|
if (!tick_inhibit)
|
||||||
|
one_tick();
|
||||||
next += 16625;
|
next += 16625;
|
||||||
int64 delay = next - GetTicks_usec();
|
int64 delay = next - GetTicks_usec();
|
||||||
if (delay > 0)
|
if (delay > 0)
|
||||||
|
|
|
@ -623,13 +623,15 @@ static void one_tick(...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool tick_inhibit;
|
||||||
static int tick_func(void *arg)
|
static int tick_func(void *arg)
|
||||||
{
|
{
|
||||||
uint64 start = GetTicks_usec();
|
uint64 start = GetTicks_usec();
|
||||||
int64 ticks = 0;
|
int64 ticks = 0;
|
||||||
uint64 next = GetTicks_usec();
|
uint64 next = GetTicks_usec();
|
||||||
while (!tick_thread_cancel) {
|
while (!tick_thread_cancel) {
|
||||||
one_tick();
|
if (!tick_inhibit)
|
||||||
|
one_tick();
|
||||||
next += 16625;
|
next += 16625;
|
||||||
int64 delay = next - GetTicks_usec();
|
int64 delay = next - GetTicks_usec();
|
||||||
if (delay > 0)
|
if (delay > 0)
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#ifndef NO_STD_NAMESPACE
|
#ifndef NO_STD_NAMESPACE
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
@ -162,6 +163,7 @@ uint32 CDROMIconAddr;
|
||||||
// Flag: Control(accRun) has been called, interrupt routine is now active
|
// Flag: Control(accRun) has been called, interrupt routine is now active
|
||||||
static bool acc_run_called = false;
|
static bool acc_run_called = false;
|
||||||
|
|
||||||
|
static std::map<int, void *> remount_map;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get pointer to drive info or drives.end() if not found
|
* Get pointer to drive info or drives.end() if not found
|
||||||
|
@ -368,6 +370,17 @@ bool CDROMMountVolume(void *fh)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDROMRemount() {
|
||||||
|
for (std::map<int, void *>::iterator i = remount_map.begin(); i != remount_map.end(); ++i)
|
||||||
|
for (drive_vec::iterator info = drives.begin(); info != drives.end(); ++info)
|
||||||
|
if (info->num == i->first) {
|
||||||
|
last_drive_num = i->first;
|
||||||
|
info->fh = i->second;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
remount_map.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mount volumes for which the to_be_mounted flag is set
|
* Mount volumes for which the to_be_mounted flag is set
|
||||||
|
@ -568,13 +581,16 @@ int16 CDROMControl(uint32 pb, uint32 dce)
|
||||||
|
|
||||||
case 7: // EjectTheDisc
|
case 7: // EjectTheDisc
|
||||||
if (ReadMacInt8(info->status + dsDiskInPlace) > 0) {
|
if (ReadMacInt8(info->status + dsDiskInPlace) > 0) {
|
||||||
SysAllowRemoval(info->fh);
|
if (info->drop) {
|
||||||
SysEject(info->fh);
|
SysAllowRemoval(info->fh);
|
||||||
WriteMacInt8(info->status + dsDiskInPlace, 0);
|
SysEject(info->fh);
|
||||||
info->twok_offset = -1;
|
info->twok_offset = -1;
|
||||||
info->close_fh();
|
info->close_fh();
|
||||||
|
info->drop = false;
|
||||||
|
}
|
||||||
|
else remount_map.insert(std::make_pair(ReadMacInt16(pb + ioVRefNum), info->fh));
|
||||||
info->fh = NULL;
|
info->fh = NULL;
|
||||||
info->drop = false;
|
WriteMacInt8(info->status + dsDiskInPlace, 0);
|
||||||
return noErr;
|
return noErr;
|
||||||
} else {
|
} else {
|
||||||
return offLinErr;
|
return offLinErr;
|
||||||
|
|
|
@ -49,6 +49,8 @@
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
extern bool tick_inhibit;
|
||||||
|
|
||||||
void PlayStartupSound();
|
void PlayStartupSound();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -57,7 +59,6 @@ void PlayStartupSound();
|
||||||
|
|
||||||
void EmulOp(uint16 opcode, M68kRegisters *r)
|
void EmulOp(uint16 opcode, M68kRegisters *r)
|
||||||
{
|
{
|
||||||
static bool bootflag;
|
|
||||||
D(bug("EmulOp %04x\n", opcode));
|
D(bug("EmulOp %04x\n", opcode));
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case M68K_EMUL_BREAK: { // Breakpoint
|
case M68K_EMUL_BREAK: { // Breakpoint
|
||||||
|
@ -84,12 +85,9 @@ void EmulOp(uint16 opcode, M68kRegisters *r)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M68K_EMUL_OP_RESET: { // MacOS reset
|
case M68K_EMUL_OP_RESET: { // MacOS reset
|
||||||
if (bootflag) {
|
|
||||||
CDROMExit();
|
|
||||||
CDROMInit();
|
|
||||||
}
|
|
||||||
bootflag = true;
|
|
||||||
D(bug("*** RESET ***\n"));
|
D(bug("*** RESET ***\n"));
|
||||||
|
tick_inhibit = true;
|
||||||
|
CDROMRemount(); // for System 7.x
|
||||||
TimerReset();
|
TimerReset();
|
||||||
EtherReset();
|
EtherReset();
|
||||||
AudioReset();
|
AudioReset();
|
||||||
|
@ -116,6 +114,7 @@ void EmulOp(uint16 opcode, M68kRegisters *r)
|
||||||
r->a[1] = ROMBaseMac + UniversalInfo; // UniversalInfo
|
r->a[1] = ROMBaseMac + UniversalInfo; // UniversalInfo
|
||||||
r->a[6] = boot_globs; // BootGlobs
|
r->a[6] = boot_globs; // BootGlobs
|
||||||
r->a[7] = RAMBaseMac + 0x10000; // Boot stack
|
r->a[7] = RAMBaseMac + 0x10000; // Boot stack
|
||||||
|
tick_inhibit = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,5 +43,6 @@ extern int16 CDROMStatus(uint32 pb, uint32 dce);
|
||||||
extern void CDROMOpenDone(void); // Called by CDROMOpen() once drives have been to the drive queue
|
extern void CDROMOpenDone(void); // Called by CDROMOpen() once drives have been to the drive queue
|
||||||
|
|
||||||
void CDROMDrop(const char *path);
|
void CDROMDrop(const char *path);
|
||||||
|
void CDROMRemount();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1438,6 +1438,7 @@ static void *nvram_func(void *arg)
|
||||||
* 60Hz thread (really 60.15Hz)
|
* 60Hz thread (really 60.15Hz)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
bool tick_inhibit;
|
||||||
static void *tick_func(void *arg)
|
static void *tick_func(void *arg)
|
||||||
{
|
{
|
||||||
int tick_counter = 0;
|
int tick_counter = 0;
|
||||||
|
@ -1454,6 +1455,7 @@ static void *tick_func(void *arg)
|
||||||
Delay_usec(delay);
|
Delay_usec(delay);
|
||||||
else if (delay < -16625)
|
else if (delay < -16625)
|
||||||
next = GetTicks_usec();
|
next = GetTicks_usec();
|
||||||
|
if (tick_inhibit) continue;
|
||||||
ticks++;
|
ticks++;
|
||||||
|
|
||||||
#if !EMULATED_PPC
|
#if !EMULATED_PPC
|
||||||
|
|
|
@ -638,6 +638,7 @@ static DWORD nvram_func(void *arg)
|
||||||
* 60Hz thread (really 60.15Hz)
|
* 60Hz thread (really 60.15Hz)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
bool tick_inhibit;
|
||||||
static DWORD tick_func(void *arg)
|
static DWORD tick_func(void *arg)
|
||||||
{
|
{
|
||||||
int tick_counter = 0;
|
int tick_counter = 0;
|
||||||
|
@ -654,6 +655,7 @@ static DWORD tick_func(void *arg)
|
||||||
Delay_usec(delay);
|
Delay_usec(delay);
|
||||||
else if (delay < -16625)
|
else if (delay < -16625)
|
||||||
next = GetTicks_usec();
|
next = GetTicks_usec();
|
||||||
|
if (tick_inhibit) continue;
|
||||||
ticks++;
|
ticks++;
|
||||||
|
|
||||||
// Pseudo Mac 1Hz interrupt, update local time
|
// Pseudo Mac 1Hz interrupt, update local time
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
extern bool tick_inhibit;
|
||||||
|
|
||||||
void PlayStartupSound();
|
void PlayStartupSound();
|
||||||
|
|
||||||
// TVector of MakeExecutable
|
// TVector of MakeExecutable
|
||||||
|
@ -283,6 +285,8 @@ void EmulOp(M68kRegisters *r, uint32 pc, int selector)
|
||||||
|
|
||||||
case OP_RESET: // Early in MacOS reset
|
case OP_RESET: // Early in MacOS reset
|
||||||
D(bug("*** RESET ***\n"));
|
D(bug("*** RESET ***\n"));
|
||||||
|
tick_inhibit = true;
|
||||||
|
CDROMRemount(); // for System 7.x
|
||||||
TimerReset();
|
TimerReset();
|
||||||
MacOSUtilReset();
|
MacOSUtilReset();
|
||||||
AudioReset();
|
AudioReset();
|
||||||
|
@ -300,6 +304,7 @@ void EmulOp(M68kRegisters *r, uint32 pc, int selector)
|
||||||
memcpy((void *)DR_EMULATOR_BASE, (void *)(ROMBase + 0x370000), DR_EMULATOR_SIZE);
|
memcpy((void *)DR_EMULATOR_BASE, (void *)(ROMBase + 0x370000), DR_EMULATOR_SIZE);
|
||||||
MakeExecutable(0, DR_EMULATOR_BASE, DR_EMULATOR_SIZE);
|
MakeExecutable(0, DR_EMULATOR_BASE, DR_EMULATOR_SIZE);
|
||||||
}
|
}
|
||||||
|
tick_inhibit = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_IRQ: // Level 1 interrupt
|
case OP_IRQ: // Level 1 interrupt
|
||||||
|
|
Loading…
Reference in New Issue