table.c

Go to the documentation of this file.
00001 /* The object file of "table.c" contains most kernel data. Variables that 
00002  * are declared in the *.h files appear with EXTERN in front of them, as in
00003  *
00004  *    EXTERN int x;
00005  *
00006  * Normally EXTERN is defined as extern, so when they are included in another
00007  * file, no storage is allocated.  If EXTERN were not present, but just say,
00008  *
00009  *    int x;
00010  *
00011  * then including this file in several source files would cause 'x' to be
00012  * declared several times.  While some linkers accept this, others do not,
00013  * so they are declared extern when included normally.  However, it must be
00014  * declared for real somewhere.  That is done here, by redefining EXTERN as
00015  * the null string, so that inclusion of all *.h files in table.c actually
00016  * generates storage for them.  
00017  *
00018  * Various variables could not be declared EXTERN, but are declared PUBLIC
00019  * or PRIVATE. The reason for this is that extern variables cannot have a  
00020  * default initialization. If such variables are shared, they must also be
00021  * declared in one of the *.h files without the initialization.  Examples 
00022  * include 'boot_image' (this file) and 'idt' and 'gdt' (protect.c). 
00023  *
00024  * Changes:
00025  *    Aug 02, 2005   set privileges and minimal boot image (Jorrit N. Herder)
00026  *    Oct 17, 2004   updated above and tasktab comments  (Jorrit N. Herder)
00027  *    May 01, 2004   changed struct for system image  (Jorrit N. Herder)
00028  */
00029 #define _TABLE
00030 
00031 #include "kernel.h"
00032 #include "proc.h"
00033 #include "ipc.h"
00034 #include <minix/com.h>
00035 #include <ibm/int86.h>
00036 
00037 /* Define stack sizes for the kernel tasks included in the system image. */
00038 #define NO_STACK        0
00039 #define SMALL_STACK     (128 * sizeof(char *))
00040 #define IDL_S   SMALL_STACK     /* 3 intr, 3 temps, 4 db for Intel */
00041 #define HRD_S   NO_STACK        /* dummy task, uses kernel stack */
00042 #define TSK_S   SMALL_STACK     /* system and clock task */
00043 
00044 /* Stack space for all the task stacks.  Declared as (char *) to align it. */
00045 #define TOT_STACK_SPACE (IDL_S + HRD_S + (2 * TSK_S))
00046 PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
00047         
00048 /* Define flags for the various process types. */
00049 #define IDL_F   (SYS_PROC | PREEMPTIBLE | BILLABLE)     /* idle task */
00050 #define TSK_F   (SYS_PROC)                              /* kernel tasks */
00051 #define SRV_F   (SYS_PROC | PREEMPTIBLE)                /* system services */
00052 #define USR_F   (BILLABLE | PREEMPTIBLE)                /* user processes */
00053 
00054 /* Define system call traps for the various process types. These call masks
00055  * determine what system call traps a process is allowed to make.
00056  */
00057 #define TSK_T   (1 << RECEIVE)                  /* clock and system */
00058 #define SRV_T   (~0)                            /* system services */
00059 #define USR_T   ((1 << SENDREC) | (1 << ECHO))  /* user processes */
00060 
00061 /* Send masks determine to whom processes can send messages or notifications. 
00062  * The values here are used for the processes in the boot image. We rely on 
00063  * the initialization code in main() to match the s_nr_to_id() mapping for the
00064  * processes in the boot image, so that the send mask that is defined here 
00065  * can be directly copied onto map[0] of the actual send mask. Privilege
00066  * structure 0 is shared by user processes. 
00067  */
00068 #define s(n)            (1 << s_nr_to_id(n))
00069 #define SRV_M   (~0)
00070 #define SYS_M   (~0)
00071 #define USR_M (s(PM_PROC_NR) | s(FS_PROC_NR) | s(RS_PROC_NR) | s(SYSTEM))
00072 #define DRV_M (USR_M | s(SYSTEM) | s(CLOCK) | s(DS_PROC_NR) | s(LOG_PROC_NR) | s(TTY_PROC_NR))
00073 
00074 /* Define kernel calls that processes are allowed to make. This is not looking
00075  * very nice, but we need to define the access rights on a per call basis. 
00076  * Note that the reincarnation server has all bits on, because it should
00077  * be allowed to distribute rights to services that it starts. 
00078  */
00079 #define c(n)    (1 << ((n)-KERNEL_CALL))
00080 #define RS_C    ~0      
00081 #define DS_C    ~0      
00082 #define PM_C    ~(c(SYS_DEVIO) | c(SYS_SDEVIO) | c(SYS_VDEVIO) | c(SYS_IRQCTL) | c(SYS_INT86))
00083 #define FS_C    (c(SYS_KILL) | c(SYS_VIRCOPY) | c(SYS_VIRVCOPY) | c(SYS_UMAP) | c(SYS_GETINFO) | c(SYS_EXIT) | c(SYS_TIMES) | c(SYS_SETALARM))
00084 #define DRV_C (FS_C | c(SYS_SEGCTL) | c(SYS_IRQCTL) | c(SYS_INT86) | c(SYS_DEVIO) | c(SYS_SDEVIO) | c(SYS_VDEVIO))
00085 #define TTY_C (DRV_C | c(SYS_ABORT) | c(SYS_VM_MAP) | c(SYS_IOPENABLE))
00086 #define MEM_C   (DRV_C | c(SYS_PHYSCOPY) | c(SYS_PHYSVCOPY) | c(SYS_VM_MAP) | \
00087         c(SYS_IOPENABLE))
00088 
00089 /* The system image table lists all programs that are part of the boot image. 
00090  * The order of the entries here MUST agree with the order of the programs
00091  * in the boot image and all kernel tasks must come first.
00092  *
00093  * Each entry provides the process number, flags, quantum size, scheduling
00094  * queue, allowed traps, ipc mask, and a name for the process table. The 
00095  * initial program counter and stack size is also provided for kernel tasks.
00096  *
00097  * Note: the quantum size must be positive in all cases! 
00098  */
00099 PUBLIC struct boot_image image[] = {
00100 /* process nr,   pc, flags, qs,  queue, stack, traps, ipcto, call,  name */ 
00101  { IDLE,  idle_task, IDL_F,  8, IDLE_Q, IDL_S,     0,     0,     0, "idle"  },
00102  { CLOCK,clock_task, TSK_F,  8, TASK_Q, TSK_S, TSK_T,     0,     0, "clock" },
00103  { SYSTEM, sys_task, TSK_F,  8, TASK_Q, TSK_S, TSK_T,     0,     0, "system"},
00104  { HARDWARE,      0, TSK_F,  8, TASK_Q, HRD_S,     0,     0,     0, "kernel"},
00105  { PM_PROC_NR,    0, SRV_F, 32,      3, 0,     SRV_T, SRV_M,  PM_C, "pm"    },
00106  { FS_PROC_NR,    0, SRV_F, 32,      4, 0,     SRV_T, SRV_M,  FS_C, "fs"    },
00107  { RS_PROC_NR,    0, SRV_F,  4,      3, 0,     SRV_T, SYS_M,  RS_C, "rs"    },
00108  { DS_PROC_NR,    0, SRV_F,  4,      3, 0,     SRV_T, SYS_M,  DS_C, "ds"    },
00109  { TTY_PROC_NR,   0, SRV_F,  4,      1, 0,     SRV_T, SYS_M, TTY_C, "tty"   },
00110  { MEM_PROC_NR,   0, SRV_F,  4,      2, 0,     SRV_T, SYS_M, MEM_C, "mem"   },
00111  { LOG_PROC_NR,   0, SRV_F,  4,      2, 0,     SRV_T, SYS_M, DRV_C, "log"   },
00112  { INIT_PROC_NR,  0, USR_F,  8, USER_Q, 0,     USR_T, USR_M,     0, "init"  },
00113 };
00114 
00115 /* Verify the size of the system image table at compile time. Also verify that 
00116  * the first chunk of the ipc mask has enough bits to accommodate the processes
00117  * in the image.  
00118  * If a problem is detected, the size of the 'dummy' array will be negative, 
00119  * causing a compile time error. Note that no space is actually allocated 
00120  * because 'dummy' is declared extern.
00121  */
00122 extern int dummy[(NR_BOOT_PROCS==sizeof(image)/
00123         sizeof(struct boot_image))?1:-1];
00124 extern int dummy[(BITCHUNK_BITS > NR_BOOT_PROCS - 1) ? 1 : -1];
00125 

Generated on Fri Apr 14 22:57:24 2006 for minix by  doxygen 1.4.6