mirror of
https://github.com/apache/nuttx.git
synced 2026-09-27 10:46:02 +08:00
More changes for a kernel-mode allocator (more to be done)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5724 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+12
-10
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* fs/fat/fs_writefat.c
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/fat.h>
|
||||
#include <nuttx/fs/mkfatfs.h>
|
||||
@@ -277,7 +278,7 @@ int mkfatfs(FAR const char *pathname, FAR struct fat_format_s *fmt)
|
||||
|
||||
/* Allocate a buffer that will be working sector memory */
|
||||
|
||||
var.fv_sect = (uint8_t*)malloc(var.fv_sectorsize);
|
||||
var.fv_sect = (uint8_t*)kmalloc(var.fv_sectorsize);
|
||||
if (!var.fv_sect)
|
||||
{
|
||||
fdbg("Failed to allocate working buffers\n");
|
||||
@@ -298,15 +299,16 @@ errout:
|
||||
|
||||
if (var.fv_sect)
|
||||
{
|
||||
free(var.fv_sect);
|
||||
kfree(var.fv_sect);
|
||||
}
|
||||
|
||||
/* Return any reported errors */
|
||||
/* Return any reported errors */
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
errno = -ret;
|
||||
return ERROR;
|
||||
}
|
||||
return OK;
|
||||
if (ret < 0)
|
||||
{
|
||||
errno = -ret;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* fs/fs_closedir.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -135,13 +135,13 @@ int closedir(FAR DIR *dirp)
|
||||
|
||||
/* Then release the container */
|
||||
|
||||
kfree(idir);
|
||||
kufree(idir);
|
||||
return OK;
|
||||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
errout_with_inode:
|
||||
inode_release(inode);
|
||||
kfree(idir);
|
||||
kufree(idir);
|
||||
#endif
|
||||
|
||||
errout:
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
|
||||
|
||||
/* Allocate the IO buffer */
|
||||
|
||||
stream->fs_bufstart = kmalloc(CONFIG_STDIO_BUFFER_SIZE);
|
||||
stream->fs_bufstart = kumalloc(CONFIG_STDIO_BUFFER_SIZE);
|
||||
if (!stream->fs_bufstart)
|
||||
{
|
||||
err = ENOMEM;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* fs/fs_foreachinode.c
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
|
||||
#include "fs_internal.h"
|
||||
@@ -187,7 +188,7 @@ int foreach_inode(foreach_inode_t handler, FAR void *arg)
|
||||
|
||||
/* Allocate the mountpoint info structure */
|
||||
|
||||
info = (FAR struct inode_path_s *)malloc(sizeof(struct inode_path_s));
|
||||
info = (FAR struct inode_path_s *)kmalloc(sizeof(struct inode_path_s));
|
||||
if (!info)
|
||||
{
|
||||
return -ENOMEM;
|
||||
@@ -207,7 +208,7 @@ int foreach_inode(foreach_inode_t handler, FAR void *arg)
|
||||
|
||||
/* Free the info structure and return the result */
|
||||
|
||||
free(info);
|
||||
kfree(info);
|
||||
return ret;
|
||||
|
||||
#else
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* fs/fs_opendir.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -232,7 +232,7 @@ FAR DIR *opendir(FAR const char *path)
|
||||
* container.
|
||||
*/
|
||||
|
||||
dir = (FAR struct fs_dirent_s *)kzalloc(sizeof(struct fs_dirent_s));
|
||||
dir = (FAR struct fs_dirent_s *)kuzalloc(sizeof(struct fs_dirent_s));
|
||||
if (!dir)
|
||||
{
|
||||
/* Insufficient memory to complete the operation.*/
|
||||
@@ -303,7 +303,7 @@ FAR DIR *opendir(FAR const char *path)
|
||||
/* Nasty goto's make error handling simpler */
|
||||
|
||||
errout_with_direntry:
|
||||
kfree(dir);
|
||||
kufree(dir);
|
||||
|
||||
errout_with_semaphore:
|
||||
inode_semgive();
|
||||
|
||||
+3
-3
@@ -151,7 +151,7 @@ int munmap(FAR void *start, size_t length)
|
||||
/* Get the offset from the beginning of the region and the actual number
|
||||
* of bytes to "unmap". All mappings must extend to the end of the region.
|
||||
* There is no support for free a block of memory but leaving a block of
|
||||
* memory at the end. This is a consequence of using realloc() to
|
||||
* memory at the end. This is a consequence of using kurealloc() to
|
||||
* simulate the unmapping.
|
||||
*/
|
||||
|
||||
@@ -186,7 +186,7 @@ int munmap(FAR void *start, size_t length)
|
||||
|
||||
/* Then free the region */
|
||||
|
||||
kfree(curr);
|
||||
kufree(curr);
|
||||
}
|
||||
|
||||
/* No.. We have been asked to "unmap' only a portion of the memory
|
||||
@@ -195,7 +195,7 @@ int munmap(FAR void *start, size_t length)
|
||||
|
||||
else
|
||||
{
|
||||
newaddr = krealloc(curr->addr, sizeof(struct fs_rammap_s) + length);
|
||||
newaddr = kurealloc(curr->addr, sizeof(struct fs_rammap_s) + length);
|
||||
DEBUGASSERT(newaddr == (FAR void*)(curr->addr));
|
||||
curr->length = length;
|
||||
}
|
||||
|
||||
+3
-3
@@ -139,7 +139,7 @@ FAR void *rammap(int fd, size_t length, off_t offset)
|
||||
|
||||
/* Allocate a region of memory of the specified size */
|
||||
|
||||
alloc = (FAR uint8_t *)kmalloc(sizeof(struct fs_rammap_s) + length);
|
||||
alloc = (FAR uint8_t *)kumalloc(sizeof(struct fs_rammap_s) + length);
|
||||
if (!alloc)
|
||||
{
|
||||
fdbg("Region allocation failed, length: %d\n", (int)length);
|
||||
@@ -232,13 +232,13 @@ FAR void *rammap(int fd, size_t length, off_t offset)
|
||||
return map->addr;
|
||||
|
||||
errout_with_region:
|
||||
kfree(alloc);
|
||||
kufree(alloc);
|
||||
errout:
|
||||
set_errno(err);
|
||||
return MAP_FAILED;
|
||||
|
||||
errout_with_errno:
|
||||
kfree(alloc);
|
||||
kufree(alloc);
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* rm/romfs/fs_romfsutil.h
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* References: Linux/Documentation/filesystems/romfs.txt
|
||||
@@ -51,6 +51,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/fs/dirent.h>
|
||||
|
||||
@@ -555,7 +556,7 @@ int romfs_hwconfigure(struct romfs_mountpt_s *rm)
|
||||
|
||||
/* Allocate the device cache buffer for normal sector accesses */
|
||||
|
||||
rm->rm_buffer = (uint8_t*)malloc(rm->rm_hwsectorsize);
|
||||
rm->rm_buffer = (uint8_t*)kmalloc(rm->rm_hwsectorsize);
|
||||
if (!rm->rm_buffer)
|
||||
{
|
||||
return -ENOMEM;
|
||||
@@ -643,7 +644,7 @@ int romfs_fileconfigure(struct romfs_mountpt_s *rm, struct romfs_file_s *rf)
|
||||
|
||||
/* Create a file buffer to support partial sector accesses */
|
||||
|
||||
rf->rf_buffer = (uint8_t*)malloc(rm->rm_hwsectorsize);
|
||||
rf->rf_buffer = (uint8_t*)kmalloc(rm->rm_hwsectorsize);
|
||||
if (!rf->rf_buffer)
|
||||
{
|
||||
return -ENOMEM;
|
||||
|
||||
Reference in New Issue
Block a user