X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Futil-ringbuffer.c;h=9d0935db605a28aa4ebc88979228876cf31f1398;hb=1c5bf75232c70f01570ddc8b075f9455b7c6ba34;hp=0902acc409f24b6b1f6395f5d14a925b8888c807;hpb=cd265a5242baa89c2149b5c5cbf0ed00cfa83892;p=palacios.git diff --git a/linux_module/util-ringbuffer.c b/linux_module/util-ringbuffer.c index 0902acc..9d0935d 100644 --- a/linux_module/util-ringbuffer.c +++ b/linux_module/util-ringbuffer.c @@ -1,21 +1,8 @@ /* - * This file is part of the Palacios Virtual Machine Monitor developed - * by the V3VEE Project with funding from the United States National - * Science Foundation and the Department of Energy. - * - * The V3VEE Project is a joint project between Northwestern University - * and the University of New Mexico. You can find out more at - * http://www.v3vee.org - * - * Copyright (c) 2010, Lei Xia - * Copyright (c) 2010, The V3VEE Project - * All rights reserved. - * - * This is free software. You are permitted to use, redistribute, - * and modify it under the terms of the GNU General Public License - * Version 2 (GPLv2). The accompanying COPYING file contains the - * full text of the license. + * Ringbuffer implementation + * (c) Lei Xia 2010 */ + #include #include @@ -25,7 +12,13 @@ #include "util-ringbuffer.h" void init_ringbuf(struct ringbuf * ring, unsigned int size) { - ring->buf = kmalloc(size, GFP_KERNEL); + ring->buf = palacios_alloc(size); + + if (!(ring->buf)) { + ERROR("Cannot allocate ring buffer data\n"); + size=0; + } + ring->size = size; ring->start = 0; @@ -34,15 +27,21 @@ void init_ringbuf(struct ringbuf * ring, unsigned int size) { } struct ringbuf * create_ringbuf(unsigned int size) { - struct ringbuf * ring = (struct ringbuf *)kmalloc(sizeof(struct ringbuf), GFP_KERNEL); + struct ringbuf * ring = (struct ringbuf *)palacios_alloc(sizeof(struct ringbuf)); + + if (!ring) { + ERROR("Cannot allocate ring buffer\n"); + return NULL; + } + init_ringbuf(ring, size); return ring; } void free_ringbuf(struct ringbuf * ring) { - kfree(ring->buf); - kfree(ring); + palacios_free(ring->buf); + palacios_free(ring); } static inline unsigned char * get_read_ptr(struct ringbuf * ring) {