Advertisement
antiquekid3

SETCROSS Source

Jan 26th, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.25 KB | None | 0 0
  1. /****************************************************************/
  2. /* test program                                                 */
  3. /****************************************************************/
  4. /* this program has been created to program the Cbar board and  */
  5. /* the 8 processor boards.                                      */
  6. /****************************************************************/
  7.  
  8. #include<stdio.h>
  9. #include<conio.h>
  10. #include<ansi.h>
  11. #include<time.h>
  12.  
  13. /****************************************************************/
  14. /* reset();                                                     */
  15. /* this routine resets the entire Cbar and Xputer system.       */
  16. /* writes 1 out to port 160h and waits for a pause before       */
  17. /* resetting.                                                   */
  18. /*--------------------------------------------------------------*/
  19. /* status( itt );                                               */
  20. /* returns a 1 if the co11 is not ready.                        */
  21. /* causes the entire system to reset but only the Cbar c004 is  */
  22. /* reset.  That is, it is the only cross bar that must be re-   */
  23. /* set up.                                                      */
  24. /*--------------------------------------------------------------*/
  25. /* send();                                                      */
  26. /* sends data to the crossbar                                   */
  27. /* only one byte                                                */
  28. /*--------------------------------------------------------------*/
  29. /* getbyte();                                                   */
  30. /* get one byte from port 170h.                                 */
  31. /*--------------------------------------------------------------*/
  32. /* setlink(a,b)                                                 */
  33. /* sequence of data sent to the crossbar to set up specific     */
  34. /* link.                                                        */
  35. /*--------------------------------------------------------------*/
  36. /* verify(a,b);                                                 */
  37. /* sequence of commands to verify that crossbar made connections*/
  38. /*--------------------------------------------------------------*/
  39. /* open_config_link();                                          */
  40. /* command sent to port 174h to enable the configuration link   */
  41. /*--------------------------------------------------------------*/
  42. /* close_config_link();                                         */
  43. /* command sent to prot 174h to disable the configuration link  */
  44. /****************************************************************/
  45.  
  46. int bad_error;
  47. bad_error=0;
  48.  
  49. void main()
  50.         {
  51.         int result;
  52.         int data;
  53.         unsigned long num;
  54.         int i,j,error,itt,count;
  55.         int c_bar,link_1,link_2;
  56.         int first_cbar,last_cbar;
  57.         int num_cbars,x;
  58.         FILE *A;
  59. start:
  60.         num=0;
  61.         error=0;
  62.  
  63.         if ((A = fopen("data.dat","r")) == NULL)
  64.             {
  65.             printf("file error or file does not exist!\n");
  66.             return;
  67.             }
  68.  
  69.         /* begin by reseting system */
  70.  
  71.         reset();
  72.         clearscreen();
  73.         printf("reset system...\n");
  74.  
  75.         /* read in the total number of crossbars */
  76.  
  77.         if (fscanf(A,"%d %d",&first_cbar, &last_cbar)== 0)
  78.             {
  79.             printf("file error or file does not exist!\n");
  80.             return;
  81.             }
  82.         for (x=first_cbar;x<=last_cbar;x++)
  83.             {
  84.             if (c_bar_set(x)) goto start;
  85.             if (soft_reset()) goto start;
  86.             }
  87.  
  88.         while ((fscanf(A,"%d %d %d",&c_bar, &link_1, &link_2)) != EOF)
  89.             {
  90.             printf("data: %d %d %d\n", c_bar, link_1, link_2);
  91.             c_bar_set(c_bar);
  92.             if (x_puter_set(link_1,link_2))
  93.                 {
  94.                 printf("Error occured during xputer...\n");
  95.                 }
  96.             }
  97.  
  98.         printf("EOF encountered execution complete.\n");
  99.         printf("finished...\n");
  100.         }
  101.  
  102. /********************* subroutine listings* ************************/
  103.  
  104. int c_bar_set(int c_bar_sub1)
  105.         {
  106.         status(11);
  107.         if (open_config_link()) return(1);
  108.         if (status(22)) return(1);
  109.         send(4);
  110.         if (status(23)) return(1);
  111.         setlink(0,c_bar_sub1);
  112.         if (close_config_link()) return(1);
  113.         return(0);
  114.         }
  115.  
  116. /*****************************************************************/
  117. int soft_reset()
  118.         {
  119.         open_data_link();
  120.         if (status(23)) return(1);
  121.         send(4);
  122.         if (status(23)) return(1);
  123.         close_data_link();
  124.         return(0);
  125.         }
  126.  
  127. /*****************************************************************/
  128. int x_puter_set(int link_1_sub,int link_2_sub)
  129.         {
  130.         if (open_data_link()) return(1);
  131.         if (setlink( link_1_sub, link_2_sub )) return(1);
  132.         if (close_data_link()) return(1);
  133.         return(0);
  134.         }
  135. /*****************************************************************/
  136. int setlink(int set_link_a,int set_link_b)
  137.         {
  138.         if (status(55)) return(1);
  139.         send(1);
  140.         if (status(3)) return(1);
  141.         send(set_link_a);
  142.         if (status(4)) return (1);
  143.         send(set_link_b);
  144.         if (status(5)) return (1);
  145.         send(3);
  146.         if (status(6)) return (1);
  147.         return(0);
  148.         }
  149. /****************************************************************/
  150. int reset()
  151.         {
  152.         clock_t start;
  153.         start = clock();
  154.         outp (0x160,0x1);
  155.  
  156.         /* wait for .20 seconds */
  157.  
  158.         while ((((float)clock()-start)/CLK_TCK) < 0.20);
  159.         outp (0x160,0);
  160.         printf ( "Time for reset %5.3f\n",((float)clock()-start)/CLK_TCK);
  161.         }
  162. /****************************************************************/
  163. int status(int point)
  164.         {
  165.         int value, loop;
  166.         loop=0;
  167. lp:
  168.         value=inp(0x173);
  169.  
  170.         /* printf("Status %d returned %d\n",point, value); */
  171.  
  172.         if (value !=1)
  173.             {
  174.             loop++;
  175.             return(1);
  176.             }
  177.         return(0);
  178.         }
  179. /****************************************************************/
  180. int send(int data)
  181.         {
  182.         outp(0x171,data);
  183.         }
  184. /****************************************************************/
  185. int open_config_link()
  186.         {
  187.         outp(0x174,0);
  188.         if (status(43)) return(1);
  189.         return(0);
  190.         }
  191. /****************************************************************/
  192. int close_config_link()
  193.         {
  194.         outp(0x174,0);
  195.         if (status(44)) return(1);
  196.         return(0);
  197.         }
  198. /****************************************************************/
  199. int open_data_link()
  200.         {
  201.         outp(0x174,1);
  202.         if (status(43)) return(1);
  203.         return(0);
  204.         }
  205. /****************************************************************/
  206. int close_data_link()
  207.         {
  208.         outp(0x174,1);
  209.         if (status(44)) return(1);
  210.         return(0);
  211.         }
  212. /****************************************************************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement