summaryrefslogtreecommitdiff
path: root/boot/boot.c
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1995-08-29 14:44:00 +0000
committerMichael I. Bushnell <mib@gnu.org>1995-08-29 14:44:00 +0000
commitcc27641bda10f3765dc0d470fae9e14f4a2e9226 (patch)
treee828dbfaf4f40c2fe289e2b173b34175b65772e7 /boot/boot.c
parent0bb2ef1a6380365f51f0c88c865f71defe6c9224 (diff)
(sigblock, sigsetmask): New functions.
(ds_device_read): Block SIGIO around critical section. (ds_device_read_inband): Likewise. (S_io_read): Likewise.
Diffstat (limited to 'boot/boot.c')
-rw-r--r--boot/boot.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/boot/boot.c b/boot/boot.c
index 606ab0a6..02715ca4 100644
--- a/boot/boot.c
+++ b/boot/boot.c
@@ -236,6 +236,18 @@ struct sigvec
};
int
+sigblock (int mask)
+{
+ return syscall (109, mask);
+}
+
+int
+sigsetmask (int mask)
+{
+ return syscall (110, mask);
+}
+
+int
sigpause (int mask)
{
return syscall (111, mask);
@@ -1444,6 +1456,8 @@ ds_device_read (device_t device,
unsigned int *datalen)
{
int avail;
+ int mask;
+
if (device != pseudo_console)
return D_NO_SUCH_DEVICE;
@@ -1456,16 +1470,19 @@ ds_device_read (device_t device,
}
#endif
+ mask = sigblock (sigmask (SIGIO));
ioctl (0, FIONREAD, &avail);
if (avail)
{
vm_allocate (mach_task_self (), (pointer_t *)data, bytes_wanted, 1);
*datalen = read (0, *data, bytes_wanted);
+ sigsetmask (mask);
return (*datalen == -1 ? D_IO_ERROR : D_SUCCESS);
}
else
{
queue_read (DEV_READ, reply_port, reply_type, bytes_wanted);
+ sigsetmask (mask);
return MIG_NO_REPLY;
}
}
@@ -1481,6 +1498,8 @@ ds_device_read_inband (device_t device,
unsigned int *datalen)
{
int avail;
+ int mask;
+
if (device != pseudo_console)
return D_NO_SUCH_DEVICE;
@@ -1493,15 +1512,18 @@ ds_device_read_inband (device_t device,
}
#endif
+ mask = sigblock (sigmask (SIGIO));
ioctl (0, FIONREAD, &avail);
if (avail)
{
*datalen = read (0, data, bytes_wanted);
+ sigsetmask (mask);
return (*datalen == -1 ? D_IO_ERROR : D_SUCCESS);
}
else
{
queue_read (DEV_READI, reply_port, reply_type, bytes_wanted);
+ sigsetmask (mask);
return MIG_NO_REPLY;
}
}
@@ -1692,6 +1714,8 @@ S_io_read (mach_port_t object,
mach_msg_type_number_t amount)
{
mach_msg_type_number_t avail;
+ int mask;
+
if (object != pseudo_console)
return EOPNOTSUPP;
@@ -1704,17 +1728,20 @@ S_io_read (mach_port_t object,
}
#endif
+ mask = sigblock (sigmask (SIGIO));
ioctl (0, FIONREAD, &avail);
if (avail)
{
if (amount > *datalen)
vm_allocate (mach_task_self (), (vm_address_t *) data, amount, 1);
*datalen = read (0, *data, amount);
+ sigsetmask (mask);
return *datalen == -1 ? errno : 0;
}
else
{
queue_read (IO_READ, reply_port, reply_type, amount);
+ sigsetmask (mask);
return MIG_NO_REPLY;
}
}