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

📄 table.c

📁 一个简单的操作系统minix的核心代码
💻 C
字号:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				src/fs/table.c	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

20800	/* This file contains the table used to map system call numbers onto the
20801	 * routines that perform them.
20802	 */
20803	
20804	#define _TABLE
20805	
20806	#include "fs.h"
20807	#include <minix/callnr.h>
20808	#include <minix/com.h>
20809	#include "buf.h"
20810	#include "dev.h"
20811	#include "file.h"
20812	#include "fproc.h"
20813	#include "inode.h"
20814	#include "lock.h"
20815	#include "super.h"
20816	
20817	PUBLIC _PROTOTYPE (int (*call_vector[NCALLS]), (void) ) = {
20818	        no_sys,         /*  0 = unused  */
20819	        do_exit,        /*  1 = exit    */
20820	        do_fork,        /*  2 = fork    */
20821	        do_read,        /*  3 = read    */
20822	        do_write,       /*  4 = write   */
20823	        do_open,        /*  5 = open    */
20824	        do_close,       /*  6 = close   */
20825	        no_sys,         /*  7 = wait    */
20826	        do_creat,       /*  8 = creat   */
20827	        do_link,        /*  9 = link    */
20828	        do_unlink,      /* 10 = unlink  */
20829	        no_sys,         /* 11 = waitpid */
20830	        do_chdir,       /* 12 = chdir   */
20831	        do_time,        /* 13 = time    */
20832	        do_mknod,       /* 14 = mknod   */
20833	        do_chmod,       /* 15 = chmod   */
20834	        do_chown,       /* 16 = chown   */
20835	        no_sys,         /* 17 = break   */
20836	        do_stat,        /* 18 = stat    */
20837	        do_lseek,       /* 19 = lseek   */
20838	        no_sys,         /* 20 = getpid  */
20839	        do_mount,       /* 21 = mount   */
20840	        do_umount,      /* 22 = umount  */
20841	        do_set,         /* 23 = setuid  */
20842	        no_sys,         /* 24 = getuid  */
20843	        do_stime,       /* 25 = stime   */
20844	        no_sys,         /* 26 = ptrace  */
20845	        no_sys,         /* 27 = alarm   */
20846	        do_fstat,       /* 28 = fstat   */
20847	        no_sys,         /* 29 = pause   */
20848	        do_utime,       /* 30 = utime   */
20849	        no_sys,         /* 31 = (stty)  */
20850	        no_sys,         /* 32 = (gtty)  */
20851	        do_access,      /* 33 = access  */
20852	        no_sys,         /* 34 = (nice)  */
20853	        no_sys,         /* 35 = (ftime) */
20854	        do_sync,        /* 36 = sync    */
20855	        no_sys,         /* 37 = kill    */
20856	        do_rename,      /* 38 = rename  */
20857	        do_mkdir,       /* 39 = mkdir   */
20858	        do_unlink,      /* 40 = rmdir   */
20859	        do_dup,         /* 41 = dup     */
20860	        do_pipe,        /* 42 = pipe    */
20861	        do_tims,        /* 43 = times   */
20862	        no_sys,         /* 44 = (prof)  */
20863	        no_sys,         /* 45 = unused  */
20864	        do_set,         /* 46 = setgid  */
20865	        no_sys,         /* 47 = getgid  */
20866	        no_sys,         /* 48 = (signal)*/
20867	        no_sys,         /* 49 = unused  */
20868	        no_sys,         /* 50 = unused  */
20869	        no_sys,         /* 51 = (acct)  */
20870	        no_sys,         /* 52 = (phys)  */
20871	        no_sys,         /* 53 = (lock)  */
20872	        do_ioctl,       /* 54 = ioctl   */
20873	        do_fcntl,       /* 55 = fcntl   */
20874	        no_sys,         /* 56 = (mpx)   */
20875	        no_sys,         /* 57 = unused  */
20876	        no_sys,         /* 58 = unused  */
20877	        do_exec,        /* 59 = execve  */
20878	        do_umask,       /* 60 = umask   */
20879	        do_chroot,      /* 61 = chroot  */
20880	        do_setsid,      /* 62 = setsid  */
20881	        no_sys,         /* 63 = getpgrp */
20882	
20883	        no_sys,         /* 64 = KSIG: signals originating in the kernel */
20884	        do_unpause,     /* 65 = UNPAUSE */
20885	        no_sys,         /* 66 = unused  */
20886	        do_revive,      /* 67 = REVIVE  */
20887	        no_sys,         /* 68 = TASK_REPLY      */
20888	        no_sys,         /* 69 = unused */
20889	        no_sys,         /* 70 = unused */
20890	        no_sys,         /* 71 = SIGACTION */
20891	        no_sys,         /* 72 = SIGSUSPEND */
20892	        no_sys,         /* 73 = SIGPENDING */
20893	        no_sys,         /* 74 = SIGPROCMASK */
20894	        no_sys,         /* 75 = SIGRETURN */
20895	        no_sys,         /* 76 = REBOOT */
20896	};
20897	
20898	
20899	/* Some devices may or may not be there in the next table. */
20900	#define DT(enable, open, rw, close, task) \
20901	        { (enable ? (open) : no_dev), (enable ? (rw) : no_dev), \
20902	          (enable ? (close) : no_dev), (enable ? (task) : 0) },
20903	
20904	/* The order of the entries here determines the mapping between major device
20905	 * numbers and tasks.  The first entry (major device 0) is not used.  The
20906	 * next entry is major device 1, etc.  Character and block devices can be
20907	 * intermixed at random.  If this ordering is changed, the devices in
20908	 * <include/minix/boot.h> must be changed to correspond to the new values.
20909	 * Note that the major device numbers used in /dev are NOT the same as the 
20910	 * task numbers used inside the kernel (as defined in <include/minix/com.h>).
20911	 * Also note that if /dev/mem is changed from 1, NULL_MAJOR must be changed
20912	 * in <include/minix/com.h>.
20913	 */
20914	PUBLIC struct dmap dmap[] = {
20915	/*  ?   Open       Read/Write   Close       Task #      Device  File
20916	    -   ----       ----------   -----       -------     ------  ----       */
20917	  DT(1, no_dev,    no_dev,      no_dev,     0)           /* 0 = not used   */
20918	  DT(1, dev_opcl,  call_task,   dev_opcl,   MEM)         /* 1 = /dev/mem   */
20919	  DT(1, dev_opcl,  call_task,   dev_opcl,   FLOPPY)      /* 2 = /dev/fd0   */
20920	  DT(ENABLE_WINI,
20921	        dev_opcl,  call_task,   dev_opcl,   WINCHESTER)  /* 3 = /dev/hd0   */
20922	  DT(1, tty_open,  call_task,   dev_opcl,   TTY)         /* 4 = /dev/tty00 */
20923	  DT(1, ctty_open, call_ctty,   ctty_close, TTY)         /* 5 = /dev/tty   */
20924	  DT(1, dev_opcl,  call_task,   dev_opcl,    PRINTER)     /* 6 = /dev/lp    */
20925	
20926	#if (MACHINE == IBM_PC)
20927	  DT(ENABLE_NETWORKING,
20928	        net_open,  call_task,   dev_opcl,   INET_PROC_NR)/* 7 = /dev/ip    */
20929	  DT(ENABLE_CDROM,
20930	        dev_opcl,  call_task,   dev_opcl,   CDROM)       /* 8 = /dev/cd0   */
20931	  DT(0, 0,         0,           0,          0)           /* 9 = not used   */
20932	  DT(ENABLE_SCSI,
20933	        dev_opcl,  call_task,   dev_opcl,   SCSI)        /*10 = /dev/sd0   */
20934	  DT(0, 0,         0,           0,          0)           /*11 = not used   */
20935	  DT(0, 0,         0,           0,          0)           /*12 = not used   */
20936	  DT(ENABLE_AUDIO,
20937	        dev_opcl,  call_task,   dev_opcl,   AUDIO)       /*13 = /dev/audio */
20938	  DT(ENABLE_AUDIO,
20939	        dev_opcl,  call_task,   dev_opcl,   MIXER)       /*14 = /dev/mixer */
20940	#endif /* IBM_PC */
20941	
20942	#if (MACHINE == ATARI)
20943	  DT(ENABLE_SCSI,
20944	        dev_opcl,  call_task,   dev_opcl,   SCSI)        /* 7 = /dev/hdscsi0 */
20945	#endif
20946	};
20947	
20948	PUBLIC int max_major = sizeof(dmap)/sizeof(struct dmap);

⌨️ 快捷键说明

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