prepared XPRAM code for PowerMac emulation (8192 bytes NVRAM)

This commit is contained in:
cebix 2001-10-07 19:50:21 +00:00
parent 3492bae5e2
commit b36675d9c2
10 changed files with 45 additions and 24 deletions

View File

@ -44,3 +44,5 @@ Unix:
- scsi_linux.cpp: adapt to SCSI Generic driver V2.0
- ESD is also available on Solaris
- serial_unix.cpp: provide a way to pipe input/output to programs
- display progress bar during disk file creation in prefs editor
- add file browsing window to "Unix Root", "Keycode Translation File", "ROM File"

View File

@ -598,14 +598,14 @@ static __saveds void tick_func(void)
static __saveds void xpram_func(void)
{
uint8 last_xpram[256];
memcpy(last_xpram, XPRAM, 256);
uint8 last_xpram[XPRAM_SIZE];
memcpy(last_xpram, XPRAM, XPRAM_SIZE);
while (xpram_proc_active) {
for (int i=0; i<60 && xpram_proc_active; i++)
Delay(50); // Only wait 1 second so we quit promptly when xpram_proc_active becomes false
if (memcmp(last_xpram, XPRAM, 256)) {
memcpy(last_xpram, XPRAM, 256);
if (memcmp(last_xpram, XPRAM, XPRAM_SIZE)) {
memcpy(last_xpram, XPRAM, XPRAM_SIZE);
SaveXPRAM();
}
}

View File

@ -26,8 +26,13 @@
// XPRAM file name
#if POWERPC_ROM
static char XPRAM_FILE_NAME[] = "ENV:SheepShaver_NVRAM";
static char XPRAM_FILE_NAME_ARC[] = "ENVARC:SheepShaver_NVRAM";
#else
static char XPRAM_FILE_NAME[] = "ENV:BasiliskII_XPRAM";
static char XPRAM_FILE_NAME_ARC[] = "ENVARC:BasiliskII_XPRAM";
#endif
/*
@ -38,7 +43,7 @@ void LoadXPRAM(void)
{
BPTR fh;
if ((fh = Open(XPRAM_FILE_NAME, MODE_OLDFILE)) != NULL) {
Read(fh, XPRAM, 256);
Read(fh, XPRAM, XPRAM_SIZE);
Close(fh);
}
}
@ -52,11 +57,11 @@ void SaveXPRAM(void)
{
BPTR fh;
if ((fh = Open(XPRAM_FILE_NAME, MODE_NEWFILE)) != NULL) {
Write(fh, XPRAM, 256);
Write(fh, XPRAM, XPRAM_SIZE);
Close(fh);
}
if ((fh = Open(XPRAM_FILE_NAME_ARC, MODE_NEWFILE)) != NULL) {
Write(fh, XPRAM, 256);
Write(fh, XPRAM, XPRAM_SIZE);
Close(fh);
}
}

View File

@ -550,13 +550,13 @@ status_t BasiliskII::tick_func(void *arg)
status_t BasiliskII::xpram_func(void *arg)
{
uint8 last_xpram[256];
memcpy(last_xpram, XPRAM, 256);
uint8 last_xpram[XPRAM_SIZE];
memcpy(last_xpram, XPRAM, XPRAM_SIZE);
while (((BasiliskII *)arg)->xpram_thread_active) {
snooze(60*1000000);
if (memcmp(last_xpram, XPRAM, 256)) {
memcpy(last_xpram, XPRAM, 256);
if (memcmp(last_xpram, XPRAM, XPRAM_SIZE)) {
memcpy(last_xpram, XPRAM, XPRAM_SIZE);
SaveXPRAM();
}
}

View File

@ -26,7 +26,11 @@
// XPRAM file name and path
#if POWERPC_ROM
const char XPRAM_FILE_NAME[] = "SheepShaver_NVRAM";
#else
const char XPRAM_FILE_NAME[] = "BasiliskII_XPRAM";
#endif
static BPath xpram_path;
@ -43,7 +47,7 @@ void LoadXPRAM(void)
// Load XPRAM from settings file
int fd;
if ((fd = open(xpram_path.Path(), O_RDONLY)) >= 0) {
read(fd, XPRAM, 256);
read(fd, XPRAM, XPRAM_SIZE);
close(fd);
}
}
@ -59,7 +63,7 @@ void SaveXPRAM(void)
return;
int fd;
if ((fd = open(xpram_path.Path(), O_WRONLY | O_CREAT, 0666)) >= 0) {
write(fd, XPRAM, 256);
write(fd, XPRAM, XPRAM_SIZE);
close(fd);
}
}

View File

@ -109,7 +109,7 @@ bool TwentyFourBitAddressing;
char *x_display_name = NULL; // X11 display name
Display *x_display = NULL; // X11 display handle
static uint8 last_xpram[256]; // Buffer for monitoring XPRAM changes
static uint8 last_xpram[XPRAM_SIZE]; // Buffer for monitoring XPRAM changes
#ifdef HAVE_PTHREADS
static pthread_t emul_thread; // Handle of MacOS emulation thread (main thread)
@ -548,7 +548,7 @@ int main(int argc, char **argv)
#ifdef HAVE_PTHREADS
// Start XPRAM watchdog thread
memcpy(last_xpram, XPRAM, 256);
memcpy(last_xpram, XPRAM, XPRAM_SIZE);
xpram_thread_active = (pthread_create(&xpram_thread, NULL, xpram_func, NULL) == 0);
D(bug("XPRAM thread started\n"));
#endif
@ -786,8 +786,8 @@ void TriggerNMI(void)
static void xpram_watchdog(void)
{
if (memcmp(last_xpram, XPRAM, 256)) {
memcpy(last_xpram, XPRAM, 256);
if (memcmp(last_xpram, XPRAM, XPRAM_SIZE)) {
memcpy(last_xpram, XPRAM, XPRAM_SIZE);
SaveXPRAM();
}
}

View File

@ -67,10 +67,10 @@ user_string_def platform_strings[] = {
{STR_FBDEV_NAME_CTRL, "Frame Buffer Name"},
{STR_FBDEVICE_FILE_CTRL, "Frame Buffer Spec File"},
{STR_INPUT_PANE_TITLE, "Input"},
{STR_INPUT_PANE_TITLE, "Mouse/Keyboard"},
{STR_KEYCODES_CTRL, "Use Raw Keycodes"},
{STR_KEYCODE_FILE_CTRL, "Keycode Translation File"},
{STR_MOUSEWHEELMODE_CTRL, "Mouse Wheel Mode"},
{STR_MOUSEWHEELMODE_CTRL, "Mouse Wheel Function"},
{STR_MOUSEWHEELMODE_PAGE_LAB, "Page Up/Down"},
{STR_MOUSEWHEELMODE_CURSOR_LAB, "Cursor Up/Down"},
{STR_MOUSEWHEELLINES_CTRL, "Lines To Scroll"},

View File

@ -26,7 +26,11 @@
// XPRAM file name and path
#if POWERPC_ROM
const char XPRAM_FILE_NAME[] = ".sheepshaver_nvram";
#else
const char XPRAM_FILE_NAME[] = ".basilisk_ii_xpram";
#endif
static char xpram_path[1024];
@ -48,7 +52,7 @@ void LoadXPRAM(void)
// Load XPRAM from settings file
int fd;
if ((fd = open(xpram_path, O_RDONLY)) >= 0) {
read(fd, XPRAM, 256);
read(fd, XPRAM, XPRAM_SIZE);
close(fd);
}
}
@ -62,7 +66,7 @@ void SaveXPRAM(void)
{
int fd;
if ((fd = open(xpram_path, O_WRONLY | O_CREAT, 0666)) >= 0) {
write(fd, XPRAM, 256);
write(fd, XPRAM, XPRAM_SIZE);
close(fd);
}
}

View File

@ -21,7 +21,13 @@
#ifndef XPRAM_H
#define XPRAM_H
extern uint8 XPRAM[256];
#if POWERPC_ROM
const int XPRAM_SIZE = 8192;
#else
const int XPRAM_SIZE = 256;
#endif
extern uint8 XPRAM[XPRAM_SIZE];
extern void XPRAMInit(void);
extern void XPRAMExit(void);

View File

@ -30,7 +30,7 @@
// Extended parameter RAM
uint8 XPRAM[256];
uint8 XPRAM[XPRAM_SIZE];
/*
@ -40,7 +40,7 @@ uint8 XPRAM[256];
void XPRAMInit(void)
{
// Clear XPRAM
memset(XPRAM, 0, 256);
memset(XPRAM, 0, XPRAM_SIZE);
// Load XPRAM from settings file
LoadXPRAM();