summaryrefslogtreecommitdiff
path: root/kernel/mboot/module.c
blob: 7a64f2e94f9d4b6a2db873dd73a447ac623feaa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <comus/mboot.h>

#include "mboot.h"

#define MULTIBOOT_TAG_TYPE_MODULE 3

struct multiboot_tag_module {
	uint32_t type;
	uint32_t size;
	uint32_t mod_start;
	uint32_t mod_end;
	char cmdline[];
};

void *mboot_get_initrd(size_t *len)
{
	void *tag = locate_mboot_table(MULTIBOOT_TAG_TYPE_MODULE);
	if (tag == NULL)
		return NULL;

	struct multiboot_tag_module *mod = (struct multiboot_tag_module *)tag;
	*len = mod->mod_end - mod->mod_start;
	return (void*) (uintptr_t) mod->mod_start;
}