PERFORCE change 108874 for review
Marcel Moolenaar
marcel at FreeBSD.org
Tue Oct 31 23:54:38 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=108874
Change 108874 by marcel at marcel_cluster on 2006/10/31 23:53:48
Major restructuring. The EFI and SKI loaders now share most of
what can be shared.
Bump the version of the loaders to 1.2 due to there being some
user-visible changes.
Affected files ...
.. //depot/projects/ia64/sys/boot/ia64/Makefile#4 edit
.. //depot/projects/ia64/sys/boot/ia64/common/Makefile#1 add
.. //depot/projects/ia64/sys/boot/ia64/common/autoload.c#1 add
.. //depot/projects/ia64/sys/boot/ia64/common/bootinfo.c#2 edit
.. //depot/projects/ia64/sys/boot/ia64/common/copy.c#2 edit
.. //depot/projects/ia64/sys/boot/ia64/common/devicename.c#3 edit
.. //depot/projects/ia64/sys/boot/ia64/common/elf_freebsd.c#2 delete
.. //depot/projects/ia64/sys/boot/ia64/common/exec.c#1 add
.. //depot/projects/ia64/sys/boot/ia64/common/libia64.h#1 add
.. //depot/projects/ia64/sys/boot/ia64/efi/Makefile#6 edit
.. //depot/projects/ia64/sys/boot/ia64/efi/conf.c#4 edit
.. //depot/projects/ia64/sys/boot/ia64/efi/efimd.c#3 edit
.. //depot/projects/ia64/sys/boot/ia64/efi/main.c#4 edit
.. //depot/projects/ia64/sys/boot/ia64/efi/version#2 edit
.. //depot/projects/ia64/sys/boot/ia64/ski/Makefile#7 edit
.. //depot/projects/ia64/sys/boot/ia64/ski/acpi_stub.c#3 edit
.. //depot/projects/ia64/sys/boot/ia64/ski/bootinfo.c#7 delete
.. //depot/projects/ia64/sys/boot/ia64/ski/copy.c#4 delete
.. //depot/projects/ia64/sys/boot/ia64/ski/devicename.c#2 delete
.. //depot/projects/ia64/sys/boot/ia64/ski/efi_stub.c#3 edit
.. //depot/projects/ia64/sys/boot/ia64/ski/elf_freebsd.c#3 delete
.. //depot/projects/ia64/sys/boot/ia64/ski/libski.h#2 edit
.. //depot/projects/ia64/sys/boot/ia64/ski/main.c#2 edit
.. //depot/projects/ia64/sys/boot/ia64/ski/skifs.c#2 edit
.. //depot/projects/ia64/sys/boot/ia64/ski/skimd.c#1 add
.. //depot/projects/ia64/sys/boot/ia64/ski/version#2 edit
Differences ...
==== //depot/projects/ia64/sys/boot/ia64/Makefile#4 (text+ko) ====
@@ -1,5 +1,5 @@
# $FreeBSD: src/sys/boot/ia64/Makefile,v 1.4 2004/11/23 06:03:03 marcel Exp $
-SUBDIR= efi ski
+SUBDIR= common efi ski
.include <bsd.subdir.mk>
==== //depot/projects/ia64/sys/boot/ia64/common/bootinfo.c#2 (text+ko) ====
@@ -32,19 +32,11 @@
#include <sys/param.h>
#include <sys/reboot.h>
#include <sys/linker.h>
-#include <machine/elf.h>
-#include <machine/bootinfo.h>
#include <efi.h>
#include <efilib.h>
-#include "bootstrap.h"
-
-/* DIG64 Headless Console & Debug Port Table. */
-#define HCDP_TABLE_GUID \
- {0xf951938d,0x620b,0x42ef,{0x82,0x79,0xa8,0x4b,0x79,0x61,0x78,0x98}}
-
-static EFI_GUID hcdp = HCDP_TABLE_GUID;
+#include "libia64.h"
/*
* Return a 'boothowto' value corresponding to the kernel arguments in
@@ -52,92 +44,60 @@
*/
static struct
{
- const char *ev;
- int mask;
+ const char *ev;
+ int mask;
} howto_names[] = {
- {"boot_askname", RB_ASKNAME},
- {"boot_cdrom", RB_CDROM},
- {"boot_ddb", RB_KDB},
- {"boot_dfltroot", RB_DFLTROOT},
- {"boot_gdb", RB_GDB},
- {"boot_multicons", RB_MULTIPLE},
- {"boot_mute", RB_MUTE},
- {"boot_pause", RB_PAUSE},
- {"boot_serial", RB_SERIAL},
- {"boot_single", RB_SINGLE},
- {"boot_verbose", RB_VERBOSE},
- {NULL, 0}
+ { "boot_askname", RB_ASKNAME},
+ { "boot_cdrom", RB_CDROM},
+ { "boot_ddb", RB_KDB},
+ { "boot_dfltroot", RB_DFLTROOT},
+ { "boot_gdb", RB_GDB},
+ { "boot_multicons", RB_MULTIPLE},
+ { "boot_mute", RB_MUTE},
+ { "boot_pause", RB_PAUSE},
+ { "boot_serial", RB_SERIAL},
+ { "boot_single", RB_SINGLE},
+ { "boot_verbose", RB_VERBOSE},
+ { NULL, 0}
};
-extern char *efi_fmtdev(void *vdev);
+static const char howto_switches[] = "aCdrgDmphsv";
+static int howto_masks[] = {
+ RB_ASKNAME, RB_CDROM, RB_KDB, RB_DFLTROOT, RB_GDB, RB_MULTIPLE,
+ RB_MUTE, RB_PAUSE, RB_SERIAL, RB_SINGLE, RB_VERBOSE
+};
int
bi_getboothowto(char *kargs)
{
- char *cp;
- int howto;
- int active;
- int i;
-
- /* Parse kargs */
- howto = 0;
- if (kargs != NULL) {
- cp = kargs;
- active = 0;
- while (*cp != 0) {
- if (!active && (*cp == '-')) {
- active = 1;
- } else if (active)
- switch (*cp) {
- case 'a':
- howto |= RB_ASKNAME;
- break;
- case 'C':
- howto |= RB_CDROM;
- break;
- case 'd':
- howto |= RB_KDB;
- break;
- case 'D':
- howto |= RB_MULTIPLE;
- break;
- case 'm':
- howto |= RB_MUTE;
- break;
- case 'g':
- howto |= RB_GDB;
- break;
- case 'h':
- howto |= RB_SERIAL;
- break;
- case 'p':
- howto |= RB_PAUSE;
- break;
- case 'r':
- howto |= RB_DFLTROOT;
- break;
- case 's':
- howto |= RB_SINGLE;
- break;
- case 'v':
- howto |= RB_VERBOSE;
- break;
- default:
- active = 0;
- break;
+ const char *sw;
+ char *opts;
+ int howto, i;
+
+ howto = 0;
+
+ /* Get the boot options from the environment first. */
+ for (i = 0; howto_names[i].ev != NULL; i++) {
+ if (getenv(howto_names[i].ev) != NULL)
+ howto |= howto_names[i].mask;
+ }
+
+ /* Parse kargs */
+ if (kargs == NULL)
+ return (howto);
+
+ opts = strchr(kargs, '-');
+ while (opts != NULL) {
+ while (*(++opts) != '\0') {
+ sw = strchr(howto_switches, *opts);
+ if (sw == NULL)
+ break;
+ howto |= howto_masks[sw - howto_switches];
}
- cp++;
+ opts = strchr(opts, '-');
}
- }
- /* get equivalents from the environment */
- for (i = 0; howto_names[i].ev != NULL; i++)
- if (getenv(howto_names[i].ev) != NULL)
- howto |= howto_names[i].mask;
- if (!strcmp(getenv("console"), "comconsole"))
- howto |= RB_SERIAL;
- if (!strcmp(getenv("console"), "nullconsole"))
- howto |= RB_MUTE;
- return(howto);
+
+ return (howto);
}
/*
@@ -146,26 +106,37 @@
* separating each variable, and a double nul terminating the environment.
*/
vm_offset_t
-bi_copyenv(vm_offset_t addr)
+bi_copyenv(vm_offset_t start)
{
- struct env_var *ep;
-
- /* traverse the environment */
- for (ep = environ; ep != NULL; ep = ep->ev_next) {
- efi_copyin(ep->ev_name, addr, strlen(ep->ev_name));
- addr += strlen(ep->ev_name);
- efi_copyin("=", addr, 1);
- addr++;
- if (ep->ev_value != NULL) {
- efi_copyin(ep->ev_value, addr, strlen(ep->ev_value));
- addr += strlen(ep->ev_value);
+ struct env_var *ep;
+ vm_offset_t addr, last;
+ size_t len;
+
+ addr = last = start;
+
+ /* Traverse the environment. */
+ for (ep = environ; ep != NULL; ep = ep->ev_next) {
+ len = strlen(ep->ev_name);
+ if (ia64_copyin(ep->ev_name, addr, len) != len)
+ break;
+ addr += len;
+ if (ia64_copyin("=", addr, 1) != 1)
+ break;
+ addr++;
+ if (ep->ev_value != NULL) {
+ len = strlen(ep->ev_value);
+ if (ia64_copyin(ep->ev_value, addr, len) != len)
+ break;
+ addr += len;
+ }
+ if (ia64_copyin("", addr, 1) != 1)
+ break;
+ last = ++addr;
}
- efi_copyin("", addr, 1);
- addr++;
- }
- efi_copyin("", addr, 1);
- addr++;
- return(addr);
+
+ if (ia64_copyin("", last++, 1) != 1)
+ last = start;
+ return(last);
}
/*
@@ -186,14 +157,14 @@
*/
#define COPY32(v, a) { \
u_int32_t x = (v); \
- efi_copyin(&x, a, sizeof(x)); \
+ ia64_copyin(&x, a, sizeof(x)); \
a += sizeof(x); \
}
#define MOD_STR(t, a, s) { \
COPY32(t, a); \
COPY32(strlen(s) + 1, a); \
- efi_copyin(s, a, strlen(s) + 1); \
+ ia64_copyin(s, a, strlen(s) + 1); \
a += roundup(strlen(s) + 1, sizeof(u_int64_t));\
}
@@ -204,7 +175,7 @@
#define MOD_VAR(t, a, s) { \
COPY32(t, a); \
COPY32(sizeof(s), a); \
- efi_copyin(&s, a, sizeof(s)); \
+ ia64_copyin(&s, a, sizeof(s)); \
a += roundup(sizeof(s), sizeof(u_int64_t)); \
}
@@ -214,7 +185,7 @@
#define MOD_METADATA(a, mm) { \
COPY32(MODINFO_METADATA | mm->md_type, a); \
COPY32(mm->md_size, a); \
- efi_copyin(mm->md_data, a, mm->md_size); \
+ ia64_copyin(mm->md_data, a, mm->md_size); \
a += roundup(mm->md_size, sizeof(u_int64_t));\
}
@@ -226,24 +197,25 @@
vm_offset_t
bi_copymodules(vm_offset_t addr)
{
- struct preloaded_file *fp;
- struct file_metadata *md;
+ struct preloaded_file *fp;
+ struct file_metadata *md;
- /* start with the first module on the list, should be the kernel */
- for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) {
-
- MOD_NAME(addr, fp->f_name); /* this field must come first */
- MOD_TYPE(addr, fp->f_type);
- if (fp->f_args)
- MOD_ARGS(addr, fp->f_args);
- MOD_ADDR(addr, fp->f_addr);
- MOD_SIZE(addr, fp->f_size);
- for (md = fp->f_metadata; md != NULL; md = md->md_next)
- if (!(md->md_type & MODINFOMD_NOCOPY))
- MOD_METADATA(addr, md);
- }
- MOD_END(addr);
- return(addr);
+ /* Start with the first module on the list, should be the kernel. */
+ for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) {
+ /* The name field must come first. */
+ MOD_NAME(addr, fp->f_name);
+ MOD_TYPE(addr, fp->f_type);
+ if (fp->f_args)
+ MOD_ARGS(addr, fp->f_args);
+ MOD_ADDR(addr, fp->f_addr);
+ MOD_SIZE(addr, fp->f_size);
+ for (md = fp->f_metadata; md != NULL; md = md->md_next) {
+ if (!(md->md_type & MODINFOMD_NOCOPY))
+ MOD_METADATA(addr, md);
+ }
+ }
+ MOD_END(addr);
+ return(addr);
}
/*
@@ -253,103 +225,76 @@
* - Module metadata are formatted and placed in kernel space.
*/
int
-bi_load(struct bootinfo *bi, struct preloaded_file *fp, UINTN *mapkey,
- UINTN pages)
+bi_load(struct preloaded_file *fp, uint64_t *bi_addr)
{
- char *rootdevname;
- struct efi_devdesc *rootdev;
- struct preloaded_file *xp;
- vm_offset_t addr, bootinfo_addr;
- vm_offset_t ssym, esym;
- struct file_metadata *md;
- EFI_STATUS status;
- UINTN bisz, key;
+ struct bootinfo bi;
+ struct preloaded_file *xp;
+ struct file_metadata *md;
+ struct devdesc *rootdev;
+ char *rootdevname;
+ vm_offset_t addr, ssym, esym;
- /*
- * Version 1 bootinfo.
- */
- bi->bi_magic = BOOTINFO_MAGIC;
- bi->bi_version = 1;
+ bzero(&bi, sizeof(struct bootinfo));
+ bi.bi_magic = BOOTINFO_MAGIC;
+ bi.bi_version = 1;
+ bi.bi_boothowto = bi_getboothowto(fp->f_args);
- /*
- * Calculate boothowto.
- */
- bi->bi_boothowto = bi_getboothowto(fp->f_args);
+ /*
+ * Allow the environment variable 'rootdev' to override the supplied
+ * device. This should perhaps go to MI code and/or have $rootdev
+ * tested/set by MI code before launching the kernel.
+ */
+ rootdevname = getenv("rootdev");
+ ia64_getdev((void**)&rootdev, rootdevname, NULL);
+ if (rootdev != NULL) {
+ /* Try reading /etc/fstab to select the root device. */
+ getrootmount(ia64_fmtdev(rootdev));
+ free(rootdev);
+ }
- /*
- * Stash EFI System Table.
- */
- bi->bi_systab = (u_int64_t) ST;
+ md = file_findmetadata(fp, MODINFOMD_SSYM);
+ ssym = (md != NULL) ? *((vm_offset_t *)&(md->md_data)) : 0;
+ md = file_findmetadata(fp, MODINFOMD_ESYM);
+ esym = (md != NULL) ? *((vm_offset_t *)&(md->md_data)) : 0;
+ if (ssym != 0 && esym != 0) {
+ bi.bi_symtab = ssym;
+ bi.bi_esymtab = esym;
+ }
- /*
- * Allow the environment variable 'rootdev' to override the supplied
- * device. This should perhaps go to MI code and/or have $rootdev
- * tested/set by MI code before launching the kernel.
- */
- rootdevname = getenv("rootdev");
- efi_getdev((void **)(&rootdev), rootdevname, NULL);
- if (rootdev == NULL) { /* bad $rootdev/$currdev */
- printf("can't determine root device\n");
- return(EINVAL);
- }
+ /* Find the last module in the chain. */
+ addr = 0;
+ for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
+ if (addr < (xp->f_addr + xp->f_size))
+ addr = xp->f_addr + xp->f_size;
+ }
- /* Try reading the /etc/fstab file to select the root device */
- getrootmount(efi_fmtdev((void *)rootdev));
- free(rootdev);
+ addr = (addr + 15) & ~15;
- ssym = esym = 0;
- if ((md = file_findmetadata(fp, MODINFOMD_SSYM)) != NULL)
- ssym = *((vm_offset_t *)&(md->md_data));
- if ((md = file_findmetadata(fp, MODINFOMD_ESYM)) != NULL)
- esym = *((vm_offset_t *)&(md->md_data));
- if (ssym == 0 || esym == 0)
- ssym = esym = 0; /* sanity */
+ /* Copy module list and metadata. */
+ bi.bi_modulep = addr;
+ addr = bi_copymodules(addr);
+ if (addr <= bi.bi_modulep) {
+ addr = bi.bi_modulep;
+ bi.bi_modulep = 0;
+ }
- bi->bi_symtab = ssym;
- bi->bi_esymtab = esym;
+ addr = (addr + 15) & ~15;
- bi->bi_hcdp = (uint64_t)efi_get_table(&hcdp); /* DIG64 HCDP table addr. */
- fpswa_init(&bi->bi_fpswa); /* find FPSWA interface */
+ /* Copy our environment. */
+ bi.bi_envp = addr;
+ addr = bi_copyenv(addr);
+ if (addr <= bi.bi_envp) {
+ addr = bi.bi_envp;
+ bi.bi_envp = 0;
+ }
- /* find the last module in the chain */
- addr = 0;
- for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
- if (addr < (xp->f_addr + xp->f_size))
- addr = xp->f_addr + xp->f_size;
- }
+ addr = (addr + PAGE_MASK) & ~PAGE_MASK;
+ bi.bi_kernend = addr;
- /* pad to a page boundary */
- addr = (addr + PAGE_MASK) & ~PAGE_MASK;
+ if (ia64_pgtbl != NULL && ia64_pgtblsz != 0) {
+ bi.bi_pgtbl = (uintptr_t)ia64_pgtbl;
+ bi.bi_pgtblsz = ia64_pgtblsz;
+ }
- /* copy our environment */
- bi->bi_envp = addr;
- addr = bi_copyenv(addr);
-
- /* pad to a page boundary */
- addr = (addr + PAGE_MASK) & ~PAGE_MASK;
-
- /* copy module list and metadata */
- bi->bi_modulep = addr;
- addr = bi_copymodules(addr);
-
- /* all done copying stuff in, save end of loaded object space */
- bi->bi_kernend = addr;
-
- /*
- * Read the memory map and stash it after bootinfo. Align the memory map
- * on a 16-byte boundary (the bootinfo block is page aligned).
- */
- bisz = (sizeof(struct bootinfo) + 0x0f) & ~0x0f;
- bi->bi_memmap = ((u_int64_t)bi) + bisz;
- bi->bi_memmap_size = EFI_PAGE_SIZE * pages - bisz;
- status = BS->GetMemoryMap(&bi->bi_memmap_size,
- (EFI_MEMORY_DESCRIPTOR *)bi->bi_memmap, &key,
- &bi->bi_memdesc_size, &bi->bi_memdesc_version);
- if (EFI_ERROR(status)) {
- printf("bi_load: Can't read memory map\n");
- return EINVAL;
- }
- *mapkey = key;
-
- return(0);
+ return (ldr_bootinfo(&bi, bi_addr));
}
==== //depot/projects/ia64/sys/boot/ia64/common/copy.c#2 (text+ko) ====
@@ -1,55 +1,152 @@
/*-
- * Copyright (c) 1998 Michael Smith <msmith at freebsd.org>
+ * Copyright (c) 2006 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.
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/efi/libefi/copy.c,v 1.6 2004/11/28 00:30:22 marcel Exp $");
+__FBSDID("$FreeBSD$");
-#include <efi.h>
-#include <efilib.h>
#include <stand.h>
+#include <ia64/include/vmparam.h>
-int
-efi_copyin(void *src, vm_offset_t va, size_t len)
+#include "libia64.h"
+
+#define LDR_LOG2_PGSZ 20
+
+uint64_t *ia64_pgtbl;
+uint32_t ia64_pgtblsz;
+
+static void *
+va2pa(vm_offset_t va, size_t *len)
+{
+ uint64_t pa;
+ uint32_t idx, ofs;
+
+ /* Backward compatibility. */
+ if (va >= IA64_RR_BASE(7)) {
+ pa = IA64_RR_MASK(va);
+ return ((void *)pa);
+ }
+
+ printf("\n%s: va=%lx, *len=%lx: pa=", __func__, va, *len);
+
+ /* We can not copy more than a page at a time. */
+ if (*len > (1UL << LDR_LOG2_PGSZ))
+ *len = 1UL << LDR_LOG2_PGSZ;
+
+ if (va < IA64_KERNELBASE) {
+ printf("\n%s: %lx: invalid loader virtual address\n",
+ __func__, va);
+ *len = 0;
+ return (NULL);
+ }
+
+ va -= IA64_KERNELBASE;
+ idx = va >> LDR_LOG2_PGSZ;
+ if (idx >= (ia64_pgtblsz >> 3)) {
+ printf("\n%s: %lx: loader virtual address out of bounds\n",
+ __func__, va);
+ *len = 0;
+ return (NULL);
+ }
+
+ ofs = va & ((1U << LDR_LOG2_PGSZ) - 1);
+ pa = ia64_pgtbl[idx];
+ if (pa == 0) {
+ pa = ldr_alloc(va - ofs);
+ if (pa == 0) {
+ *len = 0;
+ return (NULL);
+ }
+ ia64_pgtbl[idx] = pa;
+ }
+ *len -= ofs;
+ printf("%lx\n", pa + ofs);
+ return ((void *)(pa + ofs));
+}
+
+ssize_t
+ia64_copyin(const void *src, vm_offset_t va, size_t len)
{
+ void *pa;
+ ssize_t res;
+ size_t sz;
- bcopy(src, (void *)efimd_va2pa(va), len);
- return (len);
+ res = 0;
+ while (len > 0) {
+ sz = len;
+ pa = va2pa(va, &sz);
+ if (sz == 0)
+ break;
+ bcopy(src, pa, sz);
+ len -= sz;
+ res += sz;
+ va += sz;
+ }
+ return (res);
}
-int
-efi_copyout(vm_offset_t va, void *dst, size_t len)
+ssize_t
+ia64_copyout(vm_offset_t va, void *dst, size_t len)
{
+ void *pa;
+ ssize_t res;
+ size_t sz;
- bcopy((void *)efimd_va2pa(va), dst, len);
- return (len);
+ res = 0;
+ while (len > 0) {
+ sz = len;
+ pa = va2pa(va, &sz);
+ if (sz == 0)
+ break;
+ bcopy(pa, dst, sz);
+ len -= sz;
+ res += sz;
+ va += sz;
+ }
+ return (res);
}
-int
-efi_readin(int fd, vm_offset_t va, size_t len)
+ssize_t
+ia64_readin(int fd, vm_offset_t va, size_t len)
{
+ void *pa;
+ ssize_t res, s;
+ size_t sz;
- return (read(fd, (void *)efimd_va2pa(va), len));
+ res = 0;
+ while (len > 0) {
+ sz = len;
+ pa = va2pa(va, &sz);
+ if (sz == 0)
+ break;
+ s = read(fd, pa, sz);
+ if (s <= 0)
+ break;
+ len -= s;
+ res += s;
+ va += s;
+ }
+ return (res);
}
==== //depot/projects/ia64/sys/boot/ia64/common/devicename.c#3 (text+ko) ====
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 1998 Michael Smith <msmith at freebsd.org>
+ * Copyright (c) 2006 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,7 +36,7 @@
#include <efi.h>
#include <efilib.h>
-static int efi_parsedev(struct devdesc **dev, const char *devspec, const char **path);
+static int ia64_parsedev(struct devdesc **, const char *, const char **);
/*
* Point (dev) at an allocated device specifier for the device matching the
@@ -43,29 +44,24 @@
* use that. If not, use the default device.
*/
int
-efi_getdev(void **vdev, const char *devspec, const char **path)
+ia64_getdev(void **vdev, const char *devspec, const char **path)
{
struct devdesc **dev = (struct devdesc **)vdev;
- int rv;
-
+ int rv;
+
/*
- * If it looks like this is just a path and no
- * device, go with the current device.
+ * If it looks like this is just a path and no device, then
+ * use the current device instead.
*/
- if ((devspec == NULL) ||
- (devspec[0] == '/') ||
- (strchr(devspec, ':') == NULL)) {
-
- if (((rv = efi_parsedev(dev, getenv("currdev"), NULL)) == 0) &&
- (path != NULL))
+ if (devspec == NULL || *devspec == '/' || !strchr(devspec, ':')) {
+ rv = ia64_parsedev(dev, getenv("currdev"), NULL);
+ if (rv == 0 && path != NULL)
*path = devspec;
- return(rv);
+ return (rv);
}
-
- /*
- * Try to parse the device name off the beginning of the devspec
- */
- return(efi_parsedev(dev, devspec, path));
+
+ /* Parse the device name off the beginning of the devspec. */
+ return (ia64_parsedev(dev, devspec, path));
}
/*
@@ -82,13 +78,13 @@
* fs<unit>:
*/
static int
-efi_parsedev(struct devdesc **dev, const char *devspec, const char **path)
+ia64_parsedev(struct devdesc **dev, const char *devspec, const char **path)
{
struct devdesc *idev;
- struct devsw *dv;
- int i, err;
- char *cp;
- const char *np;
+ struct devsw *dv;
+ char *cp;
+ const char *np;
+ int i, err;
/* minimum length check */
if (strlen(devspec) < 2)
@@ -106,13 +102,14 @@
idev = malloc(sizeof(struct devdesc));
if (idev == NULL)
return (ENOMEM);
+
idev->d_dev = dv;
idev->d_type = dv->dv_type;
idev->d_unit = -1;
err = 0;
- np = (devspec + strlen(dv->dv_name));
- if (*np && (*np != ':')) {
+ np = devspec + strlen(dv->dv_name);
+ if (*np != '\0' && *np != ':') {
idev->d_unit = strtol(np, &cp, 0);
if (cp == np) {
idev->d_unit = -1;
@@ -120,7 +117,7 @@
return (EUNIT);
}
}
- if (*cp && (*cp != ':')) {
+ if (*cp != '\0' && *cp != ':') {
free(idev);
return (EINVAL);
}
@@ -131,46 +128,42 @@
*dev = idev;
else
free(idev);
- return(0);
+ return (0);
}
-
char *
-efi_fmtdev(void *vdev)
+ia64_fmtdev(void *vdev)
{
struct devdesc *dev = (struct devdesc *)vdev;
- static char buf[128]; /* XXX device length constant? */
+ static char buf[32]; /* XXX device length constant? */
switch(dev->d_type) {
case DEVT_NONE:
strcpy(buf, "(no device)");
break;
- case DEVT_DISK:
+ default:
sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
break;
+ }
- case DEVT_NET:
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
- break;
- }
return(buf);
}
-
/*
* Set currdev to suit the value being supplied in (value)
*/
int
-efi_setcurrdev(struct env_var *ev, int flags, const void *value)
+ia64_setcurrdev(struct env_var *ev, int flags, const void *value)
{
struct devdesc *ncurr;
- int rv;
-
- if ((rv = efi_parsedev(&ncurr, value, NULL)) != 0)
+ int rv;
+
+ rv = ia64_parsedev(&ncurr, value, NULL);
+ if (rv != 0)
return(rv);
+
free(ncurr);
env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
- return(0);
+ return (0);
}
-
==== //depot/projects/ia64/sys/boot/ia64/efi/Makefile#6 (text+ko) ====
@@ -6,48 +6,22 @@
PROG= loader.sym
INTERNALPROG=
-SRCS= bootinfo.c conf.c copy.c dev_net.c devicename.c efifpswa.c \
- efimd.c elf_freebsd.c main.c pal.S start.S vers.c
+SRCS= conf.c efimd.c main.c pal.S start.S vers.c
+
+.PATH: ${.CURDIR}/../../../${MACHINE_ARCH}/${MACHINE_ARCH}
-CFLAGS+= -DLOADER
+CFLAGS+= -I${.CURDIR}/../common
+CFLAGS+= -I${.CURDIR}/../../common
CFLAGS+= -I${.CURDIR}/../../efi/include
CFLAGS+= -I${.CURDIR}/../../efi/include/${MACHINE_ARCH}
-CFLAGS+= -I${.CURDIR}/../../efi/libefi
+CFLAGS+= -I${.CURDIR}/../../..
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand
-.if ${MK_FORTH} != "no"
-BOOT_FORTH= yes
-CFLAGS+= -DBOOT_FORTH
-CFLAGS+= -I${.CURDIR}/../../ficl
-CFLAGS+= -I${.CURDIR}/../../ficl/${MACHINE_ARCH}
-LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
-.endif
-
-.PATH: ${.CURDIR}/../common
-.PATH: ${.CURDIR}/../../../${MACHINE_ARCH}/${MACHINE_ARCH}
-
-# Always add MI sources
-.PATH: ${.CURDIR}/../../common
-.include "${.CURDIR}/../../common/Makefile.inc"
-
-CFLAGS+= -I${.CURDIR}/../../common
-
-.PATH: ${.CURDIR}/../../forth
-FILES= loader.efi loader.help loader.4th support.4th loader.conf
-FILESMODE_loader.efi= ${BINMODE}
-FILESDIR_loader.conf= /boot/defaults
-
-.if !exists(${DESTDIR}/boot/loader.rc)
-FILES+= loader.rc
-.endif
-
LDSCRIPT= ${.CURDIR}/ldscript.${MACHINE_ARCH}
LDFLAGS= -Wl,-T${LDSCRIPT} -shared -symbolic
${PROG}: ${LDSCRIPT}
-CLEANFILES= vers.c loader.efi loader.help
-
NEWVERSWHAT= "EFI boot" ${MACHINE_ARCH}
vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
@@ -56,22 +30,28 @@
OBJCOPY?= objcopy
OBJDUMP?= objdump
+FILES= loader.efi
+FILESMODE_loader.efi= ${BINMODE}
+
loader.efi: loader.sym
if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \
${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \
+ rm ${.ALLSRC}; \
exit 1; \
fi
${OBJCOPY} -j .data -j .dynamic -j .dynstr -j .dynsym -j .hash \
-j .rela.dyn -j .reloc -j .sdata -j .text \
--target=efi-app-${MACHINE_ARCH} ${.ALLSRC} ${.TARGET}
-loader.help: help.common
- cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \
- > ${.TARGET}
+CLEANFILES= vers.c loader.efi
+LIBIA64= ${.OBJDIR}/../common/libia64.a
LIBEFI= ${.OBJDIR}/../../efi/libefi/libefi.a
+.if ${MK_FORTH} != "no"
+LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
+.endif
-DPADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND}
-LDADD= ${LIBFICL} ${LIBEFI} -lstand
+DPADD= ${LIBIA64} ${LIBFICL} ${LIBEFI} ${LIBSTAND}
+LDADD= ${LIBIA64} ${LIBFICL} ${LIBEFI} -lstand ${LIBIA64}
.include <bsd.prog.mk>
==== //depot/projects/ia64/sys/boot/ia64/efi/conf.c#4 (text+ko) ====
@@ -50,23 +50,16 @@
/* Exported for libstand */
struct devsw *devsw[] = {
&efifs_dev,
- &netdev,
NULL
};
struct fs_ops *file_system[] = {
&efifs_fsops,
&ufs_fsops,
- &nfs_fsops,
&gzipfs_fsops,
NULL
};
-struct netif_driver *netif_drivers[] = {
- &efinetif,
- NULL,
-};
-
/* Exported for ia64 only */
/*
* Sort formats so that those that can detect based on arguments
==== //depot/projects/ia64/sys/boot/ia64/efi/efimd.c#3 (text+ko) ====
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2004 Marcel Moolenaar
+ * Copyright (c) 2006 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,16 +25,114 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/ia64/efi/efimd.c,v 1.2 2005/01/05 22:16:57 imp Exp $");
+__FBSDID("$FreeBSD$");
+
+#include <stand.h>
#include <efi.h>
#include <efilib.h>
-#include <machine/vmparam.h>
+#include <libia64.h>
+
+#define EFI_INTEL_FPSWA \
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list