tmpfs(5): Remove old initialization (overrode prior init of vop_bmap).
[dragonfly.git] / sys / boot / ia64 / libski / efi_stub.c
blobcfce457351d7eefc3f150a56a4dd58d5664c70c9
1 /*
2 * Copyright (c) 2003 Marcel Moolenaar
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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>
32 #include <efi.h>
33 #include <stand.h>
34 #include "libski.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 = {
65 /* Header. */
66 { EFI_RUNTIME_SERVICES_SIGNATURE,
67 EFI_RUNTIME_SERVICES_REVISION,
68 0, /* XXX HeaderSize */
69 0, /* XXX CRC32 */
72 /* Time services */
73 GetTime,
74 SetTime,
75 GetWakeupTime,
76 SetWakeupTime,
78 /* Virtual memory services */
79 SetVirtualAddressMap,
80 ConvertPointer,
82 /* Variable services */
83 GetVariable,
84 GetNextVariableName,
85 SetVariable,
87 /* Misc */
88 GetNextHighMonotonicCount,
89 ResetSystem
92 EFI_SYSTEM_TABLE efi_systab = {
93 /* Header. */
94 { EFI_SYSTEM_TABLE_SIGNATURE,
95 EFI_SYSTEM_TABLE_REVISION,
96 0, /* XXX HeaderSize */
97 0, /* XXX CRC32 */
100 /* Firmware info. */
101 L"FreeBSD", 0,
103 /* Console stuff. */
104 NULL, NULL,
105 NULL, NULL,
106 NULL, NULL,
108 /* Services (runtime first). */
109 &efi_rttab,
110 NULL,
112 /* Configuration tables. */
113 sizeof(efi_cfgtab)/sizeof(EFI_CONFIGURATION_TABLE),
114 efi_cfgtab
117 static EFI_STATUS
118 unsupported(const char *func)
120 printf("EFI: %s not supported\n", func);
121 return (EFI_UNSUPPORTED);
124 static EFI_STATUS
125 GetTime(EFI_TIME *time, EFI_TIME_CAPABILITIES *caps)
127 UINT32 comps[8];
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;
138 time->TimeZone = 0;
139 time->Daylight = 0;
140 return (EFI_SUCCESS);
143 static EFI_STATUS
144 SetTime(EFI_TIME *time)
146 return (EFI_SUCCESS);
149 static EFI_STATUS
150 GetWakeupTime(BOOLEAN *enabled, BOOLEAN *pending, EFI_TIME *time)
152 return (unsupported(__func__));
155 static EFI_STATUS
156 SetWakeupTime(BOOLEAN enable, EFI_TIME *time)
158 return (unsupported(__func__));
161 static void
162 Reloc(void *addr, UINT64 delta)
164 UINT64 **fpp = addr;
166 *fpp[0] += delta;
167 *fpp[1] += delta;
168 *fpp += delta >> 3;
171 static EFI_STATUS
172 SetVirtualAddressMap(UINTN mapsz, UINTN descsz, UINT32 version,
173 EFI_MEMORY_DESCRIPTOR *memmap)
175 UINT64 delta;
177 delta = memmap->VirtualStart - memmap->PhysicalStart;
178 Reloc(&efi_rttab.GetTime, delta);
179 Reloc(&efi_rttab.SetTime, delta);
180 return (EFI_SUCCESS); /* Hah... */
183 static EFI_STATUS
184 ConvertPointer(UINTN debug, VOID **addr)
186 return (unsupported(__func__));
189 static EFI_STATUS
190 GetVariable(CHAR16 *name, EFI_GUID *vendor, UINT32 *attrs, UINTN *datasz,
191 VOID *data)
193 return (unsupported(__func__));
196 static EFI_STATUS
197 GetNextVariableName(UINTN *namesz, CHAR16 *name, EFI_GUID *vendor)
199 return (unsupported(__func__));
202 static EFI_STATUS
203 SetVariable(CHAR16 *name, EFI_GUID *vendor, UINT32 attrs, UINTN datasz,
204 VOID *data)
206 return (unsupported(__func__));
209 static EFI_STATUS
210 GetNextHighMonotonicCount(UINT32 *high)
212 static UINT32 counter = 0;
214 *high = counter++;
215 return (EFI_SUCCESS);
218 static EFI_STATUS
219 ResetSystem(EFI_RESET_TYPE type, EFI_STATUS status, UINTN datasz,
220 CHAR16 *data)
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;
264 sal_stub_init();
265 acpi_stub_init();
267 return (0);