diff options
author | marcel <marcel@FreeBSD.org> | 2004-09-19 03:50:46 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2004-09-19 03:50:46 +0000 |
commit | 60944a9fd4aa73054c54a0943f35653950f21737 (patch) | |
tree | 89a60da91b2c3905e4fe6e3a6a6519b5f400e88f /sys/ia64 | |
parent | 78d7eda383c8601a0076d9fde2d78795be629740 (diff) | |
download | FreeBSD-src-60944a9fd4aa73054c54a0943f35653950f21737.zip FreeBSD-src-60944a9fd4aa73054c54a0943f35653950f21737.tar.gz |
MFp4:
Completely remove the remaining EFI includes and add our own (type)
definitions instead. While here, abstract more of the internals by
providing interface functions.
Diffstat (limited to 'sys/ia64')
-rw-r--r-- | sys/ia64/acpica/OsdEnvironment.c | 40 | ||||
-rw-r--r-- | sys/ia64/ia64/dump_machdep.c | 49 | ||||
-rw-r--r-- | sys/ia64/ia64/efi.c | 176 | ||||
-rw-r--r-- | sys/ia64/ia64/eficlock.c | 43 | ||||
-rw-r--r-- | sys/ia64/ia64/machdep.c | 56 | ||||
-rw-r--r-- | sys/ia64/ia64/sal.c | 21 | ||||
-rw-r--r-- | sys/ia64/include/efi.h | 165 | ||||
-rw-r--r-- | sys/ia64/include/sal.h | 2 |
8 files changed, 353 insertions, 199 deletions
diff --git a/sys/ia64/acpica/OsdEnvironment.c b/sys/ia64/acpica/OsdEnvironment.c index a6a62f6..7419e6f 100644 --- a/sys/ia64/acpica/OsdEnvironment.c +++ b/sys/ia64/acpica/OsdEnvironment.c @@ -23,58 +23,52 @@ * 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$ */ -/* - * 6.1 : Environmental support - */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <sys/types.h> #include <sys/linker_set.h> #include <sys/sysctl.h> +#include <machine/efi.h> #include "acpi.h" -extern u_int64_t ia64_efi_acpi_table; -extern u_int64_t ia64_efi_acpi20_table; +static struct uuid acpi_root_uuid = EFI_TABLE_ACPI20; -static u_long ia64_acpi_root; +static u_long acpi_root_phys; -SYSCTL_ULONG(_machdep, OID_AUTO, acpi_root, CTLFLAG_RD, &ia64_acpi_root, 0, - "The physical address of the RSDP"); +SYSCTL_ULONG(_machdep, OID_AUTO, acpi_root, CTLFLAG_RD, &acpi_root_phys, 0, + "The physical address of the RSDP"); ACPI_STATUS AcpiOsInitialize(void) { + return(AE_OK); } ACPI_STATUS AcpiOsTerminate(void) { + return(AE_OK); } ACPI_STATUS AcpiOsGetRootPointer(UINT32 Flags, ACPI_POINTER *RsdpAddress) { - if (ia64_acpi_root == 0) { - if (ia64_efi_acpi20_table) { - /* XXX put under bootverbose. */ - printf("Using ACPI2.0 table at 0x%lx\n", - ia64_efi_acpi20_table); - ia64_acpi_root = ia64_efi_acpi20_table; - } else if (ia64_efi_acpi_table) { - /* XXX put under bootverbose. */ - printf("Using ACPI1.x table at 0x%lx\n", - ia64_efi_acpi_table); - ia64_acpi_root = ia64_efi_acpi_table; - } else + void *acpi_root; + + if (acpi_root_phys == 0) { + acpi_root = efi_get_table(&acpi_root_uuid); + if (acpi_root == NULL) return (AE_NOT_FOUND); + acpi_root_phys = IA64_RR_MASK((u_long)acpi_root); } RsdpAddress->PointerType = ACPI_PHYSICAL_POINTER; - RsdpAddress->Pointer.Physical = ia64_acpi_root; + RsdpAddress->Pointer.Physical = acpi_root_phys; return (AE_OK); } diff --git a/sys/ia64/ia64/dump_machdep.c b/sys/ia64/ia64/dump_machdep.c index d8800ea..4964148 100644 --- a/sys/ia64/ia64/dump_machdep.c +++ b/sys/ia64/ia64/dump_machdep.c @@ -22,10 +22,11 @@ * 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/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> @@ -34,7 +35,6 @@ #include <sys/kerneldump.h> #include <vm/vm.h> #include <vm/pmap.h> -#include <machine/bootinfo.h> #include <machine/efi.h> #include <machine/elf.h> #include <machine/md_var.h> @@ -50,7 +50,7 @@ CTASSERT(sizeof(struct kerneldumpheader) == 512); #define MD_ALIGN(x) (((off_t)(x) + EFI_PAGE_MASK) & ~EFI_PAGE_MASK) #define DEV_ALIGN(x) (((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1)) -typedef int callback_t(EFI_MEMORY_DESCRIPTOR*, int, void*); +typedef int callback_t(struct efi_md*, int, void*); static struct kerneldumpheader kdh; static off_t dumplo, fileofs; @@ -121,7 +121,7 @@ buf_flush(struct dumperinfo *di) } static int -cb_dumpdata(EFI_MEMORY_DESCRIPTOR *mdp, int seqnr, void *arg) +cb_dumpdata(struct efi_md *mdp, int seqnr, void *arg) { struct dumperinfo *di = (struct dumperinfo*)arg; vm_offset_t pa; @@ -129,11 +129,11 @@ cb_dumpdata(EFI_MEMORY_DESCRIPTOR *mdp, int seqnr, void *arg) size_t counter, sz; int c, error, twiddle; - error = 0; /* catch case in which mdp->NumberOfPages is 0 */ + error = 0; /* catch case in which mdp->md_pages is 0 */ counter = 0; /* Update twiddle every 16MB */ twiddle = 0; - pgs = mdp->NumberOfPages; - pa = IA64_PHYS_TO_RR7(mdp->PhysicalStart); + pgs = mdp->md_pages; + pa = IA64_PHYS_TO_RR7(mdp->md_phys); printf(" chunk %d: %ld pages ", seqnr, (long)pgs); @@ -164,7 +164,7 @@ cb_dumpdata(EFI_MEMORY_DESCRIPTOR *mdp, int seqnr, void *arg) } static int -cb_dumphdr(EFI_MEMORY_DESCRIPTOR *mdp, int seqnr, void *arg) +cb_dumphdr(struct efi_md *mdp, int seqnr, void *arg) { struct dumperinfo *di = (struct dumperinfo*)arg; Elf64_Phdr phdr; @@ -174,10 +174,10 @@ cb_dumphdr(EFI_MEMORY_DESCRIPTOR *mdp, int seqnr, void *arg) phdr.p_type = PT_LOAD; phdr.p_flags = PF_R; /* XXX */ phdr.p_offset = fileofs; - phdr.p_vaddr = mdp->VirtualStart; /* XXX probably bogus. */ - phdr.p_paddr = mdp->PhysicalStart; - phdr.p_filesz = mdp->NumberOfPages << EFI_PAGE_SHIFT; - phdr.p_memsz = mdp->NumberOfPages << EFI_PAGE_SHIFT; + phdr.p_vaddr = (uintptr_t)mdp->md_virt; /* XXX probably bogus. */ + phdr.p_paddr = mdp->md_phys; + phdr.p_filesz = mdp->md_pages << EFI_PAGE_SHIFT; + phdr.p_memsz = mdp->md_pages << EFI_PAGE_SHIFT; phdr.p_align = EFI_PAGE_SIZE; error = buf_write(di, (char*)&phdr, sizeof(phdr)); @@ -186,35 +186,30 @@ cb_dumphdr(EFI_MEMORY_DESCRIPTOR *mdp, int seqnr, void *arg) } static int -cb_size(EFI_MEMORY_DESCRIPTOR *mdp, int seqnr, void *arg) +cb_size(struct efi_md *mdp, int seqnr, void *arg) { uint64_t *sz = (uint64_t*)arg; - *sz += (uint64_t)mdp->NumberOfPages << EFI_PAGE_SHIFT; + *sz += (uint64_t)mdp->md_pages << EFI_PAGE_SHIFT; return (0); } static int foreach_chunk(callback_t cb, void *arg) { - EFI_MEMORY_DESCRIPTOR *mdp; - int error, i, mdcount, seqnr; - - mdp = (EFI_MEMORY_DESCRIPTOR *)IA64_PHYS_TO_RR7(bootinfo.bi_memmap); - mdcount = bootinfo.bi_memmap_size / bootinfo.bi_memdesc_size; + struct efi_md *mdp; + int error, seqnr; - if (mdp == NULL || mdcount == 0) - return (0); - - for (i = 0, seqnr = 0; i < mdcount; i++) { - if (mdp->Type == EfiConventionalMemory) { + seqnr = 0; + mdp = efi_md_first(); + while (mdp != NULL) { + if (mdp->md_type == EFI_MD_TYPE_FREE) { error = (*cb)(mdp, seqnr++, arg); if (error) return (-error); } - mdp = NextMemoryDescriptor(mdp, bootinfo.bi_memdesc_size); + mdp = efi_md_next(mdp); } - return (seqnr); } diff --git a/sys/ia64/ia64/efi.c b/sys/ia64/ia64/efi.c index a9a8fd2..a10c208 100644 --- a/sys/ia64/ia64/efi.c +++ b/sys/ia64/ia64/efi.c @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2004 Marcel Moolenaar * Copyright (c) 2001 Doug Rabson * All rights reserved. * @@ -22,97 +23,134 @@ * 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/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <sys/param.h> #include <sys/systm.h> #include <machine/bootinfo.h> #include <machine/efi.h> #include <machine/sal.h> -EFI_SYSTEM_TABLE *ia64_efi_systab; -EFI_RUNTIME_SERVICES *ia64_efi_runtime; -u_int64_t ia64_efi_acpi_table; -u_int64_t ia64_efi_acpi20_table; +extern uint64_t ia64_call_efi_physical(uint64_t, uint64_t, uint64_t, uint64_t, + uint64_t, uint64_t); -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 struct efi_systbl *efi_systbl; +static struct efi_cfgtbl *efi_cfgtbl; +static struct efi_rt *efi_runtime; void -ia64_efi_init(void) +efi_boot_finish(void) +{ +} + +/* + * Collect the entry points for PAL and SAL. Be extra careful about NULL + * pointer values. We're running pre-console, so it's better to return + * error values than to cause panics, machine checks and other traps and + * faults. Keep this minimal... + */ +int +efi_boot_minimal(uint64_t systbl) { - EFI_CONFIGURATION_TABLE *conf; - struct sal_system_table *saltab = 0; - EFI_RUNTIME_SERVICES *rs; - EFI_MEMORY_DESCRIPTOR *md, *mdp; - int mdcount, i; - EFI_STATUS status; - - if (!bootinfo.bi_systab) { - printf("No system table!\n"); - return; + struct efi_md *md; + efi_status status; + + if (systbl == 0) + return (EINVAL); + efi_systbl = (struct efi_systbl *)IA64_PHYS_TO_RR7(systbl); + if (efi_systbl->st_hdr.th_sig != EFI_SYSTBL_SIG) { + efi_systbl = NULL; + return (EFAULT); } + efi_cfgtbl = (efi_systbl->st_cfgtbl == 0) ? NULL : + (struct efi_cfgtbl *)IA64_PHYS_TO_RR7(efi_systbl->st_cfgtbl); + if (efi_cfgtbl == NULL) + return (ENOENT); + efi_runtime = (efi_systbl->st_rt == 0) ? NULL : + (struct efi_rt *)IA64_PHYS_TO_RR7(efi_systbl->st_rt); + if (efi_runtime == NULL) + return (ENOENT); - 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); - - for (i = 0, mdp = md; i < mdcount; i++, - mdp = NextMemoryDescriptor(mdp, bootinfo.bi_memdesc_size)) { - /* - * Relocate runtime memory segments for firmware. - */ - if (mdp->Attribute & EFI_MEMORY_RUNTIME) { - if (mdp->Attribute & EFI_MEMORY_WB) - mdp->VirtualStart = - IA64_PHYS_TO_RR7(mdp->PhysicalStart); - else if (mdp->Attribute & EFI_MEMORY_UC) - mdp->VirtualStart = - IA64_PHYS_TO_RR6(mdp->PhysicalStart); + /* + * Relocate runtime memory segments for firmware. + */ + md = efi_md_first(); + while (md != NULL) { + if (md->md_attr & EFI_MD_ATTR_RT) { + if (md->md_attr & EFI_MD_ATTR_WB) + md->md_virt = + (void *)IA64_PHYS_TO_RR7(md->md_phys); + else if (md->md_attr & EFI_MD_ATTR_UC) + md->md_virt = + (void *)IA64_PHYS_TO_RR6(md->md_phys); } + md = efi_md_next(md); } - - status = ia64_call_efi_physical((u_int64_t)rs->SetVirtualAddressMap, + status = ia64_call_efi_physical((uint64_t)efi_runtime->rt_setvirtual, bootinfo.bi_memmap_size, bootinfo.bi_memdesc_size, bootinfo.bi_memdesc_version, bootinfo.bi_memmap, 0); + return ((status < 0) ? EFAULT : 0); +} - if (EFI_ERROR(status)) { - /* - * We could wrap EFI in a virtual->physical shim here. - */ - printf("SetVirtualAddressMap returned 0x%lx\n", status); - panic("Can't set firmware into virtual mode"); - } +void * +efi_get_table(struct uuid *uuid) +{ + struct efi_cfgtbl *ct; + u_long count; - for (i = 0; i < ia64_efi_systab->NumberOfTableEntries; i++) { - static EFI_GUID sal = SAL_SYSTEM_TABLE_GUID; - static EFI_GUID acpi = ACPI_TABLE_GUID; - static EFI_GUID acpi20 = ACPI_20_TABLE_GUID; - if (!memcmp(&conf[i].VendorGuid, &sal, sizeof(EFI_GUID))) - saltab = (struct sal_system_table *) - IA64_PHYS_TO_RR7((u_int64_t) conf[i].VendorTable); - if (!memcmp(&conf[i].VendorGuid, &acpi, sizeof(EFI_GUID))) - ia64_efi_acpi_table = (u_int64_t) conf[i].VendorTable; - if (!memcmp(&conf[i].VendorGuid, &acpi20, sizeof(EFI_GUID))) - ia64_efi_acpi20_table = (u_int64_t) conf[i].VendorTable; + if (efi_cfgtbl == NULL) + return (NULL); + count = efi_systbl->st_entries; + ct = efi_cfgtbl; + while (count--) { + if (!memcmp(&ct->ct_uuid, uuid, sizeof(*uuid))) + return ((void *)IA64_PHYS_TO_RR7(ct->ct_data)); + ct++; } + return (NULL); +} + +void +efi_get_time(struct efi_tm *tm) +{ - if (saltab) - ia64_sal_init(saltab); + efi_runtime->rt_gettime(tm, NULL); +} + +struct efi_md * +efi_md_first(void) +{ + + if (bootinfo.bi_memmap == 0) + return (NULL); + return ((struct efi_md *)IA64_PHYS_TO_RR7(bootinfo.bi_memmap)); +} + +struct efi_md * +efi_md_next(struct efi_md *md) +{ + uint64_t plim; + plim = IA64_PHYS_TO_RR7(bootinfo.bi_memmap + bootinfo.bi_memmap_size); + md = (struct efi_md *)((uintptr_t)md + bootinfo.bi_memdesc_size); + return ((md >= (struct efi_md *)plim) ? NULL : md); } +void +efi_reset_system(void) +{ + + if (efi_runtime != NULL) + efi_runtime->rt_reset(EFI_RESET_WARM, 0, 0, NULL); + panic("%s: unable to reset the machine", __func__); +} + +efi_status +efi_set_time(struct efi_tm *tm) +{ + + return (efi_runtime->rt_settime(tm)); +} diff --git a/sys/ia64/ia64/eficlock.c b/sys/ia64/ia64/eficlock.c index a7fc591..e48cb5c 100644 --- a/sys/ia64/ia64/eficlock.c +++ b/sys/ia64/ia64/eficlock.c @@ -22,10 +22,11 @@ * 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/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <sys/param.h> #include <sys/kernel.h> #include <sys/systm.h> @@ -46,17 +47,17 @@ eficlock_init(kobj_t dev) static void eficlock_get(kobj_t dev, time_t base, struct clocktime *ct) { - EFI_TIME time; + struct efi_tm tm; - ia64_efi_runtime->GetTime(&time, 0); + efi_get_time(&tm); - ct->sec = time.Second; - ct->min = time.Minute; - ct->hour = time.Hour; + ct->sec = tm.tm_sec; + ct->min = tm.tm_min; + ct->hour = tm.tm_hour; ct->dow = 0; /* XXX not used */ - ct->day = time.Day; - ct->mon = time.Month; - ct->year = time.Year - 1900; + ct->day = tm.tm_mday; + ct->mon = tm.tm_mon; + ct->year = tm.tm_year - 1900; } /* @@ -65,18 +66,18 @@ eficlock_get(kobj_t dev, time_t base, struct clocktime *ct) static void eficlock_set(kobj_t dev, struct clocktime *ct) { - EFI_TIME time; - EFI_STATUS status; + struct efi_tm tm; + efi_status status; - ia64_efi_runtime->GetTime(&time, 0); - time.Second = ct->sec; - time.Minute = ct->min; - time.Hour = ct->hour; - time.Day = ct->day; - time.Month = ct->mon; - time.Year = ct->year + 1900; - status = ia64_efi_runtime->SetTime(&time); - if (status != EFI_SUCCESS) + efi_get_time(&tm); + tm.tm_sec = ct->sec; + tm.tm_min = ct->min; + tm.tm_hour = ct->hour; + tm.tm_mday = ct->day; + tm.tm_mon = ct->mon; + tm.tm_year = ct->year + 1900; + status = efi_set_time(&tm); + if (status) printf("eficlock_set: could not set TODR\n"); } diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index 08c2a74..15ef3c4 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -23,10 +23,11 @@ * 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/cdefs.h> +__FBSDID("$FreeBSD$"); + #include "opt_compat.h" #include "opt_ddb.h" #include "opt_kstack_pages.h" @@ -281,14 +282,14 @@ void cpu_boot(int howto) { - ia64_efi_runtime->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, 0); + efi_reset_system(); } void cpu_halt() { - ia64_efi_runtime->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, 0); + efi_reset_system(); } static void @@ -485,8 +486,8 @@ ia64_init(void) vm_offset_t kernstart, kernend; vm_offset_t kernstartpfn, kernendpfn, pfn0, pfn1; char *p; - EFI_MEMORY_DESCRIPTOR *md, *mdp; - int mdcount, i, metadata_missing; + struct efi_md *md; + int metadata_missing; /* NO OUTPUT ALLOWED UNTIL FURTHER NOTICE */ @@ -516,15 +517,15 @@ ia64_init(void) * Look for the I/O ports first - we need them for console * probing. */ - mdcount = bootinfo.bi_memmap_size / bootinfo.bi_memdesc_size; - md = (EFI_MEMORY_DESCRIPTOR *) IA64_PHYS_TO_RR7(bootinfo.bi_memmap); - - for (i = 0, mdp = md; i < mdcount; i++, - mdp = NextMemoryDescriptor(mdp, bootinfo.bi_memdesc_size)) { - if (mdp->Type == EfiMemoryMappedIOPortSpace) - ia64_port_base = IA64_PHYS_TO_RR6(mdp->PhysicalStart); - else if (mdp->Type == EfiPalCode) - ia64_pal_base = mdp->PhysicalStart; + for (md = efi_md_first(); md != NULL; md = efi_md_next(md)) { + switch (md->md_type) { + case EFI_MD_TYPE_IOPORT: + ia64_port_base = IA64_PHYS_TO_RR6(md->md_phys); + break; + case EFI_MD_TYPE_PALCODE: + ia64_pal_base = md->md_phys; + break; + } } metadata_missing = 0; @@ -577,7 +578,8 @@ ia64_init(void) * Wire things up so we can call the firmware. */ map_pal_code(); - ia64_efi_init(); + efi_boot_minimal(bootinfo.bi_systab); + ia64_sal_init(); calculate_frequencies(); /* @@ -627,22 +629,18 @@ ia64_init(void) #endif phys_avail_cnt = 0; - for (i = 0, mdp = md; i < mdcount; i++, - mdp = NextMemoryDescriptor(mdp, bootinfo.bi_memdesc_size)) { + for (md = efi_md_first(); md != NULL; md = efi_md_next(md)) { #ifdef DEBUG_MD - printf("MD %d: type %d pa 0x%lx cnt 0x%lx\n", i, - mdp->Type, - mdp->PhysicalStart, - mdp->NumberOfPages); + printf("MD %p: type %d pa 0x%lx cnt 0x%lx\n", md, + md->md_type, md->md_phys, md->md_pages); #endif - pfn0 = ia64_btop(round_page(mdp->PhysicalStart)); - pfn1 = ia64_btop(trunc_page(mdp->PhysicalStart - + mdp->NumberOfPages * 4096)); + pfn0 = ia64_btop(round_page(md->md_phys)); + pfn1 = ia64_btop(trunc_page(md->md_phys + md->md_pages * 4096)); if (pfn1 <= pfn0) continue; - if (mdp->Type != EfiConventionalMemory) + if (md->md_type != EFI_MD_TYPE_FREE) continue; /* @@ -651,12 +649,12 @@ ia64_init(void) */ if (pfn0 >= ia64_btop(0x100000000UL)) { printf("Skipping memory chunk start 0x%lx\n", - mdp->PhysicalStart); + md->md_phys); continue; } if (pfn1 >= ia64_btop(0x100000000UL)) { printf("Skipping memory chunk end 0x%lx\n", - mdp->PhysicalStart + mdp->NumberOfPages * 4096); + md->md_phys + md->md_pages * 4096); continue; } @@ -672,7 +670,7 @@ ia64_init(void) * within the segment. */ #ifdef DEBUG_MD - printf("Descriptor %d contains kernel\n", i); + printf("Descriptor %p contains kernel\n", mp); #endif if (pfn0 < kernstartpfn) { /* diff --git a/sys/ia64/ia64/sal.c b/sys/ia64/ia64/sal.c index 220910c..c05f7be 100644 --- a/sys/ia64/ia64/sal.c +++ b/sys/ia64/ia64/sal.c @@ -22,16 +22,18 @@ * 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/cdefs.h> +__FBSDID("$FreeBSD$"); + #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> #include <sys/malloc.h> #include <vm/vm.h> #include <vm/vm_kern.h> +#include <machine/efi.h> #include <machine/md_var.h> #include <machine/sal.h> #include <machine/smp.h> @@ -49,6 +51,9 @@ static sal_entry_t fake_sal; extern u_int64_t ia64_pal_entry; sal_entry_t *ia64_sal_entry = fake_sal; +static struct uuid sal_table = EFI_TABLE_SAL; +static struct sal_system_table *sal_systbl; + static struct ia64_sal_result 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) @@ -77,7 +82,7 @@ setup_ipi_vectors(int ceil) } void -ia64_sal_init(struct sal_system_table *saltab) +ia64_sal_init(void) { static int sizes[6] = { 48, 32, 16, 32, 16, 16 @@ -85,13 +90,17 @@ ia64_sal_init(struct sal_system_table *saltab) u_int8_t *p; int i; - if (memcmp(saltab->sal_signature, SAL_SIGNATURE, 4)) { + sal_systbl = efi_get_table(&sal_table); + if (sal_systbl == NULL) + return; + + if (memcmp(sal_systbl->sal_signature, SAL_SIGNATURE, 4)) { printf("Bad signature for SAL System Table\n"); return; } - p = (u_int8_t *) (saltab + 1); - for (i = 0; i < saltab->sal_entry_count; i++) { + p = (u_int8_t *) (sal_systbl + 1); + for (i = 0; i < sal_systbl->sal_entry_count; i++) { switch (*p) { case 0: { struct sal_entrypoint_descriptor *dp; diff --git a/sys/ia64/include/efi.h b/sys/ia64/include/efi.h index 2363812..7da17be 100644 --- a/sys/ia64/include/efi.h +++ b/sys/ia64/include/efi.h @@ -1,44 +1,163 @@ -/*- - * Copyright (c) 2001 Doug Rabson +/* + * Copyright (c) 2004 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 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. + * 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$ + * $FreeBSD$ */ #ifndef _MACHINE_EFI_H_ #define _MACHINE_EFI_H_ -#include <boot/efi/include/ia64/efibind.h> -#include <boot/efi/include/efidef.h> -#include <boot/efi/include/efierr.h> -#include <boot/efi/include/efidevp.h> -#include <boot/efi/include/eficon.h> -#include <boot/efi/include/efiapi.h> +#include <sys/uuid.h> + +#define EFI_PAGE_SHIFT 12 +#define EFI_PAGE_SIZE (1 << EFI_PAGE_SHIFT) +#define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1) + +#define EFI_TABLE_ACPI20 \ + {0x8868e871,0xe4f1,0x11d3,0xbc,0x22,{0x00,0x80,0xc7,0x3c,0x88,0x81}} +#define EFI_TABLE_SAL \ + {0xeb9d2d32,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}} + +enum efi_reset { + EFI_RESET_COLD, + EFI_RESET_WARM +}; + +typedef uint16_t efi_char; +typedef unsigned long efi_status; + +struct efi_cfgtbl { + struct uuid ct_uuid; + uint64_t ct_data; +}; + +struct efi_md { + uint32_t md_type; +#define EFI_MD_TYPE_NULL 0 +#define EFI_MD_TYPE_CODE 1 /* Loader text. */ +#define EFI_MD_TYPE_DATA 2 /* Loader data. */ +#define EFI_MD_TYPE_BS_CODE 3 /* Boot services text. */ +#define EFI_MD_TYPE_BS_DATA 4 /* Boot services data. */ +#define EFI_MD_TYPE_RT_CODE 5 /* Runtime services text. */ +#define EFI_MD_TYPE_RT_DATA 6 /* Runtime services data. */ +#define EFI_MD_TYPE_FREE 7 /* Unused/free memory. */ +#define EFI_MD_TYPE_BAD 8 /* Bad memory */ +#define EFI_MD_TYPE_RECLAIM 9 /* ACPI reclaimable memory. */ +#define EFI_MD_TYPE_FIRMWARE 10 /* ACPI NV memory */ +#define EFI_MD_TYPE_IOMEM 11 /* Memory-mapped I/O. */ +#define EFI_MD_TYPE_IOPORT 12 /* I/O port space. */ +#define EFI_MD_TYPE_PALCODE 13 /* PAL */ + uint32_t __pad; + uint64_t md_phys; + void *md_virt; + uint64_t md_pages; + uint64_t md_attr; +#define EFI_MD_ATTR_UC 0x0000000000000001UL +#define EFI_MD_ATTR_WC 0x0000000000000002UL +#define EFI_MD_ATTR_WT 0x0000000000000004UL +#define EFI_MD_ATTR_WB 0x0000000000000008UL +#define EFI_MD_ATTR_UCE 0x0000000000000010UL +#define EFI_MD_ATTR_WP 0x0000000000001000UL +#define EFI_MD_ATTR_RP 0x0000000000002000UL +#define EFI_MD_ATTR_XP 0x0000000000004000UL +#define EFI_MD_ATTR_RT 0x8000000000000000UL +}; + +struct efi_tm { + uint16_t tm_year; /* 1998 - 20XX */ + uint8_t tm_mon; /* 1 - 12 */ + uint8_t tm_mday; /* 1 - 31 */ + uint8_t tm_hour; /* 0 - 23 */ + uint8_t tm_min; /* 0 - 59 */ + uint8_t tm_sec; /* 0 - 59 */ + uint8_t __pad1; + uint32_t tm_nsec; /* 0 - 999,999,999 */ + int16_t tm_tz; /* -1440 to 1440 or 2047 */ + uint8_t tm_dst; + uint8_t __pad2; +}; + +struct efi_tmcap { + uint32_t tc_res; /* 1e-6 parts per million */ + uint32_t tc_prec; /* hertz */ + uint8_t tc_stz; /* Set clears sub-second time */ +}; + +struct efi_tblhdr { + uint64_t th_sig; + uint32_t th_rev; + uint32_t th_hdrsz; + uint32_t th_crc32; + uint32_t __res; +}; + +struct efi_rt { + struct efi_tblhdr rt_hdr; + efi_status (*rt_gettime)(struct efi_tm *, struct efi_tmcap *); + efi_status (*rt_settime)(struct efi_tm *); + efi_status (*rt_getwaketime)(uint8_t *, uint8_t *, + struct efi_tm *); + efi_status (*rt_setwaketime)(uint8_t, struct efi_tm *); + efi_status (*rt_setvirtual)(u_long, u_long, uint32_t, + struct efi_md *); + efi_status (*rt_cvtptr)(u_long, void **); + efi_status (*rt_getvar)(efi_char *, struct uuid *, uint32_t *, + u_long *, void *); + efi_status (*rt_scanvar)(u_long *, efi_char *, struct uuid *); + efi_status (*rt_setvar)(efi_char *, struct uuid *, uint32_t, + u_long, void *); + efi_status (*rt_gethicnt)(uint32_t *); + efi_status (*rt_reset)(enum efi_reset, efi_status, u_long, + efi_char *); +}; -extern EFI_SYSTEM_TABLE *ia64_efi_systab; -extern EFI_RUNTIME_SERVICES *ia64_efi_runtime; +struct efi_systbl { + struct efi_tblhdr st_hdr; +#define EFI_SYSTBL_SIG 0x5453595320494249UL + efi_char *st_fwvendor; + uint32_t st_fwrev; + uint32_t __pad; + void *st_cin; + void *st_cinif; + void *st_cout; + void *st_coutif; + void *st_cerr; + void *st_cerrif; + uint64_t st_rt; + void *st_bs; + u_long st_entries; + uint64_t st_cfgtbl; +}; -extern void ia64_efi_init(void); +void efi_boot_finish(void); +int efi_boot_minimal(uint64_t); +void *efi_get_table(struct uuid *); +void efi_get_time(struct efi_tm *); +struct efi_md *efi_md_first(void); +struct efi_md *efi_md_next(struct efi_md *); +void efi_reset_system(void); +efi_status efi_set_time(struct efi_tm *); #endif /* _MACHINE_EFI_H_ */ diff --git a/sys/ia64/include/sal.h b/sys/ia64/include/sal.h index abe7c1f..759cc9f 100644 --- a/sys/ia64/include/sal.h +++ b/sys/ia64/include/sal.h @@ -137,6 +137,6 @@ typedef struct ia64_sal_result sal_entry_t extern sal_entry_t *ia64_sal_entry; -extern void ia64_sal_init(struct sal_system_table *saltab); +extern void ia64_sal_init(void); #endif /* _MACHINE_SAL_H_ */ |