The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kernel/table.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* The object file of "table.c" contains most kernel data. Variables that 
    2  * are declared in the *.h files appear with EXTERN in front of them, as in
    3  *
    4  *    EXTERN int x;
    5  *
    6  * Normally EXTERN is defined as extern, so when they are included in another
    7  * file, no storage is allocated.  If EXTERN were not present, but just say,
    8  *
    9  *    int x;
   10  *
   11  * then including this file in several source files would cause 'x' to be
   12  * declared several times.  While some linkers accept this, others do not,
   13  * so they are declared extern when included normally.  However, it must be
   14  * declared for real somewhere.  That is done here, by redefining EXTERN as
   15  * the null string, so that inclusion of all *.h files in table.c actually
   16  * generates storage for them.  
   17  *
   18  * Various variables could not be declared EXTERN, but are declared PUBLIC
   19  * or PRIVATE. The reason for this is that extern variables cannot have a  
   20  * default initialization. If such variables are shared, they must also be
   21  * declared in one of the *.h files without the initialization.  Examples 
   22  * include 'boot_image' (this file) and 'idt' and 'gdt' (protect.c). 
   23  *
   24  * Changes:
   25  *    Aug 02, 2005   set privileges and minimal boot image (Jorrit N. Herder)
   26  *    Oct 17, 2004   updated above and tasktab comments  (Jorrit N. Herder)
   27  *    May 01, 2004   changed struct for system image  (Jorrit N. Herder)
   28  */
   29 #define _TABLE
   30 
   31 #include "kernel.h"
   32 #include "proc.h"
   33 #include "ipc.h"
   34 #include <minix/com.h>
   35 #include <ibm/int86.h>
   36 
   37 /* Define stack sizes for the kernel tasks included in the system image. */
   38 #define NO_STACK        0
   39 #define SMALL_STACK     (128 * sizeof(char *))
   40 #define IDL_S   SMALL_STACK     /* 3 intr, 3 temps, 4 db for Intel */
   41 #define HRD_S   NO_STACK        /* dummy task, uses kernel stack */
   42 #define TSK_S   SMALL_STACK     /* system and clock task */
   43 
   44 /* Stack space for all the task stacks.  Declared as (char *) to align it. */
   45 #define TOT_STACK_SPACE (IDL_S + HRD_S + (2 * TSK_S))
   46 PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
   47         
   48 /* Define flags for the various process types. */
   49 #define IDL_F   (SYS_PROC | PREEMPTIBLE | BILLABLE)     /* idle task */
   50 #define TSK_F   (SYS_PROC)                              /* kernel tasks */
   51 #define SRV_F   (SYS_PROC | PREEMPTIBLE)                /* system services */
   52 #define USR_F   (BILLABLE | PREEMPTIBLE)                /* user processes */
   53 
   54 /* Define system call traps for the various process types. These call masks
   55  * determine what system call traps a process is allowed to make.
   56  */
   57 #define TSK_T   (1 << RECEIVE)                  /* clock and system */
   58 #define SRV_T   (~0)                            /* system services */
   59 #define USR_T   ((1 << SENDREC) | (1 << ECHO))  /* user processes */
   60 
   61 /* Send masks determine to whom processes can send messages or notifications. 
   62  * The values here are used for the processes in the boot image. We rely on 
   63  * the initialization code in main() to match the s_nr_to_id() mapping for the
   64  * processes in the boot image, so that the send mask that is defined here 
   65  * can be directly copied onto map[0] of the actual send mask. Privilege
   66  * structure 0 is shared by user processes. 
   67  */
   68 #define s(n)            (1 << s_nr_to_id(n))
   69 #define SRV_M   (~0)
   70 #define SYS_M   (~0)
   71 #define USR_M (s(PM_PROC_NR) | s(FS_PROC_NR) | s(RS_PROC_NR) | s(SYSTEM))
   72 #define DRV_M (USR_M | s(SYSTEM) | s(CLOCK) | s(DS_PROC_NR) | s(LOG_PROC_NR) | s(TTY_PROC_NR))
   73 
   74 /* Define kernel calls that processes are allowed to make. This is not looking
   75  * very nice, but we need to define the access rights on a per call basis. 
   76  * Note that the reincarnation server has all bits on, because it should
   77  * be allowed to distribute rights to services that it starts. 
   78  */
   79 #define c(n)    (1 << ((n)-KERNEL_CALL))
   80 #define RS_C    ~0      
   81 #define DS_C    ~0      
   82 #define PM_C    ~(c(SYS_DEVIO) | c(SYS_SDEVIO) | c(SYS_VDEVIO) | c(SYS_IRQCTL) | c(SYS_INT86))
   83 #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))
   84 #define DRV_C   (FS_C | c(SYS_SEGCTL) | c(SYS_IRQCTL) | c(SYS_INT86) | c(SYS_DEVIO) | c(SYS_VDEVIO) | c(SYS_SDEVIO)) 
   85 #define TTY_C (DRV_C | c(SYS_ABORT))
   86 #define MEM_C   (DRV_C | c(SYS_PHYSCOPY) | c(SYS_PHYSVCOPY))
   87 
   88 /* The system image table lists all programs that are part of the boot image. 
   89  * The order of the entries here MUST agree with the order of the programs
   90  * in the boot image and all kernel tasks must come first.
   91  * Each entry provides the process number, flags, quantum size (qs), scheduling
   92  * queue, allowed traps, ipc mask, and a name for the process table. The 
   93  * initial program counter and stack size is also provided for kernel tasks.
   94  */
   95 PUBLIC struct boot_image image[] = {
   96 /* process nr,   pc, flags, qs,  queue, stack, traps, ipcto, call,  name */ 
   97  { IDLE,  idle_task, IDL_F,  8, IDLE_Q, IDL_S,     0,     0,     0, "IDLE"  },
   98  { CLOCK,clock_task, TSK_F,  0, TASK_Q, TSK_S, TSK_T,     0,     0, "CLOCK" },
   99  { SYSTEM, sys_task, TSK_F,  0, TASK_Q, TSK_S, TSK_T,     0,     0, "SYSTEM"},
  100  { HARDWARE,      0, TSK_F,  0, TASK_Q, HRD_S,     0,     0,     0, "KERNEL"},
  101  { PM_PROC_NR,    0, SRV_F, 32,      3, 0,     SRV_T, SRV_M,  PM_C, "pm"    },
  102  { FS_PROC_NR,    0, SRV_F, 32,      4, 0,     SRV_T, SRV_M,  FS_C, "fs"    },
  103  { RS_PROC_NR,    0, SRV_F,  4,      3, 0,     SRV_T, SYS_M,  RS_C, "rs"    },
  104  { DS_PROC_NR,    0, SRV_F,  4,      3, 0,     SRV_T, SYS_M,  DS_C, "ds"    },
  105  { TTY_PROC_NR,   0, SRV_F,  4,      1, 0,     SRV_T, SYS_M, TTY_C, "tty"   },
  106  { MEM_PROC_NR,   0, SRV_F,  4,      2, 0,     SRV_T, SYS_M, MEM_C, "memory"},
  107  { LOG_PROC_NR,   0, SRV_F,  4,      2, 0,     SRV_T, SYS_M, DRV_C, "log"   },
  108  { DRVR_PROC_NR,  0, SRV_F,  4,      2, 0,     SRV_T, SYS_M, DRV_C, "driver"},
  109  { INIT_PROC_NR,  0, USR_F,  8, USER_Q, 0,     USR_T, USR_M,     0, "init"  },
  110 };
  111 
  112 /* Verify the size of the system image table at compile time. Also verify that 
  113  * the first chunk of the ipc mask has enough bits to accommodate the processes
  114  * in the image.  
  115  * If a problem is detected, the size of the 'dummy' array will be negative, 
  116  * causing a compile time error. Note that no space is actually allocated 
  117  * because 'dummy' is declared extern.
  118  */
  119 extern int dummy[(NR_BOOT_PROCS==sizeof(image)/
  120         sizeof(struct boot_image))?1:-1];
  121 extern int dummy[(BITCHUNK_BITS > NR_BOOT_PROCS - 1) ? 1 : -1];
  122 

Cache object: a83c98228510b6e936a72e81bcc67008


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.