c09d84bb92bfcd473cf249132ece3d51afba201c
* Copyright (c) 1989 The Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* @(#)if_vba.c 1.1 (Berkeley) %G%
#include "../tahoe/mtpr.h"
#include "../tahoe/pte.h"
#include "../tahoevba/vbavar.h"
#include "../netinet/in.h"
#include "../netinet/if_ether.h"
if_vbareserve(ifvba0
, n
, size
)
register struct pte
*pte
;
register struct ifvba
*ifvba
= ifvba0
;
struct ifvba
*vlim
= ifvba
+ n
;
n
= roundup(n
* size
, NBPG
);
cp
= (caddr_t
)malloc((u_long
)n
, M_DEVBUF
, M_NOWAIT
);
printf("No memory for device buffer\n");
* Make raw buffer pages uncacheable.
for (n
= btoc(n
); n
--; pte
++)
for (; ifvba
< vlim
; ifvba
++) {
ifvba
->iff_physaddr
= kvtophys(cp
);
* Routine to copy from VERSAbus memory into mbufs.
* Warning: This makes the fairly safe assumption that
* mbufs have even lengths.
if_vbaget(rxbuf
, totlen
, off
, ifp
, flags
)
struct mbuf
*top
= 0, **mp
= &top
;
rxbuf
+= sizeof (struct ether_header
);
packet_end
= cp
+ totlen
;
off
+= 2 * sizeof(u_short
);
totlen
-= 2 *sizeof(u_short
);
MGETHDR(m
, M_DONTWAIT
, MT_DATA
);
m
->m_pkthdr
.len
= totlen
;
MGET(m
, M_DONTWAIT
, MT_DATA
);
len
= min(totlen
, (packet_end
- cp
));
m
->m_len
= len
= min(len
, MCLBYTES
);
* Place initial small packet/header at end of mbuf.
if (top
== 0 && len
+ max_linkhdr
<= m
->m_len
)
m
->m_data
+= max_linkhdr
;
if_vba16copy(cp
, mtod(m
, u_char
*), (u_int
)len
);
bcopy(cp
, mtod(m
, u_char
*), (u_int
)len
);
if_vbaput(ifu
, m0
, flags
)
register struct mbuf
*m0
;
register struct mbuf
*m
= m0
;
register u_char
*cp
= ifu
;
if_vba16copy(mtod(m
, u_char
*), cp
, m
->m_len
);
bcopy(mtod(m
, u_char
*), cp
, m
->m_len
);
if_vba16copy(from
, to
, cnt
)
register u_char
*from
, *to
;
if (((int)from
&01) && ((int)to
&01)) {
/* source & dest at odd addresses */
if (cnt
> 1 && (((int)to
&01) == 0) && (((int)from
&01) == 0)) {
for (c
= cnt
>>1; c
; --c
) /* even address copy */
while ((int)cnt
-- > 0) /* one of the address(es) must be odd */