Diff for /src/sys/bus/usb/usb_mem.h between versions 1.2 and 1.3

version 1.2, 2003/06/17 04:28:32 version 1.3, 2003/12/30 01:01:44
Line 1 Line 1
/*        $NetBSD: usb_mem.h,v 1.9 1999/10/13 08:10:58 augustss Exp $ *//*
/*        $FreeBSD: src/sys/dev/usb/usb_mem.h,v 1.10.2.2 2000/10/31 23:23:30 n_hibma Exp $  */ * $NetBSD: usb_mem.h,v 1.18 2002/05/28 17:45:17 augustss Exp $
/*        $DragonFly: src/sys/dev/usb/usb_mem.h,v 1.1 2003/06/16 06:11:21 dillon Exp $      */ * $FreeBSD: src/sys/dev/usb/usb_mem.h,v 1.20 2003/09/01 01:07:24 jmg Exp $
  * $DragonFly$
  */
   
 /*  /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.   * Copyright (c) 1998 The NetBSD Foundation, Inc.
Line 39 Line 41
  * POSSIBILITY OF SUCH DAMAGE.   * POSSIBILITY OF SUCH DAMAGE.
  */   */
   
 #if defined(__NetBSD__) || defined(__OpenBSD__)  
 typedef struct usb_dma_block {  typedef struct usb_dma_block {
         bus_dma_tag_t tag;          bus_dma_tag_t tag;
         bus_dmamap_t map;          bus_dmamap_t map;
   #ifdef __FreeBSD__
           void *kaddr;
   #else
         caddr_t kaddr;          caddr_t kaddr;
   #endif
         bus_dma_segment_t segs[1];          bus_dma_segment_t segs[1];
         int nsegs;          int nsegs;
         size_t size;          size_t size;
Line 52  typedef struct usb_dma_block { Line 57  typedef struct usb_dma_block {
         LIST_ENTRY(usb_dma_block) next;          LIST_ENTRY(usb_dma_block) next;
 } usb_dma_block_t;  } usb_dma_block_t;
   
#define DMAADDR(dma, offset) ((dma)->block->segs[0].ds_addr + (dma)->offs + (offset))#ifdef __FreeBSD__
#define KERNADDR(dma, offset) ((void *)((dma)->block->kaddr + (dma)->offs) + (offset))#define DMAADDR(dma, o) ((dma)->block->segs[0].ds_addr + (dma)->offs + (o))
 
usbd_status     usb_allocmem(usbd_bus_handle,size_t,size_t, usb_dma_t *); 
void            usb_freemem(usbd_bus_handle, usb_dma_t *); 
 
#elif defined(__FreeBSD__) 
 
/*  
 * FreeBSD does not have special functions for dma memory, so let's keep it 
 * simple for now. 
 */ 
 
#include <sys/param.h> 
#include <sys/systm.h> 
#include <sys/queue.h> 
#include <sys/proc.h> 
#include <sys/buf.h> 
#include <sys/malloc.h> 
#include <sys/kernel.h> 
#include <vm/vm.h> 
#include <vm/pmap.h> 
 
#include <machine/pmap.h>       /* for vtophys */ 
 
#define         usb_allocmem(t,s,a,p)   (*(p) = malloc(s, M_USB, M_NOWAIT), (*(p) == NULL? USBD_NOMEM: USBD_NORMAL_COMPLETION)) 
#define         usb_freemem(t,p)        (free(*(p), M_USB)) 
 
#ifdef __alpha__ 
#define DMAADDR(dma, offset)    (alpha_XXX_dmamap((vm_offset_t) *(dma) + (offset))) 
 #else  #else
#define DMAADDR(dma, offset)  (vtophys(*(dma) + (offset)))#define DMAADDR(dma, o) (((char *)(dma)->block->map->dm_segs[0].ds_addr) + (dma)->offs + (o))
#endif 
#define KERNADDR(dma, offset)   ((void *) (*(dma) + (offset))) 
 #endif  #endif
   #define KERNADDR(dma, o) \
           ((void *)((char *)((dma)->block->kaddr) + (dma)->offs + (o)))
   
   usbd_status     usb_allocmem(usbd_bus_handle,size_t,size_t, usb_dma_t *);
   void            usb_freemem(usbd_bus_handle, usb_dma_t *);

Removed from v.1.2  
changed lines
  Added in v.1.3