72 lines
1.4 KiB
C
Executable File
72 lines
1.4 KiB
C
Executable File
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/poll.h>
|
|
#include <sys/time.h>
|
|
#include <fcntl.h>
|
|
#include <errno.h>
|
|
#include <pthread.h>
|
|
#include <math.h>
|
|
#include <unistd.h>
|
|
#include <signal.h>
|
|
#include <sys/time.h>
|
|
#include <time.h>
|
|
#include <dirent.h>
|
|
#include <limits.h>
|
|
#include <getopt.h>
|
|
|
|
#include "fh_common.h"
|
|
#include "types/vmm_api.h"
|
|
#include "types/bufCtrl.h"
|
|
#include "common.h"
|
|
#include "../../common/list.h"
|
|
|
|
|
|
struct buffer_list {
|
|
struct list_head list;
|
|
MEM_DESC mem;
|
|
};
|
|
|
|
static LIST_HEAD(buff_list);
|
|
|
|
|
|
MEM_DESC* ipo_alloc_buffer(int size, int align, const char* name)
|
|
{
|
|
|
|
struct buffer_list *buff = malloc(sizeof(struct buffer_list));
|
|
memset(&buff, 0, sizeof(struct buffer_list));
|
|
|
|
int ret = buffer_malloc_withname(&buff->mem, size, align, name);
|
|
|
|
if(!ret) {
|
|
IPO_LOG_PRT("buffer_malloc_withname failed for size = %d, name = %s\n", size, name);
|
|
free(buff);
|
|
return NULL;
|
|
}
|
|
|
|
list_add(&buff->list, &buff_list);
|
|
|
|
return &buff->mem;
|
|
}
|
|
|
|
int ipo_free_all_buffer()
|
|
{
|
|
int ret = 0;
|
|
struct list_head *p, *q;
|
|
|
|
list_for_each_safe(p, q, &buff_list){
|
|
struct buffer_list *tmp= list_entry(p, struct buffer_list, list);
|
|
list_del(p);
|
|
if(tmp->mem.base) {
|
|
FH_SYS_VmmFree(tmp->mem.base);
|
|
}
|
|
free(tmp);
|
|
}
|
|
return ret;
|
|
}
|
|
|