aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux
diff options
context:
space:
mode:
Diffstat (limited to 'com32/elflink/ldlinux')
-rw-r--r--com32/elflink/ldlinux/Makefile8
-rw-r--r--com32/elflink/ldlinux/cli.c38
-rw-r--r--com32/elflink/ldlinux/config.h2
-rw-r--r--com32/elflink/ldlinux/eprintf.c36
-rw-r--r--com32/elflink/ldlinux/execute.c8
-rw-r--r--com32/elflink/ldlinux/ldlinux.c3
-rw-r--r--com32/elflink/ldlinux/msg.c86
-rw-r--r--com32/elflink/ldlinux/readconfig.c45
8 files changed, 102 insertions, 124 deletions
diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile
index 659aa405..bfec4503 100644
--- a/com32/elflink/ldlinux/Makefile
+++ b/com32/elflink/ldlinux/Makefile
@@ -1,6 +1,6 @@
## -----------------------------------------------------------------------
##
-## Copyright 2011 Intel Corporation - All Rights Reserved
+## Copyright 2011-2013 Intel Corporation - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -18,14 +18,14 @@ LIBS = --whole-archive $(objdir)/com32/lib/libcom32min.a
OBJS = ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o adv.o \
execute.o chainboot.o kernel.o get_key.o advwrite.o setadv.o \
- eprintf.o loadhigh.o msg.o
+ loadhigh.o msg.o
BTARGET = ldlinux.c32
all: $(BTARGET) ldlinux_lnx.a
-ldlinux.c32 : $(OBJS)
- $(LD) $(LDFLAGS) -soname $(@F) -o $@ $^ $(LIBS)
+ldlinux.elf : $(OBJS)
+ $(LD) $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^ $(LIBS)
LNXCFLAGS += -D__export='__attribute__((visibility("default")))'
LNXLIBOBJS = get_key.lo
diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index b94c6835..b85357b2 100644
--- a/com32/elflink/ldlinux/cli.c
+++ b/com32/elflink/ldlinux/cli.c
@@ -71,7 +71,7 @@ static const char * cmd_reverse_search(int *cursor, clock_t *kbd_to,
memset(buf, 0, MAX_CMDLINE_LEN);
- eprintf("\033[1G\033[1;36m(reverse-i-search)`': \033[0m");
+ printf("\033[1G\033[1;36m(reverse-i-search)`': \033[0m");
while (1) {
key = mygetkey_timeout(kbd_to, tto);
@@ -105,11 +105,11 @@ static const char * cmd_reverse_search(int *cursor, clock_t *kbd_to,
*cursor = p - last_good->command;
}
- eprintf("\033[?7l\033[?25l");
+ printf("\033[?7l\033[?25l");
/* Didn't handle the line wrap case here */
- eprintf("\033[1G\033[1;36m(reverse-i-search)\033[0m`%s': %s",
+ printf("\033[1G\033[1;36m(reverse-i-search)\033[0m`%s': %s",
buf, last_good->command ? : "");
- eprintf("\033[K\r");
+ printf("\033[K\r");
}
return last_good ? last_good->command : NULL;
@@ -147,7 +147,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
* so that it follows whatever text has been written to the screen
* previously.
*/
- eprintf("%s ", input);
+ printf("%s ", input);
while (!done) {
if (redraw > 1) {
@@ -158,7 +158,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
if (pDraw_Menu)
(*pDraw_Menu) (-1, top, 1);
prev_len = 0;
- eprintf("\033[2J\033[H");
+ printf("\033[2J\033[H");
// printf("\033[0m\033[2J\033[H");
}
@@ -168,8 +168,8 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
prev_len = max(len, prev_len);
/* Redraw the command line */
- eprintf("\033[?7l\033[?25l");
- eprintf("\033[1G%s ", input);
+ printf("\033[?7l\033[?25l");
+ printf("\033[1G%s ", input);
x = strlen(input);
y = 0;
@@ -179,23 +179,23 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
at++;
x++;
if (x >= width) {
- eprintf("\r\n");
+ printf("\r\n");
x = 0;
y++;
}
}
- eprintf("\033[K\r");
+ printf("\033[K\r");
dy = y - (cursor + strlen(input) + 1) / width;
x = (cursor + strlen(input) + 1) % width;
if (dy) {
- eprintf("\033[%dA", dy);
+ printf("\033[%dA", dy);
y -= dy;
}
if (x)
- eprintf("\033[%dC", x);
- eprintf("\033[?25h");
+ printf("\033[%dC", x);
+ printf("\033[?25h");
prev_len = len;
redraw = 0;
}
@@ -288,7 +288,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
cursor++;
x++;
if (x >= width) {
- eprintf("\r\n");
+ printf("\r\n");
y++;
x = 0;
}
@@ -418,10 +418,10 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
}
case KEY_CTRL('V'):
if (BIOSName)
- eprintf("%s%s%s", syslinux_banner,
- MK_PTR(0, BIOSName), copyright_str);
+ printf("%s%s%s", syslinux_banner,
+ (char *)MK_PTR(0, BIOSName), copyright_str);
else
- eprintf("%s%s", syslinux_banner, copyright_str);
+ printf("%s%s", syslinux_banner, copyright_str);
redraw = 1;
break;
@@ -435,7 +435,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
cursor++;
x++;
if (x >= width) {
- eprintf("\r\n\033[K");
+ printf("\r\n\033[K");
y++;
x = 0;
}
@@ -452,7 +452,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
}
}
- eprintf("\033[?7h");
+ printf("\033[?7h");
/* Add the command to the history */
comm_counter = malloc(sizeof(struct cli_command));
diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h
index c551fb19..242b7dc5 100644
--- a/com32/elflink/ldlinux/config.h
+++ b/com32/elflink/ldlinux/config.h
@@ -41,8 +41,6 @@ extern void cat_help_file(int key);
extern struct menu_entry *find_label(const char *str);
extern void print_labels(const char *prefix, size_t len);
-extern void eprintf(const char *filename, ...);
-
extern int new_linux_kernel(char *okernel, char *ocmdline);
extern void pm_load_high(com32sys_t *regs);
diff --git a/com32/elflink/ldlinux/eprintf.c b/com32/elflink/ldlinux/eprintf.c
deleted file mode 100644
index f15edc6e..00000000
--- a/com32/elflink/ldlinux/eprintf.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <core.h>
-
-#define BUFFER_SIZE 4096
-
-static void veprintf(const char *format, va_list ap)
-{
- int rv, _rv;
- char buffer[BUFFER_SIZE];
- char *p;
-
- _rv = rv = vsnprintf(buffer, BUFFER_SIZE, format, ap);
-
- if (rv < 0)
- return;
-
- if (rv > BUFFER_SIZE - 1)
- rv = BUFFER_SIZE - 1;
-
- p = buffer;
- while (rv--)
- write_serial(*p++);
-
- _fwrite(buffer, _rv, stdout);
-}
-
-void eprintf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- veprintf(format, ap);
- va_end(ap);
-}
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 727df50a..5c53b995 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -55,11 +55,9 @@ __export void execute(const char *cmdline, uint32_t type)
memset(&ireg, 0, sizeof ireg);
- /* for parameter will be passed to __intcall, we need use
- * lmalloc a block of low memory */
- q = lmalloc(128);
+ q = malloc(strlen(cmdline) + 2);
if (!q) {
- printf("%s(): Fail to lmalloc a buffer to exec %s\n",
+ printf("%s(): Fail to malloc a buffer to exec %s\n",
__func__, cmdline);
return;
}
@@ -147,7 +145,7 @@ __export void execute(const char *cmdline, uint32_t type)
new_linux_kernel((char *)kernel, (char *)cmdline);
}
- lfree((void *)kernel);
+ free((void *)kernel);
/* If this returns, something went bad; return to menu */
}
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index 6f9f20fa..a8b1b386 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -12,6 +12,7 @@
#include "config.h"
#include "syslinux/adv.h"
#include "syslinux/boot.h"
+#include "syslinux/config.h"
#include <sys/module.h>
@@ -290,6 +291,8 @@ __export int main(int argc __unused, char **argv __unused)
parse_configs(config_argv);
+ __syslinux_set_serial_console_info();
+
adv = syslinux_getadv(ADV_BOOTONCE, &count);
if (adv && count) {
/*
diff --git a/com32/elflink/ldlinux/msg.c b/com32/elflink/ldlinux/msg.c
index 2efcc792..9ded33ef 100644
--- a/com32/elflink/ldlinux/msg.c
+++ b/com32/elflink/ldlinux/msg.c
@@ -4,7 +4,7 @@
#include <graphics.h>
static uint8_t TextAttribute; /* Text attribute for message file */
-static uint8_t DisplayMask; /* Display modes mask */
+extern uint8_t DisplayMask; /* Display modes mask */
/* Routine to interpret next print char */
static void (*NextCharJump)(uint8_t);
@@ -42,27 +42,27 @@ int get_msg_file(char *filename)
if (ch == 0x1A)
break;
- /*
- * 01h = text mode
- * 02h = graphics mode
- */
- UsingVGA &= 0x1;
- UsingVGA += 1;
-
NextCharJump(ch); /* Do what shall be done */
}
+ DisplayMask = 0x07;
+
fclose(f);
return 0;
}
+static inline int display_mask_vga(void)
+{
+ uint8_t mask = UsingVGA & 0x1;
+ return (DisplayMask & ++mask);
+}
+
static void msg_setbg(uint8_t data)
{
if (unhexchar(&data) == 0) {
data <<= 4;
- if (DisplayMask & UsingVGA) {
+ if (display_mask_vga())
TextAttribute = data;
- }
NextCharJump = msg_setfg;
} else {
@@ -74,7 +74,7 @@ static void msg_setbg(uint8_t data)
static void msg_setfg(uint8_t data)
{
if (unhexchar(&data) == 0) {
- if (DisplayMask & UsingVGA) {
+ if (display_mask_vga()) {
/* setbg set foreground to 0 */
TextAttribute |= data;
}
@@ -89,6 +89,34 @@ static inline void msg_ctrl_o(void)
NextCharJump = msg_setbg;
}
+/* Convert ANSI colors to PC display attributes */
+static int convert_to_pcdisplay[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
+
+static void set_fgbg(void)
+{
+ uint8_t bg, fg;
+
+ fg = convert_to_pcdisplay[(TextAttribute & 0x7)];
+ bg = convert_to_pcdisplay[((TextAttribute >> 4) & 0x7)];
+
+ printf("\033[");
+ if (TextAttribute & 0x8)
+ printf("1;"); /* Foreground bright */
+
+ printf("3%dm\033[", fg);
+
+ if (TextAttribute & 0x80)
+ printf("5;"); /* Foreground blink */
+
+ printf("4%dm", bg);
+}
+
+static void msg_formfeed(void)
+{
+ set_fgbg();
+ printf("\033[2J\033[H\033[0m");
+}
+
static void msg_novga(void)
{
syslinux_force_text_mode();
@@ -138,36 +166,19 @@ static void msg_vga(void)
VGAFilePtr = (uint16_t *)VGAFileBuf;
}
-/* Convert ANSI colors to PC display attributes */
-static int convert_to_pcdisplay[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-
static void msg_normal(uint8_t data)
{
- uint8_t bg, fg;
-
- /* Write to serial port */
- if (DisplayMask & 0x4)
- write_serial(data);
+ /* 0x1 = text mode, 0x2 = graphics mode */
+ if (!display_mask_vga() || !(DisplayCon & 0x01)) {
+ /* Write to serial port */
+ if (DisplayMask & 0x4)
+ write_serial(data);
- if (!(DisplayMask & UsingVGA))
return; /* Not screen */
+ }
- if (!(DisplayCon & 0x01))
- return;
-
- fg = convert_to_pcdisplay[(TextAttribute & 0x7)];
- bg = convert_to_pcdisplay[((TextAttribute >> 4) & 0x7)];
-
- printf("\033[");
- if (TextAttribute & 0x40)
- printf("1;"); /* Foreground bright */
-
- printf("3%dm\033[", fg);
-
- if (TextAttribute & 0x80)
- printf("5;"); /* Foreground blink */
-
- printf("4%dm%c\033[0m", bg, data);
+ set_fgbg();
+ printf("%c\033[0m", data);
}
static void msg_modectl(uint8_t data)
@@ -191,6 +202,9 @@ static void msg_putchar(uint8_t ch)
break;
case 0x0D: /* Ignore <CR> */
break;
+ case 0x0C: /* <FF> = clear screen */
+ msg_formfeed();
+ break;
case 0x19: /* <EM> = return to text mode */
msg_novga();
break;
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 6a419c6d..a2421e95 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -26,6 +26,7 @@
#include <syslinux/config.h>
#include <dprintf.h>
#include <ctype.h>
+#include <bios.h>
#include <core.h>
#include <fs.h>
@@ -79,7 +80,6 @@ short allowoptions = 1; //user-specified options allowed
short includelevel = 1; //nesting level
short defaultlevel = 0; //the current level of default
short vkernel = 0; //have we seen any "label" statements?
-short displaycon = 1; //conio.inc
extern short NoHalt; //idle.c
const char *onerror = NULL; //"onerror" command line
@@ -442,12 +442,12 @@ void print_labels(const char *prefix, size_t len)
{
struct menu_entry *me;
- eprintf("\n");
+ printf("\n");
for (me = all_entries; me; me = me->next ) {
if (!strncmp(prefix, me->label, len))
- eprintf(" %s", me->label);
+ printf(" %s", me->label);
}
- eprintf("\n");
+ printf("\n");
}
struct menu_entry *find_label(const char *str)
@@ -498,18 +498,24 @@ static const char *unlabel(const char *str)
return str;
}
-static const char *refdup_word(char **p)
+static const char *__refdup_word(char *p, char **ref)
{
- char *sp = *p;
+ char *sp = p;
char *ep = sp;
while (*ep && !my_isspace(*ep))
ep++;
- *p = ep;
+ if (ref)
+ *ref = ep;
return refstrndup(sp, ep - sp);
}
+static const char *refdup_word(char **p)
+{
+ return __refdup_word(*p, p);
+}
+
int my_isxdigit(char c)
{
unsigned int uc = c;
@@ -690,7 +696,7 @@ void cat_help_file(int key)
return;
if (cm->fkeyhelp[fkey].textname) {
- eprintf("\n");
+ printf("\n");
get_msg_file((char *)cm->fkeyhelp[fkey].textname);
}
}
@@ -729,12 +735,6 @@ extern void sirq_cleanup_nowipe(void);
extern void sirq_install(void);
extern void write_serial_str(char *);
-static inline void io_delay(void)
-{
- outb(0, 0x80);
- outb(0, 0x80);
-}
-
extern void loadfont(char *);
extern void loadkeys(char *);
@@ -1065,8 +1065,8 @@ do_include:
p = skipspace(p + 5);
/* when first time see "label", it will not really record anything */
record(m, &ld, append);
- ld.label = refstrdup(p);
- ld.kernel = refstrdup(p);
+ ld.label = __refdup_word(p, NULL);
+ ld.kernel = __refdup_word(p, NULL);
/* feng: this is the default type for all */
ld.type = KT_KERNEL;
ld.passwd = NULL;
@@ -1174,7 +1174,7 @@ do_include:
} else if (looking_at(p, "prompt")) {
forceprompt = atoi(skipspace(p + 6));
} else if (looking_at(p, "console")) {
- displaycon = atoi(skipspace(p + 7));
+ DisplayCon = atoi(skipspace(p + 7));
} else if (looking_at(p, "allowoptions")) {
allowoptions = atoi(skipspace(p + 12));
} else if (looking_at(p, "noescape")) {
@@ -1311,8 +1311,9 @@ do_include:
write_serial_str(syslinux_banner);
write_serial_str(copyright_str);
}
+
} else if (looking_at(p, "say")) {
- eprintf("%s\n", p+4);
+ printf("%s\n", p+4);
} else if (looking_at(p, "path")) {
/* PATH-based lookup */
const char *new_path;
@@ -1331,7 +1332,7 @@ do_include:
free(PATH);
PATH = _p;
} else
- eprintf("Failed to realloc PATH\n");
+ printf("Failed to realloc PATH\n");
}
}
}
@@ -1350,15 +1351,15 @@ static int parse_one_config(const char *filename)
if (fd < 0)
return fd;
- f = fdopen(fd, mode);
- parse_config_file(f);
-
if (config_cwd[0]) {
if (chdir(config_cwd) < 0)
printf("Failed to chdir to %s\n", config_cwd);
config_cwd[0] = '\0';
}
+ f = fdopen(fd, mode);
+ parse_config_file(f);
+
return 0;
}