summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2003-02-01 22:50:09 +0000
committermarcel <marcel@FreeBSD.org>2003-02-01 22:50:09 +0000
commit389e4c3a2a331c3d7194d0a3252e266dd42daa80 (patch)
treeaeaa0efb42081601d640cc4f467d7de7fc56a1df /sys
parent785fe397ccfcda0950251b71412f7936ad68b224 (diff)
downloadFreeBSD-src-389e4c3a2a331c3d7194d0a3252e266dd42daa80.zip
FreeBSD-src-389e4c3a2a331c3d7194d0a3252e266dd42daa80.tar.gz
Remove special casing for running in the simulator from the kernel
and instead add platform, firmware and EFI stubs to the loader. The net effect of this change is that besides a special console and disk driver, the kernel has no knowledge of the simulator. This has the following advantages: o Simulator support is much harder to break, o It's easier to make use of more feature complete simulators. This would only need a change in the simulator specific loader, o Running SMP kernels within the simulator. Note that ski at this time does not simulate IPIs, so there's no way to start APs. The platform, firmware and EFI stubs describe the following hardware: o 4 CPU Itanium, o 128 MB RAM within the 4GB address space, o 64 MB RAM above the 4GB address space. NOTE: The stubs in the skiloader describe a machine that should in parts be defined by the simulator. Things like processor interrupt block and AP wakeup vector cannot be choosen at random because they require interpretation by the simulator. Currently the simulator is ignorant of this. This change introduces an unofficial SSC call SSC_SAL_SET_VECTORS which is ignored by the simulator. Tested with: ski (version 0.943 for linux)
Diffstat (limited to 'sys')
-rw-r--r--sys/boot/ia64/Makefile.inc2
-rw-r--r--sys/boot/ia64/libski/Makefile1
-rw-r--r--sys/boot/ia64/libski/acpi_stub.c193
-rw-r--r--sys/boot/ia64/libski/bootinfo.c26
-rw-r--r--sys/boot/ia64/libski/efi_stub.c267
-rw-r--r--sys/boot/ia64/libski/elf_freebsd.c4
-rw-r--r--sys/boot/ia64/libski/libski.h1
-rw-r--r--sys/boot/ia64/libski/pal_stub.S65
-rw-r--r--sys/boot/ia64/libski/pal_stub.s (renamed from sys/ia64/ia64/pal_stub.s)67
-rw-r--r--sys/boot/ia64/libski/sal_stub.c117
-rw-r--r--sys/boot/ia64/libski/ssc.c12
-rw-r--r--sys/boot/ia64/ski/acpi_stub.c193
-rw-r--r--sys/boot/ia64/ski/bootinfo.c26
-rw-r--r--sys/boot/ia64/ski/efi_stub.c267
-rw-r--r--sys/boot/ia64/ski/elf_freebsd.c4
-rw-r--r--sys/boot/ia64/ski/libski.h1
-rw-r--r--sys/boot/ia64/ski/pal_stub.S65
-rw-r--r--sys/boot/ia64/ski/sal_stub.c117
-rw-r--r--sys/boot/ia64/ski/ssc.c12
-rw-r--r--sys/conf/files.ia642
-rw-r--r--sys/ia64/conf/SKI70
-rw-r--r--sys/ia64/ia64/autoconf.c3
-rw-r--r--sys/ia64/ia64/efi.c62
-rw-r--r--sys/ia64/ia64/machdep.c67
-rw-r--r--sys/ia64/ia64/mca.c17
-rw-r--r--sys/ia64/ia64/pal.S15
-rw-r--r--sys/ia64/ia64/pal.s15
-rw-r--r--sys/ia64/ia64/pmap.c4
-rw-r--r--sys/ia64/ia64/sal.c2
-rw-r--r--sys/ia64/ia64/ski.c163
-rw-r--r--sys/ia64/ia64/ssc.c5
-rw-r--r--sys/ia64/ia64/sscdisk.c3
-rw-r--r--sys/ia64/include/md_var.h1
-rw-r--r--sys/ia64/include/sal.h1
34 files changed, 1419 insertions, 451 deletions
diff --git a/sys/boot/ia64/Makefile.inc b/sys/boot/ia64/Makefile.inc
index 81a6d5a..3000e04 100644
--- a/sys/boot/ia64/Makefile.inc
+++ b/sys/boot/ia64/Makefile.inc
@@ -1,4 +1,4 @@
# $FreeBSD$
# Options used when building standalone components
-CFLAGS+= -ffreestanding
+CFLAGS+= -ffreestanding -fshort-wchar -Wformat
diff --git a/sys/boot/ia64/libski/Makefile b/sys/boot/ia64/libski/Makefile
index b6da2c8..92a70a0 100644
--- a/sys/boot/ia64/libski/Makefile
+++ b/sys/boot/ia64/libski/Makefile
@@ -5,6 +5,7 @@ INTERNALLIB= true
SRCS= skiconsole.c time.c copy.c devicename.c module.c exit.c
SRCS+= delay.c skifs.c elf_freebsd.c bootinfo.c ssc.c
+SRCS+= acpi_stub.c efi_stub.c pal_stub.s sal_stub.c
CFLAGS+= -ffreestanding -fpic -g
CFLAGS+= -I${.CURDIR}/../include
diff --git a/sys/boot/ia64/libski/acpi_stub.c b/sys/boot/ia64/libski/acpi_stub.c
new file mode 100644
index 0000000..3187925
--- /dev/null
+++ b/sys/boot/ia64/libski/acpi_stub.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2003 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <contrib/dev/acpica/acpi.h>
+
+#define APIC_IO_SAPIC 6
+#define APIC_LOCAL_SAPIC 7
+
+#pragma pack(1)
+
+typedef struct /* LOCAL SAPIC */
+{
+ APIC_HEADER Header;
+ UINT8 ProcessorId; /* ACPI processor id */
+ UINT8 LocalSapicId; /* Processor local SAPIC id */
+ UINT8 LocalSapicEid; /* Processor local SAPIC eid */
+ UINT8 Reserved[3];
+ UINT32 ProcessorEnabled: 1;
+ UINT32 FlagsReserved: 31;
+} LOCAL_SAPIC;
+
+typedef struct /* IO SAPIC */
+{
+ APIC_HEADER Header;
+ UINT8 IoSapicId; /* I/O SAPIC ID */
+ UINT8 Reserved; /* reserved - must be zero */
+ UINT32 Vector; /* interrupt base */
+ UINT64 IoSapicAddress; /* SAPIC's physical address */
+} IO_SAPIC;
+
+/*
+ */
+
+struct {
+ APIC_TABLE Header;
+ LOCAL_SAPIC cpu0;
+ LOCAL_SAPIC cpu1;
+ LOCAL_SAPIC cpu2;
+ LOCAL_SAPIC cpu3;
+ IO_SAPIC sapic;
+} apic = {
+ /* Header. */
+ {
+ {
+ APIC_SIG, /* Signature. */
+ sizeof(apic), /* Length of table. */
+ 0, /* ACPI minor revision. */
+ 0, /* XXX checksum. */
+ "FBSD", /* OEM Id. */
+ "SKI", /* OEM table Id. */
+ 0, /* OEM revision. */
+ "FBSD", /* ASL compiler Id. */
+ 0 /* ASL revision. */
+ },
+ 0xfee00000,
+ },
+ /* cpu0. */
+ {
+ {
+ APIC_LOCAL_SAPIC, /* Type. */
+ sizeof(apic.cpu0) /* Length. */
+ },
+ 0, /* ACPI processor id */
+ 0, /* Processor local SAPIC id */
+ 0, /* Processor local SAPIC eid */
+ { 0, 0, 0 },
+ 1, /* FL: Enabled. */
+ },
+ /* cpu1. */
+ {
+ {
+ APIC_LOCAL_SAPIC, /* Type. */
+ sizeof(apic.cpu1) /* Length. */
+ },
+ 1, /* ACPI processor id */
+ 0, /* Processor local SAPIC id */
+ 1, /* Processor local SAPIC eid */
+ { 0, 0, 0 },
+ 1, /* FL: Enabled. */
+ },
+ /* cpu2. */
+ {
+ {
+ APIC_LOCAL_SAPIC, /* Type. */
+ sizeof(apic.cpu2) /* Length. */
+ },
+ 2, /* ACPI processor id */
+ 1, /* Processor local SAPIC id */
+ 0, /* Processor local SAPIC eid */
+ { 0, 0, 0 },
+ 0, /* FL: Enabled. */
+ },
+ /* cpu3. */
+ {
+ {
+ APIC_LOCAL_SAPIC, /* Type. */
+ sizeof(apic.cpu3) /* Length. */
+ },
+ 3, /* ACPI processor id */
+ 1, /* Processor local SAPIC id */
+ 1, /* Processor local SAPIC eid */
+ { 0, 0, 0 },
+ 0, /* FL: Enabled. */
+ },
+ /* sapic. */
+ {
+ {
+ APIC_IO_SAPIC, /* Type. */
+ sizeof(apic.sapic) /* Length. */
+ },
+ 4, /* IO SAPIC id. */
+ 0,
+ 16, /* Interrupt base. */
+ 0xfec00000 /* IO SAPIC address. */
+ }
+};
+
+struct {
+ ACPI_TABLE_HEADER Header;
+ UINT64 apic_tbl;
+} xsdt = {
+ {
+ XSDT_SIG, /* Signature. */
+ sizeof(xsdt), /* Length of table. */
+ 0, /* ACPI minor revision. */
+ 0, /* XXX checksum. */
+ "FBSD", /* OEM Id. */
+ "SKI", /* OEM table Id. */
+ 0, /* OEM revision. */
+ "FBSD", /* ASL compiler Id. */
+ 0 /* ASL revision. */
+ },
+ NULL /* XXX APIC table address. */
+};
+
+RSDP_DESCRIPTOR acpi_root = {
+ RSDP_SIG,
+ 0, /* XXX checksum. */
+ "FBSD",
+ 2, /* ACPI Rev 2.0. */
+ NULL,
+ sizeof(xsdt), /* XSDT length. */
+ NULL, /* XXX PA of XSDT. */
+ 0, /* XXX Extended checksum. */
+};
+
+static void
+cksum(void *addr, int sz, UINT8 *sum)
+{
+ UINT8 *p, s;
+
+ p = addr;
+ s = 0;
+ while (sz--)
+ s += *p++;
+ *sum = -s;
+}
+
+void
+acpi_stub_init(void)
+{
+ acpi_root.XsdtPhysicalAddress = (UINT64)&xsdt;
+ cksum(&acpi_root, 20, &acpi_root.Checksum);
+ cksum(&acpi_root, sizeof(acpi_root), &acpi_root.ExtendedChecksum);
+
+ xsdt.apic_tbl = (UINT32)&apic;
+ cksum(&xsdt, sizeof(xsdt), &xsdt.Header.Checksum);
+}
diff --git a/sys/boot/ia64/libski/bootinfo.c b/sys/boot/ia64/libski/bootinfo.c
index 0a18ec7..91f691a 100644
--- a/sys/boot/ia64/libski/bootinfo.c
+++ b/sys/boot/ia64/libski/bootinfo.c
@@ -34,8 +34,6 @@
#include <machine/elf.h>
#include <machine/bootinfo.h>
-#include <efi.h>
-
#include "bootstrap.h"
/*
@@ -60,6 +58,7 @@ static struct
};
extern char *ski_fmtdev(void *vdev);
+extern int ski_init_stubs(struct bootinfo *);
int
bi_getboothowto(char *kargs)
@@ -250,7 +249,6 @@ bi_load(struct bootinfo *bi, struct preloaded_file *fp, char *args)
char *kernelname;
vm_offset_t ssym, esym;
struct file_metadata *md;
- EFI_MEMORY_DESCRIPTOR *memp;
/*
* Version 1 bootinfo.
@@ -320,25 +318,5 @@ bi_load(struct bootinfo *bi, struct preloaded_file *fp, char *args)
/* all done copying stuff in, save end of loaded object space */
bi->bi_kernend = addr;
- /* Describe the SKI memory map. */
- bi->bi_memmap = (u_int64_t)(bi + 1);
- bi->bi_memmap_size = 2 * sizeof(EFI_MEMORY_DESCRIPTOR);
- bi->bi_memdesc_size = sizeof(EFI_MEMORY_DESCRIPTOR);
- bi->bi_memdesc_version = 1;
-
- memp = (EFI_MEMORY_DESCRIPTOR *) bi->bi_memmap;
-
- memp[0].Type = EfiConventionalMemory;
- memp[0].PhysicalStart = 2L*1024*1024;
- memp[0].VirtualStart = 0;
- memp[0].NumberOfPages = (64L*1024*1024)>>12;
- memp[0].Attribute = EFI_MEMORY_WB;
-
- memp[1].Type = EfiMemoryMappedIOPortSpace;
- memp[1].PhysicalStart = 0xffffc000000;
- memp[1].VirtualStart = 0;
- memp[1].NumberOfPages = (64L*1024*1024)>>12;
- memp[1].Attribute = EFI_MEMORY_UC;
-
- return(0);
+ return (ski_init_stubs(bi));
}
diff --git a/sys/boot/ia64/libski/efi_stub.c b/sys/boot/ia64/libski/efi_stub.c
new file mode 100644
index 0000000..36f72c3
--- /dev/null
+++ b/sys/boot/ia64/libski/efi_stub.c
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2003 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <machine/bootinfo.h>
+#include <efi.h>
+#include <stand.h>
+#include "libski.h"
+
+extern void acpi_root;
+extern void sal_systab;
+
+extern void acpi_stub_init(void);
+extern void sal_stub_init(void);
+
+EFI_CONFIGURATION_TABLE efi_cfgtab[] = {
+ { ACPI_20_TABLE_GUID, &acpi_root },
+ { SAL_SYSTEM_TABLE_GUID, &sal_systab }
+};
+
+
+static EFI_STATUS GetTime(EFI_TIME *, EFI_TIME_CAPABILITIES *);
+static EFI_STATUS SetTime(EFI_TIME *);
+static EFI_STATUS GetWakeupTime(BOOLEAN *, BOOLEAN *, EFI_TIME *);
+static EFI_STATUS SetWakeupTime(BOOLEAN, EFI_TIME *);
+
+static EFI_STATUS SetVirtualAddressMap(UINTN, UINTN, UINT32,
+ EFI_MEMORY_DESCRIPTOR*);
+static EFI_STATUS ConvertPointer(UINTN, VOID **);
+
+static EFI_STATUS GetVariable(CHAR16 *, EFI_GUID *, UINT32 *, UINTN *, VOID *);
+static EFI_STATUS GetNextVariableName(UINTN *, CHAR16 *, EFI_GUID *);
+static EFI_STATUS SetVariable(CHAR16 *, EFI_GUID *, UINT32, UINTN, VOID *);
+
+static EFI_STATUS GetNextHighMonotonicCount(UINT32 *);
+static EFI_STATUS ResetSystem(EFI_RESET_TYPE, EFI_STATUS, UINTN, CHAR16 *);
+
+EFI_RUNTIME_SERVICES efi_rttab = {
+ /* Header. */
+ { EFI_RUNTIME_SERVICES_SIGNATURE,
+ EFI_RUNTIME_SERVICES_REVISION,
+ 0, /* XXX HeaderSize */
+ 0, /* XXX CRC32 */
+ },
+
+ /* Time services */
+ GetTime,
+ SetTime,
+ GetWakeupTime,
+ SetWakeupTime,
+
+ /* Virtual memory services */
+ SetVirtualAddressMap,
+ ConvertPointer,
+
+ /* Variable services */
+ GetVariable,
+ GetNextVariableName,
+ SetVariable,
+
+ /* Misc */
+ GetNextHighMonotonicCount,
+ ResetSystem
+};
+
+EFI_SYSTEM_TABLE efi_systab = {
+ /* Header. */
+ { EFI_SYSTEM_TABLE_SIGNATURE,
+ EFI_SYSTEM_TABLE_REVISION,
+ 0, /* XXX HeaderSize */
+ 0, /* XXX CRC32 */
+ },
+
+ /* Firmware info. */
+ L"FreeBSD", 0,
+
+ /* Console stuff. */
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL,
+
+ /* Services (runtime first). */
+ &efi_rttab,
+ NULL,
+
+ /* Configuration tables. */
+ sizeof(efi_cfgtab)/sizeof(EFI_CONFIGURATION_TABLE),
+ efi_cfgtab
+};
+
+static EFI_STATUS
+unsupported(const char *func)
+{
+ printf("EFI: %s not supported\n", func);
+ return (EFI_UNSUPPORTED);
+}
+
+static EFI_STATUS
+GetTime(EFI_TIME *time, EFI_TIME_CAPABILITIES *caps)
+{
+ UINT32 comps[8];
+
+ ssc((UINT64)comps, 0, 0, 0, SSC_GET_RTC);
+ time->Year = comps[0] + 1900;
+ time->Month = comps[1] + 1;
+ time->Day = comps[2];
+ time->Hour = comps[3];
+ time->Minute = comps[4];
+ time->Second = comps[5];
+ time->Pad1 = time->Pad2 = 0;
+ time->Nanosecond = 0;
+ time->TimeZone = 0;
+ time->Daylight = 0;
+ return (EFI_SUCCESS);
+}
+
+static EFI_STATUS
+SetTime(EFI_TIME *time)
+{
+ return (EFI_SUCCESS);
+}
+
+static EFI_STATUS
+GetWakeupTime(BOOLEAN *enabled, BOOLEAN *pending, EFI_TIME *time)
+{
+ return (unsupported(__func__));
+}
+
+static EFI_STATUS
+SetWakeupTime(BOOLEAN enable, EFI_TIME *time)
+{
+ return (unsupported(__func__));
+}
+
+static void
+Reloc(void *addr, UINT64 delta)
+{
+ UINT64 **fpp = addr;
+
+ *fpp[0] += delta;
+ *fpp[1] += delta;
+ *fpp += delta >> 3;
+}
+
+static EFI_STATUS
+SetVirtualAddressMap(UINTN mapsz, UINTN descsz, UINT32 version,
+ EFI_MEMORY_DESCRIPTOR *memmap)
+{
+ UINT64 delta;
+
+ delta = memmap->VirtualStart - memmap->PhysicalStart;
+ Reloc(&efi_rttab.GetTime, delta);
+ Reloc(&efi_rttab.SetTime, delta);
+ return (EFI_SUCCESS); /* Hah... */
+}
+
+static EFI_STATUS
+ConvertPointer(UINTN debug, VOID **addr)
+{
+ return (unsupported(__func__));
+}
+
+static EFI_STATUS
+GetVariable(CHAR16 *name, EFI_GUID *vendor, UINT32 *attrs, UINTN *datasz,
+ VOID *data)
+{
+ return (unsupported(__func__));
+}
+
+static EFI_STATUS
+GetNextVariableName(UINTN *namesz, CHAR16 *name, EFI_GUID *vendor)
+{
+ return (unsupported(__func__));
+}
+
+static EFI_STATUS
+SetVariable(CHAR16 *name, EFI_GUID *vendor, UINT32 attrs, UINTN datasz,
+ VOID *data)
+{
+ return (unsupported(__func__));
+}
+
+static EFI_STATUS
+GetNextHighMonotonicCount(UINT32 *high)
+{
+ static UINT32 counter = 0;
+
+ *high = counter++;
+ return (EFI_SUCCESS);
+}
+
+static EFI_STATUS
+ResetSystem(EFI_RESET_TYPE type, EFI_STATUS status, UINTN datasz,
+ CHAR16 *data)
+{
+ return (unsupported(__func__));
+}
+
+int
+ski_init_stubs(struct bootinfo *bi)
+{
+ EFI_MEMORY_DESCRIPTOR *memp;
+
+ /* Describe the SKI memory map. */
+ bi->bi_memmap = (u_int64_t)(bi + 1);
+ bi->bi_memmap_size = 4 * sizeof(EFI_MEMORY_DESCRIPTOR);
+ bi->bi_memdesc_size = sizeof(EFI_MEMORY_DESCRIPTOR);
+ bi->bi_memdesc_version = 1;
+
+ memp = (EFI_MEMORY_DESCRIPTOR *)bi->bi_memmap;
+
+ memp[0].Type = EfiPalCode;
+ memp[0].PhysicalStart = 0x100000;
+ memp[0].VirtualStart = 0;
+ memp[0].NumberOfPages = (4L*1024*1024)>>12;
+ memp[0].Attribute = EFI_MEMORY_WB | EFI_MEMORY_RUNTIME;
+
+ memp[1].Type = EfiConventionalMemory;
+ memp[1].PhysicalStart = 5L*1024*1024;
+ memp[1].VirtualStart = 0;
+ memp[1].NumberOfPages = (128L*1024*1024)>>12;
+ memp[1].Attribute = EFI_MEMORY_WB;
+
+ memp[2].Type = EfiConventionalMemory;
+ memp[2].PhysicalStart = 4L*1024*1024*1024;
+ memp[2].VirtualStart = 0;
+ memp[2].NumberOfPages = (64L*1024*1024)>>12;
+ memp[2].Attribute = EFI_MEMORY_WB;
+
+ memp[3].Type = EfiMemoryMappedIOPortSpace;
+ memp[3].PhysicalStart = 0xffffc000000;
+ memp[3].VirtualStart = 0;
+ memp[3].NumberOfPages = (64L*1024*1024)>>12;
+ memp[3].Attribute = EFI_MEMORY_UC;
+
+ bi->bi_systab = (u_int64_t)&efi_systab;
+
+ sal_stub_init();
+ acpi_stub_init();
+
+ return (0);
+}
diff --git a/sys/boot/ia64/libski/elf_freebsd.c b/sys/boot/ia64/libski/elf_freebsd.c
index 461ef12..e72a52d 100644
--- a/sys/boot/ia64/libski/elf_freebsd.c
+++ b/sys/boot/ia64/libski/elf_freebsd.c
@@ -130,6 +130,8 @@ struct ia64_pte {
u_int64_t pte_ig :11; /* bits 53..63 */
};
+static struct bootinfo bootinfo;
+
void
enter_kernel(const char* filename, u_int64_t start, struct bootinfo *bi)
{
@@ -167,7 +169,7 @@ elf_exec(struct preloaded_file *fp)
* Ugly hack, similar to linux. Dump the bootinfo into a
* special page reserved in the link map.
*/
- bi = (struct bootinfo *) 0x508000;
+ bi = &bootinfo;
bzero(bi, sizeof(struct bootinfo));
bi_load(bi, fp);
diff --git a/sys/boot/ia64/libski/libski.h b/sys/boot/ia64/libski/libski.h
index bb3f1dd..043177c 100644
--- a/sys/boot/ia64/libski/libski.h
+++ b/sys/boot/ia64/libski/libski.h
@@ -90,6 +90,7 @@ extern int bi_load(struct bootinfo *, struct preloaded_file *);
#define SSC_GET_RTC 65
#define SSC_EXIT 66
#define SSC_LOAD_SYMBOLS 69
+#define SSC_SAL_SET_VECTORS 120
u_int64_t ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3,
int which);
diff --git a/sys/boot/ia64/libski/pal_stub.S b/sys/boot/ia64/libski/pal_stub.S
new file mode 100644
index 0000000..e67204c
--- /dev/null
+++ b/sys/boot/ia64/libski/pal_stub.S
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2003 Marcel Moolenaar
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+
+ .text
+ENTRY(PalProc, 0)
+ cmp.eq p6,p0=6,r28 // PAL_PTCE_INFO
+(p6) br.cond.dptk pal_ptce_info
+ ;;
+ cmp.eq p6,p0=8,r28 // PAL_VM_SUMMARY
+(p6) br.cond.dptk pal_vm_summary
+ ;;
+ cmp.eq p6,p0=14,r28 // PAL_FREQ_RATIOS
+(p6) br.cond.dptk pal_freq_ratios
+ ;;
+ mov r15=66 // EXIT
+ break.i 0x80000 // SSC
+ ;;
+pal_ptce_info:
+ mov r8=0
+ mov r9=0 // base
+ movl r10=0x0000000100000001 // loop counts (outer|inner)
+ mov r11=0x0000000000000000 // loop strides (outer|inner)
+ br.sptk b0
+pal_vm_summary:
+ mov r8=0
+ movl r9=(8<<40)|(8<<32) // VM info 1
+ mov r10=(18<<8)|(41<<0) // VM info 2
+ mov r11=0
+ br.sptk b0
+pal_freq_ratios:
+ mov r8=0
+ movl r9=0x0000000B00000002 // processor ratio 11/2
+ movl r10=0x0000000100000001 // bus ratio 1/1
+ movl r11=0x0000000B00000002 // ITC ratio 11/2
+ br.sptk b0
+END(PalProc)
diff --git a/sys/ia64/ia64/pal_stub.s b/sys/boot/ia64/libski/pal_stub.s
index b91d02c..e67204c 100644
--- a/sys/ia64/ia64/pal_stub.s
+++ b/sys/boot/ia64/libski/pal_stub.s
@@ -1,10 +1,12 @@
-/*-
+/*
+ * Copyright (c) 2003 Marcel Moolenaar
* Copyright (c) 2001 Doug Rabson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
+ *
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@@ -23,44 +25,41 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD$
*/
#include <machine/asm.h>
-#include <assym.s>
-
-/*
- * Stub for running in simulation. Fakes the values from an SDV.
- */
-ENTRY(ski_fake_pal, 0)
- mov r8=-3 // default to return error
-
- cmp.eq p6,p0=PAL_PTCE_INFO,r28
- ;;
-(p6) mov r8=0
-(p6) mov r9=0
-(p6) movl r10=0x100000001
-(p6) mov r11=0
+ .text
+ENTRY(PalProc, 0)
+ cmp.eq p6,p0=6,r28 // PAL_PTCE_INFO
+(p6) br.cond.dptk pal_ptce_info
;;
- cmp.eq p6,p0=PAL_FREQ_RATIOS,r28
+ cmp.eq p6,p0=8,r28 // PAL_VM_SUMMARY
+(p6) br.cond.dptk pal_vm_summary
;;
-(p6) mov r8=0
-(p6) movl r9=0xb00000002 // proc 11/1
-(p6) movl r10=0x100000001 // bus 1/1
-(p6) movl r11=0xb00000002 // itc 11/1
- mov r14=PAL_VM_SUMMARY
+ cmp.eq p6,p0=14,r28 // PAL_FREQ_RATIOS
+(p6) br.cond.dptk pal_freq_ratios
;;
- cmp.eq p6,p0=r14,r28
- ;;
-(p6) mov r8=0
-(p6) movl r9=(8<<40)|(8<<32)
-(p6) movl r10=(18<<8)|(41<<0)
-(p6) mov r11=0
+ mov r15=66 // EXIT
+ break.i 0x80000 // SSC
;;
- tbit.nz p6,p7=r28,8 // static or stacked?
- ;;
-(p6) br.ret.sptk.few rp
-(p7) br.cond.sptk.few rp
-
-END(ski_fake_pal)
+pal_ptce_info:
+ mov r8=0
+ mov r9=0 // base
+ movl r10=0x0000000100000001 // loop counts (outer|inner)
+ mov r11=0x0000000000000000 // loop strides (outer|inner)
+ br.sptk b0
+pal_vm_summary:
+ mov r8=0
+ movl r9=(8<<40)|(8<<32) // VM info 1
+ mov r10=(18<<8)|(41<<0) // VM info 2
+ mov r11=0
+ br.sptk b0
+pal_freq_ratios:
+ mov r8=0
+ movl r9=0x0000000B00000002 // processor ratio 11/2
+ movl r10=0x0000000100000001 // bus ratio 1/1
+ movl r11=0x0000000B00000002 // ITC ratio 11/2
+ br.sptk b0
+END(PalProc)
diff --git a/sys/boot/ia64/libski/sal_stub.c b/sys/boot/ia64/libski/sal_stub.c
new file mode 100644
index 0000000..caa6671
--- /dev/null
+++ b/sys/boot/ia64/libski/sal_stub.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2003 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <machine/md_var.h>
+#include <machine/sal.h>
+#include <stand.h>
+#include "libski.h"
+
+extern void PalProc(void);
+static sal_entry_t SalProc;
+
+struct {
+ struct sal_system_table header;
+ struct sal_entrypoint_descriptor entry;
+ struct sal_ap_wakeup_descriptor wakeup;
+} sal_systab = {
+ /* Header. */
+ {
+ SAL_SIGNATURE,
+ sizeof(sal_systab),
+ { 00, 03 }, /* Revision 3.0. */
+ 2, /* Number of decsriptors. */
+ 0, /* XXX checksum. */
+ { 0 },
+ { 00, 00 }, /* XXX SAL_A version. */
+ { 00, 00 }, /* XXX SAL_B version. */
+ "FreeBSD",
+ "Ski loader",
+ { 0 }
+ },
+ /* Entrypoint. */
+ {
+ 0, /* Type=entrypoint descr. */
+ { 0 },
+ 0, /* XXX PalProc. */
+ 0, /* XXX SalProc. */
+ 0, /* XXX SalProc GP. */
+ { 0 }
+ },
+ /* AP wakeup. */
+ {
+ 5, /* Type=AP wakeup descr. */
+ 0, /* External interrupt. */
+ { 0 },
+ 255 /* Wakeup vector. */
+ }
+};
+
+static inline void
+puts(const char *s)
+{
+ s = (const char *)((7UL << 61) | (u_long)s);
+ while (*s)
+ ski_cons_putchar(*s++);
+}
+
+static struct ia64_sal_result
+SalProc(u_int64_t a1, u_int64_t a2, u_int64_t a3, u_int64_t a4, u_int64_t a5,
+ u_int64_t a6, u_int64_t a7, u_int64_t a8)
+{
+ struct ia64_sal_result res;
+
+ res.sal_status = -3;
+ res.sal_result[0] = 0;
+ res.sal_result[1] = 0;
+ res.sal_result[2] = 0;
+
+ if (a1 == SAL_FREQ_BASE) {
+ res.sal_status = 0;
+ res.sal_result[0] = 133338184;
+ } else if (a1 == SAL_SET_VECTORS) {
+ /* XXX unofficial SSC function. */
+ ssc(a2, a3, a4, a5, SSC_SAL_SET_VECTORS);
+ } else if (a1 != SAL_GET_STATE_INFO_SIZE) {
+ puts("SAL: unimplemented function called\n");
+ }
+
+ return (res);
+}
+
+void
+sal_stub_init(void)
+{
+ struct ia64_fdesc *fd;
+
+ fd = (void*)PalProc;
+ sal_systab.entry.sale_pal_proc = fd->func;
+ fd = (void*)SalProc;
+ sal_systab.entry.sale_sal_proc = fd->func;
+ sal_systab.entry.sale_sal_gp = fd->gp;
+}
diff --git a/sys/boot/ia64/libski/ssc.c b/sys/boot/ia64/libski/ssc.c
index 11a91c8..e3e9eb2 100644
--- a/sys/boot/ia64/libski/ssc.c
+++ b/sys/boot/ia64/libski/ssc.c
@@ -29,14 +29,24 @@
#include <stand.h>
#include "libski.h"
+/*
+ * Ugh... Work around a bug in the Linux version of ski for SSC_GET_RTC. The
+ * PSR.dt register is not preserved properly and causes further memory
+ * references to be done without translation. All we need to do is preserve
+ * PSR.dt across the SSC call. We do this by saving and restoring psr.l
+ * completely.
+ */
u_int64_t
ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which)
{
+ register u_int64_t psr;
register u_int64_t ret0 __asm("r8");
+ __asm __volatile("mov %0=psr;;" : "=r"(psr));
__asm __volatile("mov r15=%1\n\t"
- "break 0x80000"
+ "break 0x80000;;"
: "=r"(ret0)
: "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3));
+ __asm __volatile("mov psr.l=%0;; srlz.d" :: "r"(psr));
return ret0;
}
diff --git a/sys/boot/ia64/ski/acpi_stub.c b/sys/boot/ia64/ski/acpi_stub.c
new file mode 100644
index 0000000..3187925
--- /dev/null
+++ b/sys/boot/ia64/ski/acpi_stub.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2003 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <contrib/dev/acpica/acpi.h>
+
+#define APIC_IO_SAPIC 6
+#define APIC_LOCAL_SAPIC 7
+
+#pragma pack(1)
+
+typedef struct /* LOCAL SAPIC */
+{
+ APIC_HEADER Header;
+ UINT8 ProcessorId; /* ACPI processor id */
+ UINT8 LocalSapicId; /* Processor local SAPIC id */
+ UINT8 LocalSapicEid; /* Processor local SAPIC eid */
+ UINT8 Reserved[3];
+ UINT32 ProcessorEnabled: 1;
+ UINT32 FlagsReserved: 31;
+} LOCAL_SAPIC;
+
+typedef struct /* IO SAPIC */
+{
+ APIC_HEADER Header;
+ UINT8 IoSapicId; /* I/O SAPIC ID */
+ UINT8 Reserved; /* reserved - must be zero */
+ UINT32 Vector; /* interrupt base */
+ UINT64 IoSapicAddress; /* SAPIC's physical address */
+} IO_SAPIC;
+
+/*
+ */
+
+struct {
+ APIC_TABLE Header;
+ LOCAL_SAPIC cpu0;
+ LOCAL_SAPIC cpu1;
+ LOCAL_SAPIC cpu2;
+ LOCAL_SAPIC cpu3;
+ IO_SAPIC sapic;
+} apic = {
+ /* Header. */
+ {
+ {
+ APIC_SIG, /* Signature. */
+ sizeof(apic), /* Length of table. */
+ 0, /* ACPI minor revision. */
+ 0, /* XXX checksum. */
+ "FBSD", /* OEM Id. */
+ "SKI", /* OEM table Id. */
+ 0, /* OEM revision. */
+ "FBSD", /* ASL compiler Id. */
+ 0 /* ASL revision. */
+ },
+ 0xfee00000,
+ },
+ /* cpu0. */
+ {
+ {
+ APIC_LOCAL_SAPIC, /* Type. */
+ sizeof(apic.cpu0) /* Length. */
+ },
+ 0, /* ACPI processor id */
+ 0, /* Processor local SAPIC id */
+ 0, /* Processor local SAPIC eid */
+ { 0, 0, 0 },
+ 1, /* FL: Enabled. */
+ },
+ /* cpu1. */
+ {
+ {
+ APIC_LOCAL_SAPIC, /* Type. */
+ sizeof(apic.cpu1) /* Length. */
+ },
+ 1, /* ACPI processor id */
+ 0, /* Processor local SAPIC id */
+ 1, /* Processor local SAPIC eid */
+ { 0, 0, 0 },
+ 1, /* FL: Enabled. */
+ },
+ /* cpu2. */
+ {
+ {
+ APIC_LOCAL_SAPIC, /* Type. */
+ sizeof(apic.cpu2) /* Length. */
+ },
+ 2, /* ACPI processor id */
+ 1, /* Processor local SAPIC id */
+ 0, /* Processor local SAPIC eid */
+ { 0, 0, 0 },
+ 0, /* FL: Enabled. */
+ },
+ /* cpu3. */
+ {
+ {
+ APIC_LOCAL_SAPIC, /* Type. */
+ sizeof(apic.cpu3) /* Length. */
+ },
+ 3, /* ACPI processor id */
+ 1, /* Processor local SAPIC id */
+ 1, /* Processor local SAPIC eid */
+ { 0, 0, 0 },
+ 0, /* FL: Enabled. */
+ },
+ /* sapic. */
+ {
+ {
+ APIC_IO_SAPIC, /* Type. */
+ sizeof(apic.sapic) /* Length. */
+ },
+ 4, /* IO SAPIC id. */
+ 0,
+ 16, /* Interrupt base. */
+ 0xfec00000 /* IO SAPIC address. */
+ }
+};
+
+struct {
+ ACPI_TABLE_HEADER Header;
+ UINT64 apic_tbl;
+} xsdt = {
+ {
+ XSDT_SIG, /* Signature. */
+ sizeof(xsdt), /* Length of table. */
+ 0, /* ACPI minor revision. */
+ 0, /* XXX checksum. */
+ "FBSD", /* OEM Id. */
+ "SKI", /* OEM table Id. */
+ 0, /* OEM revision. */
+ "FBSD", /* ASL compiler Id. */
+ 0 /* ASL revision. */
+ },
+ NULL /* XXX APIC table address. */
+};
+
+RSDP_DESCRIPTOR acpi_root = {
+ RSDP_SIG,
+ 0, /* XXX checksum. */
+ "FBSD",
+ 2, /* ACPI Rev 2.0. */
+ NULL,
+ sizeof(xsdt), /* XSDT length. */
+ NULL, /* XXX PA of XSDT. */
+ 0, /* XXX Extended checksum. */
+};
+
+static void
+cksum(void *addr, int sz, UINT8 *sum)
+{
+ UINT8 *p, s;
+
+ p = addr;
+ s = 0;
+ while (sz--)
+ s += *p++;
+ *sum = -s;
+}
+
+void
+acpi_stub_init(void)
+{
+ acpi_root.XsdtPhysicalAddress = (UINT64)&xsdt;
+ cksum(&acpi_root, 20, &acpi_root.Checksum);
+ cksum(&acpi_root, sizeof(acpi_root), &acpi_root.ExtendedChecksum);
+
+ xsdt.apic_tbl = (UINT32)&apic;
+ cksum(&xsdt, sizeof(xsdt), &xsdt.Header.Checksum);
+}
diff --git a/sys/boot/ia64/ski/bootinfo.c b/sys/boot/ia64/ski/bootinfo.c
index 0a18ec7..91f691a 100644
--- a/sys/boot/ia64/ski/bootinfo.c
+++ b/sys/boot/ia64/ski/bootinfo.c
@@ -34,8 +34,6 @@
#include <machine/elf.h>
#include <machine/bootinfo.h>
-#include <efi.h>
-
#include "bootstrap.h"
/*
@@ -60,6 +58,7 @@ static struct
};
extern char *ski_fmtdev(void *vdev);
+extern int ski_init_stubs(struct bootinfo *);
int
bi_getboothowto(char *kargs)
@@ -250,7 +249,6 @@ bi_load(struct bootinfo *bi, struct preloaded_file *fp, char *args)
char *kernelname;
vm_offset_t ssym, esym;
struct file_metadata *md;
- EFI_MEMORY_DESCRIPTOR *memp;
/*
* Version 1 bootinfo.
@@ -320,25 +318,5 @@ bi_load(struct bootinfo *bi, struct preloaded_file *fp, char *args)
/* all done copying stuff in, save end of loaded object space */
bi->bi_kernend = addr;
- /* Describe the SKI memory map. */
- bi->bi_memmap = (u_int64_t)(bi + 1);
- bi->bi_memmap_size = 2 * sizeof(EFI_MEMORY_DESCRIPTOR);
- bi->bi_memdesc_size = sizeof(EFI_MEMORY_DESCRIPTOR);
- bi->bi_memdesc_version = 1;
-
- memp = (EFI_MEMORY_DESCRIPTOR *) bi->bi_memmap;
-
- memp[0].Type = EfiConventionalMemory;
- memp[0].PhysicalStart = 2L*1024*1024;
- memp[0].VirtualStart = 0;
- memp[0].NumberOfPages = (64L*1024*1024)>>12;
- memp[0].Attribute = EFI_MEMORY_WB;
-
- memp[1].Type = EfiMemoryMappedIOPortSpace;
- memp[1].PhysicalStart = 0xffffc000000;
- memp[1].VirtualStart = 0;
- memp[1].NumberOfPages = (64L*1024*1024)>>12;
- memp[1].Attribute = EFI_MEMORY_UC;
-
- return(0);
+ return (ski_init_stubs(bi));
}
diff --git a/sys/boot/ia64/ski/efi_stub.c b/sys/boot/ia64/ski/efi_stub.c
new file mode 100644
index 0000000..36f72c3
--- /dev/null
+++ b/sys/boot/ia64/ski/efi_stub.c
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2003 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <machine/bootinfo.h>
+#include <efi.h>
+#include <stand.h>
+#include "libski.h"
+
+extern void acpi_root;
+extern void sal_systab;
+
+extern void acpi_stub_init(void);
+extern void sal_stub_init(void);
+
+EFI_CONFIGURATION_TABLE efi_cfgtab[] = {
+ { ACPI_20_TABLE_GUID, &acpi_root },
+ { SAL_SYSTEM_TABLE_GUID, &sal_systab }
+};
+
+
+static EFI_STATUS GetTime(EFI_TIME *, EFI_TIME_CAPABILITIES *);
+static EFI_STATUS SetTime(EFI_TIME *);
+static EFI_STATUS GetWakeupTime(BOOLEAN *, BOOLEAN *, EFI_TIME *);
+static EFI_STATUS SetWakeupTime(BOOLEAN, EFI_TIME *);
+
+static EFI_STATUS SetVirtualAddressMap(UINTN, UINTN, UINT32,
+ EFI_MEMORY_DESCRIPTOR*);
+static EFI_STATUS ConvertPointer(UINTN, VOID **);
+
+static EFI_STATUS GetVariable(CHAR16 *, EFI_GUID *, UINT32 *, UINTN *, VOID *);
+static EFI_STATUS GetNextVariableName(UINTN *, CHAR16 *, EFI_GUID *);
+static EFI_STATUS SetVariable(CHAR16 *, EFI_GUID *, UINT32, UINTN, VOID *);
+
+static EFI_STATUS GetNextHighMonotonicCount(UINT32 *);
+static EFI_STATUS ResetSystem(EFI_RESET_TYPE, EFI_STATUS, UINTN, CHAR16 *);
+
+EFI_RUNTIME_SERVICES efi_rttab = {
+ /* Header. */
+ { EFI_RUNTIME_SERVICES_SIGNATURE,
+ EFI_RUNTIME_SERVICES_REVISION,
+ 0, /* XXX HeaderSize */
+ 0, /* XXX CRC32 */
+ },
+
+ /* Time services */
+ GetTime,
+ SetTime,
+ GetWakeupTime,
+ SetWakeupTime,
+
+ /* Virtual memory services */
+ SetVirtualAddressMap,
+ ConvertPointer,
+
+ /* Variable services */
+ GetVariable,
+ GetNextVariableName,
+ SetVariable,
+
+ /* Misc */
+ GetNextHighMonotonicCount,
+ ResetSystem
+};
+
+EFI_SYSTEM_TABLE efi_systab = {
+ /* Header. */
+ { EFI_SYSTEM_TABLE_SIGNATURE,
+ EFI_SYSTEM_TABLE_REVISION,
+ 0, /* XXX HeaderSize */
+ 0, /* XXX CRC32 */
+ },
+
+ /* Firmware info. */
+ L"FreeBSD", 0,
+
+ /* Console stuff. */
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL,
+
+ /* Services (runtime first). */
+ &efi_rttab,
+ NULL,
+
+ /* Configuration tables. */
+ sizeof(efi_cfgtab)/sizeof(EFI_CONFIGURATION_TABLE),
+ efi_cfgtab
+};
+
+static EFI_STATUS
+unsupported(const char *func)
+{
+ printf("EFI: %s not supported\n", func);
+ return (EFI_UNSUPPORTED);
+}
+
+static EFI_STATUS
+GetTime(EFI_TIME *time, EFI_TIME_CAPABILITIES *caps)
+{
+ UINT32 comps[8];
+
+ ssc((UINT64)comps, 0, 0, 0, SSC_GET_RTC);
+ time->Year = comps[0] + 1900;
+ time->Month = comps[1] + 1;
+ time->Day = comps[2];
+ time->Hour = comps[3];
+ time->Minute = comps[4];
+ time->Second = comps[5];
+ time->Pad1 = time->Pad2 = 0;
+ time->Nanosecond = 0;
+ time->TimeZone = 0;
+ time->Daylight = 0;
+ return (EFI_SUCCESS);
+}
+
+static EFI_STATUS
+SetTime(EFI_TIME *time)
+{
+ return (EFI_SUCCESS);
+}
+
+static EFI_STATUS
+GetWakeupTime(BOOLEAN *enabled, BOOLEAN *pending, EFI_TIME *time)
+{
+ return (unsupported(__func__));
+}
+
+static EFI_STATUS
+SetWakeupTime(BOOLEAN enable, EFI_TIME *time)
+{
+ return (unsupported(__func__));
+}
+
+static void
+Reloc(void *addr, UINT64 delta)
+{
+ UINT64 **fpp = addr;
+
+ *fpp[0] += delta;
+ *fpp[1] += delta;
+ *fpp += delta >> 3;
+}
+
+static EFI_STATUS
+SetVirtualAddressMap(UINTN mapsz, UINTN descsz, UINT32 version,
+ EFI_MEMORY_DESCRIPTOR *memmap)
+{
+ UINT64 delta;
+
+ delta = memmap->VirtualStart - memmap->PhysicalStart;
+ Reloc(&efi_rttab.GetTime, delta);
+ Reloc(&efi_rttab.SetTime, delta);
+ return (EFI_SUCCESS); /* Hah... */
+}
+
+static EFI_STATUS
+ConvertPointer(UINTN debug, VOID **addr)
+{
+ return (unsupported(__func__));
+}
+
+static EFI_STATUS
+GetVariable(CHAR16 *name, EFI_GUID *vendor, UINT32 *attrs, UINTN *datasz,
+ VOID *data)
+{
+ return (unsupported(__func__));
+}
+
+static EFI_STATUS
+GetNextVariableName(UINTN *namesz, CHAR16 *name, EFI_GUID *vendor)
+{
+ return (unsupported(__func__));
+}
+
+static EFI_STATUS
+SetVariable(CHAR16 *name, EFI_GUID *vendor, UINT32 attrs, UINTN datasz,
+ VOID *data)
+{
+ return (unsupported(__func__));
+}
+
+static EFI_STATUS
+GetNextHighMonotonicCount(UINT32 *high)
+{
+ static UINT32 counter = 0;
+
+ *high = counter++;
+ return (EFI_SUCCESS);
+}
+
+static EFI_STATUS
+ResetSystem(EFI_RESET_TYPE type, EFI_STATUS status, UINTN datasz,
+ CHAR16 *data)
+{
+ return (unsupported(__func__));
+}
+
+int
+ski_init_stubs(struct bootinfo *bi)
+{
+ EFI_MEMORY_DESCRIPTOR *memp;
+
+ /* Describe the SKI memory map. */
+ bi->bi_memmap = (u_int64_t)(bi + 1);
+ bi->bi_memmap_size = 4 * sizeof(EFI_MEMORY_DESCRIPTOR);
+ bi->bi_memdesc_size = sizeof(EFI_MEMORY_DESCRIPTOR);
+ bi->bi_memdesc_version = 1;
+
+ memp = (EFI_MEMORY_DESCRIPTOR *)bi->bi_memmap;
+
+ memp[0].Type = EfiPalCode;
+ memp[0].PhysicalStart = 0x100000;
+ memp[0].VirtualStart = 0;
+ memp[0].NumberOfPages = (4L*1024*1024)>>12;
+ memp[0].Attribute = EFI_MEMORY_WB | EFI_MEMORY_RUNTIME;
+
+ memp[1].Type = EfiConventionalMemory;
+ memp[1].PhysicalStart = 5L*1024*1024;
+ memp[1].VirtualStart = 0;
+ memp[1].NumberOfPages = (128L*1024*1024)>>12;
+ memp[1].Attribute = EFI_MEMORY_WB;
+
+ memp[2].Type = EfiConventionalMemory;
+ memp[2].PhysicalStart = 4L*1024*1024*1024;
+ memp[2].VirtualStart = 0;
+ memp[2].NumberOfPages = (64L*1024*1024)>>12;
+ memp[2].Attribute = EFI_MEMORY_WB;
+
+ memp[3].Type = EfiMemoryMappedIOPortSpace;
+ memp[3].PhysicalStart = 0xffffc000000;
+ memp[3].VirtualStart = 0;
+ memp[3].NumberOfPages = (64L*1024*1024)>>12;
+ memp[3].Attribute = EFI_MEMORY_UC;
+
+ bi->bi_systab = (u_int64_t)&efi_systab;
+
+ sal_stub_init();
+ acpi_stub_init();
+
+ return (0);
+}
diff --git a/sys/boot/ia64/ski/elf_freebsd.c b/sys/boot/ia64/ski/elf_freebsd.c
index 461ef12..e72a52d 100644
--- a/sys/boot/ia64/ski/elf_freebsd.c
+++ b/sys/boot/ia64/ski/elf_freebsd.c
@@ -130,6 +130,8 @@ struct ia64_pte {
u_int64_t pte_ig :11; /* bits 53..63 */
};
+static struct bootinfo bootinfo;
+
void
enter_kernel(const char* filename, u_int64_t start, struct bootinfo *bi)
{
@@ -167,7 +169,7 @@ elf_exec(struct preloaded_file *fp)
* Ugly hack, similar to linux. Dump the bootinfo into a
* special page reserved in the link map.
*/
- bi = (struct bootinfo *) 0x508000;
+ bi = &bootinfo;
bzero(bi, sizeof(struct bootinfo));
bi_load(bi, fp);
diff --git a/sys/boot/ia64/ski/libski.h b/sys/boot/ia64/ski/libski.h
index bb3f1dd..043177c 100644
--- a/sys/boot/ia64/ski/libski.h
+++ b/sys/boot/ia64/ski/libski.h
@@ -90,6 +90,7 @@ extern int bi_load(struct bootinfo *, struct preloaded_file *);
#define SSC_GET_RTC 65
#define SSC_EXIT 66
#define SSC_LOAD_SYMBOLS 69
+#define SSC_SAL_SET_VECTORS 120
u_int64_t ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3,
int which);
diff --git a/sys/boot/ia64/ski/pal_stub.S b/sys/boot/ia64/ski/pal_stub.S
new file mode 100644
index 0000000..e67204c
--- /dev/null
+++ b/sys/boot/ia64/ski/pal_stub.S
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2003 Marcel Moolenaar
+ * Copyright (c) 2001 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+
+ .text
+ENTRY(PalProc, 0)
+ cmp.eq p6,p0=6,r28 // PAL_PTCE_INFO
+(p6) br.cond.dptk pal_ptce_info
+ ;;
+ cmp.eq p6,p0=8,r28 // PAL_VM_SUMMARY
+(p6) br.cond.dptk pal_vm_summary
+ ;;
+ cmp.eq p6,p0=14,r28 // PAL_FREQ_RATIOS
+(p6) br.cond.dptk pal_freq_ratios
+ ;;
+ mov r15=66 // EXIT
+ break.i 0x80000 // SSC
+ ;;
+pal_ptce_info:
+ mov r8=0
+ mov r9=0 // base
+ movl r10=0x0000000100000001 // loop counts (outer|inner)
+ mov r11=0x0000000000000000 // loop strides (outer|inner)
+ br.sptk b0
+pal_vm_summary:
+ mov r8=0
+ movl r9=(8<<40)|(8<<32) // VM info 1
+ mov r10=(18<<8)|(41<<0) // VM info 2
+ mov r11=0
+ br.sptk b0
+pal_freq_ratios:
+ mov r8=0
+ movl r9=0x0000000B00000002 // processor ratio 11/2
+ movl r10=0x0000000100000001 // bus ratio 1/1
+ movl r11=0x0000000B00000002 // ITC ratio 11/2
+ br.sptk b0
+END(PalProc)
diff --git a/sys/boot/ia64/ski/sal_stub.c b/sys/boot/ia64/ski/sal_stub.c
new file mode 100644
index 0000000..caa6671
--- /dev/null
+++ b/sys/boot/ia64/ski/sal_stub.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2003 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <machine/md_var.h>
+#include <machine/sal.h>
+#include <stand.h>
+#include "libski.h"
+
+extern void PalProc(void);
+static sal_entry_t SalProc;
+
+struct {
+ struct sal_system_table header;
+ struct sal_entrypoint_descriptor entry;
+ struct sal_ap_wakeup_descriptor wakeup;
+} sal_systab = {
+ /* Header. */
+ {
+ SAL_SIGNATURE,
+ sizeof(sal_systab),
+ { 00, 03 }, /* Revision 3.0. */
+ 2, /* Number of decsriptors. */
+ 0, /* XXX checksum. */
+ { 0 },
+ { 00, 00 }, /* XXX SAL_A version. */
+ { 00, 00 }, /* XXX SAL_B version. */
+ "FreeBSD",
+ "Ski loader",
+ { 0 }
+ },
+ /* Entrypoint. */
+ {
+ 0, /* Type=entrypoint descr. */
+ { 0 },
+ 0, /* XXX PalProc. */
+ 0, /* XXX SalProc. */
+ 0, /* XXX SalProc GP. */
+ { 0 }
+ },
+ /* AP wakeup. */
+ {
+ 5, /* Type=AP wakeup descr. */
+ 0, /* External interrupt. */
+ { 0 },
+ 255 /* Wakeup vector. */
+ }
+};
+
+static inline void
+puts(const char *s)
+{
+ s = (const char *)((7UL << 61) | (u_long)s);
+ while (*s)
+ ski_cons_putchar(*s++);
+}
+
+static struct ia64_sal_result
+SalProc(u_int64_t a1, u_int64_t a2, u_int64_t a3, u_int64_t a4, u_int64_t a5,
+ u_int64_t a6, u_int64_t a7, u_int64_t a8)
+{
+ struct ia64_sal_result res;
+
+ res.sal_status = -3;
+ res.sal_result[0] = 0;
+ res.sal_result[1] = 0;
+ res.sal_result[2] = 0;
+
+ if (a1 == SAL_FREQ_BASE) {
+ res.sal_status = 0;
+ res.sal_result[0] = 133338184;
+ } else if (a1 == SAL_SET_VECTORS) {
+ /* XXX unofficial SSC function. */
+ ssc(a2, a3, a4, a5, SSC_SAL_SET_VECTORS);
+ } else if (a1 != SAL_GET_STATE_INFO_SIZE) {
+ puts("SAL: unimplemented function called\n");
+ }
+
+ return (res);
+}
+
+void
+sal_stub_init(void)
+{
+ struct ia64_fdesc *fd;
+
+ fd = (void*)PalProc;
+ sal_systab.entry.sale_pal_proc = fd->func;
+ fd = (void*)SalProc;
+ sal_systab.entry.sale_sal_proc = fd->func;
+ sal_systab.entry.sale_sal_gp = fd->gp;
+}
diff --git a/sys/boot/ia64/ski/ssc.c b/sys/boot/ia64/ski/ssc.c
index 11a91c8..e3e9eb2 100644
--- a/sys/boot/ia64/ski/ssc.c
+++ b/sys/boot/ia64/ski/ssc.c
@@ -29,14 +29,24 @@
#include <stand.h>
#include "libski.h"
+/*
+ * Ugh... Work around a bug in the Linux version of ski for SSC_GET_RTC. The
+ * PSR.dt register is not preserved properly and causes further memory
+ * references to be done without translation. All we need to do is preserve
+ * PSR.dt across the SSC call. We do this by saving and restoring psr.l
+ * completely.
+ */
u_int64_t
ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which)
{
+ register u_int64_t psr;
register u_int64_t ret0 __asm("r8");
+ __asm __volatile("mov %0=psr;;" : "=r"(psr));
__asm __volatile("mov r15=%1\n\t"
- "break 0x80000"
+ "break 0x80000;;"
: "=r"(ret0)
: "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3));
+ __asm __volatile("mov psr.l=%0;; srlz.d" :: "r"(psr));
return ret0;
}
diff --git a/sys/conf/files.ia64 b/sys/conf/files.ia64
index 8be7eb7..dd9dd5a 100644
--- a/sys/conf/files.ia64
+++ b/sys/conf/files.ia64
@@ -50,12 +50,10 @@ ia64/ia64/mem.c standard
ia64/ia64/mp_machdep.c optional smp
ia64/ia64/nexus.c standard
ia64/ia64/pal.s standard
-ia64/ia64/pal_stub.s optional ski
ia64/ia64/pmap.c standard
ia64/ia64/sal.c standard
ia64/ia64/sapic.c standard
ia64/ia64/setjmp.s standard
-ia64/ia64/ski.c optional ski
ia64/ia64/support.s standard
ia64/ia64/ssc.c optional ski
ia64/ia64/sscdisk.c optional ski
diff --git a/sys/ia64/conf/SKI b/sys/ia64/conf/SKI
index 1b8f179..10443cd 100644
--- a/sys/ia64/conf/SKI
+++ b/sys/ia64/conf/SKI
@@ -25,59 +25,45 @@
machine ia64
cpu ITANIUM
ident SKI
-maxusers 32
-
-#To statically compile in device wiring instead of /boot/device.hints
-#hints "GENERIC.hints"
+maxusers 0
makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
-makeoptions NO_CPU_COPTFLAGS=true #Ignore any x86 CPUTYPE
+makeoptions NO_MODULES=yes #Ignore any x86 CPUTYPE
-options SKI #Support for HP simulator
-options SCHED_4BSD #4BSD scheduler
-options INET #InterNETworking
-#options INET6 #IPv6 communications protocols
-options FFS #Berkeley Fast Filesystem
-options SOFTUPDATES #Enable FFS soft updates support
-options MD_ROOT #MD is a potential root device
-options PROCFS #Process filesystem (requires PSEUDOFS)
-options PSEUDOFS #Pseudo-filesystem framework
options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
options COMPAT_FREEBSD4
-options SCSI_DELAY=2000 #Delay (in ms) before probing SCSI
-options KTRACE #ktrace(1) syscall trace support
-options SYSVSHM #SYSV-style shared memory
-options SYSVMSG #SYSV-style message queues
-options SYSVSEM #SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
-options CONSPEED=115200
-options BREAK_TO_DEBUGGER #a BREAK on a comconsole goes to
-
-# Debugging for use in -current
options DDB
+options FFS #Berkeley Fast Filesystem
+options INET #InterNETworking
+options INET6 #IPv6 communications protocols
options INVARIANTS
options INVARIANT_SUPPORT
-options WITNESS
-
options KTR
-options KTR_ENTRIES=1024
+options KTRACE #ktrace(1) syscall trace support
options KTR_COMPILE="(KTR_INTR|KTR_PROC)"
-options KTR_MASK=0
options KTR_CPUMASK=0x3
-#options KTR_VERBOSE
+options KTR_ENTRIES=1024
+options KTR_MASK=0
+options KTR_VERBOSE
+options MD_ROOT #MD is a potential root device
+options PROCFS #Process filesystem (requires PSEUDOFS)
+options PSEUDOFS #Pseudo-filesystem framework
+options SCHED_4BSD #4BSD scheduler
+options SCSI_DELAY=500 #Delay (in ms) before probing SCSI
+options SKI
+options SOFTUPDATES #Enable FFS soft updates support
+options SYSVMSG #SYSV-style message queues
+options SYSVSEM #SYSV-style semaphores
+options SYSVSHM #SYSV-style shared memory
+options WITNESS
+options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
-# Pseudo devices - the number indicates how many units to allocated.
-device random # Entropy device
-device loop # Network loopback
+device acpi
+device bpf # Berkeley packet filter
device ether # Ethernet support
-device sl # Kernel SLIP
-device ppp # Kernel PPP
-device tun # Packet tunnel.
-device pty # Pseudo-ttys (telnet etc)
+device loop # Network loopback
device md # Memory "disks"
-device gif # IPv6 and IPv4 tunneling
-device faith # IPv6-to-IPv4 relaying/(translation)
-
-# The `bpf' device enables the Berkeley Packet Filter.
-# Be aware of the administrative consequences of enabling this!
-device bpf #Berkeley packet filter
+device pci
+device pty # Pseudo-ttys (telnet etc)
+device random # Entropy device
+device tun # Packet tunnel.
diff --git a/sys/ia64/ia64/autoconf.c b/sys/ia64/ia64/autoconf.c
index c58f4f2..65da451 100644
--- a/sys/ia64/ia64/autoconf.c
+++ b/sys/ia64/ia64/autoconf.c
@@ -105,8 +105,7 @@ cpu_rootconf()
#endif
#ifdef BOOTP
- if (!ia64_running_in_simulator())
- bootpc_init();
+ bootpc_init();
#endif
#if defined(NFSCLIENT) && defined(NFS_ROOT)
#if !defined(BOOTP_NFSROOT)
diff --git a/sys/ia64/ia64/efi.c b/sys/ia64/ia64/efi.c
index ab6917c..a9a8fd2 100644
--- a/sys/ia64/ia64/efi.c
+++ b/sys/ia64/ia64/efi.c
@@ -40,35 +40,6 @@ u_int64_t ia64_efi_acpi20_table;
extern u_int64_t ia64_call_efi_physical(u_int64_t, u_int64_t, u_int64_t,
u_int64_t, u_int64_t, u_int64_t);
-static EFI_STATUS fake_efi_proc(void);
-
-static EFI_RUNTIME_SERVICES fake_efi = {
- { EFI_RUNTIME_SERVICES_SIGNATURE,
- EFI_RUNTIME_SERVICES_REVISION,
- 0, 0, 0 },
-
- (EFI_GET_TIME) fake_efi_proc,
- (EFI_SET_TIME) fake_efi_proc,
- (EFI_GET_WAKEUP_TIME) fake_efi_proc,
- (EFI_SET_WAKEUP_TIME) fake_efi_proc,
-
- (EFI_SET_VIRTUAL_ADDRESS_MAP) fake_efi_proc,
- (EFI_CONVERT_POINTER) fake_efi_proc,
-
- (EFI_GET_VARIABLE) fake_efi_proc,
- (EFI_GET_NEXT_VARIABLE_NAME) fake_efi_proc,
- (EFI_SET_VARIABLE) fake_efi_proc,
-
- (EFI_GET_NEXT_HIGH_MONO_COUNT) fake_efi_proc,
- (EFI_RESET_SYSTEM) fake_efi_proc
-};
-
-static EFI_STATUS
-fake_efi_proc(void)
-{
- return EFI_UNSUPPORTED;
-}
-
void
ia64_efi_init(void)
{
@@ -78,14 +49,25 @@ ia64_efi_init(void)
EFI_MEMORY_DESCRIPTOR *md, *mdp;
int mdcount, i;
EFI_STATUS status;
-
- ia64_efi_runtime = &fake_efi;
if (!bootinfo.bi_systab) {
printf("No system table!\n");
return;
}
+ ia64_efi_systab = (EFI_SYSTEM_TABLE *)
+ IA64_PHYS_TO_RR7(bootinfo.bi_systab);
+ rs = (EFI_RUNTIME_SERVICES *)
+ IA64_PHYS_TO_RR7((u_int64_t)ia64_efi_systab->RuntimeServices);
+ if (!rs)
+ panic("No runtime services!");
+
+ ia64_efi_runtime = rs;
+ conf = (EFI_CONFIGURATION_TABLE *)
+ IA64_PHYS_TO_RR7((u_int64_t)ia64_efi_systab->ConfigurationTable);
+ if (!conf)
+ panic("No configuration tables!");
+
mdcount = bootinfo.bi_memmap_size / bootinfo.bi_memdesc_size;
md = (EFI_MEMORY_DESCRIPTOR *) IA64_PHYS_TO_RR7(bootinfo.bi_memmap);
@@ -104,19 +86,9 @@ ia64_efi_init(void)
}
}
- ia64_efi_systab = (EFI_SYSTEM_TABLE *)
- IA64_PHYS_TO_RR7(bootinfo.bi_systab);
-
- rs = (EFI_RUNTIME_SERVICES *)
- IA64_PHYS_TO_RR7((u_int64_t) ia64_efi_systab->RuntimeServices);
- ia64_efi_runtime = rs;
-
- status = ia64_call_efi_physical
- ((u_int64_t) rs->SetVirtualAddressMap,
- bootinfo.bi_memmap_size,
- bootinfo.bi_memdesc_size,
- bootinfo.bi_memdesc_version,
- bootinfo.bi_memmap, 0);
+ status = ia64_call_efi_physical((u_int64_t)rs->SetVirtualAddressMap,
+ bootinfo.bi_memmap_size, bootinfo.bi_memdesc_size,
+ bootinfo.bi_memdesc_version, bootinfo.bi_memmap, 0);
if (EFI_ERROR(status)) {
/*
@@ -126,8 +98,6 @@ ia64_efi_init(void)
panic("Can't set firmware into virtual mode");
}
- conf = (EFI_CONFIGURATION_TABLE *)
- IA64_PHYS_TO_RR7((u_int64_t) ia64_efi_systab->ConfigurationTable);
for (i = 0; i < ia64_efi_systab->NumberOfTableEntries; i++) {
static EFI_GUID sal = SAL_SYSTEM_TABLE_GUID;
static EFI_GUID acpi = ACPI_TABLE_GUID;
diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c
index 02ab39d..8de0d9c 100644
--- a/sys/ia64/ia64/machdep.c
+++ b/sys/ia64/ia64/machdep.c
@@ -28,14 +28,9 @@
#include "opt_compat.h"
#include "opt_ddb.h"
-#include "opt_ski.h"
#include "opt_msgbuf.h"
#include "opt_acpi.h"
-#if !defined(SKI) && !defined(DEV_ACPI)
-#error "You need the SKI option and/or the acpi device"
-#endif
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/eventhandler.h>
@@ -92,10 +87,6 @@
#include <machine/unwind.h>
#include <i386/include/specialreg.h>
-#ifdef SKI
-extern void ia64_ski_init(void);
-#endif
-
u_int64_t processor_frequency;
u_int64_t bus_frequency;
u_int64_t itc_frequency;
@@ -104,6 +95,7 @@ int cold = 1;
u_int64_t pa_bootinfo;
struct bootinfo bootinfo;
+struct pcpu early_pcpu;
extern char kstack[];
struct user *proc0uarea;
vm_offset_t proc0kstack;
@@ -205,21 +197,12 @@ cpu_startup(dummy)
bufinit();
vm_pager_bufferinit();
- if (!ia64_running_in_simulator()) {
-#ifdef DEV_ACPI
- /*
- * Traverse the MADT to discover IOSAPIC and Local SAPIC
- * information.
- */
- ia64_probe_sapics();
- ia64_mca_init();
-#else
- /*
- * It is an error to boot a SKI-only kernel on hardware.
- */
- panic("Mandatory 'device acpi' is missing");
-#endif
- }
+ /*
+ * Traverse the MADT to discover IOSAPIC and Local SAPIC
+ * information.
+ */
+ ia64_probe_sapics();
+ ia64_mca_init();
}
void
@@ -411,30 +394,6 @@ ia64_init(u_int64_t arg1, u_int64_t arg2)
*/
mdcount = bootinfo.bi_memmap_size / bootinfo.bi_memdesc_size;
md = (EFI_MEMORY_DESCRIPTOR *) IA64_PHYS_TO_RR7(bootinfo.bi_memmap);
- if (md == NULL || mdcount == 0) {
-#ifdef SKI
- static EFI_MEMORY_DESCRIPTOR ski_md[2];
- /*
- * XXX hack for ski. In reality, the loader will probably ask
- * EFI and pass the results to us. Possibly, we will call EFI
- * directly.
- */
- ski_md[0].Type = EfiConventionalMemory;
- ski_md[0].PhysicalStart = 2L*1024*1024;
- ski_md[0].VirtualStart = 0;
- ski_md[0].NumberOfPages = (64L*1024*1024)>>12;
- ski_md[0].Attribute = EFI_MEMORY_WB;
-
- ski_md[1].Type = EfiMemoryMappedIOPortSpace;
- ski_md[1].PhysicalStart = 0xffffc000000;
- ski_md[1].VirtualStart = 0;
- ski_md[1].NumberOfPages = (64L*1024*1024)>>12;
- ski_md[1].Attribute = EFI_MEMORY_UC;
-
- md = ski_md;
- mdcount = 2;
-#endif
- }
for (i = 0, mdp = md; i < mdcount; i++,
mdp = NextMemoryDescriptor(mdp, bootinfo.bi_memdesc_size)) {
@@ -444,9 +403,6 @@ ia64_init(u_int64_t arg1, u_int64_t arg2)
ia64_pal_base = mdp->PhysicalStart;
}
- /* Map the memory mapped I/O Port space */
- KASSERT(ia64_port_base != 0,
- ("%s: no I/O port memory region", __func__));
map_port_space();
metadata_missing = 0;
@@ -503,9 +459,6 @@ ia64_init(u_int64_t arg1, u_int64_t arg2)
*/
map_pal_code();
ia64_efi_init();
-#ifdef SKI
- ia64_ski_init();
-#endif
calculate_frequencies();
/*
@@ -734,12 +687,6 @@ ia64_init(u_int64_t arg1, u_int64_t arg2)
ia64_set_tpr(0);
}
-int
-ia64_running_in_simulator()
-{
- return bootinfo.bi_systab == 0;
-}
-
void
bzero(void *buf, size_t len)
{
diff --git a/sys/ia64/ia64/mca.c b/sys/ia64/ia64/mca.c
index ca24cab..4109e3d 100644
--- a/sys/ia64/ia64/mca.c
+++ b/sys/ia64/ia64/mca.c
@@ -198,14 +198,15 @@ ia64_mca_init(void)
}
max_size = round_page(max_size);
- p = contigmalloc(max_size, M_TEMP, 0, 0ul, 256*1024*1024 - 1,
- PAGE_SIZE, 256*1024*1024);
-
- mca_info_block = IA64_PHYS_TO_RR7(ia64_tpa((u_int64_t)p));
-
- if (bootverbose)
- printf("MCA: allocated %ld bytes for state information\n",
- max_size);
+ if (max_size) {
+ p = contigmalloc(max_size, M_TEMP, 0, 0ul, 256*1024*1024 - 1,
+ PAGE_SIZE, 256*1024*1024);
+ mca_info_block = IA64_PHYS_TO_RR7(ia64_tpa((u_int64_t)p));
+
+ if (bootverbose)
+ printf("MCA: allocated %ld bytes for state info.\n",
+ max_size);
+ }
/*
* Initialize the spin lock used to protect the info block. When APs
diff --git a/sys/ia64/ia64/pal.S b/sys/ia64/ia64/pal.S
index 4c5abe5..eca57ac 100644
--- a/sys/ia64/ia64/pal.S
+++ b/sys/ia64/ia64/pal.S
@@ -30,23 +30,10 @@
.data
.global ia64_pal_entry
-ia64_pal_entry: .quad ia64_call_pal_stub
+ia64_pal_entry: .quad 0
.text
/*
- * Stub for running in simulation.
- */
-ENTRY(ia64_call_pal_stub, 0)
-
- mov r8=-3
- tbit.nz p6,p7=r28,8 // static or stacked?
- ;;
-(p6) br.ret.sptk.few rp
-(p7) br.cond.sptk.few rp
-
-END(ia64_call_pal_stub)
-
-/*
* struct ia64_pal_result ia64_call_pal_static(u_int64_t proc,
* u_int64_t arg1, u_int64_t arg2, u_int64_t arg3)
*/
diff --git a/sys/ia64/ia64/pal.s b/sys/ia64/ia64/pal.s
index 4c5abe5..eca57ac 100644
--- a/sys/ia64/ia64/pal.s
+++ b/sys/ia64/ia64/pal.s
@@ -30,23 +30,10 @@
.data
.global ia64_pal_entry
-ia64_pal_entry: .quad ia64_call_pal_stub
+ia64_pal_entry: .quad 0
.text
/*
- * Stub for running in simulation.
- */
-ENTRY(ia64_call_pal_stub, 0)
-
- mov r8=-3
- tbit.nz p6,p7=r28,8 // static or stacked?
- ;;
-(p6) br.ret.sptk.few rp
-(p7) br.cond.sptk.few rp
-
-END(ia64_call_pal_stub)
-
-/*
* struct ia64_pal_result ia64_call_pal_static(u_int64_t proc,
* u_int64_t arg1, u_int64_t arg2, u_int64_t arg3)
*/
diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c
index ac5c4cf..cb3d1d3 100644
--- a/sys/ia64/ia64/pmap.c
+++ b/sys/ia64/ia64/pmap.c
@@ -207,9 +207,7 @@ static struct ia64_lpte **kptdir;
vm_offset_t kernel_vm_end;
-/*
- * Values for ptc.e. XXX values for SKI.
- */
+/* Values for ptc.e. XXX values for SKI. */
static u_int64_t pmap_ptc_e_base = 0x100000000;
static u_int64_t pmap_ptc_e_count1 = 3;
static u_int64_t pmap_ptc_e_count2 = 2;
diff --git a/sys/ia64/ia64/sal.c b/sys/ia64/ia64/sal.c
index f16d796..24ae989 100644
--- a/sys/ia64/ia64/sal.c
+++ b/sys/ia64/ia64/sal.c
@@ -85,7 +85,7 @@ ia64_sal_init(struct sal_system_table *saltab)
u_int8_t *p;
int i;
- if (memcmp(saltab->sal_signature, "SST_", 4)) {
+ if (memcmp(saltab->sal_signature, SAL_SIGNATURE, 4)) {
printf("Bad signature for SAL System Table\n");
return;
}
diff --git a/sys/ia64/ia64/ski.c b/sys/ia64/ia64/ski.c
deleted file mode 100644
index a387000..0000000
--- a/sys/ia64/ia64/ski.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*-
- * Copyright (c) 2001 Doug Rabson
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*
- * Fake out bits of EFI and SAL when running under SKI.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <machine/efi.h>
-#include <machine/sal.h>
-#include <machine/md_var.h>
-
-struct ssc_time {
- int year;
- int month;
- int day;
- int hour;
- int minute;
- int second;
- int msec;
- int wday;
-};
-
-#define SSC_GET_RTC 65
-
-static u_int64_t
-ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which)
-{
- register u_int64_t ret0 __asm("r8");
-
- __asm __volatile("mov r15=%1\n\t"
- "break 0x80001"
- : "=r"(ret0)
- : "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3));
-
- /*
- * Ugh... Work around a bug in the Linux version of ski for
- * SSC_GET_RTC. The PSR.dt register is not preserved properly
- * and causes further memory references to be done without
- * translation. All we need to do is set PSR.dt again. Note
- * that dependency violations do not exist in ski, so we
- * don't have to serialize.
- */
- __asm __volatile("ssm psr.dt");
-
- return ret0;
-}
-
-extern u_int64_t ski_fake_pal[]; /* *not* a function decl */
-extern void ia64_ski_init(void);
-extern u_int64_t ia64_pal_entry;
-
-static EFI_STATUS ski_fake_efi_proc(void);
-static EFI_STATUS ski_fake_efi_get_time(EFI_TIME *time,
- EFI_TIME_CAPABILITIES *caps);
-
-static EFI_RUNTIME_SERVICES ski_fake_efi = {
- { EFI_RUNTIME_SERVICES_SIGNATURE,
- EFI_RUNTIME_SERVICES_REVISION,
- 0, 0, 0 },
-
- (EFI_GET_TIME) ski_fake_efi_get_time,
- (EFI_SET_TIME) ski_fake_efi_proc,
- (EFI_GET_WAKEUP_TIME) ski_fake_efi_proc,
- (EFI_SET_WAKEUP_TIME) ski_fake_efi_proc,
-
- (EFI_SET_VIRTUAL_ADDRESS_MAP) ski_fake_efi_proc,
- (EFI_CONVERT_POINTER) ski_fake_efi_proc,
-
- (EFI_GET_VARIABLE) ski_fake_efi_proc,
- (EFI_GET_NEXT_VARIABLE_NAME) ski_fake_efi_proc,
- (EFI_SET_VARIABLE) ski_fake_efi_proc,
-
- (EFI_GET_NEXT_HIGH_MONO_COUNT) ski_fake_efi_proc,
- (EFI_RESET_SYSTEM) ski_fake_efi_proc
-};
-
-static EFI_STATUS
-ski_fake_efi_get_time(EFI_TIME *time, EFI_TIME_CAPABILITIES *caps)
-{
- struct ssc_time ssctime;
-
- ssc(ia64_tpa((vm_offset_t) &ssctime), 0, 0, 0, SSC_GET_RTC);
-
- time->Second = ssctime.second;
- time->Minute = ssctime.minute;
- time->Hour = ssctime.hour;
- time->Day = ssctime.day;
- time->Month = ssctime.month + 1;
- time->Year = ssctime.year + 1900;
-
- return EFI_SUCCESS;
-}
-
-static EFI_STATUS
-ski_fake_efi_proc(void)
-{
- return EFI_UNSUPPORTED;
-}
-
-static struct ia64_sal_result
-ski_fake_sal(u_int64_t a1, u_int64_t a2, u_int64_t a3, u_int64_t a4,
- u_int64_t a5, u_int64_t a6, u_int64_t a7, u_int64_t a8)
-{
- struct ia64_sal_result res;
-
- if (a1 == SAL_FREQ_BASE) {
- /*
- * Fake the values from my SDV.
- */
- res.sal_status = 0;
- res.sal_result[0] = 133347096;
- res.sal_result[1] = 0;
- res.sal_result[2] = 0;
- return res;
- }
-
- /*
- * Return an error for anything we don't care about.
- */
- res.sal_status = -3;
- res.sal_result[0] = 0;
- res.sal_result[1] = 0;
- res.sal_result[2] = 0;
- return res;
-}
-
-void
-ia64_ski_init(void)
-{
- if (!ia64_running_in_simulator())
- return;
-
- ia64_efi_runtime = &ski_fake_efi;
- ia64_pal_entry = (u_int64_t) ski_fake_pal;
- ia64_sal_entry = ski_fake_sal;
-}
diff --git a/sys/ia64/ia64/ssc.c b/sys/ia64/ia64/ssc.c
index a18eae9..6c3cb35 100644
--- a/sys/ia64/ia64/ssc.c
+++ b/sys/ia64/ia64/ssc.c
@@ -99,9 +99,6 @@ ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which)
static void
ssccnprobe(struct consdev *cp)
{
- if (!ia64_running_in_simulator())
- return;
-
cp->cn_dev = makedev(CDEV_MAJOR, 0);
cp->cn_pri = CN_INTERNAL;
}
@@ -114,8 +111,6 @@ ssccninit(struct consdev *cp)
static void
ssccnattach(void *arg)
{
- if (!ia64_running_in_simulator())
- return;
make_dev(&ssc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "ssccons");
}
SYSINIT(ssccnattach, SI_SUB_DRIVERS, SI_ORDER_ANY, ssccnattach, 0);
diff --git a/sys/ia64/ia64/sscdisk.c b/sys/ia64/ia64/sscdisk.c
index c4d5195..561ffc5 100644
--- a/sys/ia64/ia64/sscdisk.c
+++ b/sys/ia64/ia64/sscdisk.c
@@ -288,9 +288,6 @@ ssc_clone (void *arg, char *name, int namelen, dev_t *dev)
static void
ssc_drvinit(void *unused)
{
- if (!ia64_running_in_simulator())
- return;
-
ssccreate(-1);
}
diff --git a/sys/ia64/include/md_var.h b/sys/ia64/include/md_var.h
index 706294f..38d98de 100644
--- a/sys/ia64/include/md_var.h
+++ b/sys/ia64/include/md_var.h
@@ -53,7 +53,6 @@ struct ia64_fdesc {
void busdma_swi(void);
void cpu_halt(void);
void cpu_reset(void);
-int ia64_running_in_simulator(void);
int is_physical_memory(vm_offset_t addr);
void os_boot_rendez(void);
void os_mca(void);
diff --git a/sys/ia64/include/sal.h b/sys/ia64/include/sal.h
index 40940f5..abe7c1f 100644
--- a/sys/ia64/include/sal.h
+++ b/sys/ia64/include/sal.h
@@ -31,6 +31,7 @@
struct sal_system_table {
char sal_signature[4];
+#define SAL_SIGNATURE "SST_"
u_int32_t sal_length;
u_int8_t sal_rev[2];
u_int16_t sal_entry_count;
OpenPOWER on IntegriCloud