Ce(L'empreinte de Lévi) n'est pas une gamme limitée de blog vie et Voyage
I Like It !
Friday, September 16, 2016
Minix/kernel/system.c
1 static char rcsid[] = "$Id";
23/* This task handles the interface between file system and kernel as well as4 * between memory manager and kernel. System services are obtained by sending5 * sys_task() a message specifying what is needed. To make life easier for6 * MM and FS, a library is provided with routines whose names are of the7 * form sys_xxx, e.g. sys_xit sends the SYS_XIT message to sys_task. The8 * message types and parameters are:9 *10 * SYS_FORK informs kernel that a process has forked11 * SYS_NEWMAP allows MM to set up a process memory map12 * SYS_GETMAP allows MM to get a process' memory map13 * SYS_EXEC sets program counter and stack pointer after EXEC14 * SYS_XIT informs kernel that a process has exited15 * SYS_GETSP caller wants to read out some process' stack pointer16 * SYS_TIMES caller wants to get accounting times for a process17 * SYS_ABORT MM or FS cannot go on; abort MINIX18 * SYS_FRESH start with a fresh process image during EXEC (68000 & SPARC only)19 * SYS_SENDSIG send a signal to a process (POSIX style)20 * SYS_SIGRETURN complete POSIX-style signalling21 * SYS_KILL cause a signal to be sent via MM22 * SYS_ENDSIG finish up after SYS_KILL-type signal23 * SYS_COPY request a block of data to be copied between processes24 * SYS_VCOPY request a series of data blocks to be copied between procs25 * SYS_GBOOT copies the boot parameters to a process26 * SYS_MEM returns the next free chunk of physical memory27 * SYS_UMAP compute the physical address for a given virtual address28 * SYS_TRACE request a trace operation29 *30 * Message types and parameters:31 *32 * m_type PROC1 PROC2 PID MEM_PTR33 * ------------------------------------------------------34 * | SYS_FORK | parent | child | pid | |35 * |------------+---------+---------+---------+---------|36 * | SYS_NEWMAP | proc nr | | | map ptr |37 * |------------+---------+---------+---------+---------|38 * | SYS_EXEC | proc nr | traced | new sp | |39 * |------------+---------+---------+---------+---------|40 * | SYS_XIT | parent | exitee | | |41 * |------------+---------+---------+---------+---------|42 * | SYS_GETSP | proc nr | | | |43 * |------------+---------+---------+---------+---------|44 * | SYS_TIMES | proc nr | | buf ptr | |45 * |------------+---------+---------+---------+---------|46 * | SYS_ABORT | | | | |47 * |------------+---------+---------+---------+---------|48 * | SYS_FRESH | proc nr | data_cl | | |49 * |------------+---------+---------+---------+---------|50 * | SYS_GBOOT | proc nr | | | bootptr |51 * |------------+---------+---------+---------+---------|52 * | SYS_GETMAP | proc nr | | | map ptr |53 * ------------------------------------------------------54 *55 * m_type m1_i1 m1_i2 m1_i3 m1_p156 * ----------------+---------+---------+---------+--------------57 * | SYS_VCOPY | src p | dst p | vec siz | vc addr |58 * |---------------+---------+---------+---------+-------------|59 * | SYS_SENDSIG | proc nr | | | smp |60 * |---------------+---------+---------+---------+-------------|61 * | SYS_SIGRETURN | proc nr | | | scp |62 * |---------------+---------+---------+---------+-------------|63 * | SYS_ENDSIG | proc nr | | | |64 * -------------------------------------------------------------65 *66 * m_type m2_i1 m2_i2 m2_l1 m2_l267 * ------------------------------------------------------68 * | SYS_TRACE | proc_nr | request | addr | data |69 * ------------------------------------------------------70 *71 *72 * m_type m6_i1 m6_i2 m6_i3 m6_f173 * ------------------------------------------------------74 * | SYS_KILL | proc_nr | sig | | |75 * ------------------------------------------------------76 *77 *78 * m_type m5_c1 m5_i1 m5_l1 m5_c2 m5_i2 m5_l2 m5_l379 * --------------------------------------------------------------------------80 * | SYS_COPY |src seg|src proc|src vir|dst seg|dst proc|dst vir| byte ct |81 * --------------------------------------------------------------------------82 * | SYS_UMAP | seg |proc nr |vir adr| | | | byte ct |83 * --------------------------------------------------------------------------84 *85 *86 * m_type m1_i1 m1_i2 m1_i387 * |------------+----------+----------+----------88 * | SYS_MEM | mem base | mem size | tot mem |89 * ----------------------------------------------90 *91 * In addition to the main sys_task() entry point, there are 5 other minor92 * entry points:93 * cause_sig: take action to cause a signal to occur, sooner or later94 * inform: tell MM about pending signals95 * numap: umap D segment starting from process number instead of pointer96 * umap: compute the physical address for a given virtual address97 * alloc_segments: allocate segments for 8088 or higher processor98 */99100 #include "kernel.h"
101 #include 102 #include 103 #include 104 #include 105 #include 106 #include 107 #include 108 #include "proc.h"
109 #if (CHIP == INTEL)
110 #include "protect.h"
111 #endif
112 #if (MACHINE == SUN)
113 #include "logging.h"
114 #endif
115116/* PSW masks. */117 #define IF_MASK 0x00000200
118 #define IOPL_MASK 0x003000
119120PRIVATEmessagem;
121 #if (MACHINE != SUN)
122PRIVATE char sig_stuff[SIG_PUSH_BYTES]; /* used to send signals to processes */123 #endif
124125FORWARD_PROTOTYPE( int do_abort, (message *m_ptr) );
126FORWARD_PROTOTYPE( int do_copy, (message *m_ptr) );
127FORWARD_PROTOTYPE( int do_exec, (message *m_ptr) );
128FORWARD_PROTOTYPE( int do_fork, (message *m_ptr) );
129FORWARD_PROTOTYPE( int do_gboot, (message *m_ptr) );
130FORWARD_PROTOTYPE( int do_getsp, (message *m_ptr) );
131FORWARD_PROTOTYPE( int do_kill, (message *m_ptr) );
132FORWARD_PROTOTYPE( int do_mem, (message *m_ptr) );
133FORWARD_PROTOTYPE( int do_newmap, (message *m_ptr) );
134FORWARD_PROTOTYPE( int do_sendsig, (message *m_ptr) );
135FORWARD_PROTOTYPE( int do_sigreturn, (message *m_ptr) );
136FORWARD_PROTOTYPE( int do_endsig, (message *m_ptr) );
137FORWARD_PROTOTYPE( int do_times, (message *m_ptr) );
138FORWARD_PROTOTYPE( int do_trace, (message *m_ptr) );
139FORWARD_PROTOTYPE( int do_umap, (message *m_ptr) );
140FORWARD_PROTOTYPE( int do_xit, (message *m_ptr) );
141FORWARD_PROTOTYPE( int do_vcopy, (message *m_ptr) );
142FORWARD_PROTOTYPE( int do_getmap, (message *m_ptr) );
143144 #if (SHADOWING == 1)
145FORWARD_PROTOTYPE( int do_fresh, (message *m_ptr) );
146 #endif
147148