Ticket #1590: bge_2.diff

File bge_2.diff, 5.9 KB (added by PieterPanman, 16 years ago)

diff that get bge partially working (until you plug in the cable)

  • build/jam/HaikuImage

     
    134134    $(X86_ONLY)rtl8139 rtl8169 sis900 $(X86_ONLY)via_rhine wb840
    135135    $(X86_ONLY)ipro100 $(X86_ONLY)nforce #vlance
    136136    $(X86_ONLY)marvell_yukon $(X86_ONLY)syskonnect usb_ecm
    137     $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x
     137    $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x broadcom_bcm570x
    138138;
    139139#BEOS_ADD_ONS_DRIVERS_ACPI = $(X86_ONLY)acpi_button ;
    140140BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)ps2 $(X86_ONLY)isa ide scsi
  • src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/if_bgereg.h

     
    25062506#ifdef DEVICE_POLLING
    25072507    int         rxcycles;
    25082508#endif /* DEVICE_POLLING */
     2509#ifdef __HAIKU__
     2510    u_int32_t       bge_intr_status;
     2511#endif
    25092512};
    25102513
    25112514#define BGE_LOCK_INIT(_sc, _name) \
  • src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/if_bge.c

     
    31683168     * the status check).  So toggling would probably be a pessimization
    31693169     * even with MSI.  It would only be needed for using a task queue.
    31703170     */
     3171#ifndef __HAIKU__
     3172    // already done in __haiku_disable_interrupts
    31713173    CSR_WRITE_4(sc, BGE_MBX_IRQ0_LO, 0);
    3172 
     3174#endif
    31733175    /*
    31743176     * Do the mandatory PCI flush as well as get the link status.
    31753177     */
     3178#ifndef __HAIKU__
    31763179    statusword = CSR_READ_4(sc, BGE_MAC_STS) & BGE_MACSTAT_LINK_CHANGED;
     3180#else
     3181    /* Get the statusword as saved in __haiku_disable_interrupts
     3182     * and clear the saved value */
     3183    statusword = atomic_and((int32 *)&sc->bge_intr_status, 0);
     3184#endif
    31773185
    31783186    /* Make sure the descriptor ring indexes are coherent. */
    31793187    bus_dmamap_sync(sc->bge_cdata.bge_status_tag,
     
    31813189    bus_dmamap_sync(sc->bge_cdata.bge_status_tag,
    31823190        sc->bge_cdata.bge_status_map, BUS_DMASYNC_PREREAD);
    31833191
     3192    /* TODO: bge_link_upd is probably not correct with interrupt changes
     3193     * May need to also use the saved statusword... */
    31843194    if ((sc->bge_asicrev == BGE_ASICREV_BCM5700 &&
    31853195        sc->bge_chipid != BGE_CHIPID_BCM5700_B2) ||
    31863196        statusword || sc->bge_link_evt)
  • src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/glue.c

     
    55
    66
    77#include <sys/bus.h>
     8#include "if_bgereg.h"
    89
    910
    1011HAIKU_FBSD_DRIVER_GLUE(broadcom_bcm570x, bge, pci);
     
    2526    return __haiku_probe_miibus(dev, drivers);
    2627}
    2728
     29int
     30__haiku_disable_interrupts(device_t dev)
     31{
     32    struct bge_softc *sc = device_get_softc(dev);
     33
     34    // Obtain the status and return 0 if the bge did not set the intr
     35    u_int32_t status = CSR_READ_4(sc, BGE_MAC_STS);
     36    if ((status & BGE_MACSTAT_MI_INTERRUPT) == 0) {
     37        return 0;
     38    }
     39
     40    // Clear the interrupt, the bge intr handler will take care of it
     41    BGE_SETBIT(sc, BGE_PCI_MISC_CTL, BGE_PCIMISCCTL_MASK_PCI_INTR);
     42    CSR_WRITE_4(sc, BGE_MBX_IRQ0_LO, 1);
     43
     44    // save the status for the interrupt handler
     45    atomic_or((int32 *)&sc->bge_intr_status, status);
     46    return 1;
     47}
     48
     49
     50void
     51__haiku_reenable_interrupts(device_t dev)
     52{
     53    // Honestly, I don't know if this is correct.
     54    // I just copied it from if_bge searching for enable interrupts
     55    struct bge_softc *sc = device_get_softc(dev);
     56    BGE_SETBIT(sc, BGE_PCI_MISC_CTL, BGE_PCIMISCCTL_CLEAR_INTA);
     57    BGE_CLRBIT(sc, BGE_PCI_MISC_CTL, BGE_PCIMISCCTL_MASK_PCI_INTR);
     58    CSR_WRITE_4(sc, BGE_MBX_IRQ0_LO, 0);
     59}
  • src/libs/compat/freebsd_network/compat/sys/mbuf.h

     
    8282
    8383#define M_BCAST         0x00000200
    8484#define M_MCAST         0x00000400
     85#define M_FRAG          0x00000800
     86#define M_FIRSTFRAG     0x00001000
     87#define M_LASTFRAG      0x00002000
    8588#define M_VLANTAG       0x00010000
    8689
    8790#define CSUM_IP         0x0001
     
    124127struct mbuf *m_get(int how, short type);
    125128struct mbuf *m_gethdr(int how, short type);
    126129void m_clget(struct mbuf *m, int how);
     130void * m_cljget(struct mbuf *m, int how, int size);
    127131
    128132void m_extadd(struct mbuf *m, caddr_t buffer, u_int size,
    129133    void (*freeHook)(void *, void *), void *args, int flags, int type);
  • src/libs/compat/freebsd_network/mbuf.c

     
    150150    construct_ext_mbuf(m, how);
    151151}
    152152
     153/*
     154 * Comment from the freebsd (mbuf.h):
     155 * m_cljget() is different from m_clget() as it can allocate clusters without
     156 * attaching them to an mbuf.  In that case the return value is the pointer
     157 * to the cluster of the requested size.  If an mbuf was specified, it gets
     158 * the cluster attached to it and the return value can be safely ignored.
     159 * For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES.
     160 */
     161void *
     162m_cljget(struct mbuf *m, int how, int size)
     163{
     164    // TODO: implement this
     165    panic("m_cljget not yet implemented");
     166    return (void *) NULL;
    153167
     168/*
     169//  This is the freebsd code
     170    uma_zone_t zone;
     171
     172    if (m && m->m_flags & M_EXT)
     173        printf("%s: %p mbuf already has cluster\n", __func__, m);
     174    if (m != NULL)
     175        m->m_ext.ext_buf = NULL;
     176
     177    zone = m_getzone(size);
     178    return (uma_zalloc_arg(zone, m, how));
     179*/
     180}
     181
     182
    154183void
    155184m_freem(struct mbuf *mb)
    156185{