* Enlarged a single kernel_args chunk to 32 KB (was 16 KB).

* Reduced the kernel_args array size from 32 to 16 (7 are used on a normal
  build).
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27690 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-09-22 15:36:46 +00:00
parent 65a9d40a9d
commit 4a47b14ea4
2 changed files with 46 additions and 49 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
#include <util/KMessage.h> #include <util/KMessage.h>
#define CURRENT_KERNEL_ARGS_VERSION 1 #define CURRENT_KERNEL_ARGS_VERSION 1
#define MAX_KERNEL_ARGS_RANGE 32 #define MAX_KERNEL_ARGS_RANGE 16
// names of common boot_volume fields // names of common boot_volume fields
#define BOOT_METHOD "boot method" #define BOOT_METHOD "boot method"
+23 -26
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2006, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004-2008, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -13,7 +13,7 @@
#include <string.h> #include <string.h>
static const size_t kChunkSize = 4 * B_PAGE_SIZE; static const size_t kChunkSize = 8 * B_PAGE_SIZE;
kernel_args gKernelArgs; kernel_args gKernelArgs;
@@ -31,7 +31,8 @@ remove_range_index(addr_range *ranges, uint32 &numRanges, uint32 index)
return; return;
} }
memmove(&ranges[index], &ranges[index + 1], sizeof(addr_range) * (numRanges - 1 - index)); memmove(&ranges[index], &ranges[index + 1],
sizeof(addr_range) * (numRanges - 1 - index));
numRanges--; numRanges--;
} }
@@ -48,14 +49,13 @@ add_kernel_args_range(void *start, uint32 size)
// #pragma mark - addr_range utility // #pragma mark - addr_range utility
/** Inserts the specified (start, size) pair (aka range) in the /*! Inserts the specified (start, size) pair (aka range) in the
* addr_range array. addr_range array.
* It will extend existing ranges in order to have as little It will extend existing ranges in order to have as little
* ranges in the array as possible. ranges in the array as possible.
* Returns B_OK on success, or B_ENTRY_NOT_FOUND if there was Returns B_OK on success, or B_ENTRY_NOT_FOUND if there was
* no free array entry available anymore. no free array entry available anymore.
*/ */
extern "C" status_t extern "C" status_t
insert_address_range(addr_range* ranges, uint32* _numRanges, uint32 maxRanges, insert_address_range(addr_range* ranges, uint32* _numRanges, uint32 maxRanges,
addr_t start, uint32 size) addr_t start, uint32 size)
@@ -193,8 +193,8 @@ status_t
insert_physical_allocated_range(addr_t start, uint32 size) insert_physical_allocated_range(addr_t start, uint32 size)
{ {
return insert_address_range(gKernelArgs.physical_allocated_range, return insert_address_range(gKernelArgs.physical_allocated_range,
&gKernelArgs.num_physical_allocated_ranges, MAX_PHYSICAL_ALLOCATED_RANGE, &gKernelArgs.num_physical_allocated_ranges,
start, size); MAX_PHYSICAL_ALLOCATED_RANGE, start, size);
} }
@@ -210,12 +210,11 @@ insert_virtual_allocated_range(addr_t start, uint32 size)
// #pragma mark - kernel_args allocations // #pragma mark - kernel_args allocations
/** This function can be used to allocate memory that is going /*! This function can be used to allocate memory that is going
* to be passed over to the kernel. For example, the preloaded_image to be passed over to the kernel. For example, the preloaded_image
* structures are allocated this way. structures are allocated this way.
* The boot loader heap doesn't make it into the kernel! The boot loader heap doesn't make it into the kernel!
*/ */
extern "C" void* extern "C" void*
kernel_args_malloc(size_t size) kernel_args_malloc(size_t size)
{ {
@@ -246,8 +245,8 @@ kernel_args_malloc(size_t size)
// just allocate a new block and "close" the old one // just allocate a new block and "close" the old one
void* block = NULL; void* block = NULL;
if (platform_allocate_region(&block, kChunkSize, if (platform_allocate_region(&block, kChunkSize, B_READ_AREA | B_WRITE_AREA,
B_READ_AREA | B_WRITE_AREA, false) != B_OK) { false) != B_OK) {
return NULL; return NULL;
} }
@@ -261,10 +260,9 @@ kernel_args_malloc(size_t size)
} }
/** Convenience function that copies strdup() functions for the /*! Convenience function that copies strdup() functions for the
* kernel args heap. kernel args heap.
*/ */
extern "C" char * extern "C" char *
kernel_args_strdup(const char *string) kernel_args_strdup(const char *string)
{ {
@@ -282,11 +280,10 @@ kernel_args_strdup(const char *string)
} }
/** This function frees a block allocated via kernel_args_malloc(). /*! This function frees a block allocated via kernel_args_malloc().
* It's very simple; it can only free the last allocation. It's It's very simple; it can only free the last allocation. It's
* enough for its current usage in the boot loader, though. enough for its current usage in the boot loader, though.
*/ */
extern "C" void extern "C" void
kernel_args_free(void *block) kernel_args_free(void *block)
{ {