PERFORCE change 108545 for review
Marcel Moolenaar
marcel at FreeBSD.org
Fri Oct 27 05:02:35 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=108545
Change 108545 by marcel at marcel_cluster on 2006/10/27 05:01:41
Sync with current libefi.
Affected files ...
.. //depot/projects/ia64/sys/boot/ia64/common/devicename.c#2 edit
.. //depot/projects/ia64/sys/boot/ia64/efi/conf.c#3 edit
.. //depot/projects/ia64/sys/boot/ia64/efi/main.c#3 edit
Differences ...
==== //depot/projects/ia64/sys/boot/ia64/common/devicename.c#2 (text+ko) ====
@@ -34,9 +34,8 @@
#include <efi.h>
#include <efilib.h>
-#include "efiboot.h"
-static int efi_parsedev(struct efi_devdesc **dev, const char *devspec, const char **path);
+static int efi_parsedev(struct devdesc **dev, const char *devspec, const char **path);
/*
* Point (dev) at an allocated device specifier for the device matching the
@@ -46,7 +45,7 @@
int
efi_getdev(void **vdev, const char *devspec, const char **path)
{
- struct efi_devdesc **dev = (struct efi_devdesc **)vdev;
+ struct devdesc **dev = (struct devdesc **)vdev;
int rv;
/*
@@ -80,143 +79,79 @@
*
* For disk-type devices, the syntax is:
*
- * disk<unit>[s<slice>][<partition>]:
- *
+ * fs<unit>:
*/
static int
-efi_parsedev(struct efi_devdesc **dev, const char *devspec, const char **path)
+efi_parsedev(struct devdesc **dev, const char *devspec, const char **path)
{
- struct efi_devdesc *idev;
+ struct devdesc *idev;
struct devsw *dv;
- int i, unit, slice, partition, err;
+ int i, err;
char *cp;
const char *np;
/* minimum length check */
if (strlen(devspec) < 2)
- return(EINVAL);
+ return (EINVAL);
/* look for a device that matches */
- for (i = 0, dv = NULL; devsw[i] != NULL; i++) {
- if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) {
- dv = devsw[i];
+ for (i = 0; devsw[i] != NULL; i++) {
+ dv = devsw[i];
+ if (!strncmp(devspec, dv->dv_name, strlen(dv->dv_name)))
break;
- }
}
+ if (devsw[i] == NULL)
+ return (ENOENT);
+
+ idev = malloc(sizeof(struct devdesc));
+ if (idev == NULL)
+ return (ENOMEM);
+ idev->d_dev = dv;
+ idev->d_type = dv->dv_type;
+ idev->d_unit = -1;
- if (dv == NULL)
- return(ENOENT);
- idev = malloc(sizeof(struct efi_devdesc));
err = 0;
np = (devspec + strlen(dv->dv_name));
-
- switch(dv->dv_type) {
- case DEVT_NONE: /* XXX what to do here? Do we care? */
- break;
-
- case DEVT_DISK:
- unit = -1;
- slice = -1;
- partition = -1;
- if (*np && (*np != ':')) {
- unit = strtol(np, &cp, 10); /* next comes the unit number */
- if (cp == np) {
- err = EUNIT;
- goto fail;
- }
- if (*cp == 's') { /* got a slice number */
- np = cp + 1;
- slice = strtol(np, &cp, 10);
- if (cp == np) {
- err = ESLICE;
- goto fail;
- }
- }
- if (*cp && (*cp != ':')) {
- partition = *cp - 'a'; /* get a partition number */
- if ((partition < 0) || (partition >= MAXPARTITIONS)) {
- err = EPART;
- goto fail;
- }
- cp++;
- }
+ if (*np && (*np != ':')) {
+ idev->d_unit = strtol(np, &cp, 0);
+ if (cp == np) {
+ idev->d_unit = -1;
+ free(idev);
+ return (EUNIT);
}
- if (*cp && (*cp != ':')) {
- err = EINVAL;
- goto fail;
- }
-
- idev->d_kind.efidisk.unit = unit;
- idev->d_kind.efidisk.slice = slice;
- idev->d_kind.efidisk.partition = partition;
-
- if (path != NULL)
- *path = (*cp == 0) ? cp : cp + 1;
- break;
-
- case DEVT_NET:
- unit = 0;
-
- if (*np && (*np != ':')) {
- unit = strtol(np, &cp, 0); /* get unit number if present */
- if (cp == np) {
- err = EUNIT;
- goto fail;
- }
- }
- if (*cp && (*cp != ':')) {
- err = EINVAL;
- goto fail;
- }
-
- idev->d_kind.netif.unit = unit;
- if (path != NULL)
- *path = (*cp == 0) ? cp : cp + 1;
- break;
-
- default:
- err = EINVAL;
- goto fail;
}
- idev->d_dev = dv;
- idev->d_type = dv->dv_type;
- if (dev == NULL) {
+ if (*cp && (*cp != ':')) {
free(idev);
- } else {
+ return (EINVAL);
+ }
+
+ if (path != NULL)
+ *path = (*cp == 0) ? cp : cp + 1;
+ if (dev != NULL)
*dev = idev;
- }
+ else
+ free(idev);
return(0);
-
- fail:
- free(idev);
- return(err);
}
char *
efi_fmtdev(void *vdev)
{
- struct efi_devdesc *dev = (struct efi_devdesc *)vdev;
+ struct devdesc *dev = (struct devdesc *)vdev;
static char buf[128]; /* XXX device length constant? */
- char *cp;
-
+
switch(dev->d_type) {
case DEVT_NONE:
strcpy(buf, "(no device)");
break;
case DEVT_DISK:
- cp = buf;
- cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_kind.efidisk.unit);
- if (dev->d_kind.efidisk.slice > 0)
- cp += sprintf(cp, "s%d", dev->d_kind.efidisk.slice);
- if (dev->d_kind.efidisk.partition >= 0)
- cp += sprintf(cp, "%c", dev->d_kind.efidisk.partition + 'a');
- strcat(cp, ":");
+ 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_kind.netif.unit);
+ sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
break;
}
return(buf);
@@ -227,9 +162,9 @@
* Set currdev to suit the value being supplied in (value)
*/
int
-efi_setcurrdev(struct env_var *ev, int flags, void *value)
+efi_setcurrdev(struct env_var *ev, int flags, const void *value)
{
- struct efi_devdesc *ncurr;
+ struct devdesc *ncurr;
int rv;
if ((rv = efi_parsedev(&ncurr, value, NULL)) != 0)
==== //depot/projects/ia64/sys/boot/ia64/efi/conf.c#3 (text+ko) ====
@@ -38,8 +38,6 @@
#include <efi.h>
#include <efilib.h>
-#include "efiboot.h"
-
/*
* We could use linker sets for some or all of these, but
* then we would have to control what ended up linked into
@@ -57,15 +55,15 @@
};
struct fs_ops *file_system[] = {
- &efi_fsops,
-/* &ufs_fsops, */
+ &efifs_fsops,
+ &ufs_fsops,
&nfs_fsops,
&gzipfs_fsops,
NULL
};
struct netif_driver *netif_drivers[] = {
- &efi_net,
+ &efinetif,
NULL,
};
==== //depot/projects/ia64/sys/boot/ia64/efi/main.c#3 (text+ko) ====
@@ -40,7 +40,6 @@
#include <efilib.h>
#include "bootstrap.h"
-#include "efiboot.h"
/* DIG64 Headless Console & Debug Port Table. */
#define HCDP_TABLE_GUID \
@@ -51,8 +50,16 @@
extern char bootprog_date[];
extern char bootprog_maker[];
-struct efi_devdesc currdev; /* our current device */
-struct arch_switch archsw; /* MI/MD interface boundary */
+extern int efi_autoload(void);
+extern char *efi_fmtdev(void *vdev);
+extern int efi_getdev(void **vdev, const char *devspec, const char **path);
+extern int efi_setcurrdev(struct env_var *ev, int flags, const void *value);
+extern ssize_t efi_copyin(const void *src, vm_offset_t dest, size_t len);
+extern ssize_t efi_copyout(const vm_offset_t src, void *dest, size_t len);
+extern ssize_t efi_readin(int fd, vm_offset_t dest, size_t len);
+
+struct devdesc currdev; /* our current device */
+struct arch_switch archsw; /* MI/MD interface boundary */
extern u_int64_t ia64_pal_entry;
@@ -144,13 +151,10 @@
i = efifs_get_unit(img->DeviceHandle);
if (i >= 0) {
currdev.d_dev = devsw[0]; /* XXX disk */
- currdev.d_kind.efidisk.unit = i;
- /* XXX should be able to detect this, default to autoprobe */
- currdev.d_kind.efidisk.slice = -1;
- currdev.d_kind.efidisk.partition = 0;
+ currdev.d_unit = i;
} else {
currdev.d_dev = devsw[1]; /* XXX net */
- currdev.d_kind.netif.unit = 0; /* XXX */
+ currdev.d_unit = 0; /* XXX */
}
currdev.d_type = currdev.d_dev->dv_type;
More information about the p4-projects
mailing list