2005-07-14 17:14:44 +02:00
|
|
|
/* Prototypes for system library functions. */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
#ifndef _SYSLIB_H
|
|
|
|
#define _SYSLIB_H
|
|
|
|
|
|
|
|
#ifndef _TYPES_H
|
2009-11-06 09:46:22 +01:00
|
|
|
#include <minix/types.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _IPC_H
|
|
|
|
#include <minix/ipc.h>
|
|
|
|
#endif
|
|
|
|
|
2007-03-08 16:39:14 +01:00
|
|
|
#include <minix/u64.h>
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
#ifndef _DEVIO_H
|
|
|
|
#include <minix/devio.h>
|
|
|
|
#endif
|
|
|
|
|
. introduced DEV_READ_S, DEV_WRITE_S, DEV_SCATTER_S, DEV_GATHER_S
and DEV_IOCTL_S as replacements for DEV_READ, DEV_WRITE, DEV_SCATTER,
DEV_GATHER and DEV_IOCTL. Instead of a direct address, the *_S commands
pass 'grant ids' to the drivers which are referenced through a new set
of copy calls (sys_safecopyfrom and sys_safecopyto). in order for this
copy to succeed, the grant must have previously been created in the
address space of the granter.
. bitmap manipulation functions moved to <minix/bitmap.h>
. HIGHPOS introduced as field containing high 32 bits of position in
device I/O message; TTY_FLAGS no longer used
. IO_GRANT field introduced for GRANTs, to replace ADDRESS
. REP_IO_GRANT field for un-SUSPEND messages introduced to indicate
grant for which I/O was done to disambiguate messages
. SYS_SAFECOPYFROM and SYS_SAFECOPYTO introduced as new calls
. SYS_PRIV_SET_GRANTS code introduced as a code to set the address and
size of the grant table in a process' own address space
. 'type' and 'direction' field of _ins* and _outs* I/O functions
are merged into one by ORing _DIO_INPUT/_DIO_OUTPUT and _DIO_BYTE/_DIO_WORD
etc. This allows for an additional parameter, _DIO_SAFE, which indicates
the address in another address space isn't actually an address, but
a grant id. Also needs an offset, for which fields had to be merged.
. SCP_* are field names for SYS_SAFECOPY* functions
. DIAGNOSTICS and GET_KMESS moved to their own range above DIAG_BASE,
added DIAGNOSTICS_S which is a grant-based variant of DIAGNOSTICS
. removed obsolete BINCOMPAT and SRCCOMPAT options
. added GRANT_SEG type for use in vircopy - allows copying to a grant
id (without offset)
. added _MINIX_IOCTL_* macros that decode information encoded by
_IO* macros in ioctl codes, used to check which grants are necessary
for an ioctl
. introduced the type endpoint_t for process endpoints, changed some
prototypes and struct field types to match
. renamed protected to prot for g++
2006-06-20 10:38:15 +02:00
|
|
|
#include <minix/safecopies.h>
|
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
|
|
|
#include <minix/sef.h>
|
2010-03-12 16:58:41 +01:00
|
|
|
#include <machine/mcontext.h>
|
. introduced DEV_READ_S, DEV_WRITE_S, DEV_SCATTER_S, DEV_GATHER_S
and DEV_IOCTL_S as replacements for DEV_READ, DEV_WRITE, DEV_SCATTER,
DEV_GATHER and DEV_IOCTL. Instead of a direct address, the *_S commands
pass 'grant ids' to the drivers which are referenced through a new set
of copy calls (sys_safecopyfrom and sys_safecopyto). in order for this
copy to succeed, the grant must have previously been created in the
address space of the granter.
. bitmap manipulation functions moved to <minix/bitmap.h>
. HIGHPOS introduced as field containing high 32 bits of position in
device I/O message; TTY_FLAGS no longer used
. IO_GRANT field introduced for GRANTs, to replace ADDRESS
. REP_IO_GRANT field for un-SUSPEND messages introduced to indicate
grant for which I/O was done to disambiguate messages
. SYS_SAFECOPYFROM and SYS_SAFECOPYTO introduced as new calls
. SYS_PRIV_SET_GRANTS code introduced as a code to set the address and
size of the grant table in a process' own address space
. 'type' and 'direction' field of _ins* and _outs* I/O functions
are merged into one by ORing _DIO_INPUT/_DIO_OUTPUT and _DIO_BYTE/_DIO_WORD
etc. This allows for an additional parameter, _DIO_SAFE, which indicates
the address in another address space isn't actually an address, but
a grant id. Also needs an offset, for which fields had to be merged.
. SCP_* are field names for SYS_SAFECOPY* functions
. DIAGNOSTICS and GET_KMESS moved to their own range above DIAG_BASE,
added DIAGNOSTICS_S which is a grant-based variant of DIAGNOSTICS
. removed obsolete BINCOMPAT and SRCCOMPAT options
. added GRANT_SEG type for use in vircopy - allows copying to a grant
id (without offset)
. added _MINIX_IOCTL_* macros that decode information encoded by
_IO* macros in ioctl codes, used to check which grants are necessary
for an ioctl
. introduced the type endpoint_t for process endpoints, changed some
prototypes and struct field types to match
. renamed protected to prot for g++
2006-06-20 10:38:15 +02:00
|
|
|
|
2005-07-29 12:21:04 +02:00
|
|
|
/* Forward declaration */
|
|
|
|
struct reg86u;
|
2006-10-20 17:01:32 +02:00
|
|
|
struct rs_pci;
|
2005-07-29 12:21:04 +02:00
|
|
|
|
2005-07-14 17:14:44 +02:00
|
|
|
#define SYSTASK SYSTEM
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/*==========================================================================*
|
|
|
|
* Minix system library. *
|
|
|
|
*==========================================================================*/
|
2012-03-24 16:16:34 +01:00
|
|
|
int _taskcall(endpoint_t who, int syscallnr, message *msgptr);
|
|
|
|
int _kernel_call(int syscallnr, message *msgptr);
|
|
|
|
|
|
|
|
int sys_abort(int how, ...);
|
|
|
|
int sys_enable_iop(endpoint_t proc_ep);
|
|
|
|
int sys_exec(endpoint_t proc_ep, char *ptr, char *aout, vir_bytes
|
|
|
|
initpc);
|
No more intel/minix segments.
This commit removes all traces of Minix segments (the text/data/stack
memory map abstraction in the kernel) and significance of Intel segments
(hardware segments like CS, DS that add offsets to all addressing before
page table translation). This ultimately simplifies the memory layout
and addressing and makes the same layout possible on non-Intel
architectures.
There are only two types of addresses in the world now: virtual
and physical; even the kernel and processes have the same virtual
address space. Kernel and user processes can be distinguished at a
glance as processes won't use 0xF0000000 and above.
No static pre-allocated memory sizes exist any more.
Changes to booting:
. The pre_init.c leaves the kernel and modules exactly as
they were left by the bootloader in physical memory
. The kernel starts running using physical addressing,
loaded at a fixed location given in its linker script by the
bootloader. All code and data in this phase are linked to
this fixed low location.
. It makes a bootstrap pagetable to map itself to a
fixed high location (also in linker script) and jumps to
the high address. All code and data then use this high addressing.
. All code/data symbols linked at the low addresses is prefixed by
an objcopy step with __k_unpaged_*, so that that code cannot
reference highly-linked symbols (which aren't valid yet) or vice
versa (symbols that aren't valid any more).
. The two addressing modes are separated in the linker script by
collecting the unpaged_*.o objects and linking them with low
addresses, and linking the rest high. Some objects are linked
twice, once low and once high.
. The bootstrap phase passes a lot of information (e.g. free memory
list, physical location of the modules, etc.) using the kinfo
struct.
. After this bootstrap the low-linked part is freed.
. The kernel maps in VM into the bootstrap page table so that VM can
begin executing. Its first job is to make page tables for all other
boot processes. So VM runs before RS, and RS gets a fully dynamic,
VM-managed address space. VM gets its privilege info from RS as usual
but that happens after RS starts running.
. Both the kernel loading VM and VM organizing boot processes happen
using the libexec logic. This removes the last reason for VM to
still know much about exec() and vm/exec.c is gone.
Further Implementation:
. All segments are based at 0 and have a 4 GB limit.
. The kernel is mapped in at the top of the virtual address
space so as not to constrain the user processes.
. Processes do not use segments from the LDT at all; there are
no segments in the LDT any more, so no LLDT is needed.
. The Minix segments T/D/S are gone and so none of the
user-space or in-kernel copy functions use them. The copy
functions use a process endpoint of NONE to realize it's
a physical address, virtual otherwise.
. The umap call only makes sense to translate a virtual address
to a physical address now.
. Segments-related calls like newmap and alloc_segments are gone.
. All segments-related translation in VM is gone (vir2map etc).
. Initialization in VM is simpler as no moving around is necessary.
. VM and all other boot processes can be linked wherever they wish
and will be mapped in at the right location by the kernel and VM
respectively.
Other changes:
. The multiboot code is less special: it does not use mb_print
for its diagnostics any more but uses printf() as normal, saving
the output into the diagnostics buffer, only printing to the
screen using the direct print functions if a panic() occurs.
. The multiboot code uses the flexible 'free memory map list'
style to receive the list of free memory if available.
. The kernel determines the memory layout of the processes to
a degree: it tells VM where the kernel starts and ends and
where the kernel wants the top of the process to be. VM then
uses this entire range, i.e. the stack is right at the top,
and mmap()ped bits of memory are placed below that downwards,
and the break grows upwards.
Other Consequences:
. Every process gets its own page table as address spaces
can't be separated any more by segments.
. As all segments are 0-based, there is no distinction between
virtual and linear addresses, nor between userspace and
kernel addresses.
. Less work is done when context switching, leading to a net
performance increase. (8% faster on my machine for 'make servers'.)
. The layout and configuration of the GDT makes sysenter and syscall
possible.
2012-05-07 16:03:35 +02:00
|
|
|
int sys_fork(endpoint_t parent, endpoint_t child, endpoint_t *,
|
|
|
|
u32_t vm, vir_bytes *);
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_clear(endpoint_t proc_ep);
|
|
|
|
int sys_exit(void);
|
|
|
|
int sys_trace(int req, endpoint_t proc_ep, long addr, long *data_p);
|
|
|
|
|
|
|
|
int sys_schedule(endpoint_t proc_ep, int priority, int quantum, int
|
|
|
|
cpu);
|
|
|
|
int sys_schedctl(unsigned flags, endpoint_t proc_ep, int priority, int
|
|
|
|
quantum, int cpu);
|
Userspace scheduling
- cotributed by Bjorn Swift
- In this first phase, scheduling is moved from the kernel to the PM
server. The next steps are to a) moving scheduling to its own server
and b) include useful information in the "out of quantum" message,
so that the scheduler can make use of this information.
- The kernel process table now keeps record of who is responsible for
scheduling each process (p_scheduler). When this pointer is NULL,
the process will be scheduled by the kernel. If such a process runs
out of quantum, the kernel will simply renew its quantum an requeue
it.
- When PM loads, it will take over scheduling of all running
processes, except system processes, using sys_schedctl().
Essentially, this only results in taking over init. As children
inherit a scheduler from their parent, user space programs forked by
init will inherit PM (for now) as their scheduler.
- Once a process has been assigned a scheduler, and runs out of
quantum, its RTS_NO_QUANTUM flag will be set and the process
dequeued. The kernel will send a message to the scheduler, on the
process' behalf, informing the scheduler that it has run out of
quantum. The scheduler can take what ever action it pleases, based
on its policy, and then reschedule the process using the
sys_schedule() system call.
- Balance queues does not work as before. While the old in-kernel
function used to renew the quantum of processes in the highest
priority run queue, the user-space implementation only acts on
processes that have been bumped down to a lower priority queue.
This approach reacts slower to changes than the old one, but saves
us sending a sys_schedule message for each process every time we
balance the queues. Currently, when processes are moved up a
priority queue, their quantum is also renewed, but this can be
fiddled with.
- do_nice has been removed from kernel. PM answers to get- and
setpriority calls, updates it's own nice variable as well as the
max_run_queue. This will be refactored once scheduling is moved to a
separate server. We will probably have PM update it's local nice
value and then send a message to whoever is scheduling the process.
- changes to fix an issue in do_fork() where processes could run out
of quantum but bypassing the code path that handles it correctly.
The future plan is to remove the policy from do_fork() and implement
it in userspace too.
2010-03-29 13:07:20 +02: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
|
|
|
/* Shorthands for sys_runctl() system call. */
|
2009-10-01 12:36:09 +02:00
|
|
|
#define sys_stop(proc_ep) sys_runctl(proc_ep, RC_STOP, 0)
|
|
|
|
#define sys_delay_stop(proc_ep) sys_runctl(proc_ep, RC_STOP, RC_DELAY)
|
|
|
|
#define sys_resume(proc_ep) sys_runctl(proc_ep, RC_RESUME, 0)
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_runctl(endpoint_t proc_ep, int action, int flags);
|
|
|
|
|
|
|
|
int sys_update(endpoint_t src_ep, endpoint_t dst_ep);
|
|
|
|
int sys_statectl(int request);
|
|
|
|
int sys_privctl(endpoint_t proc_ep, int req, void *p);
|
|
|
|
int sys_privquery_mem(endpoint_t proc_ep, phys_bytes physstart,
|
|
|
|
phys_bytes physlen);
|
|
|
|
int sys_setgrant(cp_grant_t *grants, int ngrants);
|
|
|
|
|
|
|
|
int sys_int86(struct reg86u *reg86p);
|
|
|
|
int sys_vm_setbuf(phys_bytes base, phys_bytes size, phys_bytes high);
|
|
|
|
int sys_vm_map(endpoint_t proc_ep, int do_map, phys_bytes base,
|
|
|
|
phys_bytes size, phys_bytes offset);
|
|
|
|
int sys_vmctl(endpoint_t who, int param, u32_t value);
|
2012-08-11 17:45:35 +02:00
|
|
|
int sys_vmctl_get_pdbr(endpoint_t who, u32_t *pdbr);
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_vmctl_get_memreq(endpoint_t *who, vir_bytes *mem, vir_bytes
|
|
|
|
*len, int *wrflag, endpoint_t *who_s, vir_bytes *mem_s, endpoint_t *);
|
|
|
|
int sys_vmctl_enable_paging(void * data);
|
|
|
|
|
|
|
|
int sys_readbios(phys_bytes address, void *buf, size_t size);
|
|
|
|
int sys_stime(time_t boottime);
|
|
|
|
int sys_sysctl(int ctl, char *arg1, int arg2);
|
|
|
|
int sys_sysctl_stacktrace(endpoint_t who);
|
|
|
|
int sys_vmctl_get_mapping(int index, phys_bytes *addr, phys_bytes *len,
|
|
|
|
int *flags);
|
|
|
|
int sys_vmctl_reply_mapping(int index, vir_bytes addr);
|
|
|
|
int sys_vmctl_set_addrspace(endpoint_t who, phys_bytes ptroot, void
|
|
|
|
*ptroot_v);
|
2010-05-12 10:31:05 +02:00
|
|
|
|
2006-07-10 14:13:29 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Shorthands for sys_sdevio() system call. */
|
2009-09-22 23:42:02 +02:00
|
|
|
#define sys_insb(port, proc_ep, buffer, count) \
|
|
|
|
sys_sdevio(DIO_INPUT_BYTE, port, proc_ep, buffer, count, 0)
|
|
|
|
#define sys_insw(port, proc_ep, buffer, count) \
|
|
|
|
sys_sdevio(DIO_INPUT_WORD, port, proc_ep, buffer, count, 0)
|
|
|
|
#define sys_outsb(port, proc_ep, buffer, count) \
|
|
|
|
sys_sdevio(DIO_OUTPUT_BYTE, port, proc_ep, buffer, count, 0)
|
|
|
|
#define sys_outsw(port, proc_ep, buffer, count) \
|
|
|
|
sys_sdevio(DIO_OUTPUT_WORD, port, proc_ep, buffer, count, 0)
|
2006-07-10 14:13:29 +02:00
|
|
|
#define sys_safe_insb(port, ept, grant, offset, count) \
|
|
|
|
sys_sdevio(DIO_SAFE_INPUT_BYTE, port, ept, (void*)grant, count, offset)
|
|
|
|
#define sys_safe_outsb(port, ept, grant, offset, count) \
|
|
|
|
sys_sdevio(DIO_SAFE_OUTPUT_BYTE, port, ept, (void*)grant, count, offset)
|
. introduced DEV_READ_S, DEV_WRITE_S, DEV_SCATTER_S, DEV_GATHER_S
and DEV_IOCTL_S as replacements for DEV_READ, DEV_WRITE, DEV_SCATTER,
DEV_GATHER and DEV_IOCTL. Instead of a direct address, the *_S commands
pass 'grant ids' to the drivers which are referenced through a new set
of copy calls (sys_safecopyfrom and sys_safecopyto). in order for this
copy to succeed, the grant must have previously been created in the
address space of the granter.
. bitmap manipulation functions moved to <minix/bitmap.h>
. HIGHPOS introduced as field containing high 32 bits of position in
device I/O message; TTY_FLAGS no longer used
. IO_GRANT field introduced for GRANTs, to replace ADDRESS
. REP_IO_GRANT field for un-SUSPEND messages introduced to indicate
grant for which I/O was done to disambiguate messages
. SYS_SAFECOPYFROM and SYS_SAFECOPYTO introduced as new calls
. SYS_PRIV_SET_GRANTS code introduced as a code to set the address and
size of the grant table in a process' own address space
. 'type' and 'direction' field of _ins* and _outs* I/O functions
are merged into one by ORing _DIO_INPUT/_DIO_OUTPUT and _DIO_BYTE/_DIO_WORD
etc. This allows for an additional parameter, _DIO_SAFE, which indicates
the address in another address space isn't actually an address, but
a grant id. Also needs an offset, for which fields had to be merged.
. SCP_* are field names for SYS_SAFECOPY* functions
. DIAGNOSTICS and GET_KMESS moved to their own range above DIAG_BASE,
added DIAGNOSTICS_S which is a grant-based variant of DIAGNOSTICS
. removed obsolete BINCOMPAT and SRCCOMPAT options
. added GRANT_SEG type for use in vircopy - allows copying to a grant
id (without offset)
. added _MINIX_IOCTL_* macros that decode information encoded by
_IO* macros in ioctl codes, used to check which grants are necessary
for an ioctl
. introduced the type endpoint_t for process endpoints, changed some
prototypes and struct field types to match
. renamed protected to prot for g++
2006-06-20 10:38:15 +02:00
|
|
|
#define sys_safe_insw(port, ept, grant, offset, count) \
|
|
|
|
sys_sdevio(DIO_SAFE_INPUT_WORD, port, ept, (void*)grant, count, offset)
|
|
|
|
#define sys_safe_outsw(port, ept, grant, offset, count) \
|
|
|
|
sys_sdevio(DIO_SAFE_OUTPUT_WORD, port, ept, (void*)grant, count, offset)
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_sdevio(int req, long port, endpoint_t proc_ep, void *buffer, int
|
|
|
|
count, vir_bytes offset);
|
|
|
|
void *alloc_contig(size_t len, int flags, phys_bytes *phys);
|
|
|
|
int free_contig(void *addr, size_t len);
|
2010-02-10 14:56:26 +01:00
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
#define AC_ALIGN4K 0x01
|
|
|
|
#define AC_LOWER16M 0x02
|
2009-02-12 13:26:08 +01:00
|
|
|
#define AC_ALIGN64K 0x04
|
2009-09-21 16:23:10 +02:00
|
|
|
#define AC_LOWER1M 0x08
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2009-08-15 23:37:26 +02:00
|
|
|
/* Clock functionality: get system times, (un)schedule an alarm call, or
|
|
|
|
* retrieve/set a process-virtual timer.
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_times(endpoint_t proc_ep, clock_t *user_time, clock_t *sys_time,
|
|
|
|
clock_t *uptime, time_t *boottime);
|
|
|
|
int sys_setalarm(clock_t exp_time, int abs_time);
|
|
|
|
int sys_vtimer(endpoint_t proc_nr, int which, clock_t *newval, clock_t
|
|
|
|
*oldval);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Shorthands for sys_irqctl() system call. */
|
2005-05-02 16:30:04 +02:00
|
|
|
#define sys_irqdisable(hook_id) \
|
|
|
|
sys_irqctl(IRQ_DISABLE, 0, 0, hook_id)
|
|
|
|
#define sys_irqenable(hook_id) \
|
|
|
|
sys_irqctl(IRQ_ENABLE, 0, 0, hook_id)
|
|
|
|
#define sys_irqsetpolicy(irq_vec, policy, hook_id) \
|
|
|
|
sys_irqctl(IRQ_SETPOLICY, irq_vec, policy, hook_id)
|
2009-09-06 16:24:44 +02:00
|
|
|
#define sys_irqrmpolicy(hook_id) \
|
|
|
|
sys_irqctl(IRQ_RMPOLICY, 0, 0, hook_id)
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_irqctl(int request, int irq_vec, int policy, int *irq_hook_id);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-04-29 17:36:43 +02:00
|
|
|
/* Shorthands for sys_vircopy() and sys_physcopy() system calls. */
|
2012-06-16 19:29:37 +02:00
|
|
|
#define sys_datacopy sys_vircopy
|
|
|
|
int sys_vircopy(endpoint_t src_proc, vir_bytes src_v,
|
|
|
|
endpoint_t dst_proc, vir_bytes dst_vir, phys_bytes bytes);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-04-29 17:36:43 +02:00
|
|
|
#define sys_abscopy(src_phys, dst_phys, bytes) \
|
2012-06-16 19:29:37 +02:00
|
|
|
sys_physcopy(NONE, src_phys, NONE, dst_phys, bytes)
|
|
|
|
int sys_physcopy(endpoint_t src_proc, vir_bytes src_vir,
|
|
|
|
endpoint_t dst_proc, vir_bytes dst_vir, phys_bytes bytes);
|
. introduced DEV_READ_S, DEV_WRITE_S, DEV_SCATTER_S, DEV_GATHER_S
and DEV_IOCTL_S as replacements for DEV_READ, DEV_WRITE, DEV_SCATTER,
DEV_GATHER and DEV_IOCTL. Instead of a direct address, the *_S commands
pass 'grant ids' to the drivers which are referenced through a new set
of copy calls (sys_safecopyfrom and sys_safecopyto). in order for this
copy to succeed, the grant must have previously been created in the
address space of the granter.
. bitmap manipulation functions moved to <minix/bitmap.h>
. HIGHPOS introduced as field containing high 32 bits of position in
device I/O message; TTY_FLAGS no longer used
. IO_GRANT field introduced for GRANTs, to replace ADDRESS
. REP_IO_GRANT field for un-SUSPEND messages introduced to indicate
grant for which I/O was done to disambiguate messages
. SYS_SAFECOPYFROM and SYS_SAFECOPYTO introduced as new calls
. SYS_PRIV_SET_GRANTS code introduced as a code to set the address and
size of the grant table in a process' own address space
. 'type' and 'direction' field of _ins* and _outs* I/O functions
are merged into one by ORing _DIO_INPUT/_DIO_OUTPUT and _DIO_BYTE/_DIO_WORD
etc. This allows for an additional parameter, _DIO_SAFE, which indicates
the address in another address space isn't actually an address, but
a grant id. Also needs an offset, for which fields had to be merged.
. SCP_* are field names for SYS_SAFECOPY* functions
. DIAGNOSTICS and GET_KMESS moved to their own range above DIAG_BASE,
added DIAGNOSTICS_S which is a grant-based variant of DIAGNOSTICS
. removed obsolete BINCOMPAT and SRCCOMPAT options
. added GRANT_SEG type for use in vircopy - allows copying to a grant
id (without offset)
. added _MINIX_IOCTL_* macros that decode information encoded by
_IO* macros in ioctl codes, used to check which grants are necessary
for an ioctl
. introduced the type endpoint_t for process endpoints, changed some
prototypes and struct field types to match
. renamed protected to prot for g++
2006-06-20 10:38:15 +02:00
|
|
|
|
|
|
|
|
2006-06-23 13:54:03 +02:00
|
|
|
/* Grant-based copy functions. */
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_safecopyfrom(endpoint_t source, cp_grant_id_t grant, vir_bytes
|
2012-06-16 03:46:15 +02:00
|
|
|
grant_offset, vir_bytes my_address, size_t bytes);
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_safecopyto(endpoint_t dest, cp_grant_id_t grant, vir_bytes
|
2012-06-16 03:46:15 +02:00
|
|
|
grant_offset, vir_bytes my_address, size_t bytes);
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_vsafecopy(struct vscp_vec *copyvec, int elements);
|
. introduced DEV_READ_S, DEV_WRITE_S, DEV_SCATTER_S, DEV_GATHER_S
and DEV_IOCTL_S as replacements for DEV_READ, DEV_WRITE, DEV_SCATTER,
DEV_GATHER and DEV_IOCTL. Instead of a direct address, the *_S commands
pass 'grant ids' to the drivers which are referenced through a new set
of copy calls (sys_safecopyfrom and sys_safecopyto). in order for this
copy to succeed, the grant must have previously been created in the
address space of the granter.
. bitmap manipulation functions moved to <minix/bitmap.h>
. HIGHPOS introduced as field containing high 32 bits of position in
device I/O message; TTY_FLAGS no longer used
. IO_GRANT field introduced for GRANTs, to replace ADDRESS
. REP_IO_GRANT field for un-SUSPEND messages introduced to indicate
grant for which I/O was done to disambiguate messages
. SYS_SAFECOPYFROM and SYS_SAFECOPYTO introduced as new calls
. SYS_PRIV_SET_GRANTS code introduced as a code to set the address and
size of the grant table in a process' own address space
. 'type' and 'direction' field of _ins* and _outs* I/O functions
are merged into one by ORing _DIO_INPUT/_DIO_OUTPUT and _DIO_BYTE/_DIO_WORD
etc. This allows for an additional parameter, _DIO_SAFE, which indicates
the address in another address space isn't actually an address, but
a grant id. Also needs an offset, for which fields had to be merged.
. SCP_* are field names for SYS_SAFECOPY* functions
. DIAGNOSTICS and GET_KMESS moved to their own range above DIAG_BASE,
added DIAGNOSTICS_S which is a grant-based variant of DIAGNOSTICS
. removed obsolete BINCOMPAT and SRCCOMPAT options
. added GRANT_SEG type for use in vircopy - allows copying to a grant
id (without offset)
. added _MINIX_IOCTL_* macros that decode information encoded by
_IO* macros in ioctl codes, used to check which grants are necessary
for an ioctl
. introduced the type endpoint_t for process endpoints, changed some
prototypes and struct field types to match
. renamed protected to prot for g++
2006-06-20 10:38:15 +02:00
|
|
|
|
2012-06-06 19:05:28 +02:00
|
|
|
int sys_memset(endpoint_t who, unsigned long pattern,
|
|
|
|
phys_bytes base, phys_bytes bytes);
|
2005-07-29 17:02:27 +02:00
|
|
|
|
2010-01-14 16:24:16 +01:00
|
|
|
/* Grant-based map functions. */
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_safemap(endpoint_t grantor, cp_grant_id_t grant, vir_bytes
|
2012-06-16 20:42:27 +02:00
|
|
|
grant_offset, vir_bytes my_address, size_t bytes, int writable);
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_saferevmap_gid(cp_grant_id_t grant);
|
|
|
|
int sys_saferevmap_addr(vir_bytes addr);
|
2012-06-16 20:42:27 +02:00
|
|
|
int sys_safeunmap(vir_bytes my_address);
|
2012-03-24 16:16:34 +01:00
|
|
|
|
|
|
|
int sys_vumap(endpoint_t endpt, struct vumap_vir *vvec,
|
2012-03-21 23:51:18 +01:00
|
|
|
int vcount, size_t offset, int access, struct vumap_phys *pvec,
|
2012-03-24 16:16:34 +01:00
|
|
|
int *pcount);
|
|
|
|
int sys_umap(endpoint_t proc_ep, int seg, vir_bytes vir_addr, vir_bytes
|
|
|
|
bytes, phys_bytes *phys_addr);
|
|
|
|
int sys_umap_data_fb(endpoint_t proc_ep, vir_bytes vir_addr, vir_bytes
|
|
|
|
bytes, phys_bytes *phys_addr);
|
|
|
|
int sys_umap_remote(endpoint_t proc_ep, endpoint_t grantee, int seg,
|
|
|
|
vir_bytes vir_addr, vir_bytes bytes, phys_bytes *phys_addr);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Shorthands for sys_getinfo() system call. */
|
2005-04-29 17:36:43 +02:00
|
|
|
#define sys_getkinfo(dst) sys_getinfo(GET_KINFO, dst, 0,0,0)
|
2005-11-14 16:58:07 +01:00
|
|
|
#define sys_getloadinfo(dst) sys_getinfo(GET_LOADINFO, dst, 0,0,0)
|
2005-04-29 17:36:43 +02:00
|
|
|
#define sys_getmachine(dst) sys_getinfo(GET_MACHINE, dst, 0,0,0)
|
2010-10-26 23:07:50 +02:00
|
|
|
#define sys_getcpuinfo(dst) sys_getinfo(GET_CPUINFO, dst, 0,0,0)
|
2005-04-21 16:53:53 +02:00
|
|
|
#define sys_getproctab(dst) sys_getinfo(GET_PROCTAB, dst, 0,0,0)
|
2005-07-14 17:14:44 +02:00
|
|
|
#define sys_getprivtab(dst) sys_getinfo(GET_PRIVTAB, dst, 0,0,0)
|
2005-04-21 16:53:53 +02:00
|
|
|
#define sys_getproc(dst,nr) sys_getinfo(GET_PROC, dst, 0,0, nr)
|
2005-06-03 15:55:06 +02:00
|
|
|
#define sys_getrandomness(dst) sys_getinfo(GET_RANDOMNESS, dst, 0,0,0)
|
2009-04-02 17:24:44 +02:00
|
|
|
#define sys_getrandom_bin(d,b) sys_getinfo(GET_RANDOMNESS_BIN, d, 0,0,b)
|
2005-04-21 16:53:53 +02:00
|
|
|
#define sys_getimage(dst) sys_getinfo(GET_IMAGE, dst, 0,0,0)
|
2005-05-02 16:30:04 +02:00
|
|
|
#define sys_getirqhooks(dst) sys_getinfo(GET_IRQHOOKS, dst, 0,0,0)
|
2006-01-12 15:33:29 +01:00
|
|
|
#define sys_getirqactids(dst) sys_getinfo(GET_IRQACTIDS, dst, 0,0,0)
|
2005-04-21 16:53:53 +02:00
|
|
|
#define sys_getmonparams(v,vl) sys_getinfo(GET_MONPARAMS, v,vl, 0,0)
|
|
|
|
#define sys_getschedinfo(v1,v2) sys_getinfo(GET_SCHEDINFO, v1,0, v2,0)
|
2009-12-11 01:08:19 +01:00
|
|
|
#define sys_getpriv(dst, nr) sys_getinfo(GET_PRIV, dst, 0,0, nr)
|
2009-12-02 12:52:26 +01:00
|
|
|
#define sys_getidletsc(dst) sys_getinfo(GET_IDLETSC, dst, 0,0,0)
|
2011-11-22 02:07:33 +01:00
|
|
|
#define sys_getregs(dst,nr) sys_getinfo(GET_REGS, dst, 0,0, nr)
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_getinfo(int request, void *val_ptr, int val_len, void *val_ptr2,
|
|
|
|
int val_len2);
|
|
|
|
int sys_whoami(endpoint_t *ep, char *name, int namelen, int
|
|
|
|
*priv_flags);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-04-29 17:36:43 +02:00
|
|
|
/* Signal control. */
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_kill(endpoint_t proc_ep, int sig);
|
|
|
|
int sys_sigsend(endpoint_t proc_ep, struct sigmsg *sig_ctxt);
|
|
|
|
int sys_sigreturn(endpoint_t proc_ep, struct sigmsg *sig_ctxt);
|
|
|
|
int sys_getksig(endpoint_t *proc_ep, sigset_t *k_sig_map);
|
|
|
|
int sys_endksig(endpoint_t proc_ep);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* NOTE: two different approaches were used to distinguish the device I/O
|
|
|
|
* types 'byte', 'word', 'long': the latter uses #define and results in a
|
|
|
|
* smaller implementation, but looses the static type checking.
|
|
|
|
*/
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_voutb(pvb_pair_t *pvb_pairs, int nr_ports);
|
|
|
|
int sys_voutw(pvw_pair_t *pvw_pairs, int nr_ports);
|
|
|
|
int sys_voutl(pvl_pair_t *pvl_pairs, int nr_ports);
|
|
|
|
int sys_vinb(pvb_pair_t *pvb_pairs, int nr_ports);
|
|
|
|
int sys_vinw(pvw_pair_t *pvw_pairs, int nr_ports);
|
|
|
|
int sys_vinl(pvl_pair_t *pvl_pairs, int nr_ports);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Shorthands for sys_out() system call. */
|
2012-03-05 00:11:41 +01:00
|
|
|
#define sys_outb(p,v) sys_out((p), (u32_t) (v), _DIO_BYTE)
|
|
|
|
#define sys_outw(p,v) sys_out((p), (u32_t) (v), _DIO_WORD)
|
|
|
|
#define sys_outl(p,v) sys_out((p), (u32_t) (v), _DIO_LONG)
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_out(int port, u32_t value, int type);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Shorthands for sys_in() system call. */
|
. introduced DEV_READ_S, DEV_WRITE_S, DEV_SCATTER_S, DEV_GATHER_S
and DEV_IOCTL_S as replacements for DEV_READ, DEV_WRITE, DEV_SCATTER,
DEV_GATHER and DEV_IOCTL. Instead of a direct address, the *_S commands
pass 'grant ids' to the drivers which are referenced through a new set
of copy calls (sys_safecopyfrom and sys_safecopyto). in order for this
copy to succeed, the grant must have previously been created in the
address space of the granter.
. bitmap manipulation functions moved to <minix/bitmap.h>
. HIGHPOS introduced as field containing high 32 bits of position in
device I/O message; TTY_FLAGS no longer used
. IO_GRANT field introduced for GRANTs, to replace ADDRESS
. REP_IO_GRANT field for un-SUSPEND messages introduced to indicate
grant for which I/O was done to disambiguate messages
. SYS_SAFECOPYFROM and SYS_SAFECOPYTO introduced as new calls
. SYS_PRIV_SET_GRANTS code introduced as a code to set the address and
size of the grant table in a process' own address space
. 'type' and 'direction' field of _ins* and _outs* I/O functions
are merged into one by ORing _DIO_INPUT/_DIO_OUTPUT and _DIO_BYTE/_DIO_WORD
etc. This allows for an additional parameter, _DIO_SAFE, which indicates
the address in another address space isn't actually an address, but
a grant id. Also needs an offset, for which fields had to be merged.
. SCP_* are field names for SYS_SAFECOPY* functions
. DIAGNOSTICS and GET_KMESS moved to their own range above DIAG_BASE,
added DIAGNOSTICS_S which is a grant-based variant of DIAGNOSTICS
. removed obsolete BINCOMPAT and SRCCOMPAT options
. added GRANT_SEG type for use in vircopy - allows copying to a grant
id (without offset)
. added _MINIX_IOCTL_* macros that decode information encoded by
_IO* macros in ioctl codes, used to check which grants are necessary
for an ioctl
. introduced the type endpoint_t for process endpoints, changed some
prototypes and struct field types to match
. renamed protected to prot for g++
2006-06-20 10:38:15 +02:00
|
|
|
#define sys_inb(p,v) sys_in((p), (v), _DIO_BYTE)
|
|
|
|
#define sys_inw(p,v) sys_in((p), (v), _DIO_WORD)
|
|
|
|
#define sys_inl(p,v) sys_in((p), (v), _DIO_LONG)
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_in(int port, u32_t *value, int type);
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-12-02 15:40:51 +01:00
|
|
|
/* pci.c */
|
2012-03-24 16:16:34 +01:00
|
|
|
void pci_init(void);
|
|
|
|
int pci_first_dev(int *devindp, u16_t *vidp, u16_t *didp);
|
|
|
|
int pci_next_dev(int *devindp, u16_t *vidp, u16_t *didp);
|
|
|
|
int pci_find_dev(u8_t bus, u8_t dev, u8_t func, int *devindp);
|
|
|
|
void pci_reserve(int devind);
|
|
|
|
int pci_reserve_ok(int devind);
|
|
|
|
void pci_ids(int devind, u16_t *vidp, u16_t *didp);
|
|
|
|
void pci_rescan_bus(u8_t busnr);
|
|
|
|
u8_t pci_attr_r8(int devind, int port);
|
|
|
|
u16_t pci_attr_r16(int devind, int port);
|
|
|
|
u32_t pci_attr_r32(int devind, int port);
|
|
|
|
void pci_attr_w8(int devind, int port, u8_t value);
|
|
|
|
void pci_attr_w16(int devind, int port, u16_t value);
|
|
|
|
void pci_attr_w32(int devind, int port, u32_t value);
|
|
|
|
char *pci_dev_name(u16_t vid, u16_t did);
|
|
|
|
char *pci_slot_name(int devind);
|
|
|
|
int pci_set_acl(struct rs_pci *rs_pci);
|
|
|
|
int pci_del_acl(endpoint_t proc_ep);
|
|
|
|
int pci_get_bar(int devind, int port, u32_t *base, u32_t *size, int
|
|
|
|
*ioflag);
|
2005-12-02 15:40:51 +01:00
|
|
|
|
2006-10-30 16:53:38 +01:00
|
|
|
/* Profiling. */
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_sprof(int action, int size, int freq, int type, endpoint_t
|
|
|
|
endpt, void *ctl_ptr, void *mem_ptr);
|
|
|
|
int sys_cprof(int action, int size, endpoint_t endpt, void *ctl_ptr,
|
|
|
|
void *mem_ptr);
|
|
|
|
int sys_profbuf(void *ctl_ptr, void *mem_ptr);
|
2006-10-30 16:53:38 +01:00
|
|
|
|
2010-03-12 16:58:41 +01:00
|
|
|
/* machine context */
|
2012-03-24 16:16:34 +01:00
|
|
|
int sys_getmcontext(endpoint_t proc, mcontext_t *mcp);
|
|
|
|
int sys_setmcontext(endpoint_t proc, mcontext_t *mcp);
|
2010-03-12 16:58:41 +01:00
|
|
|
|
2010-11-17 15:53:07 +01:00
|
|
|
/* input */
|
2012-03-24 16:16:34 +01:00
|
|
|
int tty_input_inject(int type, int code, int val);
|
2010-11-17 15:53:07 +01:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
#endif /* _SYSLIB_H */
|
|
|
|
|