;;; -*- Mode:Lisp; Readtable:CL; Package:USER; Base:10; Patch-File:T -*-
;;; Patch file for System version 125.14
;;; Reason:
;;;  The 3com microcode driver had a bug: the packet length returned
;;;  by the 3com board had 20 bytes of overhead added in that was not
;;;  being subtracted out before setting the int-pkt fill-pointer.
;;;  This fails now that set-fill-pointer does bounds checking.
;;; Written 21-Jul-88 18:24:21 by pld at site Gigamos Cambridge
;;; while running on Claude Debussy from band 1
;;; with System 125.5, ZWEI 125.0, ZMail 73.0, Local-File 75.0, File-Server 24.0, Unix-Interface 13.0, Tape 24.0, Lambda-Diag 17.0, microcode 1761, SDU Boot Tape 3.14, SDU ROM 102, Kenv 7/15/88.



; From modified file DJ: L.NETWORK.DRIVERS; 3COM.LISP#96 at 21-Jul-88 18:24:30
#10R ETHERNET#: 
(COMPILER-LET ((*PACKAGE* (GLOBAL:PKG-FIND-PACKAGE "ETHERNET")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; DRIVERS; 3COM  "

(defun 3com-get-next-pkt-via-ucode (&aux int-pkt byte-count)
  (declare (values packet type source destination broadcast-p))
  (when (setq int-pkt (int-pkt-list-get net:int-receive-list-pointer))
    (setf (net:int-pkt-thread int-pkt) nil)
    (let* (;;The int-pkt-csr2 is a fixnum that has the buffer-header as the low 16 bits, and the first
	   ;;9 bits of the destination address above them.  The first address bit is the multicast bit.
	   (int-csr2 (net:int-pkt-csr-2 int-pkt))
	   (csr2 (swap-two-bytes int-csr2))
	   (type (swap-two-bytes (net:int-pkt-bit-count int-pkt)))
	   (multicast-p (ldb-test (byte 1 16) int-csr2)))
      (unless (zerop (logand %%3com-buffer-header-error csr2))
	(incf (3com-fcs-errors *3com-ethernet-interface*))
	(return-from 3com-get-next-pkt-via-ucode nil))
      (setf (net:int-pkt-csr-2 int-pkt) csr2)
      (setf (net:int-pkt-bit-count int-pkt) type)
      ;;Header: 2 bytes buffer header 14 bytes ethernet header.  Trailer: 4 bytes FCS
      (setq byte-count (- (ldb %%3com-buffer-header-nbytes csr2) 20.))
      (setf (fill-pointer int-pkt) (ceiling byte-count 2))
      (values int-pkt				; the packet
	      (net:int-pkt-bit-count int-pkt)	; the type code
	      0					; the sender
	      0					; the receiver
	      multicast-p			; only multicast address we're enabled on is broadcast address
	      ))))

))
