Added an allocator providing memory associated with VIP (i.e. page
writer) I/O requests. Not used yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26966 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f3e82cfe42
commit
d88a145e9e
@ -2207,6 +2207,8 @@ device_manager_init(struct kernel_args* args)
|
|||||||
{
|
{
|
||||||
TRACE(("device manager init\n"));
|
TRACE(("device manager init\n"));
|
||||||
|
|
||||||
|
vip_io_request_allocator_init();
|
||||||
|
|
||||||
dm_init_id_generator();
|
dm_init_id_generator();
|
||||||
dm_init_io_resources();
|
dm_init_io_resources();
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <heap.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <team.h>
|
#include <team.h>
|
||||||
#include <util/AutoLock.h>
|
#include <util/AutoLock.h>
|
||||||
@ -24,6 +25,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define VIP_HEAP_SIZE 1024 * 1024
|
||||||
|
|
||||||
// partial I/O operation phases
|
// partial I/O operation phases
|
||||||
enum {
|
enum {
|
||||||
PHASE_READ_BEGIN = 0,
|
PHASE_READ_BEGIN = 0,
|
||||||
@ -31,6 +34,11 @@ enum {
|
|||||||
PHASE_DO_ALL = 2
|
PHASE_DO_ALL = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
heap_allocator* sVIPHeap;
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
IORequestChunk::IORequestChunk()
|
IORequestChunk::IORequestChunk()
|
||||||
:
|
:
|
||||||
@ -1142,6 +1150,64 @@ IORequest::Dump() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - allocator
|
||||||
|
|
||||||
|
|
||||||
|
void*
|
||||||
|
vip_io_request_malloc(size_t size)
|
||||||
|
{
|
||||||
|
return heap_memalign(sVIPHeap, 0, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
vip_io_request_free(void* address)
|
||||||
|
{
|
||||||
|
heap_free(sVIPHeap, address);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
io_request_free(void* address)
|
||||||
|
{
|
||||||
|
if (heap_free(sVIPHeap, address) != B_OK)
|
||||||
|
free(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
vip_io_request_allocator_init()
|
||||||
|
{
|
||||||
|
static const heap_class heapClass = {
|
||||||
|
"VIP I/O", /* name */
|
||||||
|
100, /* initial percentage */
|
||||||
|
B_PAGE_SIZE / 8, /* max allocation size */
|
||||||
|
B_PAGE_SIZE, /* page size */
|
||||||
|
8, /* min bin size */
|
||||||
|
4, /* bin alignment */
|
||||||
|
8, /* min count per page */
|
||||||
|
16 /* max waste per page */
|
||||||
|
};
|
||||||
|
|
||||||
|
void* address = NULL;
|
||||||
|
area_id area = create_area("VIP I/O heap", &address, B_ANY_KERNEL_ADDRESS,
|
||||||
|
VIP_HEAP_SIZE, B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
|
if (area < B_OK) {
|
||||||
|
panic("vip_io_request_allocator_init(): couldn't allocate VIP I/O "
|
||||||
|
"heap area");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sVIPHeap = heap_create_allocator("VIP I/O heap", (addr_t)address,
|
||||||
|
VIP_HEAP_SIZE, &heapClass);
|
||||||
|
if (sVIPHeap == NULL) {
|
||||||
|
panic("vip_io_request_allocator_init(): failed to create VIP I/O "
|
||||||
|
"heap\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@ -1246,3 +1312,4 @@ delete_io_request(io_request* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // 0
|
#endif // 0
|
||||||
|
|
||||||
|
@ -320,4 +320,15 @@ private:
|
|||||||
typedef DoublyLinkedList<IORequest> IORequestList;
|
typedef DoublyLinkedList<IORequest> IORequestList;
|
||||||
|
|
||||||
|
|
||||||
|
// allocator for VIP I/O request memory
|
||||||
|
void* vip_io_request_malloc(size_t size);
|
||||||
|
void vip_io_request_free(void* address);
|
||||||
|
|
||||||
|
void io_request_free(void* address);
|
||||||
|
// frees regardless of whether allocated with vip_io_request_malloc() or
|
||||||
|
// malloc()
|
||||||
|
|
||||||
|
void vip_io_request_allocator_init();
|
||||||
|
|
||||||
|
|
||||||
#endif // IO_REQUESTS_H
|
#endif // IO_REQUESTS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user