#define DEV_SELECT (DEV_RQ_BASE + 12) /* request select() attention */
#define DEV_STATUS (DEV_RQ_BASE + 13) /* request driver status */
+#define DEV_READ_S (DEV_RQ_BASE + 20) /* (safecopy) read from minor */
+#define DEV_WRITE_S (DEV_RQ_BASE + 21) /* (safecopy) write to minor */
+#define DEV_SCATTER_S (DEV_RQ_BASE + 22) /* (safecopy) write from a vector */
+#define DEV_GATHER_S (DEV_RQ_BASE + 23) /* (safecopy) read into a vector */
+#define DEV_IOCTL_S (DEV_RQ_BASE + 24) /* (safecopy) I/O control code */
+
#define DEV_REPLY (DEV_RS_BASE + 0) /* general task reply */
#define DEV_CLONED (DEV_RS_BASE + 1) /* return cloned minor */
#define DEV_REVIVE (DEV_RS_BASE + 2) /* driver revives process */
#define DEVICE m2_i1 /* major-minor device */
#define IO_ENDPT m2_i2 /* which (proc/endpoint) wants I/O? */
#define COUNT m2_i3 /* how many bytes to transfer */
-#define REQUEST m2_i3 /* ioctl request code */
-#define POSITION m2_l1 /* file offset */
+#define REQUEST m2_i3 /* ioctl request code */
+#define POSITION m2_l1 /* file offset (low 4 bytes) */
+#define HIGHPOS m2_l2 /* file offset (high 4 bytes) */
#define ADDRESS m2_p1 /* core buffer address */
+#define IO_GRANT m2_p1 /* grant id (for DEV_*_S variants) */
/* Field names for DEV_SELECT messages to device drivers. */
#define DEV_MINOR m2_i1 /* minor device */
/* Field names used in reply messages from tasks. */
#define REP_ENDPT m2_i1 /* # of proc on whose behalf I/O was done */
#define REP_STATUS m2_i2 /* bytes transferred or error number */
+#define REP_IO_GRANT m2_i3 /* DEV_REVIVE: grant by which I/O was done */
# define SUSPEND -998 /* status to suspend caller, reply later */
/* Field names for messages to TTY driver. */
#define TTY_LINE DEVICE /* message parameter: terminal line */
#define TTY_REQUEST COUNT /* message parameter: ioctl request code */
#define TTY_SPEK POSITION/* message parameter: ioctl speed, erasing */
-#define TTY_FLAGS m2_l2 /* message parameter: ioctl tty mode */
#define TTY_PGRP m2_i3 /* message parameter: process group */
/* Field names for the QIC 02 status reply from tape driver */
# define SYS_IOPENABLE (KERNEL_CALL + 28) /* sys_enable_iop() */
# define SYS_VM_SETBUF (KERNEL_CALL + 29) /* sys_vm_setbuf() */
# define SYS_VM_MAP (KERNEL_CALL + 30) /* sys_vm_map() */
+# define SYS_SAFECOPYFROM (KERNEL_CALL + 31) /* sys_safecopyfrom() */
+# define SYS_SAFECOPYTO (KERNEL_CALL + 32) /* sys_safecopyto() */
+
+#define NR_SYS_CALLS 33 /* number of system calls */
-#define NR_SYS_CALLS 31 /* number of system calls */
+/* Pseudo call for use in kernel/table.c. */
+#define SYS_ALL_CALLS (NR_SYS_CALLS)
/* Subfunctions for SYS_PRIVCTL */
#define SYS_PRIV_INIT 1 /* Initialize a privilege structure */
#define SYS_PRIV_ADD_MEM 3 /* Add memory range (struct mem_range)
*/
#define SYS_PRIV_ADD_IRQ 4 /* Add IRQ */
+#define SYS_PRIV_SET_GRANTS 5 /* Set grant table */
/* Field names for SYS_MEMSET, SYS_SEGCTL. */
#define MEM_PTR m2_p1 /* base */
/* Field names for SYS_DEVIO, SYS_VDEVIO, SYS_SDEVIO. */
#define DIO_REQUEST m2_i3 /* device in or output */
-# define DIO_INPUT 0 /* input */
-# define DIO_OUTPUT 1 /* output */
-#define DIO_TYPE m2_i1 /* flag indicating byte, word, or long */
-# define DIO_BYTE 'b' /* byte type values */
-# define DIO_WORD 'w' /* word type values */
-# define DIO_LONG 'l' /* long type values */
+# define _DIO_INPUT 0x001
+# define _DIO_OUTPUT 0x002
+# define _DIO_DIRMASK 0x00f
+# define _DIO_BYTE 0x010
+# define _DIO_WORD 0x020
+# define _DIO_LONG 0x030
+# define _DIO_TYPEMASK 0x0f0
+# define _DIO_SAFE 0x100
+# define _DIO_SAFEMASK 0xf00
+# define DIO_INPUT_BYTE (_DIO_INPUT|_DIO_BYTE)
+# define DIO_INPUT_WORD (_DIO_INPUT|_DIO_WORD)
+# define DIO_OUTPUT_BYTE (_DIO_OUTPUT|_DIO_BYTE)
+# define DIO_OUTPUT_WORD (_DIO_OUTPUT|_DIO_WORD)
+# define DIO_SAFE_INPUT_BYTE (_DIO_INPUT|_DIO_BYTE|_DIO_SAFE)
+# define DIO_SAFE_INPUT_WORD (_DIO_INPUT|_DIO_WORD|_DIO_SAFE)
+# define DIO_SAFE_OUTPUT_BYTE (_DIO_OUTPUT|_DIO_BYTE|_DIO_SAFE)
+# define DIO_SAFE_OUTPUT_WORD (_DIO_OUTPUT|_DIO_WORD|_DIO_SAFE)
#define DIO_PORT m2_l1 /* single port address */
#define DIO_VALUE m2_l2 /* single I/O value */
#define DIO_VEC_ADDR m2_p1 /* address of buffer or (p,v)-pairs */
#define DIO_VEC_SIZE m2_l2 /* number of elements in vector */
#define DIO_VEC_ENDPT m2_i2 /* number of process where vector is */
+#define DIO_OFFSET m2_i1 /* offset from grant */
/* Field names for SYS_SIGNARLM, SYS_FLAGARLM, SYS_SYNCALRM. */
#define ALRM_EXP_TIME m2_l1 /* expire time for the alarm call */
/* Field names for SYS_INT86 */
#define INT86_REG86 m1_p1 /* pointer to registers */
+/* Field names for SYS_SAFECOPY */
+#define SCP_FROM_TO m2_i1 /* from/to whom? */
+#define SCP_INFO m2_i2 /* byte: DDDDSSSS Dest and Src seg */
+#define SCP_GID m2_i3 /* grant id */
+#define SCP_OFFSET m2_l1 /* offset within grant */
+#define SCP_ADDRESS m2_p1 /* my own address */
+#define SCP_BYTES m2_l2 /* bytes from offset */
+
+/* For the SCP_INFO field: encoding and decoding. */
+#define SCP_MAKEINFO(seg) ((seg) & 0xffff)
+#define SCP_INFO2SEG(info) ((info) & 0xffff)
+
/* Field names for SELECT (FS). */
#define SEL_NFDS m8_i1
#define SEL_READFDS m8_p1
# define FKEY_EVENTS 12 /* request open key presses */
# define FKEY_FKEYS m2_l1 /* F1-F12 keys pressed */
# define FKEY_SFKEYS m2_l2 /* Shift-F1-F12 keys pressed */
-#define DIAGNOSTICS 100 /* output a string without FS in between */
-# define DIAG_PRINT_BUF m1_p1
+#define DIAG_BASE 0xa00
+#define DIAGNOSTICS (DIAG_BASE+1) /* output a string without FS in between */
+#define DIAGNOSTICS_S (DIAG_BASE+2) /* grant-based version of DIAGNOSTICS */
+# define DIAG_PRINT_BUF_G m1_p1
# define DIAG_BUF_COUNT m1_i1
-# define DIAG_ENDPT m1_i2
-#define GET_KMESS 101 /* get kmess from TTY */
+#define GET_KMESS (DIAG_BASE+3) /* get kmess from TTY */
# define GETKM_PTR m1_p1
#define PM_BASE 0x900
#include <minix/devio.h>
#endif
+#include <minix/safecopies.h>
+
/* Forward declaration */
struct reg86u;
_PROTOTYPE( int _taskcall, (int who, int syscallnr, message *msgptr));
_PROTOTYPE( int sys_abort, (int how, ...));
-_PROTOTYPE( int sys_enable_iop, (int proc));
-_PROTOTYPE( int sys_exec, (int proc, char *ptr,
+_PROTOTYPE( int sys_enable_iop, (endpoint_t proc));
+_PROTOTYPE( int sys_exec, (endpoint_t proc, char *ptr,
char *aout, vir_bytes initpc));
_PROTOTYPE( int sys_fork, (int parent, int child, int *, struct mem_map *ptr));
-_PROTOTYPE( int sys_newmap, (int proc, struct mem_map *ptr));
-_PROTOTYPE( int sys_exit, (int proc));
-_PROTOTYPE( int sys_trace, (int req, int proc, long addr, long *data_p));
+_PROTOTYPE( int sys_newmap, (endpoint_t proc, struct mem_map *ptr));
+_PROTOTYPE( int sys_exit, (endpoint_t proc));
+_PROTOTYPE( int sys_trace, (int req, endpoint_t proc, long addr, long *data_p));
-_PROTOTYPE( int sys_privctl, (int proc, int req, int i, void *p));
-_PROTOTYPE( int sys_nice, (int proc, int priority));
+_PROTOTYPE( int sys_privctl, (endpoint_t proc, int req, int i, void *p));
+_PROTOTYPE( int sys_nice, (endpoint_t proc, int priority));
_PROTOTYPE( int sys_int86, (struct reg86u *reg86p));
_PROTOTYPE( int sys_vm_setbuf, (phys_bytes base, phys_bytes size,
phys_bytes high));
-_PROTOTYPE( int sys_vm_map, (int proc_nr, int do_map,
+_PROTOTYPE( int sys_vm_map, (endpoint_t proc_nr, int do_map,
phys_bytes base, phys_bytes size, phys_bytes offset));
/* Shorthands for sys_sdevio() system call. */
#define sys_insb(port, proc_nr, buffer, count) \
- sys_sdevio(DIO_INPUT, port, DIO_BYTE, proc_nr, buffer, count)
+ sys_sdevio(DIO_INPUT_BYTE, port, proc_nr, buffer, count, 0)
#define sys_insw(port, proc_nr, buffer, count) \
- sys_sdevio(DIO_INPUT, port, DIO_WORD, proc_nr, buffer, count)
+ sys_sdevio(DIO_INPUT_WORD, port, proc_nr, buffer, count, 0)
#define sys_outsb(port, proc_nr, buffer, count) \
- sys_sdevio(DIO_OUTPUT, port, DIO_BYTE, proc_nr, buffer, count)
+ sys_sdevio(DIO_OUTPUT_BYTE, port, proc_nr, buffer, count, 0)
#define sys_outsw(port, proc_nr, buffer, count) \
- sys_sdevio(DIO_OUTPUT, port, DIO_WORD, proc_nr, buffer, count)
-_PROTOTYPE( int sys_sdevio, (int req, long port, int type, int proc_nr,
- void *buffer, int count));
+ sys_sdevio(DIO_OUTPUT_WORD, port, proc_nr, buffer, count, 0)
+#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)
+_PROTOTYPE( int sys_sdevio, (int req, long port, endpoint_t proc_nr,
+ void *buffer, int count, vir_bytes offset));
/* Clock functionality: get system times or (un)schedule an alarm call. */
-_PROTOTYPE( int sys_times, (int proc_nr, clock_t *ptr));
+_PROTOTYPE( int sys_times, (endpoint_t proc_nr, clock_t *ptr));
_PROTOTYPE(int sys_setalarm, (clock_t exp_time, int abs_time));
/* Shorthands for sys_irqctl() system call. */
sys_vircopy(src_proc, T, src_vir, dst_proc, T, dst_vir, bytes)
#define sys_stackcopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \
sys_vircopy(src_proc, S, src_vir, dst_proc, S, dst_vir, bytes)
-_PROTOTYPE(int sys_vircopy, (int src_proc, int src_seg, vir_bytes src_vir,
- int dst_proc, int dst_seg, vir_bytes dst_vir, phys_bytes bytes));
+_PROTOTYPE(int sys_vircopy, (endpoint_t src_proc, int src_s, vir_bytes src_v,
+ endpoint_t dst_proc, int dst_seg, vir_bytes dst_vir, phys_bytes bytes));
#define sys_abscopy(src_phys, dst_phys, bytes) \
sys_physcopy(NONE, PHYS_SEG, src_phys, NONE, PHYS_SEG, dst_phys, bytes)
-_PROTOTYPE(int sys_physcopy, (int src_proc, int src_seg, vir_bytes src_vir,
- int dst_proc, int dst_seg, vir_bytes dst_vir, phys_bytes bytes));
+_PROTOTYPE(int sys_physcopy, (endpoint_t src_proc, int src_seg, vir_bytes src_vir,
+ endpoint_t dst_proc, int dst_seg, vir_bytes dst_vir, phys_bytes bytes));
+
+
+_PROTOTYPE(int sys_safecopyfrom, (endpoint_t, cp_grant_id_t,
+ vir_bytes, vir_bytes, size_t, int));
+_PROTOTYPE(int sys_safecopyto, (endpoint_t, cp_grant_id_t,
+ vir_bytes, vir_bytes, size_t, int));
+
_PROTOTYPE(int sys_memset, (unsigned long pattern,
phys_bytes base, phys_bytes bytes));
+
/* Vectored virtual / physical copy calls. */
#if DEAD_CODE /* library part not yet implemented */
_PROTOTYPE(int sys_virvcopy, (phys_cp_req *vec_ptr,int vec_size,int *nr_ok));
_PROTOTYPE(int sys_physvcopy, (phys_cp_req *vec_ptr,int vec_size,int *nr_ok));
#endif
-_PROTOTYPE(int sys_umap, (int proc_nr, int seg, vir_bytes vir_addr,
+_PROTOTYPE(int sys_umap, (endpoint_t proc_nr, int seg, vir_bytes vir_addr,
vir_bytes bytes, phys_bytes *phys_addr));
_PROTOTYPE(int sys_segctl, (int *index, u16_t *seg, vir_bytes *off,
phys_bytes phys, vir_bytes size));
#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)
#define sys_getlocktimings(dst) sys_getinfo(GET_LOCKTIMING, dst, 0,0,0)
-#define sys_getbiosbuffer(virp, sizep) sys_getinfo(GET_BIOSBUFFER, virp, \
- sizeof(*virp), sizep, sizeof(*sizep))
+#define sys_getbiosbuffer(virp, sizep) \
+ sys_getinfo(GET_BIOSBUFFER, virp, sizeof(*virp), sizep, sizeof(*sizep))
_PROTOTYPE(int sys_getinfo, (int request, void *val_ptr, int val_len,
void *val_ptr2, int val_len2) );
/* Signal control. */
-_PROTOTYPE(int sys_kill, (int proc, int sig) );
-_PROTOTYPE(int sys_sigsend, (int proc_nr, struct sigmsg *sig_ctxt) );
-_PROTOTYPE(int sys_sigreturn, (int proc_nr, struct sigmsg *sig_ctxt) );
-_PROTOTYPE(int sys_getksig, (int *k_proc_nr, sigset_t *k_sig_map) );
-_PROTOTYPE(int sys_endksig, (int proc_nr) );
+_PROTOTYPE(int sys_kill, (endpoint_t proc, int sig) );
+_PROTOTYPE(int sys_sigsend, (endpoint_t proc_nr, struct sigmsg *sig_ctxt) );
+_PROTOTYPE(int sys_sigreturn, (endpoint_t proc_nr, struct sigmsg *sig_ctxt) );
+_PROTOTYPE(int sys_getksig, (endpoint_t *k_proc_nr, sigset_t *k_sig_map) );
+_PROTOTYPE(int sys_endksig, (endpoint_t proc_nr) );
/* NOTE: two different approaches were used to distinguish the device I/O
* types 'byte', 'word', 'long': the latter uses #define and results in a
_PROTOTYPE(int sys_vinl, (pvl_pair_t *pvl_pairs, int nr_ports) );
/* Shorthands for sys_out() system call. */
-#define sys_outb(p,v) sys_out((p), (unsigned long) (v), DIO_BYTE)
-#define sys_outw(p,v) sys_out((p), (unsigned long) (v), DIO_WORD)
-#define sys_outl(p,v) sys_out((p), (unsigned long) (v), DIO_LONG)
+#define sys_outb(p,v) sys_out((p), (unsigned long) (v), _DIO_BYTE)
+#define sys_outw(p,v) sys_out((p), (unsigned long) (v), _DIO_WORD)
+#define sys_outl(p,v) sys_out((p), (unsigned long) (v), _DIO_LONG)
_PROTOTYPE(int sys_out, (int port, unsigned long value, int type) );
/* Shorthands for sys_in() system call. */
-#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)
+#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)
_PROTOTYPE(int sys_in, (int port, unsigned long *value, int type) );
/* pci.c */