File: system.c

package info (click to toggle)
elilo 3.2-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,356 kB
  • ctags: 2,507
  • sloc: ansic: 9,556; sh: 639; asm: 532; makefile: 196
file content (137 lines) | stat: -rw-r--r-- 3,596 bytes parent folder | download
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
 *  Copyright (C) 2001-2002 Hewlett-Packard Co.
 *	Contributed by Stephane Eranian <eranian@hpl.hp.com>
 *
 * This file is part of the ELILO, the EFI Linux boot loader.
 *
 *  ELILO is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  ELILO is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with ELILO; see the file COPYING.  If not, write to the Free
 *  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 *  02111-1307, USA.
 *
 * Please check out the elilo.txt for complete documentation on how
 * to use this program.
 */

/*
 * this file contains all the IA-64 specific code expected by generic loader
 */
#include <efi.h>
#include <efilib.h>

#include "elilo.h"
#include "loader.h"
#include "private.h"

extern loader_ops_t plain_loader, gzip_loader;

/*
 * IA-64 specific boot paramters initialization routine
 */
INTN
sysdeps_create_boot_params(boot_params_t *bp, CHAR8 *cmdline, memdesc_t *initrd, UINTN *cookie)
{
	UINTN cols, rows;
	SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
	EFI_STATUS status;
	mmap_desc_t mdesc;

	/*
	 * retrieve address of FPSWA interface
	 * if not found, argument is not touched
	 * will be 0 because of Memset()
	 */
	query_fpswa((VOID **)&bp->fpswa);

	if (get_memmap(&mdesc) == -1) return -1;

	DBG_PRT((L"Got memory map @ 0x%lx (%d bytes)", mdesc.md, mdesc.map_size));

	bp->efi_systab		= (UINTN)systab;
	bp->efi_memmap		= (UINTN)mdesc.md;
	bp->efi_memmap_size	= mdesc.map_size;
	bp->efi_memdesc_size	= mdesc.desc_size;
	bp->efi_memdesc_version = mdesc.desc_version;
	bp->command_line	= (UINTN)cmdline;
	bp->initrd_start	= (UINTN) initrd->start_addr;
	bp->initrd_size		= initrd->pgcnt << EFI_PAGE_SHIFT;

	/* fetch console parameters: */
	conout = systab->ConOut;
	status = conout->QueryMode(conout, conout->Mode->Mode, &cols, &rows);
	if (EFI_ERROR(status)) {
		ERR_PRT((L"boot_params QueryMode failed %r", status));
		goto error;
	}
	DBG_PRT((L"Got console info: cols=%d rows=%d x=%d y=%d",
	      cols, rows, conout->Mode->CursorColumn, conout->Mode->CursorRow));

	bp->console_info.num_cols = cols;
	bp->console_info.num_rows = rows;
	bp->console_info.orig_x = conout->Mode->CursorColumn;
	bp->console_info.orig_y = conout->Mode->CursorRow;

	*cookie = mdesc.cookie;

	return 0;
error:
	/* free descriptors' memory */
	free_memmap(&mdesc);

	return -1;
}

VOID
sysdeps_free_boot_params(boot_params_t *bp)
{
	mmap_desc_t md;

	Memset(&md, 0, sizeof(md));

	md.md = (VOID *)bp->efi_memmap;

	free_memmap(&md);
}

INTN
sysdeps_init(EFI_HANDLE dev)
{
	loader_register(&plain_loader);
	loader_register(&gzip_loader);

	return 0;
}

INTN
sysdeps_initrd_get_addr(kdesc_t *kd, memdesc_t *imem)
{
	/*
	 * We currently place the initrd at the next page aligned boundary
	 * after the kernel. 
	 *
	 * Current kernel implementation requires this (see arch/ia64/kernel/setup.c).
	 *
	 * IMPORTANT: EFI & kernel page sizes may differ. We have no way
	 * of guessing what size the kernel uses. It is the responsibility
	 * of the kernel to adjust.
	 *
	 */
#if 0
	imem->start_addr = (VOID *)ROUNDUP((UINTN)kd->kend, EFI_PAGE_SIZE);
#else
	imem->start_addr = 0; /* let the allocator decide */
#endif

	return 0;
}