haiku/src/system/kernel/boot_item.cpp
Axel Dörfler 6328832fba * Changed get_boot_item() API: it now also can retrieve the size of the boot
item entry.
* The bios_ia32 video platform code now stores the available VESA modes in
  the new vesa_modes kernel_args field.
* When configuring a VESA mode via settings file, it's no longer needed to
  specify the exact mode - the closest available mode is now used. This should
  help with bug #1962.
* frame_buffer_console_init() now also creates a boot_item for the VESA modes
  in the kernel_args.
* The VESA accelerant now filters the mode list to only contain modes that
  are actually supported.
* Moved non-shared vesa driver data into its own file vesa_private.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24675 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-03-30 11:01:41 +00:00

77 lines
1.4 KiB
C++

/*
* Copyright 2005-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <boot_item.h>
#include <util/DoublyLinkedList.h>
#include <util/kernel_cpp.h>
#include <string.h>
// ToDo: the boot items are not supposed to be changed after kernel startup
// so no locking is done. So for now, we need to be careful with adding
// new items.
struct boot_item : public DoublyLinkedListLinkImpl<boot_item> {
const char *name;
void *data;
size_t size;
};
typedef DoublyLinkedList<boot_item> ItemList;
static ItemList sItemList;
status_t
add_boot_item(const char *name, void *data, size_t size)
{
boot_item *item = new(nothrow) boot_item;
if (item == NULL)
return B_NO_MEMORY;
item->name = name;
item->data = data;
item->size = size;
sItemList.Add(item);
return B_OK;
}
void *
get_boot_item(const char *name, size_t *_size)
{
if (name == NULL || name[0] == '\0')
return NULL;
// search item
for (ItemList::Iterator it = sItemList.GetIterator(); it.HasNext();) {
boot_item *item = it.Next();
if (!strcmp(name, item->name)) {
if (_size != NULL)
*_size = item->size;
return item->data;
}
}
return NULL;
}
status_t
boot_item_init(void)
{
new(&sItemList) ItemList;
// static initializers do not work in the kernel,
// so we have to do it here, manually
return B_OK;
}