/*\r
- * This file is part of the Palacios Virtual Machine Monitor developed\r
- * by the V3VEE Project with funding from the United States National\r
- * Science Foundation and the Department of Energy.\r
- *\r
- * The V3VEE Project is a joint project between Northwestern University\r
- * and the University of New Mexico. You can find out more at\r
- * http://www.v3vee.org\r
- *\r
- * Copyright (c) 2010, Lei Xia <lxia@northwestern.edu>\r
- * Copyright (c) 2010, The V3VEE Project <http://www.v3vee.org>\r
- * All rights reserved.\r
- *\r
- * This is free software. You are permitted to use, redistribute,\r
- * and modify it under the terms of the GNU General Public License\r
- * Version 2 (GPLv2). The accompanying COPYING file contains the\r
- * full text of the license.\r
+ * Ringbuffer implementation\r
+ * (c) Lei Xia 2010\r
*/\r
+ \r
\r
#include <linux/errno.h>\r
#include <linux/percpu.h>\r
#include "util-ringbuffer.h"\r
\r
void init_ringbuf(struct ringbuf * ring, unsigned int size) {\r
- ring->buf = kmalloc(size, GFP_KERNEL);\r
+ ring->buf = palacios_alloc(size);\r
+\r
+ if (!(ring->buf)) { \r
+ ERROR("Cannot allocate ring buffer data\n");\r
+ size=0;\r
+ }\r
+\r
ring->size = size;\r
\r
ring->start = 0;\r
}\r
\r
struct ringbuf * create_ringbuf(unsigned int size) {\r
- struct ringbuf * ring = (struct ringbuf *)kmalloc(sizeof(struct ringbuf), GFP_KERNEL);\r
+ struct ringbuf * ring = (struct ringbuf *)palacios_alloc(sizeof(struct ringbuf));\r
+\r
+ if (!ring) { \r
+ ERROR("Cannot allocate ring buffer\n");\r
+ return NULL;\r
+ }\r
+\r
init_ringbuf(ring, size);\r
\r
return ring;\r
}\r
\r
void free_ringbuf(struct ringbuf * ring) {\r
- kfree(ring->buf);\r
- kfree(ring);\r
+ palacios_free(ring->buf);\r
+ palacios_free(ring);\r
}\r
\r
static inline unsigned char * get_read_ptr(struct ringbuf * ring) {\r