home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hand Held Organizer Toolkit
/
walnutcreekcdrom-handheldorganizertoolkit-march1998.iso
/
PalmPilot
/
development
/
xcopilotpalmpatch.diff
< prev
Wrap
Text File
|
1997-12-30
|
16KB
|
485 lines
diff -urN xcopilot-v0.4/README xcopilot-v0.4-iang/README
--- xcopilot-v0.4/README Tue Apr 8 21:12:18 1997
+++ xcopilot-v0.4-iang/README Thu Apr 10 19:09:59 1997
@@ -145,3 +145,23 @@
Ivan Curtis
icurtis@radlogic.com.au
+
+------------------------
+
+Version v0.4-iang changes:
+
+o Support for Palm Pilot Pro added
+ To use it, set the environment variable XCOPILOTROM to point to your
+ (1MB) Palm Pilot ROM (not included). Alternately, if you never want
+ to simulate an old Pilot, just name the new ROM "pilot.rom".
+o Logging of flow traces
+ From the debug prompt ("xcopilot -debug"), "log on" and "log off" will
+ toggle logging of major changes in the PC (program counter). This will
+ catch function calls, traps, and returns, but not conditional branches.
+o Improved sound support
+ Instead of just beeping, the correct frequency/duration/amplitude is used.
+o Parameter changes
+ The default RAM size is now 1024K, the scratch space is 64K, and
+ the time between screen updates is 1/20 second.
+
+ - Ian Goldberg <iang@cs.berkeley.edu>
diff -urN xcopilot-v0.4/display.c xcopilot-v0.4-iang/display.c
--- xcopilot-v0.4/display.c Tue Apr 8 20:19:07 1997
+++ xcopilot-v0.4-iang/display.c Thu Apr 10 19:00:20 1997
@@ -38,11 +38,12 @@
Description: Display module for xcopilot emulator
Update History: (most recent first)
- I. Curtis 9-Apr-97 11:43 -- 16bpp and keboard events courtesy of
+ Ian Goldberg 10-Apr-97 16:53 -- changed beeps into true amp/freq/dur sound
+ I. Curtis 9-Apr-97 11:43 -- 16bpp and keboard events courtesy of
Andrew Pfiffer <andyp@co.intel.com>
- I. Curtis 5-Mar-97 20:33 -- added key event processing code
- I. Curtis 25-Feb-97 20:17 -- major tidy up
- I. Curtis 23-Feb-97 21:17 -- Created.
+ I. Curtis 5-Mar-97 20:33 -- added key event processing code
+ I. Curtis 25-Feb-97 20:17 -- major tidy up
+ I. Curtis 23-Feb-97 21:17 -- Created.
******************************************************************************/
@@ -480,7 +481,7 @@
xcpPutImage();
}
-#define UTIMER 10000 /* how long between updates (useconds) */
+#define UTIMER 50000 /* how long between updates (useconds) */
extern void *CPU_getmemptr(CPTR addr);
extern int dbg_loadapp(FILE *out, FILE *in, char *cmd, char *line,
shared_img *shptr);
@@ -646,7 +647,21 @@
* maybe ring the bell
*/
if (shptr->LcdReq == lcdBell) {
- XBell(xcpDisplay, 50);
+ XKeyboardState old;
+ XKeyboardControl new;
+
+ new.bell_percent = shptr->BellAmp;
+ new.bell_pitch = shptr->BellFreq;
+ new.bell_duration = shptr->BellDur;
+ XGetKeyboardControl(xcpDisplay, &old);
+ XChangeKeyboardControl(xcpDisplay,
+ KBBellPercent|KBBellPitch|KBBellDuration, &new);
+ XBell(xcpDisplay, 0);
+ new.bell_percent = old.bell_percent;
+ new.bell_pitch = old.bell_pitch;
+ new.bell_duration = old.bell_duration;
+ XChangeKeyboardControl(xcpDisplay,
+ KBBellPercent|KBBellPitch|KBBellDuration, &new);
shptr->LcdReq = lcdNone;
}
diff -urN xcopilot-v0.4/main.c xcopilot-v0.4-iang/main.c
--- xcopilot-v0.4/main.c Tue Apr 8 19:25:18 1997
+++ xcopilot-v0.4-iang/main.c Thu Apr 10 18:32:14 1997
@@ -55,9 +55,9 @@
#include "pilotcpu.h"
#include "pdebug.h"
-#define RAMSIZE 128 /* this is in k bytes */
+#define RAMSIZE 1024 /* this is in k bytes */
-char *id_version = "XCopilot V0.4";
+char *id_version = "XCopilot V0.4-iang";
/*
* These error messages correspond to the
@@ -95,6 +95,9 @@
shptr->pen = 0;
shptr->pendown = 0;
shptr->CpuReq = cpuNone;
+ shptr->LcdReq = lcdNone;
+ shptr->logF = NULL;
+ shptr->dolog = 0;
shptr->kbin = 0;
shptr->kbout = 0;
}
diff -urN xcopilot-v0.4/mc68k/cpu4.c xcopilot-v0.4-iang/mc68k/cpu4.c
--- xcopilot-v0.4/mc68k/cpu4.c Sat Mar 1 02:53:35 1997
+++ xcopilot-v0.4-iang/mc68k/cpu4.c Thu Apr 10 18:03:02 1997
@@ -2534,6 +2534,9 @@
{ (Shptr->regs).a[7] += 4;
(Shptr->regs).sr = sr; MC68000_setpc(pc);
MakeFromSR();
+ if (Shptr->logF) {
+ fprintf(Shptr->logF, "Trapped to %08lx\n", pc);
+ }
}}}}}}}
void op_4e74(ULONG opcode)
{
diff -urN xcopilot-v0.4/mc68k/custom.c xcopilot-v0.4-iang/mc68k/custom.c
--- xcopilot-v0.4/mc68k/custom.c Tue Apr 8 18:38:44 1997
+++ xcopilot-v0.4-iang/mc68k/custom.c Thu Apr 10 18:12:13 1997
@@ -28,9 +28,11 @@
Description: Dragonball chip emulation
Update History: (most recent first)
- I. Curtis 17-Mar-97 20:42 -- added UART functionality
- I. Curtis 5-Mar-97 21:48 -- added dokey() and beep
- I. Curtis 26-Feb-97 14:28 -- modified from win95 copilot version
+ Ian Goldberg 10-Apr-97 16:53 -- added port E (for Palm Pilot)
+ -- better sound support
+ I. Curtis 17-Mar-97 20:42 -- added UART functionality
+ I. Curtis 5-Mar-97 21:48 -- added dokey() and beep
+ I. Curtis 26-Feb-97 14:28 -- modified from win95 copilot version
******************************************************************************/
#include <ctype.h>
@@ -443,6 +445,13 @@
struct {
unsigned A: 8;
} anon;
+} db_PEDIR, db_PEDATA, db_PEPUEN, db_PESEL;
+
+union {
+ UBYTE x;
+ struct {
+ unsigned A: 8;
+ } anon;
} db_PFDIR, db_PFDATA, db_PFPUEN, db_PFSEL;
union {
@@ -1325,6 +1334,10 @@
db_PDPOL.x = 0x00;
db_PDIRQEN.x = 0x00;
db_PDIRQEDGE.x= 0x00;
+ db_PEDIR.x = 0x00;
+ db_PEDATA.x = 0x00;
+ db_PEPUEN.x = 0xFF;
+ db_PESEL.x = 0xFF;
db_PFDIR.x = 0x00;
db_PFDATA.x = 0x00;
db_PFPUEN.x = 0xFF;
@@ -1540,7 +1553,9 @@
sc = (struct SndCommandType *)
get_real_address(get_long(CustShptr->regs.a[7]+4));
if ((sc->cmd >> 8) == 1) {
- /* Beep(sc->param1lo, sc->param2); */
+ CustShptr->BellFreq = (sc->param1hi << 16) + sc->param1lo;
+ CustShptr->BellDur = sc->param2;
+ CustShptr->BellAmp = sc->param3;
CustShptr->LcdReq = lcdBell;
return 1;
}
@@ -1707,6 +1722,14 @@
return db_PDIRQEN.x;
case PDIRQEDGE:
return db_PDIRQEDGE.x;
+ case PEDIR:
+ return db_PEDIR.x;
+ case PEDATA:
+ return db_PEDATA.x;
+ case PEPUEN:
+ return db_PEPUEN.x;
+ case PESEL:
+ return db_PESEL.x;
case PFDIR:
return db_PFDIR.x;
case PFDATA:
@@ -2098,6 +2121,18 @@
break;
case PDIRQEDGE:
db_PDIRQEDGE.x = value;
+ break;
+ case PEDIR:
+ db_PEDIR.x = value;
+ break;
+ case PEDATA:
+ db_PEDATA.x = value;
+ break;
+ case PEPUEN:
+ db_PEPUEN.x = value;
+ break;
+ case PESEL:
+ db_PESEL.x = value;
break;
case PFDIR:
db_PFDIR.x = value;
diff -urN xcopilot-v0.4/mc68k/dragonball.h xcopilot-v0.4-iang/mc68k/dragonball.h
--- xcopilot-v0.4/mc68k/dragonball.h Tue Feb 25 20:28:49 1997
+++ xcopilot-v0.4-iang/mc68k/dragonball.h Thu Apr 10 18:04:36 1997
@@ -27,7 +27,8 @@
Description: dragonball register definitions
Update History: (most recent first)
- I. Curtis 26-Feb-97 14:58 -- added this header
+ Ian Goldberg 10-Apr-97 16:53 -- added Port E registers (for Palm Pilot)
+ I. Curtis 26-Feb-97 14:58 -- added this header
******************************************************************************/
#define DB 0xFFFF0000
@@ -66,6 +67,10 @@
#define PDPOL 0xF41C /* Port D Polarity Register */
#define PDIRQEN 0xF41D /* Port D IRQ Enable Register */
#define PDIRQEDGE 0xF41F /* Port D IRQ Edge Register */
+#define PEDIR 0xF420 /* Port E Direction Register */
+#define PEDATA 0xF421 /* Port E Data Register */
+#define PEPUEN 0xF422 /* Port E Pullup Enable Register */
+#define PESEL 0xF423 /* Port E Select Register */
#define PFDIR 0xF428 /* Port F Direction Register */
#define PFDATA 0xF429 /* Port F Data Register */
#define PFPUEN 0xF42A /* Port F Pullup Enable Register */
diff -urN xcopilot-v0.4/mc68k/memory.c xcopilot-v0.4-iang/mc68k/memory.c
--- xcopilot-v0.4/mc68k/memory.c Tue Apr 1 19:28:29 1997
+++ xcopilot-v0.4-iang/mc68k/memory.c Thu Apr 10 18:39:02 1997
@@ -27,9 +27,10 @@
Description: Copilot Memory management
Update History: (most recent first)
- I. Curtis 5-Mar-97 21:47 -- mmapped scratchmemory and pilotram
+ Ian Goldberg 10-Apr-97 16:43 -- support for Palm Pilot ROM
+ I. Curtis 5-Mar-97 21:47 -- mmapped scratchmemory and pilotram
rom_wput() routine now actually does something
- I. Curtis 26-Feb-97 14:59 -- modified from win95 version
+ I. Curtis 26-Feb-97 14:59 -- modified from win95 version
******************************************************************************/
#include <unistd.h>
@@ -47,7 +48,7 @@
int ram_size;
int ram_size_mask;
-#define rom_size 0x080000
+int rom_size;
#define ram_start 0x00000000
#define rom_start 0x10c00000
@@ -259,15 +260,32 @@
return rommemory + (addr >> 1);
}
+/* Where to look for the ROM, if not overridden by the XCOPILOTROM
+ environmet variable */
+#ifndef DEFPILOTROM
+#define DEFPILOTROM "pilot.rom"
+#endif
+
/* This routine replaces the win_load_rom routine */
/* It was grabbed from copilot-linux sources */
static int load_rom()
{
int i;
- int f = open("pilot.rom", O_RDONLY);
+ char *romfile;
+ int f;
+ struct stat st;
+
+ romfile = getenv("XCOPILOTROM");
+ if (!romfile) romfile = DEFPILOTROM;
+ f = open(romfile, O_RDONLY);
if (f == -1) {
return PILOTCPU_ROM_NOT_FOUND;
}
+ if (fstat(f, &st)) {
+ close(f);
+ return PILOTCPU_ROM_NOT_FOUND;
+ }
+ rom_size = st.st_size;
rommemory = (UWORD*)mmap(0, rom_size, PROT_READ|PROT_WRITE,
MAP_FILE|MAP_PRIVATE, f, 0);
@@ -469,6 +487,7 @@
int i;
int f;
char fn[40];
+ int res;
buserr = 0;
if (ramsize & (ramsize-1)) {
@@ -524,11 +543,12 @@
}
map_banks(ram_bank, 0x0000, 1);
map_banks(ram_bank, 0x1000, ram_size / 0x10000);
- map_banks(rom_bank, 0x10c0, 8);
map_banks(scratch_bank, 0x0001, 16);
map_banks(custom_bank, 0xFFFF, 1);
+ res = load_rom();
+ map_banks(rom_bank, 0x10c0, rom_size/0x10000 + ((rom_size%0x10000) ? 1 : 0));
- return load_rom();
+ return res;
}
void mem_setscratchaddr(UBYTE *addr)
diff -urN xcopilot-v0.4/mc68k/memory.h xcopilot-v0.4-iang/mc68k/memory.h
--- xcopilot-v0.4/mc68k/memory.h Sat Mar 1 03:53:30 1997
+++ xcopilot-v0.4-iang/mc68k/memory.h Thu Apr 10 19:01:05 1997
@@ -30,7 +30,7 @@
I. Curtis 26-Feb-97 14:59 -- modified from win95 version
******************************************************************************/
-#define SCRATCH_SIZE 32768
+#define SCRATCH_SIZE 65536
#define PILOTCPU_ROM_NOT_FOUND 1
#define PILOTCPU_ERROR_LOADING_ROM 2
diff -urN xcopilot-v0.4/mc68k/newcpu.c xcopilot-v0.4-iang/mc68k/newcpu.c
--- xcopilot-v0.4/mc68k/newcpu.c Mon Mar 17 03:37:22 1997
+++ xcopilot-v0.4-iang/mc68k/newcpu.c Thu Apr 10 18:19:49 1997
@@ -27,12 +27,14 @@
Description: MC68000 emulation
Update History: (most recent first)
- I. Curtis 26-Feb-97 15:00 -- modified from win95 version
+ Ian Goldberg 10-Apr-97 16:53 -- added support for logging flow traces
+ I. Curtis 26-Feb-97 15:00 -- modified from win95 version
******************************************************************************/
#include <assert.h>
#include <unistd.h>
#include <stdio.h>
+#include <stdlib.h>
#include "sysdeps.h"
#include "shared.h"
@@ -98,6 +100,15 @@
void MC68000_setpc(CPTR newpc)
{
+ if (!get_real_address(newpc)) {
+ fprintf(stderr, "FATAL: weird setpc(%08lx) at %08lx!\n",
+ (unsigned long)newpc, MC68000_getpc());
+ abort();
+ }
+ if (Shptr->logF) {
+ fprintf(Shptr->logF, "setpc %08lx -> %08lx\n",
+ MC68000_getpc(), (unsigned long)newpc);
+ }
(Shptr->regs).pc = newpc;
(Shptr->regs).pc_p = (Shptr->regs).pc_oldp = get_real_address(newpc);
}
@@ -385,6 +396,17 @@
for(;;) {
if (Shptr->CpuReq != cpuNone) { /* check for a request */
return; /* bail out if requested */
+ }
+ if (Shptr->dolog == !Shptr->logF) {
+ /* We need to turn logging on or off */
+ if (Shptr->dolog) {
+ char *fname = getenv("XCOPILOTLOG");
+ if (!fname) fname = "xcopilot.log";
+ Shptr->logF = fopen(fname, "a");
+ } else {
+ fclose(Shptr->logF);
+ Shptr->logF = NULL;
+ }
}
InstructionStart_p = (Shptr->regs).pc_p;
opcode = nextiword();
diff -urN xcopilot-v0.4/mc68k/shared.h xcopilot-v0.4-iang/mc68k/shared.h
--- xcopilot-v0.4/mc68k/shared.h Tue Apr 8 18:38:51 1997
+++ xcopilot-v0.4-iang/mc68k/shared.h Thu Apr 10 18:00:36 1997
@@ -27,10 +27,13 @@
Description: definition of shared image structure
Update History: (most recent first)
- I. Curtis 26-Feb-97 15:02 -- created
+ Ian Goldberg 10-Apr-97 14:53 -- added entries for logging, sound
+ I. Curtis 26-Feb-97 15:02 -- created
******************************************************************************/
+#include <stdio.h>
+
/*******************
union flagu {
struct {
@@ -78,12 +81,17 @@
int run_updateisr; /* if TRUE, must update isr */
int quit; /* if TRUE, must quit emulation */
struct regstruct regs; /* the CPU registers state */
+ FILE *logF; /* If non-NULL, log to this file */
+ int dolog; /* Control signal to turn logging on/off */
int ExceptionFlags[48];
int CpuState;
int CpuReq;
int LcdReq;
int LcdPower;
int ErrNo;
+ ULONG BellFreq;
+ UWORD BellDur;
+ UWORD BellAmp;
} shared_img;
/*
diff -urN xcopilot-v0.4/pdebug.c xcopilot-v0.4-iang/pdebug.c
--- xcopilot-v0.4/pdebug.c Tue Apr 8 19:24:41 1997
+++ xcopilot-v0.4-iang/pdebug.c Thu Apr 10 18:33:00 1997
@@ -27,9 +27,10 @@
Description: debugging routines for xcopilot emulator
Update History: (most recent first)
- I. Curtis 9-Apr-97 11:54 -- added debug via socket
- I. Curtis 5-Mar-97 21:03 -- added load command
- I. Curtis 27-Feb-97 22:16 -- created - start/stop/quit commands
+ Ian Goldberg 10-Apr-97 16:53 -- added logging of flow traces
+ I. Curtis 9-Apr-97 11:54 -- added debug via socket
+ I. Curtis 5-Mar-97 21:03 -- added load command
+ I. Curtis 27-Feb-97 22:16 -- created - start/stop/quit commands
******************************************************************************/
#include <unistd.h>
@@ -219,6 +220,36 @@
return DEBUG_OK;
}
+/***************
+ * Show the PC *
+ ***************/
+int dbg_pc(FILE *out, FILE *in, char *cmd, char *line, shared_img *shptr)
+{
+ fprintf(out, "%08lx\n", (shptr->regs).pc +
+ ((char *)(shptr->regs).pc_p - (char *)(shptr->regs).pc_oldp));
+ return DEBUG_OK;
+}
+
+/**************************
+ * Turn logging on or off *
+ **************************/
+int dbg_log(FILE *out, FILE *in, char *cmd, char *line, shared_img *shptr)
+{
+ char *arg = strsep(&line, Delim);
+ if (!strcmp(arg, "on")) {
+ /* Turn logging on */
+ shptr->dolog = 1;
+ return DEBUG_OK;
+ } else if (!strcmp(arg, "off")) {
+ /* Turn logging off */
+ shptr->dolog = 0;
+ return DEBUG_OK;
+ } else {
+ fprintf(out, "Usage: %s on|off\n", cmd);
+ return DEBUG_OK;
+ }
+}
+
/**********************
* Quit the emulation *
**********************/
@@ -241,6 +272,8 @@
{"help", dbg_help, ": Give brief help on commands"},
{"start", dbg_start, ": Start Cpu running"},
{"stop", dbg_stop, ": Stop Cpu running"},
+ {"pc", dbg_pc, ": Show current PC"},
+ {"log", dbg_log, "on|off : turn logging on or off"},
{"load", dbg_loadapp, " <prcfile>: load application"},
{"quit", dbg_quit, ": Quit XCopilot"},
{NULL, NULL, NULL}
@@ -362,7 +395,7 @@
if (cmd_table[i].name) {
status = (cmd_table[i].fun)(out, in, word, line, shptr);
} else if (*word != '\0' && *word != ';') {
- fprintf(stdout, "E - debug - unrecognized command \"%s\"\n", word);
+ fprintf(out, "E - debug - unrecognized command \"%s\"\n", word);
}
}
while (shptr->CpuReq != cpuExit);