home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / mpel / mpeluCode.c < prev    next >
C/C++ Source or Header  |  1992-02-11  |  4KB  |  168 lines

  1. /*
  2.  * Copyright IBM Corporation 1987,1988,1989
  3.  *
  4.  * All Rights Reserved
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted,
  8.  * provided that the above copyright notice appear in all copies and that 
  9.  * both that copyright notice and this permission notice appear in
  10.  * supporting documentation, and that the name of IBM not be
  11.  * used in advertising or publicity pertaining to distribution of the
  12.  * software without specific, written prior permission.
  13.  *
  14.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  15.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  16.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  17.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  18.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  19.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  20.  * SOFTWARE.
  21.  *
  22. */
  23.  
  24. /* $Header: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/mpel/RCS/mpeluCode.c,v 1.2 1992/02/12 00:42:41 jfc Exp $ */
  25. /* $Source: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/mpel/RCS/mpeluCode.c,v $ */
  26.  
  27. #ifndef lint
  28. static char *rcsid = "$Id: mpeluCode.c,v 1.2 1992/02/12 00:42:41 jfc Exp $";
  29. #endif
  30.  
  31. #include <sys/types.h>
  32. #include <fcntl.h>
  33.  
  34. #include "Xmd.h"
  35.  
  36. #include "ibmTrace.h"
  37.  
  38. #include "mpelHdwr.h"
  39.  
  40. #ifndef AIXrt
  41.  
  42. #define FALSE 0
  43. #define TRUE (-1)
  44.  
  45. /***==================================================================***/
  46.  
  47. static void
  48. mpelClearMemory()
  49. {
  50.     volatile unsigned short int *tmp ;
  51.  
  52.     TRACE(("mpelClearMemory()\n"));
  53.  
  54.     /* zero adapter data space */
  55.     for (tmp = MPEL_LOWDATA; tmp <= MPEL_HIGHDATA; tmp++)
  56.     *tmp = 0;
  57.  
  58.     /* zero adapter program space */
  59.     for (tmp = MPEL_LOWPROGRAM ; tmp <= MPEL_HIGHPROGRAM ; tmp++) *tmp = 0;
  60.  
  61.     return;
  62. }
  63.  
  64. /***==================================================================***/
  65.  
  66. void
  67. mpelLoad(file,addr)
  68.     char    *file;
  69.     volatile unsigned short *addr;
  70. {
  71.     int        fd, nWords, done;
  72.     unsigned short int *tmp, buf[2048];
  73.  
  74.     TRACE(("mpelLoad(%s,0x%x)\n",file,addr));
  75.  
  76.     if ((fd=open(file,O_RDONLY))<0) {
  77.     ErrorF("can't open %s.\nExiting\n",file);
  78.     exit(1);
  79.     /*NOTREACHED*/
  80.     }
  81.     done= FALSE;
  82.     while (!done) {
  83.     nWords = read(fd, buf, sizeof(buf));
  84.     if (nWords < 0) {
  85.         ErrorF("WSGO!! Read failed in mpelLoad.\nExiting.\n");
  86.         exit(1);
  87.     }
  88.     else if (nWords< sizeof(buf)) 
  89.         done = TRUE;
  90.     mpelCopy(buf, addr, nWords >> 1);
  91.     addr += sizeof(buf) / 2;
  92.     }
  93.     (void) close(fd);
  94.     return;
  95. }
  96.  
  97. /***==================================================================***/
  98.  
  99. void
  100. mpelLoaduCode()
  101. {
  102. register int fd, i ;
  103.  
  104.     TRACE(("mpelLoadUCode()\n"));
  105.  
  106.     MPEL_PCR= PCR_HOLD|PCR_RESET_TMS|PCR_BYTE_ORDER;
  107.     while (MPEL_PSR&PSR_NOT_HOLD_ACK);    /* wait for TMS to stop */
  108.  
  109.     mpelClearMemory();
  110.     MPEL_CA_PTR= 0x0000480;    /* set up comm area ptr */
  111.     /* someday set annotation text font location table (maybe) */
  112.     /* someday set programmable character set font location table (maybe) */
  113.     mpelLoad(MPEL_CIRCLE_FILE,MPEL_CIRCLE_ADDR);
  114.     mpelLoad(MPEL_SINE_FILE,MPEL_SINE_ADDR);
  115.     mpelLoad(MPEL_MARKER_LOC_FILE,MPEL_MARKER_LOC_ADDR);
  116.     mpelLoad(MPEL_HATCH_FILE,MPEL_HATCH_ADDR);
  117.     mpelLoad(MPEL_MARKER_FNT_FILE,MPEL_MARKER_FNT_ADDR);
  118.     MPEL_ATF_LOC_PTR= mpelAddr(MPEL_ATF_REGION);
  119.     mpelInitFonts();
  120.     mpelLoad(MPEL_UCODE_FILE,MPEL_UCODE_ADDR);
  121.     /* we want to do this before starting the tms */
  122.     mpelInitPatterns(); 
  123.  
  124.     TRACE(("megapel load done\n"));
  125.  
  126.     MPEL_PCR = PCR_BYTE_ORDER;        /* start tms */
  127.     for (i=100000; MPEL_COMM_REASON!=MPELRSN_INIT_DONE; i--) {
  128.     if (i<0) {
  129.         ErrorF("initialization load failed (%d)\n",MPEL_COMM_REASON);
  130.         break;
  131.     }
  132.     }
  133.     MPEL_COMM_REASON = 0;
  134.  
  135.     MPEL_COMM_REQ = MPELCMD_ENTER_FIFO;
  136.     MPEL_PCR &= ~PCR_INTR_TMS;
  137.     MPEL_PCR |= PCR_INTR_TMS;
  138.  
  139.     TRACE(("megapel init done\n"));
  140.  
  141.     return;
  142. }
  143.  
  144. #else /* defined AIXrt */
  145.  
  146. void
  147. mpelLoaduCode()
  148. {
  149. register int i ;
  150.  
  151.     TRACE(("mpelLoadUCode()\n"));
  152.  
  153.     MPEL_PCR=         PCR_BYTE_ORDER;
  154.     MPEL_ATF_LOC_PTR=    mpelAddr(MPEL_ATF_REGION);
  155.     mpelInitFonts();
  156.     /* we want to do this before starting the tms */
  157.     mpelInitPatterns(); 
  158.  
  159.     MPEL_PCR= PCR_BYTE_ORDER;        /* start tms */
  160.     MPEL_COMM_REASON = 0;
  161.     MPEL_COMM_REQ = MPELCMD_ENTER_FIFO;
  162.     MPEL_PCR &= ~PCR_INTR_TMS ;
  163.     MPEL_PCR |= PCR_INTR_TMS;
  164.     return;
  165. }
  166.  
  167. #endif /* defined AIXrt */
  168.