freebsd compat. layer: couple fixes, sending now works with PCNET. enabled ifmedia_ioctl, and when opening a device, set it down, change media to ETHER/AUTO and set it back up so it sees a IFF_UP.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21047 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Hugo Santos
2007-05-07 03:20:58 +00:00
parent cdb3eb762a
commit e2941f52fd
11 changed files with 59 additions and 24 deletions
@@ -7,7 +7,7 @@ UsePrivateHeaders kernel net ;
UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ;
SubDirCcFlags [ FDefines _KERNEL=1 ] ;
SubDirCcFlags [ FDefines _KERNEL=1 LEDEBUG=128 ] ;
KernelAddon pcnet :
am7990.c
@@ -172,6 +172,8 @@ am79900_config(struct am79900_softc *sc, const char* name, int unit)
if (mem > sc->lsc.sc_memsize)
panic("%s: memsize", __func__);
sc->lsc.sc_flags |= LE_DEBUG;
lance_attach(&sc->lsc);
return (0);
@@ -450,10 +452,12 @@ am79900_intr(void *arg)
if (sc->sc_flags & LE_DEBUG)
if_printf(ifp, "%s: entering with isr=%04x\n", __func__, isr);
#endif
#if 0
if ((isr & LE_C0_INTR) == 0) {
LE_UNLOCK(sc);
return;
}
#endif
/*
* Clear interrupt source flags and turn off interrupts. If we
+1 -1
View File
@@ -5,7 +5,7 @@ UsePrivateHeaders kernel net ;
UseHeaders [ FDirName $(SUBDIR) ] : true ;
UseHeaders [ FDirName $(SUBDIR) compat ] : true ;
SubDirCcFlags [ FDefines _KERNEL=1 ] ;
SubDirCcFlags [ FDefines _KERNEL=1 KTR=1 ] ;
Library libfreebsd_network.a :
bus.c
@@ -528,7 +528,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
printf("bus_dmamem_alloc failed to align memory properly.\n");
}
CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
__func__, dmat, dmat->flags, ENOMEM);
__func__, dmat, dmat->flags, 0);
return (0);
}
+19 -1
View File
@@ -293,10 +293,13 @@ _kernel_contigmalloc(const char *file, int line, size_t size, int flags,
snprintf(name, sizeof(name), "contig:%s:%d", file, line);
area = create_area(name, &addr, B_ANY_KERNEL_ADDRESS, size,
B_FULL_LOCK | B_CONTIGUOUS, 0);
B_FULL_LOCK | B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA);
if (area < 0)
return NULL;
driver_printf("(%s) addr = %p, area = %d, size = %lu\n",
name, addr, area, size);
return addr;
}
@@ -308,6 +311,21 @@ _kernel_contigfree(void *addr, size_t size)
}
/* Marcus' vtophys */
unsigned long
vtophys(vm_offset_t vaddr)
{
physical_entry pe;
status_t status;
status = get_memory_map((void *)vaddr, 1, &pe, 1);
if (status < 0)
panic("fbsd compat: get_memory_map failed for %p, error %08lx\n",
(void *)vaddr, status);
return (unsigned long)pe.address;
}
status_t
init_compat_layer()
{
@@ -58,7 +58,7 @@
* Host to big endian, host to little endian, big endian to host, and little
* endian to host byte order functions as detailed in byteorder(9).
*/
#if _YTE_ORDER == _LITTLE_ENDIAN
#if _BYTE_ORDER == _LITTLE_ENDIAN
#define htobe16(x) bswap16((x))
#define htobe32(x) bswap32((x))
#define htobe64(x) bswap64((x))
@@ -128,9 +128,15 @@ extern struct ktr_entry ktr_buf[];
#ifdef KTR
#if 0
void ktr_tracepoint(u_int mask, const char *file, int line,
const char *format, u_long arg1, u_long arg2, u_long arg3,
u_long arg4, u_long arg5, u_long arg6);
#else
extern void driver_printf(const char *format, ...);
#define ktr_tracepoint(mask, file, line, format, arg1, arg2, arg3, arg4, arg5, arg6) \
driver_printf("(%s:%i) " format "\n", file, line, arg1, arg2, arg3, arg4, arg5, arg6)
#endif
#define CTR6(m, format, p1, p2, p3, p4, p5, p6) do { \
if (KTR_COMPILE & (m)) \
+1 -14
View File
@@ -17,19 +17,6 @@ typedef void * pmap_t;
#define pmap_kextract(vaddr) vtophys(vaddr)
/* Marcus' vtophys */
static inline unsigned long
vtophys(vm_offset_t vaddr)
{
physical_entry pe;
status_t status;
status = get_memory_map((void *)vaddr, 1, &pe, 1);
if (status < 0)
panic("fbsd compat: get_memory_map failed for %p, error %08lx\n",
(void *)vaddr, status);
return (unsigned long)pe.address;
}
unsigned long vtophys(vm_offset_t vaddr);
#endif
+17
View File
@@ -14,6 +14,8 @@
#include <Drivers.h>
#include <ether_driver.h>
#include <sys/sockio.h>
#include <compat/sys/haiku-module.h>
#include <compat/sys/bus.h>
@@ -118,6 +120,21 @@ compat_open(const char *name, uint32 flags, void **cookie)
driver_printf(" ... status = 0x%ld\n", status);
if (status == 0) {
struct ifnet *ifp = dev->ifp;
struct ifreq ifr;
ifp->if_flags = 0;
ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL);
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_media = IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, 0);
ifp->if_ioctl(ifp, SIOCSIFMEDIA, &ifr);
ifp->if_flags = IFF_UP;
ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL);
}
*cookie = dev;
return status;
+1 -1
View File
@@ -295,7 +295,7 @@ ether_sprintf(const u_char *ap)
{
static char etherbuf[18];
snprintf(etherbuf, sizeof (etherbuf),
"%02x:%02x:%02x:%02x:%02x:%02x",
"%02lx:%02lx:%02lx:%02lx:%02lx:%02lx",
(uint32)ap[0], (uint32)ap[1], (uint32)ap[2], (uint32)ap[3],
(uint32)ap[4], (uint32)ap[5]);
return (etherbuf);
+7 -4
View File
@@ -62,11 +62,13 @@
* Useful for debugging newly-ported drivers.
*/
#define IFMEDIA_DEBUG
static struct ifmedia_entry *ifmedia_match(struct ifmedia *ifm,
int flags, int mask);
#ifdef IFMEDIA_DEBUG
int ifmedia_debug = 0;
int ifmedia_debug = 1;
static void ifmedia_printword(int);
#endif
@@ -198,7 +200,6 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
struct ifmedia *ifm;
u_long cmd;
{
#if 0
struct ifmedia_entry *match;
struct ifmediareq *ifmr = (struct ifmediareq *) ifr;
int error = 0, sticky;
@@ -330,9 +331,13 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
*/
sticky = error;
if ((error == 0 || error == E2BIG) && ifmr->ifm_count != 0) {
#if 0
error = copyout((caddr_t)kptr,
(caddr_t)ifmr->ifm_ulist,
ifmr->ifm_count * sizeof(int));
#endif
/* this ioctl() is only called from within the kernel -hugo */
memcpy(kptr, ifmr->ifm_ulist, ifmr->ifm_count * sizeof(int));
}
if (error == 0)
@@ -350,8 +355,6 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
}
return (error);
#endif
return ENOTSUP;
}
/*