Omar Ramirez Luna | 7227b67 | 2010-06-23 16:02:00 +0300 | [diff] [blame^] | 1 | /* |
| 2 | * gs.c |
| 3 | * |
| 4 | * DSP-BIOS Bridge driver support functions for TI OMAP processors. |
| 5 | * |
| 6 | * General storage memory allocator services. |
| 7 | * |
| 8 | * Copyright (C) 2005-2006 Texas Instruments, Inc. |
| 9 | * |
| 10 | * This package is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | * |
| 14 | * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
| 15 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 16 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 17 | */ |
| 18 | |
| 19 | /* ----------------------------------- DSP/BIOS Bridge */ |
| 20 | #include <dspbridge/std.h> |
| 21 | #include <dspbridge/dbdefs.h> |
| 22 | #include <linux/types.h> |
| 23 | |
| 24 | /* ----------------------------------- This */ |
| 25 | #include <dspbridge/gs.h> |
| 26 | |
| 27 | #include <linux/slab.h> |
| 28 | |
| 29 | /* ----------------------------------- Globals */ |
| 30 | static u32 cumsize; |
| 31 | |
| 32 | /* |
| 33 | * ======== gs_alloc ======== |
| 34 | * purpose: |
| 35 | * Allocates memory of the specified size. |
| 36 | */ |
| 37 | void *gs_alloc(u32 size) |
| 38 | { |
| 39 | void *p; |
| 40 | |
| 41 | p = kzalloc(size, GFP_KERNEL); |
| 42 | if (p == NULL) |
| 43 | return NULL; |
| 44 | cumsize += size; |
| 45 | return p; |
| 46 | } |
| 47 | |
| 48 | /* |
| 49 | * ======== gs_exit ======== |
| 50 | * purpose: |
| 51 | * Discontinue the usage of the GS module. |
| 52 | */ |
| 53 | void gs_exit(void) |
| 54 | { |
| 55 | /* Do nothing */ |
| 56 | } |
| 57 | |
| 58 | /* |
| 59 | * ======== gs_free ======== |
| 60 | * purpose: |
| 61 | * Frees the memory. |
| 62 | */ |
| 63 | void gs_free(void *ptr) |
| 64 | { |
| 65 | kfree(ptr); |
| 66 | /* ack! no size info */ |
| 67 | /* cumsize -= size; */ |
| 68 | } |
| 69 | |
| 70 | /* |
| 71 | * ======== gs_frees ======== |
| 72 | * purpose: |
| 73 | * Frees the memory. |
| 74 | */ |
| 75 | void gs_frees(void *ptr, u32 size) |
| 76 | { |
| 77 | kfree(ptr); |
| 78 | cumsize -= size; |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | * ======== gs_init ======== |
| 83 | * purpose: |
| 84 | * Initializes the GS module. |
| 85 | */ |
| 86 | void gs_init(void) |
| 87 | { |
| 88 | /* Do nothing */ |
| 89 | } |