xref: /haiku/src/system/boot/platform/u-boot/devices.cpp (revision 0d452c8f34013b611a54c746a71c05e28796eae2)
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 
23 status_t
24 platform_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 	TRACE("Memory Disk at: %lx size: %lx\n",args->platform.boot_tgz_data, args->platform.boot_tgz_size);
31 	MemoryDisk* disk = new(nothrow) MemoryDisk(
32 		(const uint8 *)args->platform.boot_tgz_data,
33 		args->platform.boot_tgz_size, "boot.tgz");
34 	if (!disk) {
35 		dprintf("platform_add_boot_device(): Could not create MemoryDisk !\n");
36 		return B_NO_MEMORY;
37 	}
38 
39 	devicesList->Add(disk);
40 	return B_OK;
41 }
42 
43 
44 status_t
45 platform_get_boot_partition(struct stage2_args *args, Node *device,
46 	NodeList *list, boot::Partition **_partition)
47 {
48 	TRACE("platform_get_boot_partition\n");
49 
50 	NodeIterator iterator = list->GetIterator();
51 	boot::Partition *partition = NULL;
52 	while ((partition = (boot::Partition *)iterator.Next()) != NULL) {
53 		// ToDo: just take the first partition for now
54 		*_partition = partition;
55 		return B_OK;
56 	}
57 
58 	return B_ENTRY_NOT_FOUND;
59 }
60 
61 
62 status_t
63 platform_add_block_devices(stage2_args *args, NodeList *devicesList)
64 {
65 	TRACE("platform_add_block_devices\n");
66 	return B_OK;
67 }
68 
69 
70 status_t
71 platform_register_boot_device(Node *device)
72 {
73 	TRACE("platform_register_boot_device\n");
74 	return B_OK;
75 }
76