2 * Copyright (c) 2003 Marcel Moolenaar
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $FreeBSD: src/sys/boot/ia64/libski/efi_stub.c,v 1.2 2003/09/08 09:11:32 obrien Exp $
27 * $DragonFly: src/sys/boot/ia64/libski/efi_stub.c,v 1.1 2003/11/10 06:08:37 dillon Exp $
30 #include <sys/types.h>
31 #include <machine/bootinfo.h>
36 extern void acpi_root;
37 extern void sal_systab;
39 extern void acpi_stub_init(void);
40 extern void sal_stub_init(void);
42 EFI_CONFIGURATION_TABLE efi_cfgtab[] = {
43 { ACPI_20_TABLE_GUID, &acpi_root },
44 { SAL_SYSTEM_TABLE_GUID, &sal_systab }
48 static EFI_STATUS GetTime(EFI_TIME *, EFI_TIME_CAPABILITIES *);
49 static EFI_STATUS SetTime(EFI_TIME *);
50 static EFI_STATUS GetWakeupTime(BOOLEAN *, BOOLEAN *, EFI_TIME *);
51 static EFI_STATUS SetWakeupTime(BOOLEAN, EFI_TIME *);
53 static EFI_STATUS SetVirtualAddressMap(UINTN, UINTN, UINT32,
54 EFI_MEMORY_DESCRIPTOR*);
55 static EFI_STATUS ConvertPointer(UINTN, VOID **);
57 static EFI_STATUS GetVariable(CHAR16 *, EFI_GUID *, UINT32 *, UINTN *, VOID *);
58 static EFI_STATUS GetNextVariableName(UINTN *, CHAR16 *, EFI_GUID *);
59 static EFI_STATUS SetVariable(CHAR16 *, EFI_GUID *, UINT32, UINTN, VOID *);
61 static EFI_STATUS GetNextHighMonotonicCount(UINT32 *);
62 static EFI_STATUS ResetSystem(EFI_RESET_TYPE, EFI_STATUS, UINTN, CHAR16 *);
64 EFI_RUNTIME_SERVICES efi_rttab = {
66 { EFI_RUNTIME_SERVICES_SIGNATURE,
67 EFI_RUNTIME_SERVICES_REVISION,
68 0, /* XXX HeaderSize */
78 /* Virtual memory services */
82 /* Variable services */
88 GetNextHighMonotonicCount,
92 EFI_SYSTEM_TABLE efi_systab = {
94 { EFI_SYSTEM_TABLE_SIGNATURE,
95 EFI_SYSTEM_TABLE_REVISION,
96 0, /* XXX HeaderSize */
108 /* Services (runtime first). */
112 /* Configuration tables. */
113 sizeof(efi_cfgtab)/sizeof(EFI_CONFIGURATION_TABLE),
118 unsupported(const char *func)
120 printf("EFI: %s not supported\n", func);
121 return (EFI_UNSUPPORTED);
125 GetTime(EFI_TIME *time, EFI_TIME_CAPABILITIES *caps)
129 ssc((UINT64)comps, 0, 0, 0, SSC_GET_RTC);
130 time->Year = comps[0] + 1900;
131 time->Month = comps[1] + 1;
132 time->Day = comps[2];
133 time->Hour = comps[3];
134 time->Minute = comps[4];
135 time->Second = comps[5];
136 time->Pad1 = time->Pad2 = 0;
137 time->Nanosecond = 0;
140 return (EFI_SUCCESS);
144 SetTime(EFI_TIME *time)
146 return (EFI_SUCCESS);
150 GetWakeupTime(BOOLEAN *enabled, BOOLEAN *pending, EFI_TIME *time)
152 return (unsupported(__func__));
156 SetWakeupTime(BOOLEAN enable, EFI_TIME *time)
158 return (unsupported(__func__));
162 Reloc(void *addr, UINT64 delta)
172 SetVirtualAddressMap(UINTN mapsz, UINTN descsz, UINT32 version,
173 EFI_MEMORY_DESCRIPTOR *memmap)
177 delta = memmap->VirtualStart - memmap->PhysicalStart;
178 Reloc(&efi_rttab.GetTime, delta);
179 Reloc(&efi_rttab.SetTime, delta);
180 return (EFI_SUCCESS); /* Hah... */
184 ConvertPointer(UINTN debug, VOID **addr)
186 return (unsupported(__func__));
190 GetVariable(CHAR16 *name, EFI_GUID *vendor, UINT32 *attrs, UINTN *datasz,
193 return (unsupported(__func__));
197 GetNextVariableName(UINTN *namesz, CHAR16 *name, EFI_GUID *vendor)
199 return (unsupported(__func__));
203 SetVariable(CHAR16 *name, EFI_GUID *vendor, UINT32 attrs, UINTN datasz,
206 return (unsupported(__func__));
210 GetNextHighMonotonicCount(UINT32 *high)
212 static UINT32 counter = 0;
215 return (EFI_SUCCESS);
219 ResetSystem(EFI_RESET_TYPE type, EFI_STATUS status, UINTN datasz,
222 return (unsupported(__func__));
226 ski_init_stubs(struct bootinfo *bi)
228 EFI_MEMORY_DESCRIPTOR *memp;
230 /* Describe the SKI memory map. */
231 bi->bi_memmap = (u_int64_t)(bi + 1);
232 bi->bi_memmap_size = 4 * sizeof(EFI_MEMORY_DESCRIPTOR);
233 bi->bi_memdesc_size = sizeof(EFI_MEMORY_DESCRIPTOR);
234 bi->bi_memdesc_version = 1;
236 memp = (EFI_MEMORY_DESCRIPTOR *)bi->bi_memmap;
238 memp[0].Type = EfiPalCode;
239 memp[0].PhysicalStart = 0x100000;
240 memp[0].VirtualStart = 0;
241 memp[0].NumberOfPages = (4L*1024*1024)>>12;
242 memp[0].Attribute = EFI_MEMORY_WB | EFI_MEMORY_RUNTIME;
244 memp[1].Type = EfiConventionalMemory;
245 memp[1].PhysicalStart = 5L*1024*1024;
246 memp[1].VirtualStart = 0;
247 memp[1].NumberOfPages = (128L*1024*1024)>>12;
248 memp[1].Attribute = EFI_MEMORY_WB;
250 memp[2].Type = EfiConventionalMemory;
251 memp[2].PhysicalStart = 4L*1024*1024*1024;
252 memp[2].VirtualStart = 0;
253 memp[2].NumberOfPages = (64L*1024*1024)>>12;
254 memp[2].Attribute = EFI_MEMORY_WB;
256 memp[3].Type = EfiMemoryMappedIOPortSpace;
257 memp[3].PhysicalStart = 0xffffc000000;
258 memp[3].VirtualStart = 0;
259 memp[3].NumberOfPages = (64L*1024*1024)>>12;
260 memp[3].Attribute = EFI_MEMORY_UC;
262 bi->bi_systab = (u_int64_t)&efi_systab;