⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 com.h

📁 一个简单的操作系统minix的核心代码
💻 H
字号:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				include/minix/com.h	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

03500	/* System calls. */
03501	#define SEND               1    /* function code for sending messages */
03502	#define RECEIVE            2    /* function code for receiving messages */
03503	#define BOTH               3    /* function code for SEND + RECEIVE */
03504	#define ANY   (NR_PROCS+100)    /* receive(ANY, buf) accepts from any source */
03505	
03506	/* Task numbers, function codes and reply codes. */
03507	
03508	/* The values of several task numbers depend on whether they or other tasks
03509	 * are enabled.  They are defined as (PREVIOUS_TASK - ENABLE_TASK) in general.
03510	 * ENABLE_TASK is either 0 or 1, so a task either gets a new number, or gets
03511	 * the same number as the previous task and is further unused.
03512	 * The TTY task must always have the most negative number so that it is
03513	 * initialized first.  Many of the TTY function codes are shared with other
03514	 * tasks.
03515	 */
03516	
03517	#define TTY             (DL_ETH - 1)
03518	                                /* terminal I/O class */
03519	#       define CANCEL       0   /* general req to force a task to cancel */
03520	#       define HARD_INT     2   /* fcn code for all hardware interrupts */
03521	#       define DEV_READ     3   /* fcn code for reading from tty */
03522	#       define DEV_WRITE    4   /* fcn code for writing to tty */
03523	#       define DEV_IOCTL    5   /* fcn code for ioctl */
03524	#       define DEV_OPEN     6   /* fcn code for opening tty */
03525	#       define DEV_CLOSE    7   /* fcn code for closing tty */
03526	#       define SCATTERED_IO 8   /* fcn code for multiple reads/writes */
03527	#       define TTY_SETPGRP  9   /* fcn code for setpgroup */
03528	#       define TTY_EXIT    10   /* a process group leader has exited */ 
03529	#       define OPTIONAL_IO 16   /* modifier to DEV_* codes within vector */
03530	#       define SUSPEND   -998   /* used in interrupts when tty has no data */
03531	
03532	#define DL_ETH          (CDROM - ENABLE_NETWORKING)
03533	                                /* networking task */
03534	
03535	/* Message type for data link layer reqests. */
03536	#       define DL_WRITE         3
03537	#       define DL_WRITEV        4
03538	#       define DL_READ          5
03539	#       define DL_READV         6
03540	#       define DL_INIT          7
03541	#       define DL_STOP          8
03542	#       define DL_GETSTAT       9
03543	
03544	/* Message type for data link layer replies. */
03545	#       define DL_INIT_REPLY    20
03546	#       define DL_TASK_REPLY    21
03547	
03548	#       define DL_PORT          m2_i1
03549	#       define DL_PROC          m2_i2
03550	#       define DL_COUNT         m2_i3
03551	#       define DL_MODE          m2_l1
03552	#       define DL_CLCK          m2_l2
03553	#       define DL_ADDR          m2_p1
03554	#       define DL_STAT          m2_l1
03555	
03556	/* Bits in 'DL_STAT' field of DL replies. */
03557	#       define DL_PACK_SEND     0x01
03558	#       define DL_PACK_RECV     0x02
03559	#       define DL_READ_IP       0x04
03560	
03561	/* Bits in 'DL_MODE' field of DL requests. */
03562	#       define DL_NOMODE        0x0
03563	#       define DL_PROMISC_REQ   0x2
03564	#       define DL_MULTI_REQ     0x4
03565	#       define DL_BROAD_REQ     0x8
03566	
03567	#       define NW_OPEN          DEV_OPEN
03568	#       define NW_CLOSE         DEV_CLOSE
03569	#       define NW_READ          DEV_READ
03570	#       define NW_WRITE         DEV_WRITE
03571	#       define NW_IOCTL         DEV_IOCTL
03572	#       define NW_CANCEL        CANCEL
03573	
03574	#define CDROM           (AUDIO - ENABLE_CDROM)
03575	                                /* cd-rom device task */
03576	
03577	#define AUDIO           (MIXER - ENABLE_AUDIO)
03578	#define MIXER           (SCSI - ENABLE_AUDIO)
03579	                                /* audio & mixer device tasks */
03580	
03581	#define SCSI            (WINCHESTER - ENABLE_SCSI)
03582	                                /* scsi device task */
03583	
03584	#define WINCHESTER      (SYN_ALRM_TASK - ENABLE_WINI)
03585	                                /* winchester (hard) disk class */
03586	
03587	#define SYN_ALRM_TASK     -8    /* task to send CLOCK_INT messages */
03588	
03589	#define IDLE              -7    /* task to run when there's nothing to run */
03590	
03591	#define PRINTER           -6    /* printer I/O class */
03592	
03593	#define FLOPPY            -5    /* floppy disk class */
03594	
03595	#define MEM               -4    /* /dev/ram, /dev/(k)mem and /dev/null class */
03596	#       define NULL_MAJOR  1    /* major device for /dev/null */
03597	#       define RAM_DEV     0    /* minor device for /dev/ram */
03598	#       define MEM_DEV     1    /* minor device for /dev/mem */
03599	#       define KMEM_DEV    2    /* minor device for /dev/kmem */
03600	#       define NULL_DEV    3    /* minor device for /dev/null */
03601	
03602	#define CLOCK             -3    /* clock class */
03603	#       define SET_ALARM   1    /* fcn code to CLOCK, set up alarm */
03604	#       define GET_TIME    3    /* fcn code to CLOCK, get real time */
03605	#       define SET_TIME    4    /* fcn code to CLOCK, set real time */
03606	#       define GET_UPTIME  5    /* fcn code to CLOCK, get uptime */
03607	#       define SET_SYNC_AL 6    /* fcn code to CLOCK, set up alarm which */
03608	                                /* times out with a send */
03609	#       define REAL_TIME   1    /* reply from CLOCK: here is real time */
03610	#       define CLOCK_INT   HARD_INT
03611	                                /* this code will only be sent by */
03612	                                /* SYN_ALRM_TASK to a task that requested a */
03613	                                /* synchronous alarm */
03614	
03615	#define SYSTASK           -2    /* internal functions */
03616	#       define SYS_XIT        1 /* fcn code for sys_xit(parent, proc) */
03617	#       define SYS_GETSP      2 /* fcn code for sys_sp(proc, &new_sp) */
03618	#       define SYS_OLDSIG     3 /* fcn code for sys_oldsig(proc, sig) */
03619	#       define SYS_FORK       4 /* fcn code for sys_fork(parent, child) */
03620	#       define SYS_NEWMAP     5 /* fcn code for sys_newmap(procno, map_ptr) */
03621	#       define SYS_COPY       6 /* fcn code for sys_copy(ptr) */
03622	#       define SYS_EXEC       7 /* fcn code for sys_exec(procno, new_sp) */
03623	#       define SYS_TIMES      8 /* fcn code for sys_times(procno, bufptr) */
03624	#       define SYS_ABORT      9 /* fcn code for sys_abort() */
03625	#       define SYS_FRESH     10 /* fcn code for sys_fresh()  (Atari only) */
03626	#       define SYS_KILL      11 /* fcn code for sys_kill(proc, sig) */
03627	#       define SYS_GBOOT     12 /* fcn code for sys_gboot(procno, bootptr) */
03628	#       define SYS_UMAP      13 /* fcn code for sys_umap(procno, etc) */
03629	#       define SYS_MEM       14 /* fcn code for sys_mem() */
03630	#       define SYS_TRACE     15 /* fcn code for sys_trace(req,pid,addr,data) */
03631	#       define SYS_VCOPY     16 /* fnc code for sys_vcopy(src_proc, dest_proc,
03632	                                   vcopy_s, vcopy_ptr) */
03633	#       define SYS_SENDSIG   17 /* fcn code for sys_sendsig(&sigmsg) */
03634	#       define SYS_SIGRETURN 18 /* fcn code for sys_sigreturn(&sigmsg) */
03635	#       define SYS_ENDSIG    19 /* fcn code for sys_endsig(procno) */
03636	#       define SYS_GETMAP    20 /* fcn code for sys_getmap(procno, map_ptr) */
03637	
03638	#define HARDWARE          -1    /* used as source on interrupt generated msgs*/
03639	
03640	/* Names of message fields for messages to CLOCK task. */
03641	#define DELTA_TICKS    m6_l1    /* alarm interval in clock ticks */
03642	#define FUNC_TO_CALL   m6_f1    /* pointer to function to call */
03643	#define NEW_TIME       m6_l1    /* value to set clock to (SET_TIME) */
03644	#define CLOCK_PROC_NR  m6_i1    /* which proc (or task) wants the alarm? */
03645	#define SECONDS_LEFT   m6_l1    /* how many seconds were remaining */
03646	
03647	/* Names of message fields used for messages to block and character tasks. */
03648	#define DEVICE         m2_i1    /* major-minor device */
03649	#define PROC_NR        m2_i2    /* which (proc) wants I/O? */
03650	#define COUNT          m2_i3    /* how many bytes to transfer */
03651	#define REQUEST        m2_i3    /* ioctl request code */
03652	#define POSITION       m2_l1    /* file offset */
03653	#define ADDRESS        m2_p1    /* core buffer address */
03654	
03655	/* Names of message fields for messages to TTY task. */
03656	#define TTY_LINE       DEVICE   /* message parameter: terminal line */
03657	#define TTY_REQUEST    COUNT    /* message parameter: ioctl request code */
03658	#define TTY_SPEK       POSITION /* message parameter: ioctl speed, erasing */
03659	#define TTY_FLAGS      m2_l2    /* message parameter: ioctl tty mode */
03660	#define TTY_PGRP       m2_i3    /* message parameter: process group */  
03661	
03662	/* Names of the message fields for QIC 02 status reply from tape driver */
03663	#define TAPE_STAT0      m2_l1
03664	#define TAPE_STAT1      m2_l2
03665	
03666	/* Names of messages fields used in reply messages from tasks. */
03667	#define REP_PROC_NR    m2_i1    /* # of proc on whose behalf I/O was done */
03668	#define REP_STATUS     m2_i2    /* bytes transferred or error number */
03669	
03670	/* Names of fields for copy message to SYSTASK. */
03671	#define SRC_SPACE      m5_c1    /* T or D space (stack is also D) */
03672	#define SRC_PROC_NR    m5_i1    /* process to copy from */
03673	#define SRC_BUFFER     m5_l1    /* virtual address where data come from */
03674	#define DST_SPACE      m5_c2    /* T or D space (stack is also D) */
03675	#define DST_PROC_NR    m5_i2    /* process to copy to */
03676	#define DST_BUFFER     m5_l2    /* virtual address where data go to */
03677	#define COPY_BYTES     m5_l3    /* number of bytes to copy */
03678	
03679	/* Field names for accounting, SYSTASK and miscellaneous. */
03680	#define USER_TIME      m4_l1    /* user time consumed by process */
03681	#define SYSTEM_TIME    m4_l2    /* system time consumed by process */
03682	#define CHILD_UTIME    m4_l3    /* user time consumed by process' children */
03683	#define CHILD_STIME    m4_l4    /* sys time consumed by process' children */
03684	#define BOOT_TICKS     m4_l5    /* number of clock ticks since boot time */
03685	
03686	#define PROC1          m1_i1    /* indicates a process */
03687	#define PROC2          m1_i2    /* indicates a process */
03688	#define PID            m1_i3    /* process id passed from MM to kernel */
03689	#define STACK_PTR      m1_p1    /* used for stack ptr in sys_exec, sys_getsp */
03690	#define PR             m6_i1    /* process number for sys_sig */
03691	#define SIGNUM         m6_i2    /* signal number for sys_sig */
03692	#define FUNC           m6_f1    /* function pointer for sys_sig */
03693	#define MEM_PTR        m1_p1    /* tells where memory map is for sys_newmap */
03694	#define NAME_PTR       m1_p2    /* tells where program name is for dmp */
03695	#define IP_PTR         m1_p3    /* initial value for ip after exec */
03696	#define SIG_PROC       m2_i1    /* process number for inform */
03697	#define SIG_MAP        m2_l1    /* used by kernel for passing signal bit map */
03698	#define SIG_MSG_PTR    m1_i1    /* pointer to info to build sig catch stack */
03699	#define SIG_CTXT_PTR   m1_p1    /* pointer to info to restore signal context */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -