2007-11-23 12:40:33 +01:00
|
|
|
/* Best viewed with tabsize 4
|
|
|
|
*
|
|
|
|
* This file contains a standard driver for audio devices.
|
2007-11-23 12:30:50 +01:00
|
|
|
* It supports double dma buffering and can be configured to use
|
|
|
|
* extra buffer space beside the dma buffer.
|
|
|
|
* This driver also support sub devices, which can be independently
|
|
|
|
* opened and closed.
|
|
|
|
*
|
|
|
|
* The driver supports the following operations:
|
|
|
|
*
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
* m_type DEVICE USER_ENDPT COUNT POSITION ADRRESS
|
2007-11-23 12:30:50 +01:00
|
|
|
* -----------------------------------------------------------------
|
2007-11-23 12:40:33 +01:00
|
|
|
* | DEV_OPEN | device | proc nr | | | |
|
2007-11-23 12:30:50 +01:00
|
|
|
* |-------------+---------+---------+---------+---------+---------|
|
2007-11-23 12:40:33 +01:00
|
|
|
* | DEV_CLOSE | device | proc nr | | | |
|
2007-11-23 12:30:50 +01:00
|
|
|
* |-------------+---------+---------+---------+---------+---------|
|
2007-11-23 12:40:33 +01:00
|
|
|
* | DEV_READ_S | device | proc nr | bytes | | buf ptr |
|
2007-11-23 12:30:50 +01:00
|
|
|
* |-------------+---------+---------+---------+---------+---------|
|
2007-11-23 12:40:33 +01:00
|
|
|
* | DEV_WRITE_S | device | proc nr | bytes | | buf ptr |
|
2007-11-23 12:30:50 +01:00
|
|
|
* |-------------+---------+---------+---------+---------+---------|
|
2007-11-23 12:40:33 +01:00
|
|
|
* | DEV_IOCTL_S | device | proc nr |func code| | buf ptr |
|
2007-11-23 12:30:50 +01:00
|
|
|
* |-------------+---------+---------+---------+---------+---------|
|
2007-11-23 12:40:33 +01:00
|
|
|
* | DEV_STATUS | | | | | |
|
2007-11-23 12:30:50 +01:00
|
|
|
* |-------------+---------+---------+---------+---------+---------|
|
2007-11-23 12:40:33 +01:00
|
|
|
* | HARD_INT | | | | | |
|
2007-11-23 12:30:50 +01:00
|
|
|
* |-------------+---------+---------+---------+---------+---------|
|
2007-11-23 12:40:33 +01:00
|
|
|
* | SIG_STOP | | | | | |
|
2007-11-23 12:30:50 +01:00
|
|
|
* -----------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* The file contains one entry point:
|
|
|
|
*
|
|
|
|
* main: main entry when driver is brought up
|
|
|
|
*
|
2007-11-23 12:40:33 +01:00
|
|
|
* October 2007 Updated audio framework to work with mplayer, added
|
|
|
|
* savecopies (Pieter Hijma)
|
|
|
|
* February 2006 Updated audio framework,
|
|
|
|
* changed driver-framework relation (Peter Boonstoppel)
|
2007-11-23 12:30:50 +01:00
|
|
|
* November 2005 Created generic DMA driver framework (Laurens Bronwasser)
|
2007-11-23 12:40:33 +01:00
|
|
|
* August 24 2005 Ported audio driver to user space
|
|
|
|
* (only audio playback) (Peter Boonstoppel)
|
2007-11-23 12:30:50 +01:00
|
|
|
* May 20 1995 SB16 Driver: Michel R. Prevenier
|
|
|
|
*/
|
2007-11-23 12:40:33 +01:00
|
|
|
|
|
|
|
|
2010-08-25 13:18:38 +02:00
|
|
|
#include <minix/audio_fw.h>
|
Merge of David's ptrace branch. Summary:
o Support for ptrace T_ATTACH/T_DETACH and T_SYSCALL
o PM signal handling logic should now work properly, even with debuggers
being present
o Asynchronous PM/VFS protocol, full IPC support for senda(), and
AMF_NOREPLY senda() flag
DETAILS
Process stop and delay call handling of PM:
o Added sys_runctl() kernel call with sys_stop() and sys_resume()
aliases, for PM to stop and resume a process
o Added exception for sending/syscall-traced processes to sys_runctl(),
and matching SIGKREADY pseudo-signal to PM
o Fixed PM signal logic to deal with requests from a process after
stopping it (so-called "delay calls"), using the SIGKREADY facility
o Fixed various PM panics due to race conditions with delay calls versus
VFS calls
o Removed special PRIO_STOP priority value
o Added SYS_LOCK RTS kernel flag, to stop an individual process from
running while modifying its process structure
Signal and debugger handling in PM:
o Fixed debugger signals being dropped if a second signal arrives when
the debugger has not retrieved the first one
o Fixed debugger signals being sent to the debugger more than once
o Fixed debugger signals unpausing process in VFS; removed PM_UNPAUSE_TR
protocol message
o Detached debugger signals from general signal logic and from being
blocked on VFS calls, meaning that even VFS can now be traced
o Fixed debugger being unable to receive more than one pending signal in
one process stop
o Fixed signal delivery being delayed needlessly when multiple signals
are pending
o Fixed wait test for tracer, which was returning for children that were
not waited for
o Removed second parallel pending call from PM to VFS for any process
o Fixed process becoming runnable between exec() and debugger trap
o Added support for notifying the debugger before the parent when a
debugged child exits
o Fixed debugger death causing child to remain stopped forever
o Fixed consistently incorrect use of _NSIG
Extensions to ptrace():
o Added T_ATTACH and T_DETACH ptrace request, to attach and detach a
debugger to and from a process
o Added T_SYSCALL ptrace request, to trace system calls
o Added T_SETOPT ptrace request, to set trace options
o Added TO_TRACEFORK trace option, to attach automatically to children
of a traced process
o Added TO_ALTEXEC trace option, to send SIGSTOP instead of SIGTRAP upon
a successful exec() of the tracee
o Extended T_GETUSER ptrace support to allow retrieving a process's priv
structure
o Removed T_STOP ptrace request again, as it does not help implementing
debuggers properly
o Added MINIX3-specific ptrace test (test42)
o Added proper manual page for ptrace(2)
Asynchronous PM/VFS interface:
o Fixed asynchronous messages not being checked when receive() is called
with an endpoint other than ANY
o Added AMF_NOREPLY senda() flag, preventing such messages from
satisfying the receive part of a sendrec()
o Added asynsend3() that takes optional flags; asynsend() is now a
#define passing in 0 as third parameter
o Made PM/VFS protocol asynchronous; reintroduced tell_fs()
o Made PM_BASE request/reply number range unique
o Hacked in a horrible temporary workaround into RS to deal with newly
revealed RS-PM-VFS race condition triangle until VFS is asynchronous
System signal handling:
o Fixed shutdown logic of device drivers; removed old SIGKSTOP signal
o Removed is-superuser check from PM's do_procstat() (aka getsigset())
o Added sigset macros to allow system processes to deal with the full
signal set, rather than just the POSIX subset
Miscellaneous PM fixes:
o Split do_getset into do_get and do_set, merging common code and making
structure clearer
o Fixed setpriority() being able to put to sleep processes using an
invalid parameter, or revive zombie processes
o Made find_proc() global; removed obsolete proc_from_pid()
o Cleanup here and there
Also included:
o Fixed false-positive boot order kernel warning
o Removed last traces of old NOTIFY_FROM code
THINGS OF POSSIBLE INTEREST
o It should now be possible to run PM at any priority, even lower than
user processes
o No assumptions are made about communication speed between PM and VFS,
although communication must be FIFO
o A debugger will now receive incoming debuggee signals at kill time
only; the process may not yet be fully stopped
o A first step has been made towards making the SYSTEM task preemptible
2009-09-30 11:57:22 +02:00
|
|
|
#include <minix/endpoint.h>
|
2008-02-25 11:02:24 +01:00
|
|
|
#include <minix/ds.h>
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int msg_open(int minor_dev_nr);
|
|
|
|
static int msg_close(int minor_dev_nr);
|
|
|
|
static int msg_ioctl(const message *m_ptr);
|
|
|
|
static void msg_write(const message *m_ptr);
|
|
|
|
static void msg_read(message *m_ptr);
|
|
|
|
static void msg_hardware(void);
|
|
|
|
static void msg_status(message *m_ptr);
|
|
|
|
static int init_driver(void);
|
|
|
|
static int open_sub_dev(int sub_dev_nr, int operation);
|
|
|
|
static int close_sub_dev(int sub_dev_nr);
|
|
|
|
static void handle_int_write(int sub_dev_nr);
|
|
|
|
static void handle_int_read(int sub_dev_nr);
|
|
|
|
static void data_to_user(sub_dev_t *sub_dev_ptr);
|
|
|
|
static void data_from_user(sub_dev_t *sub_dev_ptr);
|
|
|
|
static int init_buffers(sub_dev_t *sub_dev_ptr);
|
|
|
|
static int get_started(sub_dev_t *sub_dev_ptr);
|
|
|
|
static void reply(int code, int replyee, int process,int status);
|
|
|
|
static int io_ctl_length(int io_request);
|
|
|
|
static special_file_t* get_special_file(int minor_dev_nr);
|
|
|
|
static void tell_dev(vir_bytes buf, size_t size, int pci_bus, int
|
2012-03-24 16:16:34 +01:00
|
|
|
pci_dev, int pci_func);
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static char io_ctl_buf[_IOCPARM_MASK];
|
|
|
|
static int irq_hook_id = 0; /* id of irq hook at the kernel */
|
|
|
|
static int irq_hook_set = FALSE;
|
|
|
|
static int device_available = 0;/*todo*/
|
2007-11-23 12:30:50 +01:00
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/* SEF functions and variables. */
|
2012-03-25 20:25:53 +02:00
|
|
|
static void sef_local_startup(void);
|
|
|
|
static int sef_cb_init_fresh(int type, sef_init_info_t *info);
|
|
|
|
static void sef_cb_signal_handler(int signo);
|
2012-03-24 16:16:34 +01:00
|
|
|
EXTERN int sef_cb_lu_prepare(int state);
|
|
|
|
EXTERN int sef_cb_lu_state_isvalid(int state);
|
|
|
|
EXTERN void sef_cb_lu_state_dump(int state);
|
2012-03-25 20:25:53 +02:00
|
|
|
int is_status_msg_expected = FALSE;
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int main(void)
|
2010-07-02 00:23:25 +02:00
|
|
|
{
|
2010-02-19 11:00:32 +01:00
|
|
|
int r, caller;
|
2008-02-25 11:02:24 +01:00
|
|
|
message mess, repl_mess;
|
2010-04-08 15:41:35 +02:00
|
|
|
int ipc_status;
|
2007-11-23 12:30:50 +01:00
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/* SEF local startup. */
|
|
|
|
sef_local_startup();
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
/* Here is the main loop of the dma driver. It waits for a message,
|
2007-11-23 12:40:33 +01:00
|
|
|
carries it out, and sends a reply. */
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
while(1) {
|
2010-04-08 15:41:35 +02:00
|
|
|
if(driver_receive(ANY, &mess, &ipc_status) != OK) {
|
|
|
|
panic("driver_receive failed");
|
|
|
|
}
|
2007-11-23 12:30:50 +01:00
|
|
|
caller = mess.m_source;
|
2007-11-23 12:40:33 +01:00
|
|
|
|
Merge of David's ptrace branch. Summary:
o Support for ptrace T_ATTACH/T_DETACH and T_SYSCALL
o PM signal handling logic should now work properly, even with debuggers
being present
o Asynchronous PM/VFS protocol, full IPC support for senda(), and
AMF_NOREPLY senda() flag
DETAILS
Process stop and delay call handling of PM:
o Added sys_runctl() kernel call with sys_stop() and sys_resume()
aliases, for PM to stop and resume a process
o Added exception for sending/syscall-traced processes to sys_runctl(),
and matching SIGKREADY pseudo-signal to PM
o Fixed PM signal logic to deal with requests from a process after
stopping it (so-called "delay calls"), using the SIGKREADY facility
o Fixed various PM panics due to race conditions with delay calls versus
VFS calls
o Removed special PRIO_STOP priority value
o Added SYS_LOCK RTS kernel flag, to stop an individual process from
running while modifying its process structure
Signal and debugger handling in PM:
o Fixed debugger signals being dropped if a second signal arrives when
the debugger has not retrieved the first one
o Fixed debugger signals being sent to the debugger more than once
o Fixed debugger signals unpausing process in VFS; removed PM_UNPAUSE_TR
protocol message
o Detached debugger signals from general signal logic and from being
blocked on VFS calls, meaning that even VFS can now be traced
o Fixed debugger being unable to receive more than one pending signal in
one process stop
o Fixed signal delivery being delayed needlessly when multiple signals
are pending
o Fixed wait test for tracer, which was returning for children that were
not waited for
o Removed second parallel pending call from PM to VFS for any process
o Fixed process becoming runnable between exec() and debugger trap
o Added support for notifying the debugger before the parent when a
debugged child exits
o Fixed debugger death causing child to remain stopped forever
o Fixed consistently incorrect use of _NSIG
Extensions to ptrace():
o Added T_ATTACH and T_DETACH ptrace request, to attach and detach a
debugger to and from a process
o Added T_SYSCALL ptrace request, to trace system calls
o Added T_SETOPT ptrace request, to set trace options
o Added TO_TRACEFORK trace option, to attach automatically to children
of a traced process
o Added TO_ALTEXEC trace option, to send SIGSTOP instead of SIGTRAP upon
a successful exec() of the tracee
o Extended T_GETUSER ptrace support to allow retrieving a process's priv
structure
o Removed T_STOP ptrace request again, as it does not help implementing
debuggers properly
o Added MINIX3-specific ptrace test (test42)
o Added proper manual page for ptrace(2)
Asynchronous PM/VFS interface:
o Fixed asynchronous messages not being checked when receive() is called
with an endpoint other than ANY
o Added AMF_NOREPLY senda() flag, preventing such messages from
satisfying the receive part of a sendrec()
o Added asynsend3() that takes optional flags; asynsend() is now a
#define passing in 0 as third parameter
o Made PM/VFS protocol asynchronous; reintroduced tell_fs()
o Made PM_BASE request/reply number range unique
o Hacked in a horrible temporary workaround into RS to deal with newly
revealed RS-PM-VFS race condition triangle until VFS is asynchronous
System signal handling:
o Fixed shutdown logic of device drivers; removed old SIGKSTOP signal
o Removed is-superuser check from PM's do_procstat() (aka getsigset())
o Added sigset macros to allow system processes to deal with the full
signal set, rather than just the POSIX subset
Miscellaneous PM fixes:
o Split do_getset into do_get and do_set, merging common code and making
structure clearer
o Fixed setpriority() being able to put to sleep processes using an
invalid parameter, or revive zombie processes
o Made find_proc() global; removed obsolete proc_from_pid()
o Cleanup here and there
Also included:
o Fixed false-positive boot order kernel warning
o Removed last traces of old NOTIFY_FROM code
THINGS OF POSSIBLE INTEREST
o It should now be possible to run PM at any priority, even lower than
user processes
o No assumptions are made about communication speed between PM and VFS,
although communication must be FIFO
o A debugger will now receive incoming debuggee signals at kill time
only; the process may not yet be fully stopped
o A first step has been made towards making the SYSTEM task preemptible
2009-09-30 11:57:22 +02:00
|
|
|
/* Now carry out the work. First check for notifications. */
|
2010-04-08 15:41:35 +02:00
|
|
|
if (is_ipc_notify(ipc_status)) {
|
Merge of David's ptrace branch. Summary:
o Support for ptrace T_ATTACH/T_DETACH and T_SYSCALL
o PM signal handling logic should now work properly, even with debuggers
being present
o Asynchronous PM/VFS protocol, full IPC support for senda(), and
AMF_NOREPLY senda() flag
DETAILS
Process stop and delay call handling of PM:
o Added sys_runctl() kernel call with sys_stop() and sys_resume()
aliases, for PM to stop and resume a process
o Added exception for sending/syscall-traced processes to sys_runctl(),
and matching SIGKREADY pseudo-signal to PM
o Fixed PM signal logic to deal with requests from a process after
stopping it (so-called "delay calls"), using the SIGKREADY facility
o Fixed various PM panics due to race conditions with delay calls versus
VFS calls
o Removed special PRIO_STOP priority value
o Added SYS_LOCK RTS kernel flag, to stop an individual process from
running while modifying its process structure
Signal and debugger handling in PM:
o Fixed debugger signals being dropped if a second signal arrives when
the debugger has not retrieved the first one
o Fixed debugger signals being sent to the debugger more than once
o Fixed debugger signals unpausing process in VFS; removed PM_UNPAUSE_TR
protocol message
o Detached debugger signals from general signal logic and from being
blocked on VFS calls, meaning that even VFS can now be traced
o Fixed debugger being unable to receive more than one pending signal in
one process stop
o Fixed signal delivery being delayed needlessly when multiple signals
are pending
o Fixed wait test for tracer, which was returning for children that were
not waited for
o Removed second parallel pending call from PM to VFS for any process
o Fixed process becoming runnable between exec() and debugger trap
o Added support for notifying the debugger before the parent when a
debugged child exits
o Fixed debugger death causing child to remain stopped forever
o Fixed consistently incorrect use of _NSIG
Extensions to ptrace():
o Added T_ATTACH and T_DETACH ptrace request, to attach and detach a
debugger to and from a process
o Added T_SYSCALL ptrace request, to trace system calls
o Added T_SETOPT ptrace request, to set trace options
o Added TO_TRACEFORK trace option, to attach automatically to children
of a traced process
o Added TO_ALTEXEC trace option, to send SIGSTOP instead of SIGTRAP upon
a successful exec() of the tracee
o Extended T_GETUSER ptrace support to allow retrieving a process's priv
structure
o Removed T_STOP ptrace request again, as it does not help implementing
debuggers properly
o Added MINIX3-specific ptrace test (test42)
o Added proper manual page for ptrace(2)
Asynchronous PM/VFS interface:
o Fixed asynchronous messages not being checked when receive() is called
with an endpoint other than ANY
o Added AMF_NOREPLY senda() flag, preventing such messages from
satisfying the receive part of a sendrec()
o Added asynsend3() that takes optional flags; asynsend() is now a
#define passing in 0 as third parameter
o Made PM/VFS protocol asynchronous; reintroduced tell_fs()
o Made PM_BASE request/reply number range unique
o Hacked in a horrible temporary workaround into RS to deal with newly
revealed RS-PM-VFS race condition triangle until VFS is asynchronous
System signal handling:
o Fixed shutdown logic of device drivers; removed old SIGKSTOP signal
o Removed is-superuser check from PM's do_procstat() (aka getsigset())
o Added sigset macros to allow system processes to deal with the full
signal set, rather than just the POSIX subset
Miscellaneous PM fixes:
o Split do_getset into do_get and do_set, merging common code and making
structure clearer
o Fixed setpriority() being able to put to sleep processes using an
invalid parameter, or revive zombie processes
o Made find_proc() global; removed obsolete proc_from_pid()
o Cleanup here and there
Also included:
o Fixed false-positive boot order kernel warning
o Removed last traces of old NOTIFY_FROM code
THINGS OF POSSIBLE INTEREST
o It should now be possible to run PM at any priority, even lower than
user processes
o No assumptions are made about communication speed between PM and VFS,
although communication must be FIFO
o A debugger will now receive incoming debuggee signals at kill time
only; the process may not yet be fully stopped
o A first step has been made towards making the SYSTEM task preemptible
2009-09-30 11:57:22 +02:00
|
|
|
switch (_ENDPOINT_P(mess.m_source)) {
|
|
|
|
case HARDWARE:
|
|
|
|
msg_hardware();
|
|
|
|
break;
|
|
|
|
default:
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: %d uncaught notify!\n",
|
Merge of David's ptrace branch. Summary:
o Support for ptrace T_ATTACH/T_DETACH and T_SYSCALL
o PM signal handling logic should now work properly, even with debuggers
being present
o Asynchronous PM/VFS protocol, full IPC support for senda(), and
AMF_NOREPLY senda() flag
DETAILS
Process stop and delay call handling of PM:
o Added sys_runctl() kernel call with sys_stop() and sys_resume()
aliases, for PM to stop and resume a process
o Added exception for sending/syscall-traced processes to sys_runctl(),
and matching SIGKREADY pseudo-signal to PM
o Fixed PM signal logic to deal with requests from a process after
stopping it (so-called "delay calls"), using the SIGKREADY facility
o Fixed various PM panics due to race conditions with delay calls versus
VFS calls
o Removed special PRIO_STOP priority value
o Added SYS_LOCK RTS kernel flag, to stop an individual process from
running while modifying its process structure
Signal and debugger handling in PM:
o Fixed debugger signals being dropped if a second signal arrives when
the debugger has not retrieved the first one
o Fixed debugger signals being sent to the debugger more than once
o Fixed debugger signals unpausing process in VFS; removed PM_UNPAUSE_TR
protocol message
o Detached debugger signals from general signal logic and from being
blocked on VFS calls, meaning that even VFS can now be traced
o Fixed debugger being unable to receive more than one pending signal in
one process stop
o Fixed signal delivery being delayed needlessly when multiple signals
are pending
o Fixed wait test for tracer, which was returning for children that were
not waited for
o Removed second parallel pending call from PM to VFS for any process
o Fixed process becoming runnable between exec() and debugger trap
o Added support for notifying the debugger before the parent when a
debugged child exits
o Fixed debugger death causing child to remain stopped forever
o Fixed consistently incorrect use of _NSIG
Extensions to ptrace():
o Added T_ATTACH and T_DETACH ptrace request, to attach and detach a
debugger to and from a process
o Added T_SYSCALL ptrace request, to trace system calls
o Added T_SETOPT ptrace request, to set trace options
o Added TO_TRACEFORK trace option, to attach automatically to children
of a traced process
o Added TO_ALTEXEC trace option, to send SIGSTOP instead of SIGTRAP upon
a successful exec() of the tracee
o Extended T_GETUSER ptrace support to allow retrieving a process's priv
structure
o Removed T_STOP ptrace request again, as it does not help implementing
debuggers properly
o Added MINIX3-specific ptrace test (test42)
o Added proper manual page for ptrace(2)
Asynchronous PM/VFS interface:
o Fixed asynchronous messages not being checked when receive() is called
with an endpoint other than ANY
o Added AMF_NOREPLY senda() flag, preventing such messages from
satisfying the receive part of a sendrec()
o Added asynsend3() that takes optional flags; asynsend() is now a
#define passing in 0 as third parameter
o Made PM/VFS protocol asynchronous; reintroduced tell_fs()
o Made PM_BASE request/reply number range unique
o Hacked in a horrible temporary workaround into RS to deal with newly
revealed RS-PM-VFS race condition triangle until VFS is asynchronous
System signal handling:
o Fixed shutdown logic of device drivers; removed old SIGKSTOP signal
o Removed is-superuser check from PM's do_procstat() (aka getsigset())
o Added sigset macros to allow system processes to deal with the full
signal set, rather than just the POSIX subset
Miscellaneous PM fixes:
o Split do_getset into do_get and do_set, merging common code and making
structure clearer
o Fixed setpriority() being able to put to sleep processes using an
invalid parameter, or revive zombie processes
o Made find_proc() global; removed obsolete proc_from_pid()
o Cleanup here and there
Also included:
o Fixed false-positive boot order kernel warning
o Removed last traces of old NOTIFY_FROM code
THINGS OF POSSIBLE INTEREST
o It should now be possible to run PM at any priority, even lower than
user processes
o No assumptions are made about communication speed between PM and VFS,
although communication must be FIFO
o A debugger will now receive incoming debuggee signals at kill time
only; the process may not yet be fully stopped
o A first step has been made towards making the SYSTEM task preemptible
2009-09-30 11:57:22 +02:00
|
|
|
drv.DriverName, mess.m_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get next message */
|
2008-02-25 11:02:24 +01:00
|
|
|
continue;
|
|
|
|
}
|
2007-11-23 12:30:50 +01:00
|
|
|
|
Merge of David's ptrace branch. Summary:
o Support for ptrace T_ATTACH/T_DETACH and T_SYSCALL
o PM signal handling logic should now work properly, even with debuggers
being present
o Asynchronous PM/VFS protocol, full IPC support for senda(), and
AMF_NOREPLY senda() flag
DETAILS
Process stop and delay call handling of PM:
o Added sys_runctl() kernel call with sys_stop() and sys_resume()
aliases, for PM to stop and resume a process
o Added exception for sending/syscall-traced processes to sys_runctl(),
and matching SIGKREADY pseudo-signal to PM
o Fixed PM signal logic to deal with requests from a process after
stopping it (so-called "delay calls"), using the SIGKREADY facility
o Fixed various PM panics due to race conditions with delay calls versus
VFS calls
o Removed special PRIO_STOP priority value
o Added SYS_LOCK RTS kernel flag, to stop an individual process from
running while modifying its process structure
Signal and debugger handling in PM:
o Fixed debugger signals being dropped if a second signal arrives when
the debugger has not retrieved the first one
o Fixed debugger signals being sent to the debugger more than once
o Fixed debugger signals unpausing process in VFS; removed PM_UNPAUSE_TR
protocol message
o Detached debugger signals from general signal logic and from being
blocked on VFS calls, meaning that even VFS can now be traced
o Fixed debugger being unable to receive more than one pending signal in
one process stop
o Fixed signal delivery being delayed needlessly when multiple signals
are pending
o Fixed wait test for tracer, which was returning for children that were
not waited for
o Removed second parallel pending call from PM to VFS for any process
o Fixed process becoming runnable between exec() and debugger trap
o Added support for notifying the debugger before the parent when a
debugged child exits
o Fixed debugger death causing child to remain stopped forever
o Fixed consistently incorrect use of _NSIG
Extensions to ptrace():
o Added T_ATTACH and T_DETACH ptrace request, to attach and detach a
debugger to and from a process
o Added T_SYSCALL ptrace request, to trace system calls
o Added T_SETOPT ptrace request, to set trace options
o Added TO_TRACEFORK trace option, to attach automatically to children
of a traced process
o Added TO_ALTEXEC trace option, to send SIGSTOP instead of SIGTRAP upon
a successful exec() of the tracee
o Extended T_GETUSER ptrace support to allow retrieving a process's priv
structure
o Removed T_STOP ptrace request again, as it does not help implementing
debuggers properly
o Added MINIX3-specific ptrace test (test42)
o Added proper manual page for ptrace(2)
Asynchronous PM/VFS interface:
o Fixed asynchronous messages not being checked when receive() is called
with an endpoint other than ANY
o Added AMF_NOREPLY senda() flag, preventing such messages from
satisfying the receive part of a sendrec()
o Added asynsend3() that takes optional flags; asynsend() is now a
#define passing in 0 as third parameter
o Made PM/VFS protocol asynchronous; reintroduced tell_fs()
o Made PM_BASE request/reply number range unique
o Hacked in a horrible temporary workaround into RS to deal with newly
revealed RS-PM-VFS race condition triangle until VFS is asynchronous
System signal handling:
o Fixed shutdown logic of device drivers; removed old SIGKSTOP signal
o Removed is-superuser check from PM's do_procstat() (aka getsigset())
o Added sigset macros to allow system processes to deal with the full
signal set, rather than just the POSIX subset
Miscellaneous PM fixes:
o Split do_getset into do_get and do_set, merging common code and making
structure clearer
o Fixed setpriority() being able to put to sleep processes using an
invalid parameter, or revive zombie processes
o Made find_proc() global; removed obsolete proc_from_pid()
o Cleanup here and there
Also included:
o Fixed false-positive boot order kernel warning
o Removed last traces of old NOTIFY_FROM code
THINGS OF POSSIBLE INTEREST
o It should now be possible to run PM at any priority, even lower than
user processes
o No assumptions are made about communication speed between PM and VFS,
although communication must be FIFO
o A debugger will now receive incoming debuggee signals at kill time
only; the process may not yet be fully stopped
o A first step has been made towards making the SYSTEM task preemptible
2009-09-30 11:57:22 +02:00
|
|
|
/* Normal messages. */
|
2007-11-23 12:30:50 +01:00
|
|
|
switch(mess.m_type) {
|
2008-02-25 11:02:24 +01:00
|
|
|
case DEV_OPEN:
|
|
|
|
/* open the special file ( = parameter) */
|
|
|
|
r = msg_open(mess.DEVICE);
|
|
|
|
repl_mess.m_type = DEV_REVIVE;
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
repl_mess.REP_ENDPT = mess.USER_ENDPT;
|
2008-02-25 11:02:24 +01:00
|
|
|
repl_mess.REP_STATUS = r;
|
|
|
|
send(caller, &repl_mess);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case DEV_CLOSE:
|
|
|
|
/* close the special file ( = parameter) */
|
|
|
|
r = msg_close(mess.DEVICE);
|
|
|
|
repl_mess.m_type = DEV_CLOSE_REPL;
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
repl_mess.REP_ENDPT = mess.USER_ENDPT;
|
2008-02-25 11:02:24 +01:00
|
|
|
repl_mess.REP_STATUS = r;
|
|
|
|
send(caller, &repl_mess);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
case DEV_IOCTL_S:
|
2008-02-25 11:02:24 +01:00
|
|
|
r = msg_ioctl(&mess);
|
|
|
|
|
|
|
|
if (r != SUSPEND)
|
|
|
|
{
|
|
|
|
repl_mess.m_type = DEV_REVIVE;
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
repl_mess.REP_ENDPT = mess.USER_ENDPT;
|
2008-02-25 11:02:24 +01:00
|
|
|
repl_mess.REP_IO_GRANT =
|
|
|
|
(unsigned)mess.IO_GRANT;
|
|
|
|
repl_mess.REP_STATUS = r;
|
|
|
|
send(caller, &repl_mess);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
case DEV_READ_S:
|
|
|
|
msg_read(&mess); continue; /* don't reply */
|
|
|
|
case DEV_WRITE_S:
|
|
|
|
msg_write(&mess); continue; /* don't reply */
|
|
|
|
case DEV_STATUS:
|
|
|
|
msg_status(&mess);continue; /* don't reply */
|
2008-02-25 11:02:24 +01:00
|
|
|
case DEV_REOPEN:
|
|
|
|
/* reopen the special file ( = parameter) */
|
|
|
|
r = msg_open(mess.DEVICE);
|
|
|
|
repl_mess.m_type = DEV_REOPEN_REPL;
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
repl_mess.REP_ENDPT = mess.USER_ENDPT;
|
2008-02-25 11:02:24 +01:00
|
|
|
repl_mess.REP_STATUS = r;
|
|
|
|
send(caller, &repl_mess);
|
|
|
|
continue;
|
2007-11-23 12:30:50 +01:00
|
|
|
default:
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: %d uncaught msg!\n",
|
2008-02-25 11:02:24 +01:00
|
|
|
drv.DriverName, mess.m_type);
|
|
|
|
continue;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
2008-02-25 11:02:24 +01:00
|
|
|
|
|
|
|
/* Should not be here. Just continue. */
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
2010-07-02 00:23:25 +02:00
|
|
|
return 1;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* sef_local_startup *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void sef_local_startup()
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
{
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
/* Register init callbacks. */
|
|
|
|
sef_setcb_init_fresh(sef_cb_init_fresh);
|
|
|
|
sef_setcb_init_lu(sef_cb_init_fresh);
|
|
|
|
sef_setcb_init_restart(sef_cb_init_fresh);
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/* Register live update callbacks. */
|
|
|
|
sef_setcb_lu_prepare(sef_cb_lu_prepare);
|
|
|
|
sef_setcb_lu_state_isvalid(sef_cb_lu_state_isvalid);
|
|
|
|
sef_setcb_lu_state_dump(sef_cb_lu_state_dump);
|
|
|
|
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
/* Register signal callbacks. */
|
|
|
|
sef_setcb_signal_handler(sef_cb_signal_handler);
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/* Let SEF perform startup. */
|
|
|
|
sef_startup();
|
|
|
|
}
|
2007-11-23 12:40:33 +01:00
|
|
|
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* sef_cb_init_fresh *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
Initialization protocol for system services.
SYSLIB CHANGES:
- SEF framework now supports a new SEF Init request type from RS. 3 different
callbacks are available (init_fresh, init_lu, init_restart) to specify
initialization code when a service starts fresh, starts after a live update,
or restarts.
SYSTEM SERVICE CHANGES:
- Initialization code for system services is now enclosed in a callback SEF will
automatically call at init time. The return code of the callback will
tell RS whether the initialization completed successfully.
- Each init callback can access information passed by RS to initialize. As of
now, each system service has access to the public entries of RS's system process
table to gather all the information required to initialize. This design
eliminates many existing or potential races at boot time and provides a uniform
initialization interface to system services. The same interface will be reused
for the upcoming publish/subscribe model to handle dynamic
registration / deregistration of system services.
VM CHANGES:
- Uniform privilege management for all system services. Every service uses the
same call mask format. For boot services, VM copies the call mask from init
data. For dynamic services, VM still receives the call mask via rs_set_priv
call that will be soon replaced by the upcoming publish/subscribe model.
RS CHANGES:
- The system process table has been reorganized and split into private entries
and public entries. Only the latter ones are exposed to system services.
- VM call masks are now entirely configured in rs/table.c
- RS has now its own slot in the system process table. Only kernel tasks and
user processes not included in the boot image are now left out from the system
process table.
- RS implements the initialization protocol for system services.
- For services in the boot image, RS blocks till initialization is complete and
panics when failure is reported back. Services are initialized in their order of
appearance in the boot image priv table and RS blocks to implements synchronous
initialization for every system service having the flag SF_SYNCH_BOOT set.
- For services started dynamically, the initialization protocol is implemented
as though it were the first ping for the service. In this case, if the
system service fails to report back (or reports failure), RS brings the service
down rather than trying to restart it.
2010-01-08 02:20:42 +01:00
|
|
|
{
|
|
|
|
/* Initialize the audio driver framework. */
|
|
|
|
return init_driver();
|
|
|
|
}
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int init_driver(void) {
|
2007-11-23 12:40:33 +01:00
|
|
|
u32_t i; char irq;
|
|
|
|
static int executed = 0;
|
|
|
|
sub_dev_t* sub_dev_ptr;
|
|
|
|
|
|
|
|
/* init variables, get dma buffers */
|
|
|
|
for (i = 0; i < drv.NrOfSubDevices; i++) {
|
|
|
|
|
|
|
|
sub_dev_ptr = &sub_dev[i];
|
|
|
|
|
|
|
|
sub_dev_ptr->Opened = FALSE;
|
|
|
|
sub_dev_ptr->DmaBusy = FALSE;
|
|
|
|
sub_dev_ptr->DmaMode = NO_DMA;
|
|
|
|
sub_dev_ptr->DmaReadNext = 0;
|
|
|
|
sub_dev_ptr->DmaFillNext = 0;
|
|
|
|
sub_dev_ptr->DmaLength = 0;
|
|
|
|
sub_dev_ptr->BufReadNext = 0;
|
|
|
|
sub_dev_ptr->BufFillNext = 0;
|
|
|
|
sub_dev_ptr->RevivePending = FALSE;
|
|
|
|
sub_dev_ptr->OutOfData = FALSE;
|
|
|
|
sub_dev_ptr->Nr = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize hardware*/
|
|
|
|
if (drv_init_hw() != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Could not initialize hardware\n", drv.DriverName);
|
2007-11-23 12:40:33 +01:00
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
/* get irq from device driver...*/
|
|
|
|
if (drv_get_irq(&irq) != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: init driver couldn't get IRQ", drv.DriverName);
|
2007-11-23 12:40:33 +01:00
|
|
|
return EIO;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
2010-04-01 14:51:31 +02:00
|
|
|
/* TODO: execute the rest of this function only once
|
2007-11-23 12:40:33 +01:00
|
|
|
we don't want to set irq policy twice */
|
|
|
|
if (executed) return OK;
|
|
|
|
executed = TRUE;
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
/* ...and register interrupt vector */
|
2007-11-23 12:40:33 +01:00
|
|
|
if ((i=sys_irqsetpolicy(irq, 0, &irq_hook_id )) != OK){
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: init driver couldn't set IRQ policy: %d", drv.DriverName, i);
|
2007-11-23 12:40:33 +01:00
|
|
|
return EIO;
|
|
|
|
}
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
irq_hook_set = TRUE; /* now signal handler knows it must unregister policy*/
|
2010-04-08 15:41:35 +02:00
|
|
|
|
|
|
|
/* Announce we are up! */
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
chardriver_announce();
|
2010-04-08 15:41:35 +02:00
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* sef_cb_signal_handler *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void sef_cb_signal_handler(int signo)
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char irq;
|
|
|
|
|
|
|
|
/* Only check for termination signal, ignore anything else. */
|
|
|
|
if (signo != SIGTERM) return;
|
|
|
|
|
|
|
|
for (i = 0; i < drv.NrOfSubDevices; i++) {
|
|
|
|
drv_stop(i); /* stop all sub devices */
|
|
|
|
}
|
|
|
|
if (irq_hook_set) {
|
|
|
|
if (sys_irqdisable(&irq_hook_id) != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("Could not disable IRQ\n");
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
}
|
|
|
|
/* get irq from device driver*/
|
|
|
|
if (drv_get_irq(&irq) != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("Msg SIG_STOP Couldn't get IRQ");
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
}
|
|
|
|
/* remove the policy */
|
|
|
|
if (sys_irqrmpolicy(&irq_hook_id) != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Could not disable IRQ\n",drv.DriverName);
|
New RS and new signal handling for system processes.
UPDATING INFO:
20100317:
/usr/src/etc/system.conf updated to ignore default kernel calls: copy
it (or merge it) to /etc/system.conf.
The hello driver (/dev/hello) added to the distribution:
# cd /usr/src/commands/scripts && make clean install
# cd /dev && MAKEDEV hello
KERNEL CHANGES:
- Generic signal handling support. The kernel no longer assumes PM as a signal
manager for every process. The signal manager of a given process can now be
specified in its privilege slot. When a signal has to be delivered, the kernel
performs the lookup and forwards the signal to the appropriate signal manager.
PM is the default signal manager for user processes, RS is the default signal
manager for system processes. To enable ptrace()ing for system processes, it
is sufficient to change the default signal manager to PM. This will temporarily
disable crash recovery, though.
- sys_exit() is now split into sys_exit() (i.e. exit() for system processes,
which generates a self-termination signal), and sys_clear() (i.e. used by PM
to ask the kernel to clear a process slot when a process exits).
- Added a new kernel call (i.e. sys_update()) to swap two process slots and
implement live update.
PM CHANGES:
- Posix signal handling is no longer allowed for system processes. System
signals are split into two fixed categories: termination and non-termination
signals. When a non-termination signaled is processed, PM transforms the signal
into an IPC message and delivers the message to the system process. When a
termination signal is processed, PM terminates the process.
- PM no longer assumes itself as the signal manager for system processes. It now
makes sure that every system signal goes through the kernel before being
actually processes. The kernel will then dispatch the signal to the appropriate
signal manager which may or may not be PM.
SYSLIB CHANGES:
- Simplified SEF init and LU callbacks.
- Added additional predefined SEF callbacks to debug crash recovery and
live update.
- Fixed a temporary ack in the SEF init protocol. SEF init reply is now
completely synchronous.
- Added SEF signal event type to provide a uniform interface for system
processes to deal with signals. A sef_cb_signal_handler() callback is
available for system processes to handle every received signal. A
sef_cb_signal_manager() callback is used by signal managers to process
system signals on behalf of the kernel.
- Fixed a few bugs with memory mapping and DS.
VM CHANGES:
- Page faults and memory requests coming from the kernel are now implemented
using signals.
- Added a new VM call to swap two process slots and implement live update.
- The call is used by RS at update time and in turn invokes the kernel call
sys_update().
RS CHANGES:
- RS has been reworked with a better functional decomposition.
- Better kernel call masks. com.h now defines the set of very basic kernel calls
every system service is allowed to use. This makes system.conf simpler and
easier to maintain. In addition, this guarantees a higher level of isolation
for system libraries that use one or more kernel calls internally (e.g. printf).
- RS is the default signal manager for system processes. By default, RS
intercepts every signal delivered to every system process. This makes crash
recovery possible before bringing PM and friends in the loop.
- RS now supports fast rollback when something goes wrong while initializing
the new version during a live update.
- Live update is now implemented by keeping the two versions side-by-side and
swapping the process slots when the old version is ready to update.
- Crash recovery is now implemented by keeping the two versions side-by-side
and cleaning up the old version only when the recovery process is complete.
DS CHANGES:
- Fixed a bug when the process doing ds_publish() or ds_delete() is not known
by DS.
- Fixed the completely broken support for strings. String publishing is now
implemented in the system library and simply wraps publishing of memory ranges.
Ideally, we should adopt a similar approach for other data types as well.
- Test suite fixed.
DRIVER CHANGES:
- The hello driver has been added to the Minix distribution to demonstrate basic
live update and crash recovery functionalities.
- Other drivers have been adapted to conform the new SEF interface.
2010-03-17 02:15:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int msg_open (int minor_dev_nr) {
|
2007-11-23 12:40:33 +01:00
|
|
|
int r, read_chan, write_chan, io_ctl;
|
|
|
|
special_file_t* special_file_ptr;
|
|
|
|
|
|
|
|
special_file_ptr = get_special_file(minor_dev_nr);
|
|
|
|
if(special_file_ptr == NULL) {
|
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
read_chan = special_file_ptr->read_chan;
|
|
|
|
write_chan = special_file_ptr->write_chan;
|
|
|
|
io_ctl = special_file_ptr->io_ctl;
|
|
|
|
|
|
|
|
if (read_chan==NO_CHANNEL && write_chan==NO_CHANNEL && io_ctl==NO_CHANNEL) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: No channel specified for minor device %d!\n",
|
2007-11-23 12:40:33 +01:00
|
|
|
drv.DriverName, minor_dev_nr);
|
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
if (read_chan == write_chan && read_chan != NO_CHANNEL) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Read and write channels are equal: %d!\n",
|
2007-11-23 12:40:33 +01:00
|
|
|
drv.DriverName, minor_dev_nr);
|
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
/* init driver */
|
|
|
|
if (!device_available) {
|
|
|
|
if (init_driver() != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Couldn't init driver!\n", drv.DriverName);
|
2007-11-23 12:40:33 +01:00
|
|
|
return EIO;
|
|
|
|
} else {
|
|
|
|
device_available = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* open the sub devices specified in the interface header file */
|
|
|
|
if (write_chan != NO_CHANNEL) {
|
|
|
|
/* open sub device for writing */
|
|
|
|
if (open_sub_dev(write_chan, DEV_WRITE_S) != OK) return EIO;
|
|
|
|
}
|
|
|
|
if (read_chan != NO_CHANNEL) {
|
|
|
|
if (open_sub_dev(read_chan, DEV_READ_S) != OK) return EIO;
|
|
|
|
}
|
|
|
|
if (read_chan == io_ctl || write_chan == io_ctl) {
|
|
|
|
/* io_ctl is already opened because it's the same as read or write */
|
|
|
|
return OK; /* we're done */
|
|
|
|
}
|
|
|
|
if (io_ctl != NO_CHANNEL) { /* Ioctl differs from read/write channels, */
|
|
|
|
r = open_sub_dev(io_ctl, NO_DMA); /* open it explicitly */
|
|
|
|
if (r != OK) return EIO;
|
|
|
|
}
|
|
|
|
return OK;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int open_sub_dev(int sub_dev_nr, int dma_mode) {
|
2010-01-22 23:01:08 +01:00
|
|
|
sub_dev_t* sub_dev_ptr;
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_ptr = &sub_dev[sub_dev_nr];
|
|
|
|
|
|
|
|
/* Only one open at a time per sub device */
|
2007-11-23 12:30:50 +01:00
|
|
|
if (sub_dev_ptr->Opened) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Sub device %d is already opened\n",
|
2007-11-23 12:40:33 +01:00
|
|
|
drv.DriverName, sub_dev_nr);
|
|
|
|
return EBUSY;
|
|
|
|
}
|
2007-11-23 12:30:50 +01:00
|
|
|
if (sub_dev_ptr->DmaBusy) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Sub device %d is still busy\n", drv.DriverName, sub_dev_nr);
|
2007-11-23 12:40:33 +01:00
|
|
|
return EBUSY;
|
|
|
|
}
|
2007-11-23 12:30:50 +01:00
|
|
|
/* Setup variables */
|
|
|
|
sub_dev_ptr->Opened = TRUE;
|
|
|
|
sub_dev_ptr->DmaReadNext = 0;
|
|
|
|
sub_dev_ptr->DmaFillNext = 0;
|
|
|
|
sub_dev_ptr->DmaLength = 0;
|
|
|
|
sub_dev_ptr->DmaMode = dma_mode;
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_ptr->BufReadNext = 0;
|
|
|
|
sub_dev_ptr->BufFillNext = 0;
|
|
|
|
sub_dev_ptr->BufLength = 0;
|
2007-11-23 12:30:50 +01:00
|
|
|
sub_dev_ptr->RevivePending = FALSE;
|
|
|
|
sub_dev_ptr->OutOfData = TRUE;
|
2007-11-23 12:40:33 +01:00
|
|
|
|
|
|
|
/* arrange DMA */
|
|
|
|
if (dma_mode != NO_DMA) { /* sub device uses DMA */
|
|
|
|
/* allocate dma buffer and extra buffer space
|
|
|
|
and configure sub device for dma */
|
|
|
|
if (init_buffers(sub_dev_ptr) != OK ) return EIO;
|
|
|
|
}
|
|
|
|
return OK;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int msg_close(int minor_dev_nr) {
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
int r, read_chan, write_chan, io_ctl;
|
|
|
|
special_file_t* special_file_ptr;
|
|
|
|
|
|
|
|
special_file_ptr = get_special_file(minor_dev_nr);
|
|
|
|
if(special_file_ptr == NULL) {
|
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
read_chan = special_file_ptr->read_chan;
|
|
|
|
write_chan = special_file_ptr->write_chan;
|
|
|
|
io_ctl = special_file_ptr->io_ctl;
|
|
|
|
|
2008-02-25 11:02:24 +01:00
|
|
|
r= OK;
|
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
/* close all sub devices */
|
|
|
|
if (write_chan != NO_CHANNEL) {
|
|
|
|
if (close_sub_dev(write_chan) != OK) r = EIO;
|
|
|
|
}
|
|
|
|
if (read_chan != NO_CHANNEL) {
|
|
|
|
if (close_sub_dev(read_chan) != OK) r = EIO;
|
|
|
|
}
|
|
|
|
if (read_chan == io_ctl || write_chan == io_ctl) {
|
|
|
|
/* io_ctl is already closed because it's the same as read or write */
|
|
|
|
return r; /* we're done */
|
|
|
|
}
|
|
|
|
/* ioctl differs from read/write channels... */
|
|
|
|
if (io_ctl != NO_CHANNEL) {
|
|
|
|
if (close_sub_dev(io_ctl) != OK) r = EIO; /* ...close it explicitly */
|
|
|
|
}
|
|
|
|
return r;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int close_sub_dev(int sub_dev_nr) {
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_t *sub_dev_ptr;
|
|
|
|
sub_dev_ptr = &sub_dev[sub_dev_nr];
|
|
|
|
if (sub_dev_ptr->DmaMode == DEV_WRITE_S && !sub_dev_ptr->OutOfData) {
|
|
|
|
/* do nothing, still data in buffers that has to be transferred */
|
|
|
|
sub_dev_ptr->Opened = FALSE; /* keep DMA busy */
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
if (sub_dev_ptr->DmaMode == NO_DMA) {
|
|
|
|
/* do nothing, there is no dma going on */
|
|
|
|
sub_dev_ptr->Opened = FALSE;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
sub_dev_ptr->Opened = FALSE;
|
|
|
|
sub_dev_ptr->DmaBusy = FALSE;
|
|
|
|
/* stop the device */
|
|
|
|
drv_stop(sub_dev_ptr->Nr);
|
|
|
|
/* free the buffers */
|
|
|
|
free(sub_dev_ptr->DmaBuf);
|
|
|
|
free(sub_dev_ptr->ExtraBuf);
|
2010-01-11 15:22:29 +01:00
|
|
|
return OK;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int msg_ioctl(const message *m_ptr)
|
2007-11-23 12:30:50 +01:00
|
|
|
{
|
|
|
|
int status, len, chan;
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_t *sub_dev_ptr;
|
|
|
|
special_file_t* special_file_ptr;
|
|
|
|
|
|
|
|
special_file_ptr = get_special_file(m_ptr->DEVICE);
|
|
|
|
if(special_file_ptr == NULL) {
|
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
chan = special_file_ptr->io_ctl;
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
if (chan == NO_CHANNEL) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: No io control channel specified!\n", drv.DriverName);
|
2007-11-23 12:40:33 +01:00
|
|
|
return EIO;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
/* get pointer to sub device data */
|
|
|
|
sub_dev_ptr = &sub_dev[chan];
|
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
if(!sub_dev_ptr->Opened) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: io control impossible - not opened!\n", drv.DriverName);
|
2007-11-23 12:40:33 +01:00
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* this is a hack...todo: may we intercept reset calls? */
|
|
|
|
/*
|
2007-11-23 12:30:50 +01:00
|
|
|
if(m_ptr->REQUEST == DSPIORESET) {
|
2007-11-23 12:40:33 +01:00
|
|
|
device_available = FALSE;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
if (m_ptr->REQUEST & _IOC_IN) { /* if there is data for us, copy it */
|
|
|
|
len = io_ctl_length(m_ptr->REQUEST);
|
|
|
|
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
if(sys_safecopyfrom(m_ptr->m_source,
|
2007-11-23 12:40:33 +01:00
|
|
|
(vir_bytes)m_ptr->ADDRESS, 0,
|
|
|
|
(vir_bytes)io_ctl_buf, len, D) != OK) {
|
|
|
|
printf("%s:%d: safecopyfrom failed\n", __FILE__, __LINE__);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all ioctl's are passed to the device specific part of the driver */
|
|
|
|
status = drv_io_ctl(m_ptr->REQUEST, (void *)io_ctl_buf, &len, chan);
|
|
|
|
|
|
|
|
/* _IOC_OUT bit -> user expects data */
|
|
|
|
if (status == OK && m_ptr->REQUEST & _IOC_OUT) {
|
|
|
|
/* copy result back to user */
|
|
|
|
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
if(sys_safecopyto(m_ptr->m_source, (vir_bytes)m_ptr->ADDRESS, 0,
|
2007-11-23 12:40:33 +01:00
|
|
|
(vir_bytes)io_ctl_buf, len, D) != OK) {
|
|
|
|
printf("%s:%d: safecopyto failed\n", __FILE__, __LINE__);
|
|
|
|
}
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static void msg_write(const message *m_ptr)
|
2007-11-23 12:30:50 +01:00
|
|
|
{
|
2010-01-22 23:01:08 +01:00
|
|
|
int chan; sub_dev_t *sub_dev_ptr;
|
2007-11-23 12:40:33 +01:00
|
|
|
special_file_t* special_file_ptr;
|
|
|
|
|
|
|
|
special_file_ptr = get_special_file(m_ptr->DEVICE);
|
|
|
|
chan = special_file_ptr->write_chan;
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
if (chan == NO_CHANNEL) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: No write channel specified!\n", drv.DriverName);
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EIO);
|
2007-11-23 12:40:33 +01:00
|
|
|
return;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
/* get pointer to sub device data */
|
|
|
|
sub_dev_ptr = &sub_dev[chan];
|
2007-11-23 12:40:33 +01:00
|
|
|
|
|
|
|
if (!sub_dev_ptr->DmaBusy) { /* get fragment size on first write */
|
|
|
|
if (drv_get_frag_size(&(sub_dev_ptr->FragSize), sub_dev_ptr->Nr) != OK){
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s; Failed to get fragment size!\n", drv.DriverName);
|
2007-11-23 12:40:33 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-11-23 12:30:50 +01:00
|
|
|
if(m_ptr->COUNT != sub_dev_ptr->FragSize) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("Fragment size does not match user's buffer length\n");
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EINVAL);
|
2007-11-23 12:30:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* if we are busy with something else than writing, return EBUSY */
|
2007-11-23 12:40:33 +01:00
|
|
|
if(sub_dev_ptr->DmaBusy && sub_dev_ptr->DmaMode != DEV_WRITE_S) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("Already busy with something else then writing\n");
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EBUSY);
|
2007-11-23 12:30:50 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-02-25 11:02:24 +01:00
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
sub_dev_ptr->RevivePending = TRUE;
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
sub_dev_ptr->ReviveProcNr = m_ptr->USER_ENDPT;
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_ptr->ReviveGrant = (cp_grant_id_t) m_ptr->ADDRESS;
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
sub_dev_ptr->SourceProcNr = m_ptr->m_source;
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
data_from_user(sub_dev_ptr);
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
if(!sub_dev_ptr->DmaBusy) { /* Dma tranfer not yet started */
|
2007-11-23 12:40:33 +01:00
|
|
|
get_started(sub_dev_ptr);
|
|
|
|
sub_dev_ptr->DmaMode = DEV_WRITE_S; /* Dma mode is writing */
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static void msg_read(message *m_ptr)
|
2007-11-23 12:30:50 +01:00
|
|
|
{
|
2010-01-22 23:01:08 +01:00
|
|
|
int chan; sub_dev_t *sub_dev_ptr;
|
2007-11-23 12:40:33 +01:00
|
|
|
special_file_t* special_file_ptr;
|
|
|
|
|
|
|
|
special_file_ptr = get_special_file(m_ptr->DEVICE);
|
|
|
|
chan = special_file_ptr->read_chan;
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
if (chan == NO_CHANNEL) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: No read channel specified!\n", drv.DriverName);
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EIO);
|
2007-11-23 12:40:33 +01:00
|
|
|
return;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
/* get pointer to sub device data */
|
|
|
|
sub_dev_ptr = &sub_dev[chan];
|
2007-11-23 12:40:33 +01:00
|
|
|
|
|
|
|
if (!sub_dev_ptr->DmaBusy) { /* get fragment size on first read */
|
|
|
|
if (drv_get_frag_size(&(sub_dev_ptr->FragSize), sub_dev_ptr->Nr) != OK){
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Could not retrieve fragment size!\n", drv.DriverName);
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT,
|
|
|
|
EIO);
|
2007-11-23 12:40:33 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-11-23 12:30:50 +01:00
|
|
|
if(m_ptr->COUNT != sub_dev_ptr->FragSize) {
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EINVAL);
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("fragment size does not match message size\n");
|
2007-11-23 12:30:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* if we are busy with something else than reading, reply EBUSY */
|
2007-11-23 12:40:33 +01:00
|
|
|
if(sub_dev_ptr->DmaBusy && sub_dev_ptr->DmaMode != DEV_READ_S) {
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
reply(DEV_REVIVE, m_ptr->m_source, m_ptr->USER_ENDPT, EBUSY);
|
2007-11-23 12:30:50 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-02-25 11:02:24 +01:00
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
sub_dev_ptr->RevivePending = TRUE;
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
sub_dev_ptr->ReviveProcNr = m_ptr->USER_ENDPT;
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_ptr->ReviveGrant = (cp_grant_id_t) m_ptr->ADDRESS;
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
sub_dev_ptr->SourceProcNr = m_ptr->m_source;
|
2007-11-23 12:30:50 +01:00
|
|
|
|
|
|
|
if(!sub_dev_ptr->DmaBusy) { /* Dma tranfer not yet started */
|
2007-11-23 12:40:33 +01:00
|
|
|
get_started(sub_dev_ptr);
|
|
|
|
sub_dev_ptr->DmaMode = DEV_READ_S; /* Dma mode is reading */
|
2007-11-23 12:30:50 +01:00
|
|
|
return; /* no need to get data from DMA buffer at this point */
|
|
|
|
}
|
2007-11-23 12:40:33 +01:00
|
|
|
/* check if data is available and possibly fill user's buffer */
|
|
|
|
data_to_user(sub_dev_ptr);
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static void msg_hardware(void) {
|
2007-11-23 12:40:33 +01:00
|
|
|
|
|
|
|
u32_t i;
|
|
|
|
|
|
|
|
/* while we have an interrupt */
|
|
|
|
while ( drv_int_sum()) {
|
|
|
|
/* loop over all sub devices */
|
|
|
|
for ( i = 0; i < drv.NrOfSubDevices; i++) {
|
|
|
|
/* if interrupt from sub device and Dma transfer
|
|
|
|
was actually busy, take care of business */
|
|
|
|
if( drv_int(i) && sub_dev[i].DmaBusy ) {
|
|
|
|
if (sub_dev[i].DmaMode == DEV_WRITE_S) handle_int_write(i);
|
|
|
|
if (sub_dev[i].DmaMode == DEV_READ_S) handle_int_read(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-14 13:44:20 +01:00
|
|
|
|
|
|
|
/* As IRQ_REENABLE is not on in sys_irqsetpolicy, we must
|
|
|
|
* re-enable out interrupt after every interrupt.
|
|
|
|
*/
|
|
|
|
if ((sys_irqenable(&irq_hook_id)) != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: msg_hardware: Couldn't enable IRQ\n", drv.DriverName);
|
2007-12-14 13:44:20 +01:00
|
|
|
}
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static void msg_status(message *m_ptr)
|
2007-11-23 12:30:50 +01:00
|
|
|
{
|
2007-11-23 12:40:33 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < drv.NrOfSubDevices; i++) {
|
|
|
|
|
|
|
|
if(sub_dev[i].ReadyToRevive)
|
|
|
|
{
|
|
|
|
m_ptr->m_type = DEV_REVIVE; /* build message */
|
|
|
|
m_ptr->REP_ENDPT = sub_dev[i].ReviveProcNr;
|
|
|
|
m_ptr->REP_IO_GRANT = sub_dev[i].ReviveGrant;
|
|
|
|
m_ptr->REP_STATUS = sub_dev[i].ReviveStatus;
|
|
|
|
send(m_ptr->m_source, m_ptr); /* send the message */
|
|
|
|
|
|
|
|
/* reset variables */
|
|
|
|
sub_dev[i].ReadyToRevive = FALSE;
|
|
|
|
sub_dev[i].RevivePending = 0;
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
is_status_msg_expected = TRUE;
|
2007-11-23 12:40:33 +01:00
|
|
|
return; /* stop after one mess,
|
|
|
|
file system will get back for other processes */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_ptr->m_type = DEV_NO_STATUS;
|
|
|
|
m_ptr->REP_STATUS = 0;
|
|
|
|
send(m_ptr->m_source, m_ptr); /* send DEV_NO_STATUS message */
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
is_status_msg_expected = FALSE;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
/* handle interrupt for specified sub device; DmaMode == DEV_WRITE_S*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void handle_int_write(int sub_dev_nr)
|
2007-11-23 12:30:50 +01:00
|
|
|
{
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_t *sub_dev_ptr;
|
|
|
|
|
|
|
|
sub_dev_ptr = &sub_dev[sub_dev_nr];
|
|
|
|
|
|
|
|
sub_dev_ptr->DmaReadNext =
|
|
|
|
(sub_dev_ptr->DmaReadNext + 1) % sub_dev_ptr->NrOfDmaFragments;
|
2007-11-23 12:30:50 +01:00
|
|
|
sub_dev_ptr->DmaLength -= 1;
|
2007-11-23 12:40:33 +01:00
|
|
|
|
|
|
|
if (sub_dev_ptr->BufLength != 0) { /* Data in extra buf, copy to Dma buf */
|
|
|
|
|
|
|
|
memcpy(sub_dev_ptr->DmaPtr +
|
|
|
|
sub_dev_ptr->DmaFillNext * sub_dev_ptr->FragSize,
|
|
|
|
sub_dev_ptr->ExtraBuf +
|
|
|
|
sub_dev_ptr->BufReadNext * sub_dev_ptr->FragSize,
|
|
|
|
sub_dev_ptr->FragSize);
|
|
|
|
|
|
|
|
sub_dev_ptr->BufReadNext =
|
|
|
|
(sub_dev_ptr->BufReadNext + 1) % sub_dev_ptr->NrOfExtraBuffers;
|
|
|
|
sub_dev_ptr->DmaFillNext =
|
|
|
|
(sub_dev_ptr->DmaFillNext + 1) % sub_dev_ptr->NrOfDmaFragments;
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
sub_dev_ptr->BufLength -= 1;
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_ptr->DmaLength += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* space became available, possibly copy new data from user */
|
2007-11-23 12:30:50 +01:00
|
|
|
data_from_user(sub_dev_ptr);
|
2007-11-23 12:40:33 +01:00
|
|
|
|
|
|
|
if(sub_dev_ptr->DmaLength == 0) { /* Dma buffer empty, stop Dma transfer */
|
|
|
|
|
|
|
|
sub_dev_ptr->OutOfData = TRUE; /* we're out of data */
|
|
|
|
if (!sub_dev_ptr->Opened) {
|
|
|
|
close_sub_dev(sub_dev_ptr->Nr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
drv_pause(sub_dev_ptr->Nr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* confirm and reenable interrupt from this sub dev */
|
|
|
|
drv_reenable_int(sub_dev_nr);
|
2007-12-14 13:44:20 +01:00
|
|
|
#if 0
|
2007-11-23 12:40:33 +01:00
|
|
|
/* reenable irq_hook*/
|
2010-01-15 22:45:30 +01:00
|
|
|
if (sys_irqenable(&irq_hook_id != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s Couldn't enable IRQ\n", drv.DriverName);
|
2007-11-23 12:40:33 +01:00
|
|
|
}
|
2007-12-14 13:44:20 +01:00
|
|
|
#endif
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
/* handle interrupt for specified sub device; DmaMode == DEV_READ_S */
|
2012-03-25 20:25:53 +02:00
|
|
|
static void handle_int_read(int sub_dev_nr)
|
2007-11-23 12:30:50 +01:00
|
|
|
{
|
2010-01-15 22:45:30 +01:00
|
|
|
sub_dev_t *sub_dev_ptr;
|
2007-11-23 12:40:33 +01:00
|
|
|
|
|
|
|
sub_dev_ptr = &sub_dev[sub_dev_nr];
|
|
|
|
|
|
|
|
sub_dev_ptr->DmaLength += 1;
|
|
|
|
sub_dev_ptr->DmaFillNext =
|
|
|
|
(sub_dev_ptr->DmaFillNext + 1) % sub_dev_ptr->NrOfDmaFragments;
|
|
|
|
|
|
|
|
/* possibly copy data to user (if it is waiting for us) */
|
|
|
|
data_to_user(sub_dev_ptr);
|
|
|
|
|
|
|
|
if (sub_dev_ptr->DmaLength == sub_dev_ptr->NrOfDmaFragments) {
|
|
|
|
/* if dma buffer full */
|
|
|
|
|
|
|
|
if (sub_dev_ptr->BufLength == sub_dev_ptr->NrOfExtraBuffers) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("All buffers full, we have a problem.\n");
|
2007-11-23 12:40:33 +01:00
|
|
|
drv_stop(sub_dev_nr); /* stop the sub device */
|
|
|
|
sub_dev_ptr->DmaBusy = FALSE;
|
|
|
|
sub_dev_ptr->ReviveStatus = 0; /* no data for user,
|
|
|
|
this is a sad story */
|
|
|
|
sub_dev_ptr->ReadyToRevive = TRUE; /* wake user up */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else { /* dma full, still room in extra buf;
|
|
|
|
copy from dma to extra buf */
|
|
|
|
memcpy(sub_dev_ptr->ExtraBuf +
|
|
|
|
sub_dev_ptr->BufFillNext * sub_dev_ptr->FragSize,
|
|
|
|
sub_dev_ptr->DmaPtr +
|
|
|
|
sub_dev_ptr->DmaReadNext * sub_dev_ptr->FragSize,
|
|
|
|
sub_dev_ptr->FragSize);
|
|
|
|
sub_dev_ptr->DmaLength -= 1;
|
|
|
|
sub_dev_ptr->DmaReadNext =
|
|
|
|
(sub_dev_ptr->DmaReadNext + 1) % sub_dev_ptr->NrOfDmaFragments;
|
|
|
|
sub_dev_ptr->BufFillNext =
|
|
|
|
(sub_dev_ptr->BufFillNext + 1) % sub_dev_ptr->NrOfExtraBuffers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* confirm interrupt, and reenable interrupt from this sub dev*/
|
|
|
|
drv_reenable_int(sub_dev_ptr->Nr);
|
|
|
|
|
2007-12-14 13:44:20 +01:00
|
|
|
#if 0
|
2007-11-23 12:40:33 +01:00
|
|
|
/* reenable irq_hook*/
|
2010-01-15 22:45:30 +01:00
|
|
|
if (sys_irqenable(&irq_hook_id) != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Couldn't reenable IRQ", drv.DriverName);
|
2007-11-23 12:40:33 +01:00
|
|
|
}
|
2007-12-14 13:44:20 +01:00
|
|
|
#endif
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int get_started(sub_dev_t *sub_dev_ptr) {
|
2010-01-15 22:45:30 +01:00
|
|
|
u32_t i;
|
2007-11-23 12:40:33 +01:00
|
|
|
|
|
|
|
/* enable interrupt messages from MINIX */
|
|
|
|
if ((i=sys_irqenable(&irq_hook_id)) != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Couldn't enable IRQs: error code %u",drv.DriverName, (unsigned int) i);
|
2007-11-23 12:40:33 +01:00
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
/* let the lower part of the driver start the device */
|
|
|
|
if (drv_start(sub_dev_ptr->Nr, sub_dev_ptr->DmaMode) != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Could not start device %d\n",
|
2007-11-23 12:40:33 +01:00
|
|
|
drv.DriverName, sub_dev_ptr->Nr);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub_dev_ptr->DmaBusy = TRUE; /* Dma is busy from now on */
|
2007-11-23 12:30:50 +01:00
|
|
|
sub_dev_ptr->DmaReadNext = 0;
|
2007-11-23 12:40:33 +01:00
|
|
|
return OK;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static void data_from_user(sub_dev_t *subdev)
|
2007-12-14 13:44:20 +01:00
|
|
|
{
|
2008-02-25 11:02:24 +01:00
|
|
|
int r;
|
|
|
|
message m;
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
if (subdev->DmaLength == subdev->NrOfDmaFragments &&
|
|
|
|
subdev->BufLength == subdev->NrOfExtraBuffers) return;/* no space */
|
|
|
|
|
|
|
|
if (!subdev->RevivePending) return; /* no new data waiting to be copied */
|
|
|
|
|
|
|
|
if (subdev->RevivePending &&
|
|
|
|
subdev->ReadyToRevive) return; /* we already got this data */
|
|
|
|
|
|
|
|
if (subdev->DmaLength < subdev->NrOfDmaFragments) { /* room in dma buf */
|
|
|
|
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
sys_safecopyfrom(subdev->SourceProcNr,
|
2007-11-23 12:40:33 +01:00
|
|
|
(vir_bytes)subdev->ReviveGrant, 0,
|
|
|
|
(vir_bytes)subdev->DmaPtr +
|
|
|
|
subdev->DmaFillNext * subdev->FragSize,
|
|
|
|
(phys_bytes)subdev->FragSize, D);
|
|
|
|
|
|
|
|
|
|
|
|
subdev->DmaLength += 1;
|
|
|
|
subdev->DmaFillNext =
|
|
|
|
(subdev->DmaFillNext + 1) % subdev->NrOfDmaFragments;
|
|
|
|
|
|
|
|
} else { /* room in extra buf */
|
|
|
|
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
sys_safecopyfrom(subdev->SourceProcNr,
|
2007-11-23 12:40:33 +01:00
|
|
|
(vir_bytes)subdev->ReviveGrant, 0,
|
|
|
|
(vir_bytes)subdev->ExtraBuf +
|
|
|
|
subdev->BufFillNext * subdev->FragSize,
|
|
|
|
(phys_bytes)subdev->FragSize, D);
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
subdev->BufLength += 1;
|
2007-11-23 12:40:33 +01:00
|
|
|
|
|
|
|
subdev->BufFillNext =
|
|
|
|
(subdev->BufFillNext + 1) % subdev->NrOfExtraBuffers;
|
2007-11-23 12:30:50 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
if(subdev->OutOfData) { /* if device paused (because of lack of data) */
|
2007-11-23 12:40:33 +01:00
|
|
|
subdev->OutOfData = FALSE;
|
|
|
|
drv_reenable_int(subdev->Nr);
|
|
|
|
/* reenable irq_hook*/
|
|
|
|
if ((sys_irqenable(&irq_hook_id)) != OK) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: Couldn't enable IRQ", drv.DriverName);
|
2007-11-23 12:40:33 +01:00
|
|
|
}
|
|
|
|
drv_resume(subdev->Nr); /* resume resume the sub device */
|
|
|
|
}
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
subdev->ReviveStatus = subdev->FragSize;
|
|
|
|
subdev->ReadyToRevive = TRUE;
|
2008-02-25 11:02:24 +01:00
|
|
|
|
|
|
|
m.m_type = DEV_REVIVE; /* build message */
|
|
|
|
m.REP_ENDPT = subdev->ReviveProcNr;
|
|
|
|
m.REP_IO_GRANT = subdev->ReviveGrant;
|
|
|
|
m.REP_STATUS = subdev->ReviveStatus;
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
r= send(subdev->SourceProcNr, &m); /* send the message */
|
2008-02-25 11:02:24 +01:00
|
|
|
if (r != OK)
|
|
|
|
{
|
|
|
|
printf("audio_fw: send to %d failed: %d\n",
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
subdev->SourceProcNr, r);
|
2008-02-25 11:02:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* reset variables */
|
|
|
|
subdev->ReadyToRevive = FALSE;
|
|
|
|
subdev->RevivePending = 0;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static void data_to_user(sub_dev_t *sub_dev_ptr)
|
2008-02-25 11:02:24 +01:00
|
|
|
{
|
|
|
|
int r;
|
|
|
|
message m;
|
|
|
|
|
2007-11-23 12:40:33 +01:00
|
|
|
if (!sub_dev_ptr->RevivePending) return; /* nobody is wating for data */
|
|
|
|
if (sub_dev_ptr->ReadyToRevive) return;/* we already filled user's buffer */
|
|
|
|
if (sub_dev_ptr->BufLength == 0 && sub_dev_ptr->DmaLength == 0) return;
|
|
|
|
/* no data for user */
|
|
|
|
|
|
|
|
if(sub_dev_ptr->BufLength != 0) { /* data in extra buffer available */
|
|
|
|
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
sys_safecopyto(sub_dev_ptr->SourceProcNr,
|
2007-11-23 12:40:33 +01:00
|
|
|
(vir_bytes)sub_dev_ptr->ReviveGrant,
|
|
|
|
0, (vir_bytes)sub_dev_ptr->ExtraBuf +
|
|
|
|
sub_dev_ptr->BufReadNext * sub_dev_ptr->FragSize,
|
|
|
|
(phys_bytes)sub_dev_ptr->FragSize, D);
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
/* adjust the buffer status variables */
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_ptr->BufReadNext =
|
|
|
|
(sub_dev_ptr->BufReadNext + 1) % sub_dev_ptr->NrOfExtraBuffers;
|
2007-11-23 12:30:50 +01:00
|
|
|
sub_dev_ptr->BufLength -= 1;
|
2007-11-23 12:40:33 +01:00
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
} else { /* extra buf empty, but data in dma buf*/
|
2007-11-23 12:40:33 +01:00
|
|
|
sys_safecopyto(
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
sub_dev_ptr->SourceProcNr,
|
2007-11-23 12:40:33 +01:00
|
|
|
(vir_bytes)sub_dev_ptr->ReviveGrant, 0,
|
|
|
|
(vir_bytes)sub_dev_ptr->DmaPtr +
|
|
|
|
sub_dev_ptr->DmaReadNext * sub_dev_ptr->FragSize,
|
|
|
|
(phys_bytes)sub_dev_ptr->FragSize, D);
|
2007-11-23 12:30:50 +01:00
|
|
|
|
|
|
|
/* adjust the buffer status variables */
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_ptr->DmaReadNext =
|
|
|
|
(sub_dev_ptr->DmaReadNext + 1) % sub_dev_ptr->NrOfDmaFragments;
|
2007-11-23 12:30:50 +01:00
|
|
|
sub_dev_ptr->DmaLength -= 1;
|
|
|
|
}
|
2007-11-23 12:40:33 +01:00
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
sub_dev_ptr->ReviveStatus = sub_dev_ptr->FragSize;
|
2007-11-23 12:40:33 +01:00
|
|
|
sub_dev_ptr->ReadyToRevive = TRUE;
|
|
|
|
/* drv_status will send REVIVE mess to FS*/
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2008-02-25 11:02:24 +01:00
|
|
|
m.m_type = DEV_REVIVE; /* build message */
|
|
|
|
m.REP_ENDPT = sub_dev_ptr->ReviveProcNr;
|
|
|
|
m.REP_IO_GRANT = sub_dev_ptr->ReviveGrant;
|
|
|
|
m.REP_STATUS = sub_dev_ptr->ReviveStatus;
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
r= send(sub_dev_ptr->SourceProcNr, &m); /* send the message */
|
2008-02-25 11:02:24 +01:00
|
|
|
if (r != OK)
|
|
|
|
{
|
|
|
|
printf("audio_fw: send to %d failed: %d\n",
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
sub_dev_ptr->SourceProcNr, r);
|
2008-02-25 11:02:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* reset variables */
|
|
|
|
sub_dev_ptr->ReadyToRevive = FALSE;
|
|
|
|
sub_dev_ptr->RevivePending = 0;
|
|
|
|
}
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int init_buffers(sub_dev_t *sub_dev_ptr)
|
2008-02-25 11:02:24 +01:00
|
|
|
{
|
2007-11-23 12:30:50 +01:00
|
|
|
#if (CHIP == INTEL)
|
2008-02-25 11:02:24 +01:00
|
|
|
char *base;
|
Merge of David's ptrace branch. Summary:
o Support for ptrace T_ATTACH/T_DETACH and T_SYSCALL
o PM signal handling logic should now work properly, even with debuggers
being present
o Asynchronous PM/VFS protocol, full IPC support for senda(), and
AMF_NOREPLY senda() flag
DETAILS
Process stop and delay call handling of PM:
o Added sys_runctl() kernel call with sys_stop() and sys_resume()
aliases, for PM to stop and resume a process
o Added exception for sending/syscall-traced processes to sys_runctl(),
and matching SIGKREADY pseudo-signal to PM
o Fixed PM signal logic to deal with requests from a process after
stopping it (so-called "delay calls"), using the SIGKREADY facility
o Fixed various PM panics due to race conditions with delay calls versus
VFS calls
o Removed special PRIO_STOP priority value
o Added SYS_LOCK RTS kernel flag, to stop an individual process from
running while modifying its process structure
Signal and debugger handling in PM:
o Fixed debugger signals being dropped if a second signal arrives when
the debugger has not retrieved the first one
o Fixed debugger signals being sent to the debugger more than once
o Fixed debugger signals unpausing process in VFS; removed PM_UNPAUSE_TR
protocol message
o Detached debugger signals from general signal logic and from being
blocked on VFS calls, meaning that even VFS can now be traced
o Fixed debugger being unable to receive more than one pending signal in
one process stop
o Fixed signal delivery being delayed needlessly when multiple signals
are pending
o Fixed wait test for tracer, which was returning for children that were
not waited for
o Removed second parallel pending call from PM to VFS for any process
o Fixed process becoming runnable between exec() and debugger trap
o Added support for notifying the debugger before the parent when a
debugged child exits
o Fixed debugger death causing child to remain stopped forever
o Fixed consistently incorrect use of _NSIG
Extensions to ptrace():
o Added T_ATTACH and T_DETACH ptrace request, to attach and detach a
debugger to and from a process
o Added T_SYSCALL ptrace request, to trace system calls
o Added T_SETOPT ptrace request, to set trace options
o Added TO_TRACEFORK trace option, to attach automatically to children
of a traced process
o Added TO_ALTEXEC trace option, to send SIGSTOP instead of SIGTRAP upon
a successful exec() of the tracee
o Extended T_GETUSER ptrace support to allow retrieving a process's priv
structure
o Removed T_STOP ptrace request again, as it does not help implementing
debuggers properly
o Added MINIX3-specific ptrace test (test42)
o Added proper manual page for ptrace(2)
Asynchronous PM/VFS interface:
o Fixed asynchronous messages not being checked when receive() is called
with an endpoint other than ANY
o Added AMF_NOREPLY senda() flag, preventing such messages from
satisfying the receive part of a sendrec()
o Added asynsend3() that takes optional flags; asynsend() is now a
#define passing in 0 as third parameter
o Made PM/VFS protocol asynchronous; reintroduced tell_fs()
o Made PM_BASE request/reply number range unique
o Hacked in a horrible temporary workaround into RS to deal with newly
revealed RS-PM-VFS race condition triangle until VFS is asynchronous
System signal handling:
o Fixed shutdown logic of device drivers; removed old SIGKSTOP signal
o Removed is-superuser check from PM's do_procstat() (aka getsigset())
o Added sigset macros to allow system processes to deal with the full
signal set, rather than just the POSIX subset
Miscellaneous PM fixes:
o Split do_getset into do_get and do_set, merging common code and making
structure clearer
o Fixed setpriority() being able to put to sleep processes using an
invalid parameter, or revive zombie processes
o Made find_proc() global; removed obsolete proc_from_pid()
o Cleanup here and there
Also included:
o Fixed false-positive boot order kernel warning
o Removed last traces of old NOTIFY_FROM code
THINGS OF POSSIBLE INTEREST
o It should now be possible to run PM at any priority, even lower than
user processes
o No assumptions are made about communication speed between PM and VFS,
although communication must be FIFO
o A debugger will now receive incoming debuggee signals at kill time
only; the process may not yet be fully stopped
o A first step has been made towards making the SYSTEM task preemptible
2009-09-30 11:57:22 +02:00
|
|
|
size_t size;
|
2008-02-25 11:02:24 +01:00
|
|
|
unsigned left;
|
|
|
|
u32_t i;
|
2008-11-19 13:26:10 +01:00
|
|
|
phys_bytes ph;
|
2008-02-25 11:02:24 +01:00
|
|
|
|
|
|
|
/* allocate dma buffer space */
|
|
|
|
size= sub_dev_ptr->DmaSize + 64 * 1024;
|
Merge of David's ptrace branch. Summary:
o Support for ptrace T_ATTACH/T_DETACH and T_SYSCALL
o PM signal handling logic should now work properly, even with debuggers
being present
o Asynchronous PM/VFS protocol, full IPC support for senda(), and
AMF_NOREPLY senda() flag
DETAILS
Process stop and delay call handling of PM:
o Added sys_runctl() kernel call with sys_stop() and sys_resume()
aliases, for PM to stop and resume a process
o Added exception for sending/syscall-traced processes to sys_runctl(),
and matching SIGKREADY pseudo-signal to PM
o Fixed PM signal logic to deal with requests from a process after
stopping it (so-called "delay calls"), using the SIGKREADY facility
o Fixed various PM panics due to race conditions with delay calls versus
VFS calls
o Removed special PRIO_STOP priority value
o Added SYS_LOCK RTS kernel flag, to stop an individual process from
running while modifying its process structure
Signal and debugger handling in PM:
o Fixed debugger signals being dropped if a second signal arrives when
the debugger has not retrieved the first one
o Fixed debugger signals being sent to the debugger more than once
o Fixed debugger signals unpausing process in VFS; removed PM_UNPAUSE_TR
protocol message
o Detached debugger signals from general signal logic and from being
blocked on VFS calls, meaning that even VFS can now be traced
o Fixed debugger being unable to receive more than one pending signal in
one process stop
o Fixed signal delivery being delayed needlessly when multiple signals
are pending
o Fixed wait test for tracer, which was returning for children that were
not waited for
o Removed second parallel pending call from PM to VFS for any process
o Fixed process becoming runnable between exec() and debugger trap
o Added support for notifying the debugger before the parent when a
debugged child exits
o Fixed debugger death causing child to remain stopped forever
o Fixed consistently incorrect use of _NSIG
Extensions to ptrace():
o Added T_ATTACH and T_DETACH ptrace request, to attach and detach a
debugger to and from a process
o Added T_SYSCALL ptrace request, to trace system calls
o Added T_SETOPT ptrace request, to set trace options
o Added TO_TRACEFORK trace option, to attach automatically to children
of a traced process
o Added TO_ALTEXEC trace option, to send SIGSTOP instead of SIGTRAP upon
a successful exec() of the tracee
o Extended T_GETUSER ptrace support to allow retrieving a process's priv
structure
o Removed T_STOP ptrace request again, as it does not help implementing
debuggers properly
o Added MINIX3-specific ptrace test (test42)
o Added proper manual page for ptrace(2)
Asynchronous PM/VFS interface:
o Fixed asynchronous messages not being checked when receive() is called
with an endpoint other than ANY
o Added AMF_NOREPLY senda() flag, preventing such messages from
satisfying the receive part of a sendrec()
o Added asynsend3() that takes optional flags; asynsend() is now a
#define passing in 0 as third parameter
o Made PM/VFS protocol asynchronous; reintroduced tell_fs()
o Made PM_BASE request/reply number range unique
o Hacked in a horrible temporary workaround into RS to deal with newly
revealed RS-PM-VFS race condition triangle until VFS is asynchronous
System signal handling:
o Fixed shutdown logic of device drivers; removed old SIGKSTOP signal
o Removed is-superuser check from PM's do_procstat() (aka getsigset())
o Added sigset macros to allow system processes to deal with the full
signal set, rather than just the POSIX subset
Miscellaneous PM fixes:
o Split do_getset into do_get and do_set, merging common code and making
structure clearer
o Fixed setpriority() being able to put to sleep processes using an
invalid parameter, or revive zombie processes
o Made find_proc() global; removed obsolete proc_from_pid()
o Cleanup here and there
Also included:
o Fixed false-positive boot order kernel warning
o Removed last traces of old NOTIFY_FROM code
THINGS OF POSSIBLE INTEREST
o It should now be possible to run PM at any priority, even lower than
user processes
o No assumptions are made about communication speed between PM and VFS,
although communication must be FIFO
o A debugger will now receive incoming debuggee signals at kill time
only; the process may not yet be fully stopped
o A first step has been made towards making the SYSTEM task preemptible
2009-09-30 11:57:22 +02:00
|
|
|
base= alloc_contig(size, AC_ALIGN4K, &ph);
|
2008-02-25 11:02:24 +01:00
|
|
|
if (!base) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: failed to allocate dma buffer for a channel\n",
|
2010-01-20 18:59:48 +01:00
|
|
|
drv.DriverName);
|
2008-02-25 11:02:24 +01:00
|
|
|
return EIO;
|
|
|
|
}
|
|
|
|
sub_dev_ptr->DmaBuf= base;
|
2007-11-23 12:40:33 +01:00
|
|
|
|
2008-02-25 11:02:24 +01:00
|
|
|
tell_dev((vir_bytes)base, size, 0, 0, 0);
|
2007-11-23 12:40:33 +01:00
|
|
|
|
2008-02-25 11:02:24 +01:00
|
|
|
/* allocate extra buffer space */
|
|
|
|
if (!(sub_dev_ptr->ExtraBuf = malloc(sub_dev_ptr->NrOfExtraBuffers *
|
|
|
|
sub_dev_ptr->DmaSize /
|
|
|
|
sub_dev_ptr->NrOfDmaFragments))) {
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s failed to allocate extra buffer for a channel\n",
|
2010-01-27 11:23:58 +01:00
|
|
|
drv.DriverName);
|
2008-02-25 11:02:24 +01:00
|
|
|
return EIO;
|
|
|
|
}
|
2007-11-23 12:40:33 +01:00
|
|
|
|
2008-02-25 11:02:24 +01:00
|
|
|
sub_dev_ptr->DmaPtr = sub_dev_ptr->DmaBuf;
|
|
|
|
i = sys_umap(SELF, D,
|
|
|
|
(vir_bytes) sub_dev_ptr->DmaBuf,
|
|
|
|
(phys_bytes) sizeof(sub_dev_ptr->DmaBuf),
|
|
|
|
&(sub_dev_ptr->DmaPhys));
|
2007-11-23 12:40:33 +01:00
|
|
|
|
2008-02-25 11:02:24 +01:00
|
|
|
if (i != OK) {
|
2007-11-23 12:40:33 +01:00
|
|
|
return EIO;
|
|
|
|
}
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2008-02-25 11:02:24 +01:00
|
|
|
if ((left = dma_bytes_left(sub_dev_ptr->DmaPhys)) <
|
|
|
|
sub_dev_ptr->DmaSize) {
|
|
|
|
/* First half of buffer crosses a 64K boundary,
|
|
|
|
* can't DMA into that */
|
|
|
|
sub_dev_ptr->DmaPtr += left;
|
|
|
|
sub_dev_ptr->DmaPhys += left;
|
|
|
|
}
|
|
|
|
/* write the physical dma address and size to the device */
|
|
|
|
drv_set_dma(sub_dev_ptr->DmaPhys,
|
|
|
|
sub_dev_ptr->DmaSize, sub_dev_ptr->Nr);
|
|
|
|
return OK;
|
|
|
|
|
|
|
|
#else /* CHIP != INTEL */
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: init_buffers() failed, CHIP != INTEL", drv.DriverName);
|
2008-02-25 11:02:24 +01:00
|
|
|
return EIO;
|
|
|
|
#endif /* CHIP == INTEL */
|
|
|
|
}
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static void reply(int code, int replyee, int process, int status) {
|
2007-11-23 12:30:50 +01:00
|
|
|
message m;
|
|
|
|
|
2008-02-25 11:02:24 +01:00
|
|
|
m.m_type = code; /* DEV_REVIVE */
|
2007-11-23 12:30:50 +01:00
|
|
|
m.REP_STATUS = status; /* result of device operation */
|
2007-11-23 12:40:33 +01:00
|
|
|
m.REP_ENDPT = process; /* which user made the request */
|
2007-11-23 12:30:50 +01:00
|
|
|
send(replyee, &m);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int io_ctl_length(int io_request) {
|
2007-11-23 12:40:33 +01:00
|
|
|
io_request >>= 16;
|
|
|
|
return io_request & _IOCPARM_MASK;
|
2007-11-23 12:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static special_file_t* get_special_file(int minor_dev_nr) {
|
2007-11-23 12:30:50 +01:00
|
|
|
int i;
|
2007-11-23 12:40:33 +01:00
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
for(i = 0; i < drv.NrOfSpecialFiles; i++) {
|
|
|
|
if(special_file[i].minor_dev_nr == minor_dev_nr) {
|
|
|
|
return &special_file[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:57:51 +02:00
|
|
|
printf("%s: No subdevice specified for minor device %d!\n",
|
2007-11-23 12:40:33 +01:00
|
|
|
drv.DriverName, minor_dev_nr);
|
|
|
|
|
2007-11-23 12:30:50 +01:00
|
|
|
return NULL;
|
2007-11-23 12:40:33 +01:00
|
|
|
}
|
2008-02-25 11:02:24 +01:00
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static void tell_dev(buf, size, pci_bus, pci_dev, pci_func)
|
2008-02-25 11:02:24 +01:00
|
|
|
vir_bytes buf;
|
|
|
|
size_t size;
|
|
|
|
int pci_bus;
|
|
|
|
int pci_dev;
|
|
|
|
int pci_func;
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
endpoint_t dev_e;
|
|
|
|
message m;
|
|
|
|
|
2010-04-08 15:41:35 +02:00
|
|
|
r= ds_retrieve_label_endpt("amddev", &dev_e);
|
2008-02-25 11:02:24 +01:00
|
|
|
if (r != OK)
|
|
|
|
{
|
2009-04-22 18:53:46 +02:00
|
|
|
#if 0
|
2010-04-08 15:41:35 +02:00
|
|
|
printf("tell_dev: ds_retrieve_label_endpt failed for 'amddev': %d\n",
|
2008-02-25 11:02:24 +01:00
|
|
|
r);
|
2009-04-22 18:53:46 +02:00
|
|
|
#endif
|
2008-02-25 11:02:24 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m.m_type= IOMMU_MAP;
|
|
|
|
m.m2_i1= pci_bus;
|
|
|
|
m.m2_i2= pci_dev;
|
|
|
|
m.m2_i3= pci_func;
|
|
|
|
m.m2_l1= buf;
|
|
|
|
m.m2_l2= size;
|
|
|
|
|
|
|
|
r= sendrec(dev_e, &m);
|
|
|
|
if (r != OK)
|
|
|
|
{
|
|
|
|
printf("tell_dev: sendrec to %d failed: %d\n", dev_e, r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (m.m_type != OK)
|
|
|
|
{
|
|
|
|
printf("tell_dev: dma map request failed: %d\n", m.m_type);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|