
=============================================
FileName: dbdbuf.c
=============================================

7c7
<  *	$Log:   /usr/shasta/pvcs/fddicon/util/dbdbuf.c_v  $
---
>  *	$Log:   /usr/shasta/pvcs/trc/util/dbdbuf.c_v  $
9,20d8
<  *    Rev 1.0   24 Jun 1993 16:06:16   jang
<  * Initial revision.
<  * 
<  *    Rev 1.15   24 Jun 1993 09:51:12   jang
<  * took out the comment of crit_on()/crit_off()
<  * 
<  *    Rev 1.14   07 Jun 1993 16:30:26   jang
<  * modified the code to make it faster
<  * 
<  *    Rev 1.12   28 Apr 1993 14:05:20   jang
<  * added *dbd_end mainly for debugging
<  * 
60a49,50
> #include <drv.h>
> #include <mpd.h>
63,64d52
< #include <memory.h>
< #include <msgutil.h>
66a55,56
> #ifdef notdef	/* everything, almost */
> 
73,79d62
< 
< 
< #define PERFORMANCE_TEST         0
< #if PERFORMANCE_TEST
< static  byte *perf_ptr = (byte *)UNUSED_U107_PIN4;
< #endif
< 
83,87c66,69
< MBOX FreeMbox;
< DBD *dbd_start = 0;
< int dbd_size   = 0;
< int dbd_count  = 0;
< DBD *dbd_end;   /* point to the last DBD header */
---
> MBOX f_FreeMbox;
> DBD *f_dbd_start = 0;
> int f_dbd_size   = 0;
> int f_dbd_count  = 0;
90c72
< init_dbd(buf_size, cnt, res_words)
---
> f_init_dbd(buf_size, cnt, res_words)
104a87
> #ifdef notdef		/* GJS */
106c89
< 	  dbd_start = (DBD *)lmalloc((sizeof(DBD) + (buf_size+res_cnt)) * cnt);
---
> 	  f_dbd_start = (DBD *)shmalloc((sizeof(DBD) + (buf_size+res_cnt)) * cnt);
108,109c91,93
< 	  dbd_start = (DBD *)lmalloc((sizeof(DBD) + (res_cnt+buf_size)) * (cnt+1));
< 	if (dbd_start == NULL)
---
> 	  f_dbd_start = (DBD *)shmalloc((sizeof(DBD) + (res_cnt+buf_size)) * (cnt+1));
> 	/* allocate from shared RAM */
> 	if (f_dbd_start == NULL)
112,113c96,100
< 	dbd_size = buf_size + res_cnt;
< 	dbd_count += cnt;
---
> #else
> 	f_dbd_start = (DBD *)0x50030000;		/* temporary zzz */
> #endif
> 	f_dbd_size = buf_size + res_cnt;
> 	f_dbd_count += cnt;
119,121c106,107
< 	dbdp = (DBD *)dbd_start;
< 	bufp = (byte *)dbd_start + sizeof(DBD) * cnt;
< 	dbd_end = (DBD *)bufp - sizeof(DBD);
---
> 	dbdp = (DBD *)f_dbd_start;
> 	bufp = (byte *)f_dbd_start + sizeof(DBD) * cnt;
127c113
< 	CreatMailbox(&FreeMbox);
---
> 	CreatMailbox(&f_FreeMbox);
143c129
< 		SendMessage((MSGHDR *)dbdp, &FreeMbox);
---
> 		SendMessage((MSGHDR *)dbdp, &f_FreeMbox);
150c136
< get_dbd()
---
> f_get_dbd()
153a140,142
> #ifdef _FEBRIDGE
> 	ulong saveMask;
> #endif
154a144,146
> #ifdef _FEBRIDGE
> 	MaskAllInts(saveMask);
> #else
156,157c148,149
< 
< 	if (dbdp = (DBD*)AcptMessage(&FreeMbox))	/* get a free buffer */
---
> #endif
> 	if (dbdp = (DBD*)AcptMessage(&f_FreeMbox))	/* get a free buffer */
159,160c151
< 		dbd_count--;
< #if 0
---
> 		f_dbd_count--;
162d152
< #endif
164,165d153
< 		dbdp->nb_flags = 0;
< 		dbdp->db_contrl = 1; 		/* one user */
170a159
> 		dbdp->db_contrl = 1; 		/* one user */
171a161,163
> #ifdef _FEBRIDGE
> 	RestoreMask(saveMask);
> #else
172a165
> #endif
179c172
< free_dbd (dbdp) 
---
> f_free_dbd(dbdp) 
192d184
<         asm("fmark");
200,201d191
< #if 0
< 		/* this is also done in enq_mb_msg(). */
203,205c193,194
< #endif
< 		dbd_count++;
< 		SendMessage((MSGHDR*)dbdp, &FreeMbox);		
---
> 		f_dbd_count++;
> 		SendMessage((MSGHDR*)dbdp, &f_FreeMbox);		
212a202,317
> #endif	/* everything */
> 
> 
> swap_bits(byte *bp, int length)
> {
> 	int i;
> 	byte temp;
> 
> 	for (i =0; i < length; i++)
> 		{
> 		temp = 0;
> 		if (bp[i] & 0x01)
> 			temp |= 0x80;
> 		if (bp[i] & 0x02)
> 			temp |= 0x40;
> 		if (bp[i] & 0x04)
> 			temp |= 0x20;
> 		if (bp[i] & 0x08)
> 			temp |= 0x10;
> 		if (bp[i] & 0x10)
> 			temp |= 0x08;
> 		if (bp[i] & 0x20)
> 			temp |= 0x04;
> 		if (bp[i] & 0x40)
> 			temp |= 0x02;
> 		if (bp[i] & 0x80)
> 			temp |= 0x01;
> 		bp[i] = temp;
> 		}
> 
> 	return;
> }
> #ifdef notdef
> #define FDDI_HEADER_LEN         13  /* fddi header: 1 FC + 6 DA + 6 SA */
> #define	OK				0
> #endif
> 
> /********************************************************************
>  *  Function  PutMacHeader
>  *
>  *  Description
>  *    This function puts the FDDI mac header and LLC, SNAP header
>  *    in front of the IP packet.
>  *
>  *  Parameters:
>  *    DBD *dbd - point to the packet to send
>  *    NID *np - dest addr
>  *    int packet_type - IP or ARP
>  *    byte *routing_info - not used
>  *    int routing_length - not used.
>  *
>  *  Return: OK
>  *******************************************************************/
> PutMacHeader (dbd,np,packet_type,routing_info,routing_length)
> DBD *dbd;
> NID *np;
> int packet_type; 
> byte *routing_info; 
> int routing_length;
> {
>   byte *bp;
>   byte *header;
>   int mac_num=0;
>   byte da[6];
> 
>   /* point header to the FC field */
>   header = dbd->nb_prot - FDDI_HEADER_LEN - sizeof(struct snap);
>   dbd->db_indent = header - dbd->db_buffer;
>   if (dbd->db_indent < 0) {
>     if (get_debug() )
>       printf("dbd->nb_prot needs to be adjusted, error\n");
>     return(1);
>   }
> 
>   dbd->db_actcnt += FDDI_HEADER_LEN + sizeof(struct snap);
> #if 0
>   if ((dbd->db_xmtportlist <= 2) &&  (dbd->db_xmtportlist > 0))
>     mac_num = dbd->db_xmtportlist - 1;
> #else
>   mac_num = PortList2Num(dbd->db_xmtportlist);
>   if (mac_num > 1) 
>     mac_num = 0;
> #endif
> 
>   /* now start to build the header */
>   *header++ = 0x51;   /* FC: long addr */
>   /* swap to FDDI order, ACR doesn't work. Since check out broadcast addr
>      takes almost same amount of time, we simply go ahead to swap it */
> #if 0
>   ncopy(da,np);   /* np may directly point to ARP cache table */
> #else
>   memcpy(da,np,6);
> #endif
>   swap_bits(da,6);    
>   ncopy(header,da);   /* DA */
>   header += 6;
> #if 0
>   ncopy(header,(byte *)MyNid(mac_num + 1));  /* SA */
> #else
>   ncopy(header,(byte *)MyNid(mac_num));  /* SA */
> #endif
>   header += 6;
> 
>   /* set LLC fields: snap auth=DOD type */
>   *header++ = IEEESNP0;
>   *header++ = IEEESNP1;
>   *header++ = IEEESNP2;
>   *header++ = IEEEDOD0;
>   *header++ = IEEEDOD1;
>   *header++ = IEEEDOD2;
>   bp = (byte *) &packet_type;
>   *header++ = bp[0];  
>   *header++ = bp[1];  
> 
>   return OK;
> }

=============================================
FileName: fddiled.c
=============================================

0a1
> 
7d7
< #include <uart.h>
8a9,10
> #ifdef notdef		/* GJS */
> #include <uart.h>
9a12
> #endif				/* GJS */
45a49
> #ifdef notdef		/* GJS */
48a53
> #endif				/* GJS */
52,56c57,58
< uChar PortMap[MAX_PORT_COUNT] = { 1, 5, 4, 3, 2, 0, 6, 7 };
< uChar Port2LedMap[MAX_PORT_COUNT] = { 1, 6, 0, 2, 3, 4, 5, 0 };
< uChar UI2PortMap[MAX_PORT_COUNT] = { 1, 4, 5, 6, 7, 2, 3, 8 };
< byte port_tx_flkcnt[MAX_PORT_COUNT];  /* used to flicking led during tx pkt */
< byte interface_flkcnt[2];
---
> uChar PortMap[MAX_PORT_COUNT] = { 1, 5, 4, 3, 2, 0 };
> uChar Port2LedMap[MAX_PORT_COUNT] = { 1, 6, 2, 3, 4, 5 };
61,64d62
< 
< /* export */byte frontPanelLed[MAX_PORT_COUNT-2];
< 
< 
69,71d66
< extern void DoIsolateBPB();
< extern void DoIsolateBPA();
< extern Flag RmonExist;
73c68,69
< void InitLed()
---
> 
> InitLed()
74a71
> #ifdef notdef		/* GJS */
84a82
> #endif				/* GJS */
86,93d83
<    for (i=0; i < MAX_PORT_COUNT; i++)
<      port_tx_flkcnt[i] = 0;
<    for (i=0; i < 2; i++)
<      interface_flkcnt[i] = 0;
< 
<    for (i=0; i < (MAX_PORT_COUNT-2); i++)
<      frontPanelLed[i] = 0;
< 
105a96
> #ifdef notdef		/* GJS */
110a102
> #endif				/* GJS */
113,132d104
< void TurnOnAllLed()
< {
<    int i;
< 
<    for (i=0; i < LED_REG_NO; i++)
<    {
<       *LedPort[i] = LedStatus[i] = 0;
<    }
< }
< 
< void TurnOffAllLed()
< {
<    int i;
< 
<    for (i=0; i < LED_REG_NO; i++)
<    {
<       *LedPort[i] = LedStatus[i] = 0xff;
<    }
< }
< 
134a107
> #ifdef notdef		/* GJS */
139a113
> #endif				/* GJS */
148c122
<    ioport = (volatile uChar*) TMS_RESET;
---
>    ioport = (volatile uChar*) FDDI_LANRST_REG;
175c149
< void RefreshLED()
---
> RefreshLED()
176a151
> #ifdef notdef		/* GJS */
182a158
> #endif				/* GJS */
186c162
< void SetPortLed(port, led, state)
---
> SetPortLed(port, led, state)
190a167
> #ifdef notdef		/* GJS */
197c174
<       return;
---
>       port = 0;
199c176
<    else if (port >= LED_PORT_NUM)
---
>    else if (port >= MAX_PORT_COUNT)
201c178
<       port = LED_PORT_NUM - 1;
---
>       port = MAX_PORT_COUNT - 1;
203a181
> 
212d189
< 	 frontPanelLed[port] &= ~RMON_LED_AR;
217d193
< 	 frontPanelLed[port] |= RMON_LED_AR;
225,226c201
<       
<       pos = port * 2 + LED_PORT_NUM + 4 + ((port)? 1 : 0);
---
>       pos = port * 2 + MAX_PORT_COUNT + 4 + ((port)? 1 : 0);
229c204
<       if ((port) && (port < (LED_PORT_NUM-1)))
---
>       if ((port) && (port < (MAX_PORT_COUNT-1)))
240c215,216
<      
---
> 
>       MDisableCSPInterrupts(&pState);
243,250d218
< 	 if ((led & LED_PEER_TREE) && ((port == 0) || (port == (MAX_PORT_COUNT-3 ))))
<   	    frontPanelLed[port] &= ~RMON_LED_PT;
< 	 if (led & LED_PRIMARY_SECONDARY)
<   	    frontPanelLed[port] &= ~RMON_LED_PS;
< 	 if (led & LED_LINK_ERROR)
<   	    frontPanelLed[port] &= ~RMON_LED_LE;
< 
< 	 MDisableCSPInterrupts(&pState);
257d224
< 	 MRestoreCSPInterrupts(&pState);
261,268d227
< 	 if ((led & LED_PEER_TREE) && ((port == 0) || (port == (MAX_PORT_COUNT-3))))
<   	    frontPanelLed[port] |= RMON_LED_PT;
< 	 if (led & LED_PRIMARY_SECONDARY)
<   	    frontPanelLed[port] |= RMON_LED_PS;
< 	 if (led & LED_LINK_ERROR)
<   	    frontPanelLed[port] |= RMON_LED_LE;
< 
< 	 MDisableCSPInterrupts(&pState);
275d233
< 	 MRestoreCSPInterrupts(&pState);
276a235
>       MRestoreCSPInterrupts(&pState);
283a243
> #endif				/* GJS */
287c247
< void set_port_led(word port_number, word port_color)
---
> set_port_led(word port_number, word port_color)
288a249
> #ifdef notdef		/* GJS */
314a276
> #endif				/* GJS */
317c279
< #if 0
---
> 
321d282
< #endif
324c285,287
<    volatile uChar *uartCmd;
---
> #ifdef notdef		/* GJS */
>    volatile uChar *ioport, status, *uartCmd;
>    uChar num, i;
326d288
< 
386a349
> #endif				/* GJS */
394d356
<       return;
419a382
> #ifdef notdef		/* GJS */
421c384
<    int delay;
---
>    int i, delay;
494a458
> #endif		/* GJS */
498c462
< void BlinkFDDILed()
---
> BlinkFDDILed()
499a464
> #ifdef notdef		/* GJS */
518a484
> #endif				/* GJS */

=============================================
FileName: fdditest.c
=============================================

8,11d7
< #define ONE_SECOND 100
< #define TWO_SECONDS (2 * ONE_SECOND)
< 
< extern ALLOC	alloc;
18,20d13
< InitializeSMT()
< {
<    uInt16 i;
22,52d14
<    init_if();
< 
<    if (!SMTInitialized)
<    {
<       alloc.dram_end = alloc.dram_alc_hi = (char *)(DRAM + DEFAULT_DRAM_SIZE);
< 
< #if 0 /* CMT only */
<       if ((MIBMain() || CSPMain() || MAPMain()))
<       {
< 	 printf("\n*** MAP initialization fails.\n");
< 	 return;
<       }
< 
<       InitCSPMIBData();
< 
<       if (DRV_Init() != OK)
<       {
< 	 printf("\n*** Driver Initialization fails.\n");
< 	 return;
<       }
< #else /* SMT */
<       if (!chnl_init(0))
<       {
< 	 return;
<       }
< #endif
< 
<       SMTInitialized = TRUE;
<    }
< }
< 
55,67c17
<    InitializeSMT();
<    Ei();
<    printf("\n\n\n\t\tInitializing SMT CMT successfully.\n\n");
<    MainMenu();
< }
< 
< RunCMT()
< {
<    set_leds(LED_BI, (LED_RDY | LED_ACT), (LED_RDY_GRN | LED_ACT_GRN));
<    InitializeSMT();
<    Ei();
<    DoConnect();
<    for (;;)
---
>    if (!SMTInitialized)
69,70c19,30
<       MainMenu();
<    }
---
>       if (init_if())
> 	  {
>       	SMTInitialized = TRUE;
>    		Ei();
>    		printf("\tInitialized SMT CMT successfully.\n");
>    	  }
> 	  else
>    		printf("\t*** SMT init failure ***\n");
> 	}
> 	FddiLedsOn();		/* turn on appropriate fddi port rx/tx LEDs */
>     if (SMTInitialized)
>    		MainMenu();
71a32
> 

=============================================
FileName: msgutil.c
=============================================


=============================================
FileName: utilasm.s
=============================================

