Imported Upstream version 3.14
[debian/elilo] / choosers / textmenu.c
index 3210dda1b91e8344d2af5569e382d89440baceea..52021a91bb7296b9614f978b202dfcad4d562142 100644 (file)
@@ -1,6 +1,10 @@
 /* 
  *  Copyright (C) 2001-2003 Hewlett-Packard Co.
  *     Contributed by Richard Hirst <rhirst@linuxcare.com>
+ *  Copyright (C) 2006-2009 Intel Corporation
+ *     Contributed by Fenghua Yu <fenghua.yu@intel.com>
+ *     Contributed by Bibo Mao <bibo.mao@intel.com>
+ *     Contributed by Chandramouli Narayanan <mouli@linux.intel.com>
  *
  * This file is part of the ELILO, the EFI Linux boot loader.
  *
@@ -27,6 +31,7 @@
 #include <efilib.h>
 
 #include "elilo.h"
+#include "console.h"
 
 #define MAX_LABELS     64
 #define MSGBUFLEN      4096
@@ -45,8 +50,8 @@ static CHAR16 PromptBuf[CMDLINE_MAXLEN];
 #define DEF_ATTR       EFI_TEXT_ATTR(EFI_LIGHTGRAY,EFI_BLACK)
 
 
-#define ClearScreen()  ST->ConOut->ClearScreen(ST->ConOut)
-#define SetTextAttr(a) ST->ConOut->SetAttribute(ST->ConOut, a)
+#define ClearScreen()  uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut)
+#define SetTextAttr(a) uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, a)
 
 static INTN
 tohex(INTN c)
@@ -182,12 +187,12 @@ paint_menu(VOID)
 }
 
 static INTN
-read_message_file(INTN msg, INT8 *buf, INTN max)
+read_message_file(INTN msg, UINT8 *buf, UINTN max)
 {
        CHAR16 *filename;
        fops_fd_t message_fd;
        EFI_STATUS status;
-       INTN len = max;
+       UINTN len = max;
 
        if (msg > 10) return 0;
 
@@ -249,7 +254,8 @@ reprint:
        SetTextAttr(CurrentAttr);
 
        for (;;) {
-               while ((status=ip->ReadKeyStroke(ip, &key)) == EFI_NOT_READY);
+               while ((status = uefi_call_wrapper(ip->ReadKeyStroke, 2, ip, &key)) 
+                       == EFI_NOT_READY);
                if (EFI_ERROR(status)) {
                        SetTextAttr(EFI_TEXT_ATTR(EFI_LIGHTGRAY,EFI_BLACK));
                        ClearScreen();
@@ -295,7 +301,7 @@ reprint:
                        if (i) {
                                msgbuf[i] = 0;
                                paint_msg(msgbuf);
-                               while ((status=ip->ReadKeyStroke(ip, &key)) == EFI_NOT_READY);
+                               while ((status= uefi_call_wrapper(ip->ReadKeyStroke, 2, ip, &key)) == EFI_NOT_READY);
                                goto reprint;
                        }
                }
@@ -357,10 +363,10 @@ textmenu_choose(CHAR16 **argv, INTN argc, INTN index, CHAR16 *kname, CHAR16 *cmd
 {      
 #      define BOOT_IMG_STR     L"BOOT_IMAGE="
        CHAR16 label[CMDLINE_MAXLEN];
-       CHAR16 initrd_name[CMDLINE_MAXLEN];
-       CHAR16 vmcode_name[CMDLINE_MAXLEN];
+       CHAR16 initrd_name[PATHNAME_MAXLEN];
+       CHAR16 vmcode_name[PATHNAME_MAXLEN];
        CHAR16 args[CMDLINE_MAXLEN];
-       CHAR16 devname[CMDLINE_MAXLEN];
+       CHAR16 devname[PATHNAME_MAXLEN];
        CHAR16 dpath[FILENAME_MAXLEN];
        CHAR16 *slash_pos, *colon_pos, *backslash_pos;
        UINTN len;
@@ -389,6 +395,7 @@ restart:
        Memset(&elilo_opt.img_opt, 0, sizeof(elilo_opt.img_opt));
 
        if (elilo_opt.prompt) {
+               console_textmode();
                ret = select_kernel(label, sizeof(label));
                if (ret == -1) return -1;
                argc    = argify(PromptBuf,sizeof(PromptBuf), argv); 
@@ -461,11 +468,11 @@ restart:
 
        if (elilo_opt.prompt == 0) {
                /* minimal printing */
-               Print(L"ELILO\n");
+               Print(L"ELILO v%s for EFI/%a\n", ELILO_VERSION, ELILO_ARCH);
                ret = wait_timeout(elilo_opt.delay);
                if (ret != 0) {
                        elilo_opt.prompt = 1;
-                       elilo_opt.initrd[0] = CHAR_NULL;
+                       elilo_opt.initrd[0] = elilo_opt.vmcode[0] = CHAR_NULL;
                        elilo_opt.timeout =  ELILO_TIMEOUT_INFINITY;
                        goto restart;
                }