From 67c9d475e7204296ca9bcfbd08a896df1a87e74a Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Sat, 25 Jul 2020 11:18:44 +1000 Subject: libmachdev: Add resume for bootstrap server machdev users can now pass along a port to the next translator in the bootstrap chain (bootstrap_resume_task), that they'll get from their command line set by the bootloader. machdev will then call task_resume on it as appropriate. It will also have the opportunity to get fsys_getpriv calls, and thus redirect the device master port, thus having the opportunity to expose its devices on the device master port, as if they were handled by the kernel. Message-Id: <20200725011847.186969-1-damien@zamaudio.com> --- libmachdev/ds_routines.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'libmachdev/ds_routines.c') diff --git a/libmachdev/ds_routines.c b/libmachdev/ds_routines.c index da5e47e2..53e0c080 100644 --- a/libmachdev/ds_routines.c +++ b/libmachdev/ds_routines.c @@ -65,6 +65,7 @@ #include #include +#include /* fallback to kernel device */ #include "device_S.h" #include "notify_S.h" @@ -94,7 +95,8 @@ ds_device_open (mach_port_t open_port, mach_port_t reply_port, char *name, device_t *devp, mach_msg_type_name_t *devicePoly) { int i; - io_return_t err; + mach_port_t dev_master; + io_return_t err = D_NO_SUCH_DEVICE; /* Open must be called on the master device port. */ if (!machdev_is_master_device (open_port)) @@ -108,11 +110,18 @@ ds_device_open (mach_port_t open_port, mach_port_t reply_port, for (i = 0; i < num_emul; i++) { err = (*emulation_list[i]->open) (reply_port, reply_port_type, - mode, name, devp, devicePoly); + mode, name, devp, devicePoly); if (err != D_NO_SUCH_DEVICE) - break; + break; } + /* Fall back to opening kernel device master */ + if (err) + { + get_privileged_ports(NULL, &dev_master); + err = device_open (dev_master, mode, name, devp); + *devicePoly = MACH_MSG_TYPE_MOVE_SEND; + } return err; } -- cgit v1.2.3