2 * Copyright (C) 2001-2003 Hewlett-Packard Co.
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
5 * This file is part of the ELILO, the EFI Linux boot loader.
7 * ELILO is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * ELILO is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with ELILO; see the file COPYING. If not, write to the Free
19 * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 * Please check out the elilo.txt for complete documentation on how
23 * to use this program.
27 * this file contains all the IA-64 specific code expected by generic loader
36 extern loader_ops_t plain_loader, gzip_loader;
39 * IA-64 specific boot paramters initialization routine
42 sysdeps_create_boot_params(boot_params_t *bp, CHAR8 *cmdline, memdesc_t *initrd, memdesc_t *vmcode, UINTN *cookie)
45 SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
50 * retrieve address of FPSWA interface
51 * if not found, argument is not touched
52 * will be 0 because of Memset()
54 query_fpswa((VOID **)&bp->fpswa);
56 if (get_memmap(&mdesc) == -1) return -1;
58 DBG_PRT((L"Got memory map @ 0x%lx (%d bytes) with key %d", mdesc.md, mdesc.map_size, mdesc.cookie));
60 bp->efi_systab = (UINTN)systab;
61 bp->efi_memmap = (UINTN)mdesc.md;
62 bp->efi_memmap_size = mdesc.map_size;
63 bp->efi_memdesc_size = mdesc.desc_size;
64 bp->efi_memdesc_version = mdesc.desc_version;
65 bp->command_line = (UINTN)cmdline;
66 bp->initrd_start = (UINTN) initrd->start_addr;
67 bp->initrd_size = initrd->size;
68 DBG_PRT((L"Got initrd @ 0x%lx (%d bytes)", initrd->start_addr, initrd->size));
70 bp->vmcode_start = (UINTN) vmcode->start_addr;
71 bp->vmcode_size = vmcode->size;
72 DBG_PRT((L"Got vmcode @ 0x%lx (%d bytes)", vmcode->start_addr, vmcode->size));
74 /* fetch console parameters: */
75 conout = systab->ConOut;
76 status = conout->QueryMode(conout, conout->Mode->Mode, &cols, &rows);
77 if (EFI_ERROR(status)) {
78 ERR_PRT((L"boot_params QueryMode failed %r", status));
81 DBG_PRT((L"Got console info: cols=%d rows=%d x=%d y=%d",
82 cols, rows, conout->Mode->CursorColumn, conout->Mode->CursorRow));
84 bp->console_info.num_cols = cols;
85 bp->console_info.num_rows = rows;
86 bp->console_info.orig_x = conout->Mode->CursorColumn;
87 bp->console_info.orig_y = conout->Mode->CursorRow;
89 *cookie = mdesc.cookie;
93 /* free descriptors' memory */
100 sysdeps_free_boot_params(boot_params_t *bp)
104 Memset(&md, 0, sizeof(md));
106 md.md = (VOID *)bp->efi_memmap;
112 sysdeps_init(EFI_HANDLE dev)
114 loader_register(&plain_loader);
115 loader_register(&gzip_loader);
121 sysdeps_initrd_get_addr(kdesc_t *kd, memdesc_t *imem)
124 * We currently place the initrd at the next page aligned boundary
127 * Current kernel implementation requires this (see arch/ia64/kernel/setup.c).
129 * IMPORTANT: EFI & kernel page sizes may differ. We have no way
130 * of guessing what size the kernel uses. It is the responsibility
131 * of the kernel to adjust.
135 imem->start_addr = (VOID *)ROUNDUP((UINTN)kd->kend, EFI_PAGE_SIZE);
137 imem->start_addr = 0; /* let the allocator decide */
143 /* Flush data cache [addr; addr + len], and sync with icache. */
145 flush_dcache (CHAR8 *addr, UINT64 len)
147 /* Cache line length is at least 32. */
148 UINT64 a = (UINT64)addr & ~0x1f;
150 DBG_PRT((L"Flush 0x%lx-", a));
153 for (len = (len + 31) & ~0x1f; len > 0; len -= 0x20, a += 0x20)
154 asm volatile ("fc %0" : : "r" (a));
155 /* Sync and serialize. Maybe extra. */
156 asm volatile (";; sync.i;; srlz.i;;");
158 DBG_PRT((L"0x%lx\n", a));