Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****************************************************************/
- /* test program */
- /****************************************************************/
- /* this program has been created to program the Cbar board and */
- /* the 8 processor boards. */
- /****************************************************************/
- #include<stdio.h>
- #include<conio.h>
- #include<ansi.h>
- #include<time.h>
- /****************************************************************/
- /* reset(); */
- /* this routine resets the entire Cbar and Xputer system. */
- /* writes 1 out to port 160h and waits for a pause before */
- /* resetting. */
- /*--------------------------------------------------------------*/
- /* status( itt ); */
- /* returns a 1 if the co11 is not ready. */
- /* causes the entire system to reset but only the Cbar c004 is */
- /* reset. That is, it is the only cross bar that must be re- */
- /* set up. */
- /*--------------------------------------------------------------*/
- /* send(); */
- /* sends data to the crossbar */
- /* only one byte */
- /*--------------------------------------------------------------*/
- /* getbyte(); */
- /* get one byte from port 170h. */
- /*--------------------------------------------------------------*/
- /* setlink(a,b) */
- /* sequence of data sent to the crossbar to set up specific */
- /* link. */
- /*--------------------------------------------------------------*/
- /* verify(a,b); */
- /* sequence of commands to verify that crossbar made connections*/
- /*--------------------------------------------------------------*/
- /* open_config_link(); */
- /* command sent to port 174h to enable the configuration link */
- /*--------------------------------------------------------------*/
- /* close_config_link(); */
- /* command sent to prot 174h to disable the configuration link */
- /****************************************************************/
- int bad_error;
- bad_error=0;
- void main()
- {
- int result;
- int data;
- unsigned long num;
- int i,j,error,itt,count;
- int c_bar,link_1,link_2;
- int first_cbar,last_cbar;
- int num_cbars,x;
- FILE *A;
- start:
- num=0;
- error=0;
- if ((A = fopen("data.dat","r")) == NULL)
- {
- printf("file error or file does not exist!\n");
- return;
- }
- /* begin by reseting system */
- reset();
- clearscreen();
- printf("reset system...\n");
- /* read in the total number of crossbars */
- if (fscanf(A,"%d %d",&first_cbar, &last_cbar)== 0)
- {
- printf("file error or file does not exist!\n");
- return;
- }
- for (x=first_cbar;x<=last_cbar;x++)
- {
- if (c_bar_set(x)) goto start;
- if (soft_reset()) goto start;
- }
- while ((fscanf(A,"%d %d %d",&c_bar, &link_1, &link_2)) != EOF)
- {
- printf("data: %d %d %d\n", c_bar, link_1, link_2);
- c_bar_set(c_bar);
- if (x_puter_set(link_1,link_2))
- {
- printf("Error occured during xputer...\n");
- }
- }
- printf("EOF encountered execution complete.\n");
- printf("finished...\n");
- }
- /********************* subroutine listings* ************************/
- int c_bar_set(int c_bar_sub1)
- {
- status(11);
- if (open_config_link()) return(1);
- if (status(22)) return(1);
- send(4);
- if (status(23)) return(1);
- setlink(0,c_bar_sub1);
- if (close_config_link()) return(1);
- return(0);
- }
- /*****************************************************************/
- int soft_reset()
- {
- open_data_link();
- if (status(23)) return(1);
- send(4);
- if (status(23)) return(1);
- close_data_link();
- return(0);
- }
- /*****************************************************************/
- int x_puter_set(int link_1_sub,int link_2_sub)
- {
- if (open_data_link()) return(1);
- if (setlink( link_1_sub, link_2_sub )) return(1);
- if (close_data_link()) return(1);
- return(0);
- }
- /*****************************************************************/
- int setlink(int set_link_a,int set_link_b)
- {
- if (status(55)) return(1);
- send(1);
- if (status(3)) return(1);
- send(set_link_a);
- if (status(4)) return (1);
- send(set_link_b);
- if (status(5)) return (1);
- send(3);
- if (status(6)) return (1);
- return(0);
- }
- /****************************************************************/
- int reset()
- {
- clock_t start;
- start = clock();
- outp (0x160,0x1);
- /* wait for .20 seconds */
- while ((((float)clock()-start)/CLK_TCK) < 0.20);
- outp (0x160,0);
- printf ( "Time for reset %5.3f\n",((float)clock()-start)/CLK_TCK);
- }
- /****************************************************************/
- int status(int point)
- {
- int value, loop;
- loop=0;
- lp:
- value=inp(0x173);
- /* printf("Status %d returned %d\n",point, value); */
- if (value !=1)
- {
- loop++;
- return(1);
- }
- return(0);
- }
- /****************************************************************/
- int send(int data)
- {
- outp(0x171,data);
- }
- /****************************************************************/
- int open_config_link()
- {
- outp(0x174,0);
- if (status(43)) return(1);
- return(0);
- }
- /****************************************************************/
- int close_config_link()
- {
- outp(0x174,0);
- if (status(44)) return(1);
- return(0);
- }
- /****************************************************************/
- int open_data_link()
- {
- outp(0x174,1);
- if (status(43)) return(1);
- return(0);
- }
- /****************************************************************/
- int close_data_link()
- {
- outp(0x174,1);
- if (status(44)) return(1);
- return(0);
- }
- /****************************************************************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement