/* usb/sys/memory.h
 *
 * (c) 2002 Simtec Electronics
 *
 * Ben Dooks
 *
 * RISCOS specific memory management functions
 *
 * $Id: memory.h,v 1.17 2003/08/07 22:16:25 ben Exp $
 *
 * This Library file is part of the Simtec Electronics USB stack development
 *   suite.
 * Specific licence is granted to use this file by third parties for the
 *   development of USB device drivers.
 *
 */

#ifndef __USB_SYS_MEMORY_H
#define __USB_SYS_MEMORY_H "$Id: memory.h,v 1.17 2003/08/07 22:16:25 ben Exp $"

/* these bits shouldn't really be here, they should be internal to
 * the usb system, and only used internally!
*/

#define USB_DYNAMIC_AREA_NAME "USB"

typedef enum {
  USB_MEMORY_TYPE_NONE,
  USB_MEMORY_TYPE_RMA,
  USB_MEMORY_TYPE_DA
} usb_mem_type_t;

/**
  Structure used to keep track of the USB dynamic area
  @memo USB dynamic area structure
*/
struct usb_dynamic_area_s {
  unsigned long  offset_to_heap;
  unsigned long  no_of_using_applications;
  unsigned long  size;
  unsigned long  max_size;
  unsigned long  id;           /* id number of dynamic area */
  usb_mem_type_t type;         /* type */

  unsigned long unused[32];     /* for future expansion... */
};

extern struct usb_dynamic_area_s *usb_dynamic_area;

extern int usb_dynamic_area_initialize(void);
extern int usb_dynamic_area_release(void);

extern struct usb_dynamic_area_s *usb_get_dynamic_area(void);

extern void *usb_rma_malloc(size_t sz);
extern void usb_rma_free(void *block);

extern void *usb_get_heap(void);

/* memory swi definitions */

extern void *usb_swi_malloc(size_t sz);
extern void *usb_swi_realloc(void *, size_t sz);
extern void usb_swi_free(void *);

extern int usb_memory_claim(void);
extern int usb_memory_release(void);

/* we can get away with varargs as it'll pass the first 4 params in regs */
extern int usb_memoryop(int op, ...);

#endif /* __USB_SYS_MEMORY_H */
