Subject: Re: How to apply patches in RCSDIFF format?
To: Scott Telford <st@epcc.ed.ac.uk>
From: Alicia da Conceicao <alicia@cyberstation.ca>
List: port-i386
Date: 10/13/1999 13:37:21
>> Unfortunately the patch does not appear to be in the usual diff
>> format.  (It looks like it was generated from rcsdiff.)  So applying
>> the patch in the "/usr/src/sys/" directory using "patch < PATCHFILE"
>> does not work.  Below is a sample of the patch format.
> Patches generated by rcsdiff should work fine with patch. That one (or
> what I can see of it) looks reasonable. In what way does patch fail?

Well, when I go to the "/usr/src/sys/dev/ic/" containing the "elink3.c"
file, and run "patch < PATHFILE", I get:

    patching file `elink3.c'
    Hunk #1 FAILED at 232.
    1 out of 1 hunk FAILED -- saving rejects to elink3.c.rej
    missing header for context diff at line 20 of patch
    can't find file to patch at input line 20
    Perhaps you should have used the -p or --strip option?
    The text leading up to this was:
    --------------------------
    |                                        u_int cmd, u_int arg));
    --------------------------
    File to patch: 

Which unfortunately fails to properly modify the "elink3.c" file.
I have appended the entire patch for only the "elink3.c" file below.
(Other files are also specified within the patch, after the elink3.c
file, but I have cut these cut for simplicity.  The entire patch is
available at:

    http://www.NetBSD.org/cgi-bin/query-pr-single.pl?number=8331

If anyone does manage to figure out how to properly apply this patch,
please let me know.

Sincerely, Alicia.

###### CUT HERE ####################################################
Index: dev/ic/elink3.c
===================================================================
RCS file: /usr/src/CVSROOT/netbsd.sys/dev/ic/elink3.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 elink3.c
*** elink3.c    1999/08/27 10:14:17     1.1.1.1
--- elink3.c    1999/08/31 09:06:33
***************
*** 232,237 ****
--- 232,239 ----
  void  ep_mii_sync __P((struct ep_softc *));
  void  ep_mii_sendbits __P((struct ep_softc *, u_int32_t, int));

  
+ void  ep_roadrunner_mii_enable __P((struct ep_softc *));
+ 
  static int epbusyeeprom __P((struct ep_softc *));
  static inline void ep_reset_cmd __P((struct ep_softc *sc, 
                                        u_int cmd, u_int arg));
***************
*** 360,366 ****
                        if (epbusyeeprom(sc))
                                return;         /* XXX why is eeprom busy? */
                        bus_space_write_2(iot, ioh, ELINK_W0_EEPROM_COMMAND,
!                                         READ_EEPROM | i);
                        if (epbusyeeprom(sc))
                                return;         /* XXX why is eeprom busy? */
                        x = bus_space_read_2(iot, ioh, ELINK_W0_EEPROM_DATA);
--- 362,369 ----
                        if (epbusyeeprom(sc))
                                return;         /* XXX why is eeprom busy? */
                        bus_space_write_2(iot, ioh, ELINK_W0_EEPROM_COMMAND,
!                               (sc->ep_chipset == ELINK_CHIPSET_ROADRUNNER ?
!                               (READ_EEPROM << 2) : READ_EEPROM) | i);
                        if (epbusyeeprom(sc))
                                return;         /* XXX why is eeprom busy? */
                        x = bus_space_read_2(iot, ioh, ELINK_W0_EEPROM_DATA);
***************
*** 459,466 ****
         * Now, determine which media we have.
         */
        switch (sc->ep_chipset) {
-       case ELINK_CHIPSET_BOOMERANG:
        case ELINK_CHIPSET_ROADRUNNER:
                /*
                 * If the device has MII, probe it.  We won't be using
                 * any `native' media in this case, only PHYs.  If
--- 462,475 ----
         * Now, determine which media we have.
         */
        switch (sc->ep_chipset) {
        case ELINK_CHIPSET_ROADRUNNER:
+               if (sc->ep_flags & ELINK_FLAGS_MII) {
+                       ep_roadrunner_mii_enable(sc);
+                       GO_WINDOW(0);
+               }
+               /* FALLTHROUGH */
+ 
+       case ELINK_CHIPSET_BOOMERANG:
                /*
                 * If the device has MII, probe it.  We won't be using
                 * any `native' media in this case, only PHYs.  If
***************
*** 798,803 ****
--- 807,818 ----
                bus_space_write_2(iot, ioh, ELINK_W1_RUNNER_RDCTL, 0);
        }

  
+       if ((sc->ep_chipset == ELINK_CHIPSET_ROADRUNNER) &&
+           (sc->ep_flags & ELINK_FLAGS_MII)) {
+               ep_roadrunner_mii_enable(sc);
+               GO_WINDOW(1);
+       }
+ 
        /* Enable interrupts. */
        bus_space_write_2(iot, ioh, ELINK_COMMAND, SET_RD_0_MASK | S_CARD_FAILURE |
                                S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
***************
*** 1312,1318 ****
                        if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG)
                                printf("%s: jabber (%x)\n",
                                       sc->sc_dev.dv_xname, i);
!                       epreset(sc);
                } else if (i & TXS_UNDERRUN) {
                        ++sc->sc_ethercom.ec_if.if_oerrors;
                        if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG)
--- 1327,1336 ----
                        if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG)
                                printf("%s: jabber (%x)\n",
                                       sc->sc_dev.dv_xname, i);
!                       if (sc->ep_chipset == ELINK_CHIPSET_ROADRUNNER)
!                               ep_reset_cmd(sc, ELINK_COMMAND, TX_RESET);
!                       else
!                               epreset(sc);
                } else if (i & TXS_UNDERRUN) {
                        ++sc->sc_ethercom.ec_if.if_oerrors;
                        if (sc->sc_ethercom.ec_if.if_flags & IFF_DEBUG)
***************
*** 1323,1329 ****
                                    sc->tx_start_thresh = min(ETHER_MAX_LEN,
                                            sc->tx_start_thresh + 20);
                        sc->tx_succ_ok = 0;
!                       epreset(sc);
                } else if (i & TXS_MAX_COLLISION) {
                        ++sc->sc_ethercom.ec_if.if_collisions;
                        bus_space_write_2(iot, ioh, ELINK_COMMAND, TX_ENABLE);
--- 1341,1350 ----
                                    sc->tx_start_thresh = min(ETHER_MAX_LEN,
                                            sc->tx_start_thresh + 20);
                        sc->tx_succ_ok = 0;
!                       if (sc->ep_chipset == ELINK_CHIPSET_ROADRUNNER)
!                               ep_reset_cmd(sc, ELINK_COMMAND, TX_RESET);
!                       else
!                               epreset(sc);
                } else if (i & TXS_MAX_COLLISION) {
                        ++sc->sc_ethercom.ec_if.if_collisions;
                        bus_space_write_2(iot, ioh, ELINK_COMMAND, TX_ENABLE);
***************
*** 1404,1410 ****
                if (status & S_CARD_FAILURE) {
                        printf("%s: adapter failure (%x)\n",
                            sc->sc_dev.dv_xname, status);
!                       epreset(sc);
                        return (1);
                }
                if (status & S_TX_COMPLETE) {
--- 1425,1434 ----
                if (status & S_CARD_FAILURE) {
                        printf("%s: adapter failure (%x)\n",
                            sc->sc_dev.dv_xname, status);
!                       if (sc->ep_chipset == ELINK_CHIPSET_ROADRUNNER)
!                               epinit(sc);
!                       else
!                               epreset(sc);
                        return (1);
                }
                if (status & S_TX_COMPLETE) {
***************
*** 2221,2224 ****
--- 2245,2266 ----
                mctl &= ~MAC_CONTROL_FDX;
        bus_space_write_2(iot, ioh, ELINK_W3_MAC_CONTROL, mctl);
        GO_WINDOW(1);   /* back to operating window */
+ }
+ 
+ void
+ ep_roadrunner_mii_enable(sc)
+       struct ep_softc *sc;
+ {
+       bus_space_tag_t iot = sc->sc_iot;
+       bus_space_handle_t ioh = sc->sc_ioh;
+ 
+       /* Roadrunner only: Turn on the MII transceiver */
+       GO_WINDOW(3);
+       bus_space_write_2(iot, ioh, ELINK_W3_RESET_OPTIONS, 0x8040);
+       delay(1000);
+       bus_space_write_2(iot, ioh, ELINK_W3_RESET_OPTIONS, 0xc040);
+       ep_reset_cmd(sc, ELINK_COMMAND, TX_RESET);
+       ep_reset_cmd(sc, ELINK_COMMAND, RX_RESET);
+       delay(1000);
+       bus_space_write_2(iot, ioh, ELINK_W3_RESET_OPTIONS, 0x8040);
  }
###### END CUT #####################################################