aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux/ldlinux.c
blob: b94010e328bb51112c3c2dec638d871080794859 (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
62
63
64
65
66
67
68
69
70
71
72
73
#include <linux/list.h>
#include <sys/times.h>
#include <stdbool.h>
#include <core-elf.h>
#include "cli.h"
#include "console.h"
#include "com32.h"
#include "menu.h"
#include "config.h"

#include <sys/module.h>

static void enter_cmdline(void)
{
	struct cli_command  *aux;
	char *cmdline;

	/* Enter endless command line prompt, should support "exit" */
	while (1) {
		cmdline = edit_cmdline("", 1, NULL, NULL);
		/* feng: give up the aux check here */
		//aux = list_entry(cli_history_head.next, typeof(*aux), list);
		//if (strcmp(aux->command, cmdline)) {
			process_command(cmdline, true);
		//}
	}
}

static void load_kernel(void)
{
	enum kernel_type type;

	if (defaultlevel == LEVEL_UI)
		type = KT_COM32;
	else
		type = KT_KERNEL;

	execute(default_cmd, type);
}

static int ldlinux_main(int argc, char **argv)
{
	openconsole(&dev_rawcon_r, &dev_ansiserial_w);

	parse_configs(NULL);

	/* TODO: ADV */
	/* TODO: Check KbdFlags? */

	if (forceprompt)
		goto cmdline;

	/*
	 * Auto boot
	 */
	if (defaultlevel || !noescape) {
		if (defaultlevel) {
			load_kernel();	/* Shouldn't return */
		} else {
			printf("No DEFAULT or UI configuration directive found!\n");

			if (noescape)
				kaboom();
		}
	}

cmdline:
	/* Should never return */
	enter_cmdline();

	return 0;
}
MODULE_MAIN(ldlinux_main);