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

📄 table.c

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

05600	/* The object file of "table.c" contains all the data.  In the *.h files, 
05601	 * declared variables appear with EXTERN in front of them, as in
05602	 *
05603	 *    EXTERN int x;
05604	 *
05605	 * Normally EXTERN is defined as extern, so when they are included in another
05606	 * file, no storage is allocated.  If the EXTERN were not present, but just
05607	 * say,
05608	 *
05609	 *    int x;
05610	 *
05611	 * then including this file in several source files would cause 'x' to be
05612	 * declared several times.  While some linkers accept this, others do not,
05613	 * so they are declared extern when included normally.  However, it must
05614	 * be declared for real somewhere.  That is done here, by redefining
05615	 * EXTERN as the null string, so the inclusion of all the *.h files in
05616	 * table.c actually generates storage for them.  All the initialized
05617	 * variables are also declared here, since
05618	 *
05619	 * extern int x = 4;
05620	 *
05621	 * is not allowed.  If such variables are shared, they must also be declared
05622	 * in one of the *.h files without the initialization.
05623	 */
05624	
05625	#define _TABLE
05626	
05627	#include "kernel.h"
05628	#include <termios.h>
05629	#include <minix/com.h>
05630	#include "proc.h"
05631	#include "tty.h"
05632	
05633	/* The startup routine of each task is given below, from -NR_TASKS upwards.
05634	 * The order of the names here MUST agree with the numerical values assigned to
05635	 * the tasks in <minix/com.h>.
05636	 */
05637	#define SMALL_STACK     (128 * sizeof(char *))
05638	
05639	#define TTY_STACK       (3 * SMALL_STACK)
05640	#define SYN_ALRM_STACK  SMALL_STACK
05641	
05642	#define DP8390_STACK    (SMALL_STACK * ENABLE_NETWORKING)
05643	
05644	#if (CHIP == INTEL)
05645	#define IDLE_STACK      ((3+3+4) * sizeof(char *))  /* 3 intr, 3 temps, 4 db */
05646	#else
05647	#define IDLE_STACK      SMALL_STACK
05648	#endif
05649	
05650	#define PRINTER_STACK   SMALL_STACK
05651	
05652	#if (CHIP == INTEL)
05653	#define WINCH_STACK     (2 * SMALL_STACK * ENABLE_WINI)
05654	#else
05655	#define WINCH_STACK     (3 * SMALL_STACK * ENABLE_WINI)
05656	#endif
05657	
05658	#if (MACHINE == ATARI)
05659	#define SCSI_STACK      (3 * SMALL_STACK)
05660	#endif
05661	
05662	#if (MACHINE == IBM_PC)
05663	#define SCSI_STACK      (2 * SMALL_STACK * ENABLE_SCSI)
05664	#endif
05665	
05666	#define CDROM_STACK     (4 * SMALL_STACK * ENABLE_CDROM)
05667	#define AUDIO_STACK     (4 * SMALL_STACK * ENABLE_AUDIO)
05668	#define MIXER_STACK     (4 * SMALL_STACK * ENABLE_AUDIO)
05669	
05670	#define FLOP_STACK      (3 * SMALL_STACK)
05671	#define MEM_STACK       SMALL_STACK
05672	#define CLOCK_STACK     SMALL_STACK
05673	#define SYS_STACK       SMALL_STACK
05674	#define HARDWARE_STACK  0               /* dummy task, uses kernel stack */
05675	
05676	
05677	#define TOT_STACK_SPACE         (TTY_STACK + DP8390_STACK + SCSI_STACK + \
05678	        SYN_ALRM_STACK + IDLE_STACK + HARDWARE_STACK + PRINTER_STACK + \
05679	        WINCH_STACK + FLOP_STACK + MEM_STACK + CLOCK_STACK + SYS_STACK + \
05680	        CDROM_STACK + AUDIO_STACK + MIXER_STACK)
05681	
05682	
05683	/* SCSI, CDROM and AUDIO may in the future have different choices like
05684	 * WINCHESTER, but for now the choice is fixed.
05685	 */
05686	#define scsi_task       aha_scsi_task
05687	#define cdrom_task      mcd_task
05688	#define audio_task      dsp_task
05689	
05690	
05691	/*
05692	 * Some notes about the following table:
05693	 *  1) The tty_task should always be first so that other tasks can use printf
05694	 *     if their initialisation has problems.
05695	 *  2) If you add a new kernel task, add it before the printer task.
05696	 *  3) The task name is used for the process name (p_name).
05697	 */
05698	
05699	PUBLIC struct tasktab tasktab[] = {
05700	        { tty_task,             TTY_STACK,      "TTY"           },
05701	#if ENABLE_NETWORKING
05702	        { dp8390_task,          DP8390_STACK,   "DP8390"        },
05703	#endif
05704	#if ENABLE_CDROM
05705	        { cdrom_task,           CDROM_STACK,    "CDROM"         },
05706	#endif
05707	#if ENABLE_AUDIO
05708	        { audio_task,           AUDIO_STACK,    "AUDIO"         },
05709	        { mixer_task,           MIXER_STACK,    "MIXER"         },
05710	#endif
05711	#if ENABLE_SCSI
05712	        { scsi_task,            SCSI_STACK,     "SCSI"          },
05713	#endif
05714	#if ENABLE_WINI
05715	        { winchester_task,      WINCH_STACK,    "WINCH"         },
05716	#endif
05717	        { syn_alrm_task,        SYN_ALRM_STACK, "SYN_AL"        },
05718	        { idle_task,            IDLE_STACK,     "IDLE"          },
05719	        { printer_task,         PRINTER_STACK,  "PRINTER"       },
05720	        { floppy_task,          FLOP_STACK,     "FLOPPY"        },
05721	        { mem_task,             MEM_STACK,      "MEMORY"        },
05722	        { clock_task,           CLOCK_STACK,    "CLOCK"         },
05723	        { sys_task,             SYS_STACK,      "SYS"           },
05724	        { 0,                    HARDWARE_STACK, "HARDWAR"       },
05725	        { 0,                    0,              "MM"            },
05726	        { 0,                    0,              "FS"            },
05727	#if ENABLE_NETWORKING
05728	        { 0,                    0,              "INET"          },
05729	#endif
05730	        { 0,                    0,              "INIT"          },
05731	};
05732	
05733	/* Stack space for all the task stacks.  (Declared as (char *) to align it.) */
05734	PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
05735	
05736	/*
05737	 * The number of kernel tasks must be the same as NR_TASKS.
05738	 * If NR_TASKS is not correct then you will get the compile error:
05739	 *   "array size is negative"
05740	 */
05741	
05742	#define NKT (sizeof tasktab / sizeof (struct tasktab) - (INIT_PROC_NR + 1))
05743	
05744	extern int dummy_tasktab_check[NR_TASKS == NKT ? 1 : -1];

⌨️ 快捷键说明

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