Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F133579555
D37556.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D37556.diff
View Options
diff --git a/stand/libofw/devicename.c b/stand/libofw/devicename.c
--- a/stand/libofw/devicename.c
+++ b/stand/libofw/devicename.c
@@ -62,6 +62,38 @@
return(ofw_parsedev(dev, devspec, path));
}
+/*
+ * Search the OFW (path) for a node that's of (want_type).
+ */
+phandle_t
+ofw_path_to_handle(const char *ofwpath, const char *want_type, const char **path)
+{
+ const char *p, *s;
+ char name[256];
+ char type[64];
+ phandle_t handle;
+ int len;
+
+ for (p = s = ofwpath; *s != '\0'; p = s) {
+ if ((s = strchr(p + 1, '/')) == NULL)
+ s = strchr(p, '\0');
+ len = s - ofwpath;
+ if (len >= sizeof(name))
+ return ((phandle_t)-1);
+ bcopy(ofwpath, name, len);
+ name[len] = '\0';
+ if ((handle = OF_finddevice(name)) == -1)
+ continue;
+ if (OF_getprop(handle, "device_type", type, sizeof(type)) == -1)
+ continue;
+ if (strcmp(want_type, type) == 0) {
+ *path = s;
+ return (handle);
+ }
+ }
+ return ((phandle_t)-1);
+}
+
/*
* Point (dev) at an allocated device specifier matching the string version
* at the beginning of (devspec). Return a pointer to the remaining
@@ -82,6 +114,7 @@
int len;
int i;
+ /* XXX next step: use devparse -- don't forget to hack ofw_disk like you did ofw_net */
for (p = s = devspec; *s != '\0'; p = s) {
if ((s = strchr(p + 1, '/')) == NULL)
s = strchr(p, '\0');
diff --git a/stand/libofw/libofw.h b/stand/libofw/libofw.h
--- a/stand/libofw/libofw.h
+++ b/stand/libofw/libofw.h
@@ -61,6 +61,8 @@
void ofw_memmap(int);
+phandle_t ofw_path_to_handle(const char *ofwpath, const char *want_type, const char **path);
+
struct preloaded_file;
struct file_format;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 27, 7:17 PM (16 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24311235
Default Alt Text
D37556.diff (1 KB)
Attached To
Mode
D37556: stand/ofw: Add ofw_path_to_handle
Attached
Detach File
Event Timeline
Log In to Comment