home *** CD-ROM | disk | FTP | other *** search
/ Hand Held Organizer Toolkit / walnutcreekcdrom-handheldorganizertoolkit-march1998.iso / PalmPilot / development / xcopilotpalmpatch.diff < prev   
Text File  |  1997-12-30  |  16KB  |  485 lines

  1. diff -urN xcopilot-v0.4/README xcopilot-v0.4-iang/README
  2. --- xcopilot-v0.4/README    Tue Apr  8 21:12:18 1997
  3. +++ xcopilot-v0.4-iang/README    Thu Apr 10 19:09:59 1997
  4. @@ -145,3 +145,23 @@
  5.  
  6.  Ivan Curtis
  7.  icurtis@radlogic.com.au
  8. +
  9. +------------------------
  10. +
  11. +Version v0.4-iang changes:
  12. +
  13. +o Support for Palm Pilot Pro added
  14. +   To use it, set the environment variable XCOPILOTROM to point to your
  15. +   (1MB) Palm Pilot ROM (not included).  Alternately, if you never want
  16. +   to simulate an old Pilot, just name the new ROM "pilot.rom".
  17. +o Logging of flow traces
  18. +   From the debug prompt ("xcopilot -debug"), "log on" and "log off" will
  19. +   toggle logging of major changes in the PC (program counter).  This will
  20. +   catch function calls, traps, and returns, but not conditional branches.
  21. +o Improved sound support
  22. +   Instead of just beeping, the correct frequency/duration/amplitude is used.
  23. +o Parameter changes
  24. +   The default RAM size is now 1024K, the scratch space is 64K, and
  25. +   the time between screen updates is 1/20 second.
  26. +
  27. +   - Ian Goldberg <iang@cs.berkeley.edu>
  28. diff -urN xcopilot-v0.4/display.c xcopilot-v0.4-iang/display.c
  29. --- xcopilot-v0.4/display.c    Tue Apr  8 20:19:07 1997
  30. +++ xcopilot-v0.4-iang/display.c    Thu Apr 10 19:00:20 1997
  31. @@ -38,11 +38,12 @@
  32.  Description:    Display module for xcopilot emulator
  33.  
  34.  Update History:   (most recent first)
  35. -   I. Curtis   9-Apr-97 11:43 -- 16bpp and keboard events courtesy of
  36. +   Ian Goldberg 10-Apr-97 16:53 -- changed beeps into true amp/freq/dur sound
  37. +   I. Curtis     9-Apr-97 11:43 -- 16bpp and keboard events courtesy of
  38.         Andrew Pfiffer <andyp@co.intel.com> 
  39. -   I. Curtis   5-Mar-97 20:33 -- added key event processing code
  40. -   I. Curtis  25-Feb-97 20:17 -- major tidy up
  41. -   I. Curtis  23-Feb-97 21:17 -- Created.
  42. +   I. Curtis     5-Mar-97 20:33 -- added key event processing code
  43. +   I. Curtis    25-Feb-97 20:17 -- major tidy up
  44. +   I. Curtis    23-Feb-97 21:17 -- Created.
  45.  
  46.  ******************************************************************************/
  47.  
  48. @@ -480,7 +481,7 @@
  49.    xcpPutImage();
  50.  }
  51.  
  52. -#define UTIMER 10000        /* how long between updates (useconds) */
  53. +#define UTIMER 50000        /* how long between updates (useconds) */
  54.  extern void *CPU_getmemptr(CPTR addr);
  55.  extern int dbg_loadapp(FILE *out, FILE *in, char *cmd, char *line,
  56.                 shared_img *shptr);
  57. @@ -646,7 +647,21 @@
  58.       * maybe ring the bell
  59.       */
  60.      if (shptr->LcdReq == lcdBell) {
  61. -      XBell(xcpDisplay, 50);
  62. +      XKeyboardState old;
  63. +      XKeyboardControl new;
  64. +
  65. +      new.bell_percent = shptr->BellAmp;
  66. +      new.bell_pitch = shptr->BellFreq;
  67. +      new.bell_duration = shptr->BellDur;
  68. +      XGetKeyboardControl(xcpDisplay, &old);
  69. +      XChangeKeyboardControl(xcpDisplay,
  70. +          KBBellPercent|KBBellPitch|KBBellDuration, &new);
  71. +      XBell(xcpDisplay, 0);
  72. +      new.bell_percent = old.bell_percent;
  73. +      new.bell_pitch = old.bell_pitch;
  74. +      new.bell_duration = old.bell_duration;
  75. +      XChangeKeyboardControl(xcpDisplay,
  76. +          KBBellPercent|KBBellPitch|KBBellDuration, &new);
  77.        shptr->LcdReq = lcdNone;
  78.      }
  79.  
  80. diff -urN xcopilot-v0.4/main.c xcopilot-v0.4-iang/main.c
  81. --- xcopilot-v0.4/main.c    Tue Apr  8 19:25:18 1997
  82. +++ xcopilot-v0.4-iang/main.c    Thu Apr 10 18:32:14 1997
  83. @@ -55,9 +55,9 @@
  84.  #include "pilotcpu.h"
  85.  #include "pdebug.h"
  86.  
  87. -#define RAMSIZE 128        /* this is in k bytes */
  88. +#define RAMSIZE 1024        /* this is in k bytes */
  89.  
  90. -char *id_version = "XCopilot V0.4";
  91. +char *id_version = "XCopilot V0.4-iang";
  92.  
  93.  /*
  94.   * These error messages correspond to the
  95. @@ -95,6 +95,9 @@
  96.    shptr->pen = 0;
  97.    shptr->pendown = 0;
  98.    shptr->CpuReq = cpuNone;
  99. +  shptr->LcdReq = lcdNone;
  100. +  shptr->logF = NULL;
  101. +  shptr->dolog = 0;
  102.    shptr->kbin = 0;
  103.    shptr->kbout = 0;
  104.  }
  105. diff -urN xcopilot-v0.4/mc68k/cpu4.c xcopilot-v0.4-iang/mc68k/cpu4.c
  106. --- xcopilot-v0.4/mc68k/cpu4.c    Sat Mar  1 02:53:35 1997
  107. +++ xcopilot-v0.4-iang/mc68k/cpu4.c    Thu Apr 10 18:03:02 1997
  108. @@ -2534,6 +2534,9 @@
  109.  {    (Shptr->regs).a[7] += 4;
  110.      (Shptr->regs).sr = sr; MC68000_setpc(pc);
  111.      MakeFromSR();
  112. +    if (Shptr->logF) {
  113. +        fprintf(Shptr->logF, "Trapped to %08lx\n", pc);
  114. +    }
  115.  }}}}}}}
  116.  void op_4e74(ULONG opcode)
  117.  {
  118. diff -urN xcopilot-v0.4/mc68k/custom.c xcopilot-v0.4-iang/mc68k/custom.c
  119. --- xcopilot-v0.4/mc68k/custom.c    Tue Apr  8 18:38:44 1997
  120. +++ xcopilot-v0.4-iang/mc68k/custom.c    Thu Apr 10 18:12:13 1997
  121. @@ -28,9 +28,11 @@
  122.  Description:    Dragonball chip emulation
  123.  
  124.  Update History:   (most recent first)
  125. -   I. Curtis  17-Mar-97 20:42 -- added UART functionality
  126. -   I. Curtis   5-Mar-97 21:48 -- added dokey() and beep
  127. -   I. Curtis  26-Feb-97 14:28 -- modified from win95 copilot version
  128. +   Ian Goldberg 10-Apr-97 16:53 -- added port E (for Palm Pilot)
  129. +                                -- better sound support
  130. +   I. Curtis    17-Mar-97 20:42 -- added UART functionality
  131. +   I. Curtis     5-Mar-97 21:48 -- added dokey() and beep
  132. +   I. Curtis    26-Feb-97 14:28 -- modified from win95 copilot version
  133.  
  134.  ******************************************************************************/
  135.  #include <ctype.h>
  136. @@ -443,6 +445,13 @@
  137.    struct {
  138.      unsigned A: 8;
  139.    } anon;
  140. +} db_PEDIR, db_PEDATA, db_PEPUEN, db_PESEL;
  141. +
  142. +union {
  143. +  UBYTE x;
  144. +  struct {
  145. +    unsigned A: 8;
  146. +  } anon;
  147.  } db_PFDIR, db_PFDATA, db_PFPUEN, db_PFSEL;
  148.  
  149.  union {
  150. @@ -1325,6 +1334,10 @@
  151.    db_PDPOL.x    = 0x00;
  152.    db_PDIRQEN.x  = 0x00;
  153.    db_PDIRQEDGE.x= 0x00;
  154. +  db_PEDIR.x    = 0x00;
  155. +  db_PEDATA.x   = 0x00;
  156. +  db_PEPUEN.x   = 0xFF;
  157. +  db_PESEL.x    = 0xFF;
  158.    db_PFDIR.x    = 0x00;
  159.    db_PFDATA.x   = 0x00;
  160.    db_PFPUEN.x   = 0xFF;
  161. @@ -1540,7 +1553,9 @@
  162.        sc = (struct SndCommandType *)
  163.      get_real_address(get_long(CustShptr->regs.a[7]+4));
  164.        if ((sc->cmd >> 8) == 1) {
  165. -    /* Beep(sc->param1lo, sc->param2); */
  166. +    CustShptr->BellFreq = (sc->param1hi << 16) + sc->param1lo;
  167. +    CustShptr->BellDur = sc->param2;
  168. +    CustShptr->BellAmp = sc->param3;
  169.      CustShptr->LcdReq = lcdBell;
  170.      return 1;
  171.        }
  172. @@ -1707,6 +1722,14 @@
  173.        return db_PDIRQEN.x;
  174.      case PDIRQEDGE:
  175.        return db_PDIRQEDGE.x;
  176. +    case PEDIR:
  177. +      return db_PEDIR.x;
  178. +    case PEDATA:
  179. +      return db_PEDATA.x;
  180. +    case PEPUEN:
  181. +      return db_PEPUEN.x;
  182. +    case PESEL:
  183. +      return db_PESEL.x;
  184.      case PFDIR:
  185.        return db_PFDIR.x;
  186.      case PFDATA:
  187. @@ -2098,6 +2121,18 @@
  188.        break;
  189.      case PDIRQEDGE:
  190.        db_PDIRQEDGE.x = value;
  191. +      break;
  192. +    case PEDIR:
  193. +      db_PEDIR.x = value;
  194. +      break;
  195. +    case PEDATA:
  196. +      db_PEDATA.x = value;
  197. +      break;
  198. +    case PEPUEN:
  199. +      db_PEPUEN.x = value;
  200. +      break;
  201. +    case PESEL:
  202. +      db_PESEL.x = value;
  203.        break;
  204.      case PFDIR:
  205.        db_PFDIR.x = value;
  206. diff -urN xcopilot-v0.4/mc68k/dragonball.h xcopilot-v0.4-iang/mc68k/dragonball.h
  207. --- xcopilot-v0.4/mc68k/dragonball.h    Tue Feb 25 20:28:49 1997
  208. +++ xcopilot-v0.4-iang/mc68k/dragonball.h    Thu Apr 10 18:04:36 1997
  209. @@ -27,7 +27,8 @@
  210.  Description:    dragonball register definitions
  211.  
  212.  Update History:   (most recent first)
  213. -   I. Curtis  26-Feb-97 14:58 -- added this header
  214. +   Ian Goldberg 10-Apr-97 16:53 -- added Port E registers (for Palm Pilot)
  215. +   I. Curtis    26-Feb-97 14:58 -- added this header
  216.  
  217.  ******************************************************************************/
  218.  #define DB 0xFFFF0000
  219. @@ -66,6 +67,10 @@
  220.  #define PDPOL     0xF41C /* Port D Polarity Register */
  221.  #define PDIRQEN   0xF41D /* Port D IRQ Enable Register */
  222.  #define PDIRQEDGE 0xF41F /* Port D IRQ Edge Register */
  223. +#define PEDIR     0xF420 /* Port E Direction Register */
  224. +#define PEDATA    0xF421 /* Port E Data Register */
  225. +#define PEPUEN    0xF422 /* Port E Pullup Enable Register */
  226. +#define PESEL     0xF423 /* Port E Select Register */
  227.  #define PFDIR     0xF428 /* Port F Direction Register */
  228.  #define PFDATA    0xF429 /* Port F Data Register */
  229.  #define PFPUEN    0xF42A /* Port F Pullup Enable Register */
  230. diff -urN xcopilot-v0.4/mc68k/memory.c xcopilot-v0.4-iang/mc68k/memory.c
  231. --- xcopilot-v0.4/mc68k/memory.c    Tue Apr  1 19:28:29 1997
  232. +++ xcopilot-v0.4-iang/mc68k/memory.c    Thu Apr 10 18:39:02 1997
  233. @@ -27,9 +27,10 @@
  234.  Description:    Copilot Memory management
  235.  
  236.  Update History:   (most recent first)
  237. -   I. Curtis   5-Mar-97 21:47 -- mmapped scratchmemory and pilotram
  238. +   Ian Goldberg 10-Apr-97 16:43 -- support for Palm Pilot ROM
  239. +   I. Curtis     5-Mar-97 21:47 -- mmapped scratchmemory and pilotram
  240.       rom_wput() routine now actually does something
  241. -   I. Curtis  26-Feb-97 14:59 -- modified from win95 version
  242. +   I. Curtis    26-Feb-97 14:59 -- modified from win95 version
  243.  
  244.  ******************************************************************************/
  245.  #include <unistd.h>
  246. @@ -47,7 +48,7 @@
  247.  
  248.  int ram_size;
  249.  int ram_size_mask;
  250. -#define rom_size 0x080000
  251. +int rom_size;
  252.  
  253.  #define ram_start 0x00000000
  254.  #define rom_start 0x10c00000
  255. @@ -259,15 +260,32 @@
  256.      return rommemory + (addr >> 1);
  257.  }
  258.  
  259. +/* Where to look for the ROM, if not overridden by the XCOPILOTROM
  260. +   environmet variable */
  261. +#ifndef DEFPILOTROM
  262. +#define DEFPILOTROM "pilot.rom"
  263. +#endif
  264. +
  265.  /* This routine replaces the win_load_rom routine */
  266.  /* It was grabbed from copilot-linux sources */
  267.  static int load_rom()
  268.  {
  269.    int i;
  270. -  int f = open("pilot.rom", O_RDONLY);
  271. +  char *romfile;
  272. +  int f;
  273. +  struct stat st;
  274. +  
  275. +  romfile = getenv("XCOPILOTROM");
  276. +  if (!romfile) romfile = DEFPILOTROM;
  277. +  f = open(romfile, O_RDONLY);
  278.    if (f == -1) {
  279.      return PILOTCPU_ROM_NOT_FOUND;
  280.    }
  281. +  if (fstat(f, &st)) {
  282. +    close(f);
  283. +    return PILOTCPU_ROM_NOT_FOUND;
  284. +  }
  285. +  rom_size = st.st_size;
  286.      
  287.    rommemory = (UWORD*)mmap(0, rom_size, PROT_READ|PROT_WRITE, 
  288.                 MAP_FILE|MAP_PRIVATE, f, 0);
  289. @@ -469,6 +487,7 @@
  290.    int i;
  291.    int f;
  292.    char fn[40];
  293. +  int res;
  294.  
  295.    buserr = 0;
  296.    if (ramsize & (ramsize-1)) {
  297. @@ -524,11 +543,12 @@
  298.    }
  299.    map_banks(ram_bank, 0x0000, 1);
  300.    map_banks(ram_bank, 0x1000, ram_size / 0x10000);
  301. -  map_banks(rom_bank, 0x10c0, 8);
  302.    map_banks(scratch_bank, 0x0001, 16);
  303.    map_banks(custom_bank, 0xFFFF, 1);
  304. +  res = load_rom();
  305. +  map_banks(rom_bank, 0x10c0, rom_size/0x10000 + ((rom_size%0x10000) ? 1 : 0));
  306.  
  307. -  return load_rom();
  308. +  return res;
  309.  }
  310.  
  311.  void mem_setscratchaddr(UBYTE *addr)
  312. diff -urN xcopilot-v0.4/mc68k/memory.h xcopilot-v0.4-iang/mc68k/memory.h
  313. --- xcopilot-v0.4/mc68k/memory.h    Sat Mar  1 03:53:30 1997
  314. +++ xcopilot-v0.4-iang/mc68k/memory.h    Thu Apr 10 19:01:05 1997
  315. @@ -30,7 +30,7 @@
  316.     I. Curtis  26-Feb-97 14:59 -- modified from win95 version
  317.  
  318.  ******************************************************************************/
  319. -#define SCRATCH_SIZE 32768
  320. +#define SCRATCH_SIZE 65536
  321.  
  322.  #define PILOTCPU_ROM_NOT_FOUND     1
  323.  #define PILOTCPU_ERROR_LOADING_ROM 2
  324. diff -urN xcopilot-v0.4/mc68k/newcpu.c xcopilot-v0.4-iang/mc68k/newcpu.c
  325. --- xcopilot-v0.4/mc68k/newcpu.c    Mon Mar 17 03:37:22 1997
  326. +++ xcopilot-v0.4-iang/mc68k/newcpu.c    Thu Apr 10 18:19:49 1997
  327. @@ -27,12 +27,14 @@
  328.  Description:    MC68000 emulation
  329.  
  330.  Update History:   (most recent first)
  331. -   I. Curtis  26-Feb-97 15:00 -- modified from win95 version
  332. +   Ian Goldberg 10-Apr-97 16:53 -- added support for logging flow traces
  333. +   I. Curtis    26-Feb-97 15:00 -- modified from win95 version
  334.  
  335.  ******************************************************************************/
  336.  #include <assert.h>
  337.  #include <unistd.h>
  338.  #include <stdio.h>
  339. +#include <stdlib.h>
  340.  
  341.  #include "sysdeps.h"
  342.  #include "shared.h"
  343. @@ -98,6 +100,15 @@
  344.  
  345.  void MC68000_setpc(CPTR newpc)
  346.  {
  347. +    if (!get_real_address(newpc)) {
  348. +    fprintf(stderr, "FATAL: weird setpc(%08lx) at %08lx!\n",
  349. +        (unsigned long)newpc, MC68000_getpc());
  350. +    abort();
  351. +    }
  352. +    if (Shptr->logF) {
  353. +    fprintf(Shptr->logF, "setpc %08lx -> %08lx\n",
  354. +        MC68000_getpc(), (unsigned long)newpc);
  355. +    }
  356.      (Shptr->regs).pc = newpc;
  357.      (Shptr->regs).pc_p = (Shptr->regs).pc_oldp = get_real_address(newpc);
  358.  }
  359. @@ -385,6 +396,17 @@
  360.    for(;;) {
  361.      if (Shptr->CpuReq != cpuNone) {   /* check for a request */
  362.        return;                  /* bail out if requested */
  363. +    }
  364. +    if (Shptr->dolog == !Shptr->logF) {
  365. +    /* We need to turn logging on or off */
  366. +    if (Shptr->dolog) {
  367. +        char *fname = getenv("XCOPILOTLOG");
  368. +        if (!fname) fname = "xcopilot.log";
  369. +        Shptr->logF = fopen(fname, "a");
  370. +    } else {
  371. +        fclose(Shptr->logF);
  372. +        Shptr->logF = NULL;
  373. +    }
  374.      }
  375.      InstructionStart_p = (Shptr->regs).pc_p;
  376.      opcode = nextiword();
  377. diff -urN xcopilot-v0.4/mc68k/shared.h xcopilot-v0.4-iang/mc68k/shared.h
  378. --- xcopilot-v0.4/mc68k/shared.h    Tue Apr  8 18:38:51 1997
  379. +++ xcopilot-v0.4-iang/mc68k/shared.h    Thu Apr 10 18:00:36 1997
  380. @@ -27,10 +27,13 @@
  381.  Description:    definition of shared image structure
  382.  
  383.  Update History:   (most recent first)
  384. -   I. Curtis  26-Feb-97 15:02 -- created
  385. +   Ian Goldberg 10-Apr-97 14:53 -- added entries for logging, sound
  386. +   I. Curtis    26-Feb-97 15:02 -- created
  387.  
  388.  ******************************************************************************/
  389.  
  390. +#include <stdio.h>
  391. +
  392.  /*******************
  393.    union flagu {
  394.    struct {
  395. @@ -78,12 +81,17 @@
  396.    int run_updateisr;        /* if TRUE, must update isr */
  397.    int quit;            /* if TRUE, must quit emulation */
  398.    struct regstruct regs;    /* the CPU registers state */
  399. +  FILE *logF;            /* If non-NULL, log to this file */
  400. +  int dolog;            /* Control signal to turn logging on/off */
  401.    int ExceptionFlags[48];
  402.    int CpuState;
  403.    int CpuReq;
  404.    int LcdReq;
  405.    int LcdPower;
  406.    int ErrNo;
  407. +  ULONG BellFreq;
  408. +  UWORD BellDur;
  409. +  UWORD BellAmp;
  410.  } shared_img;
  411.  
  412.  /*
  413. diff -urN xcopilot-v0.4/pdebug.c xcopilot-v0.4-iang/pdebug.c
  414. --- xcopilot-v0.4/pdebug.c    Tue Apr  8 19:24:41 1997
  415. +++ xcopilot-v0.4-iang/pdebug.c    Thu Apr 10 18:33:00 1997
  416. @@ -27,9 +27,10 @@
  417.  Description:    debugging routines for xcopilot emulator
  418.  
  419.  Update History:   (most recent first)
  420. -   I. Curtis   9-Apr-97 11:54 -- added debug via socket
  421. -   I. Curtis   5-Mar-97 21:03 -- added load command
  422. -   I. Curtis  27-Feb-97 22:16 -- created - start/stop/quit commands
  423. +   Ian Goldberg 10-Apr-97 16:53 -- added logging of flow traces
  424. +   I. Curtis     9-Apr-97 11:54 -- added debug via socket
  425. +   I. Curtis     5-Mar-97 21:03 -- added load command
  426. +   I. Curtis    27-Feb-97 22:16 -- created - start/stop/quit commands
  427.  
  428.  ******************************************************************************/
  429.  #include <unistd.h>
  430. @@ -219,6 +220,36 @@
  431.    return DEBUG_OK;
  432.  }
  433.  
  434. +/***************
  435. + * Show the PC *
  436. + ***************/
  437. +int dbg_pc(FILE *out, FILE *in, char *cmd, char *line, shared_img *shptr)
  438. +{
  439. +  fprintf(out, "%08lx\n", (shptr->regs).pc +
  440. +      ((char *)(shptr->regs).pc_p - (char *)(shptr->regs).pc_oldp));
  441. +  return DEBUG_OK;
  442. +}
  443. +
  444. +/**************************
  445. + * Turn logging on or off *
  446. + **************************/
  447. +int dbg_log(FILE *out, FILE *in, char *cmd, char *line, shared_img *shptr)
  448. +{
  449. +  char *arg = strsep(&line, Delim);
  450. +  if (!strcmp(arg, "on")) {
  451. +    /* Turn logging on */
  452. +    shptr->dolog = 1;
  453. +    return DEBUG_OK;
  454. +  } else if (!strcmp(arg, "off")) {
  455. +    /* Turn logging off */
  456. +    shptr->dolog = 0;
  457. +    return DEBUG_OK;
  458. +  } else {
  459. +    fprintf(out, "Usage: %s on|off\n", cmd);
  460. +    return DEBUG_OK;
  461. +  }
  462. +}
  463. +
  464.  /**********************
  465.   * Quit the emulation *
  466.   **********************/
  467. @@ -241,6 +272,8 @@
  468.    {"help", dbg_help, ": Give brief help on commands"},
  469.    {"start", dbg_start, ": Start Cpu running"},
  470.    {"stop", dbg_stop, ": Stop Cpu running"},
  471. +  {"pc", dbg_pc, ": Show current PC"},
  472. +  {"log", dbg_log, "on|off : turn logging on or off"},
  473.    {"load", dbg_loadapp, " <prcfile>: load application"},
  474.    {"quit", dbg_quit, ": Quit XCopilot"},
  475.    {NULL, NULL, NULL}
  476. @@ -362,7 +395,7 @@
  477.      if (cmd_table[i].name) {
  478.        status = (cmd_table[i].fun)(out, in, word, line, shptr);
  479.      } else if (*word != '\0' && *word != ';') {
  480. -      fprintf(stdout, "E - debug - unrecognized command \"%s\"\n", word);
  481. +      fprintf(out, "E - debug - unrecognized command \"%s\"\n", word);
  482.      }
  483.    }
  484.    while (shptr->CpuReq != cpuExit);
  485.