 +void mpc831x_adj_addend(Integer32 adj);
 +
 +#endif //MPC831X_H
-diff --git a/src/probe.c b/src/probe.c
-index 5454e30..8e7a1b9 100644
---- a/src/probe.c
-+++ b/src/probe.c
-@@ -64,7 +64,7 @@ void probe(RunTimeOpts *rtOpts, PtpClock *ptpClock)
-     if(rtOpts->probe_management_key > 0)
-       break;
-   }
--  
-+ 
-   getTime(&finish);
-   finish.seconds += PTP_SYNC_INTERVAL_TIMEOUT(ptpClock->sync_interval);
-   for(;;)
-@@ -73,7 +73,7 @@ void probe(RunTimeOpts *rtOpts, PtpClock *ptpClock)
-     interval.nanoseconds = 0;
-     netSelect(&interval, &ptpClock->netPath);
-     
--    netRecvEvent(0, ptpClock->msgIbuf, 0, &ptpClock->netPath);
-+    netRecvEvent(0, ptpClock->msgIbuf, 0, &ptpClock->netPath, ptpClock->port_state);
-     
-     if(netRecvGeneral(0, ptpClock->msgIbuf, &ptpClock->netPath))
-     {
-@@ -90,6 +90,7 @@ void probe(RunTimeOpts *rtOpts, PtpClock *ptpClock)
-       fflush(stdout);
-     }
-     
-+    printf( "getTime probe (now)\n" ); 
-     getTime(&now);
-     if( now.seconds > finish.seconds || (now.seconds == finish.seconds
-       && now.nanoseconds > finish.nanoseconds) )
-diff --git a/src/protocol.c b/src/protocol.c
-index 4ae14d4..20d9562 100644
---- a/src/protocol.c
-+++ b/src/protocol.c
-@@ -1,6 +1,9 @@
- /* protocol.c */
- 
- #include "ptpd.h"
-+#ifdef CONFIG_MPC831X
-+#include "mpc831x.h"
-+#endif
- 
- Boolean doInit(RunTimeOpts*,PtpClock*);
- void doState(RunTimeOpts*,PtpClock*);
-@@ -281,7 +284,7 @@ void handle(RunTimeOpts *rtOpts, PtpClock *ptpClock)
-   if(!ptpClock->message_activity)
-     netSelect(&wait, &ptpClock->netPath);
-   
--  if(netRecvEvent(0, ptpClock->msgIbuf, &time, &ptpClock->netPath))
-+  if(netRecvEvent(0, ptpClock->msgIbuf, &time, &ptpClock->netPath, ptpClock->port_state))
-   {
-     subTime(&time, &time, &rtOpts->inboundLatency);
-   }
-@@ -496,6 +499,10 @@ void handleDelayReq(MsgHeader *header, TimeInternal *time, Boolean isFromSelf, R
-       || header->sourceCommunicationTechnology == PTP_DEFAULT
-       || ptpClock->clock_communication_technology == PTP_DEFAULT )
-     {
-+#ifdef CONFIG_MPC831X
-+      /* Get the RX time from our HW counter */
-+      mpc831x_get_rx_time(time);
-+#endif
-       issueDelayResp(time, &ptpClock->msgTmpHeader, rtOpts, ptpClock);
-     }
-     
-@@ -505,6 +512,11 @@ void handleDelayReq(MsgHeader *header, TimeInternal *time, Boolean isFromSelf, R
-     if(isFromSelf)
-     {
-       DBG("handleDelayReq: self\n");
-+
-+#ifdef CONFIG_MPC831X
-+      /* Get the TX time from our HW counter */
-+      mpc831x_get_tx_time(time);
-+#endif
-       
-       ptpClock->delay_req_send_time.seconds = time->seconds;
-       ptpClock->delay_req_send_time.nanoseconds = time->nanoseconds;
-@@ -540,7 +552,7 @@ void handleDelayResp(MsgHeader *header, Octet *msgIbuf, Boolean isFromSelf, RunT
-       DBG("handleDelayResp: ignore from self\n");
-       return;
-     }
--    
-+   
-     resp = &ptpClock->msgTmp.resp;
-     msgUnpackDelayResp(ptpClock->msgIbuf, resp);
-     
-@@ -554,11 +566,12 @@ void handleDelayResp(MsgHeader *header, Octet *msgIbuf, Boolean isFromSelf, RunT
-       && !memcmp(header->sourceUuid, ptpClock->parent_uuid, PTP_UUID_LENGTH) )
-     {
-       ptpClock->sentDelayReq = FALSE;
--      
-+    
-       toInternalTime(&ptpClock->delay_req_receive_time, &resp->delayReceiptTimestamp, &ptpClock->halfEpoch);
-       
-       if(ptpClock->delay_req_send_time.seconds)
-       {
-+        DBG( "handleDelayResp: from master\n" );
-         updateDelay(&ptpClock->delay_req_send_time, &ptpClock->delay_req_receive_time,
-           &ptpClock->owd_filt, rtOpts, ptpClock);
-         
-@@ -626,7 +639,8 @@ void issueSync(RunTimeOpts *rtOpts, PtpClock *ptpClock)
-   
-   ++ptpClock->last_sync_event_sequence_number;
-   ptpClock->grandmaster_sequence_number = ptpClock->last_sync_event_sequence_number;
--  
-+ 
-+  printf( "getTime issueSync\n" ); 
-   getTime(&internalTime);
-   fromInternalTime(&internalTime, &originTimestamp, ptpClock->halfEpoch);
-   msgPackSync(ptpClock->msgObuf, FALSE, &originTimestamp, ptpClock);
-@@ -660,14 +674,16 @@ void issueDelayReq(RunTimeOpts *rtOpts, PtpClock *ptpClock)
-   ptpClock->sentDelayReq = TRUE;
-   ptpClock->sentDelayReqSequenceId = ++ptpClock->last_sync_event_sequence_number;
-   
-+  printf( "getTime issueDelayReq\n" ); 
-   getTime(&internalTime);
-   fromInternalTime(&internalTime, &originTimestamp, ptpClock->halfEpoch);
-   msgPackDelayReq(ptpClock->msgObuf, FALSE, &originTimestamp, ptpClock);
-   
-   if(!netSendEvent(0, ptpClock->msgObuf, DELAY_REQ_PACKET_LENGTH, &ptpClock->netPath))
-     toState(PTP_FAULTY, rtOpts, ptpClock);
--  else
-+  else{
-     DBGV("sent delay request message\n");
-+  }
- }
- 
- void issueDelayResp(TimeInternal *time, MsgHeader *header, RunTimeOpts *rtOpts, PtpClock *ptpClock)
-
- 	  	 
++/* eof mpc831x.h */
+Index: src/Makefile
+===================================================================
+--- src/Makefile	(revision 35)
++++ src/Makefile	(working copy)
+@@ -4,12 +4,40 @@
+ CFLAGS = -Wall
+ #CPPFLAGS = -DPTPD_DBG -DPTPD_NO_DAEMON
+ 
++# In case this is an MPC831X system, define CONFIG_MPC831X
++CONFIG_MPC831X=1
++
+ PROG = ptpd
+ OBJ  = ptpd.o arith.o bmc.o probe.o protocol.o \
+ 	dep/msg.o dep/net.o dep/servo.o dep/startup.o dep/sys.o dep/timer.o
+ HDR  = ptpd.h constants.h datatypes.h \
+ 	dep/ptpd_dep.h dep/constants_dep.h dep/datatypes_dep.h
+ 
++ifeq ($(CONFIG_MPC831X), 1)
++#
++# for full  debug messages define -DPTPD_DBGV below
++# for basic debug messages define -DPTPD_DBG  below
++# for no    debug messages remove the debug define
++#
++# -DCONFIG_MPC831X is defined to use MPC831X timestamping, 
++# otherwise system timer is used
++#
++CFLAGS = -Wall -DPTPD_DBGV -DCONFIG_MPC831X
++LDFLAGS = -static
++OBJ += mpc831x.o
++HDR += mpc831x.h
++#
++# Makefile from original patch for ptpd version 1b5 used CC 
++# as a specific gcc filename spec of powerpc-e300c3-linux-gcc.  
++# This does not work# with the LTIB environment, 
++# where you just use gcc (LTIB maps gcc to the right type and
++# version of the compiler for the target.
++#
++# original patch from Freescale was:      CC=powerpc-e300c3-linux-gcc
++# changed to work in an LTIB environment: CC=gcc
++#
++CC=gcc
++endif
+ 
+ .c.o:
+ 	$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<

+	if(!ioctl(mpc831x_netPath->eventSock, PTP_SET_CNT, &if_data))
+	{
+                //DBG( "mpc831x_set_curr_time board_time = %llu Hex (0x%llx)\n", board_time, board_time );
+		DBG( "mpc831x_set_curr_time seconds (%d), nanoseconds (%d)\n", \
+			time->seconds, time->nanoseconds );
+	} 
+	else

+		
+		time->seconds = BOARD_TIME_TO_SEC(board_time);
+		time->nanoseconds = BOARD_TIME_TO_NSEC(board_time, time->seconds);
+		DBG( "mpc831x_get_tx_time   %9.9d.%9.9d\n", \
+			time->seconds, time->nanoseconds );
+	} 
+	else
