aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/test_com32.c
blob: 71b19d4c106f07a26868f7b7a42e16a1dd71e1d8 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <stdlib.h>
#include <console.h>

#include "elf_module.h"

#define KLIBC_NAME			"klibc.dyn"

#define ELF_DIRECTORY		"/dyn/"

static struct elf_module	*mod_klibc;

int modules_com32_setup() {
	int res;

	res = modules_init();

	if (res != 0)
		return res;

	////////////////////////////////////////
	// Load the klibc module

	// Create its associated structure
	mod_klibc = module_alloc(ELF_DIRECTORY KLIBC_NAME);

	if (mod_klibc == NULL) {
		return -1;
	}

	res = module_load(mod_klibc);

	if (res != 0) {
		return res;
	}

	return 0;
}

void modules_com32_finalize() {
	modules_term();
}

int main(int argc, char **argv) {
	int res;

	// Open a standard r/w console
	openconsole(&dev_stdcon_r, &dev_stdcon_w);

	// Initializing the module subsystem
	res = modules_com32_setup();

	if (res != 0) {
		printf("ERROR: Could not fully initialize the module!\n");
		return res;
	}

	modules_com32_finalize();

	return 0;
}