1/*
2 * Copyright 2009, Johannes Wischert, johanneswi@gmail.com. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <KernelExport.h>
8#include <boot/platform.h>
9#include <boot/vfs.h>
10#include <boot/stdio.h>
11#include <boot/stage2.h>
12
13#define TRACE_DEVICES
14#ifdef TRACE_DEVICES
15#	define TRACE(x...) dprintf(x)
16#else
17#	define TRACE(x...)
18#endif
19
20
21
22
23status_t
24platform_add_boot_device(struct stage2_args *args, NodeList *devicesList)
25{
26	TRACE("platform_add_boot_device\n");
27
28	if (!args->platform.boot_tgz_data || !args->platform.boot_tgz_size)
29		return B_DEVICE_NOT_FOUND;
30
31	TRACE("Memory Disk at: %lx size: %lx\n", args->platform.boot_tgz_data,
32		args->platform.boot_tgz_size);
33
34	MemoryDisk* disk = new(nothrow) MemoryDisk(
35		(const uint8 *)args->platform.boot_tgz_data,
36		args->platform.boot_tgz_size, "boot.tgz");
37	if (!disk) {
38		dprintf("platform_add_boot_device(): Could not create MemoryDisk !\n");
39		return B_NO_MEMORY;
40	}
41
42	devicesList->Add(disk);
43	return B_OK;
44}
45
46
47status_t
48platform_get_boot_partition(struct stage2_args *args, Node *device,
49	NodeList *list, boot::Partition **_partition)
50{
51	TRACE("platform_get_boot_partition\n");
52
53	NodeIterator iterator = list->GetIterator();
54	boot::Partition *partition = NULL;
55	while ((partition = (boot::Partition *)iterator.Next()) != NULL) {
56		// ToDo: just take the first partition for now
57		*_partition = partition;
58		return B_OK;
59	}
60
61	return B_ENTRY_NOT_FOUND;
62}
63
64
65status_t
66platform_add_block_devices(stage2_args *args, NodeList *devicesList)
67{
68	TRACE("platform_add_block_devices\n");
69	return B_OK;
70}
71
72
73status_t
74platform_register_boot_device(Node *device)
75{
76	TRACE("platform_register_boot_device\n");
77	return B_OK;
78}
79