prepare to upload
[debian/elilo] / ia32 / system.c
index 00a1f0a3d9e8ed299544e014d3b6be624a503e14..520946a44f1aaf9fe870b573da2ef9594bb2b9fb 100644 (file)
@@ -97,7 +97,10 @@ UINTN high_base_mem = 0x90000;
 UINTN high_ext_mem = 32 * 1024 * 1024;
 
 /* This starting address will hold true for all of the loader types for now */
-VOID *kernel_start = (VOID *)0x100000; /* 1M */
+VOID *kernel_start = (VOID *)DEFAULT_KERNEL_START;
+
+/* The kernel may load elsewhere if EFI firmware reserves kernel_start */
+VOID *kernel_load_address = (VOID *)DEFAULT_KERNEL_START;
 
 VOID *initrd_start = NULL;
 UINTN initrd_size = 0;
@@ -131,21 +134,27 @@ sysdeps_initrd_get_addr(kdesc_t *kd, memdesc_t *imem)
        DBG_PRT((L"initrd_get_addr()\n"));
 
        if (!kd || !imem) {
-               ERR_PRT((L"kd=0x%x imem=0x%x", kd, imem));
+               ERR_PRT((L"kd=" PTR_FMT " imem=" PTR_FMT, kd, imem));
                return -1;
        }
 
-       VERB_PRT(3, Print(L"kstart=0x%x  kentry=0x%x  kend=0x%x\n", 
+       VERB_PRT(3, Print(L"kstart=" PTR_FMT "  kentry=" PTR_FMT "  kend=" PTR_FMT "\n", 
                kd->kstart, kd->kentry, kd->kend));
 
        imem->start_addr = kd->kend;
 
-       VERB_PRT(3, Print(L"initrd start_addr=0x%x pgcnt=%d\n", 
+       VERB_PRT(3, Print(L"initrd start_addr=" PTR_FMT " pgcnt=%d\n", 
                imem->start_addr, imem->pgcnt));
 
        return 0;
 }
 
+VOID *
+sysdeps_checkfix_initrd(VOID *start_addr, memdesc_t *imem)
+{
+       return start_addr;
+}
+
 VOID
 sysdeps_free_boot_params(boot_params_t *bp)
 {
@@ -156,6 +165,24 @@ sysdeps_free_boot_params(boot_params_t *bp)
        free_memmap(&md);
 }
 
+static VOID find_bits(unsigned long mask, UINT8 *first, UINT8* len) {
+       unsigned char bit_pos = 0, bit_len = 0;
+       *first =0;
+       *len = 0;
+       if (mask == 0)
+               return;
+       while (!(mask & 0x1)) {
+               mask = mask >> 1;
+               bit_pos++;
+       }
+       while (mask & 0x1) {
+               mask = mask >> 1;
+               bit_len++;
+       }
+       *first = bit_pos;
+       *len = bit_len;
+}
+
 /*
  * Get video information.
  */
@@ -163,10 +190,11 @@ static INTN get_video_info(boot_params_t * bp) {
         EFI_GUID GopProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
         EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop_interface;
         EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Gop_info;
-        EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE   *Gop_mode;
-        EFI_HANDLE *Gop_handle;
+        EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE   *Gop_mode = NULL;
+        EFI_HANDLE *Gop_handle = NULL;
         EFI_STATUS efi_status;
-        UINTN size, size1;
+        UINTN size = 0;
+        UINTN size1;
         UINT8 i;
 
        efi_status = uefi_call_wrapper(
@@ -179,7 +207,19 @@ static INTN get_video_info(boot_params_t * bp) {
                        (VOID **)Gop_handle);
 
        if (EFI_ERROR(efi_status) && efi_status != EFI_BUFFER_TOO_SMALL) {
-               ERR_PRT((L"LocateHandle GopProtocol failed."));
+                Print(L"LocateHandle GopProtocol failed.\n");
+                Print(L"--Either no graphics head is installed,\n" \ 
+                       "--efi console is set to serial, or,\n" \
+                       "--the EFI firmware version of this machine is\n" \
+                       "--older than UEFI 2.0. and does not support GOP");
+                Print(L"you can SAFELY IGNORE this error. elilo will\n" \
+                       "default to text-mode.\n Alternatively you can " \
+                       "now force text mode by setting config variable\n" \
+                       "text_mode=1 for x86 in elilo.conf or via cmdline.\n\n");
+                Print(L"However if this is the last text output you see\n" \
+                       "ensure that your kernel console command line\n " \
+                       "variable matches up with the actual efi boot menu\n" \
+                       "console output settings. for example efi console\n\n");
                return -1;
        }
        Gop_handle = alloc(size, 0);
@@ -204,7 +244,7 @@ static INTN get_video_info(boot_params_t * bp) {
                                3,
                                *Gop_handle,
                                &GopProtocol,
-                               &Gop_interface);
+                               (VOID **) &Gop_interface);
 
                if (EFI_ERROR(efi_status)) {
                        continue;
@@ -428,7 +468,7 @@ sysdeps_create_boot_params(
        DBG_PRT((L"fill_boot_params()\n"));
 
        if (!bp || !cmdline || !initrd || !cookie) {
-               ERR_PRT((L"bp=0x%x  cmdline=0x%x  initrd=0x%x cookie=0x%x",
+               ERR_PRT((L"bp=" PTR_FMT "  cmdline=" PTR_FMT "  initrd=" PTR_FMT " cookie=" PTR_FMT,
                        bp, cmdline, initrd, cookie));
 
                if (param_start != NULL) {
@@ -515,7 +555,7 @@ sysdeps_create_boot_params(
         * Initial RAMdisk and root device stuff.
         */
 
-       DBG_PRT((L"initrd->start_addr=0x%x  initrd->pgcnt=%d\n",
+       DBG_PRT((L"initrd->start_addr=" PTR_FMT "  initrd->pgcnt=%d\n",
                initrd->start_addr, initrd->pgcnt));
 
        /* These RAMdisk flags are not needed, just zero them. */
@@ -597,7 +637,7 @@ sysdeps_create_boot_params(
 #define WAIT_FOR_KEY() \
 { \
        EFI_INPUT_KEY key; \
-       while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key) != EFI_SUCCESS) { \
+       while (uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &key) != EFI_SUCCESS) { \
                ; \
        } \
 }
@@ -697,7 +737,9 @@ sysdeps_create_boot_params(
 
        if (!get_video_info(bp)) goto do_memmap;
 
-       efi_status = ST->ConOut->QueryMode(
+       efi_status = uefi_call_wrapper(
+               ST->ConOut->QueryMode,
+               4,
                ST->ConOut,
                ST->ConOut->Mode->Mode,
                &cols,